Skip to content

Commit f9f5301

Browse files
dmertmananguy11
authored andcommitted
ice: Register auxiliary device to provide RDMA
Register ice client auxiliary RDMA device on the auxiliary bus per PCIe device function for the auxiliary driver (irdma) to attach to. It allows to realize a single RDMA driver (irdma) capable of working with multiple netdev drivers over multi-generation Intel HW supporting RDMA. There is no load ordering dependencies between ice and irdma. Signed-off-by: Dave Ertman <[email protected]> Signed-off-by: Shiraz Saleem <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 348048e commit f9f5301

File tree

4 files changed

+87
-4
lines changed

4 files changed

+87
-4
lines changed

drivers/net/ethernet/intel/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ config ICE
294294
tristate "Intel(R) Ethernet Connection E800 Series Support"
295295
default n
296296
depends on PCI_MSI
297+
select AUXILIARY_BUS
297298
select DIMLIB
298299
select NET_DEVLINK
299300
select PLDMFW

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/if_bridge.h>
3535
#include <linux/ctype.h>
3636
#include <linux/bpf.h>
37+
#include <linux/auxiliary_bus.h>
3738
#include <linux/avf/virtchnl.h>
3839
#include <linux/cpu_rmap.h>
3940
#include <linux/dim.h>
@@ -647,6 +648,8 @@ int ice_get_rss_key(struct ice_vsi *vsi, u8 *seed);
647648
void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size);
648649
int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset);
649650
void ice_print_link_msg(struct ice_vsi *vsi, bool isup);
651+
int ice_plug_aux_dev(struct ice_pf *pf);
652+
void ice_unplug_aux_dev(struct ice_pf *pf);
650653
int ice_init_rdma(struct ice_pf *pf);
651654
const char *ice_stat_str(enum ice_status stat_err);
652655
const char *ice_aq_str(enum ice_aq_err aq_err);
@@ -678,8 +681,10 @@ void ice_service_task_schedule(struct ice_pf *pf);
678681
*/
679682
static inline void ice_set_rdma_cap(struct ice_pf *pf)
680683
{
681-
if (pf->hw.func_caps.common_cap.rdma && pf->num_rdma_msix)
684+
if (pf->hw.func_caps.common_cap.rdma && pf->num_rdma_msix) {
682685
set_bit(ICE_FLAG_RDMA_ENA, pf->flags);
686+
ice_plug_aux_dev(pf);
687+
}
683688
}
684689

685690
/**
@@ -688,6 +693,7 @@ static inline void ice_set_rdma_cap(struct ice_pf *pf)
688693
*/
689694
static inline void ice_clear_rdma_cap(struct ice_pf *pf)
690695
{
696+
ice_unplug_aux_dev(pf);
691697
clear_bit(ICE_FLAG_RDMA_ENA, pf->flags);
692698
}
693699
#endif /* _ICE_H_ */

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

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,71 @@ static int ice_reserve_rdma_qvector(struct ice_pf *pf)
249249
return 0;
250250
}
251251

