Skip to content

Commit

Permalink
nfp: add helper for cleaning up vNICs
Browse files Browse the repository at this point in the history
We will soon have to invoke more clean up for vNICs.
Move the cleanup callbacks into a helper.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed May 26, 2017
1 parent 1851f93 commit 71f8a11
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions drivers/net/ethernet/netronome/nfp/nfp_net_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ nfp_net_pf_alloc_vnics(struct nfp_pf *pf, void __iomem *ctrl_bar,
return err;
}

static void nfp_net_pf_clean_vnic(struct nfp_pf *pf, struct nfp_net *nn)
{
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_clean(nn);
}

static int
nfp_net_pf_spawn_vnics(struct nfp_pf *pf,
void __iomem *ctrl_bar, void __iomem *tx_bar,
Expand Down Expand Up @@ -480,10 +486,8 @@ nfp_net_pf_spawn_vnics(struct nfp_pf *pf,
return 0;

err_prev_deinit:
list_for_each_entry_continue_reverse(nn, &pf->vnics, vnic_list) {
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_clean(nn);
}
list_for_each_entry_continue_reverse(nn, &pf->vnics, vnic_list)
nfp_net_pf_clean_vnic(pf, nn);
nfp_net_irqs_disable(pf->pdev);
err_vec_free:
kfree(pf->irq_entries);
Expand Down Expand Up @@ -585,9 +589,7 @@ static void nfp_net_refresh_vnics(struct work_struct *work)
if (!nn->port || nn->port->type != NFP_PORT_INVALID)
continue;

nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_clean(nn);

nfp_net_pf_clean_vnic(pf, nn);
nfp_net_pf_free_vnic(pf, nn);
}

Expand Down Expand Up @@ -760,11 +762,8 @@ void nfp_net_pci_remove(struct nfp_pf *pf)
if (list_empty(&pf->vnics))
goto out;

list_for_each_entry(nn, &pf->vnics, vnic_list) {
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);

nfp_net_clean(nn);
}
list_for_each_entry(nn, &pf->vnics, vnic_list)
nfp_net_pf_clean_vnic(pf, nn);

nfp_net_pf_free_vnics(pf);

Expand Down

0 comments on commit 71f8a11

Please sign in to comment.