net/bonding: fix number of bonding Tx/Rx queues
authorDeclan Doherty <declan.doherty@intel.com>
Tue, 4 Jul 2017 16:46:24 +0000 (17:46 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 6 Jul 2017 13:00:57 +0000 (15:00 +0200)
This patch fixes the maximum number of Tx an Rx queues supported by a
bonding device return by the rte_eth_dev_info_get function.

The bonding device now calculates the maximum number of supported Tx
and Rx queues based on the slaves bound to the bonded device, with the
minimum values of Tx and Rx queues from the device slaves being the
bonded devices maximum, as each slave must be able to support the same
number of Tx and Rx queues.

Fixes: 2efb58cbab6e ("bond: new link bonding library")
Cc: stable@dpdk.org
Signed-off-by: Declan Doherty <declan.doherty@intel.com>
drivers/net/bonding/rte_eth_bond_pmd.c

index e016eb4..e097d01 100644 (file)
@@ -1691,6 +1691,8 @@ static void
 bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
        struct bond_dev_private *internals = dev->data->dev_private;
+       uint16_t max_nb_rx_queues = UINT16_MAX;
+       uint16_t max_nb_tx_queues = UINT16_MAX;
 
        dev_info->max_mac_addrs = 1;
 
@@ -1698,8 +1700,29 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
                                  ? internals->candidate_max_rx_pktlen
                                  : ETHER_MAX_JUMBO_FRAME_LEN;
 
-       dev_info->max_rx_queues = (uint16_t)128;
-       dev_info->max_tx_queues = (uint16_t)512;
+       if (internals->slave_count > 0) {
+               /* Max number of tx/rx queues that the bonded device can
+                * support is the minimum values of the bonded slaves, as
+                * all slaves must be capable of supporting the same number
+                * of tx/rx queues.
+                */
+               struct rte_eth_dev_info slave_info;
+               uint8_t idx;
+
+               for (idx = 0; idx < internals->slave_count; idx++) {
+                       rte_eth_dev_info_get(internals->slaves[idx].port_id,
+                                       &slave_info);
+
+                       if (slave_info.max_rx_queues < max_nb_rx_queues)
+                               max_nb_rx_queues = slave_info.max_rx_queues;
+
+                       if (slave_info.max_tx_queues < max_nb_tx_queues)
+                               max_nb_tx_queues = slave_info.max_tx_queues;
+               }
+       }
+
+       dev_info->max_rx_queues = max_nb_rx_queues;
+       dev_info->max_tx_queues = max_nb_tx_queues;
 
        dev_info->min_rx_bufsize = 0;