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/ni5010.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/ni5010.c')
-rw-r--r-- | drivers/net/ni5010.c | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c index cc1d09a21c0c..1dc74a78afa6 100644 --- a/drivers/net/ni5010.c +++ b/drivers/net/ni5010.c | |||
@@ -89,7 +89,6 @@ static unsigned int ports[] __initdata = | |||
89 | 89 | ||
90 | /* Information that needs to be kept for each board. */ | 90 | /* Information that needs to be kept for each board. */ |
91 | struct ni5010_local { | 91 | struct ni5010_local { |
92 | struct net_device_stats stats; | ||
93 | int o_pkt_size; | 92 | int o_pkt_size; |
94 | spinlock_t lock; | 93 | spinlock_t lock; |
95 | }; | 94 | }; |
@@ -103,7 +102,6 @@ static irqreturn_t ni5010_interrupt(int irq, void *dev_id); | |||
103 | static void ni5010_rx(struct net_device *dev); | 102 | static void ni5010_rx(struct net_device *dev); |
104 | static void ni5010_timeout(struct net_device *dev); | 103 | static void ni5010_timeout(struct net_device *dev); |
105 | static int ni5010_close(struct net_device *dev); | 104 | static int ni5010_close(struct net_device *dev); |
106 | static struct net_device_stats *ni5010_get_stats(struct net_device *dev); | ||
107 | static void ni5010_set_multicast_list(struct net_device *dev); | 105 | static void ni5010_set_multicast_list(struct net_device *dev); |
108 | static void reset_receiver(struct net_device *dev); | 106 | static void reset_receiver(struct net_device *dev); |
109 | 107 | ||
@@ -334,7 +332,6 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr) | |||
334 | dev->open = ni5010_open; | 332 | dev->open = ni5010_open; |
335 | dev->stop = ni5010_close; | 333 | dev->stop = ni5010_close; |
336 | dev->hard_start_xmit = ni5010_send_packet; | 334 | dev->hard_start_xmit = ni5010_send_packet; |
337 | dev->get_stats = ni5010_get_stats; | ||
338 | dev->set_multicast_list = ni5010_set_multicast_list; | 335 | dev->set_multicast_list = ni5010_set_multicast_list; |
339 | dev->tx_timeout = ni5010_timeout; | 336 | dev->tx_timeout = ni5010_timeout; |
340 | dev->watchdog_timeo = HZ/20; | 337 | dev->watchdog_timeo = HZ/20; |
@@ -532,11 +529,11 @@ static void ni5010_rx(struct net_device *dev) | |||
532 | 529 | ||
533 | if ( (rcv_stat & RS_VALID_BITS) != RS_PKT_OK) { | 530 | if ( (rcv_stat & RS_VALID_BITS) != RS_PKT_OK) { |
534 | PRINTK((KERN_INFO "%s: receive error.\n", dev->name)); | 531 | PRINTK((KERN_INFO "%s: receive error.\n", dev->name)); |
535 | lp->stats.rx_errors++; | 532 | dev->stats.rx_errors++; |
536 | if (rcv_stat & RS_RUNT) lp->stats.rx_length_errors++; | 533 | if (rcv_stat & RS_RUNT) dev->stats.rx_length_errors++; |
537 | if (rcv_stat & RS_ALIGN) lp->stats.rx_frame_errors++; | 534 | if (rcv_stat & RS_ALIGN) dev->stats.rx_frame_errors++; |
538 | if (rcv_stat & RS_CRC_ERR) lp->stats.rx_crc_errors++; | 535 | if (rcv_stat & RS_CRC_ERR) dev->stats.rx_crc_errors++; |
539 | if (rcv_stat & RS_OFLW) lp->stats.rx_fifo_errors++; | 536 | if (rcv_stat & RS_OFLW) dev->stats.rx_fifo_errors++; |
540 | outb(0xff, EDLC_RCLR); /* Clear the interrupt */ | 537 | outb(0xff, EDLC_RCLR); /* Clear the interrupt */ |
541 | return; | 538 | return; |
542 | } | 539 | } |
@@ -547,8 +544,8 @@ static void ni5010_rx(struct net_device *dev) | |||
547 | if (i_pkt_size > ETH_FRAME_LEN || i_pkt_size < 10 ) { | 544 | if (i_pkt_size > ETH_FRAME_LEN || i_pkt_size < 10 ) { |
548 | PRINTK((KERN_DEBUG "%s: Packet size error, packet size = %#4.4x\n", | 545 | PRINTK((KERN_DEBUG "%s: Packet size error, packet size = %#4.4x\n", |
549 | dev->name, i_pkt_size)); | 546 | dev->name, i_pkt_size)); |
550 | lp->stats.rx_errors++; | 547 | dev->stats.rx_errors++; |
551 | lp->stats.rx_length_errors++; | 548 | dev->stats.rx_length_errors++; |
552 | return; | 549 | return; |
553 | } | 550 | } |
554 | 551 | ||
@@ -556,7 +553,7 @@ static void ni5010_rx(struct net_device *dev) | |||
556 | skb = dev_alloc_skb(i_pkt_size + 3); | 553 | skb = dev_alloc_skb(i_pkt_size + 3); |
557 | if (skb == NULL) { | 554 | if (skb == NULL) { |
558 | printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); | 555 | printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); |
559 | lp->stats.rx_dropped++; | 556 | dev->stats.rx_dropped++; |
560 | return; | 557 | return; |
561 | } | 558 | } |
562 | 559 | ||
@@ -573,8 +570,8 @@ static void ni5010_rx(struct net_device *dev) | |||
573 | skb->protocol = eth_type_trans(skb,dev); | 570 | skb->protocol = eth_type_trans(skb,dev); |
574 | netif_rx(skb); | 571 | netif_rx(skb); |
575 | dev->last_rx = jiffies; | 572 | dev->last_rx = jiffies; |
576 | lp->stats.rx_packets++; | 573 | dev->stats.rx_packets++; |
577 | lp->stats.rx_bytes += i_pkt_size; | 574 | dev->stats.rx_bytes += i_pkt_size; |
578 | 575 | ||
579 | PRINTK2((KERN_DEBUG "%s: Received packet, size=%#4.4x\n", | 576 | PRINTK2((KERN_DEBUG "%s: Received packet, size=%#4.4x\n", |
580 | dev->name, i_pkt_size)); | 577 | dev->name, i_pkt_size)); |
@@ -602,14 +599,14 @@ static int process_xmt_interrupt(struct net_device *dev) | |||
602 | /* outb(0, IE_MMODE); */ /* xmt buf on sysbus FIXME: needed ? */ | 599 | /* outb(0, IE_MMODE); */ /* xmt buf on sysbus FIXME: needed ? */ |
603 | outb(MM_EN_XMT | MM_MUX, IE_MMODE); | 600 | outb(MM_EN_XMT | MM_MUX, IE_MMODE); |
604 | outb(XM_ALL, EDLC_XMASK); /* Enable xmt IRQ's */ | 601 | outb(XM_ALL, EDLC_XMASK); /* Enable xmt IRQ's */ |
605 | lp->stats.collisions++; | 602 | dev->stats.collisions++; |
606 | return 1; | 603 | return 1; |
607 | } | 604 | } |
608 | 605 | ||
609 | /* FIXME: handle other xmt error conditions */ | 606 | /* FIXME: handle other xmt error conditions */ |
610 | 607 | ||
611 | lp->stats.tx_packets++; | 608 | dev->stats.tx_packets++; |
612 | lp->stats.tx_bytes += lp->o_pkt_size; | 609 | dev->stats.tx_bytes += lp->o_pkt_size; |
613 | netif_wake_queue(dev); | 610 | netif_wake_queue(dev); |
614 | 611 | ||
615 | PRINTK2((KERN_DEBUG "%s: sent packet, size=%#4.4x\n", | 612 | PRINTK2((KERN_DEBUG "%s: sent packet, size=%#4.4x\n", |
@@ -638,24 +635,6 @@ static int ni5010_close(struct net_device *dev) | |||
638 | 635 | ||
639 | } | 636 | } |
640 | 637 | ||
641 | /* Get the current statistics. This may be called with the card open or | ||
642 | closed. */ | ||
643 | static struct net_device_stats *ni5010_get_stats(struct net_device *dev) | ||
644 | { | ||
645 | struct ni5010_local *lp = netdev_priv(dev); | ||
646 | |||
647 | PRINTK2((KERN_DEBUG "%s: entering ni5010_get_stats\n", dev->name)); | ||
648 | |||
649 | if (NI5010_DEBUG) ni5010_show_registers(dev); | ||
650 | |||
651 | /* cli(); */ | ||
652 | /* Update the statistics from the device registers. */ | ||
653 | /* We do this in the interrupt handler */ | ||
654 | /* sti(); */ | ||
655 | |||
656 | return &lp->stats; | ||
657 | } | ||
658 | |||
659 | /* Set or clear the multicast filter for this adaptor. | 638 | /* Set or clear the multicast filter for this adaptor. |
660 | num_addrs == -1 Promiscuous mode, receive all packets | 639 | num_addrs == -1 Promiscuous mode, receive all packets |
661 | num_addrs == 0 Normal mode, clear multicast list | 640 | num_addrs == 0 Normal mode, clear multicast list |