drivers/misc/mrvl_cn10k_dpi.c
Source file repositories/reference/linux-study-clean/drivers/misc/mrvl_cn10k_dpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/mrvl_cn10k_dpi.c- Extension
.c- Size
- 17964 bytes
- Lines
- 677
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/bitfield.hlinux/compat.hlinux/delay.hlinux/miscdevice.hlinux/module.hlinux/pci.hlinux/irq.hlinux/interrupt.huapi/misc/mrvl_cn10k_dpi.h
Detected Declarations
struct dpivf_configstruct dpipf_vfstruct dpi_mboxstruct dpipfstruct dpi_mbox_messageenum dpi_mbox_rsp_typefunction dpi_reg_writefunction dpi_reg_readfunction dpi_wqe_cs_offsetfunction dpi_queue_initfunction dpi_queue_finifunction dpi_mbox_intr_handlerfunction queue_configfunction dpi_pfvf_mbox_workfunction dpi_setup_mbox_regsfunction dpi_pfvf_mbox_setupfunction dpi_pfvf_mbox_destroyfunction dpi_initfunction dpi_finifunction dpi_free_irq_vectorsfunction dpi_irq_initfunction dpi_mps_mrrs_configfunction dpi_engine_configfunction dpi_dev_ioctlfunction dpi_probefunction dpi_remove
Annotated Snippet
static const struct file_operations dpi_device_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = dpi_dev_ioctl,
.compat_ioctl = compat_ptr_ioctl,
};
static int dpi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct device *dev = &pdev->dev;
struct dpipf *dpi;
int ret;
dpi = devm_kzalloc(dev, sizeof(*dpi), GFP_KERNEL);
if (!dpi)
return -ENOMEM;
dpi->pdev = pdev;
ret = pcim_enable_device(pdev);
if (ret) {
dev_err(dev, "DPI: Failed to enable PCI device\n");
return ret;
}
ret = pcim_iomap_regions(pdev, BIT(0) | BIT(4), KBUILD_MODNAME);
if (ret) {
dev_err(dev, "DPI: Failed to request MMIO region\n");
return ret;
}
dpi->reg_base = pcim_iomap_table(pdev)[PCI_DPI_CFG_BAR];
/* Initialize global PF registers */
dpi_init(dpi);
/* Setup PF-VF mailbox */
ret = dpi_pfvf_mbox_setup(dpi);
if (ret) {
dev_err(dev, "DPI: Failed to setup pf-vf mbox\n");
goto err_dpi_fini;
}
/* Register interrupts */
ret = dpi_irq_init(dpi);
if (ret) {
dev_err(dev, "DPI: Failed to initialize irq vectors\n");
goto err_dpi_mbox_free;
}
pci_set_drvdata(pdev, dpi);
dpi->miscdev.minor = MISC_DYNAMIC_MINOR;
dpi->miscdev.name = KBUILD_MODNAME;
dpi->miscdev.fops = &dpi_device_fops;
dpi->miscdev.parent = dev;
ret = misc_register(&dpi->miscdev);
if (ret) {
dev_err(dev, "DPI: Failed to register misc device\n");
goto err_dpi_mbox_free;
}
return 0;
err_dpi_mbox_free:
dpi_pfvf_mbox_destroy(dpi);
err_dpi_fini:
dpi_fini(dpi);
return ret;
}
static void dpi_remove(struct pci_dev *pdev)
{
struct dpipf *dpi = pci_get_drvdata(pdev);
misc_deregister(&dpi->miscdev);
pci_sriov_configure_simple(pdev, 0);
dpi_pfvf_mbox_destroy(dpi);
dpi_fini(dpi);
pci_set_drvdata(pdev, NULL);
}
static const struct pci_device_id dpi_id_table[] = {
{ PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_MRVL_CN10K_DPI_PF,
PCI_VENDOR_ID_CAVIUM, PCI_SUBDEVID_MRVL_CN10K_DPI_PF) },
{ 0, } /* end of table */
};
static struct pci_driver dpi_driver = {
.name = KBUILD_MODNAME,
.id_table = dpi_id_table,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/compat.h`, `linux/delay.h`, `linux/miscdevice.h`, `linux/module.h`, `linux/pci.h`, `linux/irq.h`, `linux/interrupt.h`.
- Detected declarations: `struct dpivf_config`, `struct dpipf_vf`, `struct dpi_mbox`, `struct dpipf`, `struct dpi_mbox_message`, `enum dpi_mbox_rsp_type`, `function dpi_reg_write`, `function dpi_reg_read`, `function dpi_wqe_cs_offset`, `function dpi_queue_init`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.