Skip to content

Commit

Permalink
net/bnxt: fix return values to standard error codes
Browse files Browse the repository at this point in the history
[ upstream commit e67daab ]

Fixed the return values of few routines to return standard error code.
Also fixed few error logs to more meaningful one.

Fixes: 804e746 ("net/bnxt: add hardware resource manager init code")
Fixes: e3d8f1e ("net/bnxt: cache address of doorbell to subsequent access")
Fixes: 19e6af0 ("net/bnxt: support get/set EEPROM")
Fixes: b7435d6 ("net/bnxt: add ntuple filtering support")

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 34210b2 commit 1f49e67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 54 deletions.
44 changes: 8 additions & 36 deletions drivers/net/bnxt/bnxt_ethdev.c
Expand Up @@ -1973,7 +1973,7 @@ bnxt_ethertype_filter(struct rte_eth_dev *dev,

filter1 = bnxt_get_l2_filter(bp, bfilter, vnic0);
if (filter1 == NULL) {
ret = -1;
ret = -EINVAL;
goto cleanup;
}
bfilter->enables |=
Expand Down Expand Up @@ -2167,7 +2167,7 @@ bnxt_cfg_ntuple_filter(struct bnxt *bp,
vnic0 = &bp->vnic_info[0];
filter1 = STAILQ_FIRST(&vnic0->filter);
if (filter1 == NULL) {
ret = -1;
ret = -EINVAL;
goto free_filter;
}

Expand Down Expand Up @@ -3107,7 +3107,6 @@ bnxt_set_eeprom_op(struct rte_eth_dev *dev,

return bnxt_hwrm_flash_nvram(bp, type, ordinal, ext, attr,
in_eeprom->data, in_eeprom->length);
return 0;
}

/*
Expand Down Expand Up @@ -3209,48 +3208,21 @@ bool bnxt_stratus_device(struct bnxt *bp)

static int bnxt_init_board(struct rte_eth_dev *eth_dev)
{
struct bnxt *bp = eth_dev->data->dev_private;
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
int rc;
struct bnxt *bp = eth_dev->data->dev_private;

/* enable device (incl. PCI PM wakeup), and bus-mastering */
if (!pci_dev->mem_resource[0].addr) {
PMD_DRV_LOG(ERR,
"Cannot find PCI device base address, aborting\n");
rc = -ENODEV;
goto init_err_disable;
bp->bar0 = (void *)pci_dev->mem_resource[0].addr;
bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr;
if (!bp->bar0 || !bp->doorbell_base) {
PMD_DRV_LOG(ERR, "Unable to access Hardware\n");
return -ENODEV;
}

bp->eth_dev = eth_dev;
bp->pdev = pci_dev;

bp->bar0 = (void *)pci_dev->mem_resource[0].addr;
if (!bp->bar0) {
PMD_DRV_LOG(ERR, "Cannot map device registers, aborting\n");
rc = -ENOMEM;
goto init_err_release;
}

if (!pci_dev->mem_resource[2].addr) {
PMD_DRV_LOG(ERR,
"Cannot find PCI device BAR 2 address, aborting\n");
rc = -ENODEV;
goto init_err_release;
} else {
bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr;
}

return 0;

init_err_release:
if (bp->bar0)
bp->bar0 = NULL;
if (bp->doorbell_base)
bp->doorbell_base = NULL;

init_err_disable:

return rc;
}


Expand Down
30 changes: 12 additions & 18 deletions drivers/net/bnxt/bnxt_hwrm.c
Expand Up @@ -139,14 +139,11 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
}

if (i >= HWRM_CMD_TIMEOUT) {
PMD_DRV_LOG(ERR, "Error sending msg 0x%04x\n",
req->req_type);
goto err_ret;
PMD_DRV_LOG(ERR, "Error(timeout) sending msg 0x%04x\n",
req->req_type);
return -ETIMEDOUT;
}
return 0;

err_ret:
return -1;
}

/*
Expand Down Expand Up @@ -1133,7 +1130,7 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp,
PMD_DRV_LOG(ERR, "hwrm alloc invalid ring type %d\n",
ring_type);
HWRM_UNLOCK();
return -1;
return -EINVAL;
}
req.enables = rte_cpu_to_le_32(enables);

Expand Down Expand Up @@ -2702,7 +2699,7 @@ int bnxt_hwrm_allocate_pf_only(struct bnxt *bp)

if (!BNXT_PF(bp)) {
PMD_DRV_LOG(ERR, "Attempt to allcoate VFs on a VF!\n");
return -1;
return -EINVAL;
}

rc = bnxt_hwrm_func_qcaps(bp);
Expand All @@ -2729,7 +2726,7 @@ int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs)

if (!BNXT_PF(bp)) {
PMD_DRV_LOG(ERR, "Attempt to allcoate VFs on a VF!\n");
return -1;
return -EINVAL;
}

rc = bnxt_hwrm_func_qcaps(bp);
Expand Down Expand Up @@ -3581,10 +3578,9 @@ int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf,
vnic_id_sz = bp->pf.total_vnics * sizeof(*vnic_ids);
vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
RTE_CACHE_LINE_SIZE);
if (vnic_ids == NULL) {
rc = -ENOMEM;
return rc;
}
if (vnic_ids == NULL)
return -ENOMEM;

for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
rte_mem_lock_page(((char *)vnic_ids) + sz);

Expand Down Expand Up @@ -3651,10 +3647,8 @@ int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf)
vnic_id_sz = bp->pf.total_vnics * sizeof(*vnic_ids);
vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
RTE_CACHE_LINE_SIZE);
if (vnic_ids == NULL) {
rc = -ENOMEM;
return rc;
}
if (vnic_ids == NULL)
return -ENOMEM;

for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
rte_mem_lock_page(((char *)vnic_ids) + sz);
Expand Down Expand Up @@ -3685,7 +3679,7 @@ int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf)
PMD_DRV_LOG(ERR, "No default VNIC\n");
exit:
rte_free(vnic_ids);
return -1;
return rc;
}

int bnxt_hwrm_set_em_filter(struct bnxt *bp,
Expand Down

0 comments on commit 1f49e67

Please sign in to comment.