patch 'app/testpmd: fix link check condition on port start' has been queued to stable release 22.11.2

Xueming Li xuemingl at nvidia.com
Mon Feb 27 08:00:15 CET 2023


Hi,

FYI, your patch has been queued to stable release 22.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/01/23. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=f418af17fc9927e2f9b854f6c5ab21105c1af94a

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From f418af17fc9927e2f9b854f6c5ab21105c1af94a Mon Sep 17 00:00:00 2001
From: Ferruh Yigit <ferruh.yigit at amd.com>
Date: Fri, 27 Jan 2023 22:45:13 +0000
Subject: [PATCH] app/testpmd: fix link check condition on port start
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit cdede073a515432fc168d252d93f9a2d333ce8a0 ]

In testpmd port start function, 'need_check_link_status' variable is
used to detect if a link check is required after port is started.

Intention is if at least one port is started, link check should be
called, and initially 'need_check_link_status' used as following:
```
start_port
	need_check_link_status <- 0
	for each p in port
		ret <- config & start p
		if ret is failure
			break
		need_check_link_status <- 1
	if need_check_link_status
		check link
	else
		log failure message
```

Later above logic is modified [1] because when there is no port at all,
'need_check_link_status' remains zero and it causes and error message
although this is a valid use case.

For this code updated as following:

```
start_port
	need_check_link_status <- -1
	for each p in port
		need_check_link_status <- 0
		ret <- config & start p
		if ret is failure
			break
		need_check_link_status <- 1
	if need_check_link_status == 1
		check link
	else if need_check_link_status == 0
		log failure message
```

This modification works fine if 'start_port()' called for a single port,
but function support both single port and all ports with 'RTE_PORT_ALL'
parameter to the function.

When it is called for all ports, above logic is wrong because
'need_check_link_status' value reset on each iteration of the loop.

For multi port case, if last port fails to start,
'need_check_link_status' will be zero and no link check will be done and
it will log a wrong error message.

Overall there are three cases to cover:
* No port exist at all
* All ports are already started
* At least one port started successfully

To cover all three cases, one option is to use 'need_check_link_status'
have multiple values to reflect above cases.
But meaning of values are not obvious which can lead more issues in the
future.

Instead converting 'need_check_link_status' to multiple boolean
variables whose names are self explanatory.

This fixes issue and link check called if at least one port started
successfully as intended.
Also log message only printed when at least one port exists and all
ports are already in started state.

[1]
Fixes: 92d2703e2c43 ("app/testpmd: fix log with no bound device")

Signed-off-by: Ferruh Yigit <ferruh.yigit at amd.com>
Acked-by: Aman Singh <aman.deep.singh at intel.com>
---
 app/test-pmd/testpmd.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 3c404c8a6e..538609d890 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2883,7 +2883,7 @@ update_bonding_port_dev_conf(portid_t bond_pid)
 int
 start_port(portid_t pid)
 {
-	int diag, need_check_link_status = -1;
+	int diag;
 	portid_t pi;
 	portid_t p_pi = RTE_MAX_ETHPORTS;
 	portid_t pl[RTE_MAX_ETHPORTS];
@@ -2894,6 +2894,9 @@ start_port(portid_t pid)
 	queueid_t qi;
 	struct rte_port *port;
 	struct rte_eth_hairpin_cap cap;
+	bool at_least_one_port_exist = false;
+	bool all_ports_already_started = true;
+	bool at_least_one_port_successfully_started = false;

 	if (port_id_is_invalid(pid, ENABLED_WARN))
 		return 0;
@@ -2909,11 +2912,13 @@ start_port(portid_t pid)
 			continue;
 		}

-		need_check_link_status = 0;
+		at_least_one_port_exist = true;
+
 		port = &ports[pi];
-		if (port->port_status == RTE_PORT_STOPPED)
+		if (port->port_status == RTE_PORT_STOPPED) {
 			port->port_status = RTE_PORT_HANDLING;
-		else {
+			all_ports_already_started = false;
+		} else {
 			fprintf(stderr, "Port %d is now not stopped\n", pi);
 			continue;
 		}
@@ -3133,15 +3138,14 @@ start_port(portid_t pid)
 			printf("Port %d: " RTE_ETHER_ADDR_PRT_FMT "\n", pi,
 					RTE_ETHER_ADDR_BYTES(&port->eth_addr));

-		/* at least one port started, need checking link status */
-		need_check_link_status = 1;
+		at_least_one_port_successfully_started = true;

 		pl[cfg_pi++] = pi;
 	}

-	if (need_check_link_status == 1 && !no_link_check)
+	if (at_least_one_port_successfully_started && !no_link_check)
 		check_all_ports_link_status(RTE_PORT_ALL);
-	else if (need_check_link_status == 0)
+	else if (at_least_one_port_exist & all_ports_already_started)
 		fprintf(stderr, "Please stop the ports first\n");

 	if (hairpin_mode & 0xf) {
--
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-02-27 14:08:44.335173400 +0800
+++ 0108-app-testpmd-fix-link-check-condition-on-port-start.patch	2023-02-27 14:08:40.849237000 +0800
@@ -1 +1 @@
-From cdede073a515432fc168d252d93f9a2d333ce8a0 Mon Sep 17 00:00:00 2001
+From f418af17fc9927e2f9b854f6c5ab21105c1af94a Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit cdede073a515432fc168d252d93f9a2d333ce8a0 ]
@@ -77 +79,0 @@
-Cc: stable at dpdk.org
@@ -86 +88 @@
-index f3e29a5b4b..d93d07ae09 100644
+index 3c404c8a6e..538609d890 100644
@@ -89 +91 @@
-@@ -2920,7 +2920,7 @@ update_bonding_port_dev_conf(portid_t bond_pid)
+@@ -2883,7 +2883,7 @@ update_bonding_port_dev_conf(portid_t bond_pid)
@@ -98 +100 @@
-@@ -2931,6 +2931,9 @@ start_port(portid_t pid)
+@@ -2894,6 +2894,9 @@ start_port(portid_t pid)
@@ -108 +110 @@
-@@ -2946,11 +2949,13 @@ start_port(portid_t pid)
+@@ -2909,11 +2912,13 @@ start_port(portid_t pid)
@@ -125 +127 @@
-@@ -3170,15 +3175,14 @@ start_port(portid_t pid)
+@@ -3133,15 +3138,14 @@ start_port(portid_t pid)


More information about the stable mailing list