]> git.droids-corp.org - dpdk.git/commitdiff
net/bnxt: fix switch domain allocation
authorAjit Khaparde <ajit.khaparde@broadcom.com>
Wed, 15 Jun 2022 14:56:57 +0000 (20:26 +0530)
committerAjit Khaparde <ajit.khaparde@broadcom.com>
Fri, 24 Jun 2022 21:23:52 +0000 (23:23 +0200)
Allocate switch domain after the trusted VF capability is queried
from the FW. Currently we are calling the function earlier.
Since the switch domain is allocated only for PFs or trusted VF,
the current location of code fails to allocate the domain during init.
But during cleanup we try to free the domain incorrectly.
Fix the behavior by changing the sequence of function calls.

Fixes: 3127f99274b67 ("net/bnxt: refactor init/uninit")
Cc: stable@dpdk.org
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
drivers/net/bnxt/bnxt_ethdev.c

index 0f0f40b95b151d2f97285d5ea1cdcd4c85e297c6..34f21496a4a6774b311f4e7a1778bcd730d8c8e6 100644 (file)
@@ -5287,6 +5287,25 @@ bnxt_init_locks(struct bnxt *bp)
        return err;
 }
 
+/* This should be called after we have queried trusted VF cap */
+static int bnxt_alloc_switch_domain(struct bnxt *bp)
+{
+       int rc = 0;
+
+       if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) {
+               rc = rte_eth_switch_domain_alloc(&bp->switch_domain_id);
+               if (rc)
+                       PMD_DRV_LOG(ERR,
+                                   "Failed to alloc switch domain: %d\n", rc);
+               else
+                       PMD_DRV_LOG(INFO,
+                                   "Switch domain allocated %d\n",
+                                   bp->switch_domain_id);
+       }
+
+       return rc;
+}
+
 static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)
 {
        int rc = 0;
@@ -5295,6 +5314,10 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)
        if (rc)
                return rc;
 
+       rc = bnxt_alloc_switch_domain(bp);
+       if (rc)
+               return rc;
+
        if (!reconfig_dev) {
                rc = bnxt_setup_mac_addr(bp->eth_dev);
                if (rc)
@@ -5734,24 +5757,6 @@ err:
        return ret;
 }
 
-static int bnxt_alloc_switch_domain(struct bnxt *bp)
-{
-       int rc = 0;
-
-       if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) {
-               rc = rte_eth_switch_domain_alloc(&bp->switch_domain_id);
-               if (rc)
-                       PMD_DRV_LOG(ERR,
-                                   "Failed to alloc switch domain: %d\n", rc);
-               else
-                       PMD_DRV_LOG(INFO,
-                                   "Switch domain allocated %d\n",
-                                   bp->switch_domain_id);
-       }
-
-       return rc;
-}
-
 /* Allocate and initialize various fields in bnxt struct that
  * need to be allocated/destroyed only once in the lifetime of the driver
  */
@@ -5828,10 +5833,6 @@ static int bnxt_drv_init(struct rte_eth_dev *eth_dev)
        if (rc)
                return rc;
 
-       rc = bnxt_alloc_switch_domain(bp);
-       if (rc)
-               return rc;
-
        return rc;
 }