From: Somnath Kotur Date: Fri, 11 Sep 2020 01:55:50 +0000 (-0700) Subject: net/bnxt: fix VFR cleanup during init failure X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=843a67f77a0035168c48309804a39509480c59f8;p=dpdk.git net/bnxt: fix VFR cleanup during init failure If VF-rep port add fails for some reason, code was rolling back all ports added so far. With some applications, there is no need to do that. Just log failure message for the VF rep port add and continue. Also include RTE_MAX_ETH_PORTS value in the bounds check as one port will be taken by the uplink port anyway Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") Cc: stable@dpdk.org Signed-off-by: Somnath Kotur Reviewed-by: Venkat Duvvuru Reviewed-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 8908885318..2a106fe7aa 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -6014,7 +6014,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, return -EINVAL; } - if (num_rep > RTE_MAX_ETHPORTS) { + if (num_rep >= RTE_MAX_ETHPORTS) { PMD_DRV_LOG(ERR, "nb_representor_ports = %d > %d MAX ETHPORTS\n", num_rep, RTE_MAX_ETHPORTS); @@ -6057,28 +6057,36 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, NULL, NULL, bnxt_vf_representor_init, &representor); - - if (!ret) { - vf_rep_eth_dev = rte_eth_dev_allocated(name); - if (!vf_rep_eth_dev) { - PMD_DRV_LOG(ERR, "Failed to find the eth_dev" - " for VF-Rep: %s.", name); - bnxt_pci_remove_dev_with_reps(backing_eth_dev); - ret = -ENODEV; - return ret; - } - PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR pci probe\n", - backing_eth_dev->data->port_id); - backing_bp->rep_info[representor.vf_id].vfr_eth_dev = - vf_rep_eth_dev; - backing_bp->num_reps++; - } else { + if (ret) { PMD_DRV_LOG(ERR, "failed to create bnxt vf " "representor %s.", name); - bnxt_pci_remove_dev_with_reps(backing_eth_dev); + goto err; } + + vf_rep_eth_dev = rte_eth_dev_allocated(name); + if (!vf_rep_eth_dev) { + PMD_DRV_LOG(ERR, "Failed to find the eth_dev" + " for VF-Rep: %s.", name); + ret = -ENODEV; + goto err; + } + + PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR pci probe\n", + backing_eth_dev->data->port_id); + backing_bp->rep_info[representor.vf_id].vfr_eth_dev = + vf_rep_eth_dev; + backing_bp->num_reps++; } + return 0; + +err: + /* If num_rep > 1, then rollback already created + * ports, since we'll be failing the probe anyway + */ + if (num_rep > 1) + bnxt_pci_remove_dev_with_reps(backing_eth_dev); + return ret; }