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 9CCFDA0558; Thu, 9 Jun 2022 10:50:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 818FB40689; Thu, 9 Jun 2022 10:50:38 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2058.outbound.protection.outlook.com [40.107.101.58]) by mails.dpdk.org (Postfix) with ESMTP id DAB8B40220; Thu, 9 Jun 2022 10:50:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FIQW2KSHXEa9MEJiRcllpO82AzzdvBgeqnMteZtXYHbk+1S5QErVdsJlnZf5EDmU5eHlq1fumeKyEi4d+22eH70RDG/joFqdZItKZwXKOW6rzbrUCZO66XDlGoNXyTY0FZDzPod/HNgaL+27nczH+/xJXwZquaLz4rG9/NeRFazOo9M0a7qqiKzWRe/yRNhAEKJsRziVYTdxpciaTUlhBSDe/Q3beZs9gy4zLoPCWeWsvtQTpWaNgrIdCU+fZ6y+l6uQU2XoawAsn+d6VdIAK1DuA+0PhF3agsxZyygPk6k7z0Uvem0jO7q8nJFT2QoIGXd0qlN0OqiP3FDuWN1lxw== 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=z+/xjH1dJ1WZ9MMTSkNyI3Y03W1Hcwmm/uKUeow7LGU=; b=ABFzGFsXXtj2uxWkxFva0BQFLnjEQS0+2bsEbYLtMKcIPik2OAoH++SSKzCuCTN0a3r6eOs0kFLjQN3iV9s0YowjE8Cv+gyo71W1XQwrrt6ZARitm+bLBVFA6SfcfwlJxkmmn52ElIwe8xMa37rnD1+IAeoD+Sh11KajXcdvTCAQ1KsNUAT39o4U9t8+y/ApdMQTRUVKN9avKFvx5+eWrMpfWlanEU7H6cpf1l5DJgNIC8aLtLa1Ad+NI+dkh8UILQpvhDMnFHnuFM3AQdJ1usnfLpPe5qAVvJM/vLKrtCJGwU8DuIS+khLc6LEgJvDm2BBRKcKaMqOJVIKGPSCVGA== 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=z+/xjH1dJ1WZ9MMTSkNyI3Y03W1Hcwmm/uKUeow7LGU=; b=FFN8NJsmZrqy0zvLXpJaFwUOu4BH3BYYR76wrN6PD6Tlbo63UClijB9fdyMKmE+i+x2wNhUAHit5b6nNq0mJJ8osYtT+aDRr27B1+MZ0gzhYhUDtxjrP6ffgR+BQCg4k99NHeD8QKhKikAPxNsraLDLeiPEtLjNqUIFX6YcW76o= Received: from SA9PR13CA0175.namprd13.prod.outlook.com (2603:10b6:806:28::30) by BY5PR02MB6577.namprd02.prod.outlook.com (2603:10b6:a03:20d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12; Thu, 9 Jun 2022 08:50:34 +0000 Received: from SN1NAM02FT0050.eop-nam02.prod.protection.outlook.com (2603:10b6:806:28:cafe::c4) by SA9PR13CA0175.outlook.office365.com (2603:10b6:806:28::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.6 via Frontend Transport; Thu, 9 Jun 2022 08:50:34 +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 SN1NAM02FT0050.mail.protection.outlook.com (10.97.5.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5332.12 via Frontend Transport; Thu, 9 Jun 2022 08:50:32 +0000 Received: from xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) 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; Thu, 9 Jun 2022 09:50:31 +0100 Received: from smtp.xilinx.com (172.21.105.197) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Thu, 9 Jun 2022 09:50:31 +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.247] (port=51265) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nzDs7-0003Yv-2v; Thu, 09 Jun 2022 09:50:31 +0100 Message-ID: <714db392-457c-0570-779c-49513caeb944@xilinx.com> Date: Thu, 9 Jun 2022 09:50:30 +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> <9a0fcfdf-6302-36f8-e26a-ff228cccfc74@xilinx.com> From: Ferruh Yigit In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22c21347-a10f-4c99-3b0d-08da49f51d38 X-MS-TrafficTypeDiagnostic: BY5PR02MB6577: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: DvlZuuTv5ZHcT25HF4peRgwKqaXxDahazdnjQZl1qlCJdnTWv49G9PQmQwAo4EAexYV6N0eUjpMqpQf4ePyWMWLIR915pLzgXdIqv3ftjkVIjDSauEUlZKKfEb74q9JKNZRlF5QU4rPbGpEL99bELD7k6dM1+QfjEtHyU+v3I4bDEK8KuSGQhwY1ylAXo387/Lqssg4X+suEEuzT5auMVjg2S2hdevAc8whH1czTI8d0q04//V/Ds34XvBhhy1PmL4XIjbL99YUOCKaesD6MFBz2Q6wVfuuKEpN2WNcVwLiyN1n+ZM+FH7ev9/kHOJECyRIBFg/1zVWpC+tQc7JWn6KnDoockbyn9F35RzRzrffzSuXna//3iQeIW2TjBXh3CG6iT9zbqrvrGhAqocRLDrbvnMRPTxXnFhLIWb4DtbZruxbC3NFmQDbNKHQ49M5vQD0eA5J9X/yut+/+w0OYuc8/RTrSC5mXeu+95p3czJ1GekPNezOBXWDme1yQXDqpk+nRuEA7nfoGhiaT2CLxY9+Jny9FO7vsD3JMLF/K9cB1uLh7lXpwLOiARkvg9+kJHFo9hUBmJfwMtTf5d0kco/5tm3eqGY98v5WYEB3SoagZ7vpxfKAYkgR0v4ZDEgNL88pYEhR89ofX5eMJCH8wVWvVmNfi0qIG2aje3KYCg/m/Z4XNeDIiL+Mg7LcfcHeghlJBj7F+PhAup+eHmv3x85BvAgurZF50kZjO+CSBhgk= 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)(36840700001)(46966006)(40470700004)(31686004)(36756003)(508600001)(44832011)(36860700001)(2906002)(4326008)(54906003)(110136005)(53546011)(9786002)(8936002)(5660300002)(186003)(8676002)(316002)(40460700003)(7636003)(70586007)(70206006)(2616005)(426003)(47076005)(336012)(26005)(356005)(82310400005)(7416002)(31696002)(83380400001)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2022 08:50:32.9573 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22c21347-a10f-4c99-3b0d-08da49f51d38 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: SN1NAM02FT0050.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR02MB6577 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 On 6/9/2022 8:50 AM, Dongdong Liu wrote: > Hi Ferruh > > Many thanks for your review. > On 2022/6/7 22:31, Ferruh Yigit wrote: >> 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. > > Although it can be compiled ok without this #ifdef, > I think we still need this #ifdef as this is bond related > implementation. > Code will compile and function as expected even if bonding PMD is disable, right? If so why #ifdef is needed. > This patch does the similar #ifdef grouping done in 3/5 patch. > > Thanks, > Dongdong >> >>> +} >>> + >>>   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. >> >> . >>