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 D25E6A04C0; Mon, 28 Sep 2020 01:46:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B1F7D1D649; Mon, 28 Sep 2020 01:43:43 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 3E8921D625 for ; Mon, 28 Sep 2020 01:43:32 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id E366F5C00FE; Sun, 27 Sep 2020 19:43:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 27 Sep 2020 19:43:30 -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=tYdzh5Glfij1hSx8vq4iNAH5dW9Oo d/rKuGQRDcoN249XOfbNXPgBCFJlAP0ydS9duss/wVzhKCt2YqxCgNdjr6S91xee s5Yb79L7GyslwxwjvQqnrFcU4wtVDbio0pJ8mPevCyW9u8hXUCGIKJte1mjB4wKx d6dQ5wU5Uwj5krAKHH1CuBV2dIIC7ytrBfH7nayVzSb4rG8kCT0RMW2x2CuXq3kC ojYReU7oeRwjDg7WAZ5U2myyMbybGWGO4L1coeyV03A4Bvz796PDEYpOmA9fw/pS Y/PubopdSchggXEEQ47rC/Ytdy87/G+NY50BDBmBh6ArXgpIAjgsDdqbw== 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=Zz+niNdO AKsSvbSYw9kDdKguMWMMi3YIVUXOuaY7IE1O9+FO/p52b1P7YNhS6w2CywXSq5Xc +rdxXnvPkxxJ4YpprHjQfZ2tU/hz4CUYtmtZTIbbsAtE7X13nyZV6hzo/21vQaAT LXV9xUhNno1tAno5olhFFrtzSHjksDIqZUDIlhNqV+YYgBh8OlLM3qmtcY6hZCLk bgkN23WaziF9KhOaAJzbxzrtf4W8X5bXecllO6jWA1S11ODRNNBAOZm8bTg2ByBr debDE7WWJZgGy32LAeSpQ/AhKOs7fpUq3/vLDX9uy17tYTkSv2BmCeEcrFsAk9NZ d9VHV8HGDeLBdg== 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 0E0EB328005A; Sun, 27 Sep 2020 19:43:29 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Tetsuya Mukawa , Anatoly Burakov Date: Mon, 28 Sep 2020 01:42:34 +0200 Message-Id: <20200927234249.3198780-11-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 10/25] 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