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 5DB25A04C9; Mon, 14 Sep 2020 00:09:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2011F1C0B9; Mon, 14 Sep 2020 00:08:30 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 86AA51C12A for ; Mon, 14 Sep 2020 00:08:28 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 7098E4A2; Sun, 13 Sep 2020 18:08:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 13 Sep 2020 18:08:27 -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=GKH9ZceWtvxkJ v7aVTxzAETGsGNLGvPSWHnufabDmZI=; b=jmVn0ra5ooH0wZxpC/OYuZxK2no3U 2Y7+RVyNE6v5t+QraMLDVvF8ZdI7tyOA5g5ByLvslALjEgvgxsd0+P3pna2aQFSE aP02U5THUrJpYRVwSGIq+Z2z95VR5R/YjRqUZWypnJoIaiaEBUYe2Y87Sm9blk8U 6p6eykJLZFN7g20a5ffodPlY3bvPIjBqK8Iva0626CjElJOuRzwRBgjiwaKfDLDA lzF6zps9DOvcEmL/ZFTLjVxVFPqflTxD+Y4n5UP/55aG+3qCLNOzQhqqUO6yN135 ZmZVf6FZ1RSfsoni4RvgiFf5MSln5pXD6dajY5i5HuZgqnP5MYGg9ad4A== 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=GKH9ZceWtvxkJv7aVTxzAETGsGNLGvPSWHnufabDmZI=; b=PjAZRJNl kYCkHkfi2eB0vqlOb+/Lmovzar29wuTT/KLFaOqgNYVlQtkGQhCYl3PLuKDkOt2z o8MvjklYDt86WhAzKtewgospxZQwuiut6AVGFj7lFCvWPuUVUyTuTnaF7KFv/Mt4 JxvX1UrJztBMXf8sSUi8WtVZiDZzbBNlgvOXBJSzl6tTtqxgRQHe7GblnJFf9hEV kVhP/Fd4iSVSlVtSlfPT/QRoA6e0PuWreQfqutOpcZsn8MTkCuYu8eeNsP4HK/P6 lg9WJFBKIvu4lp2kPKinWS/iiVu6XG/Z0m6JRd9MQszv0OgffnxOc64xXn9eu5C6 3VfanOwbObPc1w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeihedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedufeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth 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 36A3C3064674; Sun, 13 Sep 2020 18:08:26 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Jasvinder Singh , Cristian Dumitrescu Date: Mon, 14 Sep 2020 00:07:05 +0200 Message-Id: <20200913220711.3768597-15-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200913220711.3768597-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 14/20] net/softnic: 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" The flag RTE_ETH_DEV_CLOSE_REMOVE is set so all port resources can be freed by rte_eth_dev_close(). Freeing of private port resources is moved from the ".remove(device)" to the ".dev_close(port)" operation. Signed-off-by: Thomas Monjalon --- drivers/net/softnic/rte_eth_softnic.c | 63 ++++++++++++++------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 491a308c11..5b94e250d8 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -201,9 +201,37 @@ pmd_dev_stop(struct rte_eth_dev *dev) softnic_mtr_free(p); } +static void +pmd_free(struct pmd_internals *p) +{ + if (p == NULL) + return; + + if (p->params.conn_port) + softnic_conn_free(p->conn); + + softnic_thread_free(p); + softnic_pipeline_free(p); + softnic_table_action_profile_free(p); + softnic_port_in_action_profile_free(p); + softnic_tap_free(p); + softnic_tmgr_free(p); + softnic_link_free(p); + softnic_swq_free(p); + softnic_mempool_free(p); + + tm_hierarchy_free(p); + softnic_mtr_free(p); + + rte_free(p); +} + static int -pmd_dev_close(struct rte_eth_dev *dev __rte_unused) +pmd_dev_close(struct rte_eth_dev *dev) { + pmd_free(dev->data->dev_private); + dev->data->dev_private = NULL; /* already freed */ + dev->data->mac_addrs = NULL; /* statically allocated */ return 0; } @@ -335,31 +363,6 @@ pmd_init(struct pmd_params *params) return p; } -static void -pmd_free(struct pmd_internals *p) -{ - if (p == NULL) - return; - - if (p->params.conn_port) - softnic_conn_free(p->conn); - - softnic_thread_free(p); - softnic_pipeline_free(p); - softnic_table_action_profile_free(p); - softnic_port_in_action_profile_free(p); - softnic_tap_free(p); - softnic_tmgr_free(p); - softnic_link_free(p); - softnic_swq_free(p); - softnic_mempool_free(p); - - tm_hierarchy_free(p); - softnic_mtr_free(p); - - rte_free(p); -} - static struct rte_ether_addr eth_addr = { .addr_bytes = {0}, }; @@ -384,6 +387,7 @@ pmd_ethdev_register(struct rte_vdev_device *vdev, dev->device = &vdev->device; /* dev->data */ + dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; dev->data->dev_private = dev_private; dev->data->dev_link.link_speed = ETH_SPEED_NUM_100G; dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX; @@ -653,12 +657,9 @@ pmd_remove(struct rte_vdev_device *vdev) /* Find the ethdev entry */ dev = rte_eth_dev_allocated(rte_vdev_device_name(vdev)); if (dev == NULL) - return -ENODEV; + return 0; /* port already released */ - /* Free device data structures*/ - pmd_free(dev->data->dev_private); - dev->data->dev_private = NULL; /* already freed */ - dev->data->mac_addrs = NULL; /* statically allocated */ + pmd_dev_close(dev); rte_eth_dev_release_port(dev); return 0; -- 2.28.0