Skip to content

Commit 2fd5e43

Browse files
bmikailenkoanguy11
authored andcommitted
ice: Accumulate HW and Netdev statistics over reset
Resets happen with or without user interaction. For example, incidents such as TX hang or a reconfiguration of parameters will result in a reset. During reset, hardware and software statistics were set to zero. This created an issue for the user where a reset happens in the background, statistics set to zero, and the user checks statistics expecting them to be populated. To ensure this doesn't happen, keep accumulating stats over reset. 1. Remove function calls which reset hardware and netdev statistics. 2. Do not rollover statistics in ice_stat_update40 during reset. Signed-off-by: Benjamin Mikailenko <[email protected]> Tested-by: Gurucharan G <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 1d0e28a commit 2fd5e43

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ struct ice_vsi {
373373

374374
/* VSI stats */
375375
struct rtnl_link_stats64 net_stats;
376+
struct rtnl_link_stats64 net_stats_prev;
376377
struct ice_eth_stats eth_stats;
377378
struct ice_eth_stats eth_stats_prev;
378379

drivers/net/ethernet/intel/ice/ice_dcb_lib.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,9 @@ void ice_update_dcb_stats(struct ice_pf *pf)
881881
prev_ps = &pf->stats_prev;
882882
cur_ps = &pf->stats;
883883

884+
if (ice_is_reset_in_progress(pf->state))
885+
pf->stat_prev_loaded = false;
886+
884887
for (i = 0; i < 8; i++) {
885888
ice_stat_update32(hw, GLPRT_PXOFFRXC(port, i),
886889
pf->stat_prev_loaded,

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,11 +1795,15 @@ void ice_update_eth_stats(struct ice_vsi *vsi)
17951795
{
17961796
struct ice_eth_stats *prev_es, *cur_es;
17971797
struct ice_hw *hw = &vsi->back->hw;
1798+
struct ice_pf *pf = vsi->back;
17981799
u16 vsi_num = vsi->vsi_num; /* HW absolute index of a VSI */
17991800

18001801
prev_es = &vsi->eth_stats_prev;
18011802
cur_es = &vsi->eth_stats;
18021803

1804+
if (ice_is_reset_in_progress(pf->state))
1805+
vsi->stat_offsets_loaded = false;
1806+
18031807
ice_stat_update40(hw, GLV_GORCL(vsi_num), vsi->stat_offsets_loaded,
18041808
&prev_es->rx_bytes, &cur_es->rx_bytes);
18051809

@@ -3304,6 +3308,8 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
33043308
goto err_vectors;
33053309

33063310
ice_vsi_map_rings_to_vectors(vsi);
3311+
3312+
vsi->stat_offsets_loaded = false;
33073313
if (ice_is_xdp_ena_vsi(vsi)) {
33083314
ret = ice_vsi_determine_xdp_res(vsi);
33093315
if (ret)
@@ -3340,6 +3346,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
33403346
if (ret)
33413347
goto err_vectors;
33423348

3349+
vsi->stat_offsets_loaded = false;
33433350
break;
33443351
case ICE_VSI_CHNL:
33453352
if (test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6397,6 +6397,7 @@ ice_update_vsi_tx_ring_stats(struct ice_vsi *vsi,
63976397
*/
63986398
static void ice_update_vsi_ring_stats(struct ice_vsi *vsi)
63996399
{
6400+
struct rtnl_link_stats64 *net_stats, *stats_prev;
64006401
struct rtnl_link_stats64 *vsi_stats;
64016402
u64 pkts, bytes;
64026403
int i;
@@ -6436,10 +6437,28 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi)
64366437

64376438
rcu_read_unlock();
64386439

6439-
vsi->net_stats.tx_packets = vsi_stats->tx_packets;
6440-
vsi->net_stats.tx_bytes = vsi_stats->tx_bytes;
6441-
vsi->net_stats.rx_packets = vsi_stats->rx_packets;
6442-
vsi->net_stats.rx_bytes = vsi_stats->rx_bytes;
6440+
net_stats = &vsi->net_stats;
6441+
stats_prev = &vsi->net_stats_prev;
6442+
6443+
/* clear prev counters after reset */
6444+
if (vsi_stats->tx_packets < stats_prev->tx_packets ||
6445+
vsi_stats->rx_packets < stats_prev->rx_packets) {
6446+
stats_prev->tx_packets = 0;
6447+
stats_prev->tx_bytes = 0;
6448+
stats_prev->rx_packets = 0;
6449+
stats_prev->rx_bytes = 0;
6450+
}
6451+
6452+
/* update netdev counters */
6453+
net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets;
6454+
net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes;
6455+
net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets;
6456+
net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes;
6457+
6458+
stats_prev->tx_packets = vsi_stats->tx_packets;
6459+
stats_prev->tx_bytes = vsi_stats->tx_bytes;
6460+
stats_prev->rx_packets = vsi_stats->rx_packets;
6461+
stats_prev->rx_bytes = vsi_stats->rx_bytes;
64436462

64446463
kfree(vsi_stats);
64456464
}
@@ -6501,6 +6520,9 @@ void ice_update_pf_stats(struct ice_pf *pf)
65016520
prev_ps = &pf->stats_prev;
65026521
cur_ps = &pf->stats;
65036522

6523+
if (ice_is_reset_in_progress(pf->state))
6524+
pf->stat_prev_loaded = false;
6525+
65046526
ice_stat_update40(hw, GLPRT_GORCL(port), pf->stat_prev_loaded,
65056527
&prev_ps->eth.rx_bytes,
65066528
&cur_ps->eth.rx_bytes);

0 commit comments

Comments
 (0)