From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 893C61B4D1 for ; Wed, 10 Oct 2018 00:17:42 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BD96020365; Tue, 9 Oct 2018 18:17:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 09 Oct 2018 18:17:41 -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=mesmtp; bh=OVxrJtur5N RTqu46RqzfIDYOvSpngHxuX68N+PZ8VYY=; b=hyp/1nCaRPWAlduDNyBh+gYlW2 I4pICaX8ADa4R1+6+GSdMmopULITUUUGurYBXNmbgl51njUtoRuPlE14h/1YErzK /ZtwnjnlaZQFwTwJahaFhW6jGPscoTRwU8S2GScw6vi+Oc20ZM/s70Ay7i+soUOH rYSvGqJmcn8ahrSqo= 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= fm1; bh=OVxrJtur5NRTqu46RqzfIDYOvSpngHxuX68N+PZ8VYY=; b=woFyU0hR S1odXt+vZt/F2yNWSW7nP4uKyeDCkVgihjfpUgw7m70/3vhjzUAJvevt/fqs70KC c0ru6ebF6DA2RgJm6yYDN+Vr95z4KsWEN85CVUxxpSyIRHs/igkuMIO/g63lT+ke TnNlaqYAckr3hOr3gwIyQp3gpNTaghn/Xmc0Y+hxSxi+5onIdpDAZs2Te41EZLXx mO0M6j8adw/LYclj2H+mkDiQRIK9iSyOuO0eY0UprEWpGye+BD+byt5paQ2UFXvn ZqtYeMmvJlCo33TDY8btemTUhsklaCqdvsEnSxccGI9aqNKbvW0wXJir48hJbo7L hXtkFhcqvk2DwQ== X-ME-Sender: 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 66A60102A0; Tue, 9 Oct 2018 18:17:40 -0400 (EDT) From: Thomas Monjalon To: ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, ophirmu@mellanox.com Date: Wed, 10 Oct 2018 00:17:32 +0200 Message-Id: <20181009221732.17377-1-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180907233929.21950-1-thomas@monjalon.net> References: <20180907233929.21950-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] ethdev: complete closing of 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: , X-List-Received-Date: Tue, 09 Oct 2018 22:17:42 -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 blindly removing the associated rte_device, the driver should check if no more port (ethdev, cryptodev, etc) is open for the device. 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(). If the driver is trying to free the port again, the function rte_eth_dev_release_port() will abort with -ENODEV error. Signed-off-by: Thomas Monjalon --- lib/librte_ethdev/rte_ethdev.c | 6 ++++++ lib/librte_ethdev/rte_ethdev.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index ed83e5954..3062dc711 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) { if (eth_dev == NULL) return -EINVAL; + if (eth_dev->state == RTE_ETH_DEV_UNUSED) + return -ENODEV; rte_eth_dev_shared_data_prepare(); @@ -1441,6 +1443,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 a8942ff88..378c01afa 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1846,8 +1846,7 @@ 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. + * The function frees all port resources. * * @param port_id * The port identifier of the Ethernet device. -- 2.19.0