net/bnxt: fix switch domain allocation

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>
This commit is contained in:
Ajit Khaparde 2022-06-15 20:26:57 +05:30
parent d3fdd5b880
commit aef3baca15

View 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;
}