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 BB16BA04C0; Tue, 29 Sep 2020 01:21:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3AD7E1DA22; Tue, 29 Sep 2020 01:16:03 +0200 (CEST) Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by dpdk.org (Postfix) with ESMTP id 392B71D9B1 for ; Tue, 29 Sep 2020 01:15:45 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id D392D580797; Mon, 28 Sep 2020 19:15:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=a8hak6VZN6Dbc xczrWJS4TEBGNENTku00jyyUiGK4Bs=; b=ZL7va1n1PX2iAMiMPKIpCM3RbMN0B f8Phzbii0VoVX5grz6t5rjElpAfrhGBoXbNTNgiFIMw/e3SGoKRiM5jcE3GObPow KiNPUPkoliiMikUkxE3n88IpQu3sD8BOIGSsXNZeN1jKKIXtdJFwvduU+J6fAx3A oXzK5XRKGuwhnP2eVI0RcrStwbWWu3Fp4aFhVDRmU/EE0fbM8MNxRMpE95HndZ/Q eLBXIiW8TaaiH+jhTQINGIgJeWfEpCAsULMcjArhF9eAb9vezmDzSLuhp3Ri70z7 N/WuZnaElovuJhFAdObizAw8esacbo2MpZy/GXL4a56Ww50e3QVVEzFdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=a8hak6VZN6DbcxczrWJS4TEBGNENTku00jyyUiGK4Bs=; b=q/wsdEOo o3Jr/vvYtj3p3YM0ZgZLdrHl+94bHmnQxdQwQxl72oVu1PilhKaxP/maNYCl6gNl fXZQ+hgHXJv01ZIZl4NOgKtnNJ92EuElEOav0uVpbc2TL9XtMW0D5zaK3ZpbpIL0 ArDq2wY6acmgddHi7W8mLY5lcZC79SmBATt9dwIIvquRpaAGAD2ptHvsWSYs8ipZ s1c8eIUurwLSWs/gy6xYfcBf2errursMOAnzwo5c14J5OesYOdkZDRW+82plIkcv hByDBck25aLejfCmtcEPHA+SDJ5QBbUTvRUoIBTAjo+xAKxhtjtba8I6cQbYCW8Q ovsywRIc5Rt3HQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepvddvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 39F6F3064685; Mon, 28 Sep 2020 19:15:42 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Rosen Xu , Sachin Saxena , Stephen Hemminger , "K. Y. Srinivasan" , Haiyang Zhang , Long Li , Heinrich Kuhn , Martin Spinler , Anatoly Burakov Date: Tue, 29 Sep 2020 01:14:30 +0200 Message-Id: <20200928231437.414489-23-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928231437.414489-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> <20200928231437.414489-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 22/29] 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" 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 Reviewed-by: Sachin Saxena --- 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/szedata2/rte_eth_szedata2.c | 6 ++---- 5 files changed, 14 insertions(+), 18 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/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) { -- 2.28.0