[1/3] net/bnxt: fix Tx queue stats after queue stop and start

Message ID 20230201042014.23526-2-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers
Series bnxt PMD fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kalesh A P Feb. 1, 2023, 4:20 a.m. UTC
  From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

The Tx queue stats are being reported incorrectly due to a workaround
for ring counters sometimes being reported as zero.  When a queue is
stopped and started, the ring counter is reset to zero.  The workaround
interprets the zero as incorrect, and sets the reported ring count as
the previously read value (from before the queue being restared).  This
shows up as negative counters in testpmd's "show fwd stats" command.
The fix clears the prev counter for the queue when the queue is started.

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>
---
 drivers/net/bnxt/bnxt_txr.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
index 67e0167..21c2217 100644
--- a/drivers/net/bnxt/bnxt_txr.c
+++ b/drivers/net/bnxt/bnxt_txr.c
@@ -560,6 +560,12 @@  int bnxt_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	if (rc)
 		return rc;
 
+	/* reset the previous stats for the tx_queue since the counters
+	 * will be cleared when the queue is started.
+	 */
+	memset(&bp->prev_tx_ring_stats[tx_queue_id], 0,
+	       sizeof(struct bnxt_ring_stats));
+
 	bnxt_free_hwrm_tx_ring(bp, tx_queue_id);
 	rc = bnxt_alloc_hwrm_tx_ring(bp, tx_queue_id);
 	if (rc)