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 1EFCEA04AC; Tue, 1 Sep 2020 12:59:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EF8E61515; Tue, 1 Sep 2020 12:59:08 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 87134DE0 for ; Tue, 1 Sep 2020 12:59:07 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 30EE35C023F; Tue, 1 Sep 2020 06:59:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 01 Sep 2020 06:59:07 -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:content-type; s=fm2; bh= z91jvcOyBFmzofadnaZ8cvR+aPu8VPisENr49qpn0lI=; b=XKAUoO2bQ01bqzpi i3bqigcA9jI7jSIthaUKCeuR3+TCFR23pfRT4se3jrdl7e0o7pelVESFYOGVie7k xsjpc9dRXIeAaohCknGKAmxTqpvEbFA0cKKTEd1QsEAZ3FHxUcoodA4a3DHl6KTj /UxKsalo9W7iT8B95ZzuMeuevEakfoH1/0hGc8wlUQXIvM1fqSfOOuIN0P/feU52 LqwePRCwNgBLUYYFM+cbgGVQjTa1b9Hq9RwqXdJMmltZ5laRx7gv5eDUvrkIt2Lc YbElaPe6zNm/+0V/RgOAJ4AqVVySdNylrCP78HwrIlCqazPz9P6xKg1hnweBz3Yk HFglLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :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=z91jvcOyBFmzofadnaZ8cvR+aPu8VPisENr49qpn0 lI=; b=Jy3it1RftzaKJMEeewQHv1QU6ITXGcbl/cD8pczYTI8qIbpaW+XhyLJ26 DHljGWlLnsuqZIgYxXKl/JPSRYpvf/+H/JJgH9N0bva57wL34BrCRHT2zpQ7Njoc NRoxz1ZivP2UhV0W2xuVieiahrCCfIhbbhyYDvzRYClM6rD/XYTEitIK46qm7PL8 GoMuIowANhftlljAgw/BT12GYZMcGp1vY57uXGa8CNXqe3KYmXA3ZL8UKniT8+Fa W4tpJF7eObxUTNR8Dxe27FyuhJUaQA+TO/baJsWkDYGqz6ori3hY9ZvArHFoBLLc uU5TIUUPYy8NpSopuP2DXktPhRT/A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudefjedgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepudeggfdvfeduffdtfeeglefghfeukefgfffhueejtdetuedtjeeu ieeivdffgeehnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 2CE3B3280060; Tue, 1 Sep 2020 06:59:06 -0400 (EDT) From: Thomas Monjalon To: wangyunjian Cc: dev@dpdk.org, ferruh.yigit@intel.com, jerry.lilijun@huawei.com, xudingke@huawei.com, Yunjian Wang , Keith Wiles Date: Tue, 01 Sep 2020 12:59:04 +0200 Message-ID: <2836087.JeWKI6TpkR@thomas> In-Reply-To: <9a94f272bc7c1e5650295ddf3e02fb19b15e7951.1598596042.git.wangyunjian@huawei.com> References: <9a94f272bc7c1e5650295ddf3e02fb19b15e7951.1598596042.git.wangyunjian@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] 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" Please next time, use --cc-cmd devtools/get-maintainer.sh so you will send it to Keith (Cc'ed) for review. 28/08/2020 14:37, wangyunjian: > From: Yunjian Wang > > Set RTE_ETH_DEV_CLOSE_REMOVE upon probe so all the private > resources for the port can be freed by rte_eth_dev_close(). > > Signed-off-by: Yunjian Wang > --- > drivers/net/tap/rte_eth_tap.c | 42 ++++++++++++++++++++++------------- > 1 file changed, 26 insertions(+), 16 deletions(-) > > diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c > index 339f24bf8..e059f7f2f 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; > + > tap_link_set_down(dev); > if (internals->nlsk_fd != -1) { > tap_flow_flush(dev, NULL); > @@ -1078,6 +1085,23 @@ tap_dev_close(struct rte_eth_dev *dev) > * Since TUN device has no more opened file descriptors > * 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--; > } > > static void > @@ -1800,10 +1824,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, > @@ -1854,7 +1874,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; > @@ -2446,12 +2466,11 @@ 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; > + return 0; > > /* mac_addrs must not be freed alone because part of dev_private */ > eth_dev->data->mac_addrs = NULL; > @@ -2461,15 +2480,6 @@ rte_pmd_tap_remove(struct rte_vdev_device *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; >