DPDK patches and discussions
 help / color / mirror / Atom feed
From: Huisong Li <lihuisong@huawei.com>
To: <aman.deep.singh@intel.com>, <yuying.zhang@intel.com>,
	<ferruh.yigit@xilinx.com>, <andrew.rybchenko@oktetlabs.ru>
Cc: <dev@dpdk.org>, <thomas@monjalon.net>, <huangdaode@huawei.com>,
	<liudongdong3@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH V5 3/7] app/testpmd: refactor config all RSS command
Date: Fri, 24 Jun 2022 15:23:57 +0800	[thread overview]
Message-ID: <20220624072401.21839-4-lihuisong@huawei.com> (raw)
In-Reply-To: <20220624072401.21839-1-lihuisong@huawei.com>

The "port config <port_id> rss-hash-key" and "show port <port_id> rss-hash
key" commands both use the 'rss_type_table[]' to get 'rss_types' or the RSS
type name. So this patch uses the 'rss_type_table[]' to get the rss types.
In this way, this command naturally supports more individual types.

Suggested-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 app/test-pmd/cmdline.c                      | 127 ++++++--------------
 app/test-pmd/config.c                       |  20 ++-
 app/test-pmd/testpmd.h                      |   1 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  11 +-
 4 files changed, 63 insertions(+), 96 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index a701bac953..bea869ce56 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -693,9 +693,14 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Enable or disable packet drop on all RX queues of all ports when no "
 			"receive buffers available.\n\n"
 
-			"port config all rss (all|default|ip|tcp|udp|sctp|"
-			"l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|"
-			"none|level-default|level-outer|level-inner|<flowtype_id>)\n"
+			"port config all rss (all|default|level-default|level-outer|level-inner|"
+			"ip|tcp|udp|sctp|tunnel|vlan|none|"
+			"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
+			"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
+			"l2_payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
+			"esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
+			"l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
+			"l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
 			"    Set the RSS mode.\n\n"
 
 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
