diff mbox series

[14/18] net/bnxt: fix ring teardown

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kalesh A P Jan. 4, 2022, 8:38 a.m. UTC
From: Ajit Khaparde <ajit.khaparde@broadcom.com>

Check for valid bit while scanning for hwrm_done completion
during ring teardown. Not checking the valid bit could cause a
ring overflow when we ring the doorbell.

Fixes: 4fb6ab3f866d ("net/bnxt: check flush status during ring free")
Cc: stable@dpdk.org

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
 drivers/net/bnxt/bnxt_rxr.c | 3 +++
 drivers/net/bnxt/bnxt_txr.c | 3 +++
 2 files changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index 9621809..b60c247 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -1411,6 +1411,9 @@  int bnxt_flush_rx_cmp(struct bnxt_cp_ring_info *cpr)
 		cons = RING_CMP(cpr->cp_ring_struct, raw_cons);
 		rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons];
 
+		if (!bnxt_cpr_cmp_valid(rxcmp, raw_cons, ring_mask + 1))
+			break;
+
 		if (CMP_TYPE(rxcmp) == CMPL_BASE_TYPE_HWRM_DONE)
 			return 1;
 
diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
index e2b7e40..3b8f238 100644
--- a/drivers/net/bnxt/bnxt_txr.c
+++ b/drivers/net/bnxt/bnxt_txr.c
@@ -602,6 +602,9 @@  int bnxt_flush_tx_cmp(struct bnxt_cp_ring_info *cpr)
 		cons = RING_CMPL(ring_mask, raw_cons);
 		txcmp = (struct tx_cmpl *)&cp_desc_ring[cons];
 
+		if (!bnxt_cpr_cmp_valid(txcmp, raw_cons, ring_mask + 1))
+			break;
+
 		opaque = rte_cpu_to_le_32(txcmp->opaque);
 		raw_cons = NEXT_RAW_CMP(raw_cons);