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 3F66FA04C9; Mon, 14 Sep 2020 00:09:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D5C61BE81; Mon, 14 Sep 2020 00:08:21 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 9BD592C52 for ; Mon, 14 Sep 2020 00:08:20 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 9B2AD5E2; Sun, 13 Sep 2020 18:08:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 13 Sep 2020 18:08:19 -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=6/hE6eJbweWmL LY195w3fUApOT5EDkL5gWPO0g/wGhg=; b=AdCEWQEabDIZElFXHxPCcYbMv8fmc Nb0cKQGKSha7RDppMxjAslJlX/ULzgLBre4yl03KJ0gRefgbkQXWuXEdARgD6uJo Xxxl1TdtAh4w1ARlk/XFvUyLEsTsQG3Cd+/G8zLQUjT5aJzupikRjfS3Kg7aTr5b B/fvfUtvmxGsBvehnWW2zGPpvk5C+UVYBg8eELPpQJrjrrjgMx68Oo3y9BIyK7Se FXRbMOv8Kazawg/sAsFuQ0uc5jMNggZC2uMbfT5iZq+/ceUuaVASrLNw/vBLHoLP C+eQjwM7lTMEniGrg0J80BoOs/1xFZ5hsPJxHCIrhmQxnU6Pm1ZB8vEBg== 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=6/hE6eJbweWmLLY195w3fUApOT5EDkL5gWPO0g/wGhg=; b=K1UP6gVJ Rr7YC+fsU2ws5/HwKAqzEFSrRwGCbgWStI/Pws58fbjrt+1OY1LTJ5/Ca3aflfoi DCmtgNy6b5Y3K7hjvqi7+7Slfad6M5AFTkrrhOij4c8BAwpwdNvIv2XAG5oZlSZk TRDrJdXb7x2xFSPqvizMY3NmGf3PyQmGKh9VWTJIDqmXU4x7q1PogE79oX56XXU9 yh47dW4Wg8v3oZxkFjc4jvzZhEp3kvDdlb81ZMfVoRNVWx8i8MWRgCJ1Hr8kxhzG nmE7UEmLg3yqyGh0B/xDWA2rFMztcdJl4kWI75X34e+9oykWBN7OaTdOwmZDSqVz 30iyWGs50e9lGQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeihedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpeduvdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr 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 84C8A306468B; Sun, 13 Sep 2020 18:08:18 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Anatoly Burakov Date: Mon, 14 Sep 2020 00:07:03 +0200 Message-Id: <20200913220711.3768597-13-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 12/20] net/pcap: 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/pcap/rte_eth_pcap.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 76e704a65a..a946fa9a1a 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -734,6 +734,12 @@ eth_dev_close(struct rte_eth_dev *dev) unsigned int i; struct pmd_internals *internals = dev->data->dev_private; + if (internals == NULL) + return 0; + + PMD_LOG(INFO, "Closing pcap ethdev on NUMA socket %d", + rte_socket_id()); + /* Device wide flag, but cleanup must be performed per queue. */ if (internals->infinite_rx) { for (i = 0; i < dev->data->nb_rx_queues; i++) { @@ -748,6 +754,12 @@ eth_dev_close(struct rte_eth_dev *dev) } } + rte_free(dev->process_private); + + if (internals->phy_mac == 0) + /* not dynamically allocated, must not be freed */ + dev->data->mac_addrs = NULL; + return 0; } @@ -1322,6 +1334,7 @@ eth_from_pcaps(struct rte_vdev_device *vdev, else eth_dev->tx_pkt_burst = eth_tx_drop; + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; rte_eth_dev_probing_finish(eth_dev); return 0; } @@ -1544,30 +1557,16 @@ pmd_pcap_probe(struct rte_vdev_device *dev) static int pmd_pcap_remove(struct rte_vdev_device *dev) { - struct pmd_internals *internals = NULL; struct rte_eth_dev *eth_dev = NULL; - PMD_LOG(INFO, "Closing pcap ethdev on numa socket %d", - rte_socket_id()); - if (!dev) return -1; - /* reserve an ethdev entry */ eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (eth_dev == NULL) - return -1; - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - internals = eth_dev->data->dev_private; - if (internals != NULL && internals->phy_mac == 0) - /* not dynamically allocated, must not be freed */ - eth_dev->data->mac_addrs = NULL; - } + return 0; /* port already released */ eth_dev_close(eth_dev); - - rte_free(eth_dev->process_private); rte_eth_dev_release_port(eth_dev); return 0; -- 2.28.0