DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/4] enhance testpmd DCB command
@ 2025-02-25  9:19 Chengwen Feng
  2025-02-25  9:19 ` [PATCH 1/4] app/testpmd: remove restrict of number of TCs in " Chengwen Feng
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Chengwen Feng @ 2025-02-25  9:19 UTC (permalink / raw)
  To: thomas, stephen, aman.deep.singh; +Cc: dev

This patchset enhance the testpmd DCB command features:
1) remove restrict of number of TCs (currently its 4 or 8)
2) support config prio-tc map
3) support don't adjust queue num
4) support disable DCB

Chengwen Feng (4):
  app/testpmd: remove restrict of number of TCs in DCB command
  app/testpmd: support config prio-tc map in DCB command
  app/testpmd: support don't adjust queue num in DCB command
  app/testpmd: support disable DCB command

 app/test-pmd/cmdline.c                      | 184 ++++++++++++++++++--
 app/test-pmd/testpmd.c                      |  96 ++++++----
 app/test-pmd/testpmd.h                      |   5 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   6 +-
 4 files changed, 236 insertions(+), 55 deletions(-)

-- 
2.17.1


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

* [PATCH 1/4] app/testpmd: remove restrict of number of TCs in DCB command
  2025-02-25  9:19 [PATCH 0/4] enhance testpmd DCB command Chengwen Feng
@ 2025-02-25  9:19 ` Chengwen Feng
  2025-02-25  9:19 ` [PATCH 2/4] app/testpmd: support config prio-tc map " Chengwen Feng
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Chengwen Feng @ 2025-02-25  9:19 UTC (permalink / raw)
  To: thomas, stephen, aman.deep.singh; +Cc: dev

Currently, the "port config 0 dcb ..." command only supports 4 or 8
TCs. Other number of TCs may be used in actual applications.

This commit removes this restriction.

Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline.c                      | 4 ++--
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 86d763b66a..c23b811764 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3469,9 +3469,9 @@ cmd_config_dcb_parsed(void *parsed_result,
 		return;
 	}
 
-	if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
+	if ((res->num_tcs <= 1 || res->num_tcs > RTE_ETH_8_TCS)) {
 		fprintf(stderr,
-			"The invalid number of traffic class, only 4 or 8 allowed.\n");
+			"The invalid number of traffic class, only 2~8 allowed.\n");
 		return;
 	}
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index eeef49500f..38bc00705f 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2167,7 +2167,7 @@ Set the DCB mode for an individual port::
 
    testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off)
 
-The traffic class should be 4 or 8.
+The traffic class could be 2~8.
 
 port config - Burst
 ~~~~~~~~~~~~~~~~~~~
-- 
2.17.1


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

* [PATCH 2/4] app/testpmd: support config prio-tc map in DCB command
  2025-02-25  9:19 [PATCH 0/4] enhance testpmd DCB command Chengwen Feng
  2025-02-25  9:19 ` [PATCH 1/4] app/testpmd: remove restrict of number of TCs in " Chengwen Feng
