Skip to content

Commit

Permalink
net/bnxt: fix error handling in port start
Browse files Browse the repository at this point in the history
[ upstream commit 6de4c53 ]

1. during port start, if bnxt_init_chip() return error
   bnxt_dev_start_op() invokes bnxt_shutdown_nic() which in turn calls
   bnxt_free_all_hwrm_resources() to free up resources. Hence remove the
   bnxt_free_all_hwrm_resources() from bnxt_init_chip() failure path.
2. fix to check the return value of rte_intr_enable() as this call
   can fail.
3. set bp->dev_stopped to 0 only when port start succeeds.
4. handle failure cases in bnxt_init_chip() routine to do proper
   cleanup and return correct error value.

Fixes: b7778e8 ("net/bnxt: refactor to properly allocate resources for PF/VF")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
  • Loading branch information
Kalesh AP authored and kevintraynor committed Aug 28, 2019
1 parent 6c08109 commit 0a273ad
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions drivers/net/bnxt/bnxt_ethdev.c
Expand Up @@ -354,8 +354,9 @@ static int bnxt_init_chip(struct bnxt *bp)
bp->rx_cp_nr_rings);
return -ENOTSUP;
}
if (rte_intr_efd_enable(intr_handle, intr_vector))
return -1;
rc = rte_intr_efd_enable(intr_handle, intr_vector);
if (rc)
return rc;
}

if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
Expand All @@ -366,7 +367,8 @@ static int bnxt_init_chip(struct bnxt *bp)
if (intr_handle->intr_vec == NULL) {
PMD_DRV_LOG(ERR, "Failed to allocate %d rx_queues"
" intr_vec", bp->eth_dev->data->nb_rx_queues);
return -ENOMEM;
rc = -ENOMEM;
goto err_disable;
}
PMD_DRV_LOG(DEBUG, "intr_handle->intr_vec = %p "
"intr_handle->nb_efd = %d intr_handle->max_intr = %d\n",
Expand All @@ -381,29 +383,33 @@ static int bnxt_init_chip(struct bnxt *bp)
}

/* enable uio/vfio intr/eventfd mapping */
rte_intr_enable(intr_handle);
rc = rte_intr_enable(intr_handle);
if (rc)
goto err_free;

rc = bnxt_get_hwrm_link_config(bp, &new);
if (rc) {
PMD_DRV_LOG(ERR, "HWRM Get link config failure rc: %x\n", rc);
goto err_out;
goto err_free;
}

if (!bp->link_info.link_up) {
rc = bnxt_set_hwrm_link_config(bp, true);
if (rc) {
PMD_DRV_LOG(ERR,
"HWRM link config failure rc: %x\n", rc);
goto err_out;
goto err_free;
}
}
bnxt_print_link_info(bp->eth_dev);

return 0;

err_free:
rte_free(intr_handle->intr_vec);
err_disable:
rte_intr_efd_disable(intr_handle);
err_out:
bnxt_free_all_hwrm_resources(bp);

/* Some of the error status returned by FW may not be from errno.h */
if (rc > 0)
rc = -EIO;
Expand Down Expand Up @@ -629,7 +635,6 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
"RxQ cnt %d > CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS %d\n",
bp->rx_cp_nr_rings, RTE_ETHDEV_QUEUE_STAT_CNTRS);
}
bp->dev_stopped = 0;

rc = bnxt_init_chip(bp);
if (rc)
Expand All @@ -647,6 +652,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)

bnxt_enable_int(bp);
bp->flags |= BNXT_FLAG_INIT_DONE;
bp->dev_stopped = 0;
return 0;

error:
Expand Down

0 comments on commit 0a273ad

Please sign in to comment.