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 AD3DBA04C0; Tue, 29 Sep 2020 01:18:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 20D131D8E9; Tue, 29 Sep 2020 01:15:43 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 89AD81D914 for ; Tue, 29 Sep 2020 01:15:19 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 2D38A5C01AC; Mon, 28 Sep 2020 19:15:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:19 -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=Gx59qL9SspNVx 2GocH7kCT+J/d5XaMJivyZiED/g9tU=; b=iTVCRNqwYt7QsliC3EjtneOqKDTGr IU4nmlo+awBcMgb5UFOcGICceAPH8hb+KRbZEj9kuE4ORu7pWoJ693PjPthy4bSo w9Wyfk4DLGaOr+lzvNU3issZEVhwKbpRTc1MEHDxwAouXKqiCuOlURJ9+poJALnl 6ODdM71Z73z/MtKICpACd5pqezhR+SJRI7T5Ki4v0BMy4CAyJQrRJdQCduARcxzG 3ZMAj5zSKKHOenPE6AOaXOuXExvotnrj72kfMu2/HWuW3CyYDhHE3/Tp+aBLrtMI LnWU18ATmnRnK53CM+K6NJFua0iKQyJmcRRXojAJL8YXek7VNGI5k4zgQ== 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=Gx59qL9SspNVx2GocH7kCT+J/d5XaMJivyZiED/g9tU=; b=DCYA3whC gCAMKxhpaKQsRpOX/EVInWJcGx6z4UqJ8RGBxcu4aHz4BkkaNtnovZHJgi06PkdO ZF+NiP6dtzGCedmnkHmzgZy9iTYqlXTYCG9e1iBLR8qh+ROOlUr6hc/AQJFrt9ip gVghBAGX1Ed4+gMmoVaXK0170fDRrof72Ji2cS8TyVbIQrXkJvkRmuoz0Q2HViyV zIkwlzkfLJBjER8CPQZjdAjZDpTvws+PDquw2U4OnohqozOK4RA8RNF8PwXHBGDT yJFhCjILKDflSXgIb9kg31Xom09ZSi9cRdK02EDpEh8WNq88+LhcAFxYKB0XwoCH a2l9+0uvs/Q01g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudefnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 339DA306467E; Mon, 28 Sep 2020 19:15:18 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Tetsuya Mukawa , Anatoly Burakov Date: Tue, 29 Sep 2020 01:14:21 +0200 Message-Id: <20200928231437.414489-14-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 13/29] net/null: 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(). Signed-off-by: Thomas Monjalon --- drivers/net/null/rte_eth_null.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 0ce073fa4b..84c1d0c951 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -458,7 +458,23 @@ eth_mac_address_set(__rte_unused struct rte_eth_dev *dev, return 0; } +static int +eth_dev_close(struct rte_eth_dev *dev) +{ + PMD_LOG(INFO, "Closing null ethdev on NUMA socket %u", + rte_socket_id()); + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + /* 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_configure = eth_dev_configure, @@ -532,6 +548,7 @@ eth_dev_null_create(struct rte_vdev_device *dev, struct pmd_options *args) data->mac_addrs = &internals->eth_addr; data->promiscuous = 1; data->all_multicast = 1; + data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; eth_dev->dev_ops = &ops; @@ -701,18 +718,12 @@ rte_pmd_null_remove(struct rte_vdev_device *dev) if (!dev) return -EINVAL; - PMD_LOG(INFO, "Closing null ethdev on numa socket %u", - rte_socket_id()); - /* find the 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) - /* mac_addrs must not be freed alone because part of dev_private */ - eth_dev->data->mac_addrs = NULL; + return 0; /* port already released */ + eth_dev_close(eth_dev); rte_eth_dev_release_port(eth_dev); return 0; -- 2.28.0