Skip to content

Commit e916b08

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add bnxt_get_avail_cp_rings_for_en() helper function.
The available CP rings are calculated differently on the new 57500 chips, so add this helper to do this calculation correctly. The VFs will be assigned these available CP rings. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f7588cd commit e916b08

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7045,7 +7045,7 @@ unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp)
70457045
return bp->hw_resc.max_cp_rings;
70467046
}
70477047

7048-
unsigned int bnxt_get_max_func_cp_rings_for_en(struct bnxt *bp)
7048+
static unsigned int bnxt_get_max_func_cp_rings_for_en(struct bnxt *bp)
70497049
{
70507050
unsigned int cp = bp->hw_resc.max_cp_rings;
70517051

@@ -7070,6 +7070,17 @@ static void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs)
70707070
bp->hw_resc.max_irqs = max_irqs;
70717071
}
70727072

7073+
unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp)
7074+
{
7075+
unsigned int cp;
7076+
7077+
cp = bnxt_get_max_func_cp_rings_for_en(bp);
7078+
if (bp->flags & BNXT_FLAG_CHIP_P5)
7079+
return cp - bp->rx_nr_rings - bp->tx_nr_rings;
7080+
else
7081+
return cp - bp->cp_nr_rings;
7082+
}
7083+
70737084
int bnxt_get_avail_msix(struct bnxt *bp, int num)
70747085
{
70757086
int max_cp = bnxt_get_max_func_cp_rings(bp);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ int bnxt_hwrm_set_coal(struct bnxt *);
16911691
unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
16921692
void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
16931693
unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
1694-
unsigned int bnxt_get_max_func_cp_rings_for_en(struct bnxt *bp);
1694+
unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp);
16951695
int bnxt_get_avail_msix(struct bnxt *bp, int num);
16961696
int bnxt_reserve_rings(struct bnxt *bp);
16971697
void bnxt_tx_disable(struct bnxt *bp);

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
451451

452452
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_RESOURCE_CFG, -1, -1);
453453

454-
vf_cp_rings = bnxt_get_max_func_cp_rings_for_en(bp) - bp->cp_nr_rings;
454+
vf_cp_rings = bnxt_get_avail_cp_rings_for_en(bp);
455455
vf_stat_ctx = hw_resc->max_stat_ctxs - bp->num_stat_ctxs;
456456
if (bp->flags & BNXT_FLAG_AGG_RINGS)
457457
vf_rx_rings = hw_resc->max_rx_rings - bp->rx_nr_rings * 2;
@@ -549,8 +549,7 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
549549
max_stat_ctxs = hw_resc->max_stat_ctxs;
550550

551551
/* Remaining rings are distributed equally amongs VF's for now */
552-
vf_cp_rings = (bnxt_get_max_func_cp_rings_for_en(bp) -
553-
bp->cp_nr_rings) / num_vfs;
552+
vf_cp_rings = bnxt_get_avail_cp_rings_for_en(bp) / num_vfs;
554553
vf_stat_ctx = (max_stat_ctxs - bp->num_stat_ctxs) / num_vfs;
555554
if (bp->flags & BNXT_FLAG_AGG_RINGS)
556555
vf_rx_rings = (hw_resc->max_rx_rings - bp->rx_nr_rings * 2) /
@@ -644,7 +643,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
644643
*/
645644
vfs_supported = *num_vfs;
646645

647-
avail_cp = bnxt_get_max_func_cp_rings_for_en(bp) - bp->cp_nr_rings;
646+
avail_cp = bnxt_get_avail_cp_rings_for_en(bp);
648647
avail_stat = hw_resc->max_stat_ctxs - bp->num_stat_ctxs;
649648
avail_cp = min_t(int, avail_cp, avail_stat);
650649

0 commit comments

Comments
 (0)