aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/atp.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/atp.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/atp.c')
-rw-r--r--drivers/net/atp.c49
1 files changed, 18 insertions, 31 deletions
diff --git a/drivers/net/atp.c b/drivers/net/atp.c
index 6020d5ec38b9..cec2e3672cd0 100644
--- a/drivers/net/atp.c
+++ b/drivers/net/atp.c
@@ -171,7 +171,6 @@ static char mux_8012[] = { 0xff, 0xf7, 0xff, 0xfb, 0xf3, 0xfb, 0xff, 0xf7,};
171struct net_local { 171struct net_local {
172 spinlock_t lock; 172 spinlock_t lock;
173 struct net_device *next_module; 173 struct net_device *next_module;
174 struct net_device_stats stats;
175 struct timer_list timer; /* Media selection timer. */ 174 struct timer_list timer; /* Media selection timer. */
176 long last_rx_time; /* Last Rx, in jiffies, to handle Rx hang. */ 175 long last_rx_time; /* Last Rx, in jiffies, to handle Rx hang. */
177 int saved_tx_size; 176 int saved_tx_size;
@@ -205,7 +204,6 @@ static irqreturn_t atp_interrupt(int irq, void *dev_id);
205static void net_rx(struct net_device *dev); 204static void net_rx(struct net_device *dev);
206static void read_block(long ioaddr, int length, unsigned char *buffer, int data_mode); 205static void read_block(long ioaddr, int length, unsigned char *buffer, int data_mode);
207static int net_close(struct net_device *dev); 206static int net_close(struct net_device *dev);
208static struct net_device_stats *net_get_stats(struct net_device *dev);
209static void set_rx_mode_8002(struct net_device *dev); 207static void set_rx_mode_8002(struct net_device *dev);
210static void set_rx_mode_8012(struct net_device *dev); 208static void set_rx_mode_8012(struct net_device *dev);
211static void tx_timeout(struct net_device *dev); 209static void tx_timeout(struct net_device *dev);
@@ -348,7 +346,6 @@ static int __init atp_probe1(long ioaddr)
348 dev->open = net_open; 346 dev->open = net_open;
349 dev->stop = net_close; 347 dev->stop = net_close;
350 dev->hard_start_xmit = atp_send_packet; 348 dev->hard_start_xmit = atp_send_packet;
351 dev->get_stats = net_get_stats;
352 dev->set_multicast_list = 349 dev->set_multicast_list =
353 lp->chip_type == RTL8002 ? &set_rx_mode_8002 : &set_rx_mode_8012; 350 lp->chip_type == RTL8002 ? &set_rx_mode_8002 : &set_rx_mode_8012;
354 dev->tx_timeout = tx_timeout; 351 dev->tx_timeout = tx_timeout;
@@ -538,18 +535,17 @@ static void write_packet(long ioaddr, int length, unsigned char *packet, int pad
538 535
539static void tx_timeout(struct net_device *dev) 536static void tx_timeout(struct net_device *dev)
540{ 537{
541 struct net_local *np = netdev_priv(dev);
542 long ioaddr = dev->base_addr; 538 long ioaddr = dev->base_addr;
543 539
544 printk(KERN_WARNING "%s: Transmit timed out, %s?\n", dev->name, 540 printk(KERN_WARNING "%s: Transmit timed out, %s?\n", dev->name,
545 inb(ioaddr + PAR_CONTROL) & 0x10 ? "network cable problem" 541 inb(ioaddr + PAR_CONTROL) & 0x10 ? "network cable problem"
546 : "IRQ conflict"); 542 : "IRQ conflict");
547 np->stats.tx_errors++; 543 dev->stats.tx_errors++;
548 /* Try to restart the adapter. */ 544 /* Try to restart the adapter. */
549 hardware_init(dev); 545 hardware_init(dev);
550 dev->trans_start = jiffies; 546 dev->trans_start = jiffies;
551 netif_wake_queue(dev); 547 netif_wake_queue(dev);
552 np->stats.tx_errors++; 548 dev->stats.tx_errors++;
553} 549}
554 550
555static int atp_send_packet(struct sk_buff *skb, struct net_device *dev) 551static int atp_send_packet(struct sk_buff *skb, struct net_device *dev)
@@ -629,7 +625,7 @@ static irqreturn_t atp_interrupt(int irq, void *dev_instance)
629 /* We acknowledged the normal Rx interrupt, so if the interrupt 625 /* We acknowledged the normal Rx interrupt, so if the interrupt
630 is still outstanding we must have a Rx error. */ 626 is still outstanding we must have a Rx error. */
631 if (read_status & (CMR1_IRQ << 3)) { /* Overrun. */ 627 if (read_status & (CMR1_IRQ << 3)) { /* Overrun. */
632 lp->stats.rx_over_errors++; 628 dev->stats.rx_over_errors++;
633 /* Set to no-accept mode long enough to remove a packet. */ 629 /* Set to no-accept mode long enough to remove a packet. */
634 write_reg_high(ioaddr, CMR2, CMR2h_OFF); 630 write_reg_high(ioaddr, CMR2, CMR2h_OFF);
635 net_rx(dev); 631 net_rx(dev);
@@ -649,9 +645,9 @@ static irqreturn_t atp_interrupt(int irq, void *dev_instance)
649 and reinitialize the adapter. */ 645 and reinitialize the adapter. */
650 write_reg(ioaddr, ISR, ISR_TxErr + ISR_TxOK); 646 write_reg(ioaddr, ISR, ISR_TxErr + ISR_TxOK);
651 if (status & (ISR_TxErr<<3)) { 647 if (status & (ISR_TxErr<<3)) {
652 lp->stats.collisions++; 648 dev->stats.collisions++;
653 if (++lp->re_tx > 15) { 649 if (++lp->re_tx > 15) {
654 lp->stats.tx_aborted_errors++; 650 dev->stats.tx_aborted_errors++;
655 hardware_init(dev); 651 hardware_init(dev);
656 break; 652 break;
657 } 653 }
@@ -660,7 +656,7 @@ static irqreturn_t atp_interrupt(int irq, void *dev_instance)
660 write_reg(ioaddr, CMR1, CMR1_ReXmit + CMR1_Xmit); 656 write_reg(ioaddr, CMR1, CMR1_ReXmit + CMR1_Xmit);
661 } else { 657 } else {
662 /* Finish up the transmit. */ 658 /* Finish up the transmit. */
663 lp->stats.tx_packets++; 659 dev->stats.tx_packets++;
664 lp->pac_cnt_in_tx_buf--; 660 lp->pac_cnt_in_tx_buf--;
665 if ( lp->saved_tx_size) { 661 if ( lp->saved_tx_size) {
666 trigger_send(ioaddr, lp->saved_tx_size); 662 trigger_send(ioaddr, lp->saved_tx_size);
@@ -678,7 +674,7 @@ static irqreturn_t atp_interrupt(int irq, void *dev_instance)
678 "%ld jiffies status %02x CMR1 %02x.\n", dev->name, 674 "%ld jiffies status %02x CMR1 %02x.\n", dev->name,
679 num_tx_since_rx, jiffies - dev->last_rx, status, 675 num_tx_since_rx, jiffies - dev->last_rx, status,
680 (read_nibble(ioaddr, CMR1) >> 3) & 15); 676 (read_nibble(ioaddr, CMR1) >> 3) & 15);
681 lp->stats.rx_missed_errors++; 677 dev->stats.rx_missed_errors++;
682 hardware_init(dev); 678 hardware_init(dev);
683 num_tx_since_rx = 0; 679 num_tx_since_rx = 0;
684 break; 680 break;
@@ -735,13 +731,13 @@ static void atp_timed_checker(unsigned long data)
735 struct net_local *lp = netdev_priv(atp_timed_dev); 731 struct net_local *lp = netdev_priv(atp_timed_dev);
736 write_reg_byte(ioaddr, PAR0 + i, atp_timed_dev->dev_addr[i]); 732 write_reg_byte(ioaddr, PAR0 + i, atp_timed_dev->dev_addr[i]);
737 if (i == 2) 733 if (i == 2)
738 lp->stats.tx_errors++; 734 dev->stats.tx_errors++;
739 else if (i == 3) 735 else if (i == 3)
740 lp->stats.tx_dropped++; 736 dev->stats.tx_dropped++;
741 else if (i == 4) 737 else if (i == 4)
742 lp->stats.collisions++; 738 dev->stats.collisions++;
743 else 739 else
744 lp->stats.rx_errors++; 740 dev->stats.rx_errors++;
745 } 741 }
746#endif 742#endif
747 } 743 }
@@ -765,14 +761,14 @@ static void net_rx(struct net_device *dev)
765 printk(KERN_DEBUG " rx_count %04x %04x %04x %04x..", rx_head.pad, 761 printk(KERN_DEBUG " rx_count %04x %04x %04x %04x..", rx_head.pad,
766 rx_head.rx_count, rx_head.rx_status, rx_head.cur_addr); 762 rx_head.rx_count, rx_head.rx_status, rx_head.cur_addr);
767 if ((rx_head.rx_status & 0x77) != 0x01) { 763 if ((rx_head.rx_status & 0x77) != 0x01) {
768 lp->stats.rx_errors++; 764 dev->stats.rx_errors++;
769 if (rx_head.rx_status & 0x0004) lp->stats.rx_frame_errors++; 765 if (rx_head.rx_status & 0x0004) dev->stats.rx_frame_errors++;
770 else if (rx_head.rx_status & 0x0002) lp->stats.rx_crc_errors++; 766 else if (rx_head.rx_status & 0x0002) dev->stats.rx_crc_errors++;
771 if (net_debug > 3) 767 if (net_debug > 3)
772 printk(KERN_DEBUG "%s: Unknown ATP Rx error %04x.\n", 768 printk(KERN_DEBUG "%s: Unknown ATP Rx error %04x.\n",
773 dev->name, rx_head.rx_status); 769 dev->name, rx_head.rx_status);
774 if (rx_head.rx_status & 0x0020) { 770 if (rx_head.rx_status & 0x0020) {
775 lp->stats.rx_fifo_errors++; 771 dev->stats.rx_fifo_errors++;
776 write_reg_high(ioaddr, CMR1, CMR1h_TxENABLE); 772 write_reg_high(ioaddr, CMR1, CMR1h_TxENABLE);
777 write_reg_high(ioaddr, CMR1, CMR1h_RxENABLE | CMR1h_TxENABLE); 773 write_reg_high(ioaddr, CMR1, CMR1h_RxENABLE | CMR1h_TxENABLE);
778 } else if (rx_head.rx_status & 0x0050) 774 } else if (rx_head.rx_status & 0x0050)
@@ -787,7 +783,7 @@ static void net_rx(struct net_device *dev)
787 if (skb == NULL) { 783 if (skb == NULL) {
788 printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", 784 printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n",
789 dev->name); 785 dev->name);
790 lp->stats.rx_dropped++; 786 dev->stats.rx_dropped++;
791 goto done; 787 goto done;
792 } 788 }
793 789
@@ -796,8 +792,8 @@ static void net_rx(struct net_device *dev)
796 skb->protocol = eth_type_trans(skb, dev); 792 skb->protocol = eth_type_trans(skb, dev);
797 netif_rx(skb); 793 netif_rx(skb);
798 dev->last_rx = jiffies; 794 dev->last_rx = jiffies;
799 lp->stats.rx_packets++; 795 dev->stats.rx_packets++;
800 lp->stats.rx_bytes += pkt_len; 796 dev->stats.rx_bytes += pkt_len;
801 } 797 }
802 done: 798 done:
803 write_reg(ioaddr, CMR1, CMR1_NextPkt); 799 write_reg(ioaddr, CMR1, CMR1_NextPkt);
@@ -849,15 +845,6 @@ net_close(struct net_device *dev)
849 return 0; 845 return 0;
850} 846}
851 847
852/* Get the current statistics. This may be called with the card open or
853 closed. */
854static struct net_device_stats *
855net_get_stats(struct net_device *dev)
856{
857 struct net_local *lp = netdev_priv(dev);
858 return &lp->stats;
859}
860
861/* 848/*
862 * Set or clear the multicast filter for this adapter. 849 * Set or clear the multicast filter for this adapter.
863 */ 850 */