From patchwork Sun Sep 27 23:42:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 78939 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36CF1A04C0; Mon, 28 Sep 2020 01:47:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 97A941D664; Mon, 28 Sep 2020 01:43:49 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 89B521D63C for ; Mon, 28 Sep 2020 01:43:38 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 3B5DC5C0112; Sun, 27 Sep 2020 19:43:37 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 27 Sep 2020 19:43:37 -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=af0A3WA3DVOQGbGj50XhKGpxSKnZO I2WvAhoAc0FTOPa8+2IwhBt38RQZJrEpLytRlYqIlmLjhF0OfgpMo0hS5pLSxLj/ 0oBQgRRpcUWR3h9nm1p13uKdKYjiOAUTp+8N9xkUrMTGJLMbLup52vSP1jq740o8 8MvhWVFh8KeO+7kZ/X78djYxnZqYNHtM05vd1KovLqsVH+bQ0uYCfeXRVT9uQ2h8 u3tBWAbK0MG3HSJ3Ov8bgmGENzVvWtmb2eBb7Sp/Vk96o6iXRIy8AUPERSmdCNDI Eigh1U95zdJywIuHNKyyajY/WIiBb1n0hm5PAeM/JUrhdu8Vqs+80MQrw== 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=SL8iG2sw X5838DYlY17/BmJDtIUJzDL+Y4wJdpl3fENCjI/UHDzsx7q/ExIbVOYuaxJml8Si 8u3ige8WCfuYKogzGeWf4KB2isA+ounkpmPsgod7hzmsexwG2EKvSgKxq02PCTTr 3kpavN3+MIJIjGudqIWyYEuMf2tkxKVm8pJQ3F0No7Jq1SNidA40Avpa/pOPD7B1 KjKs3rMyPXlmXnEYQ3mrnFOynRZdTb9C1QhIEuuL/Uu5bTpBVkV4kCFDwAvquqYt UjTe7D+2c9tONH5czv5j1comHDC6cQVPRCnOjQbCJ+9HbL15MGuufgfNmmkKRipW +egqqq7nuwqbXA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdehgddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 5ADDD328005E; Sun, 27 Sep 2020 19:43:36 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Bruce Richardson , Anatoly Burakov Date: Mon, 28 Sep 2020 01:42:38 +0200 Message-Id: <20200927234249.3198780-15-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 Subject: [dpdk-dev] [PATCH v2 14/25] 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; }