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 99E33A04C0; Tue, 29 Sep 2020 01:17:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1DA6F1D90D; Tue, 29 Sep 2020 01:15:20 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 0BD511D8D1 for ; Tue, 29 Sep 2020 01:15:05 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id A8DE25C01B0; Mon, 28 Sep 2020 19:15:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:04 -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=eNXQ7yZTlH3MT yqjxIWINnIQIuF9l8QoOQ4Jo3eLaCU=; b=jCFMp4M+MAsCRsZLnj5ZE8UF8crMH Dxa32bEKKMEx+J93XYHdu1TL+8yqPGfO6DER0gRoV22Mmea03+T7AtYeM2dl9sRM 751seo9liKRJ8e7QfF1HcbGVV/P97ilW+iyvGhqQnIEGGGdAO2IC2LApBS5tMIbQ fMOHoIQmKKxKNhZpxmwtd02ObtX0QgelPERUF3P+7Wis0JsAGHpRMZSGd0h/YgYG ayUEEDKqICo/7BvedF5ZapPVzJafTmA4Z6x5159Sw//Uu3/0ZN8K1l9OvfoLUKKn Rz4Bbuf+QLgcRduCAjKUPpFgbq3JZz7+qagpxSltNkDAr9rnrzC630LwA== 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=eNXQ7yZTlH3MTyqjxIWINnIQIuF9l8QoOQ4Jo3eLaCU=; b=uKg4eT1+ h8q1Au6ZKpQoHYv8Q/7Ihor5QJxy1+sCf88XF8zCiOPj9+tKKEoQ1lpbPuIefqcP s7QijW4KSpetKZszKHzfopFVgeYOwEXg7VhFJv9pLGrmzQgQQlQmrfN9+yXbsNB3 ZK3pZohLus1u31Tw/HDcSqjbYT2MNeZluvzbMrbCaDUUdOwCW39EuhbCTT1xajv4 bpULI8XuLoEgVag97WIyVu5Kosuq8pL13w5zYtOTxTgceMTNZbGzYUtPiNt9s3Ig ZtMatcGhK3/yz5pXG5mz13HbtDZ7pH9Jv8HXnsvlNPEUfkRR4ljQEh0uvVxqSma3 1DkB59XcTU/OuA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepkeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth 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 A1A4C3064684; Mon, 28 Sep 2020 19:15:03 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Chas Williams , "Wei Hu (Xavier)" , Anatoly Burakov Date: Tue, 29 Sep 2020 01:14:15 +0200 Message-Id: <20200928231437.414489-8-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 07/29] net/bonding: 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. Signed-off-by: Thomas Monjalon --- drivers/net/bonding/rte_eth_bond_pmd.c | 34 ++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index dff835ef92..a9ed5d8e12 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2103,6 +2103,9 @@ bond_ethdev_close(struct rte_eth_dev *dev) int skipped = 0; struct rte_flow_error ferror; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + RTE_BOND_LOG(INFO, "Closing bonded device %s", dev->device->name); while (internals->slave_count != skipped) { uint16_t port_id = internals->slaves[skipped].port_id; @@ -2119,6 +2122,17 @@ bond_ethdev_close(struct rte_eth_dev *dev) bond_flow_ops.flush(dev, &ferror); bond_ethdev_free_queues(dev); rte_bitmap_reset(internals->vlan_filter_bmp); + rte_bitmap_free(internals->vlan_filter_bmp); + rte_free(internals->vlan_filter_bmpmem); + + /* Try to release mempool used in mode6. If the bond + * device is not mode6, free the NULL is not problem. + */ + rte_mempool_free(internals->mode6.mempool); + + dev->dev_ops = NULL; + dev->rx_pkt_burst = NULL; + dev->tx_pkt_burst = NULL; return 0; } @@ -3195,6 +3209,7 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode) } internals = eth_dev->data->dev_private; + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; eth_dev->data->nb_rx_queues = (uint16_t)1; eth_dev->data->nb_tx_queues = (uint16_t)1; @@ -3414,14 +3429,10 @@ bond_remove(struct rte_vdev_device *dev) name = rte_vdev_device_name(dev); RTE_BOND_LOG(INFO, "Uninitializing pmd_bond for %s", name); - /* now free all data allocation - for eth_dev structure, - * dummy pci driver and internal (private) data - */ - /* find an ethdev entry */ eth_dev = rte_eth_dev_allocated(name); if (eth_dev == NULL) - return -ENODEV; + return 0; /* port already released */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) return rte_eth_dev_release_port(eth_dev); @@ -3436,19 +3447,6 @@ bond_remove(struct rte_vdev_device *dev) bond_ethdev_stop(eth_dev); bond_ethdev_close(eth_dev); } - - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - - internals = eth_dev->data->dev_private; - /* Try to release mempool used in mode6. If the bond - * device is not mode6, free the NULL is not problem. - */ - rte_mempool_free(internals->mode6.mempool); - rte_bitmap_free(internals->vlan_filter_bmp); - rte_free(internals->vlan_filter_bmpmem); - rte_eth_dev_release_port(eth_dev); return 0; -- 2.28.0