Skip to content

Commit 08654eb

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Change IRQ assignment for RDMA driver.
In the current code, the range of MSIX vectors allocated for the RDMA driver is disjoint from the network driver. This creates a problem for the new firmware ring reservation scheme. The new scheme requires the reserved completion rings/MSIX vectors to be in a contiguous range. Change the logic to allocate RDMA MSIX vectors to be contiguous with the vectors used by bnxt_en on new firmware using the new scheme. The new function bnxt_get_num_msix() calculates the exact number of vectors needed by both drivers. Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9899bb5 commit 08654eb

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4720,6 +4720,21 @@ static int bnxt_hwrm_reserve_rings(struct bnxt *bp, int tx, int rx, int grp,
47204720
return bnxt_hwrm_reserve_vf_rings(bp, tx, rx, grp, cp, vnic);
47214721
}
47224722

4723+
static int bnxt_cp_rings_in_use(struct bnxt *bp)
4724+
{
4725+
int cp = bp->cp_nr_rings;
4726+
int ulp_msix, ulp_base;
4727+
4728+
ulp_msix = bnxt_get_ulp_msix_num(bp);
4729+
if (ulp_msix) {
4730+
ulp_base = bnxt_get_ulp_msix_base(bp);
4731+
cp += ulp_msix;
4732+
if ((ulp_base + ulp_msix) > cp)
4733+
cp = ulp_base + ulp_msix;
4734+
}
4735+
return cp;
4736+
}
4737+
47234738
static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
47244739
bool shared);
47254740

@@ -5893,12 +5908,24 @@ void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs)
58935908
bp->hw_resc.max_irqs = max_irqs;
58945909
}
58955910

5911+
static int bnxt_get_num_msix(struct bnxt *bp)
5912+
{
5913+
if (!(bp->flags & BNXT_FLAG_NEW_RM))
5914+
return bnxt_get_max_func_irqs(bp);
5915+
5916+
return bnxt_cp_rings_in_use(bp);
5917+
}
5918+
58965919
static int bnxt_init_msix(struct bnxt *bp)
58975920
{
5898-
int i, total_vecs, rc = 0, min = 1;
5921+
int i, total_vecs, max, rc = 0, min = 1;
58995922
struct msix_entry *msix_ent;
59005923

5901-
total_vecs = bnxt_get_max_func_irqs(bp);
5924+
total_vecs = bnxt_get_num_msix(bp);
5925+
max = bnxt_get_max_func_irqs(bp);
5926+
if (total_vecs > max)
5927+
total_vecs = max;
5928+
59025929
msix_ent = kcalloc(total_vecs, sizeof(struct msix_entry), GFP_KERNEL);
59035930
if (!msix_ent)
59045931
return -ENOMEM;

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
116116
if (!(bp->flags & BNXT_FLAG_USING_MSIX))
117117
return -ENODEV;
118118

119+
if (edev->ulp_tbl[ulp_id].msix_requested)
120+
return -EAGAIN;
121+
119122
max_cp_rings = bnxt_get_max_func_cp_rings(bp);
120123
max_idx = min_t(int, bp->total_irqs, max_cp_rings);
121124
avail_msix = max_idx - bp->cp_nr_rings;
@@ -124,7 +127,11 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
124127
if (avail_msix > num_msix)
125128
avail_msix = num_msix;
126129

127-
idx = max_idx - avail_msix;
130+
if (bp->flags & BNXT_FLAG_NEW_RM)
131+
idx = bp->cp_nr_rings;
132+
else
133+
idx = max_idx - avail_msix;
134+
edev->ulp_tbl[ulp_id].msix_base = idx;
128135
for (i = 0; i < avail_msix; i++) {
129136
ent[i].vector = bp->irq_tbl[idx + i].vector;
130137
ent[i].ring_idx = idx + i;
@@ -154,6 +161,27 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id)
154161
return 0;
155162
}
156163

164+
int bnxt_get_ulp_msix_num(struct bnxt *bp)
165+
{
166+
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
167+
struct bnxt_en_dev *edev = bp->edev;
168+
169+
return edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested;
170+
}
171+
return 0;
172+
}
173+
174+
int bnxt_get_ulp_msix_base(struct bnxt *bp)
175+
{
176+
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
177+
struct bnxt_en_dev *edev = bp->edev;
178+
179+
if (edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested)
180+
return edev->ulp_tbl[BNXT_ROCE_ULP].msix_base;
181+
}
182+
return 0;
183+
}
184+
157185
void bnxt_subtract_ulp_resources(struct bnxt *bp, int ulp_id)
158186
{
159187
ASSERT_RTNL();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct bnxt_ulp {
4949
unsigned long *async_events_bmap;
5050
u16 max_async_event_id;
5151
u16 msix_requested;
52+
u16 msix_base;
5253
atomic_t ref_count;
5354
};
5455

@@ -84,6 +85,8 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)
8485
return false;
8586
}
8687

88+
int bnxt_get_ulp_msix_num(struct bnxt *bp);
89+
int bnxt_get_ulp_msix_base(struct bnxt *bp);
8790
void bnxt_subtract_ulp_resources(struct bnxt *bp, int ulp_id);
8891
void bnxt_ulp_stop(struct bnxt *bp);
8992
void bnxt_ulp_start(struct bnxt *bp);

0 commit comments

Comments
 (0)