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 2060BA04C9; Mon, 14 Sep 2020 00:09:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3A84A1C115; Mon, 14 Sep 2020 00:08:36 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 29F091C01E for ; Mon, 14 Sep 2020 00:08:35 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 14D035D6; Sun, 13 Sep 2020 18:08:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 13 Sep 2020 18:08:34 -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=669nX+VkN1CM6 97WtFyvA8We9KKCt/COzSMrNsGnHtU=; b=fz1QhLpwWK2kUrm02pjRknaOnG8TZ KG6XTvM3pGrgfBexBWNITVg4c2iHg8+hb0TQPoSkH+Kk3MUutm90CW7pB03sAyp0 wvolpoeyFLb6ybpxNrEPr0Pkx0gHYHQwUgx/KmywcrivL7Dw6+sFTa0QfHLfXFzK upMSjki1STPkXYmuk+rOdMjLe7oa3PA+e6erRkjRq4ho9c5oaOVSjAXcVUSv9qVt jcKYrFGgv64vlCKLbKx0LRGC/K/6TsAUrl7gPWLW1gumtU9Y3nX8Nu+wouIc/bIq PnjHaU1p6BWTbaUirXyQK2FfhRXLTtZ/7TA+qf+3FR7ogVQSfbpIdrNOw== 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=669nX+VkN1CM697WtFyvA8We9KKCt/COzSMrNsGnHtU=; b=EBbJge5Q JagOScs0UZi58xZw06gOBT+ntMC8k/AE/FB/tT25JOzSnhfT86XNF+scFUcMV06d aHhvBsTLlZqq0hgolKsN3aABqEz2ksTdLQOBMXTlubXvmV/FJnMdb3uvjiufTlt5 zkaX7+MlnhPmTU+wym06K3zTf0bQ67iQ1EdMi8adR7Q4lcr4FgU6T/1vBMQLxd0c 87bozV6NgzpE3retyOdJI+u4MxAL5Je/ZTa6DTA3ncBIuezpRwv1QyC51NgxnhU0 SC2i0fnsXlOl2ZQ4AfJiyxT+A9C/pibQja5HfiYQiVA0kmEBX3viHiHRQmLiH4bR 7wYjbF9Zi6kR4w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeihedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpeduheenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr 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 D21E93064685; Sun, 13 Sep 2020 18:08:32 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Yunjian Wang , Keith Wiles Date: Mon, 14 Sep 2020 00:07:06 +0200 Message-Id: <20200913220711.3768597-16-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 15/20] net/tap: 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" From: Yunjian Wang 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: Yunjian Wang --- [Thomas] Note: freeing in secondary process is inconsistent between .dev_close and .remove operations. --- drivers/net/tap/rte_eth_tap.c | 46 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 6bce90c531..2e325f55aa 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -72,6 +72,10 @@ static int tap_devices_count; +static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = { + "UNKNOWN", "TUN", "TAP" +}; + static const char *valid_arguments[] = { ETH_TAP_IFACE_ARG, ETH_TAP_REMOTE_ARG, @@ -1040,6 +1044,9 @@ tap_dev_close(struct rte_eth_dev *dev) struct pmd_process_private *process_private = dev->process_private; struct rx_queue *rxq; + if (process_private == NULL) + return 0; + tap_link_set_down(dev); if (internals->nlsk_fd != -1) { tap_flow_flush(dev, NULL); @@ -1079,6 +1086,23 @@ tap_dev_close(struct rte_eth_dev *dev) * it will be removed from kernel */ + /* mac_addrs must not be freed alone because part of dev_private */ + dev->data->mac_addrs = NULL; + + internals = dev->data->dev_private; + TAP_LOG(DEBUG, "Closing %s Ethernet device on NUMA %u", + tuntap_types[internals->type], rte_socket_id()); + + if (internals->ioctl_sock != -1) { + close(internals->ioctl_sock); + internals->ioctl_sock = -1; + } + rte_free(dev->process_private); + dev->process_private = NULL; + if (tap_devices_count == 1) + rte_mp_action_unregister(TAP_MP_KEY); + tap_devices_count--; + return 0; } @@ -1802,10 +1826,6 @@ static const struct eth_dev_ops ops = { .filter_ctrl = tap_dev_filter_ctrl, }; -static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = { - "UNKNOWN", "TUN", "TAP" -}; - static int eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, char *remote_iface, struct rte_ether_addr *mac_addr, @@ -1856,7 +1876,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, /* Setup some default values */ data = dev->data; data->dev_private = pmd; - data->dev_flags = RTE_ETH_DEV_INTR_LSC; + data->dev_flags = RTE_ETH_DEV_INTR_LSC | RTE_ETH_DEV_CLOSE_REMOVE; data->numa_node = numa_node; data->dev_link = pmd_link; @@ -2448,30 +2468,16 @@ static int rte_pmd_tap_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; - struct pmd_internals *internals; /* find the ethdev entry */ eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (!eth_dev) - return -ENODEV; - - /* mac_addrs must not be freed alone because part of dev_private */ - eth_dev->data->mac_addrs = NULL; + return 0; if (rte_eal_process_type() != RTE_PROC_PRIMARY) return rte_eth_dev_release_port(eth_dev); tap_dev_close(eth_dev); - - internals = eth_dev->data->dev_private; - TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", - tuntap_types[internals->type], rte_socket_id()); - - close(internals->ioctl_sock); - rte_free(eth_dev->process_private); - if (tap_devices_count == 1) - rte_mp_action_unregister(TAP_MP_KEY); - tap_devices_count--; rte_eth_dev_release_port(eth_dev); return 0; -- 2.28.0