Skip to content

Commit a2cea09

Browse files
Michael Changregkh
authored andcommitted
bnxt_en: Do not adjust max_cp_rings by the ones used by RDMA.
[ Upstream commit 00fe9c3 ] Currently, the driver adjusts the bp->hw_resc.max_cp_rings by the number of MSIX vectors used by RDMA. There is one code path in open that needs to check the true max_cp_rings including any used by RDMA. This code is now checking for the reduced max_cp_rings which will fail when the number of cp rings is very small. To fix this in a clean way, we don't adjust max_cp_rings anymore. Instead, we add a helper bnxt_get_max_func_cp_rings_for_en() to get the reduced max_cp_rings when appropriate. Fixes: ec86f14 ("bnxt_en: Add ULP calls to stop and restart IRQs.") Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e779d52 commit a2cea09

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5907,9 +5907,9 @@ unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp)
59075907
return bp->hw_resc.max_cp_rings;
59085908
}
59095909

5910-
void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max)
5910+
unsigned int bnxt_get_max_func_cp_rings_for_en(struct bnxt *bp)
59115911
{
5912-
bp->hw_resc.max_cp_rings = max;
5912+
return bp->hw_resc.max_cp_rings - bnxt_get_ulp_msix_num(bp);
59135913
}
59145914

59155915
static unsigned int bnxt_get_max_func_irqs(struct bnxt *bp)
@@ -8492,7 +8492,8 @@ static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx,
84928492

84938493
*max_tx = hw_resc->max_tx_rings;
84948494
*max_rx = hw_resc->max_rx_rings;
8495-
*max_cp = min_t(int, hw_resc->max_irqs, hw_resc->max_cp_rings);
8495+
*max_cp = min_t(int, bnxt_get_max_func_cp_rings_for_en(bp),
8496+
hw_resc->max_irqs);
84968497
*max_cp = min_t(int, *max_cp, hw_resc->max_stat_ctxs);
84978498
max_ring_grps = hw_resc->max_hw_ring_grps;
84988499
if (BNXT_CHIP_TYPE_NITRO_A0(bp) && BNXT_PF(bp)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ int bnxt_hwrm_set_coal(struct bnxt *);
14681468
unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
14691469
void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
14701470
unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
1471-
void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max);
1471+
unsigned int bnxt_get_max_func_cp_rings_for_en(struct bnxt *bp);
14721472
int bnxt_get_avail_msix(struct bnxt *bp, int num);
14731473
int bnxt_reserve_rings(struct bnxt *bp);
14741474
void bnxt_tx_disable(struct bnxt *bp);

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

Lines changed: 4 additions & 3 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 = hw_resc->max_cp_rings - bp->cp_nr_rings;
454+
vf_cp_rings = bnxt_get_max_func_cp_rings_for_en(bp) - bp->cp_nr_rings;
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;
@@ -544,7 +544,8 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
544544
max_stat_ctxs = hw_resc->max_stat_ctxs;
545545

546546
/* Remaining rings are distributed equally amongs VF's for now */
547-
vf_cp_rings = (hw_resc->max_cp_rings - bp->cp_nr_rings) / num_vfs;
547+
vf_cp_rings = (bnxt_get_max_func_cp_rings_for_en(bp) -
548+
bp->cp_nr_rings) / num_vfs;
548549
vf_stat_ctx = (max_stat_ctxs - bp->num_stat_ctxs) / num_vfs;
549550
if (bp->flags & BNXT_FLAG_AGG_RINGS)
550551
vf_rx_rings = (hw_resc->max_rx_rings - bp->rx_nr_rings * 2) /
@@ -638,7 +639,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
638639
*/
639640
vfs_supported = *num_vfs;
640641

641-
avail_cp = hw_resc->max_cp_rings - bp->cp_nr_rings;
642+
avail_cp = bnxt_get_max_func_cp_rings_for_en(bp) - bp->cp_nr_rings;
642643
avail_stat = hw_resc->max_stat_ctxs - bp->num_stat_ctxs;
643644
avail_cp = min_t(int, avail_cp, avail_stat);
644645

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
169169
edev->ulp_tbl[ulp_id].msix_requested = avail_msix;
170170
}
171171
bnxt_fill_msix_vecs(bp, ent);
172-
bnxt_set_max_func_cp_rings(bp, max_cp_rings - avail_msix);
173172
edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED;
174173
return avail_msix;
175174
}
@@ -178,7 +177,6 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id)
178177
{
179178
struct net_device *dev = edev->net;
180179
struct bnxt *bp = netdev_priv(dev);
181-
int max_cp_rings, msix_requested;
182180

183181
ASSERT_RTNL();
184182
if (ulp_id != BNXT_ROCE_ULP)
@@ -187,9 +185,6 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id)
187185
if (!(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
188186
return 0;
189187

190-
max_cp_rings = bnxt_get_max_func_cp_rings(bp);
191-
msix_requested = edev->ulp_tbl[ulp_id].msix_requested;
192-
bnxt_set_max_func_cp_rings(bp, max_cp_rings + msix_requested);
193188
edev->ulp_tbl[ulp_id].msix_requested = 0;
194189
edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED;
195190
if (netif_running(dev)) {

0 commit comments

Comments
 (0)