@ 2025-02-25  9:19 ` Chengwen Feng
  2025-02-25  9:19 ` [PATCH 3/4] app/testpmd: support don't adjust queue num " Chengwen Feng
  2025-02-25  9:19 ` [PATCH 4/4] app/testpmd: support disable " Chengwen Feng
  3 siblings, 0 replies; 5+ messages in thread
From: Chengwen Feng @ 2025-02-25  9:19 UTC (permalink / raw)
  To: thomas, stephen, aman.deep.singh; +Cc: dev

Currently, the "port config 0 dcb ..." command config the prio-tc map
by remainder operation, which means the prio-tc = prio % nb_tcs.

This commit introduces an optional parameter "prio-tc" which is the same
as kernel dcb ets tool. The new command:

  port config 0 dcb vt off 4 pfc off prio-tc 0:1 1:2 2:3 ...

If this parameter is not specified, the prio-tc map is configured by
default.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline.c                      | 119 ++++++++++++++++++--
 app/test-pmd/testpmd.c                      |  21 ++--
 app/test-pmd/testpmd.h                      |   4 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   3 +-
 4 files changed, 125 insertions(+), 22 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index c23b811764..a8aa948c81 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3447,19 +3447,111 @@ struct cmd_config_dcb {
 	cmdline_fixed_string_t vt_en;
 	uint8_t num_tcs;
 	cmdline_fixed_string_t pfc;
-	cmdline_fixed_string_t pfc_en;
+	cmdline_multi_string_t token_str;
 };
 
+static int
+parse_dcb_token_prio_tc(char *param_str[], int param_num,
+			uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
+			uint8_t *prio_tc_en)
+{
+	unsigned long prio, tc;
+	int prio_tc_maps = 0;
+	char *param, *end;
+	int i;
+
+	for (i = 0; i < param_num; i++) {
+		param = param_str[i];
+		prio = strtoul(param, &end, 10);
+		if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
+			fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
+			return -1;
+		}
+		if ((*end != ':') || (strlen(end + 1) == 0)) {
+			fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
+			return -1;
+		}
+		tc = strtoul(end + 1, &end, 10);
+		if (tc >= RTE_ETH_8_TCS) {
+			fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
+			return -1;
+		}
+		if (*end != '\0') {
+			fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
+			return -1;
+		}
+		prio_tc[prio] = tc;
+		prio_tc_maps++;
+	} while (0);
+
+	if (prio_tc_maps == 0) {
+		fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
+		return -1;
+	}
+	*prio_tc_en = 1;
+
+	return 0;
+}
+
+static int
+parse_dcb_token_value(char *token_str,
+		      uint8_t *pfc_en,
+		      uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
+		      uint8_t *prio_tc_en)
+{
+#define MAX_TOKEN_NUM	128
+	char *split_str[MAX_TOKEN_NUM];
+	int split_num = 0;
+	char *token;
+
+	/* split multiple token to split str. */
+	do {
+		token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
+		if (token == NULL)
+			break;
+		if (split_num >= MAX_TOKEN_NUM) {
+			fprintf(stderr, "Bad Argument: too much argument\n");
+			return -1;
+		}
+		split_str[split_num++] = token;
+	} while (1);
+
+	/* parse fixed parameter "pfc-en" first. */
+	token = split_str[0];
+	if (strcmp(token, "on") == 0)
+		*pfc_en = 1;
+	else if (strcmp(token, "off") == 0)
+		*pfc_en = 0;
+	else {
+		fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
+		return -EINVAL;
+	}
+
+	if (split_num == 1)
+		return 0;
+
+	/* start parse optional parameter. */
+	token = split_str[1];
+	if (strcmp(token, "prio-tc") != 0) {
+		fprintf(stderr, "Bad Argument: unknown token %s\n", token);
+		return -1;
+	}
+
+	return parse_dcb_token_prio_tc(&split_str[2], split_num - 2, prio_tc, prio_tc_en);
+}
+
 static void
 cmd_config_dcb_parsed(void *parsed_result,
                         __rte_unused struct cmdline *cl,
                         __rte_unused void *data)
 {
+	uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
 	struct cmd_config_dcb *res = parsed_result;
 	struct rte_eth_dcb_info dcb_info;
 	portid_t port_id = res->port_id;
+	uint8_t prio_tc_en = 0;
 	struct rte_port *port;
-	uint8_t pfc_en;
+	uint8_t pfc_en = 0;
 	int ret;
 
 	port = &ports[port_id];
@@ -3488,20 +3580,19 @@ cmd_config_dcb_parsed(void *parsed_result,
 		return;
 	}
 
-	if (!strncmp(res->pfc_en, "on", 2))
-		pfc_en = 1;
-	else
-		pfc_en = 0;
+	ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en);
+	if (ret != 0)
+		return;
 
 	/* DCB in VT mode */
 	if (!strncmp(res->vt_en, "on", 2))
 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
 				(enum rte_eth_nb_tcs)res->num_tcs,
-				pfc_en);
+				pfc_en, prio_tc, prio_tc_en);
 	else
 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
 				(enum rte_eth_nb_tcs)res->num_tcs,
-				pfc_en);
+				pfc_en, prio_tc, prio_tc_en);
 	if (ret != 0) {
 		fprintf(stderr, "Cannot initialize network ports.\n");
 		return;
@@ -3528,13 +3619,17 @@ static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
 static cmdline_parse_token_string_t cmd_config_dcb_pfc =
         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
-static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
-        TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
+static cmdline_parse_token_string_t cmd_config_dcb_token_str =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
 
 static cmdline_parse_inst_t cmd_config_dcb = {
 	.f = cmd_config_dcb_parsed,
 	.data = NULL,
-	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
+	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP\n"
+		    "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
+		    "      PRIO-MAPPING := PRIO:TC\n"
+		    "      PRIO: { 0 .. 7 }\n"
+		    "      TC: { 0 .. 7 }",
 	.tokens = {
 		(void *)&cmd_config_dcb_port,
 		(void *)&cmd_config_dcb_config,
@@ -3544,7 +3639,7 @@ static cmdline_parse_inst_t cmd_config_dcb = {
 		(void *)&cmd_config_dcb_vt_en,
 		(void *)&cmd_config_dcb_num_tcs,
 		(void *)&cmd_config_dcb_pfc,
-		(void *)&cmd_config_dcb_pfc_en,
+		(void *)&cmd_config_dcb_token_str,
                 NULL,
         },
 };
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0520aba0db..f4c23fd896 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4126,9 +4126,10 @@ const uint16_t vlan_tags[] = {
 
 static void
 get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,
-		 enum rte_eth_nb_tcs num_tcs, uint8_t pfc_en)
+		 enum rte_eth_nb_tcs num_tcs, uint8_t pfc_en,
+		 uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES], uint8_t prio_tc_en)
 {
-	uint8_t i;
+	uint8_t dcb_tc_val, i;
 
 	/*
 	 * Builds up the correct configuration for dcb+vt based on the vlan tags array
@@ -4155,8 +4156,9 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,
 				1 << (i % vmdq_rx_conf->nb_queue_pools);
 		}
 		for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
-			vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
-			vmdq_tx_conf->dcb_tc[i] = i % num_tcs;
+			dcb_tc_val = prio_tc_en ? prio_tc[i] : i % num_tcs;
+			vmdq_rx_conf->dcb_tc[i] = dcb_tc_val;
+			vmdq_tx_conf->dcb_tc[i] = dcb_tc_val;
 		}
 
 		/* set DCB mode of RX and TX of multiple queues */
@@ -4174,8 +4176,9 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,
 		tx_conf->nb_tcs = num_tcs;
 
 		for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++) {
-			rx_conf->dcb_tc[i] = i % num_tcs;
-			tx_conf->dcb_tc[i] = i % num_tcs;
+			dcb_tc_val = prio_tc_en ? prio_tc[i] : i % num_tcs;
+			rx_conf->dcb_tc[i] = dcb_tc_val;
+			tx_conf->dcb_tc[i] = dcb_tc_val;
 		}
 
 		eth_conf->rxmode.mq_mode =
@@ -4195,7 +4198,9 @@ int
 init_port_dcb_config(portid_t pid,
 		     enum dcb_mode_enable dcb_mode,
 		     enum rte_eth_nb_tcs num_tcs,
-		     uint8_t pfc_en)
+		     uint8_t pfc_en,
+		     uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
+		     uint8_t prio_tc_en)
 {
 	struct rte_eth_conf port_conf;
 	struct rte_port *rte_port;
@@ -4212,7 +4217,7 @@ init_port_dcb_config(portid_t pid,
 	memcpy(&port_conf, &rte_port->dev_conf, sizeof(struct rte_eth_conf));
 
 	/* set configuration of DCB in vt mode and DCB in non-vt mode */
-	get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en);
+	get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en, prio_tc, prio_tc_en);
 
 	port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
 	/* remove RSS HASH offload for DCB in vt mode */
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a933fb433a..671641dac5 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1150,7 +1150,9 @@ uint8_t port_is_bonding_member(portid_t member_pid);
 
 int init_port_dcb_config(portid_t pid, enum dcb_mode_enable dcb_mode,
 		     enum rte_eth_nb_tcs num_tcs,
-		     uint8_t pfc_en);
+		     uint8_t pfc_en,
+		     uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
+		     uint8_t prio_tc_en);
 int start_port(portid_t pid);
 void stop_port(portid_t pid);
 void close_port(portid_t pid);
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 38bc00705f..3cbc377271 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2165,9 +2165,10 @@ port config - DCB
 
 Set the DCB mode for an individual port::
 
-   testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off)
+   testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off) prio-tc (prio-tc)
 
 The traffic class could be 2~8.
+The prio-tc field here is optional, if not specified then the prio-tc use default configuration.
 
 port config - Burst
 ~~~~~~~~~~~~~~~~~~~
-- 
2.17.1


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

* [PATCH 3/4] app/testpmd: support don't adjust queue num in DCB command
  2025-02-25  9:19 [PATCH 0/4] enhance testpmd DCB command Chengwen Feng
  2025-02-25  9:19 ` [PATCH 1/4] app/testpmd: remove restrict of number of TCs in " Chengwen Feng
  2025-02-25  9:19 ` [PATCH 2/4] app/testpmd: support config prio-tc map " Chengwen Feng
@ 2025-02-25  9:19 ` Chengwen Feng
  2025-02-25  9:19 ` [PATCH 4/4] app/testpmd: support disable " Chengwen Feng
  3 siblings, 0 replies; 5+ messages in thread
From: Chengwen Feng @ 2025-02-25  9:19 UTC (permalink / raw)
  To: thomas, stephen, aman.deep.singh; +Cc: dev

In some test scenarios, users want to test DCB by specifying the number
of Rx/Tx queues. But the "port config 0 dcb ..." command will auto
adjust Rx/Tx queue number.

This patch introduces an optional parameter "keep-qnum" which make sure
the "port config 0 dcb ..." command don't adjust Rx/Tx queue number.
The new command:

  port config 0 dcb vt off 4 pfc off keep-qnum

If this parameter is not specified, the Rx/Tx queue number was adjusted
by default.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline.c                      | 83 ++++++++++++++++++---
 app/test-pmd/testpmd.c                      | 41 +++++-----
 app/test-pmd/testpmd.h                      |  3 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  3 +-
 4 files changed, 98 insertions(+), 32 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index a8aa948c81..ef65a75dc7 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3493,14 +3493,47 @@ parse_dcb_token_prio_tc(char *param_str[], int param_num,
 	return 0;
 }
 
+#define DCB_TOKEN_PRIO_TC	"prio-tc"
+#define DCB_TOKEN_KEEP_QNUM	"keep-qnum"
+
+static int
+parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
+{
+	int i;
+
+	if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
+		*param_num = 0;
+		return 0;
+	}
+
+	if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
+		fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
+		return -EINVAL;
+	}
+
+	for (i = 1; i < split_num; i++) {
+		if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
+		    (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
+			continue;
+		/* find another optional parameter, then exit. */
+		break;
+	}
+
+	*param_num = i - 1;
+
+	return 0;
+}
+
 static int
 parse_dcb_token_value(char *token_str,
 		      uint8_t *pfc_en,
 		      uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
-		      uint8_t *prio_tc_en)
+		      uint8_t *prio_tc_en,
+		      uint8_t *keep_qnum)
 {
 #define MAX_TOKEN_NUM	128
 	char *split_str[MAX_TOKEN_NUM];
+	int param_num, start, ret;
 	int split_num = 0;
 	char *token;
 
@@ -3531,13 +3564,40 @@ parse_dcb_token_value(char *token_str,
 		return 0;
 
 	/* start parse optional parameter. */
-	token = split_str[1];
-	if (strcmp(token, "prio-tc") != 0) {
-		fprintf(stderr, "Bad Argument: unknown token %s\n", token);
-		return -1;
-	}
+	start = 1;
+	do {
+		param_num = 0;
+		ret = parse_dcb_token_find(&split_str[start], split_num - start, &param_num);
+		if (ret != 0)
+			return ret;
 
-	return parse_dcb_token_prio_tc(&split_str[2], split_num - 2, prio_tc, prio_tc_en);
+		token = split_str[start];
+		if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
+			if (*prio_tc_en == 1) {
+				fprintf(stderr, "Bad Argument: detect multiple %s token\n",
+					DCB_TOKEN_PRIO_TC);
+				return -1;
+			}
+			ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
+						      prio_tc_en);
+			if (ret != 0)
+				return ret;
+		} else {
+			/* this must be keep-qnum. */
+			if (*keep_qnum == 1) {
+				fprintf(stderr, "Bad Argument: detect multiple %s token\n",
+					DCB_TOKEN_KEEP_QNUM);
+				return -1;
+			}
+			*keep_qnum = 1;
+		}
+
+		start += param_num + 1;
+		if (start >= split_num)
+			break;
+	} while (1);
+
+	return 0;
 }
 
 static void
@@ -3550,6 +3610,7 @@ cmd_config_dcb_parsed(void *parsed_result,
 	struct rte_eth_dcb_info dcb_info;
 	portid_t port_id = res->port_id;
 	uint8_t prio_tc_en = 0;
+	uint8_t keep_qnum = 0;
 	struct rte_port *port;
 	uint8_t pfc_en = 0;
 	int ret;
@@ -3580,7 +3641,7 @@ cmd_config_dcb_parsed(void *parsed_result,
 		return;
 	}
 
-	ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en);
+	ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
 	if (ret != 0)
 		return;
 
@@ -3588,11 +3649,11 @@ cmd_config_dcb_parsed(void *parsed_result,
 	if (!strncmp(res->vt_en, "on", 2))
 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
 				(enum rte_eth_nb_tcs)res->num_tcs,
-				pfc_en, prio_tc, prio_tc_en);
+				pfc_en, prio_tc, prio_tc_en, keep_qnum);
 	else
 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
 				(enum rte_eth_nb_tcs)res->num_tcs,
-				pfc_en, prio_tc, prio_tc_en);
+				pfc_en, prio_tc, prio_tc_en, keep_qnum);
 	if (ret != 0) {
 		fprintf(stderr, "Cannot initialize network ports.\n");
 		return;
@@ -3625,7 +3686,7 @@ static cmdline_parse_token_string_t cmd_config_dcb_token_str =
 static cmdline_parse_inst_t cmd_config_dcb = {
 	.f = cmd_config_dcb_parsed,
 	.data = NULL,
-	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP\n"
+	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
 		    "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
 		    "      PRIO-MAPPING := PRIO:TC\n"
 		    "      PRIO: { 0 .. 7 }\n"
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index f4c23fd896..b11762f698 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4200,7 +4200,8 @@ init_port_dcb_config(portid_t pid,
 		     enum rte_eth_nb_tcs num_tcs,
 		     uint8_t pfc_en,
 		     uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
-		     uint8_t prio_tc_en)
+		     uint8_t prio_tc_en,
+		     uint8_t keep_qnum)
 {
 	struct rte_eth_conf port_conf;
 	struct rte_port *rte_port;
@@ -4248,26 +4249,28 @@ init_port_dcb_config(portid_t pid,
 		return -1;
 	}
 
-	/* Assume the ports in testpmd have the same dcb capability
-	 * and has the same number of rxq and txq in dcb mode
-	 */
-	if (dcb_mode == DCB_VT_ENABLED) {
-		if (rte_port->dev_info.max_vfs > 0) {
-			nb_rxq = rte_port->dev_info.nb_rx_queues;
-			nb_txq = rte_port->dev_info.nb_tx_queues;
-		} else {
-			nb_rxq = rte_port->dev_info.max_rx_queues;
-			nb_txq = rte_port->dev_info.max_tx_queues;
-		}
-	} else {
-		/*if vt is disabled, use all pf queues */
-		if (rte_port->dev_info.vmdq_pool_base == 0) {
-			nb_rxq = rte_port->dev_info.max_rx_queues;
-			nb_txq = rte_port->dev_info.max_tx_queues;
+	if (keep_qnum == 0) {
+		/* Assume the ports in testpmd have the same dcb capability
+		 * and has the same number of rxq and txq in dcb mode
+		 */
+		if (dcb_mode == DCB_VT_ENABLED) {
+			if (rte_port->dev_info.max_vfs > 0) {
+				nb_rxq = rte_port->dev_info.nb_rx_queues;
+				nb_txq = rte_port->dev_info.nb_tx_queues;
+			} else {
+				nb_rxq = rte_port->dev_info.max_rx_queues;
+				nb_txq = rte_port->dev_info.max_tx_queues;
+			}
 		} else {
-			nb_rxq = (queueid_t)num_tcs;
-			nb_txq = (queueid_t)num_tcs;
+			/*if vt is disabled, use all pf queues */
+			if (rte_port->dev_info.vmdq_pool_base == 0) {
+				nb_rxq = rte_port->dev_info.max_rx_queues;
+				nb_txq = rte_port->dev_info.max_tx_queues;
+			} else {
+				nb_rxq = (queueid_t)num_tcs;
+				nb_txq = (queueid_t)num_tcs;
 
+			}
 		}
 	}
 	rx_free_thresh = 64;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 671641dac5..8b21021aa0 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1152,7 +1152,8 @@ int init_port_dcb_config(portid_t pid, enum dcb_mode_enable dcb_mode,
 		     enum rte_eth_nb_tcs num_tcs,
 		     uint8_t pfc_en,
 		     uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
-		     uint8_t prio_tc_en);
+		     uint8_t prio_tc_en,
+		     uint8_t keep_qnum);
 int start_port(portid_t pid);
 void stop_port(portid_t pid);
 void close_port(portid_t pid);
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 3cbc377271..44eed3f49d 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2165,10 +2165,11 @@ port config - DCB
 
 Set the DCB mode for an individual port::
 
-   testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off) prio-tc (prio-tc)
+   testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off) prio-tc (prio-tc) keep-qnum
 
 The traffic class could be 2~8.
 The prio-tc field here is optional, if not specified then the prio-tc use default configuration.
+The keep-qnum field here is also optional, if specified then don't adjust Rx/Tx queue number.
 
 port config - Burst
 ~~~~~~~~~~~~~~~~~~~
-- 
2.17.1


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

* [PATCH 4/4] app/testpmd: support disable DCB command
  2025-02-25  9:19 [PATCH 0/4] enhance testpmd DCB command Chengwen Feng
                   ` (2 preceding siblings ...)
  2025-02-25  9:19 ` [PATCH 3/4] app/testpmd: support don't adjust queue num " Chengwen Feng
@ 2025-02-25  9:19 ` Chengwen Feng
  3 siblings, 0 replies; 5+ messages in thread