@@ -2062,81 +2067,7 @@ cmd_config_rss_parsed(void *parsed_result,
 	uint16_t i;
 	int ret;
 
-	if (!strcmp(res->value, "all"))
-		rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
-			RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
-			RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
-			RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
-			RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2;
-	else if (!strcmp(res->value, "eth"))
-		rss_conf.rss_hf = RTE_ETH_RSS_ETH;
-	else if (!strcmp(res->value, "vlan"))
-		rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
-	else if (!strcmp(res->value, "ip"))
-		rss_conf.rss_hf = RTE_ETH_RSS_IP;
-	else if (!strcmp(res->value, "udp"))
-		rss_conf.rss_hf = RTE_ETH_RSS_UDP;
-	else if (!strcmp(res->value, "tcp"))
-		rss_conf.rss_hf = RTE_ETH_RSS_TCP;
-	else if (!strcmp(res->value, "sctp"))
-		rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
-	else if (!strcmp(res->value, "l2_payload"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
-	else if (!strcmp(res->value, "port"))
-		rss_conf.rss_hf = RTE_ETH_RSS_PORT;
-	else if (!strcmp(res->value, "vxlan"))
-		rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
-	else if (!strcmp(res->value, "geneve"))
-		rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
-	else if (!strcmp(res->value, "nvgre"))
-		rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
-	else if (!strcmp(res->value, "l3-pre32"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
-	else if (!strcmp(res->value, "l3-pre40"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
-	else if (!strcmp(res->value, "l3-pre48"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
-	else if (!strcmp(res->value, "l3-pre56"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
-	else if (!strcmp(res->value, "l3-pre64"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
-	else if (!strcmp(res->value, "l3-pre96"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
-	else if (!strcmp(res->value, "l3-src-only"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
-	else if (!strcmp(res->value, "l3-dst-only"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
-	else if (!strcmp(res->value, "l4-src-only"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
-	else if (!strcmp(res->value, "l4-dst-only"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
-	else if (!strcmp(res->value, "l2-src-only"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
-	else if (!strcmp(res->value, "l2-dst-only"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
-	else if (!strcmp(res->value, "l2tpv3"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
-	else if (!strcmp(res->value, "esp"))
-		rss_conf.rss_hf = RTE_ETH_RSS_ESP;
-	else if (!strcmp(res->value, "ah"))
-		rss_conf.rss_hf = RTE_ETH_RSS_AH;
-	else if (!strcmp(res->value, "pfcp"))
-		rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
-	else if (!strcmp(res->value, "pppoe"))
-		rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
-	else if (!strcmp(res->value, "gtpu"))
-		rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
-	else if (!strcmp(res->value, "ecpri"))
-		rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
-	else if (!strcmp(res->value, "mpls"))
-		rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
-	else if (!strcmp(res->value, "ipv4-chksum"))
-		rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
-	else if (!strcmp(res->value, "l2tpv2"))
-		rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2;
-	else if (!strcmp(res->value, "none"))
-		rss_conf.rss_hf = 0;
-	else if (!strcmp(res->value, "level-default")) {
+	if (!strcmp(res->value, "level-default")) {
 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
 	} else if (!strcmp(res->value, "level-outer")) {
@@ -2145,14 +2076,29 @@ cmd_config_rss_parsed(void *parsed_result,
 	} else if (!strcmp(res->value, "level-inner")) {
 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
-	} else if (!strcmp(res->value, "default"))
+	} else if (!strcmp(res->value, "default")) {
 		use_default = 1;
-	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
-						atoi(res->value) < 64)
-		rss_conf.rss_hf = 1ULL << atoi(res->value);
-	else {
-		fprintf(stderr, "Unknown parameter\n");
-		return;
+	} else if (isdigit(res->value[0])) {
+		int value = atoi(res->value);
+		if (value > 0 && value < 64)
+			rss_conf.rss_hf = 1ULL << (uint8_t)value;
+		else {
+			fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
+			return;
+		}
+	} else if (!strcmp(res->value, "all") || !strcmp(res->value, "ip") ||
+		   !strcmp(res->value, "udp") || !strcmp(res->value, "tcp") ||
+		   !strcmp(res->value, "sctp") || !strcmp(res->value, "vlan") ||
+		   !strcmp(res->value, "none")) {
+		/* Parse group types or none type */
+		rss_conf.rss_hf = str_to_rsstypes(res->value);
+	} else {
+		/* Get individual type. */
+		rss_conf.rss_hf = str_to_rsstypes(res->value);
+		if (rss_conf.rss_hf == 0) {
+			fprintf(stderr, "Unknown parameter\n");
+			return;
+		}
 	}
 	rss_conf.rss_key = NULL;
 	/* Update global configuration for RSS types. */
@@ -2203,9 +2149,14 @@ static cmdline_parse_inst_t cmd_config_rss = {
 	.f = cmd_config_rss_parsed,
 	.data = NULL,
 	.help_str = "port config all rss "
-		"all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|"
-		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|"
-		"none|level-default|level-outer|level-inner|<flowtype_id>",
+		"all|default|level-default|level-outer|level-inner|"
+		"ip|tcp|udp|sctp|tunnel|vlan|none|"
+		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
+		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
+		"l2_payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
+		"esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
+		"l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
+		"l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
 	.tokens = {
 		(void *)&cmd_config_rss_port,
 		(void *)&cmd_config_rss_keyword,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 36a828307c..3bf03c0969 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -673,6 +673,19 @@ print_dev_capabilities(uint64_t capabilities)
 	}
 }
 
+uint64_t
+str_to_rsstypes(const char *str)
+{
+	uint16_t i;
+
+	for (i = 0; rss_type_table[i].str != NULL; i++) {
+		if (strcmp(rss_type_table[i].str, str) == 0)
+			return rss_type_table[i].rss_type;
+	}
+
+	return 0;
+}
+
 const char *
 rsstypes_to_str(uint64_t rss_type)
 {
@@ -3856,15 +3869,10 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
 {
 	struct rte_eth_rss_conf rss_conf;
 	int diag;
-	unsigned int i;
 
 	rss_conf.rss_key = NULL;
 	rss_conf.rss_key_len = 0;
-	rss_conf.rss_hf = 0;
-	for (i = 0; rss_type_table[i].str; i++) {
-		if (!strcmp(rss_type_table[i].str, rss_type))
-			rss_conf.rss_hf = rss_type_table[i].rss_type;
-	}
+	rss_conf.rss_hf = str_to_rsstypes(rss_type);
 	diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
 	if (diag == 0) {
 		rss_conf.rss_key = hash_key;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 195488b602..2e2987eb66 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1199,6 +1199,7 @@ extern int flow_parse(const char *src, void *result, unsigned int size,
 		      struct rte_flow_item **pattern,
 		      struct rte_flow_action **actions);
 
+uint64_t str_to_rsstypes(const char *str);
 const char *rsstypes_to_str(uint64_t rss_type);
 
 /* For registering driver specific testpmd commands. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index cc299cff6c..63a9e26f33 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2143,8 +2143,15 @@ port config - RSS
 ~~~~~~~~~~~~~~~~~
 
 Set the RSS (Receive Side Scaling) mode on or off::
-
-   testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|l2tpv2|none)
+   testpmd> port config all rss (all|default|level-default|level-outer|level-inner| \
+                                 ip|tcp|udp|sctp|tunnel|vlan|none| \
+                                 ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other| \
+                                 ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp| \
+                                 ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-exl2_payload|port| \
+                                 vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan| \
+                                 esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum| \
+                                 l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32| \
+                                 l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)
 
 RSS is on by default.
 
-- 
2.33.0


  parent reply	other threads:[~2022-06-24  7:26 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29 10:24 [PATCH V2 0/2] fix RSS types display Huisong Li
2022-04-29 10:24 ` [PATCH V2 1/2] app/testpmd: fix supported RSS offload display Huisong Li
2022-04-29 10:24 ` [PATCH V2 2/2] app/testpmd: unify RSS types display Huisong Li
2022-06-07  8:32 ` [PATCH V3 app/testpmd 0/4] fix RSS types and flow type Huisong Li
2022-06-07  8:32   ` [PATCH V3 app/testpmd 1/4] app/testpmd: fix supported RSS offload display Huisong Li
2022-06-07 15:45     ` Ferruh Yigit
2022-06-09  3:25       ` lihuisong (C)
2022-06-17  1:38         ` lihuisong (C)
2022-06-20 12:35         ` Ferruh Yigit
2022-06-21  2:17           ` lihuisong (C)
2022-06-07  8:32   ` [PATCH V3 app/testpmd 2/4] app/testpmd: unify RSS types display and obtaination Huisong Li
2022-06-07 15:46     ` Ferruh Yigit
2022-06-09  3:25       ` lihuisong (C)
2022-06-07  8:32   ` [PATCH V3 app/testpmd 3/4] app/testpmd: compact RSS types output in some commands Huisong Li
2022-06-07 15:46     ` Ferruh Yigit
2022-06-09  3:41       ` lihuisong (C)
2022-06-20 12:37         ` Ferruh Yigit
2022-06-07  8:32   ` [PATCH V3 app/testpmd 4/4] app/testpmd: remove duplicated flow type to string table Huisong Li
2022-06-07 15:47     ` Ferruh Yigit
2022-06-09  3:26       ` lihuisong (C)
2022-06-20 12:38         ` Ferruh Yigit
2022-06-21  2:18           ` lihuisong (C)
2022-06-21  7:51             ` Ferruh Yigit
2022-06-21 12:21               ` lihuisong (C)
2022-06-24  4:12 ` [PATCH V4 0/7] app/testpmd: fix RSS and flow type Huisong Li
2022-06-24  4:12   ` [PATCH V4 1/7] app/testpmd: fix supported RSS offload display Huisong Li
2022-06-24  4:12   ` [PATCH V4 2/7] app/testpmd: unify the name of L2 payload offload Huisong Li
2022-06-24  4:12   ` [PATCH V4 3/7] app/testpmd: refactor config all RSS command Huisong Li
2022-06-24  4:12   ` [PATCH V4 4/7] app/testpmd: unify RSS types display Huisong Li
2022-06-24  4:12   ` [PATCH V4 5/7] app/testpmd: compact RSS types output in some commands Huisong Li
2022-06-24  4:12   ` [PATCH V4 6/7] app/testpmd: reorder elements in RSS type table array Huisong Li
2022-06-24  4:12   ` [PATCH V4 7/7] app/testpmd: remove duplicated flow type to string table Huisong Li
2022-06-24  7:23 ` [PATCH V5 0/7] app/testpmd: fix RSS and flow type Huisong Li
2022-06-24  7:23   ` [PATCH V5 1/7] app/testpmd: fix supported RSS offload display Huisong Li
2022-06-24 13:01     ` Ferruh Yigit
2022-06-25  2:12       ` lihuisong (C)
2022-06-28 13:18         ` Ferruh Yigit
2022-06-24  7:23   ` [PATCH V5 2/7] app/testpmd: unify the name of L2 payload offload Huisong Li
2022-06-24 13:53     ` Ferruh Yigit
2022-06-25  2:12       ` lihuisong (C)
2022-06-28 13:17         ` Ferruh Yigit
2022-06-29  1:47           ` lihuisong (C)
2022-06-24  7:23   ` Huisong Li [this message]
2022-06-24 13:55     ` [PATCH V5 3/7] app/testpmd: refactor config all RSS command Ferruh Yigit
2022-06-25  2:13       ` lihuisong (C)
2022-06-24  7:23   ` [PATCH V5 4/7] app/testpmd: unify RSS types display Huisong Li
2022-06-24  7:23   ` [PATCH V5 5/7] app/testpmd: compact RSS types output in some commands Huisong Li
2022-06-24 14:04     ` Ferruh Yigit
2022-06-25  2:13       ` lihuisong (C)
2022-06-28 13:18         ` Ferruh Yigit
2022-06-24  7:24   ` [PATCH V5 6/7] app/testpmd: reorder elements in RSS type table array Huisong Li
2022-06-24 14:00     ` Ferruh Yigit
2022-06-25  2:14       ` lihuisong (C)
2022-06-24  7:24   ` [PATCH V5 7/7] app/testpmd: remove duplicated flow type to string table Huisong Li
2022-06-24  8:55   ` [PATCH V5 0/7] app/testpmd: fix RSS and flow type lihuisong (C)
2022-06-24  8:59     ` David Marchand
2022-06-24  9:54       ` lihuisong (C)
2022-06-24 10:44         ` Ferruh Yigit
2022-06-25  1:09           ` lihuisong (C)
2022-06-28 13:18             ` Ferruh Yigit
2022-06-29  8:34 ` [PATCH V6 0/8] " Huisong Li
2022-06-29  8:34   ` [PATCH V6 1/8] app/testpmd: fix supported RSS offload display Huisong Li
2022-06-29  8:34   ` [PATCH V6 2/8] app/testpmd: unify the name of L2 payload offload Huisong Li
2022-06-29  8:34   ` [PATCH V6 3/8] doc: testpmd rename RSS type ether to L2 payload Huisong Li
2022-06-29  8:34   ` [PATCH V6 4/8] app/testpmd: refactor config all RSS command Huisong Li
2022-06-29  8:34   ` [PATCH V6 5/8] app/testpmd: unify RSS types display Huisong Li
2022-06-29  8:34   ` [PATCH V6 6/8] app/testpmd: compact RSS types output in some commands Huisong Li
2022-06-29  8:34   ` [PATCH V6 7/8] app/testpmd: reorder elements in RSS type table array Huisong Li
2022-06-29  8:34   ` [PATCH V6 8/8] app/testpmd: remove duplicated flow type to string table Huisong Li
2022-06-29  9:59   ` [PATCH V6 0/8] app/testpmd: fix RSS and flow type lihuisong (C)
2022-06-29 14:13     ` Ferruh Yigit
2022-06-29 20:05   ` Ferruh Yigit

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=20220624072401.21839-4-lihuisong@huawei.com \
    --to=lihuisong@huawei.com \
    --cc=aman.deep.singh@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@xilinx.com \
    --cc=huangdaode@huawei.com \
    --cc=liudongdong3@huawei.com \
    --cc=thomas@monjalon.net \
    --cc=yuying.zhang@intel.com \
    /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).