Skip to content

Commit 90f4fd0

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Refactor __bnxt_vf_reps_destroy().
Add a new helper function __bnxt_free_one_vf_rep() to free one VF rep. We also reintialize the VF rep fields to proper initial values so that the function can be used without freeing the VF rep data structure. This will be used in subsequent patches to free and recreate VF reps after error recovery. Reviewed-by: Edwin Peer <[email protected]> Reviewed-by: Sriharsha Basavapatna <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ea2d37b commit 90f4fd0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,21 @@ void bnxt_vf_reps_open(struct bnxt *bp)
288288
bnxt_vf_rep_open(bp->vf_reps[i]->dev);
289289
}
290290

291+
static void __bnxt_free_one_vf_rep(struct bnxt *bp, struct bnxt_vf_rep *vf_rep)
292+
{
293+
if (!vf_rep)
294+
return;
295+
296+
if (vf_rep->dst) {
297+
dst_release((struct dst_entry *)vf_rep->dst);
298+
vf_rep->dst = NULL;
299+
}
300+
if (vf_rep->tx_cfa_action != CFA_HANDLE_INVALID) {
301+
hwrm_cfa_vfr_free(bp, vf_rep->vf_idx);
302+
vf_rep->tx_cfa_action = CFA_HANDLE_INVALID;
303+
}
304+
}
305+
291306
static void __bnxt_vf_reps_destroy(struct bnxt *bp)
292307
{
293308
u16 num_vfs = pci_num_vf(bp->pdev);
@@ -297,11 +312,7 @@ static void __bnxt_vf_reps_destroy(struct bnxt *bp)
297312
for (i = 0; i < num_vfs; i++) {
298313
vf_rep = bp->vf_reps[i];
299314
if (vf_rep) {
300-
dst_release((struct dst_entry *)vf_rep->dst);
301-
302-
if (vf_rep->tx_cfa_action != CFA_HANDLE_INVALID)
303-
hwrm_cfa_vfr_free(bp, vf_rep->vf_idx);
304-
315+
__bnxt_free_one_vf_rep(bp, vf_rep);
305316
if (vf_rep->dev) {
306317
/* if register_netdev failed, then netdev_ops
307318
* would have been set to NULL

0 commit comments

Comments
 (0)