From: Kalesh AP Date: Thu, 18 Jul 2019 03:35:55 +0000 (+0530) Subject: net/bnxt: fix error handling in port start X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6de4c538b393d5a1414a18b2dfb83293b9c429a1;p=dpdk.git net/bnxt: fix error handling in port start 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: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur --- diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 35e50f1db0..39229f150a 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -394,8 +394,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) { @@ -406,7 +407,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", @@ -421,12 +423,14 @@ 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) { @@ -434,16 +438,18 @@ static int bnxt_init_chip(struct bnxt *bp) 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; @@ -759,7 +765,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) @@ -781,6 +786,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) eth_dev->tx_pkt_burst = bnxt_transmit_function(eth_dev); bnxt_enable_int(bp); bp->flags |= BNXT_FLAG_INIT_DONE; + bp->dev_stopped = 0; return 0; error: