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 06718A04C0; Mon, 28 Sep 2020 01:47:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A03EE1D656; Mon, 28 Sep 2020 01:43:46 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 387CF1D60D for ; Mon, 28 Sep 2020 01:43:35 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id DEF845C00E9; Sun, 27 Sep 2020 19:43:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 27 Sep 2020 19:43:33 -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=Vxwx6YxnL4tmBgsRGlK89v4V6yW/a 3+DwTw4FG5CAg/rITA7rRojWX+NhfWza6662sAstaYulF2D/TZQRdWv1euL3GySk XebyIutyMSnjrHyMw9s9bS7slkb6ctB2X6CJroDIATZFnuFJaT+j1fmCAhlJ2ccb 7hbEkpAHmftFKneu0IQlJ66k3koSIOOhadvs9wLSStXXk8ud8I0kdbfW9ULf8AfR llykJtntmxS8MWxmvw5klZsnAEEQHwz8BTD+d2a9Tw4/xkpG+n++K8lMdw7P6OZp ec5wJNKzI4+31W5VeEmh7VaUDrNX3/QFkl+itTbhFy+44cGd9umwVqDJg== 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=vYdlwdgo ZOnUyU87ra2IkSWEO/kLTJfHePjGvS1jDZcvL6hpzX4Tg9urPjBq9TdHlS42BnuE tGgiEXSuN351YjURU37Y2EDOKQ3aBaycxzhFo2F74rDb6I+wqIjufRRTJrkPHOzw KgukI52rw/Dc6yMw8blKnrAhfQ2M2t8Nxc/BEiE+9bPVhNHPVgZ9j9U0Jxo40qEa 9Sn/m3rhAGpUutJEIaTvtu8dEds6l+rle1qpjY1/Blen0mxxzNKkbAyU1/F4s4JJ mKnZNPcezp653VQ7MooXoNqESaThTT6QBAsUtDoQUwxLjs3CkoVX+0RUm1QQFOkX Zfp2IZUMfQ4qsQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdehgddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepuddtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 310123280059; Sun, 27 Sep 2020 19:43:33 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Anatoly Burakov Date: Mon, 28 Sep 2020 01:42:36 +0200 Message-Id: <20200927234249.3198780-13-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 12/25] 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