From: Chengwen Feng @ 2025-02-25  9:19 UTC (permalink / raw)
  To: thomas, stephen, aman.deep.singh; +Cc: dev

After the "port config 0 dcb ..." command is invoked, no command is
available to disable DCB.

This commit introduces disable DCB when num_tcs is 1, so user could
disable the DCB by command:
  port config 0 dcb vt off 1 pfc off

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline.c                      |  4 +--
 app/test-pmd/testpmd.c                      | 40 +++++++++++++--------
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  2 +-
 3 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index ef65a75dc7..517e8d47b6 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3622,9 +3622,9 @@ cmd_config_dcb_parsed(void *parsed_result,
 		return;
 	}
 
-	if ((res->num_tcs <= 1 || res->num_tcs > RTE_ETH_8_TCS)) {
+	if ((res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS)) {
 		fprintf(stderr,
-			"The invalid number of traffic class, only 2~8 allowed.\n");
+			"The invalid number of traffic class, only 1~8 allowed.\n");
 		return;
 	}
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index b11762f698..5e0892d99b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4194,6 +4194,14 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, enum dcb_mode_enable dcb_mode,
 		eth_conf->dcb_capability_en = RTE_ETH_DCB_PG_SUPPORT;
 }
 
+static void
+clear_eth_dcb_conf(struct rte_eth_conf *eth_conf)
+{
+	eth_conf->rxmode.mq_mode &= ~(RTE_ETH_MQ_RX_DCB | RTE_ETH_MQ_RX_VMDQ_DCB);
+	eth_conf->txmode.mq_mode = RTE_ETH_MQ_TX_NONE;
+	eth_conf->dcb_capability_en = 0;
+}
+
 int
 init_port_dcb_config(portid_t pid,
 		     enum dcb_mode_enable dcb_mode,
@@ -4217,16 +4225,19 @@ init_port_dcb_config(portid_t pid,
 	/* retain the original device configuration. */
 	memcpy(&port_conf, &rte_port->dev_conf, sizeof(struct rte_eth_conf));
 
-	/* set configuration of DCB in vt mode and DCB in non-vt mode */
-	get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en, prio_tc, prio_tc_en);
-
-	port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
-	/* remove RSS HASH offload for DCB in vt mode */
-	if (port_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB) {
-		port_conf.rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_RSS_HASH;
-		for (i = 0; i < nb_rxq; i++)
-			rte_port->rxq[i].conf.offloads &=
-				~RTE_ETH_RX_OFFLOAD_RSS_HASH;
+	if (num_tcs > 1) {
+		/* set configuration of DCB in vt mode and DCB in non-vt mode */
+		get_eth_dcb_conf(&port_conf, dcb_mode, num_tcs, pfc_en, prio_tc, prio_tc_en);
+		port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
+		/* remove RSS HASH offload for DCB in vt mode */
+		if (port_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB) {
+			port_conf.rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_RSS_HASH;
+			for (i = 0; i < nb_rxq; i++)
+				rte_port->rxq[i].conf.offloads &=
+					~RTE_ETH_RX_OFFLOAD_RSS_HASH;
+		}
+	} else {
+		clear_eth_dcb_conf(&port_conf);
 	}
 
 	/* re-configure the device . */
@@ -4241,7 +4252,8 @@ init_port_dcb_config(portid_t pid,
 	/* If dev_info.vmdq_pool_base is greater than 0,
 	 * the queue id of vmdq pools is started after pf queues.
 	 */
-	if (dcb_mode == DCB_VT_ENABLED &&
+	if (num_tcs > 1 &&
+	    dcb_mode == DCB_VT_ENABLED &&
 	    rte_port->dev_info.vmdq_pool_base > 0) {
 		fprintf(stderr,
 			"VMDQ_DCB multi-queue mode is nonsensical for port %d.\n",
@@ -4249,7 +4261,7 @@ init_port_dcb_config(portid_t pid,
 		return -1;
 	}
 
-	if (keep_qnum == 0) {
+	if (num_tcs > 1 && keep_qnum == 0) {
 		/* Assume the ports in testpmd have the same dcb capability
 		 * and has the same number of rxq and txq in dcb mode
 		 */
@@ -4287,10 +4299,10 @@ init_port_dcb_config(portid_t pid,
 	if (retval != 0)
 		return retval;
 
-	rte_port->dcb_flag = 1;
+	rte_port->dcb_flag = num_tcs > 1 ? 1 : 0;
 
 	/* Enter DCB configuration status */
-	dcb_config = 1;
+	dcb_config = num_tcs > 1 ? 1 : 0;
 
 	return 0;
 }
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 44eed3f49d..6ad83ae50d 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2167,7 +2167,7 @@ Set the DCB mode for an individual port::
 
    testpmd> port config (port_id) dcb vt (on|off) (traffic_class) pfc (on|off) prio-tc (prio-tc) keep-qnum
 
-The traffic class could be 2~8.
+The traffic class could be 1~8, if the value is 1, DCB is disabled.
 The prio-tc field here is optional, if not specified then the prio-tc use default configuration.
 The keep-qnum field here is also optional, if specified then don't adjust Rx/Tx queue number.
 
-- 
2.17.1


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

end of thread, other threads:[~2025-02-25  9:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-25  9:19 [PATCH 0/4] enhance testpmd DCB command Chengwen Feng
2025-02-25  9:19 ` [PATCH 1/4] app/testpmd: remove restrict of number of TCs in " Chengwen Feng
2025-02-25  9:19 ` [PATCH 2/4] app/testpmd: support config prio-tc map " Chengwen Feng
2025-02-25  9:19 ` [PATCH 3/4] app/testpmd: support don't adjust queue num " Chengwen Feng
2025-02-25  9:19 ` [PATCH 4/4] app/testpmd: support disable " Chengwen Feng

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).