Skip to content

Commit f4370a8

Browse files
shirazsaleemanguy11
authored andcommitted
i40e: Register auxiliary devices to provide RDMA
Convert i40e to use the auxiliary bus infrastructure to export the RDMA functionality of the device to the RDMA driver. Register i40e client auxiliary RDMA device on the auxiliary bus per PCIe device function for the new auxiliary rdma driver (irdma) to attach to. The global i40e_register_client and i40e_unregister_client symbols will be obsoleted once irdma replaces i40iw in the kernel for the X722 device. Signed-off-by: Shiraz Saleem <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 9ed7533 commit f4370a8

File tree

4 files changed

+114
-20
lines changed

4 files changed

+114
-20
lines changed

drivers/net/ethernet/intel/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ config I40E
241241
tristate "Intel(R) Ethernet Controller XL710 Family support"
242242
imply PTP_1588_CLOCK
243243
depends on PCI
244+
select AUXILIARY_BUS
244245
help
245246
This driver supports Intel(R) Ethernet Controller XL710 Family of
246247
devices. For more information on how to identify your adapter, go

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,8 @@ struct i40e_netdev_priv {
870870
struct i40e_vsi *vsi;
871871
};
872872

873+
extern struct ida i40e_client_ida;
874+
873875
/* struct that defines an interrupt vector */
874876
struct i40e_q_vector {
875877
struct i40e_vsi *vsi;

drivers/net/ethernet/intel/i40e/i40e_client.c

Lines changed: 110 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ static const char i40e_client_interface_version_str[] = I40E_CLIENT_VERSION_STR;
1212
static struct i40e_client *registered_client;
1313
static LIST_HEAD(i40e_devices);
1414
static DEFINE_MUTEX(i40e_device_mutex);
15+
DEFINE_IDA(i40e_client_ida);
1516

1617
static int i40e_client_virtchnl_send(struct i40e_info *ldev,
1718
struct i40e_client *client,
@@ -275,6 +276,57 @@ void i40e_client_update_msix_info(struct i40e_pf *pf)
275276
cdev->lan_info.msix_entries = &pf->msix_entries[pf->iwarp_base_vector];
276277
}
277278

279+
static void i40e_auxiliary_dev_release(struct device *dev)
280+
{
281+
struct i40e_auxiliary_device *i40e_aux_dev =
282+
container_of(dev, struct i40e_auxiliary_device, aux_dev.dev);
283+
284+
ida_free(&i40e_client_ida, i40e_aux_dev->aux_dev.id);
285+
kfree(i40e_aux_dev);
286+
}
287+
288+
static int i40e_register_auxiliary_dev(struct i40e_info *ldev, const char *name)
289+
{
290+
struct i40e_auxiliary_device *i40e_aux_dev;
291+
struct pci_dev *pdev = ldev->pcidev;
292+
struct auxiliary_device *aux_dev;
293+
int ret;
294+
295+
i40e_aux_dev = kzalloc(sizeof(*i40e_aux_dev), GFP_KERNEL);
296+
if (!i40e_aux_dev)
297+
return -ENOMEM;
298+
299+
i40e_aux_dev->ldev = ldev;
300+
301+
aux_dev = &i40e_aux_dev->aux_dev;
302+
aux_dev->name = name;
303+
aux_dev->dev.parent = &pdev->dev;
304+
aux_dev->dev.release = i40e_auxiliary_dev_release;
305+
ldev->aux_dev = aux_dev;
306+
307+
ret = ida_alloc(&i40e_client_ida, GFP_KERNEL);
308+
if (ret < 0) {
309+
kfree(i40e_aux_dev);
310+
return ret;
311+
}
312+
aux_dev->id = ret;
313+
314+
ret = auxiliary_device_init(aux_dev);
315+
if (ret < 0) {
316+
ida_free(&i40e_client_ida, aux_dev->id);
317+
kfree(i40e_aux_dev);
318+
return ret;
319+
}
320+
321+
ret = auxiliary_device_add(aux_dev);
322+
if (ret) {
323+
auxiliary_device_uninit(aux_dev);
324+
return ret;
325+
}
326+
327+
return ret;
328+
}
329+
278330
/**
279331
* i40e_client_add_instance - add a client instance struct to the instance list
280332
* @pf: pointer to the board struct
@@ -286,9 +338,6 @@ static void i40e_client_add_instance(struct i40e_pf *pf)
286338
struct netdev_hw_addr *mac = NULL;
287339
struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
288340

289-
if (!registered_client || pf->cinst)
290-
return;
291-
292341
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
293342
if (!cdev)
294343
return;
@@ -308,11 +357,8 @@ static void i40e_client_add_instance(struct i40e_pf *pf)
308357
cdev->lan_info.fw_build = pf->hw.aq.fw_build;
309358
set_bit(__I40E_CLIENT_INSTANCE_NONE, &cdev->state);
310359

311-
if (i40e_client_get_params(vsi, &cdev->lan_info.params)) {
312-
kfree(cdev);
313-
cdev = NULL;
314-
return;
315-
}
360+
if (i40e_client_get_params(vsi, &cdev->lan_info.params))
361+
goto free_cdev;
316362

317363
mac = list_first_entry(&cdev->lan_info.netdev->dev_addrs.list,
318364
struct netdev_hw_addr, list);
@@ -324,7 +370,17 @@ static void i40e_client_add_instance(struct i40e_pf *pf)
324370
cdev->client = registered_client;
325371
pf->cinst = cdev;
326372

327-
i40e_client_update_msix_info(pf);
373+
cdev->lan_info.msix_count = pf->num_iwarp_msix;
374+
cdev->lan_info.msix_entries = &pf->msix_entries[pf->iwarp_base_vector];
375+
376+
if (i40e_register_auxiliary_dev(&cdev->lan_info, "iwarp"))
377+
goto free_cdev;
378+
379+
return;
380+
381+
free_cdev:
382+
kfree(cdev);
383+
pf->cinst = NULL;
328384
}
329385

330386
/**
@@ -345,7 +401,7 @@ void i40e_client_del_instance(struct i40e_pf *pf)
345401
**/
346402
void i40e_client_subtask(struct i40e_pf *pf)
347403
{
348-
struct i40e_client *client = registered_client;
404+
struct i40e_client *client;
349405
struct i40e_client_instance *cdev;
350406
struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
351407
int ret = 0;
@@ -359,9 +415,11 @@ void i40e_client_subtask(struct i40e_pf *pf)
359415
test_bit(__I40E_CONFIG_BUSY, pf->state))
360416
return;
361417

362-
if (!client || !cdev)
418+
if (!cdev || !cdev->client)
363419
return;
364420

421+
client = cdev->client;
422+
365423
/* Here we handle client opens. If the client is down, and
366424
* the netdev is registered, then open the client.
367425
*/
@@ -423,16 +481,8 @@ int i40e_lan_add_device(struct i40e_pf *pf)
423481
pf->hw.pf_id, pf->hw.bus.bus_id,
424482
pf->hw.bus.device, pf->hw.bus.func);
425483

