DPDK patches and discussions
 help / color / mirror / Atom feed
From: Qi Zhang <qi.z.zhang@intel.com>
To: ferruh.yigit@intel.com, adrien.mazarguil@6wind.com
Cc: thomas@monjalon.net, dev@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>
Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix testpmd failure due to RSS offload check
Date: Wed, 25 Apr 2018 15:43:13 +0800	[thread overview]
Message-ID: <20180425074313.242146-1-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20180425014929.72014-1-qi.z.zhang@intel.com>

After add RSS hash offload check, default rss_hf will fail on
devices that not support all bits, the patch introduce RSS
negotiate flag, when it is set, RSS configuration will negotiate
with device capability. By default negotiate is turn on, so it
will not break exist PMD. It can be disabled by "--disable-rss-neg"
in start parameters or be enable/disable by testpmd command
"port config all rss neg|noneg".

Fixes: 527624c663f8 ("ethdev: add supported hash function check")
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---

v2:
- fix command help string.

 app/test-pmd/cmdline.c                      | 22 ++++++++++++++++------
 app/test-pmd/parameters.c                   |  5 +++++
 app/test-pmd/testpmd.c                      | 12 +++++++++++-
 app/test-pmd/testpmd.h                      |  1 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 +++-
 5 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 333852194..9390be741 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -822,7 +822,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			" for ports.\n\n"
 
 			"port config all rss (all|default|ip|tcp|udp|sctp|"
-			"ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
+			"ether|port|vxlan|geneve|nvgre|none|neg|noneg|<flowtype_id>)\n"
 			"    Set the RSS mode.\n\n"
 
 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
@@ -2029,7 +2029,13 @@ cmd_config_rss_parsed(void *parsed_result,
 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
 						atoi(res->value) < 64)
 		rss_conf.rss_hf = 1ULL << atoi(res->value);