252+
/**
253+
* ice_adev_release - function to be mapped to AUX dev's release op
254+
* @dev: pointer to device to free
255+
*/
256+
static void ice_adev_release(struct device *dev)
257+
{
258+
struct iidc_auxiliary_dev *iadev;
259+
260+
iadev = container_of(dev, struct iidc_auxiliary_dev, adev.dev);
261+
kfree(iadev);
262+
}
263+
264+
/**
265+
* ice_plug_aux_dev - allocate and register AUX device
266+
* @pf: pointer to pf struct
267+
*/
268+
int ice_plug_aux_dev(struct ice_pf *pf)
269+
{
270+
struct iidc_auxiliary_dev *iadev;
271+
struct auxiliary_device *adev;
272+
int ret;
273+
274+
iadev = kzalloc(sizeof(*iadev), GFP_KERNEL);
275+
if (!iadev)
276+
return -ENOMEM;
277+
278+
adev = &iadev->adev;
279+
pf->adev = adev;
280+
iadev->pf = pf;
281+
282+
adev->id = pf->aux_idx;
283+
adev->dev.release = ice_adev_release;
284+
adev->dev.parent = &pf->pdev->dev;
285+
adev->name = IIDC_RDMA_ROCE_NAME;
286+
287+
ret = auxiliary_device_init(adev);
288+
if (ret) {
289+
pf->adev = NULL;
290+
kfree(iadev);
291+
return ret;
292+
}
293+
294+
ret = auxiliary_device_add(adev);
295+
if (ret) {
296+
pf->adev = NULL;
297+
auxiliary_device_uninit(adev);
298+
return ret;
299+
}
300+
301+
return 0;
302+
}
303+
304+
/* ice_unplug_aux_dev - unregister and free AUX device
305+
* @pf: pointer to pf struct
306+
*/
307+
void ice_unplug_aux_dev(struct ice_pf *pf)
308+
{
309+
if (!pf->adev)
310+
return;
311+
312+
auxiliary_device_delete(pf->adev);
313+
auxiliary_device_uninit(pf->adev);
314+
pf->adev = NULL;
315+
}
316+
252317
/**
253318
* ice_init_rdma - initializes PF for RDMA use
254319
* @pf: ptr to ice_pf
@@ -260,8 +325,10 @@ int ice_init_rdma(struct ice_pf *pf)
260325

261326
/* Reserve vector resources */
262327
ret = ice_reserve_rdma_qvector(pf);
263-
if (ret < 0)
328+
if (ret < 0) {
264329
dev_err(dev, "failed to reserve vectors for RDMA\n");
330+
return ret;
331+
}
265332

266-
return ret;
333+
return ice_plug_aux_dev(pf);
267334
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ ice_prepare_for_reset(struct ice_pf *pf)
456456
if (test_bit(ICE_PREPARED_FOR_RESET, pf->state))
457457
return;
458458

459+
ice_unplug_aux_dev(pf);
460+
459461
/* Notify VFs of impending reset */
460462
if (ice_check_sq_alive(hw, &hw->mailboxq))
461463
ice_vc_notify_reset(pf);
@@ -2120,6 +2122,8 @@ int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset)
21202122
return -EBUSY;
21212123
}
21222124

2125+
ice_unplug_aux_dev(pf);
2126+
21232127
switch (reset) {
21242128
case ICE_RESET_PFR:
21252129
set_bit(ICE_PFR_REQ, pf->state);
@@ -4456,11 +4460,12 @@ static void ice_remove(struct pci_dev *pdev)
44564460
ice_free_vfs(pf);
44574461
}
44584462

4459-
set_bit(ICE_DOWN, pf->state);
44604463
ice_service_task_stop(pf);
44614464

44624465
ice_aq_cancel_waiting_tasks(pf);
4466+
ice_unplug_aux_dev(pf);
44634467
ida_free(&ice_aux_ida, pf->aux_idx);
4468+
set_bit(ICE_DOWN, pf->state);
44644469

44654470
mutex_destroy(&(&pf->hw)->fdir_fltr_lock);
44664471
ice_deinit_lag(pf);
@@ -4616,6 +4621,8 @@ static int __maybe_unused ice_suspend(struct device *dev)
46164621
*/
46174622
disabled = ice_service_task_stop(pf);
46184623

4624+
ice_unplug_aux_dev(pf);
4625+
46194626
/* Already suspended?, then there is nothing to do */
46204627
if (test_and_set_bit(ICE_SUSPENDED, pf->state)) {
46214628
if (!disabled)
@@ -6286,6 +6293,8 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
62866293

62876294
/* if we get here, reset flow is successful */
62886295
clear_bit(ICE_RESET_FAILED, pf->state);
6296+
6297+
ice_plug_aux_dev(pf);
62896298
return;
62906299

62916300
err_vsi_rebuild:

0 commit comments

Comments
 (0)