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 207D2A04C0; Mon, 28 Sep 2020 01:48:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 111021D66A; Mon, 28 Sep 2020 01:43:51 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 465351D644 for ; Mon, 28 Sep 2020 01:43:40 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id EC2845C00DA; Sun, 27 Sep 2020 19:43:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 27 Sep 2020 19:43:38 -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=nKi7QTsskAs98 zlw8lpQy/3YbHDzla22fCmG1AkJnhE=; b=kBFRoDfKqNDvcfoiQXzxH9xzNYY5Y G1QScl4N4T01AtDKF6S59JkAHQpr0pn5k3YouT4+/d8r8XgOv1x0DqZLyEIYsm4x 4X11XlNmcStRHZDoDWfWw//ua4VcxafHayNcVlMbMtpfLuk52UAubit5YtJcTGgC R8HMEYJHqSEfVfdc85WQomQovD3WwzNY52rGvm23vD4D3YhdlLsKDSJkDCmjMwB6 VUoUGEe4u1cpH5xRgFnI8mxRw7kMWl9NdEvo31HFThZY71IocVMYdg1F6QxoeLa5 R7imzMJi07FIvxhBrqISWvOffYxrQlXQXO4vCNWjc5uoSUT0qwKPJFl9A== 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=nKi7QTsskAs98zlw8lpQy/3YbHDzla22fCmG1AkJnhE=; b=aYAy2Y66 xynDmzhRqgPDCgewWrmVROv9iDDvyTZj1/JzRzpnCxuArvo0R7qBCavJS7QhBe19 7hPvKuqZGN8IRaRmJ2VQmEhjIPRtc3/hI/dwtPv0rvvd5l0B2iWJHAVa/bfU1+IS asmeI7jSg+fC/kqAXF9P9KthhIJDSKmpCP98kT8KAzD+dj9NM2Gy6MWQ8glougP2 8/ZUc7/Gc1n5nhYt5GlgLQUVBNdcnNTeDzcQ6gLYbP9RJScbBo+Vf1Ir1X8Ddgm5 wtZpjOEJko14QyK0osbL/o5iClH6LArPyuKNzwYo5Q8rwoXxC0galwvBxV2Dd3A3 ILJqk1gcMvlhWA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdehgddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 0ED483280059; Sun, 27 Sep 2020 19:43:37 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Cristian Dumitrescu , Jasvinder Singh , Anatoly Burakov Date: Mon, 28 Sep 2020 01:42:39 +0200 Message-Id: <20200927234249.3198780-16-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927234249.3198780-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> <20200927234249.3198780-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 15/25] 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. Nothing is closed in a secondary process. Signed-off-by: Thomas Monjalon Acked-by: Cristian Dumitrescu --- drivers/net/softnic/rte_eth_softnic.c | 66 ++++++++++++++------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index 038abd98da..ad9e2aa86d 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -201,9 +201,40 @@ 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) { + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + pmd_free(dev->data->dev_private); + dev->data->dev_private = NULL; /* already freed */ + dev->data->mac_addrs = NULL; /* statically allocated */ return 0; } @@ -335,31 +366,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 +390,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; @@ -652,12 +659,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