-	else {
+	else if (!strcmp(res->value, "neg")) {
+		rss_hf_noneg = 0;
+		return;
+	} else if (!strcmp(res->value, "noneg")) {
+		rss_hf_noneg = 1;
+		return;
+	} else {
 		printf("Unknown parameter\n");
 		return;
 	}
@@ -2037,10 +2043,14 @@ cmd_config_rss_parsed(void *parsed_result,
 	/* Update global configuration for RSS types. */
 	rss_hf = rss_conf.rss_hf;
 	RTE_ETH_FOREACH_DEV(i) {
-		if (!strcmp(res->value, "default")) {
-			rte_eth_dev_info_get(i, &dev_info);
+		rte_eth_dev_info_get(i, &dev_info);
+		if (!strcmp(res->value, "default"))
 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
-		}
+		else
+			rss_conf.rss_hf &= (rss_hf_noneg ?
+				rss_conf.rss_hf :
+				dev_info.flow_type_rss_offloads);
+
 		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
 		if (diag < 0)
 			printf("Configuration of RSS hash at ethernet port %d "
@@ -2064,7 +2074,7 @@ cmdline_parse_inst_t cmd_config_rss = {
 	.f = cmd_config_rss_parsed,
 	.data = NULL,
 	.help_str = "port config all rss "
-		"all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
+		"all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|neg|noneg|<flowtype_id>",
 	.tokens = {
 		(void *)&cmd_config_rss_port,
 		(void *)&cmd_config_rss_keyword,
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 394fa6d92..4758ec1d9 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -139,6 +139,7 @@ usage(char* progname)
 	printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
 	printf("  --enable-drop-en: enable per queue packet drop.\n");
 	printf("  --disable-rss: disable rss.\n");
+	printf("  --disable-rss-neg: disable rss negotiate with device capa.\n");
 	printf("  --port-topology=N: set port topology (N: paired (default) or "
 	       "chained).\n");
 	printf("  --forward-mode=N: set forwarding mode (N: %s).\n",
@@ -594,6 +595,7 @@ launch_args_parse(int argc, char** argv)
 		{ "enable-hw-vlan-extend",      0, 0, 0 },
 		{ "enable-drop-en",            0, 0, 0 },
 		{ "disable-rss",                0, 0, 0 },
+		{ "disable-rss-neg",            0, 0, 0 },
 		{ "port-topology",              1, 0, 0 },
 		{ "forward-mode",               1, 0, 0 },
 		{ "rss-ip",			0, 0, 0 },
@@ -909,6 +911,9 @@ launch_args_parse(int argc, char** argv)
 
 			if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
 				rss_hf = 0;
+			if (!strcmp(lgopts[opt_idx].name, "disable-rss-neg")) {
+				rss_hf_noneg = 1;
+			}
 			if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
 				if (!strcmp(optarg, "paired"))
 					port_topology = PORT_TOPOLOGY_PAIRED;
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index d6da41927..68214677c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -257,6 +257,12 @@ int16_t tx_rs_thresh = RTE_PMD_PARAM_UNSET;
 uint64_t rss_hf = ETH_RSS_IP; /* RSS IP by default. */
 
 /*
+ * Negotiate with device capability when config
+ * Receive Side Scaling (RSS).
+ */
+uint8_t rss_hf_noneg = 0; /* Negotiate by default */
+
+/*
  * Port topology configuration
  */
 uint16_t port_topology = PORT_TOPOLOGY_PAIRED; /* Ports are paired by default */
@@ -2265,13 +2271,17 @@ init_port_config(void)
 {
 	portid_t pid;
 	struct rte_port *port;
+	struct rte_eth_dev_info dev_info;
 
 	RTE_ETH_FOREACH_DEV(pid) {
 		port = &ports[pid];
 		port->dev_conf.fdir_conf = fdir_conf;
 		if (nb_rxq > 1) {
+			rte_eth_dev_info_get(pid, &dev_info);
 			port->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL;
-			port->dev_conf.rx_adv_conf.rss_conf.rss_hf = rss_hf;
+			port->dev_conf.rx_adv_conf.rss_conf.rss_hf =
+				rss_hf_noneg ? rss_hf :
+				(rss_hf & dev_info.flow_type_rss_offloads);
 		} else {
 			port->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL;
 			port->dev_conf.rx_adv_conf.rss_conf.rss_hf = 0;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 070919822..c37c4ee70 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -385,6 +385,7 @@ extern struct rte_eth_rxmode rx_mode;
 extern struct rte_eth_txmode tx_mode;
 
 extern uint64_t rss_hf;
+extern uint8_t rss_hf_noneg;
 
 extern queueid_t nb_rxq;
 extern queueid_t nb_txq;
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 593b13a3d..8db9cf5c1 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1751,13 +1751,15 @@ port config - RSS
 
 Set the RSS (Receive Side Scaling) mode on or off::
 
-   testpmd> port config all rss (all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)
+   testpmd> port config all rss (all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|neg|noneg)
 
 RSS is on by default.
 
 The ``all`` option is equivalent to ip|tcp|udp|sctp|ether.
 The ``default`` option enables all supported RSS types reported by device info.
 The ``none`` option is equivalent to the ``--disable-rss`` command-line option.
+The ``neg`` option enable the negotiation with device capability when configure RSS.
+The ``noneg`` option disable the negotiation and is equivalent to ``--disable-rss-neg`` command-line option.
 
 port config - RSS Reta
 ~~~~~~~~~~~~~~~~~~~~~~
-- 
2.13.6

  reply	other threads:[~2018-04-25  7:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25  1:49 [dpdk-dev] [PATCH] " Qi Zhang
2018-04-25  7:43 ` Qi Zhang [this message]
2018-04-25 12:03   ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2018-04-25 13:34     ` Zhang, Qi Z
2018-04-25 13:38 ` [dpdk-dev] [PATCH v3] " Qi Zhang
2018-04-25 14:02   ` Ferruh Yigit
2018-04-25 16:27   ` Adrien Mazarguil
2018-04-25 16:34     ` Ferruh Yigit
2018-04-25 23:46     ` 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=20180425074313.242146-1-qi.z.zhang@intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --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).