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 31A4641BBC for ; Fri, 3 Feb 2023 10:57:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 275FA42B8C; Fri, 3 Feb 2023 10:57:00 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id CE6664021E; Fri, 3 Feb 2023 10:56:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675418217; x=1706954217; h=message-id:date:subject:to:cc:references:from: in-reply-to:mime-version; bh=iympOsBjRzqyyDCg7EqF+UhIe3Hh8eKMPBDSKdNiEy0=; b=KfSy2UTVhngCYEQTUuuhDnfgihnnRvaXbt9UKx8UymtdCvi4wBquqPd8 GmkHkGNHgg+8rlNzt41x4yY3ernNMi/046/PNu/FF6CUg/PlJyoQa1612 tefdfr/BpLgazYon2ICm8tjdav+tSNgqxl2OdQ5rVARBN+mSbTBkvDAvD ziucwrW1ZZOZOQ+mnKUSdjXGZtW2ESFuk7qNSwffqn9HZt8OOkScQbrnf fPgQhP5KR0VKYexvYGbtWzQJLJWlGJq4x1oFThiK08D2G3ttvkvFhet7Y QDUoMYbmiOdg8rW1IQUnHmiiqYBFawd7XNjSxc4MtHI4qVFSeflLsZvJD Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10609"; a="309043410" X-IronPort-AV: E=Sophos;i="5.97,270,1669104000"; d="scan'208,217";a="309043410" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2023 01:56:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10609"; a="774268178" X-IronPort-AV: E=Sophos;i="5.97,270,1669104000"; d="scan'208,217";a="774268178" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga002.fm.intel.com with ESMTP; 03 Feb 2023 01:56:27 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 3 Feb 2023 01:56:26 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Fri, 3 Feb 2023 01:56:26 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Fri, 3 Feb 2023 01:56:26 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LGpSSesfKWaCZIE0CS7ru6NseogCn8n3uI3dREYtt0XJP9jDsZT963XGQTpCViH5kWJAtKkjzmz7ARUAcd66wSvT/+9j6x7hC6j6gXDO60dywzc2B6m5X+Q3REMPA/de2hwMet75o0OnaV3XnE+HcJ3RxXMoLbj0pllACzwF+VOtv7GkOkVUBoWds/yWNsMDbrIwdvzTyyxzAoobdPVeoVaNq62W5FfcxsgFT4i9FWORFJBiyJAjaM0++II0IBbMjdPsjQQ6fr2RHgtH1nI/hqPj2JvCcHnCyMS+KAo8vUzL7bbaDh8omySFbzTSBsJzSZc+uRSQBoFc3cDCPHvBQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ye26N7i4znlVG0FoDZGOeuqgb0DKS9kfnbkxshZ6dw8=; b=nhwLMRxlh7QmER7oYHSiJYLbwm/XGov26nAUMe833oJ/pElVDuoWrHwLTrK/O1TGh19oplXXzbAZQ/C1D8/DFIg8XImgVUBYVWYXS25mKIO2ZgYQJL7FDVC2yAZa68kHLqgUHIzzKixNI/bPWWNMzN5bW3+P9KJfX9vO32jtA9eDx8YBavZpEV6pmRAVtzvBmIp++p/BsqLv/eC/ws2f/RUbKdTh+eUDl9Pj8PLY64GiJeasJcvgS8PYR7HxRXekWm1bOfY7QLBAE0h6q2oHNg23ImzWkIokgH9XnJsi3oHalk6R3oNhgjl0QjUOYnaJvRaBhq6U+6Y1Zbky/m6T5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MWHPR11MB0062.namprd11.prod.outlook.com (2603:10b6:301:67::34) by IA1PR11MB6244.namprd11.prod.outlook.com (2603:10b6:208:3e6::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.31; Fri, 3 Feb 2023 09:56:24 +0000 Received: from MWHPR11MB0062.namprd11.prod.outlook.com ([fe80::610f:2851:ae4e:ebe4]) by MWHPR11MB0062.namprd11.prod.outlook.com ([fe80::610f:2851:ae4e:ebe4%7]) with mapi id 15.20.6064.025; Fri, 3 Feb 2023 09:56:24 +0000 Content-Type: multipart/alternative; boundary="------------5NabDCwbXayCa3xEUNh25vlU" Message-ID: Date: Fri, 3 Feb 2023 15:26:13 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] app/testpmd: fix link check condition on port start Content-Language: en-US To: Ferruh Yigit , Yuying Zhang , Michael Qiu , Pablo de Lara CC: , , References: <20230127224514.2650827-1-ferruh.yigit@amd.com> From: "Singh, Aman Deep" In-Reply-To: <20230127224514.2650827-1-ferruh.yigit@amd.com> X-ClientProxiedBy: BM1PR01CA0145.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:68::15) To MWHPR11MB0062.namprd11.prod.outlook.com (2603:10b6:301:67::34) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR11MB0062:EE_|IA1PR11MB6244:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ef4a344-0dd2-4cbf-096d-08db05cce87f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5w1EwggKwLAkbCas7rzvtvAARIyPAEV0qO4knmvfLq2Vd/QjlZUI2iz7aNA+LdU5/rjX5vkixXV04GRkcoih8UAsWQf6hpAbURMSEfCbhN7hLHksciozMGJF6Z+ubcRgBN7s4gREOXc2Th7cyXEW8W4a8/TzEtMzFU1UkaGf1v6s+AY3EAwAph+6lmo+Wnz+OA3J433emhCWBKA9KmbqSRdoNBZsnpimWfAq6CBxcZz2qOztRvwTlx2I18BDUpiee+ow3R/Ur2Nyb5Qd5Iw7zDYcRNU3n0PyrwQRV52sSfsuRRMLn51c5E6gp059zsG8LxWIP9JVO8xj2MWja4pXJlod36z7JYLBKoHJVMt72+eUqpxw63LRjeRSzrJW5VBZHhmLr0A0WXG/V1a57AbmmCpJv/BmNx4voAUUEXtgbLLdxx9NNkGrW42Uxvf+fOdpcKsnIrhO+9iQxQm7XwCbYCfrW730w29LpBio2jPKD7IWAR5Kt64uh80mTvbsk0dBts/ksRgShVp+FtcIm9Ta/iwDA7KWJrMwJzJddsdBO2Rc7ZJy2oxmlrosKaDI6LMSIAPMVc+qqQtZtGtgVW7o0Nj9+7VaHav68aggylmL5ljwNs5iC//71cZLewOK8gkuYG97iQJe9kZvX1h9ij3qByByWwp1QpnaLRgIpIBmaAMno2D2EbJb6JrScTfnS+2UDkgEaSD81Y1DO28Onk/EzkIu0JDl2Eky4ffawsd3U94= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB0062.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(366004)(39860400002)(396003)(376002)(346002)(136003)(451199018)(36756003)(31696002)(38100700002)(82960400001)(86362001)(316002)(4326008)(66946007)(66556008)(66476007)(8676002)(6486002)(6636002)(110136005)(2906002)(478600001)(8936002)(41300700001)(5660300002)(83380400001)(33964004)(6506007)(53546011)(26005)(6512007)(186003)(107886003)(6666004)(2616005)(31686004)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dUpIQVZRczVybENvMTNvcU5NanMxeU9iN3d0U2VnbWZXMXNJd0oySVZseFV3?= =?utf-8?B?bGNHNm1ONTZpNVJhWEZsdVA4L2VhRWlBaHpsWUIyUHdkRk9FbDU3aVBsS000?= =?utf-8?B?UWtCWUNqV2pMbFBKR0xHRHhDdERIM1JWTHRHQzlnTXRhYm9FcWpZcXkrKzVn?= =?utf-8?B?Q2dUcmhkOW5INmJ3MytwNFQyeGxjOHNmUGc1R0hMTGRlT1U0KzVrbzVFOHFx?= =?utf-8?B?WGtST0ZqKzY1Z3Bqb3oyazV3L0JGRFczWURzU2kyOW13c3RtMnF5aE9tV05r?= =?utf-8?B?SjhiYTVqSEl3bWxBWUVzZTloVlBSL2l6NEQwdGU1M3pGS3BiNjdTVUFpSHJN?= =?utf-8?B?Ukl2TFJ2RHFkZUFXelIxVElGV2NKaHlWeGFPTDdjbXRTSW5RQy9XS0VOQStk?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= X-MS-Exchange-CrossTenant-Network-Message-Id: 7ef4a344-0dd2-4cbf-096d-08db05cce87f X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB0062.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2023 09:56:23.8757 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J5KwcXAgFfjiO/E+G5+nkFdpfF+ESi6z6LfWEuZHffBiVa3yTJVoCGf0vH7j66JMbxBSgfOXgomHdk6zFew/JEP9bpwEKRkg+iOJU1uIt+w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB6244 X-OriginatorOrg: intel.com 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 --------------5NabDCwbXayCa3xEUNh25vlU Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit On 1/28/2023 4:15 AM, Ferruh Yigit wrote: > 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 on port started successfully Minor typo, on => one > 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") > Cc:stable@dpdk.org > > Signed-off-by: Ferruh Yigit Acked-by: Aman Singh > --- > > Cc:michael.qiu@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 134d79a55547..2a1125c9fe81 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -2880,7 +2880,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]; > @@ -2891,6 +2891,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; > @@ -2906,11 +2909,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; > } > @@ -3130,15 +3135,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) { --------------5NabDCwbXayCa3xEUNh25vlU Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit


On 1/28/2023 4:15 AM, Ferruh Yigit wrote:
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 on port started successfully
Minor typo, on => one
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")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
---

Cc: michael.qiu@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 134d79a55547..2a1125c9fe81 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2880,7 +2880,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];
@@ -2891,6 +2891,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;
@@ -2906,11 +2909,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;
 		}
@@ -3130,15 +3135,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) {
--------------5NabDCwbXayCa3xEUNh25vlU--