From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9F632A04AF; Mon, 28 Sep 2020 11:54:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 837DE1D68E; Mon, 28 Sep 2020 11:54:57 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10058.outbound.protection.outlook.com [40.107.1.58]) by dpdk.org (Postfix) with ESMTP id B71AB1D684 for ; Mon, 28 Sep 2020 11:54:56 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DbmOhFCY9oghhsdvqCqV51W2QSsgXo2Crp1qI5bhrX29/L8X4ef8gSMFXPpwEhcR+Ur05phu+h5NKmk6WJEfaW4rYcaEcFKwq//awjlEimWTu8rijoFk1/8PlZKUm+SoVWLDOjMvY8c7ovJyRIRNiGH9BywPPmkqH8Qxml9sLgKBINUFf7tFXD3L1D1fNLe7gWDbZWYtkuiMpyAwbYM1m+pUwM9/QCLXktMj6a6SzQQBWnY4ktBOLZ65abehmeKvCaVItnhX4JHIC2ZLz15mxu1FJfMKLzA6kvIhXH4oqBdTGwNtheHy42nRQnH5iqq0HsodckLHqVZcSplGRnKyyg== 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-SenderADCheck; bh=HJNH+Rb0zdTdY+xBg+IhkfpR2iRryxuABrGvNDkb9yg=; b=OcqEB4RostPVtzppBbus4bOm3XnZ6d7vo2YUG3jxjzYBdk0AaTyh7m9OkZMlv+cKlEz3WQh2y0zYjJ6CaCQw1CYuG7nFlpW+rZaZTO/BUnrreTJimTIemZYFVYP31hEP7+qTJB0iX0eCSui6aoTtWAno4ICDzfnxTjmQmb/qYXUiW5cl+K63g3PfEnEbN76gespsxJA9tEEpTPNIYmIY3HbWEXwWDaxUMtkcvAcfYVFX0uMppLGpjS+ElwJju/q+gWf6KgPShE1NczTSowu6jteSOX9RqT0LXU0UKg5/jwiuX9C1B7Q5XLyjRqpkpKQv4KzB+yHk1LHxWVDlyT6VSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HJNH+Rb0zdTdY+xBg+IhkfpR2iRryxuABrGvNDkb9yg=; b=jTIrUqbcmIqv7KPnlsh2s1p0ElMsX64i/24C2hfxRT86RUZUUE/qrYdPJo+gO1HD/yEqqOBZm02/drzR9L523ZpQ1m72aFtEvGH1UdHcgH/JrTGv7fgswUy/1SKi+VJQhHc20eRuZTmeo7dtlBVtNvPfW4VdNmYGnT83iSov1kY= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5837.eurprd04.prod.outlook.com (2603:10a6:803:ec::28) by VI1PR04MB5664.eurprd04.prod.outlook.com (2603:10a6:803:e0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Mon, 28 Sep 2020 09:54:54 +0000 Received: from VI1PR04MB5837.eurprd04.prod.outlook.com ([fe80::cc01:9fe2:2544:8a4b]) by VI1PR04MB5837.eurprd04.prod.outlook.com ([fe80::cc01:9fe2:2544:8a4b%7]) with mapi id 15.20.3391.030; Mon, 28 Sep 2020 09:54:54 +0000 To: Thomas Monjalon , dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Rosen Xu , Stephen Hemminger , "K. Y. Srinivasan" , Haiyang Zhang , Long Li , Heinrich Kuhn , Gagandeep Singh , Akhil Goyal , Martin Spinler , Anatoly Burakov References: <20200913220711.3768597-1-thomas@monjalon.net> <20200927234249.3198780-1-thomas@monjalon.net> <20200927234249.3198780-19-thomas@monjalon.net> From: "Sachin Saxena (OSS)" Message-ID: <643da810-3c6a-0c16-b00f-7d641f05ee73@oss.nxp.com> Date: Mon, 28 Sep 2020 15:24:43 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 In-Reply-To: <20200927234249.3198780-19-thomas@monjalon.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-ClientProxiedBy: SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) To VI1PR04MB5837.eurprd04.prod.outlook.com (2603:10a6:803:ec::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.3] (27.57.93.125) by SG2PR03CA0168.apcprd03.prod.outlook.com (2603:1096:4:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.16 via Frontend Transport; Mon, 28 Sep 2020 09:54:49 +0000 X-Originating-IP: [27.57.93.125] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c3592a7e-fb66-4fa8-dc4c-08d863948ce8 X-MS-TrafficTypeDiagnostic: VI1PR04MB5664: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:59; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bqYuO+wkg8Dk/tk5P81kxQeC4tHJ6srJPZri6xVtGqYq791k6Tv1S3LEPthOZ/ZXf8TDRJgaZR/1nR9V8czb/V59lkhP51DJQ2psBV+BIlsIXlHGkY/4tQqjYyEsv+13VJMPicorWGt24B+lbKVo0kzQS51IuI9dKBqjcsQr8+Fn97WSay//8P9Rlei2LKgePnih6TKOPmc63mDen2GEFeJB4ixXyN9HfnmxmzKekNNWJ2BNDTOfzZ8ADswrruWCR43ov49nIxthwDGQTDMDVc+r1Y06o/SOeSXp8OLZ2xSbsbOpQ1q1kLHUG7xfwfOybBFxrc0YFmY+Fo6SNKE5Rb8Q/mJY9k2/MSlX9Ed0Xqb1DSN2xi48mWv3UzjC0QFbgXZPu6M44n5AwR4RGFE2RyXQJFf9BLRIlOklyBu8d3A= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5837.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(366004)(396003)(136003)(31686004)(2906002)(186003)(16576012)(6666004)(316002)(54906003)(1006002)(31696002)(4326008)(16526019)(8936002)(2616005)(53546011)(956004)(8676002)(52116002)(6486002)(7416002)(5660300002)(26005)(86362001)(83380400001)(66556008)(66946007)(66476007)(478600001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: l8SXk2Bh6kCtXiuAbcrNEGAayYui6i2tvq7QqwYUwrKQPTFV76bmKiqIvS0Mz/KXV/DOLmQec2roVg1oO11t8n2haE9t5YM8mPaqM1q+cc24vt79hRMzOq3p1QDpvMFengfddK2f/J4XdrEX5tOZfsdzr02TxadEGDa36uMLO2Mmq4FJwoS7rOwnHIPVC4z68Zcoz/Lp7TJuyFLyQBakIHiD3N0aFzmoUeOXf4wy5O3lkank9jk3AqqN/RU+MNV9lPTAIsvNgxM0QPnrlhEYtGLOYmTa2Zre99BgwWu2gdNNKPlscOo4CdcM/tZ1/Lsv8nRSoDfJj0m/u7mHb5SZ8XPoS5aYxX807M8eb0sUWA5HeWVj8NpmnfX1FO8tLSaYaISNtw2053mQkGj/roWVAr6a/4aZg2vWBRgp17KZmjR/8sFbQC/2uzx7R5J5EL8guwC7vHfmZOSjguIV8rOpzTg77HkhoLv9whRlblIsyH/pfs1AJf1Ba16VxeWpBLq7Y5KlG8Zb6pkUEbkcEASrpBcZ/mZ4BuNV3QJhnVs+4eB02dInmKwvGweZlZZnJ/HnT5K1McBOVyGMlVACbJPXAZPjxdNdUrAXnjLi9OOvaRc+XW5DbupAQ3CkKHhMIvHc93w1h/4UtOy88TZSaxYENA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3592a7e-fb66-4fa8-dc4c-08d863948ce8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5837.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2020 09:54:54.5044 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: d8o55rIQUlzHPitfzaMM6DMeSxrJqQ3Z4t6nTDxK5R2VABOyBBwd1sxO4n0rpshDkyfWh+fyIu7ALQ1b0iY7TQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5664 Subject: Re: [dpdk-dev] [PATCH v2 18/25] drivers/net: accept removing device without any port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" For "net/pfe" Reviewed-by: Sachin Saxena On 28-Sep-20 5:12 AM, Thomas Monjalon wrote: > The ports can be closed (i.e. completely released) > before removing the whole device. > Such case was wrongly considered an error by some drivers. > > If the device supports only one port, there is nothing much > to free after the port is closed. > > Signed-off-by: Thomas Monjalon > Reviewed-by: Ferruh Yigit > Reviewed-by: Rosen Xu > --- > drivers/net/ipn3ke/ipn3ke_ethdev.c | 6 ++---- > drivers/net/kni/rte_eth_kni.c | 16 +++++++--------- > drivers/net/netvsc/hn_ethdev.c | 2 +- > drivers/net/nfp/nfp_net.c | 2 ++ > drivers/net/pfe/pfe_ethdev.c | 6 ++---- > drivers/net/szedata2/rte_eth_szedata2.c | 6 ++---- > 6 files changed, 16 insertions(+), 22 deletions(-) > > diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c > index 027be29bd8..4446d2af9e 100644 > --- a/drivers/net/ipn3ke/ipn3ke_ethdev.c > +++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c > @@ -562,10 +562,8 @@ static int ipn3ke_vswitch_remove(struct rte_afu_device *afu_dev) > afu_dev->device.name, i); > > ethdev = rte_eth_dev_allocated(afu_dev->device.name); > - if (!ethdev) > - return -ENODEV; > - > - rte_eth_dev_destroy(ethdev, ipn3ke_rpst_uninit); > + if (ethdev != NULL) > + rte_eth_dev_destroy(ethdev, ipn3ke_rpst_uninit); > } > > ret = rte_eth_switch_domain_free(hw->switch_domain_id); > diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c > index 45ab1b17a8..2a4058f7b0 100644 > --- a/drivers/net/kni/rte_eth_kni.c > +++ b/drivers/net/kni/rte_eth_kni.c > @@ -488,17 +488,15 @@ eth_kni_remove(struct rte_vdev_device *vdev) > > /* find the ethdev entry */ > eth_dev = rte_eth_dev_allocated(name); > - if (eth_dev == NULL) > - return -1; > - > - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { > - eth_kni_dev_stop(eth_dev); > - return rte_eth_dev_release_port(eth_dev); > + if (eth_dev != NULL) { > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { > + eth_kni_dev_stop(eth_dev); > + return rte_eth_dev_release_port(eth_dev); > + } > + eth_kni_close(eth_dev); > + rte_eth_dev_release_port(eth_dev); > } > > - eth_kni_close(eth_dev); > - rte_eth_dev_release_port(eth_dev); > - > is_kni_initialized--; > if (is_kni_initialized == 0) > rte_kni_close(); > diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c > index 15d6e9762d..19a9eb6bc2 100644 > --- a/drivers/net/netvsc/hn_ethdev.c > +++ b/drivers/net/netvsc/hn_ethdev.c > @@ -1092,7 +1092,7 @@ static int eth_hn_remove(struct rte_vmbus_device *dev) > > eth_dev = rte_eth_dev_allocated(dev->device.name); > if (!eth_dev) > - return -ENODEV; > + return 0; /* port already released */ > > ret = eth_hn_dev_uninit(eth_dev); > if (ret) > diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c > index 9509dc8bd6..ce25cf1ed4 100644 > --- a/drivers/net/nfp/nfp_net.c > +++ b/drivers/net/nfp/nfp_net.c > @@ -3739,6 +3739,8 @@ static int eth_nfp_pci_remove(struct rte_pci_device *pci_dev) > int port = 0; > > eth_dev = rte_eth_dev_allocated(pci_dev->device.name); > + if (eth_dev == NULL) > + return 0; /* port already released */ > if ((pci_dev->id.device_id == PCI_DEVICE_ID_NFP4000_PF_NIC) || > (pci_dev->id.device_id == PCI_DEVICE_ID_NFP6000_PF_NIC)) { > port = get_pf_port_number(eth_dev->data->name); > diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c > index 187a0019ff..9d5415d9b1 100644 > --- a/drivers/net/pfe/pfe_ethdev.c > +++ b/drivers/net/pfe/pfe_ethdev.c > @@ -1155,10 +1155,8 @@ pmd_pfe_remove(struct rte_vdev_device *vdev) > return 0; > > eth_dev = rte_eth_dev_allocated(name); > - if (eth_dev == NULL) > - return -ENODEV; > - > - pfe_eth_exit(eth_dev, g_pfe); > + if (eth_dev != NULL) > + pfe_eth_exit(eth_dev, g_pfe); > munmap(g_pfe->cbus_baseaddr, g_pfe->cbus_size); > > if (g_pfe->nb_devs == 0) { > diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c > index 4325b9a30d..5f589dfa4c 100644 > --- a/drivers/net/szedata2/rte_eth_szedata2.c > +++ b/drivers/net/szedata2/rte_eth_szedata2.c > @@ -1910,10 +1910,8 @@ static int szedata2_eth_pci_remove(struct rte_pci_device *pci_dev) > pci_dev->device.name, i); > PMD_DRV_LOG(DEBUG, "Removing eth_dev %s", name); > eth_dev = rte_eth_dev_allocated(name); > - if (!eth_dev) { > - PMD_DRV_LOG(ERR, "eth_dev %s not found", name); > - retval = retval ? retval : -ENODEV; > - } > + if (eth_dev == NULL) > + continue; /* port already released */ > > ret = rte_szedata2_eth_dev_uninit(eth_dev); > if (ret != 0) {