Skip to content

Commit 3e0d3cb

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice, irdma: move interrupts code to irdma
Move responsibility of MSI-X requesting for RDMA feature from ice driver to irdma driver. It is done to allow simple fallback when there is not enough MSI-X available. Change amount of MSI-X used for control from 4 to 1, as it isn't needed to have more than one MSI-X for this purpose. Reviewed-by: Jacob Keller <[email protected]> Signed-off-by: Michal Swiatkowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent ad61cd9 commit 3e0d3cb

File tree

7 files changed

+65
-56
lines changed

7 files changed

+65
-56
lines changed

drivers/infiniband/hw/irdma/hw.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,6 @@ static int irdma_save_msix_info(struct irdma_pci_f *rf)
498498
iw_qvlist->num_vectors = rf->msix_count;
499499
if (rf->msix_count <= num_online_cpus())
500500
rf->msix_shared = true;
501-
else if (rf->msix_count > num_online_cpus() + 1)
502-
rf->msix_count = num_online_cpus() + 1;
503501

504502
pmsix = rf->msix_entries;
505503
for (i = 0, ceq_idx = 0; i < rf->msix_count; i++, iw_qvinfo++) {

drivers/infiniband/hw/irdma/main.c

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,43 @@ static void irdma_lan_unregister_qset(struct irdma_sc_vsi *vsi,
206206
ibdev_dbg(&iwdev->ibdev, "WS: LAN free_res for rdma qset failed.\n");
207207
}
208208

209+
static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
210+
{
211+
int i;
212+
213+
rf->msix_count = num_online_cpus() + IRDMA_NUM_AEQ_MSIX;
214+
rf->msix_entries = kcalloc(rf->msix_count, sizeof(*rf->msix_entries),
215+
GFP_KERNEL);
216+
if (!rf->msix_entries)
217+
return -ENOMEM;
218+
219+
for (i = 0; i < rf->msix_count; i++)
220+
if (ice_alloc_rdma_qvector(pf, &rf->msix_entries[i]))
221+
break;
222+
223+
if (i < IRDMA_MIN_MSIX) {
224+
for (; i > 0; i--)
225+
ice_free_rdma_qvector(pf, &rf->msix_entries[i]);
226+
227+
kfree(rf->msix_entries);
228+
return -ENOMEM;
229+
}
230+
231+
rf->msix_count = i;
232+
233+
return 0;
234+
}
235+
236+
static void irdma_deinit_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
237+
{
238+
int i;
239+
240+
for (i = 0; i < rf->msix_count; i++)
241+
ice_free_rdma_qvector(pf, &rf->msix_entries[i]);
242+
243+
kfree(rf->msix_entries);
244+
}
245+
209246
static void irdma_remove(struct auxiliary_device *aux_dev)
210247
{
211248
struct iidc_auxiliary_dev *iidc_adev = container_of(aux_dev,
@@ -216,6 +253,7 @@ static void irdma_remove(struct auxiliary_device *aux_dev)
216253

217254
irdma_ib_unregister_device(iwdev);
218255
ice_rdma_update_vsi_filter(pf, iwdev->vsi_num, false);
256+
irdma_deinit_interrupts(iwdev->rf, pf);
219257

220258
pr_debug("INIT: Gen2 PF[%d] device remove success\n", PCI_FUNC(pf->pdev->devfn));
221259
}
@@ -230,9 +268,7 @@ static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf
230268
rf->gen_ops.unregister_qset = irdma_lan_unregister_qset;
231269
rf->hw.hw_addr = pf->hw.hw_addr;
232270
rf->pcidev = pf->pdev;
233-
rf->msix_count = pf->num_rdma_msix;
234271
rf->pf_id = pf->hw.pf_id;
235-
rf->msix_entries = &pf->msix_entries[pf->rdma_base_vector];
236272
rf->default_vsi.vsi_idx = vsi->vsi_num;
237273
rf->protocol_used = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ?
238274
IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY;
@@ -281,6 +317,10 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
281317
irdma_fill_device_info(iwdev, pf, vsi);
282318
rf = iwdev->rf;
283319

320+
err = irdma_init_interrupts(rf, pf);
321+
if (err)
322+
goto err_init_interrupts;
323+
284324
err = irdma_ctrl_init_hw(rf);
285325
if (err)
286326
goto err_ctrl_init;
@@ -311,6 +351,8 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
311351
err_rt_init:
312352
irdma_ctrl_deinit_hw(rf);
313353
err_ctrl_init:
354+
irdma_deinit_interrupts(rf, pf);
355+
err_init_interrupts:
314356
kfree(iwdev->rf);
315357
ib_dealloc_device(&iwdev->ibdev);
316358

drivers/infiniband/hw/irdma/main.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ extern struct auxiliary_driver i40iw_auxiliary_drv;
117117

118118
#define IRDMA_IRQ_NAME_STR_LEN (64)
119119

120+
#define IRDMA_NUM_AEQ_MSIX 1
121+
#define IRDMA_MIN_MSIX 2
122+
120123
enum init_completion_state {
121124
INVALID_STATE = 0,
122125
INITIAL_STATE,

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
#define ICE_MIN_LAN_OICR_MSIX 1
9898
#define ICE_MIN_MSIX (ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_LAN_OICR_MSIX)
9999
#define ICE_FDIR_MSIX 2
100-
#define ICE_RDMA_NUM_AEQ_MSIX 4
101100
#define ICE_NO_VSI 0xffff
102101
#define ICE_VSI_MAP_CONTIG 0
103102
#define ICE_VSI_MAP_SCATTER 1

drivers/net/ethernet/intel/ice/ice_idc.c

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -228,61 +228,34 @@ void ice_get_qos_params(struct ice_pf *pf, struct iidc_qos_params *qos)
228228
}
229229
EXPORT_SYMBOL_GPL(ice_get_qos_params);
230230

231-
/**
232-
* ice_alloc_rdma_qvectors - Allocate vector resources for RDMA driver
233-
* @pf: board private structure to initialize
234-
*/
235-
static int ice_alloc_rdma_qvectors(struct ice_pf *pf)
231+
int ice_alloc_rdma_qvector(struct ice_pf *pf, struct msix_entry *entry)
236232
{
237-
if (ice_is_rdma_ena(pf)) {
238-
int i;
239-
240-
pf->msix_entries = kcalloc(pf->num_rdma_msix,
241-
sizeof(*pf->msix_entries),
242-
GFP_KERNEL);
243-
if (!pf->msix_entries)
244-
return -ENOMEM;
233+
struct msi_map map = ice_alloc_irq(pf, true);
245234

246-
/* RDMA is the only user of pf->msix_entries array */
247-
pf->rdma_base_vector = 0;
248-
249-
for (i = 0; i < pf->num_rdma_msix; i++) {
250-
struct msix_entry *entry = &pf->msix_entries[i];
251-
struct msi_map map;
235+
if (map.index < 0)
236+
return -ENOMEM;
252237

253-
map = ice_alloc_irq(pf, false);
254-
if (map.index < 0)
255-
break;
238+
entry->entry = map.index;
239+
entry->vector = map.virq;
256240

257-
entry->entry = map.index;
258-
entry->vector = map.virq;
259-
}
260-
}
261241
return 0;
262242
}
243+
EXPORT_SYMBOL_GPL(ice_alloc_rdma_qvector);
263244

264245
/**
265246
* ice_free_rdma_qvector - free vector resources reserved for RDMA driver
266247
* @pf: board private structure to initialize
248+
* @entry: MSI-X entry to be removed
267249
*/
268-
static void ice_free_rdma_qvector(struct ice_pf *pf)
250+
void ice_free_rdma_qvector(struct ice_pf *pf, struct msix_entry *entry)
269251
{
270-
int i;
271-
272-
if (!pf->msix_entries)
273-
return;
274-
275-
for (i = 0; i < pf->num_rdma_msix; i++) {
276-
struct msi_map map;
252+
struct msi_map map;
277253

278-
map.index = pf->msix_entries[i].entry;
279-
map.virq = pf->msix_entries[i].vector;
280-
ice_free_irq(pf, map);
281-
}
282-
283-
kfree(pf->msix_entries);
284-
pf->msix_entries = NULL;
254+
map.index = entry->entry;
255+
map.virq = entry->vector;
256+
ice_free_irq(pf, map);
285257
}
258+
EXPORT_SYMBOL_GPL(ice_free_rdma_qvector);
286259

287260
/**
288261
* ice_adev_release - function to be mapped to AUX dev's release op
@@ -382,21 +355,13 @@ int ice_init_rdma(struct ice_pf *pf)
382355
return -ENOMEM;
383356
}
384357

385-
/* Reserve vector resources */
386-
ret = ice_alloc_rdma_qvectors(pf);
387-
if (ret < 0) {
388-
dev_err(dev, "failed to reserve vectors for RDMA\n");
389-
goto err_reserve_rdma_qvector;
390-
}
391358
pf->rdma_mode |= IIDC_RDMA_PROTOCOL_ROCEV2;
392359
ret = ice_plug_aux_dev(pf);
393360
if (ret)
394361
goto err_plug_aux_dev;
395362
return 0;
396363

397364
err_plug_aux_dev:
398-
ice_free_rdma_qvector(pf);
399-
err_reserve_rdma_qvector:
400365
pf->adev = NULL;
401366
xa_erase(&ice_aux_id, pf->aux_idx);
402367
return ret;
@@ -412,6 +377,5 @@ void ice_deinit_rdma(struct ice_pf *pf)
412377
return;
413378

414379
ice_unplug_aux_dev(pf);
415-
ice_free_rdma_qvector(pf);
416380
xa_erase(&ice_aux_id, pf->aux_idx);
417381
}

drivers/net/ethernet/intel/ice/ice_irq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ static struct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_only)
8484
return entry;
8585
}
8686

