diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-10-03 20:41:50 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:16 -0400 |
commit | 09f75cd7bf13720738e6a196cc0107ce9a5bd5a0 (patch) | |
tree | 4c85b0b395abe7f88c87162fc22570e5de255cb1 /drivers/net/fec.c | |
parent | ff8ac60948ba819b89e9c87083e8050fc2f89999 (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/fec.c')
-rw-r--r-- | drivers/net/fec.c | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 4e8df910c00d..4419c3cee995 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -204,7 +204,6 @@ struct fec_enet_private { | |||
204 | cbd_t *tx_bd_base; | 204 | cbd_t *tx_bd_base; |
205 | cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ | 205 | cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ |
206 | cbd_t *dirty_tx; /* The ring entries to be free()ed. */ | 206 | cbd_t *dirty_tx; /* The ring entries to be free()ed. */ |
207 | struct net_device_stats stats; | ||
208 | uint tx_full; | 207 | uint tx_full; |
209 | spinlock_t lock; | 208 | spinlock_t lock; |
210 | 209 | ||
@@ -234,7 +233,6 @@ static irqreturn_t fec_enet_interrupt(int irq, void * dev_id); | |||
234 | static void fec_enet_tx(struct net_device *dev); | 233 | static void fec_enet_tx(struct net_device *dev); |
235 | static void fec_enet_rx(struct net_device *dev); | 234 | static void fec_enet_rx(struct net_device *dev); |
236 | static int fec_enet_close(struct net_device *dev); | 235 | static int fec_enet_close(struct net_device *dev); |
237 | static struct net_device_stats *fec_enet_get_stats(struct net_device *dev); | ||
238 | static void set_multicast_list(struct net_device *dev); | 236 | static void set_multicast_list(struct net_device *dev); |
239 | static void fec_restart(struct net_device *dev, int duplex); | 237 | static void fec_restart(struct net_device *dev, int duplex); |
240 | static void fec_stop(struct net_device *dev); | 238 | static void fec_stop(struct net_device *dev); |
@@ -359,7 +357,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
359 | */ | 357 | */ |
360 | fep->tx_skbuff[fep->skb_cur] = skb; | 358 | fep->tx_skbuff[fep->skb_cur] = skb; |
361 | 359 | ||
362 | fep->stats.tx_bytes += skb->len; | 360 | dev->stats.tx_bytes += skb->len; |
363 | fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK; | 361 | fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK; |
364 | 362 | ||
365 | /* Push the data cache so the CPM does not get stale memory | 363 | /* Push the data cache so the CPM does not get stale memory |
@@ -409,7 +407,7 @@ fec_timeout(struct net_device *dev) | |||
409 | struct fec_enet_private *fep = netdev_priv(dev); | 407 | struct fec_enet_private *fep = netdev_priv(dev); |
410 | 408 | ||
411 | printk("%s: transmit timed out.\n", dev->name); | 409 | printk("%s: transmit timed out.\n", dev->name); |
412 | fep->stats.tx_errors++; | 410 | dev->stats.tx_errors++; |
413 | #ifndef final_version | 411 | #ifndef final_version |
414 | { | 412 | { |
415 | int i; | 413 | int i; |
@@ -511,19 +509,19 @@ fec_enet_tx(struct net_device *dev) | |||
511 | if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | | 509 | if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | |
512 | BD_ENET_TX_RL | BD_ENET_TX_UN | | 510 | BD_ENET_TX_RL | BD_ENET_TX_UN | |
513 | BD_ENET_TX_CSL)) { | 511 | BD_ENET_TX_CSL)) { |
514 | fep->stats.tx_errors++; | 512 | dev->stats.tx_errors++; |
515 | if (status & BD_ENET_TX_HB) /* No heartbeat */ | 513 | if (status & BD_ENET_TX_HB) /* No heartbeat */ |
516 | fep->stats.tx_heartbeat_errors++; | 514 | dev->stats.tx_heartbeat_errors++; |
517 | if (status & BD_ENET_TX_LC) /* Late collision */ | 515 | if (status & BD_ENET_TX_LC) /* Late collision */ |
518 | fep->stats.tx_window_errors++; | 516 | dev->stats.tx_window_errors++; |
519 | if (status & BD_ENET_TX_RL) /* Retrans limit */ | 517 | if (status & BD_ENET_TX_RL) /* Retrans limit */ |
520 | fep->stats.tx_aborted_errors++; | 518 | dev->stats.tx_aborted_errors++; |
521 | if (status & BD_ENET_TX_UN) /* Underrun */ | 519 | if (status & BD_ENET_TX_UN) /* Underrun */ |
522 | fep->stats.tx_fifo_errors++; | 520 | dev->stats.tx_fifo_errors++; |
523 | if (status & BD_ENET_TX_CSL) /* Carrier lost */ | 521 | if (status & BD_ENET_TX_CSL) /* Carrier lost */ |
524 | fep->stats.tx_carrier_errors++; | 522 | dev->stats.tx_carrier_errors++; |
525 | } else { | 523 | } else { |
526 | fep->stats.tx_packets++; | 524 | dev->stats.tx_packets++; |
527 | } | 525 | } |
528 | 526 | ||
529 | #ifndef final_version | 527 | #ifndef final_version |
@@ -534,7 +532,7 @@ fec_enet_tx(struct net_device *dev) | |||
534 | * but we eventually sent the packet OK. | 532 | * but we eventually sent the packet OK. |
535 | */ | 533 | */ |
536 | if (status & BD_ENET_TX_DEF) | 534 | if (status & BD_ENET_TX_DEF) |
537 | fep->stats.collisions++; | 535 | dev->stats.collisions++; |
538 | 536 | ||
539 | /* Free the sk buffer associated with this last transmit. | 537 | /* Free the sk buffer associated with this last transmit. |
540 | */ | 538 | */ |
@@ -607,17 +605,17 @@ while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) { | |||
607 | /* Check for errors. */ | 605 | /* Check for errors. */ |
608 | if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO | | 606 | if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO | |
609 | BD_ENET_RX_CR | BD_ENET_RX_OV)) { | 607 | BD_ENET_RX_CR | BD_ENET_RX_OV)) { |
610 | fep->stats.rx_errors++; | 608 | dev->stats.rx_errors++; |
611 | if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) { | 609 | if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) { |
612 | /* Frame too long or too short. */ | 610 | /* Frame too long or too short. */ |
613 | fep->stats.rx_length_errors++; | 611 | dev->stats.rx_length_errors++; |
614 | } | 612 | } |
615 | if (status & BD_ENET_RX_NO) /* Frame alignment */ | 613 | if (status & BD_ENET_RX_NO) /* Frame alignment */ |
616 | fep->stats.rx_frame_errors++; | 614 | dev->stats.rx_frame_errors++; |
617 | if (status & BD_ENET_RX_CR) /* CRC Error */ | 615 | if (status & BD_ENET_RX_CR) /* CRC Error */ |
618 | fep->stats.rx_crc_errors++; | 616 | dev->stats.rx_crc_errors++; |
619 | if (status & BD_ENET_RX_OV) /* FIFO overrun */ | 617 | if (status & BD_ENET_RX_OV) /* FIFO overrun */ |
620 | fep->stats.rx_fifo_errors++; | 618 | dev->stats.rx_fifo_errors++; |
621 | } | 619 | } |
622 | 620 | ||
623 | /* Report late collisions as a frame error. | 621 | /* Report late collisions as a frame error. |
@@ -625,16 +623,16 @@ while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) { | |||
625 | * have in the buffer. So, just drop this frame on the floor. | 623 | * have in the buffer. So, just drop this frame on the floor. |
626 | */ | 624 | */ |
627 | if (status & BD_ENET_RX_CL) { | 625 | if (status & BD_ENET_RX_CL) { |
628 | fep->stats.rx_errors++; | 626 | dev->stats.rx_errors++; |
629 | fep->stats.rx_frame_errors++; | 627 | dev->stats.rx_frame_errors++; |
630 | goto rx_processing_done; | 628 | goto rx_processing_done; |
631 | } | 629 | } |
632 | 630 | ||
633 | /* Process the incoming frame. | 631 | /* Process the incoming frame. |
634 | */ | 632 | */ |
635 | fep->stats.rx_packets++; | 633 | dev->stats.rx_packets++; |
636 | pkt_len = bdp->cbd_datlen; | 634 | pkt_len = bdp->cbd_datlen; |
637 | fep->stats.rx_bytes += pkt_len; | 635 | dev->stats.rx_bytes += pkt_len; |
638 | data = (__u8*)__va(bdp->cbd_bufaddr); | 636 | data = (__u8*)__va(bdp->cbd_bufaddr); |
639 | 637 | ||
640 | /* This does 16 byte alignment, exactly what we need. | 638 | /* This does 16 byte alignment, exactly what we need. |
@@ -646,7 +644,7 @@ while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) { | |||
646 | 644 | ||
647 | if (skb == NULL) { | 645 | if (skb == NULL) { |
648 | printk("%s: Memory squeeze, dropping packet.\n", dev->name); | 646 | printk("%s: Memory squeeze, dropping packet.\n", dev->name); |
649 | fep->stats.rx_dropped++; | 647 | dev->stats.rx_dropped++; |
650 | } else { | 648 | } else { |
651 | skb_put(skb,pkt_len-4); /* Make room */ | 649 | skb_put(skb,pkt_len-4); /* Make room */ |
652 | skb_copy_to_linear_data(skb, data, pkt_len-4); | 650 | skb_copy_to_linear_data(skb, data, pkt_len-4); |
@@ -2220,13 +2218,6 @@ fec_enet_close(struct net_device *dev) | |||
2220 | return 0; | 2218 | return 0; |
2221 | } | 2219 | } |
2222 | 2220 | ||
2223 | static struct net_device_stats *fec_enet_get_stats(struct net_device *dev) | ||
2224 | { | ||
2225 | struct fec_enet_private *fep = netdev_priv(dev); | ||
2226 | |||
2227 | return &fep->stats; | ||
2228 | } | ||
2229 | |||
2230 | /* Set or clear the multicast filter for this adaptor. | 2221 | /* Set or clear the multicast filter for this adaptor. |
2231 | * Skeleton taken from sunlance driver. | 2222 | * Skeleton taken from sunlance driver. |
2232 | * The CPM Ethernet implementation allows Multicast as well as individual | 2223 | * The CPM Ethernet implementation allows Multicast as well as individual |
@@ -2462,7 +2453,6 @@ int __init fec_enet_init(struct net_device *dev) | |||
2462 | dev->tx_timeout = fec_timeout; | 2453 | dev->tx_timeout = fec_timeout; |
2463 | dev->watchdog_timeo = TX_TIMEOUT; | 2454 | dev->watchdog_timeo = TX_TIMEOUT; |
2464 | dev->stop = fec_enet_close; | 2455 | dev->stop = fec_enet_close; |
2465 | dev->get_stats = fec_enet_get_stats; | ||
2466 | dev->set_multicast_list = set_multicast_list; | 2456 | dev->set_multicast_list = set_multicast_list; |
2467 | 2457 | ||
2468 | for (i=0; i<NMII-1; i++) | 2458 | for (i=0; i<NMII-1; i++) |