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/znet.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/znet.c')
-rw-r--r-- | drivers/net/znet.c | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/drivers/net/znet.c b/drivers/net/znet.c index dcd4e1b136b5..43712c7b9ecf 100644 --- a/drivers/net/znet.c +++ b/drivers/net/znet.c | |||
@@ -128,7 +128,6 @@ MODULE_LICENSE("GPL"); | |||
128 | 128 | ||
129 | struct znet_private { | 129 | struct znet_private { |
130 | int rx_dma, tx_dma; | 130 | int rx_dma, tx_dma; |
131 | struct net_device_stats stats; | ||
132 | spinlock_t lock; | 131 | spinlock_t lock; |
133 | short sia_base, sia_size, io_size; | 132 | short sia_base, sia_size, io_size; |
134 | struct i82593_conf_block i593_init; | 133 | struct i82593_conf_block i593_init; |
@@ -161,7 +160,6 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev); | |||
161 | static irqreturn_t znet_interrupt(int irq, void *dev_id); | 160 | static irqreturn_t znet_interrupt(int irq, void *dev_id); |
162 | static void znet_rx(struct net_device *dev); | 161 | static void znet_rx(struct net_device *dev); |
163 | static int znet_close(struct net_device *dev); | 162 | static int znet_close(struct net_device *dev); |
164 | static struct net_device_stats *net_get_stats(struct net_device *dev); | ||
165 | static void hardware_init(struct net_device *dev); | 163 | static void hardware_init(struct net_device *dev); |
166 | static void update_stop_hit(short ioaddr, unsigned short rx_stop_offset); | 164 | static void update_stop_hit(short ioaddr, unsigned short rx_stop_offset); |
167 | static void znet_tx_timeout (struct net_device *dev); | 165 | static void znet_tx_timeout (struct net_device *dev); |
@@ -445,7 +443,6 @@ static int __init znet_probe (void) | |||
445 | dev->open = &znet_open; | 443 | dev->open = &znet_open; |
446 | dev->hard_start_xmit = &znet_send_packet; | 444 | dev->hard_start_xmit = &znet_send_packet; |
447 | dev->stop = &znet_close; | 445 | dev->stop = &znet_close; |
448 | dev->get_stats = net_get_stats; | ||
449 | dev->set_multicast_list = &znet_set_multicast_list; | 446 | dev->set_multicast_list = &znet_set_multicast_list; |
450 | dev->tx_timeout = znet_tx_timeout; | 447 | dev->tx_timeout = znet_tx_timeout; |
451 | dev->watchdog_timeo = TX_TIMEOUT; | 448 | dev->watchdog_timeo = TX_TIMEOUT; |
@@ -564,7 +561,7 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
564 | ushort *tx_link = znet->tx_cur - 1; | 561 | ushort *tx_link = znet->tx_cur - 1; |
565 | ushort rnd_len = (length + 1)>>1; | 562 | ushort rnd_len = (length + 1)>>1; |
566 | 563 | ||
567 | znet->stats.tx_bytes+=length; | 564 | dev->stats.tx_bytes+=length; |
568 | 565 | ||
569 | if (znet->tx_cur >= znet->tx_end) | 566 | if (znet->tx_cur >= znet->tx_end) |
570 | znet->tx_cur = znet->tx_start; | 567 | znet->tx_cur = znet->tx_start; |
@@ -639,20 +636,20 @@ static irqreturn_t znet_interrupt(int irq, void *dev_id) | |||
639 | tx_status = inw(ioaddr); | 636 | tx_status = inw(ioaddr); |
640 | /* It's undocumented, but tx_status seems to match the i82586. */ | 637 | /* It's undocumented, but tx_status seems to match the i82586. */ |
641 | if (tx_status & TX_OK) { | 638 | if (tx_status & TX_OK) { |
642 | znet->stats.tx_packets++; | 639 | dev->stats.tx_packets++; |
643 | znet->stats.collisions += tx_status & TX_NCOL_MASK; | 640 | dev->stats.collisions += tx_status & TX_NCOL_MASK; |
644 | } else { | 641 | } else { |
645 | if (tx_status & (TX_LOST_CTS | TX_LOST_CRS)) | 642 | if (tx_status & (TX_LOST_CTS | TX_LOST_CRS)) |
646 | znet->stats.tx_carrier_errors++; | 643 | dev->stats.tx_carrier_errors++; |
647 | if (tx_status & TX_UND_RUN) | 644 | if (tx_status & TX_UND_RUN) |
648 | znet->stats.tx_fifo_errors++; | 645 | dev->stats.tx_fifo_errors++; |
649 | if (!(tx_status & TX_HRT_BEAT)) | 646 | if (!(tx_status & TX_HRT_BEAT)) |
650 | znet->stats.tx_heartbeat_errors++; | 647 | dev->stats.tx_heartbeat_errors++; |
651 | if (tx_status & TX_MAX_COL) | 648 | if (tx_status & TX_MAX_COL) |
652 | znet->stats.tx_aborted_errors++; | 649 | dev->stats.tx_aborted_errors++; |
653 | /* ...and the catch-all. */ | 650 | /* ...and the catch-all. */ |
654 | if ((tx_status | (TX_LOST_CRS | TX_LOST_CTS | TX_UND_RUN | TX_HRT_BEAT | TX_MAX_COL)) != (TX_LOST_CRS | TX_LOST_CTS | TX_UND_RUN | TX_HRT_BEAT | TX_MAX_COL)) | 651 | if ((tx_status | (TX_LOST_CRS | TX_LOST_CTS | TX_UND_RUN | TX_HRT_BEAT | TX_MAX_COL)) != (TX_LOST_CRS | TX_LOST_CTS | TX_UND_RUN | TX_HRT_BEAT | TX_MAX_COL)) |
655 | znet->stats.tx_errors++; | 652 | dev->stats.tx_errors++; |
656 | 653 | ||
657 | /* Transceiver may be stuck if cable | 654 | /* Transceiver may be stuck if cable |
658 | * was removed while emiting a | 655 | * was removed while emiting a |
@@ -748,19 +745,19 @@ static void znet_rx(struct net_device *dev) | |||
748 | this_rfp_ptr[-3]<<1); | 745 | this_rfp_ptr[-3]<<1); |
749 | /* Once again we must assume that the i82586 docs apply. */ | 746 | /* Once again we must assume that the i82586 docs apply. */ |
750 | if ( ! (status & RX_RCV_OK)) { /* There was an error. */ | 747 | if ( ! (status & RX_RCV_OK)) { /* There was an error. */ |
751 | znet->stats.rx_errors++; | 748 | dev->stats.rx_errors++; |
752 | if (status & RX_CRC_ERR) znet->stats.rx_crc_errors++; | 749 | if (status & RX_CRC_ERR) dev->stats.rx_crc_errors++; |
753 | if (status & RX_ALG_ERR) znet->stats.rx_frame_errors++; | 750 | if (status & RX_ALG_ERR) dev->stats.rx_frame_errors++; |
754 | #if 0 | 751 | #if 0 |
755 | if (status & 0x0200) znet->stats.rx_over_errors++; /* Wrong. */ | 752 | if (status & 0x0200) dev->stats.rx_over_errors++; /* Wrong. */ |
756 | if (status & 0x0100) znet->stats.rx_fifo_errors++; | 753 | if (status & 0x0100) dev->stats.rx_fifo_errors++; |
757 | #else | 754 | #else |
758 | /* maz : Wild guess... */ | 755 | /* maz : Wild guess... */ |
759 | if (status & RX_OVRRUN) znet->stats.rx_over_errors++; | 756 | if (status & RX_OVRRUN) dev->stats.rx_over_errors++; |
760 | #endif | 757 | #endif |
761 | if (status & RX_SRT_FRM) znet->stats.rx_length_errors++; | 758 | if (status & RX_SRT_FRM) dev->stats.rx_length_errors++; |
762 | } else if (pkt_len > 1536) { | 759 | } else if (pkt_len > 1536) { |
763 | znet->stats.rx_length_errors++; | 760 | dev->stats.rx_length_errors++; |
764 | } else { | 761 | } else { |
765 | /* Malloc up new buffer. */ | 762 | /* Malloc up new buffer. */ |
766 | struct sk_buff *skb; | 763 | struct sk_buff *skb; |
@@ -769,7 +766,7 @@ static void znet_rx(struct net_device *dev) | |||
769 | if (skb == NULL) { | 766 | if (skb == NULL) { |
770 | if (znet_debug) | 767 | if (znet_debug) |
771 | printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); | 768 | printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); |
772 | znet->stats.rx_dropped++; | 769 | dev->stats.rx_dropped++; |
773 | break; | 770 | break; |
774 | } | 771 | } |
775 | 772 | ||
@@ -789,8 +786,8 @@ static void znet_rx(struct net_device *dev) | |||
789 | skb->protocol=eth_type_trans(skb,dev); | 786 | skb->protocol=eth_type_trans(skb,dev); |
790 | netif_rx(skb); | 787 | netif_rx(skb); |
791 | dev->last_rx = jiffies; | 788 | dev->last_rx = jiffies; |
792 | znet->stats.rx_packets++; | 789 | dev->stats.rx_packets++; |
793 | znet->stats.rx_bytes += pkt_len; | 790 | dev->stats.rx_bytes += pkt_len; |
794 | } | 791 | } |
795 | znet->rx_cur = this_rfp_ptr; | 792 | znet->rx_cur = this_rfp_ptr; |
796 | if (znet->rx_cur >= znet->rx_end) | 793 | if (znet->rx_cur >= znet->rx_end) |
@@ -827,15 +824,6 @@ static int znet_close(struct net_device *dev) | |||
827 | return 0; | 824 | return 0; |
828 | } | 825 | } |
829 | 826 | ||
830 | /* Get the current statistics. This may be called with the card open or | ||
831 | closed. */ | ||
832 | static struct net_device_stats *net_get_stats(struct net_device *dev) | ||
833 | { | ||
834 | struct znet_private *znet = dev->priv; | ||
835 | |||
836 | return &znet->stats; | ||
837 | } | ||
838 | |||
839 | static void show_dma(struct net_device *dev) | 827 | static void show_dma(struct net_device *dev) |
840 | { | 828 | { |
841 | short ioaddr = dev->base_addr; | 829 | short ioaddr = dev->base_addr; |