aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/declance.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/declance.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/declance.c')
-rw-r--r--drivers/net/declance.c52
1 files changed, 21 insertions, 31 deletions
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index b2577f40124e..7e7ac3330e60 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -258,8 +258,6 @@ struct lance_private {
258 int rx_new, tx_new; 258 int rx_new, tx_new;
259 int rx_old, tx_old; 259 int rx_old, tx_old;
260 260
261 struct net_device_stats stats;
262
263 unsigned short busmaster_regval; 261 unsigned short busmaster_regval;
264 262
265 struct timer_list multicast_timer; 263 struct timer_list multicast_timer;
@@ -583,22 +581,22 @@ static int lance_rx(struct net_device *dev)
583 581
584 /* We got an incomplete frame? */ 582 /* We got an incomplete frame? */
585 if ((bits & LE_R1_POK) != LE_R1_POK) { 583 if ((bits & LE_R1_POK) != LE_R1_POK) {
586 lp->stats.rx_over_errors++; 584 dev->stats.rx_over_errors++;
587 lp->stats.rx_errors++; 585 dev->stats.rx_errors++;
588 } else if (bits & LE_R1_ERR) { 586 } else if (bits & LE_R1_ERR) {
589 /* Count only the end frame as a rx error, 587 /* Count only the end frame as a rx error,
590 * not the beginning 588 * not the beginning
591 */ 589 */
592 if (bits & LE_R1_BUF) 590 if (bits & LE_R1_BUF)
593 lp->stats.rx_fifo_errors++; 591 dev->stats.rx_fifo_errors++;
594 if (bits & LE_R1_CRC) 592 if (bits & LE_R1_CRC)
595 lp->stats.rx_crc_errors++; 593 dev->stats.rx_crc_errors++;
596 if (bits & LE_R1_OFL) 594 if (bits & LE_R1_OFL)
597 lp->stats.rx_over_errors++; 595 dev->stats.rx_over_errors++;
598 if (bits & LE_R1_FRA) 596 if (bits & LE_R1_FRA)
599 lp->stats.rx_frame_errors++; 597 dev->stats.rx_frame_errors++;
600 if (bits & LE_R1_EOP) 598 if (bits & LE_R1_EOP)
601 lp->stats.rx_errors++; 599 dev->stats.rx_errors++;
602 } else { 600 } else {
603 len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4; 601 len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4;
604 skb = dev_alloc_skb(len + 2); 602 skb = dev_alloc_skb(len + 2);
@@ -606,7 +604,7 @@ static int lance_rx(struct net_device *dev)
606 if (skb == 0) { 604 if (skb == 0) {
607 printk("%s: Memory squeeze, deferring packet.\n", 605 printk("%s: Memory squeeze, deferring packet.\n",
608 dev->name); 606 dev->name);
609 lp->stats.rx_dropped++; 607 dev->stats.rx_dropped++;
610 *rds_ptr(rd, mblength, lp->type) = 0; 608 *rds_ptr(rd, mblength, lp->type) = 0;
611 *rds_ptr(rd, rmd1, lp->type) = 609 *rds_ptr(rd, rmd1, lp->type) =
612 ((lp->rx_buf_ptr_lnc[entry] >> 16) & 610 ((lp->rx_buf_ptr_lnc[entry] >> 16) &
@@ -614,7 +612,7 @@ static int lance_rx(struct net_device *dev)
614 lp->rx_new = (entry + 1) & RX_RING_MOD_MASK; 612 lp->rx_new = (entry + 1) & RX_RING_MOD_MASK;
615 return 0; 613 return 0;
616 } 614 }
617 lp->stats.rx_bytes += len; 615 dev->stats.rx_bytes += len;
618 616
619 skb_reserve(skb, 2); /* 16 byte align */ 617 skb_reserve(skb, 2); /* 16 byte align */
620 skb_put(skb, len); /* make room */ 618 skb_put(skb, len); /* make room */
@@ -625,7 +623,7 @@ static int lance_rx(struct net_device *dev)
625 skb->protocol = eth_type_trans(skb, dev); 623 skb->protocol = eth_type_trans(skb, dev);
626 netif_rx(skb); 624 netif_rx(skb);
627 dev->last_rx = jiffies; 625 dev->last_rx = jiffies;
628 lp->stats.rx_packets++; 626 dev->stats.rx_packets++;
629 } 627 }
630 628
631 /* Return the packet to the pool */ 629 /* Return the packet to the pool */
@@ -660,14 +658,14 @@ static void lance_tx(struct net_device *dev)
660 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_ERR) { 658 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_ERR) {
661 status = *tds_ptr(td, misc, lp->type); 659 status = *tds_ptr(td, misc, lp->type);
662 660
663 lp->stats.tx_errors++; 661 dev->stats.tx_errors++;
664 if (status & LE_T3_RTY) 662 if (status & LE_T3_RTY)
665 lp->stats.tx_aborted_errors++; 663 dev->stats.tx_aborted_errors++;
666 if (status & LE_T3_LCOL) 664 if (status & LE_T3_LCOL)
667 lp->stats.tx_window_errors++; 665 dev->stats.tx_window_errors++;
668 666
669 if (status & LE_T3_CLOS) { 667 if (status & LE_T3_CLOS) {
670 lp->stats.tx_carrier_errors++; 668 dev->stats.tx_carrier_errors++;
671 printk("%s: Carrier Lost\n", dev->name); 669 printk("%s: Carrier Lost\n", dev->name);
672 /* Stop the lance */ 670 /* Stop the lance */
673 writereg(&ll->rap, LE_CSR0); 671 writereg(&ll->rap, LE_CSR0);
@@ -681,7 +679,7 @@ static void lance_tx(struct net_device *dev)
681 * transmitter, restart the adapter. 679 * transmitter, restart the adapter.
682 */ 680 */
683 if (status & (LE_T3_BUF | LE_T3_UFL)) { 681 if (status & (LE_T3_BUF | LE_T3_UFL)) {
684 lp->stats.tx_fifo_errors++; 682 dev->stats.tx_fifo_errors++;
685 683
686 printk("%s: Tx: ERR_BUF|ERR_UFL, restarting\n", 684 printk("%s: Tx: ERR_BUF|ERR_UFL, restarting\n",
687 dev->name); 685 dev->name);
@@ -702,13 +700,13 @@ static void lance_tx(struct net_device *dev)
702 700
703 /* One collision before packet was sent. */ 701 /* One collision before packet was sent. */
704 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EONE) 702 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EONE)
705 lp->stats.collisions++; 703 dev->stats.collisions++;
706 704
707 /* More than one collision, be optimistic. */ 705 /* More than one collision, be optimistic. */
708 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EMORE) 706 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EMORE)
709 lp->stats.collisions += 2; 707 dev->stats.collisions += 2;
710 708
711 lp->stats.tx_packets++; 709 dev->stats.tx_packets++;
712 } 710 }
713 j = (j + 1) & TX_RING_MOD_MASK; 711 j = (j + 1) & TX_RING_MOD_MASK;
714 } 712 }
@@ -754,10 +752,10 @@ static irqreturn_t lance_interrupt(const int irq, void *dev_id)
754 lance_tx(dev); 752 lance_tx(dev);
755 753
756 if (csr0 & LE_C0_BABL) 754 if (csr0 & LE_C0_BABL)
757 lp->stats.tx_errors++; 755 dev->stats.tx_errors++;
758 756
759 if (csr0 & LE_C0_MISS) 757 if (csr0 & LE_C0_MISS)
760 lp->stats.rx_errors++; 758 dev->stats.rx_errors++;
761 759
762 if (csr0 & LE_C0_MERR) { 760 if (csr0 & LE_C0_MERR) {
763 printk("%s: Memory error, status %04x\n", dev->name, csr0); 761 printk("%s: Memory error, status %04x\n", dev->name, csr0);
@@ -912,7 +910,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
912 len = ETH_ZLEN; 910 len = ETH_ZLEN;
913 } 911 }
914 912
915 lp->stats.tx_bytes += len; 913 dev->stats.tx_bytes += len;
916 914
917 entry = lp->tx_new; 915 entry = lp->tx_new;
918 *lib_ptr(ib, btx_ring[entry].length, lp->type) = (-len); 916 *lib_ptr(ib, btx_ring[entry].length, lp->type) = (-len);
@@ -938,13 +936,6 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
938 return 0; 936 return 0;
939} 937}
940 938
941static struct net_device_stats *lance_get_stats(struct net_device *dev)
942{
943 struct lance_private *lp = netdev_priv(dev);
944
945 return &lp->stats;
946}
947
948static void lance_load_multicast(struct net_device *dev) 939static void lance_load_multicast(struct net_device *dev)
949{ 940{
950 struct lance_private *lp = netdev_priv(dev); 941 struct lance_private *lp = netdev_priv(dev);
@@ -1244,7 +1235,6 @@ static int __init dec_lance_probe(struct device *bdev, const int type)
1244 dev->hard_start_xmit = &lance_start_xmit; 1235 dev->hard_start_xmit = &lance_start_xmit;
1245 dev->tx_timeout = &lance_tx_timeout; 1236 dev->tx_timeout = &lance_tx_timeout;
1246 dev->watchdog_timeo = 5*HZ; 1237 dev->watchdog_timeo = 5*HZ;
1247 dev->get_stats = &lance_get_stats;
1248 dev->set_multicast_list = &lance_set_multicast; 1238 dev->set_multicast_list = &lance_set_multicast;
1249 1239
1250 /* lp->ll is the location of the registers for lance card */ 1240 /* lp->ll is the location of the registers for lance card */