Skip to content

Commit ec86f14

Browse files
Michael Chandavem330
Michael Chan
authored andcommitted
bnxt_en: Add ULP calls to stop and restart IRQs.
When the driver needs to re-initailize the IRQ vectors, we make the new ulp_irq_stop() call to tell the RDMA driver to disable and free the IRQ vectors. After IRQ vectors have been re-initailized, we make the ulp_irq_restart() call to tell the RDMA driver that IRQs can be restarted. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fbcfc8e commit ec86f14

File tree

3 files changed

+90
-17
lines changed

3 files changed

+90
-17
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6064,8 +6064,10 @@ int bnxt_reserve_rings(struct bnxt *bp)
60646064
}
60656065
if ((bp->flags & BNXT_FLAG_NEW_RM) &&
60666066
(bnxt_get_num_msix(bp) != bp->total_irqs)) {
6067+
bnxt_ulp_irq_stop(bp);
60676068
bnxt_clear_int_mode(bp);
60686069
rc = bnxt_init_int_mode(bp);
6070+
bnxt_ulp_irq_restart(bp, rc);
60696071
if (rc)
60706072
return rc;
60716073
}
@@ -8575,16 +8577,15 @@ int bnxt_restore_pf_fw_resources(struct bnxt *bp)
85758577
int rc;
85768578

85778579
ASSERT_RTNL();
8578-
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP))
8579-
return 0;
8580-
85818580
bnxt_hwrm_func_qcaps(bp);
85828581

85838582
if (netif_running(bp->dev))
85848583
__bnxt_close_nic(bp, true, false);
85858584

8585+
bnxt_ulp_irq_stop(bp);
85868586
bnxt_clear_int_mode(bp);
85878587
rc = bnxt_init_int_mode(bp);
8588+
bnxt_ulp_irq_restart(bp, rc);
85888589

85898590
if (netif_running(bp->dev)) {
85908591
if (rc)

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

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Broadcom NetXtreme-C/E network driver.
22
*
3-
* Copyright (c) 2016 Broadcom Limited
3+
* Copyright (c) 2016-2018 Broadcom Limited
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -101,13 +101,27 @@ static int bnxt_unregister_dev(struct bnxt_en_dev *edev, int ulp_id)
101101
return 0;
102102
}
103103

104+
static void bnxt_fill_msix_vecs(struct bnxt *bp, struct bnxt_msix_entry *ent)
105+
{
106+
struct bnxt_en_dev *edev = bp->edev;
107+
int num_msix, idx, i;
108+
109+
num_msix = edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested;
110+
idx = edev->ulp_tbl[BNXT_ROCE_ULP].msix_base;
111+
for (i = 0; i < num_msix; i++) {
112+
ent[i].vector = bp->irq_tbl[idx + i].vector;
113+
ent[i].ring_idx = idx + i;
114+
ent[i].db_offset = (idx + i) * 0x80;
115+
}
116+
}
117+
104118
static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
105119
struct bnxt_msix_entry *ent, int num_msix)
106120
{
107121
struct net_device *dev = edev->net;
108122
struct bnxt *bp = netdev_priv(dev);
109123
int max_idx, max_cp_rings;
110-
int avail_msix, i, idx;
124+
int avail_msix, idx;
111125
int rc = 0;
112126

113127
ASSERT_RTNL();
@@ -154,13 +168,10 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
154168
avail_msix = hw_resc->resv_cp_rings - bp->cp_nr_rings;
155169
edev->ulp_tbl[ulp_id].msix_requested = avail_msix;
156170
}
157-
for (i = 0; i < avail_msix; i++) {
158-
ent[i].vector = bp->irq_tbl[idx + i].vector;
159-
ent[i].ring_idx = idx + i;
160-
ent[i].db_offset = (idx + i) * 0x80;
161-
}
171+
bnxt_fill_msix_vecs(bp, ent);
162172
bnxt_set_max_func_irqs(bp, bnxt_get_max_func_irqs(bp) - avail_msix);
163173
bnxt_set_max_func_cp_rings(bp, max_cp_rings - avail_msix);
174+
edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED;
164175
return avail_msix;
165176
}
166177

@@ -174,11 +185,15 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id)
174185
if (ulp_id != BNXT_ROCE_ULP)
175186
return -EINVAL;
176187

