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 0772CA034F; Fri, 4 Feb 2022 13:15:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F4F840143; Fri, 4 Feb 2022 13:15:34 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 37C6A4013F for ; Fri, 4 Feb 2022 13:15:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643976932; x=1675512932; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=xf7yLLodgRNWvPQ64N9iqBxD4aWZ3bita6fTNuxtwe8=; b=UI57sVgjoz+H/0aOeAwjaeEUH+fUpXK6ruZR6u4mTdrIzXfuRsRkRCqB S7EdBPBvaRkaSUlDcWXva2bPsb3XUJAHdvz8ml39ocqOBfzvYa2He01Uj 4NQZqJ7CUO+GkXXtgncZ1SnVZEzBlpGt6Zx4wsoZid0A5zpq2dxLzSCcX 1WA5kZ9SatyfKc1Kz2J/Ig7uGgQmwHQmST95UN9YD1jQ7za6qTM+Z+7yq E1PZR4Ef3pOkWhgVWE8peHrRBYeikzQ9nAmSnuXpnG/kU5iLhDALXiVyG u9r5z/4I2Sn0HyuxVWYEiDESwp74j81QWdwDVLkb6yhJn5KOjBkvG6M4r w==; X-IronPort-AV: E=McAfee;i="6200,9189,10247"; a="311659843" X-IronPort-AV: E=Sophos;i="5.88,342,1635231600"; d="scan'208";a="311659843" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2022 04:15:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,342,1635231600"; d="scan'208";a="539148642" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by orsmga008.jf.intel.com with ESMTP; 04 Feb 2022 04:15:31 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 4 Feb 2022 04:15:30 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Fri, 4 Feb 2022 04:15:30 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.47) 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.2308.20; Fri, 4 Feb 2022 04:15:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iAPVl9iujbP4/3eKxHzTS9KV31OfpainCpk93kAovoj/l/uJhLoiosp8nRQRFI6N65f+/JYNHFAWkwIirSEdpgAuZZ8qdE5YTRK8IZ/w+EvWGFakTgnW8YLkjyRQtAo9LPX3GfeXs4lkwwqDQajKN8fXAv5QrsOnu/x8EdPG5xi/e+7FRf6MipZ1wbrDwaxDnHkoITUy4AiIvgGVxDMdTMTKhBA8bWidVM2p/d7B3NlSLzl3dzUfqhfWnPYPpekDMErQJZ3DdZsPKV4+CibMVDUXN5UuEonjwUhZXbtwsNQFQQlmu5wWSAAEQ+dLoy9NmvBxqa/18DzxlhwQi1B0Eg== 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=fB4wl+VBa1ZDddp/CuuThLDNspRcx5O0RItFdk/prws=; b=AnUS6EwRNll2toBt33+AnvJcWypMXQWHqYriw87g0Hx9bs/VQ+Ymfu/GfnGrj2wSX8ubuRjHNnj61PwsLKs+HOQr92JLsmvAmJFVHzBfnLp5MDIfie4pT34WBriMNgWNXx2XUkIcrwbK8AV3CNlQbIwRZVCfN75iYeXg4VbNgVMmFEDb/Na8FQqb3N2HZ4IjGpp8GzN93AYHxKkRKNEb8wY080IKdPuTTAZxJQ6r+3MKUT7uYpGX/TdNH/C7EBmf1ZGPo914nNF7qEpzicBK/a1ZYe8nEATitUxAH82+6P8bs+YhwesJJq2jhSiOMshUMBdAIcYfbahc0puAIJdeMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by DM6PR11MB3179.namprd11.prod.outlook.com (2603:10b6:5:5e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 4 Feb 2022 12:15:04 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::5046:8550:928d:850e]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::5046:8550:928d:850e%7]) with mapi id 15.20.4951.012; Fri, 4 Feb 2022 12:15:04 +0000 Message-ID: Date: Fri, 4 Feb 2022 12:14:58 +0000 Subject: Re: [dpdk-dev] [PATCH 2/3] app/testpmd: fix slave device isn't released Content-Language: en-US To: "Min Hu (Connor)" , CC: , References: <20211025063922.34066-1-humin29@huawei.com> <20211025063922.34066-3-humin29@huawei.com> From: Ferruh Yigit X-User: ferruhy In-Reply-To: <20211025063922.34066-3-humin29@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0256.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::28) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ea11a84b-c210-4de6-8f07-08d9e7d7f94c X-MS-TrafficTypeDiagnostic: DM6PR11MB3179:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:514; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t4TqC2zyXl/1Nl6u8vPuCqrSt4mgJQ5hrD7nnYuEQxfJfn3Mtxp7RHFFtEGUGbmfKQGw7SU5mWCYv98/IbKn8o5ewWvfqafkpuTsRQsdw5HXy+I7tS3azwtjoowmOwXik0z0KycFN7O8F6sTs6Ki2P2l7Dg4bAtkiah61+5nU78k3ZBeWU+/tePvfzbAnDJlZAm5TXDVPW3dJiJbmBXXzgTEaqqJz49h2e8rDWcBhNCa2pAtifPaV0gAzJsQ2oZDjuIicETW6TIAsY4S29KNqjab5VgJ9vPJRtcPZJSsWk1/0tWjePDOHah+hOayPMj2WnDYeHGVbX3jaoGSr99v1QlbKc/rMJaC6qOhWf4K2jei0wEr4kh7jWPl/3Kumq00uCXFIdmgy7UbFdoz/Ozxxo4vvNfhy/rOelQ0O5TMEHnYoh4+xLLbLPw96E/cHwkVg6GvuoFzYZ0N645XT37uSfD8YuAMJ+14hDNrTnRtUW9Jm8aDBBrs1PhnLAHil1FWk3Zo8vpjN1qwbVdWeJlt4jZucsgCZVoZybIQAqpfSGzQGBUZqzXt2DeEfAXgEy4IjaXjyDTWlkAbZ4Q+ws1EREzwCmtUgiLcnwJtzcVwJsU12W+Lk6cwvJGdq5NpLinuatGVwTWixL7nEjcUz/pcL/bsyAFiWTR6cKSqIj4ScmrFLks0mP6ocASkNTv+Pvd74PwPh05qQs8GB4UDYi/ODA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(38100700002)(44832011)(6486002)(66476007)(66556008)(31696002)(82960400001)(186003)(26005)(2616005)(86362001)(107886003)(66946007)(83380400001)(316002)(6512007)(55236004)(53546011)(6666004)(4326008)(8936002)(8676002)(2906002)(508600001)(6506007)(5660300002)(36756003)(31686004)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OFJBaWduNmpBSHUrKytLM0owcHBlaThqNUI4Nk1Eb3NCdXpjWXA4WXlscVk5?= =?utf-8?B?aWR0SjhQQkRUcWV4OVlhUEJZb09Hc3hudlpFNlZRYmR6QllrMG5kbU94TmMv?= =?utf-8?B?YmhFNkZOZGFVdkRiZERpb2VQS0dobjBtSG95dzBDdm9YSVR3WDdqZUcyZ3Zv?= =?utf-8?B?YVkxYnZMRjUrM041L1hwTXp4NzdWUmR3Q2ZONWNXV0FkZjY2aTE5eDBHcm5a?= =?utf-8?B?R0FveGx1a3Y4Tlp1WlFSK3RzemgwVDBUSzhoWlBKMDNIdlNkWncxYU53Sks3?= =?utf-8?B?bWRDZmRORkY5QURhSXFkaHdkMEQxaGVnRFAzcEdDOEJTTVhIOGNDaXZTY3pH?= =?utf-8?B?Y09YbjBuSUh2bzYxN0ZHdUhPdzMvd1EzaC9HRSsrcTM1Ym5JU0VBLy95MEhs?= =?utf-8?B?ZUhzcU84TWRSSENtNlJjWUdjckE0ekg0dmdTekk0N292V1Roa2ROcVVoRWl0?= =?utf-8?B?SG9LWWE2QjhvM2tCd09Ba0lweUkxc1ZEM1VESFlycWJmd01TL2FHZl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Vp0Nkh5Y04ySS9VOG5E?= =?utf-8?B?em11UlhsY3BvUnIrTmlqa245bUZpcnZSRXB1cjk2MlZsYXphWE45RUdHOEF3?= =?utf-8?B?Qm9hRWRoVmM0SzRzNFRMN1Y5enAyV01lUmZ4eVRESW1zOUR3amRMTkZ3anJn?= =?utf-8?B?WWVMN1N6MFBnWCtqUXIrZ2Q0ZXY1TWRmM3ZvVzlqczhqeDVDMmJydC9nQ3Fx?= =?utf-8?B?eGg5TXdxQXF5d29oQ095NnVobjJhRkZ1T1lPNXJUaDBPQ1ZHQmdaQ01WL1Vv?= =?utf-8?B?OHVJQjVwTk9QSmhTRjdERDNQSWpFTWx0Nnl2SkQzaGE0eDdQNkVHY242c0tR?= =?utf-8?B?MkdvYUszM2h1SVdIczRobzkzR3h3RjlOTzdyZlVCUlRFcCs1dGVxbjhFZVps?= =?utf-8?B?WFNzY01rcXN3RVUxbjNoZ1ZQQXFCQTA2VG9KM00yNEhwSSt0RDByaUN4T1Ri?= =?utf-8?B?L0hTTUN3QTRzM3VIMlpDeWhDSnJOZnQ0ZDdpYlNLOXdqQWJOWmtzNStVMDNV?= =?utf-8?B?Q3dCcFUreG92UnltMUllT2pVd1d5U3ZqMVdSWW1JN3FPWUJUL21xd0Q2dHRN?= =?utf-8?B?ZFM4cUwyNnBEa1d4aHkxR0NPMnJwTXBPcFM4cnlic2swaHNxOHRDNnY5U0U4?= =?utf-8?B?WDB5VEViNUg5YUNyTnN6amNDUVlCK3cyT1JCL0pDTGhwL0w5MDVSV2VPdE53?= =?utf-8?B?ZTlkYXpjRnYxcmhDS1hINFVMQkkwekxOMVZtTHVXVGZCVjVSR0lFdUlvYzI4?= =?utf-8?Q?oEHvest3gk6pZZTmLEsjPbE=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: ea11a84b-c210-4de6-8f07-08d9e7d7f94c X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2022 12:15:03.9445 (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: qzpBQSd+kDRZNOr1ZAmUvf+c0ioekdInvVBJNibuVoMxLV8jUzZc6qhMFPcXeLYIi7g2IrwrN0ySjBeidzDw+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3179 X-OriginatorOrg: intel.com 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 10/25/2021 7:39 AM, Min Hu (Connor) 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. > 'close_port()' function traverses all ports, when bonding is close, if it removes the slaves, won't 'close_port()' close slave devices? If so this prevents, 'cl_quit' global variable. > 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) > --- > app/test-pmd/cmdline.c | 1 + > app/test-pmd/testpmd.c | 67 ++++++++++++++++++++++++++++++++++++------ > app/test-pmd/testpmd.h | 1 + > 3 files changed, 60 insertions(+), 9 deletions(-) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index 5bfb4b509b..98236a8be3 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -8743,6 +8743,7 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result, > __rte_unused void *data) > { > cmdline_quit(cl); > + cl_quit = 1; > } > > cmdline_parse_token_string_t cmd_quit_quit = > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index d6b9ebc4dd..fea9744bd6 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -221,6 +221,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. > @@ -613,15 +614,6 @@ eth_dev_start_mp(uint16_t port_id) > return 0; > } > > -static int > -eth_dev_stop_mp(uint16_t port_id) > -{ > - if (is_proc_primary()) > - return rte_eth_dev_stop(port_id); > - > - return 0; > -} > - > static void > mempool_free_mp(struct rte_mempool *mp) > { > @@ -3123,6 +3115,55 @@ remove_invalid_ports(void) > nb_cfg_ports = nb_fwd_ports; > } > > +#ifdef RTE_NET_BOND > +static void > +handle_bonding_slave_device(portid_t bond_pid) 'handle' in the function is not very specific, it is not clear what this function does. > +{ > + portid_t slave_pids[RTE_MAX_ETHPORTS]; > + struct rte_port *port; > + portid_t slave_pid; > + int num_slaves; > + int i; > + > + num_slaves = rte_eth_bond_slaves_get(bond_pid, slave_pids, > + RTE_MAX_ETHPORTS); > + if (num_slaves < 0) { > + fprintf(stderr, "Failed to get slave list for port = %u\n", > + bond_pid); > + return; > + } > + > + for (i = 0; i < num_slaves; i++) { > + slave_pid = slave_pids[i]; > + /* Before removing a slave device, stop the slave device. */ > + 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]; > + if (rte_atomic16_cmpset(&(port->port_status), > + RTE_PORT_STARTED, RTE_PORT_STOPPED) == 0) > + fprintf(stderr, "Port %u can not be set into stopped\n", > + slave_pid); > + } > + > + /* > + * Remove the slave from a bonded device in case of failing to > + * close bond device. > + */ > + if (rte_eth_bond_slave_remove(bond_pid, slave_pid) != 0) Similar to Aman's comment in previous patch, if a bonding device is removed shouldn't the bonding PMD stop the slaves and removed them, instead of application? > + fprintf(stderr, "Failed to remove slave %u from master port = %u\n", > + slave_pid, bond_pid); > + 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); > + } > +} > +#endif > + > void > close_port(portid_t pid) > { > @@ -3161,6 +3202,14 @@ close_port(portid_t pid) > > if (is_proc_primary()) { > port_flow_flush(pi); > +#ifdef RTE_NET_BOND > + /* > + * If this port is bond device, all slaves under the > + * device need to be removed or closed. > + */ > + if (port->bond_flag == 1) > + handle_bonding_slave_device(pi); > +#endif > port_flex_item_flush(pi); > rte_eth_dev_close(pi); > } > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index ad3b4f875c..216fc41432 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -27,6 +27,7 @@ > #define RTE_PORT_STARTED (uint16_t)1 > #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.