diff options
author | Paulius Zaleckas <paulius.zaleckas@teltonika.lt> | 2008-04-28 19:45:43 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-29 01:55:12 -0400 |
commit | 815f8802d201aba1ce343ba832daf639165f01a1 (patch) | |
tree | 6516c07ff9ab68af426445f745dc36280a4602e3 /drivers/net/3c509.c | |
parent | ba0f6caeb5d9cf6fbb99f84ff0f2731f04996595 (diff) |
3c509: use netstats in net_device structure
Use net_device_stats from net_device structure instead of local.
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/3c509.c')
-rw-r--r-- | drivers/net/3c509.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c index 54dac0696d91..e6c545fe5f58 100644 --- a/drivers/net/3c509.c +++ b/drivers/net/3c509.c | |||
@@ -167,7 +167,6 @@ enum RxFilter { | |||
167 | enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA }; | 167 | enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA }; |
168 | 168 | ||
169 | struct el3_private { | 169 | struct el3_private { |
170 | struct net_device_stats stats; | ||
171 | spinlock_t lock; | 170 | spinlock_t lock; |
172 | /* skb send-queue */ | 171 | /* skb send-queue */ |
173 | int head, size; | 172 | int head, size; |
@@ -794,7 +793,6 @@ el3_open(struct net_device *dev) | |||
794 | static void | 793 | static void |
795 | el3_tx_timeout (struct net_device *dev) | 794 | el3_tx_timeout (struct net_device *dev) |
796 | { | 795 | { |
797 | struct el3_private *lp = netdev_priv(dev); | ||
798 | int ioaddr = dev->base_addr; | 796 | int ioaddr = dev->base_addr; |
799 | 797 | ||
800 | /* Transmitter timeout, serious problems. */ | 798 | /* Transmitter timeout, serious problems. */ |
@@ -802,7 +800,7 @@ el3_tx_timeout (struct net_device *dev) | |||
802 | "Tx FIFO room %d.\n", | 800 | "Tx FIFO room %d.\n", |
803 | dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS), | 801 | dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS), |
804 | inw(ioaddr + TX_FREE)); | 802 | inw(ioaddr + TX_FREE)); |
805 | lp->stats.tx_errors++; | 803 | dev->stats.tx_errors++; |
806 | dev->trans_start = jiffies; | 804 | dev->trans_start = jiffies; |
807 | /* Issue TX_RESET and TX_START commands. */ | 805 | /* Issue TX_RESET and TX_START commands. */ |
808 | outw(TxReset, ioaddr + EL3_CMD); | 806 | outw(TxReset, ioaddr + EL3_CMD); |
@@ -820,7 +818,7 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
820 | 818 | ||
821 | netif_stop_queue (dev); | 819 | netif_stop_queue (dev); |
822 | 820 | ||
823 | lp->stats.tx_bytes += skb->len; | 821 | dev->stats.tx_bytes += skb->len; |
824 | 822 | ||
825 | if (el3_debug > 4) { | 823 | if (el3_debug > 4) { |
826 | printk(KERN_DEBUG "%s: el3_start_xmit(length = %u) called, status %4.4x.\n", | 824 | printk(KERN_DEBUG "%s: el3_start_xmit(length = %u) called, status %4.4x.\n", |
@@ -881,7 +879,7 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
881 | int i = 4; | 879 | int i = 4; |
882 | 880 | ||
883 | while (--i > 0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { | 881 | while (--i > 0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { |
884 | if (tx_status & 0x38) lp->stats.tx_aborted_errors++; | 882 | if (tx_status & 0x38) dev->stats.tx_aborted_errors++; |
885 | if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); | 883 | if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); |
886 | if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); | 884 | if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); |
887 | outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ | 885 | outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ |
@@ -931,12 +929,11 @@ el3_interrupt(int irq, void *dev_id) | |||
931 | outw(AckIntr | RxEarly, ioaddr + EL3_CMD); | 929 | outw(AckIntr | RxEarly, ioaddr + EL3_CMD); |
932 | } | 930 | } |
933 | if (status & TxComplete) { /* Really Tx error. */ | 931 | if (status & TxComplete) { /* Really Tx error. */ |
934 | struct el3_private *lp = netdev_priv(dev); | ||
935 | short tx_status; | 932 | short tx_status; |
936 | int i = 4; | 933 | int i = 4; |
937 | 934 | ||
938 | while (--i>0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { | 935 | while (--i>0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { |
939 | if (tx_status & 0x38) lp->stats.tx_aborted_errors++; | 936 | if (tx_status & 0x38) dev->stats.tx_aborted_errors++; |
940 | if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); | 937 | if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); |
941 | if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); | 938 | if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); |
942 | outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ | 939 | outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ |
@@ -1002,7 +999,7 @@ el3_get_stats(struct net_device *dev) | |||
1002 | spin_lock_irqsave(&lp->lock, flags); | 999 | spin_lock_irqsave(&lp->lock, flags); |
1003 | update_stats(dev); | 1000 | update_stats(dev); |
1004 | spin_unlock_irqrestore(&lp->lock, flags); | 1001 | spin_unlock_irqrestore(&lp->lock, flags); |
1005 | return &lp->stats; | 1002 | return &dev->stats; |
1006 | } | 1003 | } |
1007 | 1004 | ||
1008 | /* Update statistics. We change to register window 6, so this should be run | 1005 | /* Update statistics. We change to register window 6, so this should be run |
@@ -1012,7 +1009,6 @@ el3_get_stats(struct net_device *dev) | |||
1012 | */ | 1009 | */ |
1013 | static void update_stats(struct net_device *dev) | 1010 | static void update_stats(struct net_device *dev) |
1014 | { | 1011 | { |
1015 | struct el3_private *lp = netdev_priv(dev); | ||
1016 | int ioaddr = dev->base_addr; | 1012 | int ioaddr = dev->base_addr; |
1017 | 1013 | ||
1018 | if (el3_debug > 5) | 1014 | if (el3_debug > 5) |
@@ -1021,13 +1017,13 @@ static void update_stats(struct net_device *dev) | |||
1021 | outw(StatsDisable, ioaddr + EL3_CMD); | 1017 | outw(StatsDisable, ioaddr + EL3_CMD); |
1022 | /* Switch to the stats window, and read everything. */ | 1018 | /* Switch to the stats window, and read everything. */ |
1023 | EL3WINDOW(6); | 1019 | EL3WINDOW(6); |
1024 | lp->stats.tx_carrier_errors += inb(ioaddr + 0); | 1020 | dev->stats.tx_carrier_errors += inb(ioaddr + 0); |
1025 | lp->stats.tx_heartbeat_errors += inb(ioaddr + 1); | 1021 | dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); |
1026 | /* Multiple collisions. */ inb(ioaddr + 2); | 1022 | /* Multiple collisions. */ inb(ioaddr + 2); |
1027 | lp->stats.collisions += inb(ioaddr + 3); | 1023 | dev->stats.collisions += inb(ioaddr + 3); |
1028 | lp->stats.tx_window_errors += inb(ioaddr + 4); | 1024 | dev->stats.tx_window_errors += inb(ioaddr + 4); |
1029 | lp->stats.rx_fifo_errors += inb(ioaddr + 5); | 1025 | dev->stats.rx_fifo_errors += inb(ioaddr + 5); |
1030 | lp->stats.tx_packets += inb(ioaddr + 6); | 1026 | dev->stats.tx_packets += inb(ioaddr + 6); |
1031 | /* Rx packets */ inb(ioaddr + 7); | 1027 | /* Rx packets */ inb(ioaddr + 7); |
1032 | /* Tx deferrals */ inb(ioaddr + 8); | 1028 | /* Tx deferrals */ inb(ioaddr + 8); |
1033 | inw(ioaddr + 10); /* Total Rx and Tx octets. */ | 1029 | inw(ioaddr + 10); /* Total Rx and Tx octets. */ |
@@ -1042,7 +1038,6 @@ static void update_stats(struct net_device *dev) | |||
1042 | static int | 1038 | static int |
1043 | el3_rx(struct net_device *dev) | 1039 | el3_rx(struct net_device *dev) |
1044 | { | 1040 | { |
1045 | struct el3_private *lp = netdev_priv(dev); | ||
1046 | int ioaddr = dev->base_addr; | 1041 | int ioaddr = dev->base_addr; |
1047 | short rx_status; | 1042 | short rx_status; |
1048 | 1043 | ||
@@ -1054,21 +1049,21 @@ el3_rx(struct net_device *dev) | |||
1054 | short error = rx_status & 0x3800; | 1049 | short error = rx_status & 0x3800; |
1055 | 1050 | ||
1056 | outw(RxDiscard, ioaddr + EL3_CMD); | 1051 | outw(RxDiscard, ioaddr + EL3_CMD); |
1057 | lp->stats.rx_errors++; | 1052 | dev->stats.rx_errors++; |
1058 | switch (error) { | 1053 | switch (error) { |
1059 | case 0x0000: lp->stats.rx_over_errors++; break; | 1054 | case 0x0000: dev->stats.rx_over_errors++; break; |
1060 | case 0x0800: lp->stats.rx_length_errors++; break; | 1055 | case 0x0800: dev->stats.rx_length_errors++; break; |
1061 | case 0x1000: lp->stats.rx_frame_errors++; break; | 1056 | case 0x1000: dev->stats.rx_frame_errors++; break; |
1062 | case 0x1800: lp->stats.rx_length_errors++; break; | 1057 | case 0x1800: dev->stats.rx_length_errors++; break; |
1063 | case 0x2000: lp->stats.rx_frame_errors++; break; | 1058 | case 0x2000: dev->stats.rx_frame_errors++; break; |
1064 | case 0x2800: lp->stats.rx_crc_errors++; break; | 1059 | case 0x2800: dev->stats.rx_crc_errors++; break; |
1065 | } | 1060 | } |
1066 | } else { | 1061 | } else { |
1067 | short pkt_len = rx_status & 0x7ff; | 1062 | short pkt_len = rx_status & 0x7ff; |
1068 | struct sk_buff *skb; | 1063 | struct sk_buff *skb; |
1069 | 1064 | ||
1070 | skb = dev_alloc_skb(pkt_len+5); | 1065 | skb = dev_alloc_skb(pkt_len+5); |
1071 | lp->stats.rx_bytes += pkt_len; | 1066 | dev->stats.rx_bytes += pkt_len; |
1072 | if (el3_debug > 4) | 1067 | if (el3_debug > 4) |
1073 | printk("Receiving packet size %d status %4.4x.\n", | 1068 | printk("Receiving packet size %d status %4.4x.\n", |
1074 | pkt_len, rx_status); | 1069 | pkt_len, rx_status); |
@@ -1083,11 +1078,11 @@ el3_rx(struct net_device *dev) | |||
1083 | skb->protocol = eth_type_trans(skb,dev); | 1078 | skb->protocol = eth_type_trans(skb,dev); |
1084 | netif_rx(skb); | 1079 | netif_rx(skb); |
1085 | dev->last_rx = jiffies; | 1080 | dev->last_rx = jiffies; |
1086 | lp->stats.rx_packets++; | 1081 | dev->stats.rx_packets++; |
1087 | continue; | 1082 | continue; |
1088 | } | 1083 | } |
1089 | outw(RxDiscard, ioaddr + EL3_CMD); | 1084 | outw(RxDiscard, ioaddr + EL3_CMD); |
1090 | lp->stats.rx_dropped++; | 1085 | dev->stats.rx_dropped++; |
1091 | if (el3_debug) | 1086 | if (el3_debug) |
1092 | printk("%s: Couldn't allocate a sk_buff of size %d.\n", | 1087 | printk("%s: Couldn't allocate a sk_buff of size %d.\n", |
1093 | dev->name, pkt_len); | 1088 | dev->name, pkt_len); |