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 A4350239 for ; Mon, 15 Oct 2018 01:20:36 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 49856217DD; Sun, 14 Oct 2018 19:20:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 19:20:36 -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=qQWwZHk466 KaP2KW0MkaMO89Z+H71tx7XDV8n7AxEC4=; b=FEKhR7Abu1IpmP2HJJFeHNtvII LUQOsXR6Q2rKSNl1heia8P4Iy6qMuksgWVu3+ZGHoyT/rFKhidwGrgCikcoEqKHx OzAc31jSzvEQV8Xma4QfyNaca4ziz9kx3H5ikEcMySIf3Kxc7pbShB69CC9HCye4 vUoEbVhkqFiHk6Ujo= 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=qQWwZHk466KaP2KW0MkaMO89Z+H71tx7XDV8n7AxEC4=; b=eop2E3v5 lJ0GMMlu/2JR0YYKU7lfK4KvQXsFTcQnjhlUOtt59y/mCOXbgEwiFQ6WBFQnolAs FUTmISQkA2cQfeElcCk3AWnjibMGziu3gThmLttfu1ISx1nA3kIUp05iEyV1McrQ QA3eqKMe/jjyM1bccDve+AjaecFbYRB9gMVoBBd0P1KbV5EUOJT7bsJd0XBP1iw9 CL6o5N45+2TnfQVzq9XTW919W2bER4IHGf4BVxsVCSs7akBFEBV4BslGijwALJ6g wrseBe/Pp8oDLpb+zSHOGxRlUfixoZ2dx8ciZUXN5cQ6oNq3Wj1ZwJUsZuNjjU4N n7liWCLOoazNfw== 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 64C6DE455C; Sun, 14 Oct 2018 19:20:35 -0400 (EDT) From: Thomas Monjalon To: ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, ophirmu@mellanox.com Date: Mon, 15 Oct 2018 01:20:20 +0200 Message-Id: <20181014232020.12114-3-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014232020.12114-1-thomas@monjalon.net> References: <20180907233929.21950-1-thomas@monjalon.net> <20181014232020.12114-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 2/2] 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: Sun, 14 Oct 2018 23:20:37 -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 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 --- drivers/net/bnxt/bnxt_ethdev.c | 4 ---- drivers/net/vhost/rte_eth_vhost.c | 4 ---- lib/librte_ethdev/rte_ethdev.c | 9 +++------ lib/librte_ethdev/rte_ethdev.h | 3 +-- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index ff41cb0fa..183b40821 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -712,10 +712,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) if (bp->dev_stopped == 0) bnxt_dev_stop_op(eth_dev); - if (eth_dev->data->mac_addrs != NULL) { - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - } if (bp->grp_info != NULL) { rte_free(bp->grp_info); bp->grp_info = NULL; diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 986bf9633..b9cefbbe5 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -998,12 +998,8 @@ eth_dev_close(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_tx_queues; i++) rte_free(dev->data->tx_queues[i]); - rte_free(dev->data->mac_addrs); free(internal->dev_name); free(internal->iface_name); - rte_free(internal); - - dev->data->dev_private = NULL; } static int diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 178800a5b..987ba5ab1 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -367,6 +367,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(); @@ -1384,12 +1386,7 @@ rte_eth_dev_close(uint16_t port_id) dev->data->dev_started = 0; (*dev->dev_ops->dev_close)(dev); - dev->data->nb_rx_queues = 0; - rte_free(dev->data->rx_queues); - dev->data->rx_queues = NULL; - dev->data->nb_tx_queues = 0; - rte_free(dev->data->tx_queues); - dev->data->tx_queues = NULL; + rte_eth_dev_release_port(dev); } int diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index fb40c89e0..dcdeb184b 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1802,8 +1802,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. To free these resources, call rte_eth_dev_detach(). + * The function frees all port resources. * * @param port_id * The port identifier of the Ethernet device. -- 2.19.0