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 D1207A04C0; Tue, 29 Sep 2020 01:19:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5990C1D9B6; Tue, 29 Sep 2020 01:15:46 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 2C2E41D932 for ; Tue, 29 Sep 2020 01:15:23 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id C95145C01A2; Mon, 28 Sep 2020 19:15:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:22 -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=Eo4bslkX5NzUu 3fnyOHMMzVqyIfNgnZHy9xA3btFvMk=; b=stz35jTeY7CWj1G1ZjyrSECRaNbuq D7E4T92eE7IYCzOXJJE9nBDbdHB0KxePKyCH3dZQ0AnYZfZJQTw1Nv7k7JWE1h7G hl4PkhyucNsSSshvucWqijk5JB1L+5MyvteO0zqoaiQx5kyDXyWxahPpdDTBiA6k 0haWpysnscBQNswUHIcUaONz1Sv3RdikeN2CrW5IdqzvqROrdpKJYaWC1l/iUWnY WK0vaOWeCGW/s8rAxJkpeaJbTpV/5Z23Yluin/Dd/s4YOPhbcxhsHTbiZg4Z8PpZ VS38YOIRkTx9klFZ+YGVp+h7+uN3S4mgvdrhiU3ckL3RnWrPuR9In1MwA== 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=Eo4bslkX5NzUu3fnyOHMMzVqyIfNgnZHy9xA3btFvMk=; b=cgxLr7cb TeudJYDBmQkUJ3Di8JnEwMnn8jejFWZpqt+HCniNI6KZSEx7rWzbiLWdtQP6xIIj 6anc7ppFu3tUVyYDb22dp2ZqpWF9CxNXdW7YYtVQ1NAcOmjj8+j1e0iq8CLGGyej MAvt/mwZ/vjtUYau3hxuQth6xm1qMn1uhN2pU6rcxDsBCeQjo02d1w8o/2NevmMf PuqLLlwPZoclkMJnJby/wPipWIxAG9HbtfqzxPtdA6lRYLrv84H1AZ57/yddIB40 rsOuYF1HKaJAMcvCrMkyr/HVJcXrsVhzWYhkNMA6m5smxNcUa+PEQf6gIa6RTsbd 7Q9I82aXd1zYOg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudeinecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 F2E0B3064674; Mon, 28 Sep 2020 19:15:21 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Anatoly Burakov Date: Tue, 29 Sep 2020 01:14:23 +0200 Message-Id: <20200928231437.414489-16-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 15/29] 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..909eef8cce 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -734,6 +734,14 @@ eth_dev_close(struct rte_eth_dev *dev) unsigned int i; struct pmd_internals *internals = dev->data->dev_private; + PMD_LOG(INFO, "Closing pcap ethdev on NUMA socket %d", + rte_socket_id()); + + rte_free(dev->process_private); + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + /* 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 +756,10 @@ eth_dev_close(struct rte_eth_dev *dev) } } + 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