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 8BBE9A04C0; Tue, 29 Sep 2020 01:20:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A4F7E1DA03; Tue, 29 Sep 2020 01:15:57 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 39C4C1D717 for ; Tue, 29 Sep 2020 01:15:31 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id D3BAC5C00E5; Mon, 28 Sep 2020 19:15:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:29 -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=U35ZERtIYckLYJluCKmWVgjX0XHJ5 R5Zxyn5+lJtAttX85y//BxKsnrxVeZdT/HaVo6k4KA5Gad3POhk2loYoLTnlJXok 5RiYfD79x+ze7aw9w/k+4Dw24WuUX95Yae9CxYVITaLbEZxIQSR5EgwF/V/4qUCH mlb9D9PJVO+OXdvFtLxH5cXc3vv9gP5ZEEM5c8LXlJVeaAwy7LxzVwwgvEq5Iw1+ jR2MRInXkR2BAgWT2HG09D+7pCvH6zyjex2R13on30I5pOSn0r1Mr/Slw7eiYwZH 8c44H7oo7StaJ0RE6NrJmu+lcN9dFAdXCz3pXr6z+wBHVyNIZkcyqsvrg== 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=CA1wHMz/ I4H9nO2BSPiYMPZD53RDrIiW6OqGrNNsYB8VZCRUvJMdWPhyVeHiJkft5zXkW/5a yrL2tOZcyDiJJNRZVUC/61pYalWco+HW00iTOjHXaoMi+kpgtqz7rPB9+oqz0zoC wcu/UgvSqKPc1QogPeaC8VPmd6AKW2QSLy7Bpo4G2NJm5FRMy8g0O35cjiq0Mbv3 DmHLDM+zKuAmvNjwcSf46KNt7F0m0xzMaLn0ZKGVR33a/lWbMzsR/DjTr57rNVon RXbPJaU0CgFIMKdiL8at2G8UnvwRL0GrE24UYAmTFtinvicEOr87A8UArCLwT0W7 ODGuS02PnyZmTw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudelnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 C882C3064684; Mon, 28 Sep 2020 19:15:28 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Cristian Dumitrescu , Jasvinder Singh , Anatoly Burakov Date: Tue, 29 Sep 2020 01:14:27 +0200 Message-Id: <20200928231437.414489-20-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928231437.414489-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> <20200928231437.414489-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 19/29] 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