drivers/net/ethernet/netronome/nfp/nfp_net_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfp_net_main.c- Extension
.c- Size
- 19429 bytes
- Lines
- 835
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/etherdevice.hlinux/kernel.hlinux/init.hlinux/lockdep.hlinux/pci.hlinux/pci_regs.hlinux/random.hlinux/rtnetlink.hnfpcore/nfp.hnfpcore/nfp_cpp.hnfpcore/nfp_dev.hnfpcore/nfp_nffw.hnfpcore/nfp_nsp.hnfpcore/nfp6000_pcie.hnfp_app.hnfp_net_ctrl.hnfp_net_sriov.hnfp_net.hnfp_main.hnfp_port.h
Detected Declarations
function nfp_net_get_mac_addrfunction nfp_net_find_portfunction nfp_net_pf_get_num_portsfunction nfp_net_pf_free_vnicfunction nfp_net_pf_free_vnicsfunction nfp_net_pf_alloc_vnicfunction nfp_net_pf_init_vnicfunction nfp_net_pf_alloc_vnicsfunction nfp_net_pf_clean_vnicfunction nfp_net_pf_alloc_irqsfunction nfp_net_pf_free_irqsfunction nfp_net_pf_init_vnicsfunction nfp_net_pf_app_initfunction nfp_net_pf_app_cleanfunction nfp_net_pf_app_start_ctrlfunction nfp_net_pf_app_stop_ctrlfunction nfp_net_pf_app_startfunction nfp_net_pf_app_stopfunction nfp_net_pci_unmap_memfunction nfp_net_pci_map_memfunction nfp_net_lr2speedfunction nfp_net_speed2lrfunction nfp_net_notify_port_speedfunction nfp_net_eth_port_updatefunction nfp_net_refresh_port_table_syncfunction nfp_net_refresh_vnicsfunction nfp_net_refresh_port_tablefunction nfp_net_refresh_eth_portfunction nfp_net_pci_probefunction nfp_net_pci_remove
Annotated Snippet
if (err) {
nfp_net_free(nn);
return ERR_PTR(err);
}
}
pf->num_vnics++;
list_add_tail(&nn->vnic_list, &pf->vnics);
return nn;
}
static int
nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
{
int err;
nn->id = id;
if (nn->port) {
err = nfp_devlink_port_register(pf->app, nn->port);
if (err)
return err;
}
err = nfp_net_init(nn);
if (err)
goto err_devlink_port_clean;
nfp_net_debugfs_vnic_add(nn, pf->ddir);
nfp_net_info(nn);
if (nfp_net_is_data_vnic(nn)) {
err = nfp_app_vnic_init(pf->app, nn);
if (err)
goto err_debugfs_vnic_clean;
}
return 0;
err_debugfs_vnic_clean:
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_clean(nn);
err_devlink_port_clean:
if (nn->port)
nfp_devlink_port_unregister(nn->port);
return err;
}
static int
nfp_net_pf_alloc_vnics(struct nfp_pf *pf, void __iomem *ctrl_bar,
void __iomem *qc_bar, int stride)
{
struct nfp_net *nn;
unsigned int i;
int err;
for (i = 0; i < pf->max_data_vnics; i++) {
nn = nfp_net_pf_alloc_vnic(pf, true, ctrl_bar, qc_bar,
stride, i);
if (IS_ERR(nn)) {
err = PTR_ERR(nn);
goto err_free_prev;
}
if (nn->port)
nn->port->link_cb = nfp_net_refresh_port_table;
ctrl_bar += NFP_PF_CSR_SLICE_SIZE;
/* Kill the vNIC if app init marked it as invalid */
if (nn->port && nn->port->type == NFP_PORT_INVALID)
nfp_net_pf_free_vnic(pf, nn);
}
if (list_empty(&pf->vnics))
return -ENODEV;
return 0;
err_free_prev:
nfp_net_pf_free_vnics(pf);
return err;
}
static void nfp_net_pf_clean_vnic(struct nfp_pf *pf, struct nfp_net *nn)
{
if (nfp_net_is_data_vnic(nn))
nfp_app_vnic_clean(pf->app, nn);
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/kernel.h`, `linux/init.h`, `linux/lockdep.h`, `linux/pci.h`, `linux/pci_regs.h`, `linux/random.h`, `linux/rtnetlink.h`.
- Detected declarations: `function nfp_net_get_mac_addr`, `function nfp_net_find_port`, `function nfp_net_pf_get_num_ports`, `function nfp_net_pf_free_vnic`, `function nfp_net_pf_free_vnics`, `function nfp_net_pf_alloc_vnic`, `function nfp_net_pf_init_vnic`, `function nfp_net_pf_alloc_vnics`, `function nfp_net_pf_clean_vnic`, `function nfp_net_pf_alloc_irqs`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.