drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c- Extension
.c- Size
- 21482 bytes
- Lines
- 883
- 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/etherdevice.hlinux/module.hlinux/pci.hlinux/net_tstamp.hotx2_common.hotx2_reg.hotx2_ptp.hcn10k.hcn10k_ipsec.h
Detected Declarations
function otx2vf_process_vfaf_mbox_msgfunction otx2vf_vfaf_mbox_handlerfunction otx2vf_process_mbox_msg_upfunction otx2vf_vfaf_mbox_up_handlerfunction otx2vf_vfaf_mbox_intr_handlerfunction otx2vf_disable_mbox_intrfunction otx2vf_register_mbox_intrfunction otx2vf_vfaf_mbox_destroyfunction otx2vf_vfaf_mbox_initfunction otx2vf_openfunction otx2vf_stopfunction otx2vf_xmitfunction otx2vf_set_rx_modefunction otx2vf_do_set_rx_modefunction otx2vf_change_mtufunction otx2vf_reset_taskfunction otx2vf_set_featuresfunction otx2_vf_wq_initfunction otx2vf_realloc_msix_vectorsfunction otx2vf_probefunction otx2vf_removefunction otx2vf_init_modulefunction otx2vf_cleanup_modulemodule init otx2vf_init_module
Annotated Snippet
static const struct net_device_ops otx2vf_netdev_ops = {
.ndo_open = otx2vf_open,
.ndo_stop = otx2vf_stop,
.ndo_start_xmit = otx2vf_xmit,
.ndo_select_queue = otx2_select_queue,
.ndo_set_rx_mode = otx2vf_set_rx_mode,
.ndo_set_mac_address = otx2_set_mac_address,
.ndo_change_mtu = otx2vf_change_mtu,
.ndo_set_features = otx2vf_set_features,
.ndo_get_stats64 = otx2_get_stats64,
.ndo_tx_timeout = otx2_tx_timeout,
.ndo_setup_tc = otx2_setup_tc,
.ndo_hwtstamp_get = otx2_config_hwtstamp_get,
.ndo_hwtstamp_set = otx2_config_hwtstamp_set,
};
static int otx2_vf_wq_init(struct otx2_nic *vf)
{
vf->otx2_wq = create_singlethread_workqueue("otx2vf_wq");
if (!vf->otx2_wq)
return -ENOMEM;
INIT_WORK(&vf->rx_mode_work, otx2vf_do_set_rx_mode);
INIT_WORK(&vf->reset_task, otx2vf_reset_task);
return 0;
}
static int otx2vf_realloc_msix_vectors(struct otx2_nic *vf)
{
struct otx2_hw *hw = &vf->hw;
int num_vec, err;
num_vec = hw->nix_msixoff;
num_vec += NIX_LF_CINT_VEC_START + hw->max_queues;
otx2vf_disable_mbox_intr(vf);
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(vf->dev, "%s: Failed to realloc %d IRQ vectors\n",
__func__, num_vec);
return err;
}
return otx2vf_register_mbox_intr(vf, false);
}
static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
int num_vec = pci_msix_vec_count(pdev);
struct device *dev = &pdev->dev;
int err, qcount, qos_txqs;
struct net_device *netdev;
struct otx2_nic *vf;
struct otx2_hw *hw;
err = pcim_enable_device(pdev);
if (err) {
dev_err(dev, "Failed to enable PCI device\n");
return err;
}
err = pcim_request_all_regions(pdev, DRV_NAME);
if (err) {
dev_err(dev, "PCI request regions failed 0x%x\n", err);
return err;
}
err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
if (err) {
dev_err(dev, "DMA mask config failed, abort\n");
return err;
}
pci_set_master(pdev);
qcount = num_online_cpus();
qos_txqs = min_t(int, qcount, OTX2_QOS_MAX_LEAF_NODES);
netdev = alloc_etherdev_mqs(sizeof(*vf), qcount + qos_txqs, qcount);
if (!netdev)
return -ENOMEM;
pci_set_drvdata(pdev, netdev);
SET_NETDEV_DEV(netdev, &pdev->dev);
vf = netdev_priv(netdev);
vf->netdev = netdev;
vf->pdev = pdev;
vf->dev = dev;
vf->iommu_domain = iommu_get_domain_for_dev(dev);
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/module.h`, `linux/pci.h`, `linux/net_tstamp.h`, `otx2_common.h`, `otx2_reg.h`, `otx2_ptp.h`, `cn10k.h`.
- Detected declarations: `function otx2vf_process_vfaf_mbox_msg`, `function otx2vf_vfaf_mbox_handler`, `function otx2vf_process_mbox_msg_up`, `function otx2vf_vfaf_mbox_up_handler`, `function otx2vf_vfaf_mbox_intr_handler`, `function otx2vf_disable_mbox_intr`, `function otx2vf_register_mbox_intr`, `function otx2vf_vfaf_mbox_destroy`, `function otx2vf_vfaf_mbox_init`, `function otx2vf_open`.
- 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.