提交 dfd44151 编写于 作者: P Paulius Zaleckas 提交者: Jeff Garzik

3c515: use netstats in net_device structure

Use net_device_stats from net_device structure instead of local.
Signed-off-by: NPaulius Zaleckas <paulius.zaleckas@teltonika.lt>
Signed-off-by: NJeff Garzik <jgarzik@redhat.com>
上级 815f8802
...@@ -310,7 +310,6 @@ struct corkscrew_private { ...@@ -310,7 +310,6 @@ struct corkscrew_private {
struct sk_buff *tx_skbuff[TX_RING_SIZE]; struct sk_buff *tx_skbuff[TX_RING_SIZE];
unsigned int cur_rx, cur_tx; /* The next free ring entry */ unsigned int cur_rx, cur_tx; /* The next free ring entry */
unsigned int dirty_rx, dirty_tx;/* The ring entries to be free()ed. */ unsigned int dirty_rx, dirty_tx;/* The ring entries to be free()ed. */
struct net_device_stats stats;
struct sk_buff *tx_skb; /* Packet being eaten by bus master ctrl. */ struct sk_buff *tx_skb; /* Packet being eaten by bus master ctrl. */
struct timer_list timer; /* Media selection timer. */ struct timer_list timer; /* Media selection timer. */
int capabilities ; /* Adapter capabilities word. */ int capabilities ; /* Adapter capabilities word. */
...@@ -983,8 +982,8 @@ static void corkscrew_timeout(struct net_device *dev) ...@@ -983,8 +982,8 @@ static void corkscrew_timeout(struct net_device *dev)
break; break;
outw(TxEnable, ioaddr + EL3_CMD); outw(TxEnable, ioaddr + EL3_CMD);
dev->trans_start = jiffies; dev->trans_start = jiffies;
vp->stats.tx_errors++; dev->stats.tx_errors++;
vp->stats.tx_dropped++; dev->stats.tx_dropped++;
netif_wake_queue(dev); netif_wake_queue(dev);
} }
...@@ -1050,7 +1049,7 @@ static int corkscrew_start_xmit(struct sk_buff *skb, ...@@ -1050,7 +1049,7 @@ static int corkscrew_start_xmit(struct sk_buff *skb,
} }
/* Put out the doubleword header... */ /* Put out the doubleword header... */
outl(skb->len, ioaddr + TX_FIFO); outl(skb->len, ioaddr + TX_FIFO);
vp->stats.tx_bytes += skb->len; dev->stats.tx_bytes += skb->len;
#ifdef VORTEX_BUS_MASTER #ifdef VORTEX_BUS_MASTER
if (vp->bus_master) { if (vp->bus_master) {
/* Set the bus-master controller to transfer the packet. */ /* Set the bus-master controller to transfer the packet. */
...@@ -1094,9 +1093,9 @@ static int corkscrew_start_xmit(struct sk_buff *skb, ...@@ -1094,9 +1093,9 @@ static int corkscrew_start_xmit(struct sk_buff *skb,
printk("%s: Tx error, status %2.2x.\n", printk("%s: Tx error, status %2.2x.\n",
dev->name, tx_status); dev->name, tx_status);
if (tx_status & 0x04) if (tx_status & 0x04)
vp->stats.tx_fifo_errors++; dev->stats.tx_fifo_errors++;
if (tx_status & 0x38) if (tx_status & 0x38)
vp->stats.tx_aborted_errors++; dev->stats.tx_aborted_errors++;
if (tx_status & 0x30) { if (tx_status & 0x30) {
int j; int j;
outw(TxReset, ioaddr + EL3_CMD); outw(TxReset, ioaddr + EL3_CMD);
...@@ -1257,7 +1256,6 @@ static irqreturn_t corkscrew_interrupt(int irq, void *dev_id) ...@@ -1257,7 +1256,6 @@ static irqreturn_t corkscrew_interrupt(int irq, void *dev_id)
static int corkscrew_rx(struct net_device *dev) static int corkscrew_rx(struct net_device *dev)
{ {
struct corkscrew_private *vp = netdev_priv(dev);
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
int i; int i;
short rx_status; short rx_status;
...@@ -1271,17 +1269,17 @@ static int corkscrew_rx(struct net_device *dev) ...@@ -1271,17 +1269,17 @@ static int corkscrew_rx(struct net_device *dev)
if (corkscrew_debug > 2) if (corkscrew_debug > 2)
printk(" Rx error: status %2.2x.\n", printk(" Rx error: status %2.2x.\n",
rx_error); rx_error);
vp->stats.rx_errors++; dev->stats.rx_errors++;
if (rx_error & 0x01) if (rx_error & 0x01)
vp->stats.rx_over_errors++; dev->stats.rx_over_errors++;
if (rx_error & 0x02) if (rx_error & 0x02)
vp->stats.rx_length_errors++; dev->stats.rx_length_errors++;
if (rx_error & 0x04) if (rx_error & 0x04)
vp->stats.rx_frame_errors++; dev->stats.rx_frame_errors++;
if (rx_error & 0x08) if (rx_error & 0x08)
vp->stats.rx_crc_errors++; dev->stats.rx_crc_errors++;
if (rx_error & 0x10) if (rx_error & 0x10)
vp->stats.rx_length_errors++; dev->stats.rx_length_errors++;
} else { } else {
/* The packet length: up to 4.5K!. */ /* The packet length: up to 4.5K!. */
short pkt_len = rx_status & 0x1fff; short pkt_len = rx_status & 0x1fff;
...@@ -1301,8 +1299,8 @@ static int corkscrew_rx(struct net_device *dev) ...@@ -1301,8 +1299,8 @@ static int corkscrew_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;
vp->stats.rx_packets++; dev->stats.rx_packets++;
vp->stats.rx_bytes += pkt_len; dev->stats.rx_bytes += pkt_len;
/* Wait a limited time to go to next packet. */ /* Wait a limited time to go to next packet. */
for (i = 200; i >= 0; i--) for (i = 200; i >= 0; i--)
if (! (inw(ioaddr + EL3_STATUS) & CmdInProgress)) if (! (inw(ioaddr + EL3_STATUS) & CmdInProgress))
...@@ -1312,7 +1310,7 @@ static int corkscrew_rx(struct net_device *dev) ...@@ -1312,7 +1310,7 @@ static int corkscrew_rx(struct net_device *dev)
printk("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, pkt_len); printk("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, pkt_len);
} }
outw(RxDiscard, ioaddr + EL3_CMD); outw(RxDiscard, ioaddr + EL3_CMD);
vp->stats.rx_dropped++; dev->stats.rx_dropped++;
/* Wait a limited time to skip this packet. */ /* Wait a limited time to skip this packet. */
for (i = 200; i >= 0; i--) for (i = 200; i >= 0; i--)
if (!(inw(ioaddr + EL3_STATUS) & CmdInProgress)) if (!(inw(ioaddr + EL3_STATUS) & CmdInProgress))
...@@ -1337,23 +1335,23 @@ static int boomerang_rx(struct net_device *dev) ...@@ -1337,23 +1335,23 @@ static int boomerang_rx(struct net_device *dev)
if (corkscrew_debug > 2) if (corkscrew_debug > 2)
printk(" Rx error: status %2.2x.\n", printk(" Rx error: status %2.2x.\n",
rx_error); rx_error);
vp->stats.rx_errors++; dev->stats.rx_errors++;
if (rx_error & 0x01) if (rx_error & 0x01)
vp->stats.rx_over_errors++; dev->stats.rx_over_errors++;
if (rx_error & 0x02) if (rx_error & 0x02)
vp->stats.rx_length_errors++; dev->stats.rx_length_errors++;
if (rx_error & 0x04) if (rx_error & 0x04)
vp->stats.rx_frame_errors++; dev->stats.rx_frame_errors++;
if (rx_error & 0x08) if (rx_error & 0x08)
vp->stats.rx_crc_errors++; dev->stats.rx_crc_errors++;
if (rx_error & 0x10) if (rx_error & 0x10)
vp->stats.rx_length_errors++; dev->stats.rx_length_errors++;
} else { } else {
/* The packet length: up to 4.5K!. */ /* The packet length: up to 4.5K!. */
short pkt_len = rx_status & 0x1fff; short pkt_len = rx_status & 0x1fff;
struct sk_buff *skb; struct sk_buff *skb;
vp->stats.rx_bytes += pkt_len; dev->stats.rx_bytes += pkt_len;
if (corkscrew_debug > 4) if (corkscrew_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);
...@@ -1388,7 +1386,7 @@ static int boomerang_rx(struct net_device *dev) ...@@ -1388,7 +1386,7 @@ static int boomerang_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;
vp->stats.rx_packets++; dev->stats.rx_packets++;
} }
entry = (++vp->cur_rx) % RX_RING_SIZE; entry = (++vp->cur_rx) % RX_RING_SIZE;
} }
...@@ -1475,7 +1473,7 @@ static struct net_device_stats *corkscrew_get_stats(struct net_device *dev) ...@@ -1475,7 +1473,7 @@ static struct net_device_stats *corkscrew_get_stats(struct net_device *dev)
update_stats(dev->base_addr, dev); update_stats(dev->base_addr, dev);
spin_unlock_irqrestore(&vp->lock, flags); spin_unlock_irqrestore(&vp->lock, flags);
} }
return &vp->stats; return &dev->stats;
} }
/* Update statistics. /* Update statistics.
...@@ -1487,19 +1485,17 @@ static struct net_device_stats *corkscrew_get_stats(struct net_device *dev) ...@@ -1487,19 +1485,17 @@ static struct net_device_stats *corkscrew_get_stats(struct net_device *dev)
*/ */
static void update_stats(int ioaddr, struct net_device *dev) static void update_stats(int ioaddr, struct net_device *dev)
{ {
struct corkscrew_private *vp = netdev_priv(dev);
/* Unlike the 3c5x9 we need not turn off stats updates while reading. */ /* Unlike the 3c5x9 we need not turn off stats updates while reading. */
/* Switch to the stats window, and read everything. */ /* Switch to the stats window, and read everything. */
EL3WINDOW(6); EL3WINDOW(6);
vp->stats.tx_carrier_errors += inb(ioaddr + 0); dev->stats.tx_carrier_errors += inb(ioaddr + 0);
vp->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);
vp->stats.collisions += inb(ioaddr + 3); dev->stats.collisions += inb(ioaddr + 3);
vp->stats.tx_window_errors += inb(ioaddr + 4); dev->stats.tx_window_errors += inb(ioaddr + 4);
vp->stats.rx_fifo_errors += inb(ioaddr + 5); dev->stats.rx_fifo_errors += inb(ioaddr + 5);
vp->stats.tx_packets += inb(ioaddr + 6); dev->stats.tx_packets += inb(ioaddr + 6);
vp->stats.tx_packets += (inb(ioaddr + 9) & 0x30) << 4; dev->stats.tx_packets += (inb(ioaddr + 9) & 0x30) << 4;
/* Rx packets */ inb(ioaddr + 7); /* Rx packets */ inb(ioaddr + 7);
/* Must read to clear */ /* Must read to clear */
/* Tx deferrals */ inb(ioaddr + 8); /* Tx deferrals */ inb(ioaddr + 8);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册