This patch fixes a bug where only some of the statistics were being reset
when calling rte_eth_stats_reset() or rte_eth_xstats_reset().

This patch marks the VSI to update its offset, causing the stats be look
like they are reset.

Fixes: 9aace75fc82e ("i40e: fix statistics")

Signed-off-by: Harry van Haaren <harry.van.haaren at gmail.com>
---
 drivers/net/i40e/i40e_ethdev.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index a39bd28..70c1674 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2129,14 +2129,15 @@ i40e_dev_xstats_reset(struct rte_eth_dev *dev)
 {
        struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct i40e_hw_port_stats *hw_stats = &pf->stats;
+       /*struct i40e_hw_port_stats *hw_stats = &pf->stats;*/

-       /* The hw registers are cleared on read */
+       /* Mark PF and VSI stats to update the offset, aka "reset" */
        pf->offset_loaded = false;
-       i40e_read_stats_registers(pf, hw);
+       if (pf->main_vsi)
+               pf->main_vsi->offset_loaded = false;

-       /* reset software counters */
-       memset(hw_stats, 0, sizeof(*hw_stats));
+       /* read the stats, reading current register values into offset */
+       i40e_read_stats_registers(pf, hw);
 }

 static int
-- 
1.9.1

Reply via email to