drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c- Extension
.c- Size
- 90750 bytes
- Lines
- 3564
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/interrupt.hlinux/pci.hlinux/etherdevice.hlinux/of.hlinux/if_vlan.hlinux/iommu.hnet/ip.hlinux/bpf.hlinux/bpf_trace.hlinux/bitfield.hnet/page_pool/types.hotx2_reg.hotx2_common.hotx2_txrx.hotx2_struct.hotx2_ptp.hcn10k.hqos.hrvu_trace.hcn10k_ipsec.hotx2_xsk.h
Detected Declarations
function otx2_change_mtufunction otx2_disable_flr_me_intrfunction otx2_flr_wq_destroyfunction otx2_flr_handlerfunction otx2_pf_flr_intr_handlerfunction otx2_pf_me_intr_handlerfunction otx2_register_flr_me_intrfunction otx2_pf_flr_initfunction otx2_queue_vf_workfunction otx2_forward_msg_pfvffunction otx2_forward_vf_mbox_msgsfunction otx2_pfvf_mbox_handlerfunction otx2_pfvf_mbox_up_handlerfunction otx2_pfvf_mbox_intr_handlerfunction otx2_pfvf_mbox_initfunction otx2_pfvf_mbox_destroyfunction otx2_enable_pfvf_mbox_intrfunction otx2_disable_pfvf_mbox_intrfunction otx2_register_pfvf_mbox_intrfunction otx2_process_pfaf_mbox_msgfunction otx2_pfaf_mbox_handlerfunction otx2_handle_link_eventfunction otx2_mbox_up_handler_rep_event_up_notifyfunction otx2_mbox_up_handler_mcs_intr_notifyfunction otx2_mbox_up_handler_cgx_link_eventfunction otx2_process_mbox_msg_upfunction otx2_pfaf_mbox_up_handlerfunction otx2_pfaf_mbox_intr_handlerfunction otx2_disable_mbox_intrfunction otx2_register_mbox_intrfunction otx2_pfaf_mbox_destroyfunction otx2_pfaf_mbox_initfunction otx2_cgx_config_linkeventsfunction otx2_reset_mac_statsfunction otx2_cgx_config_loopbackfunction otx2_set_real_num_queuesfunction otx2_q_intr_handlerfunction otx2_cq_intr_handlerfunction otx2_disable_napifunction otx2_free_cq_resfunction otx2_free_sq_resfunction otx2_get_rbuf_sizefunction otx2_init_hw_resourcesfunction otx2_free_hw_resourcesfunction otx2_promisc_use_mce_listfunction otx2_do_set_rx_modefunction otx2_set_irq_coalescefunction otx2_dim_work
Annotated Snippet
static const struct net_device_ops otx2_netdev_ops = {
.ndo_open = otx2_open,
.ndo_stop = otx2_stop,
.ndo_start_xmit = otx2_xmit,
.ndo_select_queue = otx2_select_queue,
.ndo_fix_features = otx2_fix_features,
.ndo_set_mac_address = otx2_set_mac_address,
.ndo_change_mtu = otx2_change_mtu,
.ndo_set_rx_mode = otx2_set_rx_mode,
.ndo_set_features = otx2_set_features,
.ndo_tx_timeout = otx2_tx_timeout,
.ndo_get_stats64 = otx2_get_stats64,
.ndo_set_vf_mac = otx2_set_vf_mac,
.ndo_set_vf_vlan = otx2_set_vf_vlan,
.ndo_get_vf_config = otx2_get_vf_config,
.ndo_bpf = otx2_xdp,
.ndo_xsk_wakeup = otx2_xsk_wakeup,
.ndo_xdp_xmit = otx2_xdp_xmit,
.ndo_setup_tc = otx2_setup_tc,
.ndo_set_vf_trust = otx2_ndo_set_vf_trust,
.ndo_hwtstamp_get = otx2_config_hwtstamp_get,
.ndo_hwtstamp_set = otx2_config_hwtstamp_set,
};
int otx2_wq_init(struct otx2_nic *pf)
{
pf->otx2_wq = create_singlethread_workqueue("otx2_wq");
if (!pf->otx2_wq)
return -ENOMEM;
INIT_WORK(&pf->rx_mode_work, otx2_rx_mode_wrk_handler);
INIT_WORK(&pf->reset_task, otx2_reset_task);
return 0;
}
int otx2_check_pf_usable(struct otx2_nic *nic)
{
u64 rev;
rev = otx2_read64(nic, RVU_PF_BLOCK_ADDRX_DISC(BLKADDR_RVUM));
rev = (rev >> 12) & 0xFF;
/* Check if AF has setup revision for RVUM block,
* otherwise this driver probe should be deferred
* until AF driver comes up.
*/
if (!rev) {
dev_warn(nic->dev,
"AF is not initialized, deferring probe\n");
return -EPROBE_DEFER;
}
return 0;
}
int otx2_realloc_msix_vectors(struct otx2_nic *pf)
{
struct otx2_hw *hw = &pf->hw;
int num_vec, err;
/* NPA interrupts are inot registered, so alloc only
* upto NIX vector offset.
*/
num_vec = hw->nix_msixoff;
num_vec += NIX_LF_CINT_VEC_START + hw->max_queues;
otx2_disable_mbox_intr(pf);
pci_free_irq_vectors(hw->pdev);
err = pci_alloc_irq_vectors(hw->pdev, num_vec, num_vec, PCI_IRQ_MSIX);
if (err < 0) {
dev_err(pf->dev, "%s: Failed to realloc %d IRQ vectors\n",
__func__, num_vec);
return err;
}
return otx2_register_mbox_intr(pf, false);
}
EXPORT_SYMBOL(otx2_realloc_msix_vectors);
static int otx2_sriov_vfcfg_init(struct otx2_nic *pf)
{
int i;
pf->vf_configs = devm_kcalloc(pf->dev, pf->total_vfs,
sizeof(struct otx2_vf_config),
GFP_KERNEL);
if (!pf->vf_configs)
return -ENOMEM;
for (i = 0; i < pf->total_vfs; i++) {
pf->vf_configs[i].pf = pf;
pf->vf_configs[i].intf_down = true;
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/pci.h`, `linux/etherdevice.h`, `linux/of.h`, `linux/if_vlan.h`, `linux/iommu.h`, `net/ip.h`.
- Detected declarations: `function otx2_change_mtu`, `function otx2_disable_flr_me_intr`, `function otx2_flr_wq_destroy`, `function otx2_flr_handler`, `function otx2_pf_flr_intr_handler`, `function otx2_pf_me_intr_handler`, `function otx2_register_flr_me_intr`, `function otx2_pf_flr_init`, `function otx2_queue_vf_work`, `function otx2_forward_msg_pfvf`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.