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 7BA3CA054F for ; Tue, 7 Jun 2022 16:31:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 72CBB41153; Tue, 7 Jun 2022 16:31:34 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2066.outbound.protection.outlook.com [40.107.243.66]) by mails.dpdk.org (Postfix) with ESMTP id 01E9D40156; Tue, 7 Jun 2022 16:31:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mqwyiqAXT4XYlFUAHCBVPwud9IQTZ4t4dWAMKuzSdr5mo6BItFCaUK6foUeo27qOLhuYrIkrdtsW/1mSKbyZAqOyQEN55uHC114mJN8BILMnqCoyrCsSsHMWbklG7qWXPnkwN3ZXn/QJUH8lN7aNalUIo+rRwgJACCsTMBjt/3fNpcjkARONHlNwZVWj9vMXJ2hhKM+3HFd4ZtzcJ/B+FgE3JhM7/QP0KHVEXnL5K1Ef8ZdzBu5JJQ72jz5J+mTK2qchJSVoPx1pGvc/4KGTyK4Yo5LVP6O4IOnGB8puCltNlbdeKldQ/3WZWROl/oPbjZc1p2aYWd33JMDchvr4JQ== 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=MJdT3c8ZmkbIMA4rWW7uTATIOmwx3BqBUSCWMiW3ris=; b=RrpkWaTF6NcLV03d8wpCYFSndZjFNK1NdxbfU2ChIvVD8NNgmnJCybo/UqNgzFCOwrOxxkQTxu7GWqmUeYSgs0s2SaM+p14zYxcbojW5fsL6acudloIcDvFxsO64IzZOypNPjCZYpEFblxtt97EiIl2VPT2kkM234qONBMzWBVZXGwkbB+8DvmB9TQ6JmbwJCBngQzE6f6CMZUEyKqB/cmSM5iLH9pNnqjCxZRKlFXNQOmozE5YtwCMc1ugs+xb5rGFyZxtX7uj8KolY8ejP8mrU3dnN+2igrwjL5eGKKkMeDl330Khq0+CSYy05DrEDPazeLYwTG7no8eYxfwBGhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=huawei.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MJdT3c8ZmkbIMA4rWW7uTATIOmwx3BqBUSCWMiW3ris=; b=jOGIjP7wKPpr7lq7vMd6sUxhiCxOvkM3u/RVoi56hdl/HQk+FnREHphqvP3o6OHxM72I7ouY2Isi8Cu/x2wFZNRMHBHeDi3JfrtJ0X/nm1EvMFR71vUNMrLwu+FDC25yarHSKdk09PZtr81asIENOsHBUr46KdbDAE5oCkpl4aU= Received: from DM3PR08CA0006.namprd08.prod.outlook.com (2603:10b6:0:52::16) by CH2PR02MB6838.namprd02.prod.outlook.com (2603:10b6:610:79::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Tue, 7 Jun 2022 14:31:29 +0000 Received: from DM3NAM02FT013.eop-nam02.prod.protection.outlook.com (2603:10b6:0:52:cafe::18) by DM3PR08CA0006.outlook.office365.com (2603:10b6:0:52::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Tue, 7 Jun 2022 14:31:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch01.xlnx.xilinx.com; pr=C Received: from xir-pvapexch01.xlnx.xilinx.com (149.199.80.198) by DM3NAM02FT013.mail.protection.outlook.com (10.13.5.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5314.12 via Frontend Transport; Tue, 7 Jun 2022 14:31:27 +0000 Received: from xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 7 Jun 2022 15:31:25 +0100 Received: from smtp.xilinx.com (172.21.105.197) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 7 Jun 2022 15:31:25 +0100 Envelope-to: liudongdong3@huawei.com, dev@dpdk.org, stable@dpdk.org, xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com, bernard.iremonger@intel.com, pablo.de.lara.guarch@intel.com, lihuisong@huawei.com, humin29@huawei.com Received: from [10.71.117.191] (port=6629) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nyaEu-0000vX-EX; Tue, 07 Jun 2022 15:31:24 +0100 Message-ID: <9a0fcfdf-6302-36f8-e26a-ff228cccfc74@xilinx.com> Date: Tue, 7 Jun 2022 15:31:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v4] app/testpmd: fix slave device isn't released Content-Language: en-US To: Dongdong Liu , CC: , , , , , , Huisong Li , Min Hu References: <20220503100217.46203-5-humin29@huawei.com> <20220607081038.23859-1-liudongdong3@huawei.com> From: Ferruh Yigit In-Reply-To: <20220607081038.23859-1-liudongdong3@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 092cff07-211e-4444-da34-08da4892686a X-MS-TrafficTypeDiagnostic: CH2PR02MB6838:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gj7gQPAzxU1vqVvwf8HY4E77OkHS+H19cjxgVYApK0KpPby0cFB3vuA2487aDExjsv5cIFkwPvtFehcnen/eB392PP2TgAXChF4Jb3TO+2z5icJNktsVygVjOCSYUDwxnhAlAgoGcvQkjPu/9P6tvMcRGysy9mr2EztE/GkUZ0lDlATjRhYe5UTCYa//FgJjSKUYk3Ul79U8gH4LmB6cW6xTqms99JncBwCipH03r3vVolCkjCnbGStMAuGyUMil1/fYAvMlETelp5sj5EUTyH2KIxcxY8f8ZCK5vDfvgh9fsc6QNJtMw4SWYutBooHJyQI9EqOafb3gEwmI20uDUM9V6PByddT/zOdMrsjstUURxRUvYyBfrNgPnrbAEogAiDcSeZyDi0dDjEq/B5hNDbc9ipV3c3olqwRIfVoM0WMxyviuv1sM6Cc/+HESF04YS6UaBHMfvKMWIoKcXWLbXY8Pw5wvmRSJVyNBTVZVazclRaDkIIH7scpXyfXWCUNJ7mOSsFVT5vujPsrjF3O6o165qaK1dVYc7DJyoZXqHtL/7Kc9OqJewdGJ72O93mgPlNECRw4LAcosCxHVd55EWJW2L4t/EAl5QmmhBLaBhWjZI8vg9iu+WrmbEojXUHiq3t8EsY2jlEFTmlQPpMYr45POkjOVEQloXbJHKpwosKLnjOVH3M4Rx3L0kEe+JStrI9HTX5NAuMrxkjqV4HtNCvJ01YSopZo0pUrJsR0MZEQ= X-Forefront-Antispam-Report: CIP:149.199.80.198; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:xir-pvapexch01.xlnx.xilinx.com; PTR:unknown-80-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(2616005)(7416002)(7636003)(4326008)(8676002)(8936002)(2906002)(36756003)(5660300002)(82310400005)(31686004)(9786002)(356005)(70206006)(70586007)(36860700001)(316002)(31696002)(83380400001)(47076005)(44832011)(426003)(336012)(508600001)(53546011)(110136005)(54906003)(26005)(40460700003)(186003)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2022 14:31:27.8573 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 092cff07-211e-4444-da34-08da4892686a X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT013.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR02MB6838 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 On 6/7/2022 9:10 AM, Dongdong Liu wrote: > From: Huisong Li > > Currently, some eth devices are added to bond device, these devices are not > released when the quit command is executed in testpmd. This patch adds the > release operation for all active slaves under a bond device. > > Fixes: 0e545d3047fe ("app/testpmd: check stopping port is not in bonding") > Cc: stable@dpdk.org > > Signed-off-by: Huisong Li > Signed-off-by: Min Hu (Connor) > Signed-off-by: Dongdong Liu > --- > app/test-pmd/cmdline.c | 1 + > app/test-pmd/testpmd.c | 46 ++++++++++++++++++++++++++++++++++++++++++ > app/test-pmd/testpmd.h | 2 ++ > 3 files changed, 49 insertions(+) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index fdd0cada3b..6c58b02650 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -8915,6 +8915,7 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result, > __rte_unused void *data) > { > cmdline_quit(cl); > + cl_quit = 1; > } > > static cmdline_parse_token_string_t cmd_quit_quit = > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index fc1b64b60d..2b16551a26 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -229,6 +229,7 @@ unsigned int xstats_display_num; /**< Size of extended statistics to show */ > * option. Set flag to exit stats period loop after received SIGINT/SIGTERM. > */ > uint8_t f_quit; > +uint8_t cl_quit; /* Quit testpmd from cmdline. */ > > /* > * Max Rx frame size, set by '--max-pkt-len' parameter. > @@ -3201,11 +3202,44 @@ remove_invalid_ports(void) > nb_cfg_ports = nb_fwd_ports; > } > > +static void > +clear_bonding_slave_device(portid_t *slave_pids, uint16_t num_slaves) > +{ > +#ifdef RTE_NET_BOND > + struct rte_port *port; > + portid_t slave_pid; > + uint16_t i; > + > + for (i = 0; i < num_slaves; i++) { > + slave_pid = slave_pids[i]; > + if (port_is_started(slave_pid) == 1) { > + if (rte_eth_dev_stop(slave_pid) != 0) > + fprintf(stderr, "rte_eth_dev_stop failed for port %u\n", > + slave_pid); > + > + port = &ports[slave_pid]; > + port->port_status = RTE_PORT_STOPPED; > + } > + > + clear_port_slave_flag(slave_pid); > + > + /* Close slave device when testpmd quit or is killed. */ > + if (cl_quit == 1 || f_quit == 1) > + rte_eth_dev_close(slave_pid); > + } > +#else > + RTE_SET_USED(slave_pids); > + RTE_SET_USED(num_slaves); > +#endif Do we need this #ifdef, everything is already available in compile time. > +} > + > void > close_port(portid_t pid) > { > portid_t pi; > struct rte_port *port; > + portid_t slave_pids[RTE_MAX_ETHPORTS]; > + int num_slaves = 0; > > if (port_id_is_invalid(pid, ENABLED_WARN)) > return; > @@ -3240,7 +3274,19 @@ close_port(portid_t pid) > port_flow_flush(pi); > port_flex_item_flush(pi); > port_action_handle_flush(pi); > +#ifdef RTE_NET_BOND > + if (port->bond_flag == 1) > + num_slaves = rte_eth_bond_slaves_get(pi, > + slave_pids, RTE_MAX_ETHPORTS); > +#endif > rte_eth_dev_close(pi); > + /* > + * If this port is bonded device, all slaves under the > + * device need to be removed or closed. > + */ > + if (port->bond_flag == 1 && num_slaves > 0) > + clear_bonding_slave_device(slave_pids, > + num_slaves); > } > > free_xstats_display_info(pi); > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 6693813dda..b44d5dd5ac 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -38,6 +38,8 @@ > #define RTE_PORT_CLOSED (uint16_t)2 > #define RTE_PORT_HANDLING (uint16_t)3 > > +extern uint8_t cl_quit; > + > /* > * It is used to allocate the memory for hash key. > * The hash key size is NIC dependent.