ethdev: fix switching domain allocation
authorViacheslav Ovsiienko <viacheslavo@mellanox.com>
Thu, 16 Jan 2020 16:19:54 +0000 (16:19 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:59:19 +0000 (19:59 +0100)
The maximum amount of unique swutching domain is supposed
to be equal RTE_MAX_ETHPORTS. Current implementation allows
to allocate only RTE_MAX_ETHPORTS-1 domains.

The definition of RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID is
changed from 0 to UINT16_MAX, the rte_eth_dev_info_get is
updated to initialize dev_ibfo structure accordingly.

Fixes: ce9250406323 ("ethdev: add switch domain allocator")
Cc: stable@dpdk.org
Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
lib/librte_ethdev/rte_ethdev.c
lib/librte_ethdev/rte_ethdev.h

index aec2d0f..42ce177 100644 (file)
@@ -2968,6 +2968,7 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
         * return status and does not know if get is successful or not.
         */
        memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
+       dev_info->switch_info.domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
        dev = &rte_eth_devices[port_id];
@@ -5064,8 +5065,7 @@ rte_eth_switch_domain_alloc(uint16_t *domain_id)
 
        *domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;
 
-       for (i = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID + 1;
-               i < RTE_MAX_ETHPORTS; i++) {
+       for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
                if (rte_eth_switch_domains[i].state ==
                        RTE_ETH_SWITCH_DOMAIN_UNUSED) {
                        rte_eth_switch_domains[i].state =
index 18a9def..d1a593a 100644 (file)
@@ -1196,7 +1196,7 @@ struct rte_eth_dev_portconf {
  * Default values for switch domain id when ethdev does not support switch
  * domain definitions.
  */
-#define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID   (0)
+#define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID   (UINT16_MAX)
 
 /**
  * Ethernet device associated switch information