]> git.droids-corp.org - dpdk.git/commitdiff
net/bonding: fix slaves initializing on MTU setting
authorJunjie Wan <wanjunjie@bytedance.com>
Tue, 15 Feb 2022 10:59:40 +0000 (18:59 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 17 Feb 2022 11:55:21 +0000 (12:55 +0100)
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 complain for the slave device
"Port 0 must be configured before MTU set"

Test can be reproduced with ovs.

Fixes: b26bee10ee37 ("ethdev: forbid MTU set before device configure")
Cc: stable@dpdk.org
Signed-off-by: Junjie Wan <wanjunjie@bytedance.com>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
app/test/test_link_bonding.c
app/test/test_link_bonding_rssconf.c
drivers/net/bonding/eth_bond_private.h
drivers/net/bonding/rte_eth_bond_api.c
drivers/net/bonding/rte_eth_bond_pmd.c

index 82a9b8e01a8282290e3f74d01bd9c1743655223c..194ed5a7ec7d8a1541ad40143c94d33d1f7d5bdb 100644 (file)
@@ -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,
index f9eae939738659ef8b5921d013c79bfb1a6db6ac..7228965ced60c9e90bc3b3fddb3defcb5e53755a 100644 (file)
@@ -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,
index 156335c425298164c819c576a6541b7b792d3ba7..8222e3cd38df97a9d8ec96cc0f4bb01269e35fb4 100644 (file)
@@ -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);
index b78867b125200e81142360cc30742fa0d8f9aad6..4ac191c4685d4a95c0dcd0b265d6c0102d1bcea7 100644 (file)
@@ -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 */
index 846a13191664e37b4527e8508bf9c2fcb4cd0f44..b305b6a35bcdcdfd1f8a5cd638945b39b8480dd0 100644 (file)
@@ -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
                 */
@@ -3848,6 +3867,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;
 }