drivers/pci/endpoint/functions/pci-epf-vntb.c
Source file repositories/reference/linux-study-clean/drivers/pci/endpoint/functions/pci-epf-vntb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/endpoint/functions/pci-epf-vntb.c- Extension
.c- Size
- 43382 bytes
- Lines
- 1679
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/atomic.hlinux/delay.hlinux/io.hlinux/module.hlinux/slab.hlinux/pci-ep-msi.hlinux/pci-epc.hlinux/pci-epf.hlinux/ntb.h
Detected Declarations
struct epf_ntb_ctrlstruct epf_ntbenum epf_ntb_barfunction epf_ntb_link_upfunction epf_ntb_configure_mwfunction epf_ntb_teardown_mwfunction epf_ntb_cmd_handlerfunction epf_ntb_doorbell_handlerfunction epf_ntb_config_sspad_bar_clearfunction epf_ntb_config_sspad_bar_setfunction epf_ntb_config_spad_bar_freefunction epf_ntb_config_spad_bar_allocfunction epf_ntb_configure_interruptfunction epf_ntb_db_bar_init_msi_doorbellfunction epf_ntb_db_bar_initfunction epf_ntb_db_bar_clearfunction epf_ntb_mw_bar_initfunction epf_ntb_mw_bar_clearfunction epf_ntb_is_bar_usedfunction epf_ntb_find_barfunction epf_ntb_init_epc_barfunction epf_ntb_epc_initfunction epf_ntb_epc_cleanupfunction epf_ntb_num_mws_storefunction epf_ntb_add_cfsfunction pci_readfunction pci_writefunction vpci_scan_busfunction vntb_epf_mw_countfunction vntb_epf_spad_countfunction vntb_epf_peer_mw_countfunction vntb_epf_db_valid_maskfunction vntb_epf_db_set_maskfunction vntb_epf_mw_set_transfunction vntb_epf_mw_clear_transfunction vntb_epf_peer_mw_get_addrfunction vntb_epf_link_enablefunction vntb_epf_spad_readfunction vntb_epf_spad_writefunction vntb_epf_peer_spad_readfunction vntb_epf_peer_spad_writefunction vntb_epf_peer_db_setfunction vntb_epf_db_readfunction vntb_epf_mw_get_alignfunction vntb_epf_link_is_upfunction vntb_epf_db_clear_maskfunction vntb_epf_db_clearfunction vntb_epf_link_disable
Annotated Snippet
static struct pci_driver vntb_pci_driver = {
.name = "pci-vntb",
.id_table = pci_vntb_table,
.probe = pci_vntb_probe,
};
/* ============ PCIe EPF Driver Bind ====================*/
/**
* epf_ntb_bind() - Initialize endpoint controller to provide NTB functionality
* @epf: NTB endpoint function device
*
* Initialize both the endpoint controllers associated with NTB function device.
* Invoked when a primary interface or secondary interface is bound to EPC
* device. This function will succeed only when EPC is bound to both the
* interfaces.
*
* Returns: Zero for success, or an error code in case of failure
*/
static int epf_ntb_bind(struct pci_epf *epf)
{
struct epf_ntb *ntb = epf_get_drvdata(epf);
struct device *dev = &epf->dev;
int ret;
if (!epf->epc) {
dev_dbg(dev, "PRIMARY EPC interface not yet bound\n");
return 0;
}
ret = epf_ntb_init_epc_bar(ntb);
if (ret) {
dev_err(dev, "Failed to create NTB EPC\n");
return ret;
}
ret = epf_ntb_config_spad_bar_alloc(ntb);
if (ret) {
dev_err(dev, "Failed to allocate BAR memory\n");
goto err_bar_alloc;
}
ret = epf_ntb_epc_init(ntb);
if (ret) {
dev_err(dev, "Failed to initialize EPC\n");
goto err_bar_alloc;
}
epf_set_drvdata(epf, ntb);
pci_space[0] = (ntb->vntb_pid << 16) | ntb->vntb_vid;
pci_vntb_table[0].vendor = ntb->vntb_vid;
pci_vntb_table[0].device = ntb->vntb_pid;
ret = pci_register_driver(&vntb_pci_driver);
if (ret) {
dev_err(dev, "failure register vntb pci driver\n");
goto err_epc_cleanup;
}
ret = vpci_scan_bus(ntb);
if (ret)
goto err_unregister;
return 0;
err_unregister:
pci_unregister_driver(&vntb_pci_driver);
err_epc_cleanup:
epf_ntb_epc_cleanup(ntb);
err_bar_alloc:
epf_ntb_config_spad_bar_free(ntb);
return ret;
}
/**
* epf_ntb_unbind() - Cleanup the initialization from epf_ntb_bind()
* @epf: NTB endpoint function device
*
* Cleanup the initialization from epf_ntb_bind()
*/
static void epf_ntb_unbind(struct pci_epf *epf)
{
struct epf_ntb *ntb = epf_get_drvdata(epf);
epf_ntb_epc_cleanup(ntb);
epf_ntb_config_spad_bar_free(ntb);
pci_unregister_driver(&vntb_pci_driver);
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/delay.h`, `linux/io.h`, `linux/module.h`, `linux/slab.h`, `linux/pci-ep-msi.h`, `linux/pci-epc.h`, `linux/pci-epf.h`.
- Detected declarations: `struct epf_ntb_ctrl`, `struct epf_ntb`, `enum epf_ntb_bar`, `function epf_ntb_link_up`, `function epf_ntb_configure_mw`, `function epf_ntb_teardown_mw`, `function epf_ntb_cmd_handler`, `function epf_ntb_doorbell_handler`, `function epf_ntb_config_sspad_bar_clear`, `function epf_ntb_config_sspad_bar_set`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: pattern 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.