public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: fix DCB forwarding TC mask and queue guard
@ 2026-03-11  8:37 Talluri Chaitanyababu
  2026-03-11 15:56 ` Stephen Hemminger
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Talluri Chaitanyababu @ 2026-03-11  8:37 UTC (permalink / raw)
  To: dev, bruce.richardson, aman.deep.singh
  Cc: shaiq.wani, Talluri Chaitanyababu, stable

Update forwarding TC mask based on configured traffic classes to properly
handle both 4 TC and 8 TC modes. The bitmask calculation (1u << nb_tcs) - 1
correctly creates masks for all available traffic classes (0xF for 4 TCs,
0xFF for 8 TCs).

When the mask is not updated after a TC configuration change, it stays at
the default 0xFF, which causes dcb_fwd_tc_update_dcb_info() to skip the
compress logic entirely (early return when mask ==
DEFAULT_DCB_FWD_TC_MASK).
This can lead to inconsistent queue allocations.

Additionally, the existing VMDQ pool guard in dcb_fwd_config_setup() only
checks RX queue counts, missing the case where the TX port has zero queues
for a given pool/TC combination. When nb_tx_queue is 0, the expression
"j % nb_tx_queue" triggers a SIGFPE (integer division by zero).

Fix this by:
1. Updating dcb_fwd_tc_mask after port DCB reconfiguration, and returning
   on failure so fwd_config_setup() is not called with a stale mask.
2. Extending the existing pool guard to also check TX queue counts.
3. Adding a defensive break after the division by dcb_fwd_tc_cores to
   catch integer truncation to zero.

Fixes: 0ecbf93f5001 ("app/testpmd: add command to disable DCB")
Cc: stable@dpdk.org

Signed-off-by: Talluri Chaitanyababu <chaitanyababux.talluri@intel.com>
Signed-off-by: Shaiq Wani <shaiq.wani@intel.com>
---
 app/test-pmd/cmdline.c | 13 +++++++++++++
 app/test-pmd/config.c  |  9 ++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index c33c66f327..3fb9b940eb 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3682,6 +3682,19 @@ cmd_config_dcb_parsed(void *parsed_result,
 		return;
 	}
 
+	/*
+	 * Update forwarding TC mask to match actual configured TCs.
+	 * Must query after init_port_dcb_config() to get updated nb_tcs.
+	 */
+	ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
+	if (ret == 0 && dcb_info.nb_tcs > 0) {
+		dcb_fwd_tc_mask = (1u << dcb_info.nb_tcs) - 1;
+	} else if (ret != 0) {
+		fprintf(stderr, "Failed to get DCB info for port %u: %s\n",
+				port_id, rte_strerror(-ret));
+		return;
+	}
+
 	fwd_config_setup();
 
 	cmd_reconfig_device_queue(port_id, 1, 1);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index f9f3c542a6..9b201ac241 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -5450,7 +5450,8 @@ dcb_fwd_config_setup(void)
 			/* if the nb_queue is zero, means this tc is
 			 * not enabled on the POOL
 			 */
-			if (rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue == 0)
+			if (rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue == 0 ||
+			    txp_dcb_info.tc_queue.tc_txq[i][tc].nb_queue == 0)
 				break;
 			k = fwd_lcores[lc_id]->stream_nb +
 				fwd_lcores[lc_id]->stream_idx;
@@ -5458,6 +5459,12 @@ dcb_fwd_config_setup(void)
 						dcb_fwd_tc_cores;
 			nb_tx_queue = txp_dcb_info.tc_queue.tc_txq[i][tc].nb_queue /
 						dcb_fwd_tc_cores;
+			/* guard against integer truncation to zero (e.g.
+			 * nb_queue=1, dcb_fwd_tc_cores=2) to prevent SIGFPE
+			 * from "j % nb_tx_queue" below.
+			 */
+			if (nb_rx_queue == 0 || nb_tx_queue == 0)
+				break;
 			rxq = rxp_dcb_info.tc_queue.tc_rxq[i][tc].base + nb_rx_queue * sub_core_idx;
 			txq = txp_dcb_info.tc_queue.tc_txq[i][tc].base + nb_tx_queue * sub_core_idx;
 			for (j = 0; j < nb_rx_queue; j++) {
-- 
2.43.0


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

end of thread, other threads:[~2026-03-24  0:07 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11  8:37 [PATCH] app/testpmd: fix DCB forwarding TC mask and queue guard Talluri Chaitanyababu
2026-03-11 15:56 ` Stephen Hemminger
2026-03-12 10:36 ` [PATCH v2] " Talluri Chaitanyababu
2026-03-12 18:44   ` Stephen Hemminger
2026-03-13  0:19   ` fengchengwen
2026-03-16  6:05     ` Talluri, ChaitanyababuX
2026-03-17  1:07       ` fengchengwen
2026-03-18  7:21         ` Talluri, ChaitanyababuX
2026-03-19  1:19           ` fengchengwen
2026-03-16  6:21 ` [PATCH v3] " Talluri Chaitanyababu
2026-03-17  1:23   ` fengchengwen
2026-03-17  8:57   ` Thomas Monjalon
2026-03-17  9:02     ` Thomas Monjalon
2026-03-18  6:17 ` [PATCH v4] app/testpmd: fix DCB forwarding TC mismatch handling Talluri Chaitanyababu
2026-03-19  1:35   ` fengchengwen
2026-03-20  6:29 ` [PATCH v5] " Talluri Chaitanyababu
2026-03-20  9:38   ` fengchengwen
2026-03-24  0:06   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox