From patchwork Sun Sep 27 23:42:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 78928 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 85684A04C0; Mon, 28 Sep 2020 01:44:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CE62F1D610; Mon, 28 Sep 2020 01:43:22 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 9B8E01D5FB for ; Mon, 28 Sep 2020 01:43:19 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 43C4A5C00E4; Sun, 27 Sep 2020 19:43:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 27 Sep 2020 19:43:18 -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=VkL5G8jtSU7cW YFxEIPD+xVCsZkpaSVIP/d3tULckQQ=; b=pvNb6FeYOQjz664Xk0gxQ1us7rcST 9z5ZGuJUN0UFLmgict3xxV912ulesOjbH3Hh+jt2fwN8kB/XOgjQMBG0lowrqvrG l0eTdTzxVcpq6eixmbjQrS8AURj0oYSLZeonyWOmfmySwj0kpf6i+woMTlX865WW BjsB7EcybmyTAxkq9qAtTM0ESNKI3a1s30OLoBdPq+DFQsg6TYDZ3BGlzOwSsTmr i2V7WIkuvvm0rRzRLY2HRkg/R8jJGaCYpBmhfDR4zGK3SVOOrBh94A9Ze1J8bYzA tmfqnb/ouNxK+B6blxf1IU27Ajt7ySTwv6MdA+3cc0qWkkFoS89/TL7sg== 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=VkL5G8jtSU7cWYFxEIPD+xVCsZkpaSVIP/d3tULckQQ=; b=qEYHvD31 IjKT7/A5mXCyxqoXM/7mE85PFFHi9nq1NHDUHI7+poVQUi+beSsCZ5KWxxTU744O rLnJjXgzBHzVRLoAP4A8U0pCnnVR3aNEixxSLj1fNNO5GO2RhG8txQ6dTOSAAADP Td4KzXT9Md2LDUgb8SEN2H1Sr6ba6Bfa9JiSWHWzFdhBDqAaVMBs3MJDVtHznW4+ U8YVuQi8XlHLIvmYgv6uVLhRY6Q/wW1a4H7n2kwZ+QhAUg1P2pRsTogdKOLGGG95 jXW+AftyVo3w1wVnVlj1tUsWr4ZLdnyv7E6NMlXkjhPMxmdbLKiSWTP0vtdtP162 UrkIMbf2JeE6HQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdehgddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth 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 5D0453280059; Sun, 27 Sep 2020 19:43:17 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, "John W. Linville" , Anatoly Burakov Date: Mon, 28 Sep 2020 01:42:27 +0200 Message-Id: <20200927234249.3198780-4-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 Subject: [dpdk-dev] [PATCH v2 03/25] net/af_packet: 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 Reviewed-by: Ferruh Yigit --- drivers/net/af_packet/rte_eth_af_packet.c | 56 ++++++++++++----------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 7d0ff1cbb3..12c202cba4 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -377,8 +377,32 @@ eth_stats_reset(struct rte_eth_dev *dev) } static int -eth_dev_close(struct rte_eth_dev *dev __rte_unused) +eth_dev_close(struct rte_eth_dev *dev) { + struct pmd_internals *internals; + struct tpacket_req *req; + unsigned int q; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + PMD_LOG(INFO, "Closing AF_PACKET ethdev on NUMA socket %u", + rte_socket_id()); + + internals = dev->data->dev_private; + req = &internals->req; + for (q = 0; q < internals->nb_queues; q++) { + munmap(internals->rx_queue[q].map, + 2 * req->tp_block_size * req->tp_block_nr); + rte_free(internals->rx_queue[q].rd); + rte_free(internals->tx_queue[q].rd); + } + free(internals->if_name); + rte_free(internals->rx_queue); + rte_free(internals->tx_queue); + + /* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs = NULL; return 0; } @@ -835,6 +859,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, data->nb_tx_queues = (uint16_t)nb_queues; data->dev_link = pmd_link; data->mac_addrs = &(*internals)->eth_addr; + data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; (*eth_dev)->dev_ops = &ops; @@ -1033,13 +1058,7 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev) static int rte_pmd_af_packet_remove(struct rte_vdev_device *dev) { - struct rte_eth_dev *eth_dev = NULL; - struct pmd_internals *internals; - struct tpacket_req *req; - unsigned q; - - PMD_LOG(INFO, "Closing AF_PACKET ethdev on numa socket %u", - rte_socket_id()); + struct rte_eth_dev *eth_dev; if (dev == NULL) return -1; @@ -1047,26 +1066,9 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev) /* find the ethdev entry */ eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (eth_dev == NULL) - return -1; - - /* mac_addrs must not be freed alone because part of dev_private */ - eth_dev->data->mac_addrs = NULL; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return rte_eth_dev_release_port(eth_dev); - - internals = eth_dev->data->dev_private; - req = &internals->req; - for (q = 0; q < internals->nb_queues; q++) { - munmap(internals->rx_queue[q].map, - 2 * req->tp_block_size * req->tp_block_nr); - rte_free(internals->rx_queue[q].rd); - rte_free(internals->tx_queue[q].rd); - } - free(internals->if_name); - rte_free(internals->rx_queue); - rte_free(internals->tx_queue); + return 0; /* port already released */ + eth_dev_close(eth_dev); rte_eth_dev_release_port(eth_dev); return 0;