426-
/* If a client has already been registered, we need to add an instance
427-
* of it to our new LAN device.
428-
*/
429-
if (registered_client)
430-
i40e_client_add_instance(pf);
484+
i40e_client_add_instance(pf);
431485

432-
/* Since in some cases register may have happened before a device gets
433-
* added, we can schedule a subtask to go initiate the clients if
434-
* they can be launched at probe time.
435-
*/
436486
set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state);
437487
i40e_service_event_schedule(pf);
438488

@@ -449,9 +499,13 @@ int i40e_lan_add_device(struct i40e_pf *pf)
449499
**/
450500
int i40e_lan_del_device(struct i40e_pf *pf)
451501
{
502+
struct auxiliary_device *aux_dev = pf->cinst->lan_info.aux_dev;
452503
struct i40e_device *ldev, *tmp;
453504
int ret = -ENODEV;
454505

506+
auxiliary_device_delete(aux_dev);
507+
auxiliary_device_uninit(aux_dev);
508+
455509
/* First, remove any client instance. */
456510
i40e_client_del_instance(pf);
457511

@@ -732,6 +786,42 @@ static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
732786
return err;
733787
}
734788

789+
void i40e_client_device_register(struct i40e_info *ldev, struct i40e_client *client)
790+
{
791+
struct i40e_pf *pf = ldev->pf;
792+
793+
pf->cinst->client = client;
794+
set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state);
795+
i40e_service_event_schedule(pf);
796+
}
797+
EXPORT_SYMBOL_GPL(i40e_client_device_register);
798+
799+
void i40e_client_device_unregister(struct i40e_info *ldev)
800+
{
801+
struct i40e_pf *pf = ldev->pf;
802+
struct i40e_client_instance *cdev = pf->cinst;
803+
804+
if (!cdev)
805+
return;
806+
807+
while (test_and_set_bit(__I40E_SERVICE_SCHED, pf->state))
808+
usleep_range(500, 1000);
809+
810+
if (test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
811+
cdev->client->ops->close(&cdev->lan_info, cdev->client, false);
812+
clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
813+
i40e_client_release_qvlist(&cdev->lan_info);
814+
}
815+
816+
pf->cinst->client = NULL;
817+
clear_bit(__I40E_SERVICE_SCHED, pf->state);
818+
}
819+
EXPORT_SYMBOL_GPL(i40e_client_device_unregister);
820+
821+
/* Retain these legacy global registration/unregistration calls till i40iw is
822+
* removed from the kernel. The irdma unified driver does not use these
823+
* exported symbols.
824+
*/
735825
/**
736826
* i40e_register_client - Register a i40e client driver with the L2 driver
737827
* @client: pointer to the i40e_client struct

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16270,6 +16270,7 @@ static void __exit i40e_exit_module(void)
1627016270
{
1627116271
pci_unregister_driver(&i40e_driver);
1627216272
destroy_workqueue(i40e_wq);
16273+
ida_destroy(&i40e_client_ida);
1627316274
i40e_dbg_exit();
1627416275
}
1627516276
module_exit(i40e_exit_module);

0 commit comments

Comments
 (0)