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 9BBB0A04C9; Mon, 14 Sep 2020 00:09:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CE52B1C08C; Mon, 14 Sep 2020 00:08:26 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id B3A861C08C for ; Mon, 14 Sep 2020 00:08:25 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id B5A1E5D6; Sun, 13 Sep 2020 18:08:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 13 Sep 2020 18:08:25 -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=MjRVH+zMO1fmr iDmMbsnNw7aKalKLCg8sQuqg30b0+w=; b=C3lwpIOaPEepH1AKuhFQHVlrmre89 V78ROjXOT/P1qi5J7aA8wQwTAsWKLZlxSGmvMcquxqnR+f2hwZR8P/uHzS/rWa7Y IgMyGOrQ+rYGoYsu+SXa/nxEfnB2yog4rX9DGV7FiFywRz4SaN+hKHa8sYL0+MPh JebJOJWyddeqgDO/1aMu1Sw3wURD83QioqOx8JpFyjHmuIRqUaYi/sMhMbsKzXb5 u5sb5n4N98FdNYLKgAIbSIljc7czxFmQGTDNynqV708E8qCtUfuBArXBLHY49K1f 0QGVtf9FmQOU/cRqjrKY1gEWnlqODMLpwSpNiwMm3T8VahUyIC5iH0ZLg== 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=MjRVH+zMO1fmriDmMbsnNw7aKalKLCg8sQuqg30b0+w=; b=AEnsCtd1 6JlThXXc/rEco7wDA0LyiImfeA0OBVLI520tBKzjLi7myJbIpKi5EhYzhL7+41HM Ypk8420AEh289PgNfklCbwVc5Zvz0ls90dX/B/Sa1oTv/ZbStqACPkju+tzvOZkd qbyLAd3NXIcX1pxMGRRAHBIWbMXwO/G4stmOtf/6O67UdxFzLNXXoojfGtqA/Ja5 CN48AGSoTcurdF4rEyyhadMeiiC9ZXSmcyzRxRPfyoWqt9NXVcoXKF/TctrgLpOF 1jLTAoCTr2mLo8iVjIVsaM/ouwOKd54X2mj5RL6cc88ywFJcE9ceQh3uyk5BS2hr 4UsFxA16Vz8ZIg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeihedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedufeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr 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 92FFB3064674; Sun, 13 Sep 2020 18:08:23 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Bruce Richardson Date: Mon, 14 Sep 2020 00:07:04 +0200 Message-Id: <20200913220711.3768597-14-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 13/20] net/ring: 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/ring/rte_eth_ring.c | 51 ++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 733c898259..afe3ec46cc 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -226,7 +226,35 @@ static int eth_link_update(struct rte_eth_dev *dev __rte_unused, int wait_to_complete __rte_unused) { return 0; } +static int +eth_dev_close(struct rte_eth_dev *dev) +{ + struct pmd_internals *internals = NULL; + struct ring_queue *r = NULL; + uint16_t i; + + eth_dev_stop(dev); + + internals = dev->data->dev_private; + if (internals->action == DEV_CREATE) { + /* + * it is only necessary to delete the rings in rx_queues because + * they are the same used in tx_queues + */ + for (i = 0; i < dev->data->nb_rx_queues; i++) { + r = dev->data->rx_queues[i]; + rte_ring_free(r->rng); + } + } + + /* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs = NULL; + + return 0; +} + static const struct eth_dev_ops ops = { + .dev_close = eth_dev_close, .dev_start = eth_dev_start, .dev_stop = eth_dev_stop, .dev_set_link_up = eth_dev_set_link_up, @@ -328,6 +356,7 @@ do_eth_dev_ring_create(const char *name, eth_dev->dev_ops = &ops; data->kdrv = RTE_KDRV_NONE; data->numa_node = numa_node; + data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; /* finally assign rx and tx ops */ eth_dev->rx_pkt_burst = eth_ring_rx; @@ -659,9 +688,6 @@ rte_pmd_ring_remove(struct rte_vdev_device *dev) { const char *name = rte_vdev_device_name(dev); struct rte_eth_dev *eth_dev = NULL; - struct pmd_internals *internals = NULL; - struct ring_queue *r = NULL; - uint16_t i; PMD_LOG(INFO, "Un-Initializing pmd_ring for %s", name); @@ -671,24 +697,9 @@ rte_pmd_ring_remove(struct rte_vdev_device *dev) /* find an ethdev entry */ eth_dev = rte_eth_dev_allocated(name); if (eth_dev == NULL) - return -ENODEV; + return 0; /* port already released */ - eth_dev_stop(eth_dev); - - internals = eth_dev->data->dev_private; - if (internals->action == DEV_CREATE) { - /* - * it is only necessary to delete the rings in rx_queues because - * they are the same used in tx_queues - */ - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - r = eth_dev->data->rx_queues[i]; - rte_ring_free(r->rng); - } - } - - /* mac_addrs must not be freed alone because part of dev_private */ - eth_dev->data->mac_addrs = NULL; + eth_dev_close(eth_dev); rte_eth_dev_release_port(eth_dev); return 0; } -- 2.28.0