Skip to content

Commit ac797ce

Browse files
sbasavapatnadavem330
authored andcommitted
bnxt_en: Free and allocate VF-Reps during error recovery.
During firmware recovery, VF-Rep configuration in the firmware is lost. Fix it by freeing and (re)allocating VF-Reps in FW at relevant points during the error recovery process. Signed-off-by: Sriharsha Basavapatna <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 90f4fd0 commit ac797ce

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11081,6 +11081,7 @@ static void bnxt_fw_reset_close(struct bnxt *bp)
1108111081
pci_disable_device(bp->pdev);
1108211082
}
1108311083
__bnxt_close_nic(bp, true, false);
11084+
bnxt_vf_reps_free(bp);
1108411085
bnxt_clear_int_mode(bp);
1108511086
bnxt_hwrm_func_drv_unrgtr(bp);
1108611087
if (pci_is_enabled(bp->pdev))
@@ -11825,6 +11826,8 @@ static void bnxt_fw_reset_task(struct work_struct *work)
1182511826
bnxt_ulp_start(bp, rc);
1182611827
if (!rc)
1182711828
bnxt_reenable_sriov(bp);
11829+
bnxt_vf_reps_alloc(bp);
11830+
bnxt_vf_reps_open(bp);
1182811831
bnxt_dl_health_recovery_done(bp);
1182911832
bnxt_dl_health_status_update(bp, true);
1183011833
rtnl_unlock();

drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,11 @@ void bnxt_vf_reps_open(struct bnxt *bp)
284284
if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
285285
return;
286286

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+
}
289292
}
290293

291294
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)
361364
__bnxt_vf_reps_destroy(bp);
362365
}
363366

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+
364384
static int bnxt_alloc_vf_rep(struct bnxt *bp, struct bnxt_vf_rep *vf_rep,
365385
u16 *cfa_code_map)
366386
{
@@ -381,6 +401,43 @@ static int bnxt_alloc_vf_rep(struct bnxt *bp, struct bnxt_vf_rep *vf_rep,
381401
return 0;
382402
}
383403

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+
384441
/* Use the OUI of the PF's perm addr and report the same mac addr
385442
* for the same VF-rep each time
386443
*/

drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ void bnxt_vf_reps_close(struct bnxt *bp);
1919
void bnxt_vf_reps_open(struct bnxt *bp);
2020
void bnxt_vf_rep_rx(struct bnxt *bp, struct sk_buff *skb);
2121
struct net_device *bnxt_get_vf_rep(struct bnxt *bp, u16 cfa_code);
22+
int bnxt_vf_reps_alloc(struct bnxt *bp);
23+
void bnxt_vf_reps_free(struct bnxt *bp);
2224

2325
static inline u16 bnxt_vf_rep_get_fid(struct net_device *dev)
2426
{
@@ -61,5 +63,15 @@ static inline bool bnxt_dev_is_vf_rep(struct net_device *dev)
6163
{
6264
return false;
6365
}
66+
67+
static inline int bnxt_vf_reps_alloc(struct bnxt *bp)
68+
{
69+
return 0;
70+
}
71+
72+
static inline void bnxt_vf_reps_free(struct bnxt *bp)
73+
{
74+
}
75+
6476
#endif /* CONFIG_BNXT_SRIOV */
6577
#endif /* BNXT_VFR_H */

0 commit comments

Comments
 (0)