diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-10-03 20:41:50 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:16 -0400 |
commit | 09f75cd7bf13720738e6a196cc0107ce9a5bd5a0 (patch) | |
tree | 4c85b0b395abe7f88c87162fc22570e5de255cb1 /drivers/net/eepro.c | |
parent | ff8ac60948ba819b89e9c87083e8050fc2f89999 (diff) |
[NET] drivers/net: statistics cleanup #1 -- save memory and shrink code
We now have struct net_device_stats embedded in struct net_device,
and the default ->get_stats() hook does the obvious thing for us.
Run through drivers/net/* and remove the driver-local storage of
statistics, and driver-local ->get_stats() hook where applicable.
This was just the low-hanging fruit in drivers/net; plenty more drivers
remain to be updated.
[ Resolved conflicts with napi_struct changes and fix sunqe build
regression... -DaveM ]
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/eepro.c')
-rw-r--r-- | drivers/net/eepro.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c index 6eb84f14c88d..54811f6f766d 100644 --- a/drivers/net/eepro.c +++ b/drivers/net/eepro.c | |||
@@ -192,7 +192,6 @@ static unsigned int net_debug = NET_DEBUG; | |||
192 | 192 | ||
193 | /* Information that need to be kept for each board. */ | 193 | /* Information that need to be kept for each board. */ |
194 | struct eepro_local { | 194 | struct eepro_local { |
195 | struct net_device_stats stats; | ||
196 | unsigned rx_start; | 195 | unsigned rx_start; |
197 | unsigned tx_start; /* start of the transmit chain */ | 196 | unsigned tx_start; /* start of the transmit chain */ |
198 | int tx_last; /* pointer to last packet in the transmit chain */ | 197 | int tx_last; /* pointer to last packet in the transmit chain */ |
@@ -315,7 +314,6 @@ static irqreturn_t eepro_interrupt(int irq, void *dev_id); | |||
315 | static void eepro_rx(struct net_device *dev); | 314 | static void eepro_rx(struct net_device *dev); |
316 | static void eepro_transmit_interrupt(struct net_device *dev); | 315 | static void eepro_transmit_interrupt(struct net_device *dev); |
317 | static int eepro_close(struct net_device *dev); | 316 | static int eepro_close(struct net_device *dev); |
318 | static struct net_device_stats *eepro_get_stats(struct net_device *dev); | ||
319 | static void set_multicast_list(struct net_device *dev); | 317 | static void set_multicast_list(struct net_device *dev); |
320 | static void eepro_tx_timeout (struct net_device *dev); | 318 | static void eepro_tx_timeout (struct net_device *dev); |
321 | 319 | ||
@@ -514,7 +512,7 @@ buffer (transmit-buffer = 32K - receive-buffer). | |||
514 | 512 | ||
515 | /* a complete sel reset */ | 513 | /* a complete sel reset */ |
516 | #define eepro_complete_selreset(ioaddr) { \ | 514 | #define eepro_complete_selreset(ioaddr) { \ |
517 | lp->stats.tx_errors++;\ | 515 | dev->stats.tx_errors++;\ |
518 | eepro_sel_reset(ioaddr);\ | 516 | eepro_sel_reset(ioaddr);\ |
519 | lp->tx_end = \ | 517 | lp->tx_end = \ |
520 | lp->xmt_lower_limit;\ | 518 | lp->xmt_lower_limit;\ |
@@ -856,7 +854,6 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe) | |||
856 | dev->open = eepro_open; | 854 | dev->open = eepro_open; |
857 | dev->stop = eepro_close; | 855 | dev->stop = eepro_close; |
858 | dev->hard_start_xmit = eepro_send_packet; | 856 | dev->hard_start_xmit = eepro_send_packet; |
859 | dev->get_stats = eepro_get_stats; | ||
860 | dev->set_multicast_list = &set_multicast_list; | 857 | dev->set_multicast_list = &set_multicast_list; |
861 | dev->tx_timeout = eepro_tx_timeout; | 858 | dev->tx_timeout = eepro_tx_timeout; |
862 | dev->watchdog_timeo = TX_TIMEOUT; | 859 | dev->watchdog_timeo = TX_TIMEOUT; |
@@ -1154,9 +1151,9 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1154 | 1151 | ||
1155 | if (hardware_send_packet(dev, buf, length)) | 1152 | if (hardware_send_packet(dev, buf, length)) |
1156 | /* we won't wake queue here because we're out of space */ | 1153 | /* we won't wake queue here because we're out of space */ |
1157 | lp->stats.tx_dropped++; | 1154 | dev->stats.tx_dropped++; |
1158 | else { | 1155 | else { |
1159 | lp->stats.tx_bytes+=skb->len; | 1156 | dev->stats.tx_bytes+=skb->len; |
1160 | dev->trans_start = jiffies; | 1157 | dev->trans_start = jiffies; |
1161 | netif_wake_queue(dev); | 1158 | netif_wake_queue(dev); |
1162 | } | 1159 | } |
@@ -1166,7 +1163,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1166 | dev_kfree_skb (skb); | 1163 | dev_kfree_skb (skb); |
1167 | 1164 | ||
1168 | /* You might need to clean up and record Tx statistics here. */ | 1165 | /* You might need to clean up and record Tx statistics here. */ |
1169 | /* lp->stats.tx_aborted_errors++; */ | 1166 | /* dev->stats.tx_aborted_errors++; */ |
1170 | 1167 | ||
1171 | if (net_debug > 5) | 1168 | if (net_debug > 5) |
1172 | printk(KERN_DEBUG "%s: exiting eepro_send_packet routine.\n", dev->name); | 1169 | printk(KERN_DEBUG "%s: exiting eepro_send_packet routine.\n", dev->name); |
@@ -1273,16 +1270,6 @@ static int eepro_close(struct net_device *dev) | |||
1273 | return 0; | 1270 | return 0; |
1274 | } | 1271 | } |
1275 | 1272 | ||
1276 | /* Get the current statistics. This may be called with the card open or | ||
1277 | closed. */ | ||
1278 | static struct net_device_stats * | ||
1279 | eepro_get_stats(struct net_device *dev) | ||
1280 | { | ||
1281 | struct eepro_local *lp = netdev_priv(dev); | ||
1282 | |||
1283 | return &lp->stats; | ||
1284 | } | ||
1285 | |||
1286 | /* Set or clear the multicast filter for this adaptor. | 1273 | /* Set or clear the multicast filter for this adaptor. |
1287 | */ | 1274 | */ |
1288 | static void | 1275 | static void |
@@ -1575,12 +1562,12 @@ eepro_rx(struct net_device *dev) | |||
1575 | /* Malloc up new buffer. */ | 1562 | /* Malloc up new buffer. */ |
1576 | struct sk_buff *skb; | 1563 | struct sk_buff *skb; |
1577 | 1564 | ||
1578 | lp->stats.rx_bytes+=rcv_size; | 1565 | dev->stats.rx_bytes+=rcv_size; |
1579 | rcv_size &= 0x3fff; | 1566 | rcv_size &= 0x3fff; |
1580 | skb = dev_alloc_skb(rcv_size+5); | 1567 | skb = dev_alloc_skb(rcv_size+5); |
1581 | if (skb == NULL) { | 1568 | if (skb == NULL) { |
1582 | printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); | 1569 | printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); |
1583 | lp->stats.rx_dropped++; | 1570 | dev->stats.rx_dropped++; |
1584 | rcv_car = lp->rx_start + RCV_HEADER + rcv_size; | 1571 | rcv_car = lp->rx_start + RCV_HEADER + rcv_size; |
1585 | lp->rx_start = rcv_next_frame; | 1572 | lp->rx_start = rcv_next_frame; |
1586 | outw(rcv_next_frame, ioaddr + HOST_ADDRESS_REG); | 1573 | outw(rcv_next_frame, ioaddr + HOST_ADDRESS_REG); |
@@ -1602,28 +1589,28 @@ eepro_rx(struct net_device *dev) | |||
1602 | skb->protocol = eth_type_trans(skb,dev); | 1589 | skb->protocol = eth_type_trans(skb,dev); |
1603 | netif_rx(skb); | 1590 | netif_rx(skb); |
1604 | dev->last_rx = jiffies; | 1591 | dev->last_rx = jiffies; |
1605 | lp->stats.rx_packets++; | 1592 | dev->stats.rx_packets++; |
1606 | } | 1593 | } |
1607 | 1594 | ||
1608 | else { /* Not sure will ever reach here, | 1595 | else { /* Not sure will ever reach here, |
1609 | I set the 595 to discard bad received frames */ | 1596 | I set the 595 to discard bad received frames */ |
1610 | lp->stats.rx_errors++; | 1597 | dev->stats.rx_errors++; |
1611 | 1598 | ||
1612 | if (rcv_status & 0x0100) | 1599 | if (rcv_status & 0x0100) |
1613 | lp->stats.rx_over_errors++; | 1600 | dev->stats.rx_over_errors++; |
1614 | 1601 | ||
1615 | else if (rcv_status & 0x0400) | 1602 | else if (rcv_status & 0x0400) |
1616 | lp->stats.rx_frame_errors++; | 1603 | dev->stats.rx_frame_errors++; |
1617 | 1604 | ||
1618 | else if (rcv_status & 0x0800) | 1605 | else if (rcv_status & 0x0800) |
1619 | lp->stats.rx_crc_errors++; | 1606 | dev->stats.rx_crc_errors++; |
1620 | 1607 | ||
1621 | printk(KERN_DEBUG "%s: event = %#x, status = %#x, next = %#x, size = %#x\n", | 1608 | printk(KERN_DEBUG "%s: event = %#x, status = %#x, next = %#x, size = %#x\n", |
1622 | dev->name, rcv_event, rcv_status, rcv_next_frame, rcv_size); | 1609 | dev->name, rcv_event, rcv_status, rcv_next_frame, rcv_size); |
1623 | } | 1610 | } |
1624 | 1611 | ||
1625 | if (rcv_status & 0x1000) | 1612 | if (rcv_status & 0x1000) |
1626 | lp->stats.rx_length_errors++; | 1613 | dev->stats.rx_length_errors++; |
1627 | 1614 | ||
1628 | rcv_car = lp->rx_start + RCV_HEADER + rcv_size; | 1615 | rcv_car = lp->rx_start + RCV_HEADER + rcv_size; |
1629 | lp->rx_start = rcv_next_frame; | 1616 | lp->rx_start = rcv_next_frame; |
@@ -1666,11 +1653,11 @@ eepro_transmit_interrupt(struct net_device *dev) | |||
1666 | netif_wake_queue (dev); | 1653 | netif_wake_queue (dev); |
1667 | 1654 | ||
1668 | if (xmt_status & TX_OK) | 1655 | if (xmt_status & TX_OK) |
1669 | lp->stats.tx_packets++; | 1656 | dev->stats.tx_packets++; |
1670 | else { | 1657 | else { |
1671 | lp->stats.tx_errors++; | 1658 | dev->stats.tx_errors++; |
1672 | if (xmt_status & 0x0400) { | 1659 | if (xmt_status & 0x0400) { |
1673 | lp->stats.tx_carrier_errors++; | 1660 | dev->stats.tx_carrier_errors++; |
1674 | printk(KERN_DEBUG "%s: carrier error\n", | 1661 | printk(KERN_DEBUG "%s: carrier error\n", |
1675 | dev->name); | 1662 | dev->name); |
1676 | printk(KERN_DEBUG "%s: XMT status = %#x\n", | 1663 | printk(KERN_DEBUG "%s: XMT status = %#x\n", |
@@ -1684,11 +1671,11 @@ eepro_transmit_interrupt(struct net_device *dev) | |||
1684 | } | 1671 | } |
1685 | } | 1672 | } |
1686 | if (xmt_status & 0x000f) { | 1673 | if (xmt_status & 0x000f) { |
1687 | lp->stats.collisions += (xmt_status & 0x000f); | 1674 | dev->stats.collisions += (xmt_status & 0x000f); |
1688 | } | 1675 | } |
1689 | 1676 | ||
1690 | if ((xmt_status & 0x0040) == 0x0) { | 1677 | if ((xmt_status & 0x0040) == 0x0) { |
1691 | lp->stats.tx_heartbeat_errors++; | 1678 | dev->stats.tx_heartbeat_errors++; |
1692 | } | 1679 | } |
1693 | } | 1680 | } |
1694 | } | 1681 | } |