aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/netdev.c
diff options
context:
space:
mode:
authorJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-01-07 00:12:09 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-01-24 03:13:37 -0500
commit67fd4fcb78a7ced369a6bd8a131ec8c65ebd2bbb (patch)
tree53747c0e34152d47c440f9dbb8318301747ccbab /drivers/net/e1000e/netdev.c
parentbb134d2298b49f50cf6d9388410fba96272905dc (diff)
e1000e: convert to stats64
Based on the patch provided by Flavio Leitner <fleitner@redhat.com> Provides accurate stats at the time user reads them. v2: fixed whitespace/merging issues (by Jeff Kirsher) v3: fixed namespacing issues (by Bruce Allan) CC: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Tested-by: Jeff Pieper <jeffrey.e.pieper@intel.com> Signed-off-by: Flavio Leitner <fleitner@redhat.com>
Diffstat (limited to 'drivers/net/e1000e/netdev.c')
-rw-r--r--drivers/net/e1000e/netdev.c72
1 files changed, 57 insertions, 15 deletions
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 1c18f26b0812..1c2f33dd0633 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -900,8 +900,6 @@ next_desc:
900 900
901 adapter->total_rx_bytes += total_rx_bytes; 901 adapter->total_rx_bytes += total_rx_bytes;
902 adapter->total_rx_packets += total_rx_packets; 902 adapter->total_rx_packets += total_rx_packets;
903 netdev->stats.rx_bytes += total_rx_bytes;
904 netdev->stats.rx_packets += total_rx_packets;
905 return cleaned; 903 return cleaned;
906} 904}
907 905
@@ -1057,8 +1055,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
1057 } 1055 }
1058 adapter->total_tx_bytes += total_tx_bytes; 1056 adapter->total_tx_bytes += total_tx_bytes;
1059 adapter->total_tx_packets += total_tx_packets; 1057 adapter->total_tx_packets += total_tx_packets;
1060 netdev->stats.tx_bytes += total_tx_bytes;
1061 netdev->stats.tx_packets += total_tx_packets;
1062 return count < tx_ring->count; 1058 return count < tx_ring->count;
1063} 1059}
1064 1060
@@ -1245,8 +1241,6 @@ next_desc:
1245 1241
1246 adapter->total_rx_bytes += total_rx_bytes; 1242 adapter->total_rx_bytes += total_rx_bytes;
1247 adapter->total_rx_packets += total_rx_packets; 1243 adapter->total_rx_packets += total_rx_packets;
1248 netdev->stats.rx_bytes += total_rx_bytes;
1249 netdev->stats.rx_packets += total_rx_packets;
1250 return cleaned; 1244 return cleaned;
1251} 1245}
1252 1246
@@ -1426,8 +1420,6 @@ next_desc:
1426 1420
1427 adapter->total_rx_bytes += total_rx_bytes; 1421 adapter->total_rx_bytes += total_rx_bytes;
1428 adapter->total_rx_packets += total_rx_packets; 1422 adapter->total_rx_packets += total_rx_packets;
1429 netdev->stats.rx_bytes += total_rx_bytes;
1430 netdev->stats.rx_packets += total_rx_packets;
1431 return cleaned; 1423 return cleaned;
1432} 1424}
1433 1425
@@ -3338,6 +3330,8 @@ int e1000e_up(struct e1000_adapter *adapter)
3338 return 0; 3330 return 0;
3339} 3331}
3340 3332
3333static void e1000e_update_stats(struct e1000_adapter *adapter);
3334
3341void e1000e_down(struct e1000_adapter *adapter) 3335void e1000e_down(struct e1000_adapter *adapter)
3342{ 3336{
3343 struct net_device *netdev = adapter->netdev; 3337 struct net_device *netdev = adapter->netdev;
@@ -3372,6 +3366,11 @@ void e1000e_down(struct e1000_adapter *adapter)
3372 del_timer_sync(&adapter->phy_info_timer); 3366 del_timer_sync(&adapter->phy_info_timer);
3373 3367
3374 netif_carrier_off(netdev); 3368 netif_carrier_off(netdev);
3369
3370 spin_lock(&adapter->stats64_lock);
3371 e1000e_update_stats(adapter);
3372 spin_unlock(&adapter->stats64_lock);
3373
3375 adapter->link_speed = 0; 3374 adapter->link_speed = 0;
3376 adapter->link_duplex = 0; 3375 adapter->link_duplex = 0;
3377 3376
@@ -3413,6 +3412,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
3413 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; 3412 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
3414 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; 3413 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
3415 3414
3415 spin_lock_init(&adapter->stats64_lock);
3416
3416 e1000e_set_interrupt_capability(adapter); 3417 e1000e_set_interrupt_capability(adapter);
3417 3418
3418 if (e1000_alloc_queues(adapter)) 3419 if (e1000_alloc_queues(adapter))
@@ -3886,7 +3887,7 @@ release:
3886 * e1000e_update_stats - Update the board statistics counters 3887 * e1000e_update_stats - Update the board statistics counters
3887 * @adapter: board private structure 3888 * @adapter: board private structure
3888 **/ 3889 **/
3889void e1000e_update_stats(struct e1000_adapter *adapter) 3890static void e1000e_update_stats(struct e1000_adapter *adapter)
3890{ 3891{
3891 struct net_device *netdev = adapter->netdev; 3892 struct net_device *netdev = adapter->netdev;
3892 struct e1000_hw *hw = &adapter->hw; 3893 struct e1000_hw *hw = &adapter->hw;
@@ -4285,7 +4286,9 @@ static void e1000_watchdog_task(struct work_struct *work)
4285 } 4286 }
4286 4287
4287link_up: 4288link_up:
4289 spin_lock(&adapter->stats64_lock);
4288 e1000e_update_stats(adapter); 4290 e1000e_update_stats(adapter);
4291 spin_unlock(&adapter->stats64_lock);
4289 4292
4290 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; 4293 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
4291 adapter->tpt_old = adapter->stats.tpt; 4294 adapter->tpt_old = adapter->stats.tpt;
@@ -4897,16 +4900,55 @@ static void e1000_reset_task(struct work_struct *work)
4897} 4900}
4898 4901
4899/** 4902/**
4900 * e1000_get_stats - Get System Network Statistics 4903 * e1000_get_stats64 - Get System Network Statistics
4901 * @netdev: network interface device structure 4904 * @netdev: network interface device structure
4905 * @stats: rtnl_link_stats64 pointer
4902 * 4906 *
4903 * Returns the address of the device statistics structure. 4907 * Returns the address of the device statistics structure.
4904 * The statistics are actually updated from the timer callback.
4905 **/ 4908 **/
4906static struct net_device_stats *e1000_get_stats(struct net_device *netdev) 4909struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
4910 struct rtnl_link_stats64 *stats)
4907{ 4911{
4908 /* only return the current stats */ 4912 struct e1000_adapter *adapter = netdev_priv(netdev);
4909 return &netdev->stats; 4913
4914 memset(stats, 0, sizeof(struct rtnl_link_stats64));
4915 spin_lock(&adapter->stats64_lock);
4916 e1000e_update_stats(adapter);
4917 /* Fill out the OS statistics structure */
4918 stats->rx_bytes = adapter->stats.gorc;
4919 stats->rx_packets = adapter->stats.gprc;
4920 stats->tx_bytes = adapter->stats.gotc;
4921 stats->tx_packets = adapter->stats.gptc;
4922 stats->multicast = adapter->stats.mprc;
4923 stats->collisions = adapter->stats.colc;
4924
4925 /* Rx Errors */
4926
4927 /*
4928 * RLEC on some newer hardware can be incorrect so build
4929 * our own version based on RUC and ROC
4930 */
4931 stats->rx_errors = adapter->stats.rxerrc +
4932 adapter->stats.crcerrs + adapter->stats.algnerrc +
4933 adapter->stats.ruc + adapter->stats.roc +
4934 adapter->stats.cexterr;
4935 stats->rx_length_errors = adapter->stats.ruc +
4936 adapter->stats.roc;
4937 stats->rx_crc_errors = adapter->stats.crcerrs;
4938 stats->rx_frame_errors = adapter->stats.algnerrc;
4939 stats->rx_missed_errors = adapter->stats.mpc;
4940
4941 /* Tx Errors */
4942 stats->tx_errors = adapter->stats.ecol +
4943 adapter->stats.latecol;
4944 stats->tx_aborted_errors = adapter->stats.ecol;
4945 stats->tx_window_errors = adapter->stats.latecol;
4946 stats->tx_carrier_errors = adapter->stats.tncrs;
4947
4948 /* Tx Dropped needs to be maintained elsewhere */
4949
4950 spin_unlock(&adapter->stats64_lock);
4951 return stats;
4910} 4952}
4911 4953
4912/** 4954/**
@@ -5675,7 +5717,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
5675 .ndo_open = e1000_open, 5717 .ndo_open = e1000_open,
5676 .ndo_stop = e1000_close, 5718 .ndo_stop = e1000_close,
5677 .ndo_start_xmit = e1000_xmit_frame, 5719 .ndo_start_xmit = e1000_xmit_frame,
5678 .ndo_get_stats = e1000_get_stats, 5720 .ndo_get_stats64 = e1000e_get_stats64,
5679 .ndo_set_multicast_list = e1000_set_multi, 5721 .ndo_set_multicast_list = e1000_set_multi,
5680 .ndo_set_mac_address = e1000_set_mac, 5722 .ndo_set_mac_address = e1000_set_mac,
5681 .ndo_change_mtu = e1000_change_mtu, 5723 .ndo_change_mtu = e1000_change_mtu,