DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
To: dev@dpdk.org
Cc: kishore.padmanabha@broadcom.com,
	Farah Smith <farah.smith@broadcom.com>,
	stable@dpdk.org,
	Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
Subject: [PATCH] net/bnxt: validate ptype table indexing at build time
Date: Sun, 20 Sep 2026 21:07:17 -0600	[thread overview]
Message-ID: <20260921030717.1034849-1-Mohammad-Shuab.Siddique@broadcom.com> (raw)

From: Farah Smith <farah.smith@broadcom.com>

The Thor2/P7 (V3 completion) receive path left a TODO instead of
calling a build-time validation of the ptype lookup table indexing,
unlike the equivalent V2 completion path which already validates its
own index layout via bnxt_check_ptype_constants(). Without it, any
future drift between the V3 completion field shift/mask definitions
and the ptype table's index layout would silently produce an
out-of-bounds ptype table index at runtime instead of being caught
at compile time.

Add bnxt_check_ptype_constants_v3(), mirroring the existing V2
helper, and call it from bnxt_parse_pkt_type_v3() via
RTE_BUILD_BUG_ON.

Fixes: 65d2b0557ba3 ("net/bnxt: support Rx completion v3")
Cc: stable@dpdk.org

Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
---
 drivers/net/bnxt/bnxt_rxr.c |  3 +--
 drivers/net/bnxt/bnxt_rxr.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index 0fab4ddf78..18790d6821 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -575,9 +575,8 @@ bnxt_parse_pkt_type_v3(struct rte_mbuf *mbuf,
 	flags2 = rte_le_to_cpu_32(rxcmp1->flags2);
 	meta = rte_le_to_cpu_32(rxcmp->metadata1_payload_offset);
 
-	/* TODO */
 	/* Validate ptype table indexing at build time. */
-	/* bnxt_check_ptype_constants_v3(); */
+	bnxt_check_ptype_constants_v3();
 
 	/*
 	 * Index format:
diff --git a/drivers/net/bnxt/bnxt_rxr.h b/drivers/net/bnxt/bnxt_rxr.h
index c971233dc3..0e8840e2cd 100644
--- a/drivers/net/bnxt/bnxt_rxr.h
+++ b/drivers/net/bnxt/bnxt_rxr.h
@@ -475,6 +475,17 @@ bnxt_parse_pkt_type_v2(struct rte_mbuf *mbuf,
 	(((f2) & RX_PKT_V3_CMPL_HI_FLAGS2_IP_TYPE) >> \
 	 (RX_PKT_V3_CMPL_FLAGS2_IP_TYPE_SFT - BNXT_PTYPE_TBL_IP_VER_SFT))
 
+static inline void
+bnxt_check_ptype_constants_v3(void)
+{
+	RTE_BUILD_BUG_ON(BNXT_CMPL_V3_ITYPE_TO_IDX(RX_PKT_V3_CMPL_FLAGS_ITYPE_MASK) !=
+			 BNXT_PTYPE_TBL_TYPE_MSK);
+	RTE_BUILD_BUG_ON(BNXT_CMPL_V3_VLAN_TO_IDX(RX_PKT_V3_CMPL_METADATA1_VALID) !=
+			 BNXT_PTYPE_TBL_VLAN_MSK);
+	RTE_BUILD_BUG_ON(BNXT_CMPL_V3_IP_VER_TO_IDX(RX_PKT_V3_CMPL_HI_FLAGS2_IP_TYPE) !=
+			 BNXT_PTYPE_TBL_IP_VER_MSK);
+}
+
 #define RX_CMP_V3_VLAN_VALID(rxcmp)        \
 	(((struct rx_pkt_v3_cmpl *)rxcmp)->metadata1_payload_offset &	\
 	 RX_PKT_V3_CMPL_METADATA1_VALID)
-- 
2.47.3


                 reply	other threads:[~2026-09-21  3:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260921030717.1034849-1-Mohammad-Shuab.Siddique@broadcom.com \
    --to=mohammad-shuab.siddique@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=farah.smith@broadcom.com \
    --cc=kishore.padmanabha@broadcom.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox