Skip to content

Commit

Permalink
net/bnxt: fix device init error path
Browse files Browse the repository at this point in the history
[ upstream commit 7d2d64c ]

1. bnxt_dev_init() invokes bnxt_dev_uninit() on failure. So there is
   no need to do individual function cleanups in failure path.
2. rearrange the check for primary process to remove an unwanted goto.
3. fix to invoke bnxt_hwrm_func_buf_unrgtr() in bnxt_dev_uninit() when
   it is needed.

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 e8ab24b commit 65bfa74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
28 changes: 14 additions & 14 deletions drivers/net/bnxt/bnxt_ethdev.c
Expand Up @@ -3281,8 +3281,16 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)

bp->dev_stopped = 1;

eth_dev->dev_ops = &bnxt_dev_ops;
eth_dev->rx_pkt_burst = &bnxt_recv_pkts;
eth_dev->tx_pkt_burst = &bnxt_xmit_pkts;

/*
* For secondary processes, we don't initialise any further
* as primary has already done this work.
*/
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
goto skip_init;
return 0;

if (bnxt_vf_pciid(pci_dev->id.device_id))
bp->flags |= BNXT_FLAG_VF;
Expand All @@ -3293,12 +3301,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
"Board initialization failed rc: %x\n", rc);
goto error;
}
skip_init:
eth_dev->dev_ops = &bnxt_dev_ops;
eth_dev->rx_pkt_burst = &bnxt_recv_pkts;
eth_dev->tx_pkt_burst = &bnxt_xmit_pkts;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;

if (pci_dev->id.device_id != BROADCOM_DEV_ID_NS2) {
snprintf(mz_name, RTE_MEMZONE_NAMESIZE,
Expand Down Expand Up @@ -3547,21 +3549,16 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)

rc = bnxt_alloc_mem(bp);
if (rc)
goto error_free_int;
goto error_free;

rc = bnxt_request_int(bp);
if (rc)
goto error_free_int;
goto error_free;

bnxt_init_nic(bp);

return 0;

error_free_int:
bnxt_disable_int(bp);
bnxt_hwrm_func_buf_unrgtr(bp);
bnxt_free_int(bp);
bnxt_free_mem(bp);
error_free:
bnxt_dev_uninit(eth_dev);
error:
Expand All @@ -3581,6 +3578,9 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev)
bnxt_disable_int(bp);
bnxt_free_int(bp);
bnxt_free_mem(bp);

bnxt_hwrm_func_buf_unrgtr(bp);

if (bp->grp_info != NULL) {
rte_free(bp->grp_info);
bp->grp_info = NULL;
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/bnxt/bnxt_hwrm.c
Expand Up @@ -2968,6 +2968,9 @@ int bnxt_hwrm_func_buf_unrgtr(struct bnxt *bp)
struct hwrm_func_buf_unrgtr_input req = {.req_type = 0 };
struct hwrm_func_buf_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;

if (!(BNXT_PF(bp) && bp->pdev->max_vfs))
return 0;

HWRM_PREP(req, FUNC_BUF_UNRGTR, BNXT_USE_CHIMP_MB);

rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
Expand Down

0 comments on commit 65bfa74

Please sign in to comment.