diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-10-31 19:52:03 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-11-02 07:59:55 -0500 |
commit | 02e7173149c3ffcf963075ec2bdc5f7be8335a78 (patch) | |
tree | d4206ce6e7f222891f7ccb547eadd01515217950 /drivers/net/atlx | |
parent | ae27e98a51526595837ab7498b23d6478a198960 (diff) |
atlx: use embedded net_device_stats
There is now a net_device_stats structure inside net_device that should
be used if possible by devices. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/atlx')
-rw-r--r-- | drivers/net/atlx/atl1.c | 43 | ||||
-rw-r--r-- | drivers/net/atlx/atl1.h | 2 | ||||
-rw-r--r-- | drivers/net/atlx/atl2.c | 55 | ||||
-rw-r--r-- | drivers/net/atlx/atl2.h | 1 | ||||
-rw-r--r-- | drivers/net/atlx/atlx.c | 13 |
5 files changed, 44 insertions, 70 deletions
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c index 246d92b4263..6cc47616b6d 100644 --- a/drivers/net/atlx/atl1.c +++ b/drivers/net/atlx/atl1.c | |||
@@ -1662,6 +1662,7 @@ static void atl1_via_workaround(struct atl1_adapter *adapter) | |||
1662 | 1662 | ||
1663 | static void atl1_inc_smb(struct atl1_adapter *adapter) | 1663 | static void atl1_inc_smb(struct atl1_adapter *adapter) |
1664 | { | 1664 | { |
1665 | struct net_device *netdev = adapter->netdev; | ||
1665 | struct stats_msg_block *smb = adapter->smb.smb; | 1666 | struct stats_msg_block *smb = adapter->smb.smb; |
1666 | 1667 | ||
1667 | /* Fill out the OS statistics structure */ | 1668 | /* Fill out the OS statistics structure */ |
@@ -1704,30 +1705,30 @@ static void atl1_inc_smb(struct atl1_adapter *adapter) | |||
1704 | adapter->soft_stats.tx_trunc += smb->tx_trunc; | 1705 | adapter->soft_stats.tx_trunc += smb->tx_trunc; |
1705 | adapter->soft_stats.tx_pause += smb->tx_pause; | 1706 | adapter->soft_stats.tx_pause += smb->tx_pause; |
1706 | 1707 | ||
1707 | adapter->net_stats.rx_packets = adapter->soft_stats.rx_packets; | 1708 | netdev->stats.rx_packets = adapter->soft_stats.rx_packets; |
1708 | adapter->net_stats.tx_packets = adapter->soft_stats.tx_packets; | 1709 | netdev->stats.tx_packets = adapter->soft_stats.tx_packets; |
1709 | adapter->net_stats.rx_bytes = adapter->soft_stats.rx_bytes; | 1710 | netdev->stats.rx_bytes = adapter->soft_stats.rx_bytes; |
1710 | adapter->net_stats.tx_bytes = adapter->soft_stats.tx_bytes; | 1711 | netdev->stats.tx_bytes = adapter->soft_stats.tx_bytes; |
1711 | adapter->net_stats.multicast = adapter->soft_stats.multicast; | 1712 | netdev->stats.multicast = adapter->soft_stats.multicast; |
1712 | adapter->net_stats.collisions = adapter->soft_stats.collisions; | 1713 | netdev->stats.collisions = adapter->soft_stats.collisions; |
1713 | adapter->net_stats.rx_errors = adapter->soft_stats.rx_errors; | 1714 | netdev->stats.rx_errors = adapter->soft_stats.rx_errors; |
1714 | adapter->net_stats.rx_over_errors = | 1715 | netdev->stats.rx_over_errors = |
1715 | adapter->soft_stats.rx_missed_errors; | 1716 | adapter->soft_stats.rx_missed_errors; |
1716 | adapter->net_stats.rx_length_errors = | 1717 | netdev->stats.rx_length_errors = |
1717 | adapter->soft_stats.rx_length_errors; | 1718 | adapter->soft_stats.rx_length_errors; |
1718 | adapter->net_stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; | 1719 | netdev->stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; |
1719 | adapter->net_stats.rx_frame_errors = | 1720 | netdev->stats.rx_frame_errors = |
1720 | adapter->soft_stats.rx_frame_errors; | 1721 | adapter->soft_stats.rx_frame_errors; |
1721 | adapter->net_stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; | 1722 | netdev->stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; |
1722 | adapter->net_stats.rx_missed_errors = | 1723 | netdev->stats.rx_missed_errors = |
1723 | adapter->soft_stats.rx_missed_errors; | 1724 | adapter->soft_stats.rx_missed_errors; |
1724 | adapter->net_stats.tx_errors = adapter->soft_stats.tx_errors; | 1725 | netdev->stats.tx_errors = adapter->soft_stats.tx_errors; |
1725 | adapter->net_stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; | 1726 | netdev->stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; |
1726 | adapter->net_stats.tx_aborted_errors = | 1727 | netdev->stats.tx_aborted_errors = |
1727 | adapter->soft_stats.tx_aborted_errors; | 1728 | adapter->soft_stats.tx_aborted_errors; |
1728 | adapter->net_stats.tx_window_errors = | 1729 | netdev->stats.tx_window_errors = |
1729 | adapter->soft_stats.tx_window_errors; | 1730 | adapter->soft_stats.tx_window_errors; |
1730 | adapter->net_stats.tx_carrier_errors = | 1731 | netdev->stats.tx_carrier_errors = |
1731 | adapter->soft_stats.tx_carrier_errors; | 1732 | adapter->soft_stats.tx_carrier_errors; |
1732 | } | 1733 | } |
1733 | 1734 | ||
@@ -1860,7 +1861,7 @@ static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter) | |||
1860 | adapter->rx_buffer_len + NET_IP_ALIGN); | 1861 | adapter->rx_buffer_len + NET_IP_ALIGN); |
1861 | if (unlikely(!skb)) { | 1862 | if (unlikely(!skb)) { |
1862 | /* Better luck next round */ | 1863 | /* Better luck next round */ |
1863 | adapter->net_stats.rx_dropped++; | 1864 | adapter->netdev->stats.rx_dropped++; |
1864 | break; | 1865 | break; |
1865 | } | 1866 | } |
1866 | 1867 | ||
@@ -2983,7 +2984,7 @@ static int __devinit atl1_probe(struct pci_dev *pdev, | |||
2983 | netdev->open = &atl1_open; | 2984 | netdev->open = &atl1_open; |
2984 | netdev->stop = &atl1_close; | 2985 | netdev->stop = &atl1_close; |
2985 | netdev->hard_start_xmit = &atl1_xmit_frame; | 2986 | netdev->hard_start_xmit = &atl1_xmit_frame; |
2986 | netdev->get_stats = &atlx_get_stats; | 2987 | |
2987 | netdev->set_multicast_list = &atlx_set_multi; | 2988 | netdev->set_multicast_list = &atlx_set_multi; |
2988 | netdev->set_mac_address = &atl1_set_mac; | 2989 | netdev->set_mac_address = &atl1_set_mac; |
2989 | netdev->change_mtu = &atl1_change_mtu; | 2990 | netdev->change_mtu = &atl1_change_mtu; |
@@ -3173,8 +3174,6 @@ static struct atl1_stats atl1_gstrings_stats[] = { | |||
3173 | {"tx_bytes", ATL1_STAT(soft_stats.tx_bytes)}, | 3174 | {"tx_bytes", ATL1_STAT(soft_stats.tx_bytes)}, |
3174 | {"rx_errors", ATL1_STAT(soft_stats.rx_errors)}, | 3175 | {"rx_errors", ATL1_STAT(soft_stats.rx_errors)}, |
3175 | {"tx_errors", ATL1_STAT(soft_stats.tx_errors)}, | 3176 | {"tx_errors", ATL1_STAT(soft_stats.tx_errors)}, |
3176 | {"rx_dropped", ATL1_STAT(net_stats.rx_dropped)}, | ||
3177 | {"tx_dropped", ATL1_STAT(net_stats.tx_dropped)}, | ||
3178 | {"multicast", ATL1_STAT(soft_stats.multicast)}, | 3177 | {"multicast", ATL1_STAT(soft_stats.multicast)}, |
3179 | {"collisions", ATL1_STAT(soft_stats.collisions)}, | 3178 | {"collisions", ATL1_STAT(soft_stats.collisions)}, |
3180 | {"rx_length_errors", ATL1_STAT(soft_stats.rx_length_errors)}, | 3179 | {"rx_length_errors", ATL1_STAT(soft_stats.rx_length_errors)}, |
diff --git a/drivers/net/atlx/atl1.h b/drivers/net/atlx/atl1.h index ffa73fc8d95..324ef5e9341 100644 --- a/drivers/net/atlx/atl1.h +++ b/drivers/net/atlx/atl1.h | |||
@@ -754,7 +754,7 @@ struct atl1_hw { | |||
754 | struct atl1_adapter { | 754 | struct atl1_adapter { |
755 | struct net_device *netdev; | 755 | struct net_device *netdev; |
756 | struct pci_dev *pdev; | 756 | struct pci_dev *pdev; |
757 | struct net_device_stats net_stats; | 757 | |
758 | struct atl1_sft_stats soft_stats; | 758 | struct atl1_sft_stats soft_stats; |
759 | struct vlan_group *vlgrp; | 759 | struct vlan_group *vlgrp; |
760 | u32 rx_buffer_len; | 760 | u32 rx_buffer_len; |
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c index f5bdc92c1a6..8c5d009ca82 100644 --- a/drivers/net/atlx/atl2.c +++ b/drivers/net/atlx/atl2.c | |||
@@ -418,7 +418,7 @@ static void atl2_intr_rx(struct atl2_adapter *adapter) | |||
418 | * Check that some rx space is free. If not, | 418 | * Check that some rx space is free. If not, |
419 | * free one and mark stats->rx_dropped++. | 419 | * free one and mark stats->rx_dropped++. |
420 | */ | 420 | */ |
421 | adapter->net_stats.rx_dropped++; | 421 | netdev->stats.rx_dropped++; |
422 | break; | 422 | break; |
423 | } | 423 | } |
424 | skb_reserve(skb, NET_IP_ALIGN); | 424 | skb_reserve(skb, NET_IP_ALIGN); |
@@ -435,20 +435,20 @@ static void atl2_intr_rx(struct atl2_adapter *adapter) | |||
435 | } else | 435 | } else |
436 | #endif | 436 | #endif |
437 | netif_rx(skb); | 437 | netif_rx(skb); |
438 | adapter->net_stats.rx_bytes += rx_size; | 438 | netdev->stats.rx_bytes += rx_size; |
439 | adapter->net_stats.rx_packets++; | 439 | netdev->stats.rx_packets++; |
440 | netdev->last_rx = jiffies; | 440 | netdev->last_rx = jiffies; |
441 | } else { | 441 | } else { |
442 | adapter->net_stats.rx_errors++; | 442 | netdev->stats.rx_errors++; |
443 | 443 | ||
444 | if (rxd->status.ok && rxd->status.pkt_size <= 60) | 444 | if (rxd->status.ok && rxd->status.pkt_size <= 60) |
445 | adapter->net_stats.rx_length_errors++; | 445 | netdev->stats.rx_length_errors++; |
446 | if (rxd->status.mcast) | 446 | if (rxd->status.mcast) |
447 | adapter->net_stats.multicast++; | 447 | netdev->stats.multicast++; |
448 | if (rxd->status.crc) | 448 | if (rxd->status.crc) |
449 | adapter->net_stats.rx_crc_errors++; | 449 | netdev->stats.rx_crc_errors++; |
450 | if (rxd->status.align) | 450 | if (rxd->status.align) |
451 | adapter->net_stats.rx_frame_errors++; | 451 | netdev->stats.rx_frame_errors++; |
452 | } | 452 | } |
453 | 453 | ||
454 | /* advance write ptr */ | 454 | /* advance write ptr */ |
@@ -463,6 +463,7 @@ static void atl2_intr_rx(struct atl2_adapter *adapter) | |||
463 | 463 | ||
464 | static void atl2_intr_tx(struct atl2_adapter *adapter) | 464 | static void atl2_intr_tx(struct atl2_adapter *adapter) |
465 | { | 465 | { |
466 | struct net_device *netdev = adapter->netdev; | ||
466 | u32 txd_read_ptr; | 467 | u32 txd_read_ptr; |
467 | u32 txs_write_ptr; | 468 | u32 txs_write_ptr; |
468 | struct tx_pkt_status *txs; | 469 | struct tx_pkt_status *txs; |
@@ -522,20 +523,20 @@ static void atl2_intr_tx(struct atl2_adapter *adapter) | |||
522 | 523 | ||
523 | /* tx statistics: */ | 524 | /* tx statistics: */ |
524 | if (txs->ok) { | 525 | if (txs->ok) { |
525 | adapter->net_stats.tx_bytes += txs->pkt_size; | 526 | netdev->stats.tx_bytes += txs->pkt_size; |
526 | adapter->net_stats.tx_packets++; | 527 | netdev->stats.tx_packets++; |
527 | } | 528 | } |
528 | else | 529 | else |
529 | adapter->net_stats.tx_errors++; | 530 | netdev->stats.tx_errors++; |
530 | 531 | ||
531 | if (txs->defer) | 532 | if (txs->defer) |
532 | adapter->net_stats.collisions++; | 533 | netdev->stats.collisions++; |
533 | if (txs->abort_col) | 534 | if (txs->abort_col) |
534 | adapter->net_stats.tx_aborted_errors++; | 535 | netdev->stats.tx_aborted_errors++; |
535 | if (txs->late_col) | 536 | if (txs->late_col) |
536 | adapter->net_stats.tx_window_errors++; | 537 | netdev->stats.tx_window_errors++; |
537 | if (txs->underun) | 538 | if (txs->underun) |
538 | adapter->net_stats.tx_fifo_errors++; | 539 | netdev->stats.tx_fifo_errors++; |
539 | } while (1); | 540 | } while (1); |
540 | 541 | ||
541 | if (free_hole) { | 542 | if (free_hole) { |
@@ -621,7 +622,7 @@ static irqreturn_t atl2_intr(int irq, void *data) | |||
621 | 622 | ||
622 | /* link event */ | 623 | /* link event */ |
623 | if (status & (ISR_PHY | ISR_MANUAL)) { | 624 | if (status & (ISR_PHY | ISR_MANUAL)) { |
624 | adapter->net_stats.tx_carrier_errors++; | 625 | adapter->netdev->stats.tx_carrier_errors++; |
625 | atl2_check_for_link(adapter); | 626 | atl2_check_for_link(adapter); |
626 | } | 627 | } |
627 | 628 | ||
@@ -900,19 +901,6 @@ static int atl2_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
900 | } | 901 | } |
901 | 902 | ||
902 | /* | 903 | /* |
903 | * atl2_get_stats - Get System Network Statistics | ||
904 | * @netdev: network interface device structure | ||
905 | * | ||
906 | * Returns the address of the device statistics structure. | ||
907 | * The statistics are actually updated from the timer callback. | ||
908 | */ | ||
909 | static struct net_device_stats *atl2_get_stats(struct net_device *netdev) | ||
910 | { | ||
911 | struct atl2_adapter *adapter = netdev_priv(netdev); | ||
912 | return &adapter->net_stats; | ||
913 | } | ||
914 | |||
915 | /* | ||
916 | * atl2_change_mtu - Change the Maximum Transfer Unit | 904 | * atl2_change_mtu - Change the Maximum Transfer Unit |
917 | * @netdev: network interface device structure | 905 | * @netdev: network interface device structure |
918 | * @new_mtu: new value for maximum frame size | 906 | * @new_mtu: new value for maximum frame size |
@@ -1050,16 +1038,18 @@ static void atl2_tx_timeout(struct net_device *netdev) | |||
1050 | static void atl2_watchdog(unsigned long data) | 1038 | static void atl2_watchdog(unsigned long data) |
1051 | { | 1039 | { |
1052 | struct atl2_adapter *adapter = (struct atl2_adapter *) data; | 1040 | struct atl2_adapter *adapter = (struct atl2_adapter *) data; |
1053 | u32 drop_rxd, drop_rxs; | ||
1054 | unsigned long flags; | ||
1055 | 1041 | ||
1056 | if (!test_bit(__ATL2_DOWN, &adapter->flags)) { | 1042 | if (!test_bit(__ATL2_DOWN, &adapter->flags)) { |
1043 | u32 drop_rxd, drop_rxs; | ||
1044 | unsigned long flags; | ||
1045 | |||
1057 | spin_lock_irqsave(&adapter->stats_lock, flags); | 1046 | spin_lock_irqsave(&adapter->stats_lock, flags); |
1058 | drop_rxd = ATL2_READ_REG(&adapter->hw, REG_STS_RXD_OV); | 1047 | drop_rxd = ATL2_READ_REG(&adapter->hw, REG_STS_RXD_OV); |
1059 | drop_rxs = ATL2_READ_REG(&adapter->hw, REG_STS_RXS_OV); | 1048 | drop_rxs = ATL2_READ_REG(&adapter->hw, REG_STS_RXS_OV); |
1060 | adapter->net_stats.rx_over_errors += (drop_rxd+drop_rxs); | ||
1061 | spin_unlock_irqrestore(&adapter->stats_lock, flags); | 1049 | spin_unlock_irqrestore(&adapter->stats_lock, flags); |
1062 | 1050 | ||
1051 | adapter->netdev->stats.rx_over_errors += drop_rxd + drop_rxs; | ||
1052 | |||
1063 | /* Reset the timer */ | 1053 | /* Reset the timer */ |
1064 | mod_timer(&adapter->watchdog_timer, jiffies + 4 * HZ); | 1054 | mod_timer(&adapter->watchdog_timer, jiffies + 4 * HZ); |
1065 | } | 1055 | } |
@@ -1396,7 +1386,6 @@ static int __devinit atl2_probe(struct pci_dev *pdev, | |||
1396 | netdev->open = &atl2_open; | 1386 | netdev->open = &atl2_open; |
1397 | netdev->stop = &atl2_close; | 1387 | netdev->stop = &atl2_close; |
1398 | netdev->hard_start_xmit = &atl2_xmit_frame; | 1388 | netdev->hard_start_xmit = &atl2_xmit_frame; |
1399 | netdev->get_stats = &atl2_get_stats; | ||
1400 | netdev->set_multicast_list = &atl2_set_multi; | 1389 | netdev->set_multicast_list = &atl2_set_multi; |
1401 | netdev->set_mac_address = &atl2_set_mac; | 1390 | netdev->set_mac_address = &atl2_set_mac; |
1402 | netdev->change_mtu = &atl2_change_mtu; | 1391 | netdev->change_mtu = &atl2_change_mtu; |
diff --git a/drivers/net/atlx/atl2.h b/drivers/net/atlx/atl2.h index 09974df76b1..d918bbe621e 100644 --- a/drivers/net/atlx/atl2.h +++ b/drivers/net/atlx/atl2.h | |||
@@ -453,7 +453,6 @@ struct atl2_adapter { | |||
453 | /* OS defined structs */ | 453 | /* OS defined structs */ |
454 | struct net_device *netdev; | 454 | struct net_device *netdev; |
455 | struct pci_dev *pdev; | 455 | struct pci_dev *pdev; |
456 | struct net_device_stats net_stats; | ||
457 | #ifdef NETIF_F_HW_VLAN_TX | 456 | #ifdef NETIF_F_HW_VLAN_TX |
458 | struct vlan_group *vlgrp; | 457 | struct vlan_group *vlgrp; |
459 | #endif | 458 | #endif |
diff --git a/drivers/net/atlx/atlx.c b/drivers/net/atlx/atlx.c index 3cc9d1089ca..3dc01421567 100644 --- a/drivers/net/atlx/atlx.c +++ b/drivers/net/atlx/atlx.c | |||
@@ -182,19 +182,6 @@ static void atlx_clear_phy_int(struct atlx_adapter *adapter) | |||
182 | } | 182 | } |
183 | 183 | ||
184 | /* | 184 | /* |
185 | * atlx_get_stats - Get System Network Statistics | ||
186 | * @netdev: network interface device structure | ||
187 | * | ||
188 | * Returns the address of the device statistics structure. | ||
189 | * The statistics are actually updated from the timer callback. | ||
190 | */ | ||
191 | static struct net_device_stats *atlx_get_stats(struct net_device *netdev) | ||
192 | { | ||
193 | struct atlx_adapter *adapter = netdev_priv(netdev); | ||
194 | return &adapter->net_stats; | ||
195 | } | ||
196 | |||
197 | /* | ||
198 | * atlx_tx_timeout - Respond to a Tx Hang | 185 | * atlx_tx_timeout - Respond to a Tx Hang |
199 | * @netdev: network interface device structure | 186 | * @netdev: network interface device structure |
200 | */ | 187 | */ |