Skip to content

Commit 6b7ed22

Browse files
vcgomesanguy11
authored andcommitted
igc: Fix returning wrong statistics
'igc_update_stats()' was not updating 'netdev->stats', so the returned statistics, for example, requested by: $ ip -s link show dev enp3s0 were not being updated and were always zero. Fix by returning a set of statistics that are actually being updated (adapter->stats64). Fixes: c9a11c2 ("igc: Add netdev") Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 1773482 commit 6b7ed22

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

drivers/net/ethernet/intel/igc/igc_main.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,21 +3891,23 @@ static int igc_change_mtu(struct net_device *netdev, int new_mtu)
38913891
}
38923892

38933893
/**
3894-
* igc_get_stats - Get System Network Statistics
3894+
* igc_get_stats64 - Get System Network Statistics
38953895
* @netdev: network interface device structure
3896+
* @stats: rtnl_link_stats64 pointer
38963897
*
38973898
* Returns the address of the device statistics structure.
38983899
* The statistics are updated here and also from the timer callback.
38993900
*/
3900-
static struct net_device_stats *igc_get_stats(struct net_device *netdev)
3901+
static void igc_get_stats64(struct net_device *netdev,
3902+
struct rtnl_link_stats64 *stats)
39013903
{
39023904
struct igc_adapter *adapter = netdev_priv(netdev);
39033905

3906+
spin_lock(&adapter->stats64_lock);
39043907
if (!test_bit(__IGC_RESETTING, &adapter->state))
39053908
igc_update_stats(adapter);
3906-
3907-
/* only return the current stats */
3908-
return &netdev->stats;
3909+
memcpy(stats, &adapter->stats64, sizeof(*stats));
3910+
spin_unlock(&adapter->stats64_lock);
39093911
}
39103912

39113913
static netdev_features_t igc_fix_features(struct net_device *netdev,
@@ -4855,7 +4857,7 @@ static const struct net_device_ops igc_netdev_ops = {
48554857
.ndo_set_rx_mode = igc_set_rx_mode,
48564858
.ndo_set_mac_address = igc_set_mac,
48574859
.ndo_change_mtu = igc_change_mtu,
4858-
.ndo_get_stats = igc_get_stats,
4860+
.ndo_get_stats64 = igc_get_stats64,
48594861
.ndo_fix_features = igc_fix_features,
48604862
.ndo_set_features = igc_set_features,
48614863
.ndo_features_check = igc_features_check,

0 commit comments

Comments
 (0)