Skip to content

Commit d630624

Browse files
vikasbrcmkuba-moo
authored andcommitted
bnxt_en: Utilize ulp client resources if RoCE is not registered
If the RoCE driver is not registered for a RoCE capable device, add flexibility to use the RoCE resources (MSIX/NQs) for L2 purposes, such as additional rings configured by the user or for XDP. Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com> Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://lore.kernel.org/r/20240409215431.41424-7-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2e4592d commit d630624

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7470,14 +7470,27 @@ static bool bnxt_rings_ok(struct bnxt *bp, struct bnxt_hw_rings *hwr)
74707470
static int __bnxt_reserve_rings(struct bnxt *bp)
74717471
{
74727472
struct bnxt_hw_rings hwr = {0};
7473+
int cp = bp->cp_nr_rings;
74737474
int rx_rings, rc;
7475+
int ulp_msix = 0;
74747476
bool sh = false;
74757477
int tx_cp;
74767478

74777479
if (!bnxt_need_reserve_rings(bp))
74787480
return 0;
74797481

7480-
hwr.cp = bnxt_nq_rings_in_use(bp);
7482+
if (!bnxt_ulp_registered(bp->edev)) {
7483+
ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
7484+
if (!ulp_msix)
7485+
bnxt_set_ulp_stat_ctxs(bp, 0);
7486+
7487+
if (ulp_msix > bp->ulp_num_msix_want)
7488+
ulp_msix = bp->ulp_num_msix_want;
7489+
hwr.cp = cp + ulp_msix;
7490+
} else {
7491+
hwr.cp = bnxt_nq_rings_in_use(bp);
7492+
}
7493+
74817494
hwr.tx = bp->tx_nr_rings;
74827495
hwr.rx = bp->rx_nr_rings;
74837496
if (bp->flags & BNXT_FLAG_SHARED_RINGS)
@@ -7550,12 +7563,11 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
75507563
bnxt_set_dflt_rss_indir_tbl(bp, NULL);
75517564

75527565
if (!bnxt_ulp_registered(bp->edev) && BNXT_NEW_RM(bp)) {
7553-
int resv_msix, resv_ctx, ulp_msix, ulp_ctxs;
7566+
int resv_msix, resv_ctx, ulp_ctxs;
75547567
struct bnxt_hw_resc *hw_resc;
75557568

75567569
hw_resc = &bp->hw_resc;
75577570
resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings;
7558-
ulp_msix = bnxt_get_ulp_msix_num(bp);
75597571
ulp_msix = min_t(int, resv_msix, ulp_msix);
75607572
bnxt_set_ulp_msix_num(bp, ulp_msix);
75617573
resv_ctx = hw_resc->resv_stat_ctxs - bp->cp_nr_rings;
@@ -10609,13 +10621,23 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
1060910621
{
1061010622
bool irq_cleared = false;
1061110623
int tcs = bp->num_tc;
10624+
int irqs_required;
1061210625
int rc;
1061310626

1061410627
if (!bnxt_need_reserve_rings(bp))
1061510628
return 0;
1061610629

10617-
if (irq_re_init && BNXT_NEW_RM(bp) &&
10618-
bnxt_get_num_msix(bp) != bp->total_irqs) {
10630+
if (!bnxt_ulp_registered(bp->edev)) {
10631+
int ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
10632+
10633+
if (ulp_msix > bp->ulp_num_msix_want)
10634+
ulp_msix = bp->ulp_num_msix_want;
10635+
irqs_required = ulp_msix + bp->cp_nr_rings;
10636+
} else {
10637+
irqs_required = bnxt_get_num_msix(bp);
10638+
}
10639+
10640+
if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) {
1061910641
bnxt_ulp_irq_stop(bp);
1062010642
bnxt_clear_int_mode(bp);
1062110643
irq_cleared = true;
@@ -13625,8 +13647,8 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
1362513647
return -ENOMEM;
1362613648
hwr.stat = hwr.cp;
1362713649
if (BNXT_NEW_RM(bp)) {
13628-
hwr.cp += bnxt_get_ulp_msix_num(bp);
13629-
hwr.stat += bnxt_get_ulp_stat_ctxs(bp);
13650+
hwr.cp += bnxt_get_ulp_msix_num_in_use(bp);
13651+
hwr.stat += bnxt_get_ulp_stat_ctxs_in_use(bp);
1363013652
hwr.grp = rx;
1363113653
hwr.rss_ctx = bnxt_get_total_rss_ctxs(bp, &hwr);
1363213654
}
@@ -14899,8 +14921,9 @@ static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx,
1489914921
*max_rx = hw_resc->max_rx_rings;
1490014922
*max_cp = bnxt_get_max_func_cp_rings_for_en(bp);
1490114923
max_irq = min_t(int, bnxt_get_max_func_irqs(bp) -
14902-
bnxt_get_ulp_msix_num(bp),
14903-
hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp));
14924+
bnxt_get_ulp_msix_num_in_use(bp),
14925+
hw_resc->max_stat_ctxs -
14926+
bnxt_get_ulp_stat_ctxs_in_use(bp));
1490414927
if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
1490514928
*max_cp = min_t(int, *max_cp, max_irq);
1490614929
max_ring_grps = hw_resc->max_hw_ring_grps;

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ void bnxt_set_ulp_msix_num(struct bnxt *bp, int num)
6161
bp->edev->ulp_num_msix_vec = num;
6262
}
6363

64+
int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp)
65+
{
66+
if (bnxt_ulp_registered(bp->edev))
67+
return bp->edev->ulp_num_msix_vec;
68+
return 0;
69+
}
70+
6471
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
6572
{
6673
if (bp->edev)
@@ -74,6 +81,13 @@ void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ulp_ctx)
7481
bp->edev->ulp_num_ctxs = num_ulp_ctx;
7582
}
7683

84+
int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp)
85+
{
86+
if (bnxt_ulp_registered(bp->edev))
87+
return bp->edev->ulp_num_ctxs;
88+
return 0;
89+
}
90+
7791
void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp)
7892
{
7993
if (bp->edev) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
9898
}
9999

100100
int bnxt_get_ulp_msix_num(struct bnxt *bp);
101+
int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp);
101102
void bnxt_set_ulp_msix_num(struct bnxt *bp, int num);
102103
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
103104
void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ctxs);
105+
int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp);
104106
void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp);
105107
void bnxt_ulp_stop(struct bnxt *bp);
106108
void bnxt_ulp_start(struct bnxt *bp, int err);

0 commit comments

Comments
 (0)