From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AC287A0560; Tue, 18 Oct 2022 21:46:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 90ABE4161A; Tue, 18 Oct 2022 21:45:53 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 986CD41145 for ; Tue, 18 Oct 2022 21:45:52 +0200 (CEST) Received: from bree.oktetlabs.ru (bree.oktetlabs.ru [192.168.34.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPS id 1C75767; Tue, 18 Oct 2022 22:45:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 1C75767 Authentication-Results: shelob.oktetlabs.ru/1C75767; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: Chas Williams <3chas3@gmail.com>, "Min Hu (Connor)" , Andrew Rybchenko , Chas Williams , Anatoly Burakov Subject: [PATCH v2] net/bonding: make bonded device configure method re-entrant Date: Tue, 18 Oct 2022 22:45:49 +0300 Message-Id: <20221018194549.635113-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220911122405.3995083-1-ivan.malov@oktetlabs.ru> References: <20220911122405.3995083-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org According to the documentation, rte_eth_dev_configure() can be invoked repeatedly while in stopped state. The current implementation in the bonding driver allows for that (technically), but the user sees warnings which say that back-end devices have already been harnessed. Re-factor the code to have cleanup before each (re-)configure. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Acked-by: Chas Williams <3chas3@gmail.com> --- drivers/net/bonding/rte_eth_bond_pmd.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 27005c747c..486b7fc9f7 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2148,18 +2148,14 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev) return 0; } -int -bond_ethdev_close(struct rte_eth_dev *dev) +static void +bond_ethdev_cfg_cleanup(struct rte_eth_dev *dev) { struct bond_dev_private *internals = dev->data->dev_private; uint16_t bond_port_id = internals->port_id; 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; @@ -2178,6 +2174,20 @@ bond_ethdev_close(struct rte_eth_dev *dev) } } bond_flow_ops.flush(dev, &ferror); +} + +int +bond_ethdev_close(struct rte_eth_dev *dev) +{ + struct bond_dev_private *internals = dev->data->dev_private; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + RTE_BOND_LOG(INFO, "Closing bonded device %s", dev->device->name); + + bond_ethdev_cfg_cleanup(dev); + bond_ethdev_free_queues(dev); rte_bitmap_reset(internals->vlan_filter_bmp); rte_bitmap_free(internals->vlan_filter_bmp); @@ -3610,6 +3620,9 @@ bond_ethdev_configure(struct rte_eth_dev *dev) unsigned i, j; + + bond_ethdev_cfg_cleanup(dev); + /* * If RSS is enabled, fill table with default values and * set key to the value specified in port RSS configuration. -- 2.30.2