@@ -12,6 +12,7 @@ static const char i40e_client_interface_version_str[] = I40E_CLIENT_VERSION_STR;
12
12
static struct i40e_client * registered_client ;
13
13
static LIST_HEAD (i40e_devices );
14
14
static DEFINE_MUTEX (i40e_device_mutex );
15
+ DEFINE_IDA (i40e_client_ida );
15
16
16
17
static int i40e_client_virtchnl_send (struct i40e_info * ldev ,
17
18
struct i40e_client * client ,
@@ -275,6 +276,57 @@ void i40e_client_update_msix_info(struct i40e_pf *pf)
275
276
cdev -> lan_info .msix_entries = & pf -> msix_entries [pf -> iwarp_base_vector ];
276
277
}
277
278
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
+
278
330
/**
279
331
* i40e_client_add_instance - add a client instance struct to the instance list
280
332
* @pf: pointer to the board struct
@@ -286,9 +338,6 @@ static void i40e_client_add_instance(struct i40e_pf *pf)
286
338
struct netdev_hw_addr * mac = NULL ;
287
339
struct i40e_vsi * vsi = pf -> vsi [pf -> lan_vsi ];
288
340
289
- if (!registered_client || pf -> cinst )
290
- return ;
291
-
292
341
cdev = kzalloc (sizeof (* cdev ), GFP_KERNEL );
293
342
if (!cdev )
294
343
return ;
@@ -308,11 +357,8 @@ static void i40e_client_add_instance(struct i40e_pf *pf)
308
357
cdev -> lan_info .fw_build = pf -> hw .aq .fw_build ;
309
358
set_bit (__I40E_CLIENT_INSTANCE_NONE , & cdev -> state );
310
359
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 ;
316
362
317
363
mac = list_first_entry (& cdev -> lan_info .netdev -> dev_addrs .list ,
318
364
struct netdev_hw_addr , list );
@@ -324,7 +370,17 @@ static void i40e_client_add_instance(struct i40e_pf *pf)
324
370
cdev -> client = registered_client ;
325
371
pf -> cinst = cdev ;
326
372
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 ;
328
384
}
329
385
330
386
/**
@@ -345,7 +401,7 @@ void i40e_client_del_instance(struct i40e_pf *pf)
345
401
**/
346
402
void i40e_client_subtask (struct i40e_pf * pf )
347
403
{
348
- struct i40e_client * client = registered_client ;
404
+ struct i40e_client * client ;
349
405
struct i40e_client_instance * cdev ;
350
406
struct i40e_vsi * vsi = pf -> vsi [pf -> lan_vsi ];
351
407
int ret = 0 ;
@@ -359,9 +415,11 @@ void i40e_client_subtask(struct i40e_pf *pf)
359
415
test_bit (__I40E_CONFIG_BUSY , pf -> state ))
360
416
return ;
361
417
362
- if (!client || !cdev )
418
+ if (!cdev || !cdev -> client )
363
419
return ;
364
420
421
+ client = cdev -> client ;
422
+
365
423
/* Here we handle client opens. If the client is down, and
366
424
* the netdev is registered, then open the client.
367
425
*/
@@ -423,16 +481,8 @@ int i40e_lan_add_device(struct i40e_pf *pf)
423
481
pf -> hw .pf_id , pf -> hw .bus .bus_id ,
424
482
pf -> hw .bus .device , pf -> hw .bus .func );
425
483
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 );
431
485
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
- */
436
486
set_bit (__I40E_CLIENT_SERVICE_REQUESTED , pf -> state );
437
487
i40e_service_event_schedule (pf );
438
488
@@ -449,9 +499,13 @@ int i40e_lan_add_device(struct i40e_pf *pf)
449
499
**/
450
500
int i40e_lan_del_device (struct i40e_pf * pf )
451
501
{
502
+ struct auxiliary_device * aux_dev = pf -> cinst -> lan_info .aux_dev ;
452
503
struct i40e_device * ldev , * tmp ;
453
504
int ret = - ENODEV ;
454
505
506
+ auxiliary_device_delete (aux_dev );
507
+ auxiliary_device_uninit (aux_dev );
508
+
455
509
/* First, remove any client instance. */
456
510
i40e_client_del_instance (pf );
457
511
@@ -732,6 +786,42 @@ static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
732
786
return err ;
733
787
}
734
788
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
+ */
735
825
/**
736
826
* i40e_register_client - Register a i40e client driver with the L2 driver
737
827
* @client: pointer to the i40e_client struct
0 commit comments