From patchwork Mon Sep 28 23:14:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 79081 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 43FE5A04C0; Tue, 29 Sep 2020 01:19:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 28A1F1D9C0; Tue, 29 Sep 2020 01:15:48 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 2013E1D93C for ; Tue, 29 Sep 2020 01:15:26 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id AA6A15C01AA; Mon, 28 Sep 2020 19:15:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:24 -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=lOxXH3W4EmtRV 1spnp7Qho2DHh++oNFzN8M9esuA62E=; b=HRHXIkUAw8/xOMw3o+UymI8MrahaL yGBG10JsGeyFn52LknHmS4k41/IZfZgGwJhrQeQQFUg/2AUZmLPu0bGpqoXjTGNH X7GHFDAuI6G0kpBCqMjbLf+G18gCu0predOriuNIiRkTihrtjAK8x+uXjq+M/2TE AyLE2EkCMbF1YHW+wTEENXUGcJ/lMENbKZ7oeChYMP2T9f6Zu9L64Rp1X+tTXBGG rt9fn/9SPlKbA8e404Kkh8t13LNgeWv6e3Dj0arDo/U1Xhxfiw1JPQr/V4GYKyVZ HYUikBYZw0vi9kQbDPnP5tmCxqx56Qk+91aO1lcCN7RJaivH8It04gc2w== 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=lOxXH3W4EmtRV1spnp7Qho2DHh++oNFzN8M9esuA62E=; b=jC6BIIoT Z5NZKARb8f5CrHk5RHD5ekXJgKU0Q5JOvGI0v3mpnLukivkWX+2MukO8Q6qe7/ZD R5UhTo6yGzod7a/MXDqUW894RDnD1d+V5GH10RrrbKxNlyE0qzU8tURR0S8uzwWt j7TEtAWjYxQrbhWZV6h2VwRsq9wb8YjOQ0nX/m3v5gEPWQmTiM7XNKldE8DtYAlH 57a9yT/t3Q+tfbdCszzpFnxesJ3ZepRY9LKeJYTM84LJA+LL0Zb5zXXfs5VCrNpG Cb1g3WdLsDNAX2ePvdEUTer64nST9dqzxdee0dinAbNzT9LzPjfMdXKROdYr0xVQ Eu5QqelWjGwanQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudeinecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 A20583064680; Mon, 28 Sep 2020 19:15:23 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Sachin Saxena , Gagandeep Singh , Akhil Goyal Date: Tue, 29 Sep 2020 01:14:24 +0200 Message-Id: <20200928231437.414489-17-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 Subject: [dpdk-dev] [PATCH v3 16/29] net/pfe: release port upon close 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" From: Sachin Saxena With removal of old close behavior, the private port resources must be released in the .dev_close callback. Freeing of port private resources is moved from the ".remove(device)" to the ".dev_close(port)" operation Signed-off-by: Sachin Saxena --- drivers/net/pfe/pfe_ethdev.c | 42 ++++++++++++++---------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c index 187a0019ff..55f2fea4b2 100644 --- a/drivers/net/pfe/pfe_ethdev.c +++ b/drivers/net/pfe/pfe_ethdev.c @@ -385,29 +385,23 @@ pfe_eth_stop(struct rte_eth_dev *dev/*, int wake*/) dev->tx_pkt_burst = &pfe_dummy_xmit_pkts; } -static void -pfe_eth_exit(struct rte_eth_dev *dev, struct pfe *pfe) -{ - PMD_INIT_FUNC_TRACE(); - - pfe_eth_stop(dev); - /* Close the device file for link status */ - pfe_eth_close_cdev(dev->data->dev_private); - - rte_eth_dev_release_port(dev); - pfe->nb_devs--; -} - static int pfe_eth_close(struct rte_eth_dev *dev) { + PMD_INIT_FUNC_TRACE(); + if (!dev) return -1; if (!g_pfe) return -1; - pfe_eth_exit(dev, g_pfe); + pfe_eth_stop(dev); + /* Close the device file for link status */ + pfe_eth_close_cdev(dev->data->dev_private); + + munmap(g_pfe->cbus_baseaddr, g_pfe->cbus_size); + g_pfe->nb_devs--; if (g_pfe->nb_devs == 0) { pfe_hif_exit(g_pfe); @@ -852,6 +846,8 @@ pfe_eth_init(struct rte_vdev_device *vdev, struct pfe *pfe, int id) eth_dev->data->nb_rx_queues = 1; eth_dev->data->nb_tx_queues = 1; + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + /* For link status, open the PFE CDEV; Error from this function * is silently ignored; In case of error, the link status will not * be available. @@ -1144,6 +1140,7 @@ pmd_pfe_remove(struct rte_vdev_device *vdev) { const char *name; struct rte_eth_dev *eth_dev = NULL; + int ret = 0; name = rte_vdev_device_name(vdev); if (name == NULL) @@ -1155,19 +1152,12 @@ 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); - munmap(g_pfe->cbus_baseaddr, g_pfe->cbus_size); - - if (g_pfe->nb_devs == 0) { - pfe_hif_exit(g_pfe); - pfe_hif_lib_exit(g_pfe); - rte_free(g_pfe); - g_pfe = NULL; + if (eth_dev) { + pfe_eth_close(eth_dev); + ret = rte_eth_dev_release_port(eth_dev); } - return 0; + + return ret; } static