From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E0A241D52 for ; Thu, 23 Feb 2023 16:08:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 48B8D4328C; Thu, 23 Feb 2023 16:08:18 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id C519E43282 for ; Thu, 23 Feb 2023 16:08:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677164896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SkHOjwYNUU+Q1sZAG64D23KRlH5MSZ16Or9q2KP3HuE=; b=IXmqmVbZnG9EduRSsYmr/H61IGFIjJRFwrHm2/1uA801VGDJ9wOdIVUOiu+RFwYOZF9Klk m4F5RngNeir1rg42fnGx/A+gXZoVdlDjS21OKWSHD/3Oz8RK5+BqT6Czlnzya9N6DVITzR BYKUXAVrxJZ3zCb6laYIjAA5ENAXoAg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-232-ar1YWxOgNiqUQeRXkx05pQ-1; Thu, 23 Feb 2023 10:08:13 -0500 X-MC-Unique: ar1YWxOgNiqUQeRXkx05pQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7879857A93; Thu, 23 Feb 2023 15:08:07 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id E715F2166B29; Thu, 23 Feb 2023 15:08:06 +0000 (UTC) From: Kevin Traynor To: Ferruh Yigit Cc: Aman Singh , dpdk stable Subject: patch 'app/testpmd: fix link check condition on port start' has been queued to stable release 21.11.4 Date: Thu, 23 Feb 2023 15:05:57 +0000 Message-Id: <20230223150631.723699-66-ktraynor@redhat.com> In-Reply-To: <20230223150631.723699-1-ktraynor@redhat.com> References: <20230223150631.723699-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/28/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://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/e0f5e9d162f3d01837a1db231ee852e7e3fb16f8 Thanks. Kevin --- >From e0f5e9d162f3d01837a1db231ee852e7e3fb16f8 Mon Sep 17 00:00:00 2001 From: Ferruh Yigit Date: Fri, 27 Jan 2023 22:45:13 +0000 Subject: [PATCH] app/testpmd: fix link check condition on port start [ 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 Acked-by: Aman Singh --- 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 4e15c982c8..ea5cada21e 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2805,5 +2805,5 @@ 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; @@ -2816,4 +2816,7 @@ start_port(portid_t pid) 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)) @@ -2831,9 +2834,11 @@ start_port(portid_t pid) } - 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; @@ -3050,13 +3055,12 @@ start_port(portid_t pid) 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"); -- 2.39.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-02-23 14:46:25.400266408 +0000 +++ 0066-app-testpmd-fix-link-check-condition-on-port-start.patch 2023-02-23 14:46:23.818236133 +0000 @@ -1 +1 @@ -From cdede073a515432fc168d252d93f9a2d333ce8a0 Mon Sep 17 00:00:00 2001 +From e0f5e9d162f3d01837a1db231ee852e7e3fb16f8 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit cdede073a515432fc168d252d93f9a2d333ce8a0 ] + @@ -77 +78,0 @@ -Cc: stable@dpdk.org @@ -86 +87 @@ -index f3e29a5b4b..d93d07ae09 100644 +index 4e15c982c8..ea5cada21e 100644 @@ -89 +90 @@ -@@ -2921,5 +2921,5 @@ int +@@ -2805,5 +2805,5 @@ int @@ -96 +97 @@ -@@ -2932,4 +2932,7 @@ start_port(portid_t pid) +@@ -2816,4 +2816,7 @@ start_port(portid_t pid) @@ -104 +105 @@ -@@ -2947,9 +2950,11 @@ start_port(portid_t pid) +@@ -2831,9 +2834,11 @@ start_port(portid_t pid) @@ -119 +120 @@ -@@ -3171,13 +3176,12 @@ start_port(portid_t pid) +@@ -3050,13 +3055,12 @@ start_port(portid_t pid)