Commit 815f8802 authored by Paulius Zaleckas's avatar Paulius Zaleckas Committed by Jeff Garzik

3c509: use netstats in net_device structure

Use net_device_stats from net_device structure instead of local.
Signed-off-by: default avatarPaulius Zaleckas <paulius.zaleckas@teltonika.lt>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent ba0f6cae
...@@ -167,7 +167,6 @@ enum RxFilter { ...@@ -167,7 +167,6 @@ enum RxFilter {
enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA }; enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA };
struct el3_private { struct el3_private {
struct net_device_stats stats;
spinlock_t lock; spinlock_t lock;
/* skb send-queue */ /* skb send-queue */
int head, size; int head, size;
...@@ -794,7 +793,6 @@ el3_open(struct net_device *dev) ...@@ -794,7 +793,6 @@ el3_open(struct net_device *dev)
static void static void
el3_tx_timeout (struct net_device *dev) el3_tx_timeout (struct net_device *dev)
{ {
struct el3_private *lp = netdev_priv(dev);
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
/* Transmitter timeout, serious problems. */ /* Transmitter timeout, serious problems. */
...@@ -802,7 +800,7 @@ el3_tx_timeout (struct net_device *dev) ...@@ -802,7 +800,7 @@ el3_tx_timeout (struct net_device *dev)
"Tx FIFO room %d.\n", "Tx FIFO room %d.\n",
dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS), dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS),
inw(ioaddr + TX_FREE)); inw(ioaddr + TX_FREE));
lp->stats.tx_errors++; dev->stats.tx_errors++;
dev->trans_start = jiffies; dev->trans_start = jiffies;
/* Issue TX_RESET and TX_START commands. */ /* Issue TX_RESET and TX_START commands. */
outw(TxReset, ioaddr + EL3_CMD); outw(TxReset, ioaddr + EL3_CMD);
...@@ -820,7 +818,7 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -820,7 +818,7 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
netif_stop_queue (dev); netif_stop_queue (dev);
lp->stats.tx_bytes += skb->len; dev->stats.tx_bytes += skb->len;
if (el3_debug > 4) { if (el3_debug > 4) {
printk(KERN_DEBUG "%s: el3_start_xmit(length = %u) called, status %4.4x.\n", 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,7 +879,7 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
int i = 4; int i = 4;
while (--i > 0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { while (--i > 0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) {
if (tx_status & 0x38) lp->stats.tx_aborted_errors++; if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD);
if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD);
outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */
...@@ -931,12 +929,11 @@ el3_interrupt(int irq, void *dev_id) ...@@ -931,12 +929,11 @@ el3_interrupt(int irq, void *dev_id)
outw(AckIntr | RxEarly, ioaddr + EL3_CMD); outw(AckIntr | RxEarly, ioaddr + EL3_CMD);
} }
if (status & TxComplete) { /* Really Tx error. */ if (status & TxComplete) { /* Really Tx error. */
struct el3_private *lp = netdev_priv(dev);
short tx_status; short tx_status;
int i = 4; int i = 4;
while (--i>0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { while (--i>0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) {
if (tx_status & 0x38) lp->stats.tx_aborted_errors++; if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD);
if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD);
outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */
...@@ -1002,7 +999,7 @@ el3_get_stats(struct net_device *dev) ...@@ -1002,7 +999,7 @@ el3_get_stats(struct net_device *dev)
spin_lock_irqsave(&lp->lock, flags); spin_lock_irqsave(&lp->lock, flags);
update_stats(dev); update_stats(dev);
spin_unlock_irqrestore(&lp->lock, flags); spin_unlock_irqrestore(&lp->lock, flags);
return &lp->stats; return &dev->stats;
} }
/* Update statistics. We change to register window 6, so this should be run /* 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,7 +1009,6 @@ el3_get_stats(struct net_device *dev)
*/ */
static void update_stats(struct net_device *dev) static void update_stats(struct net_device *dev)
{ {
struct el3_private *lp = netdev_priv(dev);
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
if (el3_debug > 5) if (el3_debug > 5)
...@@ -1021,13 +1017,13 @@ static void update_stats(struct net_device *dev) ...@@ -1021,13 +1017,13 @@ static void update_stats(struct net_device *dev)
outw(StatsDisable, ioaddr + EL3_CMD); outw(StatsDisable, ioaddr + EL3_CMD);
/* Switch to the stats window, and read everything. */ /* Switch to the stats window, and read everything. */
EL3WINDOW(6); EL3WINDOW(6);
lp->stats.tx_carrier_errors += inb(ioaddr + 0); dev->stats.tx_carrier_errors += inb(ioaddr + 0);
lp->stats.tx_heartbeat_errors += inb(ioaddr + 1); dev->stats.tx_heartbeat_errors += inb(ioaddr + 1);
/* Multiple collisions. */ inb(ioaddr + 2); /* Multiple collisions. */ inb(ioaddr + 2);
lp->stats.collisions += inb(ioaddr + 3); dev->stats.collisions += inb(ioaddr + 3);
lp->stats.tx_window_errors += inb(ioaddr + 4); dev->stats.tx_window_errors += inb(ioaddr + 4);
lp->stats.rx_fifo_errors += inb(ioaddr + 5); dev->stats.rx_fifo_errors += inb(ioaddr + 5);
lp->stats.tx_packets += inb(ioaddr + 6); dev->stats.tx_packets += inb(ioaddr + 6);
/* Rx packets */ inb(ioaddr + 7); /* Rx packets */ inb(ioaddr + 7);
/* Tx deferrals */ inb(ioaddr + 8); /* Tx deferrals */ inb(ioaddr + 8);
inw(ioaddr + 10); /* Total Rx and Tx octets. */ inw(ioaddr + 10); /* Total Rx and Tx octets. */
...@@ -1042,7 +1038,6 @@ static void update_stats(struct net_device *dev) ...@@ -1042,7 +1038,6 @@ static void update_stats(struct net_device *dev)
static int static int
el3_rx(struct net_device *dev) el3_rx(struct net_device *dev)
{ {
struct el3_private *lp = netdev_priv(dev);
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
short rx_status; short rx_status;
...@@ -1054,21 +1049,21 @@ el3_rx(struct net_device *dev) ...@@ -1054,21 +1049,21 @@ el3_rx(struct net_device *dev)
short error = rx_status & 0x3800; short error = rx_status & 0x3800;
outw(RxDiscard, ioaddr + EL3_CMD); outw(RxDiscard, ioaddr + EL3_CMD);
lp->stats.rx_errors++; dev->stats.rx_errors++;
switch (error) { switch (error) {
case 0x0000: lp->stats.rx_over_errors++; break; case 0x0000: dev->stats.rx_over_errors++; break;
case 0x0800: lp->stats.rx_length_errors++; break; case 0x0800: dev->stats.rx_length_errors++; break;
case 0x1000: lp->stats.rx_frame_errors++; break; case 0x1000: dev->stats.rx_frame_errors++; break;
case 0x1800: lp->stats.rx_length_errors++; break; case 0x1800: dev->stats.rx_length_errors++; break;
case 0x2000: lp->stats.rx_frame_errors++; break; case 0x2000: dev->stats.rx_frame_errors++; break;
case 0x2800: lp->stats.rx_crc_errors++; break; case 0x2800: dev->stats.rx_crc_errors++; break;
} }
} else { } else {
short pkt_len = rx_status & 0x7ff; short pkt_len = rx_status & 0x7ff;
struct sk_buff *skb; struct sk_buff *skb;
skb = dev_alloc_skb(pkt_len+5); skb = dev_alloc_skb(pkt_len+5);
lp->stats.rx_bytes += pkt_len; dev->stats.rx_bytes += pkt_len;
if (el3_debug > 4) if (el3_debug > 4)
printk("Receiving packet size %d status %4.4x.\n", printk("Receiving packet size %d status %4.4x.\n",
pkt_len, rx_status); pkt_len, rx_status);
...@@ -1083,11 +1078,11 @@ el3_rx(struct net_device *dev) ...@@ -1083,11 +1078,11 @@ el3_rx(struct net_device *dev)
skb->protocol = eth_type_trans(skb,dev); skb->protocol = eth_type_trans(skb,dev);
netif_rx(skb); netif_rx(skb);
dev->last_rx = jiffies; dev->last_rx = jiffies;
lp->stats.rx_packets++; dev->stats.rx_packets++;
continue; continue;
} }
outw(RxDiscard, ioaddr + EL3_CMD); outw(RxDiscard, ioaddr + EL3_CMD);
lp->stats.rx_dropped++; dev->stats.rx_dropped++;
if (el3_debug) if (el3_debug)
printk("%s: Couldn't allocate a sk_buff of size %d.\n", printk("%s: Couldn't allocate a sk_buff of size %d.\n",
dev->name, pkt_len); dev->name, pkt_len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment