aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/a2065.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/a2065.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/a2065.c')
-rw-r--r--drivers/net/a2065.c51
1 files changed, 21 insertions, 30 deletions
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index fa0c6cb3d798..77773ce52eff 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -119,7 +119,6 @@ struct lance_private {
119 int lance_log_rx_bufs, lance_log_tx_bufs; 119 int lance_log_rx_bufs, lance_log_tx_bufs;
120 int rx_ring_mod_mask, tx_ring_mod_mask; 120 int rx_ring_mod_mask, tx_ring_mod_mask;
121 121
122 struct net_device_stats stats;
123 int tpe; /* cable-selection is TPE */ 122 int tpe; /* cable-selection is TPE */
124 int auto_select; /* cable-selection by carrier */ 123 int auto_select; /* cable-selection by carrier */
125 unsigned short busmaster_regval; 124 unsigned short busmaster_regval;
@@ -294,18 +293,18 @@ static int lance_rx (struct net_device *dev)
294 293
295 /* We got an incomplete frame? */ 294 /* We got an incomplete frame? */
296 if ((bits & LE_R1_POK) != LE_R1_POK) { 295 if ((bits & LE_R1_POK) != LE_R1_POK) {
297 lp->stats.rx_over_errors++; 296 dev->stats.rx_over_errors++;
298 lp->stats.rx_errors++; 297 dev->stats.rx_errors++;
299 continue; 298 continue;
300 } else if (bits & LE_R1_ERR) { 299 } else if (bits & LE_R1_ERR) {
301 /* Count only the end frame as a rx error, 300 /* Count only the end frame as a rx error,
302 * not the beginning 301 * not the beginning
303 */ 302 */
304 if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++; 303 if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++;
305 if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++; 304 if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++;
306 if (bits & LE_R1_OFL) lp->stats.rx_over_errors++; 305 if (bits & LE_R1_OFL) dev->stats.rx_over_errors++;
307 if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++; 306 if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++;
308 if (bits & LE_R1_EOP) lp->stats.rx_errors++; 307 if (bits & LE_R1_EOP) dev->stats.rx_errors++;
309 } else { 308 } else {
310 len = (rd->mblength & 0xfff) - 4; 309 len = (rd->mblength & 0xfff) - 4;
311 skb = dev_alloc_skb (len+2); 310 skb = dev_alloc_skb (len+2);
@@ -313,7 +312,7 @@ static int lance_rx (struct net_device *dev)
313 if (skb == 0) { 312 if (skb == 0) {
314 printk(KERN_WARNING "%s: Memory squeeze, " 313 printk(KERN_WARNING "%s: Memory squeeze, "
315 "deferring packet.\n", dev->name); 314 "deferring packet.\n", dev->name);
316 lp->stats.rx_dropped++; 315 dev->stats.rx_dropped++;
317 rd->mblength = 0; 316 rd->mblength = 0;
318 rd->rmd1_bits = LE_R1_OWN; 317 rd->rmd1_bits = LE_R1_OWN;
319 lp->rx_new = (lp->rx_new + 1) & lp->rx_ring_mod_mask; 318 lp->rx_new = (lp->rx_new + 1) & lp->rx_ring_mod_mask;
@@ -328,8 +327,8 @@ static int lance_rx (struct net_device *dev)
328 skb->protocol = eth_type_trans (skb, dev); 327 skb->protocol = eth_type_trans (skb, dev);
329 netif_rx (skb); 328 netif_rx (skb);
330 dev->last_rx = jiffies; 329 dev->last_rx = jiffies;
331 lp->stats.rx_packets++; 330 dev->stats.rx_packets++;
332 lp->stats.rx_bytes += len; 331 dev->stats.rx_bytes += len;
333 } 332 }
334 333
335 /* Return the packet to the pool */ 334 /* Return the packet to the pool */
@@ -364,12 +363,12 @@ static int lance_tx (struct net_device *dev)
364 if (td->tmd1_bits & LE_T1_ERR) { 363 if (td->tmd1_bits & LE_T1_ERR) {
365 status = td->misc; 364 status = td->misc;
366 365
367 lp->stats.tx_errors++; 366 dev->stats.tx_errors++;
368 if (status & LE_T3_RTY) lp->stats.tx_aborted_errors++; 367 if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++;
369 if (status & LE_T3_LCOL) lp->stats.tx_window_errors++; 368 if (status & LE_T3_LCOL) dev->stats.tx_window_errors++;
370 369
371 if (status & LE_T3_CLOS) { 370 if (status & LE_T3_CLOS) {
372 lp->stats.tx_carrier_errors++; 371 dev->stats.tx_carrier_errors++;
373 if (lp->auto_select) { 372 if (lp->auto_select) {
374 lp->tpe = 1 - lp->tpe; 373 lp->tpe = 1 - lp->tpe;
375 printk(KERN_ERR "%s: Carrier Lost, " 374 printk(KERN_ERR "%s: Carrier Lost, "
@@ -388,7 +387,7 @@ static int lance_tx (struct net_device *dev)
388 /* buffer errors and underflows turn off the transmitter */ 387 /* buffer errors and underflows turn off the transmitter */
389 /* Restart the adapter */ 388 /* Restart the adapter */
390 if (status & (LE_T3_BUF|LE_T3_UFL)) { 389 if (status & (LE_T3_BUF|LE_T3_UFL)) {
391 lp->stats.tx_fifo_errors++; 390 dev->stats.tx_fifo_errors++;
392 391
393 printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, " 392 printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, "
394 "restarting\n", dev->name); 393 "restarting\n", dev->name);
@@ -408,13 +407,13 @@ static int lance_tx (struct net_device *dev)
408 407
409 /* One collision before packet was sent. */ 408 /* One collision before packet was sent. */
410 if (td->tmd1_bits & LE_T1_EONE) 409 if (td->tmd1_bits & LE_T1_EONE)
411 lp->stats.collisions++; 410 dev->stats.collisions++;
412 411
413 /* More than one collision, be optimistic. */ 412 /* More than one collision, be optimistic. */
414 if (td->tmd1_bits & LE_T1_EMORE) 413 if (td->tmd1_bits & LE_T1_EMORE)
415 lp->stats.collisions += 2; 414 dev->stats.collisions += 2;
416 415
417 lp->stats.tx_packets++; 416 dev->stats.tx_packets++;
418 } 417 }
419 418
420 j = (j + 1) & lp->tx_ring_mod_mask; 419 j = (j + 1) & lp->tx_ring_mod_mask;
@@ -459,9 +458,9 @@ static irqreturn_t lance_interrupt (int irq, void *dev_id)
459 458
460 /* Log misc errors. */ 459 /* Log misc errors. */
461 if (csr0 & LE_C0_BABL) 460 if (csr0 & LE_C0_BABL)
462 lp->stats.tx_errors++; /* Tx babble. */ 461 dev->stats.tx_errors++; /* Tx babble. */
463 if (csr0 & LE_C0_MISS) 462 if (csr0 & LE_C0_MISS)
464 lp->stats.rx_errors++; /* Missed a Rx frame. */ 463 dev->stats.rx_errors++; /* Missed a Rx frame. */
465 if (csr0 & LE_C0_MERR) { 464 if (csr0 & LE_C0_MERR) {
466 printk(KERN_ERR "%s: Bus master arbitration failure, status " 465 printk(KERN_ERR "%s: Bus master arbitration failure, status "
467 "%4.4x.\n", dev->name, csr0); 466 "%4.4x.\n", dev->name, csr0);
@@ -606,7 +605,7 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
606 /* Now, give the packet to the lance */ 605 /* Now, give the packet to the lance */
607 ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN); 606 ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN);
608 lp->tx_new = (lp->tx_new+1) & lp->tx_ring_mod_mask; 607 lp->tx_new = (lp->tx_new+1) & lp->tx_ring_mod_mask;
609 lp->stats.tx_bytes += skblen; 608 dev->stats.tx_bytes += skblen;
610 609
611 if (TX_BUFFS_AVAIL <= 0) 610 if (TX_BUFFS_AVAIL <= 0)
612 netif_stop_queue(dev); 611 netif_stop_queue(dev);
@@ -621,13 +620,6 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
621 return status; 620 return status;
622} 621}
623 622
624static struct net_device_stats *lance_get_stats (struct net_device *dev)
625{
626 struct lance_private *lp = netdev_priv(dev);
627
628 return &lp->stats;
629}
630
631/* taken from the depca driver */ 623/* taken from the depca driver */
632static void lance_load_multicast (struct net_device *dev) 624static void lance_load_multicast (struct net_device *dev)
633{ 625{
@@ -782,7 +774,6 @@ static int __devinit a2065_init_one(struct zorro_dev *z,
782 dev->hard_start_xmit = &lance_start_xmit; 774 dev->hard_start_xmit = &lance_start_xmit;
783 dev->tx_timeout = &lance_tx_timeout; 775 dev->tx_timeout = &lance_tx_timeout;
784 dev->watchdog_timeo = 5*HZ; 776 dev->watchdog_timeo = 5*HZ;
785 dev->get_stats = &lance_get_stats;
786 dev->set_multicast_list = &lance_set_multicast; 777 dev->set_multicast_list = &lance_set_multicast;
787 dev->dma = 0; 778 dev->dma = 0;
788 779