Commit beba69ca authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: make nfp_net alloc/init/cleanup/free not depend on netdevs

struct nfp_net represents a vNIC, we will be moving away from the
requirement for every vNIC to have a netdev associated with it.
Remove "netdev" from some function names and prefer passing
struct nfp_net pointer as argument instead of struct net_device *.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cd6f8db9
......@@ -807,11 +807,13 @@ void nfp_net_get_fw_version(struct nfp_net_fw_version *fw_ver,
void __iomem *ctrl_bar);
struct nfp_net *
nfp_net_netdev_alloc(struct pci_dev *pdev,
nfp_net_alloc(struct pci_dev *pdev,
unsigned int max_tx_rings, unsigned int max_rx_rings);
void nfp_net_netdev_free(struct nfp_net *nn);
int nfp_net_netdev_init(struct net_device *netdev);
void nfp_net_netdev_clean(struct net_device *netdev);
void nfp_net_free(struct nfp_net *nn);
int nfp_net_init(struct nfp_net *nn);
void nfp_net_clean(struct nfp_net *nn);
void nfp_net_set_ethtool_ops(struct net_device *netdev);
void nfp_net_info(struct nfp_net *nn);
int nfp_net_reconfig(struct nfp_net *nn, u32 update);
......
......@@ -516,11 +516,10 @@ nfp_net_rx_ring_init(struct nfp_net_rx_ring *rx_ring,
/**
* nfp_net_vecs_init() - Assign IRQs and setup rvecs.
* @netdev: netdev structure
* @nn: NFP Network structure
*/
static void nfp_net_vecs_init(struct net_device *netdev)
static void nfp_net_vecs_init(struct nfp_net *nn)
{
struct nfp_net *nn = netdev_priv(netdev);
struct nfp_net_r_vector *r_vec;
int r;
......@@ -3087,7 +3086,7 @@ void nfp_net_info(struct nfp_net *nn)
}
/**
* nfp_net_netdev_alloc() - Allocate netdev and related structure
* nfp_net_alloc() - Allocate netdev and related structure
* @pdev: PCI device
* @max_tx_rings: Maximum number of TX rings supported by device
* @max_rx_rings: Maximum number of RX rings supported by device
......@@ -3097,7 +3096,7 @@ void nfp_net_info(struct nfp_net *nn)
*
* Return: NFP Net device structure, or ERR_PTR on error.
*/
struct nfp_net *nfp_net_netdev_alloc(struct pci_dev *pdev,
struct nfp_net *nfp_net_alloc(struct pci_dev *pdev,
unsigned int max_tx_rings,
unsigned int max_rx_rings)
{
......@@ -3144,10 +3143,10 @@ struct nfp_net *nfp_net_netdev_alloc(struct pci_dev *pdev,
}
/**
* nfp_net_netdev_free() - Undo what @nfp_net_netdev_alloc() did
* nfp_net_free() - Undo what @nfp_net_alloc() did
* @nn: NFP Net device to reconfigure
*/
void nfp_net_netdev_free(struct nfp_net *nn)
void nfp_net_free(struct nfp_net *nn)
{
free_netdev(nn->dp.netdev);
}
......@@ -3221,14 +3220,14 @@ static void nfp_net_irqmod_init(struct nfp_net *nn)
}
/**
* nfp_net_netdev_init() - Initialise/finalise the netdev structure
* @netdev: netdev structure
* nfp_net_init() - Initialise/finalise the nfp_net structure
* @nn: NFP Net device structure
*
* Return: 0 on success or negative errno on error.
*/
int nfp_net_netdev_init(struct net_device *netdev)
int nfp_net_init(struct nfp_net *nn)
{
struct nfp_net *nn = netdev_priv(netdev);
struct net_device *netdev = nn->dp.netdev;
int err;
nn->dp.rx_dma_dir = DMA_FROM_DEVICE;
......@@ -3367,19 +3366,17 @@ int nfp_net_netdev_init(struct net_device *netdev)
netif_carrier_off(netdev);
nfp_net_set_ethtool_ops(netdev);
nfp_net_vecs_init(netdev);
nfp_net_vecs_init(nn);
return register_netdev(netdev);
}
/**
* nfp_net_netdev_clean() - Undo what nfp_net_netdev_init() did.
* @netdev: netdev structure
* nfp_net_clean() - Undo what nfp_net_init() did.
* @nn: NFP Net device structure
*/
void nfp_net_netdev_clean(struct net_device *netdev)
void nfp_net_clean(struct nfp_net *nn)
{
struct nfp_net *nn = netdev_priv(netdev);
unregister_netdev(nn->dp.netdev);
if (nn->dp.xdp_prog)
......
......@@ -277,7 +277,7 @@ static void nfp_net_pf_free_netdevs(struct nfp_pf *pf)
list_del(&nn->port_list);
pf->num_netdevs--;
nfp_net_netdev_free(nn);
nfp_net_free(nn);
}
}
......@@ -294,7 +294,7 @@ nfp_net_pf_alloc_port_netdev(struct nfp_pf *pf, void __iomem *ctrl_bar,
n_rx_rings = readl(ctrl_bar + NFP_NET_CFG_MAX_RXRINGS);
/* Allocate and initialise the netdev */
nn = nfp_net_netdev_alloc(pf->pdev, n_tx_rings, n_rx_rings);
nn = nfp_net_alloc(pf->pdev, n_tx_rings, n_rx_rings);
if (IS_ERR(nn))
return nn;
......@@ -326,7 +326,7 @@ nfp_net_pf_init_port_netdev(struct nfp_pf *pf, struct nfp_net *nn,
*/
nn->me_freq_mhz = 1200;
err = nfp_net_netdev_init(nn->dp.netdev);
err = nfp_net_init(nn);
if (err)
return err;
......@@ -451,7 +451,7 @@ nfp_net_pf_spawn_netdevs(struct nfp_pf *pf,
err_prev_deinit:
list_for_each_entry_continue_reverse(nn, &pf->ports, port_list) {
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_netdev_clean(nn->dp.netdev);
nfp_net_clean(nn);
}
nfp_net_irqs_disable(pf->pdev);
err_vec_free:
......@@ -518,11 +518,11 @@ static void nfp_net_refresh_netdevs(struct work_struct *work)
nn_warn(nn, "Port config changed, unregistering. Reboot required before port will be operational again.\n");
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_netdev_clean(nn->dp.netdev);
nfp_net_clean(nn);
list_del(&nn->port_list);
pf->num_netdevs--;
nfp_net_netdev_free(nn);
nfp_net_free(nn);
}
if (list_empty(&pf->ports))
......@@ -693,7 +693,7 @@ void nfp_net_pci_remove(struct nfp_pf *pf)
list_for_each_entry(nn, &pf->ports, port_list) {
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_netdev_clean(nn->dp.netdev);
nfp_net_clean(nn);
}
nfp_net_pf_free_netdevs(pf);
......
......@@ -202,7 +202,7 @@ static int nfp_netvf_pci_probe(struct pci_dev *pdev,
rx_bar_off = NFP_PCIE_QUEUE(startq);
/* Allocate and initialise the netdev */
nn = nfp_net_netdev_alloc(pdev, max_tx_rings, max_rx_rings);
nn = nfp_net_alloc(pdev, max_tx_rings, max_rx_rings);
if (IS_ERR(nn)) {
err = PTR_ERR(nn);
goto err_ctrl_unmap;
......@@ -283,7 +283,7 @@ static int nfp_netvf_pci_probe(struct pci_dev *pdev,
*/
nn->me_freq_mhz = 1200;
err = nfp_net_netdev_init(nn->dp.netdev);
err = nfp_net_init(nn);
if (err)
goto err_irqs_disable;
......@@ -304,7 +304,7 @@ static int nfp_netvf_pci_probe(struct pci_dev *pdev,
else
iounmap(vf->q_bar);
err_netdev_free:
nfp_net_netdev_free(nn);
nfp_net_free(nn);
err_ctrl_unmap:
iounmap(ctrl_bar);
err_pci_regions:
......@@ -328,7 +328,7 @@ static void nfp_netvf_pci_remove(struct pci_dev *pdev)
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_debugfs_dir_clean(&vf->ddir);
nfp_net_netdev_clean(nn->dp.netdev);
nfp_net_clean(nn);
nfp_net_irqs_disable(pdev);
......@@ -340,7 +340,7 @@ static void nfp_netvf_pci_remove(struct pci_dev *pdev)
}
iounmap(nn->dp.ctrl_bar);
nfp_net_netdev_free(nn);
nfp_net_free(nn);
pci_release_regions(pdev);
pci_disable_device(pdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment