DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: Wan Junjie <wanjunjie@bytedance.com>,
	Chas Williams <chas3@att.com>,
	"Min Hu (Connor)" <humin29@huawei.com>,
	Ferruh Yigit <ferruh.yigit@intel.com>,
	 Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Subject: [PATCH] net/bonding: fix slaves initializing on mtu setting
Date: Fri, 4 Mar 2022 09:22:56 +0800	[thread overview]
Message-ID: <20220304012257.39247-5-humin29@huawei.com> (raw)
In-Reply-To: <20220304012257.39247-1-humin29@huawei.com>

From: Wan Junjie <wanjunjie@bytedance.com>

If a initial process for the bonding device is like:
rte_eth_dev_configure
rte_eth_dev_set_mtu
queue setup and start, etc.

Pass the vdev args to application, and init bonding device only.
-a 0000:af:00.0 --vdev="net_bonding0,mode=2,slave=0000:af:00.0"

It will fail and compain for the slave device
"Port 0 must be configured before MTU set"

Test can be reproduced with ovs.

Fixes: b26bee1 ("ethdev: forbid MTU set before device configure")

Signed-off-by: Wan Junjie <wanjunjie@bytedance.com>
---
 app/test/test_link_bonding.c           |  4 +++
 app/test/test_link_bonding_rssconf.c   |  4 +++
 drivers/net/bonding/eth_bond_private.h |  4 +++
 drivers/net/bonding/rte_eth_bond_api.c |  6 ++++
 drivers/net/bonding/rte_eth_bond_pmd.c | 43 ++++++++++++++++++++++----
 5 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index dc6fc46b9c..12c50ef393 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -181,6 +181,10 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr)
 			test_params->nb_tx_q, &default_pmd_conf),
 			"rte_eth_dev_configure for port %d failed", port_id);
 
+	int ret = rte_eth_dev_set_mtu(port_id, 1550);
+	RTE_TEST_ASSERT(ret == 0 || ret == -ENOTSUP,
+			"rte_eth_dev_set_mtu for port %d failed", port_id);
+
 	for (q_id = 0; q_id < test_params->nb_rx_q; q_id++)
 		TEST_ASSERT_SUCCESS(rte_eth_rx_queue_setup(port_id, q_id, RX_RING_SIZE,
 				rte_eth_dev_socket_id(port_id), &rx_conf_default,
diff --git a/app/test/test_link_bonding_rssconf.c b/app/test/test_link_bonding_rssconf.c
index f9eae93973..7228965ced 100644
--- a/app/test/test_link_bonding_rssconf.c
+++ b/app/test/test_link_bonding_rssconf.c
@@ -128,6 +128,10 @@ configure_ethdev(uint16_t port_id, struct rte_eth_conf *eth_conf,
 			RXTX_QUEUE_COUNT, eth_conf) == 0, "Failed to configure device %u",
 			port_id);
 
+	int ret = rte_eth_dev_set_mtu(port_id, 1550);
+	RTE_TEST_ASSERT(ret == 0 || ret == -ENOTSUP,
+			"rte_eth_dev_set_mtu for port %d failed", port_id);
+
 	for (rxq = 0; rxq < RXTX_QUEUE_COUNT; rxq++) {
 		TEST_ASSERT(rte_eth_rx_queue_setup(port_id, rxq, RXTX_RING_SIZE,
 				rte_eth_dev_socket_id(port_id), NULL,
diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h
index 156335c425..8222e3cd38 100644
--- a/drivers/net/bonding/eth_bond_private.h
+++ b/drivers/net/bonding/eth_bond_private.h
@@ -246,6 +246,10 @@ int
 slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev);
 
+int
+slave_start(struct rte_eth_dev *bonded_eth_dev,
+		struct rte_eth_dev *slave_eth_dev);
+
 void
 slave_remove(struct bond_dev_private *internals,
 		struct rte_eth_dev *slave_eth_dev);
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index b78867b125..4ac191c468 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -566,6 +566,12 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
 					slave_port_id);
 			return -1;
 		}
+		if (slave_start(bonded_eth_dev, slave_eth_dev) != 0) {
+			internals->slave_count--;
+			RTE_BOND_LOG(ERR, "rte_bond_slaves_start: port=%d",
+					slave_port_id);
+			return -1;
+		}
 	}
 
 	/* Update all slave devices MACs */
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index bfa931098e..58dad0a0e3 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1678,14 +1678,10 @@ int
 slave_configure(struct rte_eth_dev *bonded_eth_dev,
 		struct rte_eth_dev *slave_eth_dev)
 {
-	struct bond_rx_queue *bd_rx_q;
-	struct bond_tx_queue *bd_tx_q;
 	uint16_t nb_rx_queues;
 	uint16_t nb_tx_queues;
 
 	int errval;
-	uint16_t q_id;
-	struct rte_flow_error flow_error;
 
 	struct bond_dev_private *internals = bonded_eth_dev->data->dev_private;
 
@@ -1758,6 +1754,19 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 				slave_eth_dev->data->port_id, errval);
 		return errval;
 	}
+	return 0;
+}
+
+int
+slave_start(struct rte_eth_dev *bonded_eth_dev,
+		struct rte_eth_dev *slave_eth_dev)
+{
+	int errval = 0;
+	struct bond_rx_queue *bd_rx_q;
+	struct bond_tx_queue *bd_tx_q;
+	uint16_t q_id;
+	struct rte_flow_error flow_error;
+	struct bond_dev_private *internals = bonded_eth_dev->data->dev_private;
 
 	/* Setup Rx Queues */
 	for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
@@ -1806,10 +1815,13 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev,
 			return errval;
 		}
 
-		if (internals->mode4.dedicated_queues.flow[slave_eth_dev->data->port_id] != NULL)
-			rte_flow_destroy(slave_eth_dev->data->port_id,
+		if (internals->mode4.dedicated_queues.flow[slave_eth_dev->data->port_id] != NULL) {
+			errval = rte_flow_destroy(slave_eth_dev->data->port_id,
 					internals->mode4.dedicated_queues.flow[slave_eth_dev->data->port_id],
 					&flow_error);
+			RTE_BOND_LOG(ERR, "bond_ethdev_8023ad_flow_destroy: port=%d, err (%d)",
+				slave_eth_dev->data->port_id, errval);
+		}
 
 		errval = bond_ethdev_8023ad_flow_set(bonded_eth_dev,
 				slave_eth_dev->data->port_id);
@@ -2001,6 +2013,13 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 				internals->slaves[i].port_id);
 			goto out_err;
 		}
+		if (slave_start(eth_dev, slave_ethdev) != 0) {
+			RTE_BOND_LOG(ERR,
+				"bonded port (%d) failed to start slave device (%d)",
+				eth_dev->data->port_id,
+				internals->slaves[i].port_id);
+			goto out_err;
+		}
 		/* We will need to poll for link status if any slave doesn't
 		 * support interrupts
 		 */
@@ -3847,6 +3866,18 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 		return -1;
 	}
 
+	/* configure slaves so we can pass mtu setting */
+	for (i = 0; i < internals->slave_count; i++) {
+		struct rte_eth_dev *slave_ethdev =
+				&(rte_eth_devices[internals->slaves[i].port_id]);
+		if (slave_configure(dev, slave_ethdev) != 0) {
+			RTE_BOND_LOG(ERR,
+				"bonded port (%d) failed to configure slave device (%d)",
+				dev->data->port_id,
+				internals->slaves[i].port_id);
+			return -1;
+		}
+	}
 	return 0;
 }
 
-- 
2.33.0


  parent reply	other threads:[~2022-03-04  1:23 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28  3:26 [PATCH] app/testpmd: add help messages for multi-process Min Hu (Connor)
2022-02-28  8:57 ` Thomas Monjalon
2022-03-01  3:41   ` Min Hu (Connor)
2022-03-01  8:36     ` Thomas Monjalon
2022-03-01  9:19       ` Min Hu (Connor)
2022-03-01  3:39 ` [PATCH v2] " Min Hu (Connor)
2022-03-01  8:35   ` Thomas Monjalon
2022-03-01  9:17     ` Min Hu (Connor)
2022-03-01  9:16 ` [PATCH v3] " Min Hu (Connor)
2022-03-03 12:09   ` Ferruh Yigit
2022-03-03 14:59     ` Ajit Khaparde
2022-03-04  1:28     ` Min Hu (Connor)
2022-03-04  1:22 ` [PATCH] 1 version Min Hu (Connor)
2022-03-04  1:22   ` [PATCH] app/testpmd: add help messages for multi-process Min Hu (Connor)
2022-03-04  1:25     ` Min Hu (Connor)
2022-03-04  1:22   ` [PATCH] dpdk: show dev basic info Min Hu (Connor)
2022-03-04  1:25     ` Min Hu (Connor)
2022-03-04  1:22   ` [PATCH v4] ethdev: introduce dump API Min Hu (Connor)
2022-03-04  1:26     ` Min Hu (Connor)
2022-03-04  1:22   ` Min Hu (Connor) [this message]
2022-03-04  1:27     ` [PATCH] net/bonding: fix slaves initializing on mtu setting Min Hu (Connor)
2022-03-04  1:25   ` [PATCH] 1 version Min Hu (Connor)
2022-03-04  1:27 ` [PATCH v4] app/testpmd: add help messages for multi-process Min Hu (Connor)
2022-03-04  2:50   ` Zhang, Yuying
2022-03-04  6:29     ` Min Hu (Connor)
2022-03-04  6:26 ` [PATCH v5] " Min Hu (Connor)
2022-03-04  9:11   ` Zhang, Yuying
2022-03-04 15:35     ` Ferruh Yigit
2022-03-06 22:52       ` Thomas Monjalon
2022-03-07  1:05         ` Min Hu (Connor)
2022-03-04 14:46   ` Ferruh Yigit
2022-03-07  1:04 ` Min Hu (Connor)
2022-04-25  6:51   ` Min Hu (Connor)
2022-06-02  2:24   ` Min Hu (Connor)
2022-06-02 23:08     ` Ferruh Yigit
2022-06-09  8:07       ` Dongdong Liu
2022-06-09  8:52 ` [PATCH v6] " Dongdong Liu
2022-06-09 14:06   ` Ferruh Yigit
2022-06-09 14:58     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220304012257.39247-5-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=chas3@att.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=ivan.ilchenko@oktetlabs.ru \
    --cc=wanjunjie@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).