87+
#define ICE_RDMA_AEQ_MSIX 1
8788
static int ice_get_default_msix_amount(struct ice_pf *pf)
8889
{
8990
return ICE_MIN_LAN_OICR_MSIX + num_online_cpus() +
9091
(test_bit(ICE_FLAG_FD_ENA, pf->flags) ? ICE_FDIR_MSIX : 0) +
91-
(ice_is_rdma_ena(pf) ? num_online_cpus() + ICE_RDMA_NUM_AEQ_MSIX : 0);
92+
(ice_is_rdma_ena(pf) ? num_online_cpus() + ICE_RDMA_AEQ_MSIX : 0);
9293
}
9394

9495
/**

include/linux/net/intel/iidc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ int ice_del_rdma_qset(struct ice_pf *pf, struct iidc_rdma_qset_params *qset);
7878
int ice_rdma_request_reset(struct ice_pf *pf, enum iidc_reset_type reset_type);
7979
int ice_rdma_update_vsi_filter(struct ice_pf *pf, u16 vsi_id, bool enable);
8080
void ice_get_qos_params(struct ice_pf *pf, struct iidc_qos_params *qos);
81+
int ice_alloc_rdma_qvector(struct ice_pf *pf, struct msix_entry *entry);
82+
void ice_free_rdma_qvector(struct ice_pf *pf, struct msix_entry *entry);
8183

8284
/* Structure representing auxiliary driver tailored information about the core
8385
* PCI dev, each auxiliary driver using the IIDC interface will have an

0 commit comments

Comments
 (0)