DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/bnxt: fix to clear cached value of stats in clear stats
@ 2021-07-13 13:34 Kalesh A P
  2021-07-15  4:23 ` Ajit Khaparde
  0 siblings, 1 reply; 2+ messages in thread
From: Kalesh A P @ 2021-07-13 13:34 UTC (permalink / raw)
  To: dev; +Cc: ajit.khaparde

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

As part of the workaround put in the commit "219842b9990c",
driver caches the last read stats values from the hardware.
But this is not cleared during the clear stats operation. This
results in showing up stale stats values while reading the stats
after the clear operation.

Fixes: 219842b9990c ("net/bnxt: workaround spurious zero stats in Thor")
Cc: stable@dpdk.org

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_stats.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c
index c7b23f4..991eafc 100644
--- a/drivers/net/bnxt/bnxt_stats.c
+++ b/drivers/net/bnxt/bnxt_stats.c
@@ -603,6 +603,16 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
 	return rc;
 }
 
+static void bnxt_clear_prev_stat(struct bnxt *bp)
+{
+	/*
+	 * Clear the cached values of stats returned by HW in the previous
+	 * get operation.
+	 */
+	memset(bp->prev_rx_ring_stats, 0, sizeof(struct bnxt_ring_stats) * bp->rx_cp_nr_rings);
+	memset(bp->prev_tx_ring_stats, 0, sizeof(struct bnxt_ring_stats) * bp->tx_cp_nr_rings);
+}
+
 int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
@@ -625,6 +635,8 @@ int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
 		rte_atomic64_clear(&rxq->rx_mbuf_alloc_fail);
 	}
 
+	bnxt_clear_prev_stat(bp);
+
 	return ret;
 }
 
@@ -933,6 +945,8 @@ int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev)
 		PMD_DRV_LOG(ERR, "Failed to reset xstats: %s\n",
 			    strerror(-ret));
 
+	bnxt_clear_prev_stat(bp);
+
 	return ret;
 }
 
-- 
2.10.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-15  4:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 13:34 [dpdk-dev] [PATCH] net/bnxt: fix to clear cached value of stats in clear stats Kalesh A P
2021-07-15  4:23 ` Ajit Khaparde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).