diff options
author | Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com> | 2024-02-21 00:03:12 +0100 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-02-22 15:31:23 +0100 |
commit | 8c81ae6c54c1273a1e08b10e1e2aa5bc321af10c (patch) | |
tree | 4f2fc51d19739222f1763a2a7e1ab326b1265685 /drivers/net/ethernet/broadcom | |
parent | bnxt_en: Check additional resources in bnxt_check_rings() (diff) | |
download | linux-8c81ae6c54c1273a1e08b10e1e2aa5bc321af10c.tar.xz linux-8c81ae6c54c1273a1e08b10e1e2aa5bc321af10c.zip |
bnxt_en: Add bnxt_get_total_vnics() to calculate number of VNICs
Refactor the code by adding a new function to calculate the number of
required VNICs. This is used in multiple places when reserving or
checking resources.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers/net/ethernet/broadcom')
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 71ac165dfb52..95af3cd7dba0 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7308,13 +7308,22 @@ static void bnxt_check_rss_tbl_no_rmgr(struct bnxt *bp) } } +static int bnxt_get_total_vnics(struct bnxt *bp, int rx_rings) +{ + if (bp->flags & BNXT_FLAG_RFS) { + if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) + return rx_rings + 1; + } + return 1; +} + static bool bnxt_need_reserve_rings(struct bnxt *bp) { struct bnxt_hw_resc *hw_resc = &bp->hw_resc; int cp = bnxt_cp_rings_in_use(bp); int nq = bnxt_nq_rings_in_use(bp); int rx = bp->rx_nr_rings, stat; - int vnic = 1, grp = rx; + int vnic, grp = rx; if (hw_resc->resv_tx_rings != bp->tx_nr_rings && bp->hwrm_spec_code >= 0x10601) @@ -7329,9 +7338,9 @@ static bool bnxt_need_reserve_rings(struct bnxt *bp) bnxt_check_rss_tbl_no_rmgr(bp); return false; } - if ((bp->flags & BNXT_FLAG_RFS) && - !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) - vnic = rx + 1; + + vnic = bnxt_get_total_vnics(bp, rx); + if (bp->flags & BNXT_FLAG_AGG_RINGS) rx <<= 1; stat = bnxt_get_func_stat_ctxs(bp); @@ -7382,13 +7391,13 @@ static int __bnxt_reserve_rings(struct bnxt *bp) hwr.cp = bnxt_nq_rings_in_use(bp); hwr.tx = bp->tx_nr_rings; hwr.rx = bp->rx_nr_rings; - hwr.vnic = 1; if (bp->flags & BNXT_FLAG_SHARED_RINGS) sh = true; if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) hwr.cp_p5 = hwr.rx + hwr.tx; - else if (bp->flags & BNXT_FLAG_RFS) - hwr.vnic = hwr.rx + 1; + + hwr.vnic = bnxt_get_total_vnics(bp, hwr.rx); + if (bp->flags & BNXT_FLAG_AGG_RINGS) hwr.rx <<= 1; hwr.grp = bp->rx_nr_rings; @@ -13326,10 +13335,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, if (max_tx < hwr.tx) return -ENOMEM; - hwr.vnic = 1; - if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5_PLUS)) == - BNXT_FLAG_RFS) - hwr.vnic += rx; + hwr.vnic = bnxt_get_total_vnics(bp, rx); tx_cp = __bnxt_num_tx_to_cp(bp, hwr.tx, tx_sets, tx_xdp); hwr.cp = sh ? max_t(int, tx_cp, rx) : tx_cp + rx; |