DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <stephen@networkplumber.org>,
	<aman.deep.singh@intel.com>
Cc: <dev@dpdk.org>
Subject: [PATCH 3/4] app/testpmd: support don't adjust queue num in DCB command
Date: Tue, 25 Feb 2025 17:19:28 +0800	[thread overview]
Message-ID: <20250225091929.25072-4-fengchengwen@huawei.com> (raw)
In-Reply-To: <20250225091929.25072-1-fengchengwen@huawei.com>

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


  parent reply	other threads:[~2025-02-25  9:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25  9:19 [PATCH 0/4] enhance testpmd " 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 [this message]
2025-02-25  9:19 ` [PATCH 4/4] app/testpmd: support disable " Chengwen Feng
2025-02-25 14:42 ` [PATCH 0/4] enhance testpmd " Stephen Hemminger

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=20250225091929.25072-4-fengchengwen@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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;
as well as URLs for NNTP newsgroup(s).