@@ -284,8 +284,11 @@ void bnxt_vf_reps_open(struct bnxt *bp)
284
284
if (bp -> eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV )
285
285
return ;
286
286
287
- for (i = 0 ; i < pci_num_vf (bp -> pdev ); i ++ )
288
- bnxt_vf_rep_open (bp -> vf_reps [i ]-> dev );
287
+ for (i = 0 ; i < pci_num_vf (bp -> pdev ); i ++ ) {
288
+ /* Open the VF-Rep only if it is allocated in the FW */
289
+ if (bp -> vf_reps [i ]-> tx_cfa_action != CFA_HANDLE_INVALID )
290
+ bnxt_vf_rep_open (bp -> vf_reps [i ]-> dev );
291
+ }
289
292
}
290
293
291
294
static void __bnxt_free_one_vf_rep (struct bnxt * bp , struct bnxt_vf_rep * vf_rep )
@@ -361,6 +364,23 @@ void bnxt_vf_reps_destroy(struct bnxt *bp)
361
364
__bnxt_vf_reps_destroy (bp );
362
365
}
363
366
367
+ /* Free the VF-Reps in firmware, during firmware hot-reset processing.
368
+ * Note that the VF-Rep netdevs are still active (not unregistered) during
369
+ * this process. As the mode transition from SWITCHDEV to LEGACY happens
370
+ * under the rtnl_lock() this routine is safe under the rtnl_lock().
371
+ */
372
+ void bnxt_vf_reps_free (struct bnxt * bp )
373
+ {
374
+ u16 num_vfs = pci_num_vf (bp -> pdev );
375
+ int i ;
376
+
377
+ if (bp -> eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV )
378
+ return ;
379
+
380
+ for (i = 0 ; i < num_vfs ; i ++ )
381
+ __bnxt_free_one_vf_rep (bp , bp -> vf_reps [i ]);
382
+ }
383
+
364
384
static int bnxt_alloc_vf_rep (struct bnxt * bp , struct bnxt_vf_rep * vf_rep ,
365
385
u16 * cfa_code_map )
366
386
{
@@ -381,6 +401,43 @@ static int bnxt_alloc_vf_rep(struct bnxt *bp, struct bnxt_vf_rep *vf_rep,
381
401
return 0 ;
382
402
}
383
403
404
+ /* Allocate the VF-Reps in firmware, during firmware hot-reset processing.
405
+ * Note that the VF-Rep netdevs are still active (not unregistered) during
406
+ * this process. As the mode transition from SWITCHDEV to LEGACY happens
407
+ * under the rtnl_lock() this routine is safe under the rtnl_lock().
408
+ */
409
+ int bnxt_vf_reps_alloc (struct bnxt * bp )
410
+ {
411
+ u16 * cfa_code_map = bp -> cfa_code_map , num_vfs = pci_num_vf (bp -> pdev );
412
+ struct bnxt_vf_rep * vf_rep ;
413
+ int rc , i ;
414
+
415
+ if (bp -> eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV )
416
+ return 0 ;
417
+
418
+ if (!cfa_code_map )
419
+ return - EINVAL ;
420
+
421
+ for (i = 0 ; i < MAX_CFA_CODE ; i ++ )
422
+ cfa_code_map [i ] = VF_IDX_INVALID ;
423
+
424
+ for (i = 0 ; i < num_vfs ; i ++ ) {
425
+ vf_rep = bp -> vf_reps [i ];
426
+ vf_rep -> vf_idx = i ;
427
+
428
+ rc = bnxt_alloc_vf_rep (bp , vf_rep , cfa_code_map );
429
+ if (rc )
430
+ goto err ;
431
+ }
432
+
433
+ return 0 ;
434
+
435
+ err :
436
+ netdev_info (bp -> dev , "%s error=%d\n" , __func__ , rc );
437
+ bnxt_vf_reps_free (bp );
438
+ return rc ;
439
+ }
440
+
384
441
/* Use the OUI of the PF's perm addr and report the same mac addr
385
442
* for the same VF-rep each time
386
443
*/
0 commit comments