From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 5AC2A5F17 for ; Sat, 8 Sep 2018 01:39:33 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id DDC0121FF6; Fri, 7 Sep 2018 19:39:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 07 Sep 2018 19:39:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=mesmtp; bh=pm+v5w5wRijmYxSqV0Ax2v3ouiTbOyyZjNQDwh fWjKw=; b=SPWh9CjbrtrYvp+JYjOnnmn7pvWMGGA8UfzL0xu30jZHq+MyKDUxTy s3w/meYHbjdzDEM3fWbgjtKaWR9/MME8SkiNZl8JZBChHykLDgH2O5gtwAJJJjSB 5mDZFaCGuvEUTEhQCO0lyUQC5b+u88gaVArRVTHbB6kkRhkLG8oeM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=pm+v5w5wRijmYxSqV 0Ax2v3ouiTbOyyZjNQDwhfWjKw=; b=tImmoVo5zEjxznptOfj58osa9xBbkYeFA nHJ/09Mbxt1ssDYafFFUZ+YD4nrWIGB33so/5z3dIoLTn2D128V0/DiFiRksimnJ zAHifgs+4Pv9KluMwkM9Z6D2CXoTdIvuMB/4GVOeGMrLzqenyAadHtlot6MRACNJ vf9gOy4lM5lHfvHe4h820k+WPDq/TgpxZzJRqEIUQ85GuGkHG7bzDQGesvLjynl7 w7S837xCKB1rLbGUiZHP/h4FlqFmztWKWZgEMRt0tenxSmoB+eNck/xgtJ8y+jkQ w6CFZEoYcvSAEYS5rxyVq6b0W+YGvN6IpRhwxOU9rXrU/LWLo/y4g== X-ME-Proxy: X-ME-Sender: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id D2B801028D; Fri, 7 Sep 2018 19:39:31 -0400 (EDT) From: Thomas Monjalon To: ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org Date: Sat, 8 Sep 2018 01:39:29 +0200 Message-Id: <20180907233929.21950-1-thomas@monjalon.net> X-Mailer: git-send-email 2.18.0 Subject: [dpdk-dev] [RFC] ethdev: complete closing to free all resources 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: , X-List-Received-Date: Fri, 07 Sep 2018 23:39:33 -0000 After closing a port, it cannot be restarted. So there is no reason to not free all associated resources. The last step was done with rte_eth_dev_detach() which is deprecated. Instead of removing the associated rte_device, the driver should check if no more port (ethdev, cryptodev, etc) is still open for the device. Then the device resources can be freed by the driver inside the dev_close() driver callback operation. The last ethdev freeing (dev_private and final release), which were done by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close(). Signed-off-by: Thomas Monjalon --- This patch contains only the change in the close function as RFC. This idea was presented at Dublin during the "hotplug talk". --- lib/librte_ethdev/rte_ethdev.c | 5 +++++ lib/librte_ethdev/rte_ethdev.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 4c3202505..071fcbd23 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1358,6 +1358,7 @@ void rte_eth_dev_close(uint16_t port_id) { struct rte_eth_dev *dev; + struct rte_bus *bus; RTE_ETH_VALID_PORTID_OR_RET(port_id); dev = &rte_eth_devices[port_id]; @@ -1372,6 +1373,10 @@ rte_eth_dev_close(uint16_t port_id) dev->data->nb_tx_queues = 0; rte_free(dev->data->tx_queues); dev->data->tx_queues = NULL; + + rte_free(dev->data->dev_private); + + rte_eth_dev_release_port(dev); } int diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 7070e9ab4..37a757a7a 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1797,8 +1797,9 @@ int rte_eth_dev_set_link_down(uint16_t port_id); /** * Close a stopped Ethernet device. The device cannot be restarted! - * The function frees all resources except for needed by the - * closed state. To free these resources, call rte_eth_dev_detach(). + * The function frees all port resources. + * If there is no more port associated with the underlying device, + * the driver should free the device resources. * * @param port_id * The port identifier of the Ethernet device. -- 2.18.0