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/smc91x.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/smc91x.c')
-rw-r--r-- | drivers/net/smc91x.c | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c index c5837ab5c96b..fe28d277f21a 100644 --- a/drivers/net/smc91x.c +++ b/drivers/net/smc91x.c | |||
@@ -183,13 +183,6 @@ struct smc_local { | |||
183 | struct sk_buff *pending_tx_skb; | 183 | struct sk_buff *pending_tx_skb; |
184 | struct tasklet_struct tx_task; | 184 | struct tasklet_struct tx_task; |
185 | 185 | ||
186 | /* | ||
187 | * these are things that the kernel wants me to keep, so users | ||
188 | * can find out semi-useless statistics of how well the card is | ||
189 | * performing | ||
190 | */ | ||
191 | struct net_device_stats stats; | ||
192 | |||
193 | /* version/revision of the SMC91x chip */ | 186 | /* version/revision of the SMC91x chip */ |
194 | int version; | 187 | int version; |
195 | 188 | ||
@@ -332,8 +325,8 @@ static void smc_reset(struct net_device *dev) | |||
332 | /* free any pending tx skb */ | 325 | /* free any pending tx skb */ |
333 | if (pending_skb) { | 326 | if (pending_skb) { |
334 | dev_kfree_skb(pending_skb); | 327 | dev_kfree_skb(pending_skb); |
335 | lp->stats.tx_errors++; | 328 | dev->stats.tx_errors++; |
336 | lp->stats.tx_aborted_errors++; | 329 | dev->stats.tx_aborted_errors++; |
337 | } | 330 | } |
338 | 331 | ||
339 | /* | 332 | /* |
@@ -512,13 +505,13 @@ static inline void smc_rcv(struct net_device *dev) | |||
512 | } | 505 | } |
513 | SMC_WAIT_MMU_BUSY(); | 506 | SMC_WAIT_MMU_BUSY(); |
514 | SMC_SET_MMU_CMD(MC_RELEASE); | 507 | SMC_SET_MMU_CMD(MC_RELEASE); |
515 | lp->stats.rx_errors++; | 508 | dev->stats.rx_errors++; |
516 | if (status & RS_ALGNERR) | 509 | if (status & RS_ALGNERR) |
517 | lp->stats.rx_frame_errors++; | 510 | dev->stats.rx_frame_errors++; |
518 | if (status & (RS_TOOSHORT | RS_TOOLONG)) | 511 | if (status & (RS_TOOSHORT | RS_TOOLONG)) |
519 | lp->stats.rx_length_errors++; | 512 | dev->stats.rx_length_errors++; |
520 | if (status & RS_BADCRC) | 513 | if (status & RS_BADCRC) |
521 | lp->stats.rx_crc_errors++; | 514 | dev->stats.rx_crc_errors++; |
522 | } else { | 515 | } else { |
523 | struct sk_buff *skb; | 516 | struct sk_buff *skb; |
524 | unsigned char *data; | 517 | unsigned char *data; |
@@ -526,7 +519,7 @@ static inline void smc_rcv(struct net_device *dev) | |||
526 | 519 | ||
527 | /* set multicast stats */ | 520 | /* set multicast stats */ |
528 | if (status & RS_MULTICAST) | 521 | if (status & RS_MULTICAST) |
529 | lp->stats.multicast++; | 522 | dev->stats.multicast++; |
530 | 523 | ||
531 | /* | 524 | /* |
532 | * Actual payload is packet_len - 6 (or 5 if odd byte). | 525 | * Actual payload is packet_len - 6 (or 5 if odd byte). |
@@ -542,7 +535,7 @@ static inline void smc_rcv(struct net_device *dev) | |||
542 | dev->name); | 535 | dev->name); |
543 | SMC_WAIT_MMU_BUSY(); | 536 | SMC_WAIT_MMU_BUSY(); |
544 | SMC_SET_MMU_CMD(MC_RELEASE); | 537 | SMC_SET_MMU_CMD(MC_RELEASE); |
545 | lp->stats.rx_dropped++; | 538 | dev->stats.rx_dropped++; |
546 | return; | 539 | return; |
547 | } | 540 | } |
548 | 541 | ||
@@ -570,8 +563,8 @@ static inline void smc_rcv(struct net_device *dev) | |||
570 | dev->last_rx = jiffies; | 563 | dev->last_rx = jiffies; |
571 | skb->protocol = eth_type_trans(skb, dev); | 564 | skb->protocol = eth_type_trans(skb, dev); |
572 | netif_rx(skb); | 565 | netif_rx(skb); |
573 | lp->stats.rx_packets++; | 566 | dev->stats.rx_packets++; |
574 | lp->stats.rx_bytes += data_len; | 567 | dev->stats.rx_bytes += data_len; |
575 | } | 568 | } |
576 | } | 569 | } |
577 | 570 | ||
@@ -644,8 +637,8 @@ static void smc_hardware_send_pkt(unsigned long data) | |||
644 | packet_no = SMC_GET_AR(); | 637 | packet_no = SMC_GET_AR(); |
645 | if (unlikely(packet_no & AR_FAILED)) { | 638 | if (unlikely(packet_no & AR_FAILED)) { |
646 | printk("%s: Memory allocation failed.\n", dev->name); | 639 | printk("%s: Memory allocation failed.\n", dev->name); |
647 | lp->stats.tx_errors++; | 640 | dev->stats.tx_errors++; |
648 | lp->stats.tx_fifo_errors++; | 641 | dev->stats.tx_fifo_errors++; |
649 | smc_special_unlock(&lp->lock); | 642 | smc_special_unlock(&lp->lock); |
650 | goto done; | 643 | goto done; |
651 | } | 644 | } |
@@ -688,8 +681,8 @@ static void smc_hardware_send_pkt(unsigned long data) | |||
688 | smc_special_unlock(&lp->lock); | 681 | smc_special_unlock(&lp->lock); |
689 | 682 | ||
690 | dev->trans_start = jiffies; | 683 | dev->trans_start = jiffies; |
691 | lp->stats.tx_packets++; | 684 | dev->stats.tx_packets++; |
692 | lp->stats.tx_bytes += len; | 685 | dev->stats.tx_bytes += len; |
693 | 686 | ||
694 | SMC_ENABLE_INT(IM_TX_INT | IM_TX_EMPTY_INT); | 687 | SMC_ENABLE_INT(IM_TX_INT | IM_TX_EMPTY_INT); |
695 | 688 | ||
@@ -729,8 +722,8 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
729 | numPages = ((skb->len & ~1) + (6 - 1)) >> 8; | 722 | numPages = ((skb->len & ~1) + (6 - 1)) >> 8; |
730 | if (unlikely(numPages > 7)) { | 723 | if (unlikely(numPages > 7)) { |
731 | printk("%s: Far too big packet error.\n", dev->name); | 724 | printk("%s: Far too big packet error.\n", dev->name); |
732 | lp->stats.tx_errors++; | 725 | dev->stats.tx_errors++; |
733 | lp->stats.tx_dropped++; | 726 | dev->stats.tx_dropped++; |
734 | dev_kfree_skb(skb); | 727 | dev_kfree_skb(skb); |
735 | return 0; | 728 | return 0; |
736 | } | 729 | } |
@@ -803,17 +796,17 @@ static void smc_tx(struct net_device *dev) | |||
803 | dev->name, tx_status, packet_no); | 796 | dev->name, tx_status, packet_no); |
804 | 797 | ||
805 | if (!(tx_status & ES_TX_SUC)) | 798 | if (!(tx_status & ES_TX_SUC)) |
806 | lp->stats.tx_errors++; | 799 | dev->stats.tx_errors++; |
807 | 800 | ||
808 | if (tx_status & ES_LOSTCARR) | 801 | if (tx_status & ES_LOSTCARR) |
809 | lp->stats.tx_carrier_errors++; | 802 | dev->stats.tx_carrier_errors++; |
810 | 803 | ||
811 | if (tx_status & (ES_LATCOL | ES_16COL)) { | 804 | if (tx_status & (ES_LATCOL | ES_16COL)) { |
812 | PRINTK("%s: %s occurred on last xmit\n", dev->name, | 805 | PRINTK("%s: %s occurred on last xmit\n", dev->name, |
813 | (tx_status & ES_LATCOL) ? | 806 | (tx_status & ES_LATCOL) ? |
814 | "late collision" : "too many collisions"); | 807 | "late collision" : "too many collisions"); |
815 | lp->stats.tx_window_errors++; | 808 | dev->stats.tx_window_errors++; |
816 | if (!(lp->stats.tx_window_errors & 63) && net_ratelimit()) { | 809 | if (!(dev->stats.tx_window_errors & 63) && net_ratelimit()) { |
817 | printk(KERN_INFO "%s: unexpectedly large number of " | 810 | printk(KERN_INFO "%s: unexpectedly large number of " |
818 | "bad collisions. Please check duplex " | 811 | "bad collisions. Please check duplex " |
819 | "setting.\n", dev->name); | 812 | "setting.\n", dev->name); |
@@ -1347,19 +1340,19 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id) | |||
1347 | SMC_SELECT_BANK(2); | 1340 | SMC_SELECT_BANK(2); |
1348 | 1341 | ||
1349 | /* single collisions */ | 1342 | /* single collisions */ |
1350 | lp->stats.collisions += card_stats & 0xF; | 1343 | dev->stats.collisions += card_stats & 0xF; |
1351 | card_stats >>= 4; | 1344 | card_stats >>= 4; |
1352 | 1345 | ||
1353 | /* multiple collisions */ | 1346 | /* multiple collisions */ |
1354 | lp->stats.collisions += card_stats & 0xF; | 1347 | dev->stats.collisions += card_stats & 0xF; |
1355 | } else if (status & IM_RX_OVRN_INT) { | 1348 | } else if (status & IM_RX_OVRN_INT) { |
1356 | DBG(1, "%s: RX overrun (EPH_ST 0x%04x)\n", dev->name, | 1349 | DBG(1, "%s: RX overrun (EPH_ST 0x%04x)\n", dev->name, |
1357 | ({ int eph_st; SMC_SELECT_BANK(0); | 1350 | ({ int eph_st; SMC_SELECT_BANK(0); |
1358 | eph_st = SMC_GET_EPH_STATUS(); | 1351 | eph_st = SMC_GET_EPH_STATUS(); |
1359 | SMC_SELECT_BANK(2); eph_st; }) ); | 1352 | SMC_SELECT_BANK(2); eph_st; }) ); |
1360 | SMC_ACK_INT(IM_RX_OVRN_INT); | 1353 | SMC_ACK_INT(IM_RX_OVRN_INT); |
1361 | lp->stats.rx_errors++; | 1354 | dev->stats.rx_errors++; |
1362 | lp->stats.rx_fifo_errors++; | 1355 | dev->stats.rx_fifo_errors++; |
1363 | } else if (status & IM_EPH_INT) { | 1356 | } else if (status & IM_EPH_INT) { |
1364 | smc_eph_interrupt(dev); | 1357 | smc_eph_interrupt(dev); |
1365 | } else if (status & IM_MDINT) { | 1358 | } else if (status & IM_MDINT) { |
@@ -1628,19 +1621,6 @@ static int smc_close(struct net_device *dev) | |||
1628 | } | 1621 | } |
1629 | 1622 | ||
1630 | /* | 1623 | /* |
1631 | * Get the current statistics. | ||
1632 | * This may be called with the card open or closed. | ||
1633 | */ | ||
1634 | static struct net_device_stats *smc_query_statistics(struct net_device *dev) | ||
1635 | { | ||
1636 | struct smc_local *lp = netdev_priv(dev); | ||
1637 | |||
1638 | DBG(2, "%s: %s\n", dev->name, __FUNCTION__); | ||
1639 | |||
1640 | return &lp->stats; | ||
1641 | } | ||
1642 | |||
1643 | /* | ||
1644 | * Ethtool support | 1624 | * Ethtool support |
1645 | */ | 1625 | */ |
1646 | static int | 1626 | static int |
@@ -1965,7 +1945,6 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr) | |||
1965 | dev->hard_start_xmit = smc_hard_start_xmit; | 1945 | dev->hard_start_xmit = smc_hard_start_xmit; |
1966 | dev->tx_timeout = smc_timeout; | 1946 | dev->tx_timeout = smc_timeout; |
1967 | dev->watchdog_timeo = msecs_to_jiffies(watchdog); | 1947 | dev->watchdog_timeo = msecs_to_jiffies(watchdog); |
1968 | dev->get_stats = smc_query_statistics; | ||
1969 | dev->set_multicast_list = smc_set_multicast_list; | 1948 | dev->set_multicast_list = smc_set_multicast_list; |
1970 | dev->ethtool_ops = &smc_ethtool_ops; | 1949 | dev->ethtool_ops = &smc_ethtool_ops; |
1971 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1950 | #ifdef CONFIG_NET_POLL_CONTROLLER |