188+
if (!(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
189+
return 0;
190+
177191
max_cp_rings = bnxt_get_max_func_cp_rings(bp);
178192
msix_requested = edev->ulp_tbl[ulp_id].msix_requested;
179193
bnxt_set_max_func_cp_rings(bp, max_cp_rings + msix_requested);
180194
edev->ulp_tbl[ulp_id].msix_requested = 0;
181195
bnxt_set_max_func_irqs(bp, bnxt_get_max_func_irqs(bp) + msix_requested);
196+
edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED;
182197
if (netif_running(dev)) {
183198
bnxt_close_nic(bp, true, false);
184199
bnxt_open_nic(bp, true, false);
@@ -340,6 +355,58 @@ void bnxt_ulp_shutdown(struct bnxt *bp)
340355
}
341356
}
342357

358+
void bnxt_ulp_irq_stop(struct bnxt *bp)
359+
{
360+
struct bnxt_en_dev *edev = bp->edev;
361+
struct bnxt_ulp_ops *ops;
362+
363+
if (!edev || !(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
364+
return;
365+
366+
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
367+
struct bnxt_ulp *ulp = &edev->ulp_tbl[BNXT_ROCE_ULP];
368+
369+
if (!ulp->msix_requested)
370+
return;
371+
372+
ops = rtnl_dereference(ulp->ulp_ops);
373+
if (!ops || !ops->ulp_irq_stop)
374+
return;
375+
ops->ulp_irq_stop(ulp->handle);
376+
}
377+
}
378+
379+
void bnxt_ulp_irq_restart(struct bnxt *bp, int err)
380+
{
381+
struct bnxt_en_dev *edev = bp->edev;
382+
struct bnxt_ulp_ops *ops;
383+
384+
if (!edev || !(edev->flags & BNXT_EN_FLAG_MSIX_REQUESTED))
385+
return;
386+
387+
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
388+
struct bnxt_ulp *ulp = &edev->ulp_tbl[BNXT_ROCE_ULP];
389+
struct bnxt_msix_entry *ent = NULL;
390+
391+
if (!ulp->msix_requested)
392+
return;
393+
394+
ops = rtnl_dereference(ulp->ulp_ops);
395+
if (!ops || !ops->ulp_irq_restart)
396+
return;
397+
398+
if (!err) {
399+
ent = kcalloc(ulp->msix_requested, sizeof(*ent),
400+
GFP_KERNEL);
401+
if (!ent)
402+
return;
403+
bnxt_fill_msix_vecs(bp, ent);
404+
}
405+
ops->ulp_irq_restart(ulp->handle, ent);
406+
kfree(ent);
407+
}
408+
}
409+
343410
void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl)
344411
{
345412
u16 event_id = le16_to_cpu(cmpl->event_id);

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Broadcom NetXtreme-C/E network driver.
22
*
3-
* Copyright (c) 2016 Broadcom Limited
3+
* Copyright (c) 2016-2018 Broadcom Limited
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -20,19 +20,21 @@
2020
struct hwrm_async_event_cmpl;
2121
struct bnxt;
2222

23+
struct bnxt_msix_entry {
24+
u32 vector;
25+
u32 ring_idx;
26+
u32 db_offset;
27+
};
28+
2329
struct bnxt_ulp_ops {
2430
/* async_notifier() cannot sleep (in BH context) */
2531
void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *);
2632
void (*ulp_stop)(void *);
2733
void (*ulp_start)(void *);
2834
void (*ulp_sriov_config)(void *, int);
2935
void (*ulp_shutdown)(void *);
30-
};
31-
32-
struct bnxt_msix_entry {
33-
u32 vector;
34-
u32 ring_idx;
35-
u32 db_offset;
36+
void (*ulp_irq_stop)(void *);
37+
void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *);
3638
};
3739

3840
struct bnxt_fw_msg {
@@ -61,6 +63,7 @@ struct bnxt_en_dev {
6163
#define BNXT_EN_FLAG_ROCEV2_CAP 0x2
6264
#define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \
6365
BNXT_EN_FLAG_ROCEV2_CAP)
66+
#define BNXT_EN_FLAG_MSIX_REQUESTED 0x4
6467
const struct bnxt_en_ops *en_ops;
6568
struct bnxt_ulp ulp_tbl[BNXT_MAX_ULP];
6669
};
@@ -92,6 +95,8 @@ void bnxt_ulp_stop(struct bnxt *bp);
9295
void bnxt_ulp_start(struct bnxt *bp);
9396
void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
9497
void bnxt_ulp_shutdown(struct bnxt *bp);
98+
void bnxt_ulp_irq_stop(struct bnxt *bp);
99+
void bnxt_ulp_irq_restart(struct bnxt *bp, int err);
95100
void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
96101
struct bnxt_en_dev *bnxt_ulp_probe(struct net_device *dev);
97102

0 commit comments

Comments
 (0)