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 8B000A04C0; Tue, 29 Sep 2020 01:20:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CD5281D9FC; Tue, 29 Sep 2020 01:15:55 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 8E5A41D717 for ; Tue, 29 Sep 2020 01:15:29 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 36BF25C01AA; Mon, 28 Sep 2020 19:15:28 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:28 -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=HLs5G5Mb4WpeX 2k/Rx5t2pBLcdKrW+j4ZHAvXNpHG4E=; b=pgJRdOppXhDisK0SK9KfVjB9hlua5 Ml9y7rUaaPG5R8RZqVRTCfgzpb7lJ1Sa9jXWswJymW/KamQj/VqDVliWKi8T4Wv5 WVwSIcR645VBhWKOXXooi0b4ZqhcWZFOoc2ef8BsyfZBr1eVytBs4sCHTe1pNkXP BAAOW6ru/yz9Q8ZoOVNX6Pdw1Ou/kOOPsvsiT3oQPH3HxKZBDnVkSBMTninjnp2h EWxIeWVbzzZ/cgrCwoN9n14sdb2lLbmsrE13GVdR3Px8bKs7629BStncqrh3T2Bk VMOg6QkOHZ6EmGNOihignNv7ZTBrSA1gmTiPUcbL/VBk8ZEfdfSgJTHlA== 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=HLs5G5Mb4WpeX2k/Rx5t2pBLcdKrW+j4ZHAvXNpHG4E=; b=BE4Lp8/V lMBCXRYe5Mkijzf3D6KIVoQSjDSIK3t5to1iGoBtWVUIB9A07P3brK2RJioUk17T N8T9jaTl/KkKadgBqt43Y2uQldWQlmQA/fIBWmJvngJoliOG4qIk87ohT2lUj0lM Gl+n5NGAstb+grFOiBKaW1Ll0pvP8+U045NSffQ/9fBB13oD6FwqMvRpy6qx/Qag EHV6jgoxNSqSFf7l+aYcFXq+rvX3+j5fToUeH1Fv1cIF91435AJYYqBnzN2WwbwS 529UACTD2S8hfZcRLuEIkGZEB07QFQQKjTqfFjiApFXifd+IM2pDqxldIEpqo+Dn EWygzTBD29CE7A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudelnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 45A7D3064682; Mon, 28 Sep 2020 19:15:27 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Bruce Richardson , Anatoly Burakov Date: Tue, 29 Sep 2020 01:14:26 +0200 Message-Id: <20200928231437.414489-19-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 18/29] 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. Nothing is closed in a secondary process. Signed-off-by: Thomas Monjalon Acked-by: Bruce Richardson --- drivers/net/ring/rte_eth_ring.c | 54 +++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 40fe1ca4ba..ed0fdeb28f 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -226,7 +226,38 @@ 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; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + 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, @@ -327,6 +358,7 @@ do_eth_dev_ring_create(const char *name, eth_dev->dev_ops = &ops; 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; @@ -658,9 +690,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); @@ -670,24 +699,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