Commit 92268c32 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Cleanup bnxt_hwrm_func_cfg().

1. Use local variable pf for repeated access to this pointer.

2.  The 2nd argument num_vfs was unnecessarily declared as pointer to int.
This function doesn't change num_vfs so change the argument to int.
Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2bcfa6f6
...@@ -363,7 +363,7 @@ static int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp) ...@@ -363,7 +363,7 @@ static int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp)
} }
/* only call by PF to reserve resources for VF */ /* only call by PF to reserve resources for VF */
static int bnxt_hwrm_func_cfg(struct bnxt *bp, int *num_vfs) static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
{ {
u32 rc = 0, mtu, i; u32 rc = 0, mtu, i;
u16 vf_tx_rings, vf_rx_rings, vf_cp_rings, vf_stat_ctx, vf_vnics; u16 vf_tx_rings, vf_rx_rings, vf_cp_rings, vf_stat_ctx, vf_vnics;
...@@ -378,18 +378,17 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int *num_vfs) ...@@ -378,18 +378,17 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int *num_vfs)
* be removed once new HWRM provides HW ring groups capability in * be removed once new HWRM provides HW ring groups capability in
* hwrm_func_qcap. * hwrm_func_qcap.
*/ */
vf_cp_rings = min_t(u16, bp->pf.max_cp_rings, bp->pf.max_stat_ctxs); vf_cp_rings = min_t(u16, pf->max_cp_rings, pf->max_stat_ctxs);
vf_cp_rings = (vf_cp_rings - bp->cp_nr_rings) / *num_vfs; vf_cp_rings = (vf_cp_rings - bp->cp_nr_rings) / num_vfs;
/* TODO: restore this logic below once the WA above is removed */ /* TODO: restore this logic below once the WA above is removed */
/* vf_cp_rings = (bp->pf.max_cp_rings - bp->cp_nr_rings) / *num_vfs; */ /* vf_cp_rings = (pf->max_cp_rings - bp->cp_nr_rings) / num_vfs; */
vf_stat_ctx = (bp->pf.max_stat_ctxs - bp->num_stat_ctxs) / *num_vfs; vf_stat_ctx = (pf->max_stat_ctxs - bp->num_stat_ctxs) / num_vfs;
if (bp->flags & BNXT_FLAG_AGG_RINGS) if (bp->flags & BNXT_FLAG_AGG_RINGS)
vf_rx_rings = (bp->pf.max_rx_rings - bp->rx_nr_rings * 2) / vf_rx_rings = (pf->max_rx_rings - bp->rx_nr_rings * 2) /
*num_vfs; num_vfs;
else else
vf_rx_rings = (bp->pf.max_rx_rings - bp->rx_nr_rings) / vf_rx_rings = (pf->max_rx_rings - bp->rx_nr_rings) / num_vfs;
*num_vfs; vf_tx_rings = (pf->max_tx_rings - bp->tx_nr_rings) / num_vfs;
vf_tx_rings = (bp->pf.max_tx_rings - bp->tx_nr_rings) / *num_vfs;
req.enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_MTU | req.enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_MTU |
FUNC_CFG_REQ_ENABLES_MRU | FUNC_CFG_REQ_ENABLES_MRU |
...@@ -417,22 +416,22 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int *num_vfs) ...@@ -417,22 +416,22 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int *num_vfs)
req.num_stat_ctxs = cpu_to_le16(vf_stat_ctx); req.num_stat_ctxs = cpu_to_le16(vf_stat_ctx);
mutex_lock(&bp->hwrm_cmd_lock); mutex_lock(&bp->hwrm_cmd_lock);
for (i = 0; i < *num_vfs; i++) { for (i = 0; i < num_vfs; i++) {
req.vf_id = cpu_to_le16(pf->first_vf_id + i); req.vf_id = cpu_to_le16(pf->first_vf_id + i);
rc = _hwrm_send_message(bp, &req, sizeof(req), rc = _hwrm_send_message(bp, &req, sizeof(req),
HWRM_CMD_TIMEOUT); HWRM_CMD_TIMEOUT);
if (rc) if (rc)
break; break;
bp->pf.active_vfs = i + 1; pf->active_vfs = i + 1;
bp->pf.vf[i].fw_fid = le16_to_cpu(req.vf_id); pf->vf[i].fw_fid = le16_to_cpu(req.vf_id);
} }
mutex_unlock(&bp->hwrm_cmd_lock); mutex_unlock(&bp->hwrm_cmd_lock);
if (!rc) { if (!rc) {
bp->pf.max_pf_tx_rings = bp->tx_nr_rings; pf->max_pf_tx_rings = bp->tx_nr_rings;
if (bp->flags & BNXT_FLAG_AGG_RINGS) if (bp->flags & BNXT_FLAG_AGG_RINGS)
bp->pf.max_pf_rx_rings = bp->rx_nr_rings * 2; pf->max_pf_rx_rings = bp->rx_nr_rings * 2;
else else
bp->pf.max_pf_rx_rings = bp->rx_nr_rings; pf->max_pf_rx_rings = bp->rx_nr_rings;
} }
return rc; return rc;
} }
...@@ -492,7 +491,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs) ...@@ -492,7 +491,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
goto err_out1; goto err_out1;
/* Reserve resources for VFs */ /* Reserve resources for VFs */
rc = bnxt_hwrm_func_cfg(bp, num_vfs); rc = bnxt_hwrm_func_cfg(bp, *num_vfs);
if (rc) if (rc)
goto err_out2; goto err_out2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment