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 02DB544132; Sun, 2 Jun 2024 12:31:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0F17427D8; Sun, 2 Jun 2024 12:31:00 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2071.outbound.protection.outlook.com [40.107.212.71]) by mails.dpdk.org (Postfix) with ESMTP id 3EACC40150 for ; Sun, 2 Jun 2024 12:30:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oItCKHxl9dMo8fhkYMoq7p56qVh7p0V0+dYLFxlA3mlJszswCQyUUrIRcm97M9Sfci2kTzsqUNQN6IFq7PW7rcPmRzJRCd9deuSRQKaWMCihQtagTTe1tkkwmgtfAhPCqZQzYkI1YvVtTjSnxsB7H6E18fZdA1+bmI7OhjuZ4WMNRLDd0lJFG+bE4yQVkSwWKw7hJzQ73s0QxeHOTlrQzN/vsItx/Md/R51rPQJ0If3ZlSi6WAzkT26b2U/kxflv3U4hU6NlLJ+Y6yDbIBCEZTr6HIR7eg6zOPi95AFFttZRZqYlgLbRStTXerItIsdR9Y3oLCz62uRUlWHVknyiyA== 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=Glq2y4101OpwN+y/kKUtf+KzmP/YNTjLEXhXhhrgreU=; b=h15wpgNoMGeG2+sNN6Zx8lQt5g1IzGpN842Ex4Q1Gt9YwRLv2UV6kZJKfJvAW2qTfg9DQ+qiYMKiIHiqk+3ZOHkURxMXL2XyBmoTt+/RkcD45dAb6H6kjFGb3e+OlBh/Qz7akLFqEEjwDIWGG5Knbfo1kc+0wskJ6Ll9HQdOMhyTlmgEqKPOdpI+3R5z+P5w5Gd6d5OLUbdLIpAj636gLQVjkbGkH8R4PvW8tdeOjJ0jKz+bUJvDfA31RVE6+DAJzq673eW5NHbk4/AakPj9UgribrpeKW+k6q+N2KoSgplJLsD56aMsPvbA2L+wmuvR50OYkHkwQMwe62eW+CGdOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Glq2y4101OpwN+y/kKUtf+KzmP/YNTjLEXhXhhrgreU=; b=ZfJRXeThDP5oC+QBzux1+lnf4YI6KO6o0MxxFBmMKxrhXugUhynEjKwotWuK54wA4eOQ1tNva1Gfry1YJgsMHqekVQpmJ/509RtBlcnRhej2Dkv+T1uGIpsX0PTYDlq6z+lf8B0cYiulpDOhaoYFo0oaoY9kl4gEnTJZaOIfz8Qzup8TQYx30aAFgFzXDWLYJXg+U4XVGK5SZKD+N/IKec+kKQTbrAltN5r1c9sJHHAh5+axP7vqSMvF8QjOZzvUZM2GgRHFPCtBMGHuRNlqySWx3ogsX1YLidWGNbinxHxWp2pfGMQoO2Z0j1NRS2RCHCdSpcTON2uDLilsXoAQnA== Received: from BL1PR13CA0008.namprd13.prod.outlook.com (2603:10b6:208:256::13) by MW3PR12MB4378.namprd12.prod.outlook.com (2603:10b6:303:52::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Sun, 2 Jun 2024 10:30:56 +0000 Received: from BL6PEPF00020E65.namprd04.prod.outlook.com (2603:10b6:208:256:cafe::21) by BL1PR13CA0008.outlook.office365.com (2603:10b6:208:256::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.13 via Frontend Transport; Sun, 2 Jun 2024 10:30:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF00020E65.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Sun, 2 Jun 2024 10:30:56 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sun, 2 Jun 2024 03:30:41 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sun, 2 Jun 2024 03:30:41 -0700 Received: from nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Sun, 2 Jun 2024 03:30:39 -0700 From: Maayan Kashani To: CC: , , , "Aman Singh" , Yuying Zhang Subject: [PATCH] app/testpmd: support retrying device stop Date: Sun, 2 Jun 2024 13:30:35 +0300 Message-ID: <20240602103035.197205-1-mkashani@nvidia.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E65:EE_|MW3PR12MB4378:EE_ X-MS-Office365-Filtering-Correlation-Id: 78a40047-0e48-4b01-0fb4-08dc82ef167e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?AvDjhqc5KCOzfeO2BOPBM4HT+8Fd2wG2/cJEJbPqck+U+OEJ0QmxMEEtDlRy?= =?us-ascii?Q?lmDGe02NXr4YyxEBpl7cFXg1jLFwD9Ir+nlXY+cpRCsQA0bo+NlzLT3VvKaN?= =?us-ascii?Q?F8fJ2juG7HwlKE91M7Mg7t056rYk0X5qAWEceP4+nsxLO8p9ZziQpQ+Jobyk?= =?us-ascii?Q?MMdVEUBTUHRenznXZqxZ5zY7fPmj1GsHaT+U9IKlkg3PfZXWLPhOzIPKuGkP?= =?us-ascii?Q?kmJFD2aNo7tmZk9pR1tX4ddeTWQsA8mKsADbQo+wwQhth0VZztoj9Gr7dfPI?= =?us-ascii?Q?0ZTv1oRRY/fFI4HWjoqYSNYkh7PLXnyyJxla6APwoALbpVCnGicuyuvapr6e?= =?us-ascii?Q?0F4xZvX+hEj/bZtUOJl7Izy1jay4MBYYvlkZ4lI13xuvdsth3X1OeUI6C2nw?= =?us-ascii?Q?0bWXKtARJsjQzuglZjpbKdkOkXy3TuWJhmno96nCU8LzTnvp6w+bPY0dk1Q7?= =?us-ascii?Q?ttcXLz4deSkVGM6eoaULtLxcBSY9gD1l1q3/gGh4INo4cS34+RPKGjzd5dm6?= =?us-ascii?Q?LQzVsWHlTskqVNXLmgplC+4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228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(82310400017)(376005)(1800799015)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2024 10:30:56.3891 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78a40047-0e48-4b01-0fb4-08dc82ef167e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E65.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4378 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Dariusz Sosnowski In some cases rte_eth_dev_stop() can fail with EBUSY error code meaning that port cannot be stopped, because of other resources referencing this port and port must be stopped again after these resources are freed. This patch adds handling of EBUSY error code on port stop to testpmd. Signed-off-by: Dariusz Sosnowski --- app/test-pmd/testpmd.c | 47 +++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 70ea257fda..2d4d583cdf 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3361,6 +3361,7 @@ stop_port(portid_t pid) int need_check_link_status = 0; portid_t peer_pl[RTE_MAX_ETHPORTS]; int peer_pi; + bool left_ebusy = false; int ret; if (port_id_is_invalid(pid, ENABLED_WARN)) @@ -3412,12 +3413,25 @@ stop_port(portid_t pid) port_flow_flush(pi); ret = eth_dev_stop_mp(pi); - if (ret != 0) { - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", - pi); + if (ret == -EBUSY) { + if (pid == (portid_t)RTE_PORT_ALL) { + left_ebusy = true; + printf("Stopping port %u will be retried.\n", pi); + } else { + printf("rte_eth_dev_stop failed for port %u. " + "It can be stopped again after related ports " + "are stopped\n", pi); + } + /* Allow to retry stopping the port. */ + port->port_status = RTE_PORT_STARTED; + continue; + } else if (ret != 0) { + printf("rte_eth_dev_stop failed for port %u\n", pi); /* Allow to retry stopping the port. */ port->port_status = RTE_PORT_STARTED; continue; + } else { + printf("Port %u is stopped\n", pi); } if (port->port_status == RTE_PORT_HANDLING) @@ -3427,6 +3441,27 @@ stop_port(portid_t pid) pi); need_check_link_status = 1; } + if (left_ebusy) { + RTE_ETH_FOREACH_DEV(pi) { + port = &ports[pi]; + + if (port->port_status == RTE_PORT_STARTED) + port->port_status = RTE_PORT_HANDLING; + else + continue; + + if (eth_dev_stop_mp(pi) != 0) + printf("rte_eth_dev_stop failed for port %u\n", pi); + else + printf("Port %u is stopped\n", pi); + + if (port->port_status == RTE_PORT_HANDLING) + port->port_status = RTE_PORT_STOPPED; + else + fprintf(stderr, "Port %d can not be set into stopped\n", + pi); + } + } if (need_check_link_status && !no_link_check) check_all_ports_link_status(RTE_PORT_ALL); @@ -3797,11 +3832,7 @@ pmd_test_exit(void) #endif if (ports != NULL) { no_link_check = 1; - RTE_ETH_FOREACH_DEV(pt_id) { - printf("\nStopping port %d...\n", pt_id); - fflush(stdout); - stop_port(pt_id); - } + stop_port(RTE_PORT_ALL); RTE_ETH_FOREACH_DEV(pt_id) { printf("\nShutting down port %d...\n", pt_id); fflush(stdout); -- 2.25.1