Skip to contentSkip to conversation

examples/multi_process: add options to control port configuration

PATCH In review Wenwu Ma 4 participants 12 messages Feb 17, 2022 – Mar 8, 2022

lore
Share & tools
lore

Wenwu Ma

author
#0 lore raw

PATCH 1/1 examples/multi_process: add options to control port configuration

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. Therefore, we added two new options --rx-mq-mode and --rx-offloads, through which the user can set the values appropriately according to the situation to make app startup normally.

---
 examples/multi_process/symmetric_mp/main.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
examples/multi_process/symmetric_mp/main.c +16 -2
index 050337765f..df41abe682 100644
@@ -52,6 +52,8 @@
 
 #define PARAM_PROC_ID "proc-id"
 #define PARAM_NUM_PROCS "num-procs"
+#define PARAM_RX_OFFLOADS "rx-offloads"
+#define PARAM_RX_MQ_MODE "rx-mq-mode"
 
 /* for each lcore, record the elements of the ports array to use */
 struct lcore_ports{
@@ -69,6 +71,8 @@ struct port_stats{
 
 static int proc_id = -1;
 static unsigned num_procs = 0;
+static uint64_t rx_offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM;
+static enum rte_eth_rx_mq_mode rx_mq_mode = RTE_ETH_MQ_RX_RSS;
 
 static uint16_t ports[RTE_MAX_ETHPORTS];
 static unsigned num_ports = 0;
@@ -84,9 +88,13 @@ smp_usage(const char *prgname, const char *errmsg)
 	printf("\n%s [EAL options] -- -p <port mask> "
 			"--"PARAM_NUM_PROCS" <n>"
 			" --"PARAM_PROC_ID" <id>\n"
+			" --"PARAM_RX_OFFLOADS" <offload>\n"
+			" --"PARAM_RX_MQ_MODE" <mode>\n"
 			"-p         : a hex bitmask indicating what ports are to be used\n"
 			"--num-procs: the number of processes which will be used\n"
 			"--proc-id  : the id of the current process (id < num-procs)\n"
+			"--rx-offloads : rx offload capabilities of ports\n"
+			"--rx-mq-mode : the multi-queue packet distribution mode, e.g. RSS.\n"
 			"\n",
 			prgname);
 	exit(1);
@@ -119,6 +127,8 @@ smp_parse_args(int argc, char **argv)
 	static struct option lgopts[] = {
 			{PARAM_NUM_PROCS, 1, 0, 0},
 			{PARAM_PROC_ID, 1, 0, 0},
+			{PARAM_RX_OFFLOADS, 1, 0, 0},
+			{PARAM_RX_MQ_MODE, 1, 0, 0},
 			{NULL, 0, 0, 0}
 	};
 
@@ -137,6 +147,10 @@ smp_parse_args(int argc, char **argv)
 				num_procs = atoi(optarg);
 			else if (strncmp(lgopts[option_index].name, PARAM_PROC_ID, 7) == 0)
 				proc_id = atoi(optarg);
+			else if (strncmp(lgopts[option_index].name, PARAM_RX_OFFLOADS, 11) == 0)
+				rx_offloads = atoi(optarg);
+			else if (strncmp(lgopts[option_index].name, PARAM_RX_MQ_MODE, 10) == 0)
+				rx_mq_mode = atoi(optarg);
 			break;
 
 		default:
@@ -175,9 +189,9 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 {
 	struct rte_eth_conf port_conf = {
 			.rxmode = {
-				.mq_mode	= RTE_ETH_MQ_RX_RSS,
+				.mq_mode	= rx_mq_mode,
 				.split_hdr_size = 0,
-				.offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM,
+				.offloads = rx_offloads,
 			},
 			.rx_adv_conf = {
 				.rss_conf = {
Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · Wenwu Ma

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. Therefore, we added two new options --rx-mq-mode and --rx-offloads, through which the user can set the values appropriately according to the situation to make app startup normally.

The idea seems reasonable enough, but I think the implementation requiring the user to pass in special "magic numbers" for the offload values is not a good idea. Perhaps add in a separate flag for "no-csum" to disable that.

For the no-rss case, can you explain how you would see this app being used in the absense of RSS support to distribute traffic among the separate processes?

author
#2 lore raw
Quoted 21 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: 2022年2月17日 17:06
To: Ma, WenwuX <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>
Subject: Re: [PATCH] examples/multi_process: add options to control port configuration

Quoted 7 lines · Wenwu Ma

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. Therefore, we added two new options --rx-mq-mode and --rx-offloads, through which the user can set the values appropriately according to the situation to make app startup normally.

Quoted 7 lines

The idea seems reasonable enough, but I think the implementation requiring the user to pass in special "magic numbers" for the offload values is not a good idea. Perhaps add in a separate flag for "no-csum" to disable that.

For the no-rss case, can you explain how you would see this app being used in the absense of RSS support to distribute traffic among the separate processes?

When app run in qemu vm and the backend is dpdk vhost, it will report error below:
"virtio_dev_configure(): RSS support requested but not supported by the device"

#3 lore raw
Quoted 25 lines · WenwuX
Quoted 25 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: 2022年2月17日 17:06
To: Ma, WenwuX <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>
Subject: Re: [PATCH] examples/multi_process: add options to control port configuration

Quoted 7 lines · Wenwu Ma

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. Therefore, we added two new options --rx-mq-mode and --rx-offloads, through which the user can set the values appropriately according to the situation to make app startup normally.

The idea seems reasonable enough, but I think the implementation requiring the user to pass in special "magic numbers" for the offload values is not a good idea. Perhaps add in a separate flag for "no-csum" to disable that.

Quoted 6 lines
Quoted 3 lines

For the no-rss case, can you explain how you would see this app being used in the absense of RSS support to distribute traffic among the separate processes?

When app run in qemu vm and the backend is dpdk vhost, it will report error below:
"virtio_dev_configure(): RSS support requested but not supported by the device"

Sure, I understand that. But how does it make sense to run multiple copies of the app if RSS cannot be used to spread the traffic between the instances?

author
#4 lore raw
Quoted 44 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: 2022年2月18日 17:42
To: Ma, WenwuX <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>
Subject: Re: [PATCH] examples/multi_process: add options to control port configuration

Quoted 12 lines · WenwuX
Quoted 12 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: 2022年2月17日 17:06
To: Ma, WenwuX <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>
Subject: Re: [PATCH] examples/multi_process: add options to control port configuration

Quoted 3 lines
Quoted 3 lines · Wenwu Ma
Quoted 2 lines

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or

csum.

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Therefore, we added two new options --rx-mq-mode and --rx-offloads, through which the user can set the values appropriately according to the situation to make app startup normally.

The idea seems reasonable enough, but I think the implementation requiring the user to pass in special "magic numbers" for the offload values is not a good idea. Perhaps add in a separate flag for "no-

csum" to disable that.

Quoted 5 lines
Quoted 4 lines

For the no-rss case, can you explain how you would see this app being used in the absense of RSS support to distribute traffic among the separate processes?

Quoted 7 lines
Quoted 1 line

When app run in qemu vm and the backend is dpdk vhost, it will report

error below:

Quoted 1 line

"virtio_dev_configure(): RSS support requested but not supported by the

device"

Sure, I understand that. But how does it make sense to run multiple copies of the app if RSS cannot be used to spread the traffic between the instances?

in test case, vhost backend has 2 queues, and we set fwd as txonly, and in vm, we run app as follows

./examples/multi_process/symmetric_mp/build/symmetric_mp -l 1 -n 4 --proc-type=auto -- -p 3 --num-procs=2 --proc-id=0 ./examples/multi_process/symmetric_mp/build/symmetric_mp -l 2 -n 4 --proc-type=secondary -- -p 3 --num-procs=2 --proc-id=1

So, instance 0 receive pkts in queue 0, and instance 1 receive pkts in queue 1.

#5 lore raw
Quoted 52 lines · WenwuX
Quoted 44 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: 2022年2月18日 17:42
To: Ma, WenwuX <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>
Subject: Re: [PATCH] examples/multi_process: add options to control port configuration

Quoted 12 lines · WenwuX
Quoted 12 lines

-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: 2022年2月17日 17:06
To: Ma, WenwuX <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>
Subject: Re: [PATCH] examples/multi_process: add options to control port configuration

Quoted 3 lines
Quoted 3 lines · Wenwu Ma
Quoted 2 lines

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or

csum.

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Therefore, we added two new options --rx-mq-mode and --rx-offloads, through which the user can set the values appropriately according to the situation to make app startup normally.

The idea seems reasonable enough, but I think the implementation requiring the user to pass in special "magic numbers" for the offload values is not a good idea. Perhaps add in a separate flag for "no-

csum" to disable that.

Quoted 5 lines
Quoted 4 lines

For the no-rss case, can you explain how you would see this app being used in the absense of RSS support to distribute traffic among the separate processes?

Quoted 7 lines
Quoted 1 line

When app run in qemu vm and the backend is dpdk vhost, it will report

error below:

Quoted 1 line

"virtio_dev_configure(): RSS support requested but not supported by the

device"

Sure, I understand that. But how does it make sense to run multiple copies of the app if RSS cannot be used to spread the traffic between the instances?

Quoted 7 lines

in test case, vhost backend has 2 queues, and we set fwd as txonly, and in vm, we run app as follows

./examples/multi_process/symmetric_mp/build/symmetric_mp -l 1 -n 4 --proc-type=auto -- -p 3 --num-procs=2 --proc-id=0 ./examples/multi_process/symmetric_mp/build/symmetric_mp -l 2 -n 4 --proc-type=secondary -- -p 3 --num-procs=2 --proc-id=1

So, instance 0 receive pkts in queue 0, and instance 1 receive pkts in queue 1.

Interesting. So with vhost/virtio, the distribution of the traffic to queues in entirely controls by the backend without the virtio PMD being able to control it?

Anyway, if we want to allow running the app without rss, I would echo the comment I made about "csum", in that we probably just want a suitably named flag for it, rather than just requiring magic numbers from the user.

Two options therefore I'd suggest:
1. just make the app ignore errors with csum and RSS - if they are not supported by a NIC, just log a warning and run the app anyway, reconfiguring the NIC without them. Only quit the app if the second reconfiguration fails.
2. Add explicit --no-csum and --no-rss flags.

I would actually tend towards the first option as more usable, but the second could work too.

/Bruce

author
#6 lore raw

PATCH v2 1/1 examples/multi_process: reconfigure port when rss or csum isn't supported

In reply to Wenwu Ma

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. This Patch make the app to reconfigure the NIC without them. Only quit the app if the second reconfiguration fails.

---
 examples/multi_process/symmetric_mp/main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
examples/multi_process/symmetric_mp/main.c +14 -0
index 050337765f..c0e7ed70e0 100644
@@ -232,6 +232,20 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	}
 
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	if (retval == -EINVAL) {
+		printf("Maybe port %u don't have csum offloads capabilities, "
+			"so clear csum config and try again.\n", port);
+		port_conf.rxmode.offloads &= ~(RTE_ETH_RX_OFFLOAD_CHECKSUM);
+		retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	}
+
+	if (retval == -ENOTSUP) {
+		printf("Maybe port %u don't support rss, "
+			"so clear rss config and try again.\n", port);
+		port_conf.rxmode.mq_mode &= ~(RTE_ETH_MQ_RX_RSS);
+		retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	}
+
 	if (retval < 0)
 		return retval;
 
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH v2] examples/multi_process: reconfigure port when rss or csum isn't supported

Quoted 16 lines · Wenwu Ma

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. This Patch make the app to reconfigure the NIC without them. Only quit the app if the second reconfiguration fails.

---
 examples/multi_process/symmetric_mp/main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
examples/multi_process/symmetric_mp/main.c +0 -0
index 050337765f..c0e7ed70e0 100644

examples/multi_process/symmetric_mp/main.c smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool, · line 237

Quoted 6 lines
examples/multi_process/symmetric_mp/main.c +3 -0
@@ -232,6 +232,20 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	}
 
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	if (retval == -EINVAL) {
+		printf("Maybe port %u don't have csum offloads capabilities, "
+			"so clear csum config and try again.\n", port);

Two comments for here and below:
1. Don't split error messages across multiple lines, as it means the user/developer cannot find them using "grep" on the code.
2. Text should try and be shorter and clearer. I'd suggest:
"Port configuration failed. Re-attempting with HW checksum disabled"

examples/multi_process/symmetric_mp/main.c smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool, · line 244

Quoted 7 lines
examples/multi_process/symmetric_mp/main.c +7 -0
+		port_conf.rxmode.offloads &= ~(RTE_ETH_RX_OFFLOAD_CHECKSUM);
+		retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	}
+
+	if (retval == -ENOTSUP) {
+		printf("Maybe port %u don't support rss, "
+			"so clear rss config and try again.\n", port);

Same two comments from above apply here.

Quoted 10 lines
examples/multi_process/symmetric_mp/main.c +4 -0
+		port_conf.rxmode.mq_mode &= ~(RTE_ETH_MQ_RX_RSS);
+		retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	}
+
 	if (retval < 0)
 		return retval;
 
Signature · 1 line
2.25.1
author
#8 lore raw

PATCH v3 1/1 examples/multi_process: reconfigure port when rss or csum isn't supported

In reply to Wenwu Ma

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. This Patch make the app to reconfigure the NIC without them. Only quit the app if the second reconfiguration fails.

---
 examples/multi_process/symmetric_mp/main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
examples/multi_process/symmetric_mp/main.c +14 -0
index 050337765f..0e991acdf2 100644
@@ -232,6 +232,20 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	}
 
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	if (retval == -EINVAL) {
+		printf("Port %u configuration failed. Re-attempting with HW checksum disabled.\n",
+			port);
+		port_conf.rxmode.offloads &= ~(RTE_ETH_RX_OFFLOAD_CHECKSUM);
+		retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	}
+
+	if (retval == -ENOTSUP) {
+		printf("Port %u configuration failed. Re-attempting with HW rss disabled.\n",
+			port);
+		port_conf.rxmode.mq_mode &= ~(RTE_ETH_MQ_RX_RSS);
+		retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	}
+
 	if (retval < 0)
 		return retval;
 
Signature · 1 line
2.25.1
Acked-by on v3 1/1
#9 lore raw

Re: [PATCH v3] examples/multi_process: reconfigure port when rss or csum isn't supported

Quoted 8 lines · Wenwu Ma

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. This Patch make the app to reconfigure the NIC without them. Only quit the app if the second reconfiguration fails.

---

While I am surprised to see different error codes for different essentially the same issue - lack of HW support, that is a separate problem to the one this is addressing. Given this is just a sample app, I think this approach is fine for configuring things - keeping things simple for the user.

Quoted 31 lines
 examples/multi_process/symmetric_mp/main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
examples/multi_process/symmetric_mp/main.c +14 -0
index 050337765f..0e991acdf2 100644
@@ -232,6 +232,20 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
 	}
 
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	if (retval == -EINVAL) {
+		printf("Port %u configuration failed. Re-attempting with HW checksum disabled.\n",
+			port);
+		port_conf.rxmode.offloads &= ~(RTE_ETH_RX_OFFLOAD_CHECKSUM);
+		retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	}
+
+	if (retval == -ENOTSUP) {
+		printf("Port %u configuration failed. Re-attempting with HW rss disabled.\n",
+			port);
+		port_conf.rxmode.mq_mode &= ~(RTE_ETH_MQ_RX_RSS);
+		retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
+	}
+
 	if (retval < 0)
 		return retval;
 
Signature · 1 line
2.25.1
Tested-by
#10 lore raw

RE: [PATCH v3] examples/multi_process: reconfigure port when rss or csum isn't supported

Quoted 19 lines

-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Tuesday, February 22, 2022 5:41 PM
To: Ma, WenwuX <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He, Xingguang <[email protected]>
Subject: Re: [PATCH v3] examples/multi_process: reconfigure port when rss or csum isn't supported

Quoted 7 lines · Wenwu Ma

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. This Patch make the app to reconfigure the NIC without them. Only quit the app if the second reconfiguration fails.

---

Quoted 7 lines

While I am surprised to see different error codes for different essentially the same issue - lack of HW support, that is a separate problem to the one this is addressing. Given this is just a sample app, I think this approach is fine for configuring things - keeping things simple for the user.

#11 lore raw

Re: [PATCH v3] examples/multi_process: reconfigure port when rss or csum isn't supported

28/02/2022 08:55, Ling, WeiX:

Quoted 10 lines

From: Bruce Richardson <[email protected]>

Quoted 9 lines · Wenwu Ma
Quoted 7 lines

The default values of rx mq_mode and rx offloads for port will cause symmetric_mp startup failure if the port do not support rss or csum. This Patch make the app to reconfigure the NIC without them. Only quit the app if the second reconfiguration fails.

---

Quoted 8 lines
Quoted 7 lines

While I am surprised to see different error codes for different essentially the same issue - lack of HW support, that is a separate problem to the one this is addressing. Given this is just a sample app, I think this approach is fine for configuring things - keeping things simple for the user.

Applied with title "examples/multi_process: make RSS and checksum optional"