aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mace.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-10-03 20:41:50 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:51:16 -0400
commit09f75cd7bf13720738e6a196cc0107ce9a5bd5a0 (patch)
tree4c85b0b395abe7f88c87162fc22570e5de255cb1 /drivers/net/mace.c
parentff8ac60948ba819b89e9c87083e8050fc2f89999 (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/mace.c')
-rw-r--r--drivers/net/mace.c59
1 files changed, 24 insertions, 35 deletions
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index de3b002e9a4c..ee132b1e09b0 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -57,7 +57,6 @@ struct mace_data {
57 unsigned char tx_fullup; 57 unsigned char tx_fullup;
58 unsigned char tx_active; 58 unsigned char tx_active;
59 unsigned char tx_bad_runt; 59 unsigned char tx_bad_runt;
60 struct net_device_stats stats;
61 struct timer_list tx_timeout; 60 struct timer_list tx_timeout;
62 int timeout_active; 61 int timeout_active;
63 int port_aaui; 62 int port_aaui;
@@ -78,7 +77,6 @@ struct mace_data {
78static int mace_open(struct net_device *dev); 77static int mace_open(struct net_device *dev);
79static int mace_close(struct net_device *dev); 78static int mace_close(struct net_device *dev);
80static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev); 79static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev);
81static struct net_device_stats *mace_stats(struct net_device *dev);
82static void mace_set_multicast(struct net_device *dev); 80static void mace_set_multicast(struct net_device *dev);
83static void mace_reset(struct net_device *dev); 81static void mace_reset(struct net_device *dev);
84static int mace_set_address(struct net_device *dev, void *addr); 82static int mace_set_address(struct net_device *dev, void *addr);
@@ -188,7 +186,6 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
188 mp->tx_cmds = (volatile struct dbdma_cmd *) DBDMA_ALIGN(mp + 1); 186 mp->tx_cmds = (volatile struct dbdma_cmd *) DBDMA_ALIGN(mp + 1);
189 mp->rx_cmds = mp->tx_cmds + NCMDS_TX * N_TX_RING + 1; 187 mp->rx_cmds = mp->tx_cmds + NCMDS_TX * N_TX_RING + 1;
190 188
191 memset(&mp->stats, 0, sizeof(mp->stats));
192 memset((char *) mp->tx_cmds, 0, 189 memset((char *) mp->tx_cmds, 0,
193 (NCMDS_TX*N_TX_RING + N_RX_RING + 2) * sizeof(struct dbdma_cmd)); 190 (NCMDS_TX*N_TX_RING + N_RX_RING + 2) * sizeof(struct dbdma_cmd));
194 init_timer(&mp->tx_timeout); 191 init_timer(&mp->tx_timeout);
@@ -213,7 +210,6 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
213 dev->open = mace_open; 210 dev->open = mace_open;
214 dev->stop = mace_close; 211 dev->stop = mace_close;
215 dev->hard_start_xmit = mace_xmit_start; 212 dev->hard_start_xmit = mace_xmit_start;
216 dev->get_stats = mace_stats;
217 dev->set_multicast_list = mace_set_multicast; 213 dev->set_multicast_list = mace_set_multicast;
218 dev->set_mac_address = mace_set_address; 214 dev->set_mac_address = mace_set_address;
219 215
@@ -584,13 +580,6 @@ static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev)
584 return 0; 580 return 0;
585} 581}
586 582
587static struct net_device_stats *mace_stats(struct net_device *dev)
588{
589 struct mace_data *p = (struct mace_data *) dev->priv;
590
591 return &p->stats;
592}
593
594static void mace_set_multicast(struct net_device *dev) 583static void mace_set_multicast(struct net_device *dev)
595{ 584{
596 struct mace_data *mp = (struct mace_data *) dev->priv; 585 struct mace_data *mp = (struct mace_data *) dev->priv;
@@ -644,19 +633,19 @@ static void mace_set_multicast(struct net_device *dev)
644 spin_unlock_irqrestore(&mp->lock, flags); 633 spin_unlock_irqrestore(&mp->lock, flags);
645} 634}
646 635
647static void mace_handle_misc_intrs(struct mace_data *mp, int intr) 636static void mace_handle_misc_intrs(struct mace_data *mp, int intr, struct net_device *dev)
648{ 637{
649 volatile struct mace __iomem *mb = mp->mace; 638 volatile struct mace __iomem *mb = mp->mace;
650 static int mace_babbles, mace_jabbers; 639 static int mace_babbles, mace_jabbers;
651 640
652 if (intr & MPCO) 641 if (intr & MPCO)
653 mp->stats.rx_missed_errors += 256; 642 dev->stats.rx_missed_errors += 256;
654 mp->stats.rx_missed_errors += in_8(&mb->mpc); /* reading clears it */ 643 dev->stats.rx_missed_errors += in_8(&mb->mpc); /* reading clears it */
655 if (intr & RNTPCO) 644 if (intr & RNTPCO)
656 mp->stats.rx_length_errors += 256; 645 dev->stats.rx_length_errors += 256;
657 mp->stats.rx_length_errors += in_8(&mb->rntpc); /* reading clears it */ 646 dev->stats.rx_length_errors += in_8(&mb->rntpc); /* reading clears it */
658 if (intr & CERR) 647 if (intr & CERR)
659 ++mp->stats.tx_heartbeat_errors; 648 ++dev->stats.tx_heartbeat_errors;
660 if (intr & BABBLE) 649 if (intr & BABBLE)
661 if (mace_babbles++ < 4) 650 if (mace_babbles++ < 4)
662 printk(KERN_DEBUG "mace: babbling transmitter\n"); 651 printk(KERN_DEBUG "mace: babbling transmitter\n");
@@ -680,7 +669,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
680 spin_lock_irqsave(&mp->lock, flags); 669 spin_lock_irqsave(&mp->lock, flags);
681 intr = in_8(&mb->ir); /* read interrupt register */ 670 intr = in_8(&mb->ir); /* read interrupt register */
682 in_8(&mb->xmtrc); /* get retries */ 671 in_8(&mb->xmtrc); /* get retries */
683 mace_handle_misc_intrs(mp, intr); 672 mace_handle_misc_intrs(mp, intr, dev);
684 673
685 i = mp->tx_empty; 674 i = mp->tx_empty;
686 while (in_8(&mb->pr) & XMTSV) { 675 while (in_8(&mb->pr) & XMTSV) {
@@ -693,7 +682,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
693 */ 682 */
694 intr = in_8(&mb->ir); 683 intr = in_8(&mb->ir);
695 if (intr != 0) 684 if (intr != 0)
696 mace_handle_misc_intrs(mp, intr); 685 mace_handle_misc_intrs(mp, intr, dev);
697 if (mp->tx_bad_runt) { 686 if (mp->tx_bad_runt) {
698 fs = in_8(&mb->xmtfs); 687 fs = in_8(&mb->xmtfs);
699 mp->tx_bad_runt = 0; 688 mp->tx_bad_runt = 0;
@@ -767,14 +756,14 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
767 } 756 }
768 /* Update stats */ 757 /* Update stats */
769 if (fs & (UFLO|LCOL|LCAR|RTRY)) { 758 if (fs & (UFLO|LCOL|LCAR|RTRY)) {
770 ++mp->stats.tx_errors; 759 ++dev->stats.tx_errors;
771 if (fs & LCAR) 760 if (fs & LCAR)
772 ++mp->stats.tx_carrier_errors; 761 ++dev->stats.tx_carrier_errors;
773 if (fs & (UFLO|LCOL|RTRY)) 762 if (fs & (UFLO|LCOL|RTRY))
774 ++mp->stats.tx_aborted_errors; 763 ++dev->stats.tx_aborted_errors;
775 } else { 764 } else {
776 mp->stats.tx_bytes += mp->tx_bufs[i]->len; 765 dev->stats.tx_bytes += mp->tx_bufs[i]->len;
777 ++mp->stats.tx_packets; 766 ++dev->stats.tx_packets;
778 } 767 }
779 dev_kfree_skb_irq(mp->tx_bufs[i]); 768 dev_kfree_skb_irq(mp->tx_bufs[i]);
780 --mp->tx_active; 769 --mp->tx_active;
@@ -828,7 +817,7 @@ static void mace_tx_timeout(unsigned long data)
828 goto out; 817 goto out;
829 818
830 /* update various counters */ 819 /* update various counters */
831 mace_handle_misc_intrs(mp, in_8(&mb->ir)); 820 mace_handle_misc_intrs(mp, in_8(&mb->ir), dev);
832 821
833 cp = mp->tx_cmds + NCMDS_TX * mp->tx_empty; 822 cp = mp->tx_cmds + NCMDS_TX * mp->tx_empty;
834 823
@@ -848,7 +837,7 @@ static void mace_tx_timeout(unsigned long data)
848 /* fix up the transmit side */ 837 /* fix up the transmit side */
849 i = mp->tx_empty; 838 i = mp->tx_empty;
850 mp->tx_active = 0; 839 mp->tx_active = 0;
851 ++mp->stats.tx_errors; 840 ++dev->stats.tx_errors;
852 if (mp->tx_bad_runt) { 841 if (mp->tx_bad_runt) {
853 mp->tx_bad_runt = 0; 842 mp->tx_bad_runt = 0;
854 } else if (i != mp->tx_fill) { 843 } else if (i != mp->tx_fill) {
@@ -916,18 +905,18 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id)
916 /* got a packet, have a look at it */ 905 /* got a packet, have a look at it */
917 skb = mp->rx_bufs[i]; 906 skb = mp->rx_bufs[i];
918 if (skb == 0) { 907 if (skb == 0) {
919 ++mp->stats.rx_dropped; 908 ++dev->stats.rx_dropped;
920 } else if (nb > 8) { 909 } else if (nb > 8) {
921 data = skb->data; 910 data = skb->data;
922 frame_status = (data[nb-3] << 8) + data[nb-4]; 911 frame_status = (data[nb-3] << 8) + data[nb-4];
923 if (frame_status & (RS_OFLO|RS_CLSN|RS_FRAMERR|RS_FCSERR)) { 912 if (frame_status & (RS_OFLO|RS_CLSN|RS_FRAMERR|RS_FCSERR)) {
924 ++mp->stats.rx_errors; 913 ++dev->stats.rx_errors;
925 if (frame_status & RS_OFLO) 914 if (frame_status & RS_OFLO)
926 ++mp->stats.rx_over_errors; 915 ++dev->stats.rx_over_errors;
927 if (frame_status & RS_FRAMERR) 916 if (frame_status & RS_FRAMERR)
928 ++mp->stats.rx_frame_errors; 917 ++dev->stats.rx_frame_errors;
929 if (frame_status & RS_FCSERR) 918 if (frame_status & RS_FCSERR)
930 ++mp->stats.rx_crc_errors; 919 ++dev->stats.rx_crc_errors;
931 } else { 920 } else {
932 /* Mace feature AUTO_STRIP_RCV is on by default, dropping the 921 /* Mace feature AUTO_STRIP_RCV is on by default, dropping the
933 * FCS on frames with 802.3 headers. This means that Ethernet 922 * FCS on frames with 802.3 headers. This means that Ethernet
@@ -939,15 +928,15 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id)
939 nb -= 8; 928 nb -= 8;
940 skb_put(skb, nb); 929 skb_put(skb, nb);
941 skb->protocol = eth_type_trans(skb, dev); 930 skb->protocol = eth_type_trans(skb, dev);
942 mp->stats.rx_bytes += skb->len; 931 dev->stats.rx_bytes += skb->len;
943 netif_rx(skb); 932 netif_rx(skb);
944 dev->last_rx = jiffies; 933 dev->last_rx = jiffies;
945 mp->rx_bufs[i] = NULL; 934 mp->rx_bufs[i] = NULL;
946 ++mp->stats.rx_packets; 935 ++dev->stats.rx_packets;
947 } 936 }
948 } else { 937 } else {
949 ++mp->stats.rx_errors; 938 ++dev->stats.rx_errors;
950 ++mp->stats.rx_length_errors; 939 ++dev->stats.rx_length_errors;
951 } 940 }
952 941
953 /* advance to next */ 942 /* advance to next */