Skip to content

Commit 3b5bdd1

Browse files
jjagielskanguy11
authored andcommitted
iavf: Fix refreshing iavf adapter stats on ethtool request
Currently iavf adapter statistics are refreshed only in a watchdog task, triggered approximately every two seconds, which causes some ethtool requests to return outdated values. Add explicit statistics refresh when requested by ethtool -S. Fixes: b476b00 ("iavf: Move commands processing to the separate function") Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com> Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com> Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 0cc318d commit 3b5bdd1

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

drivers/net/ethernet/intel/iavf/iavf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ struct iavf_adapter {
305305
#define IAVF_FLAG_AQ_DEL_FDIR_FILTER BIT(26)
306306
#define IAVF_FLAG_AQ_ADD_ADV_RSS_CFG BIT(27)
307307
#define IAVF_FLAG_AQ_DEL_ADV_RSS_CFG BIT(28)
308+
#define IAVF_FLAG_AQ_REQUEST_STATS BIT(29)
308309

309310
/* OS defined structs */
310311
struct net_device *netdev;
@@ -444,6 +445,7 @@ int iavf_up(struct iavf_adapter *adapter);
444445
void iavf_down(struct iavf_adapter *adapter);
445446
int iavf_process_config(struct iavf_adapter *adapter);
446447
void iavf_schedule_reset(struct iavf_adapter *adapter);
448+
void iavf_schedule_request_stats(struct iavf_adapter *adapter);
447449
void iavf_reset(struct iavf_adapter *adapter);
448450
void iavf_set_ethtool_ops(struct net_device *netdev);
449451
void iavf_update_stats(struct iavf_adapter *adapter);

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ static void iavf_get_ethtool_stats(struct net_device *netdev,
354354
struct iavf_adapter *adapter = netdev_priv(netdev);
355355
unsigned int i;
356356

357+
/* Explicitly request stats refresh */
358+
iavf_schedule_request_stats(adapter);
359+
357360
iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats);
358361

359362
rcu_read_lock();

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ void iavf_schedule_reset(struct iavf_adapter *adapter)
174174
}
175175
}
176176

177+
/**
178+
* iavf_schedule_request_stats - Set the flags and schedule statistics request
179+
* @adapter: board private structure
180+
*
181+
* Sets IAVF_FLAG_AQ_REQUEST_STATS flag so iavf_watchdog_task() will explicitly
182+
* request and refresh ethtool stats
183+
**/
184+
void iavf_schedule_request_stats(struct iavf_adapter *adapter)
185+
{
186+
adapter->aq_required |= IAVF_FLAG_AQ_REQUEST_STATS;
187+
mod_delayed_work(iavf_wq, &adapter->watchdog_task, 0);
188+
}
189+
177190
/**
178191
* iavf_tx_timeout - Respond to a Tx Hang
179192
* @netdev: network interface device structure
@@ -1709,6 +1722,11 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)
17091722
iavf_del_adv_rss_cfg(adapter);
17101723
return 0;
17111724
}
1725+
if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_STATS) {
1726+
iavf_request_stats(adapter);
1727+
return 0;
1728+
}
1729+
17121730
return -EAGAIN;
17131731
}
17141732

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ void iavf_request_stats(struct iavf_adapter *adapter)
784784
/* no error message, this isn't crucial */
785785
return;
786786
}
787+
788+
adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_STATS;
787789
adapter->current_op = VIRTCHNL_OP_GET_STATS;
788790
vqs.vsi_id = adapter->vsi_res->vsi_id;
789791
/* queue maps are ignored for this message - only the vsi is used */

0 commit comments

Comments
 (0)