drivers/infiniband/hw/hfi1/init.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hfi1/init.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hfi1/init.c- Extension
.c- Size
- 52758 bytes
- Lines
- 1988
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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/pci.hlinux/netdevice.hlinux/vmalloc.hlinux/delay.hlinux/xarray.hlinux/module.hlinux/printk.hlinux/hrtimer.hlinux/bitmap.hlinux/numa.hrdma/rdma_vt.hhfi.hdevice.hcommon.htrace.hmad.hsdma.hdebugfs.hverbs.haspm.haffinity.hexp_rcv.hnetdev.h
Detected Declarations
function hfi1_create_kctxtfunction hfi1_create_kctxtsfunction countfunction hfi1_rcd_freefunction hfi1_rcd_putfunction hfi1_rcd_getfunction allocate_rcd_indexfunction hfi1_rcd_get_by_indexfunction _putfunction hfi1_create_ctxtdatafunction staticfunction hfi1_create_ctxtdatafunction heldfunction cca_timer_fnfunction hfi1_init_pportdatafunction loadtime_initfunction transmitfunction enable_chipfunction create_workqueuesfunction destroy_workqueuesfunction enable_general_intrfunction stop_timersfunction hfi1_initfunction hfi1_free_ctxtdatafunction finalize_asic_datafunction hfi1_alloc_devdatafunction hfi1_disable_after_errorfunction compute_krcvqsfunction hfi1_mod_initfunction hfi1_mod_cleanupfunction cleanup_device_datafunction postinit_cleanupfunction init_onefunction wait_for_clientsfunction remove_onefunction shutdown_onefunction memoryfunction hfi1_setup_eagerbufsmodule init hfi1_mod_init
Annotated Snippet
static struct pci_driver hfi1_pci_driver = {
.name = DRIVER_NAME,
.probe = init_one,
.remove = remove_one,
.shutdown = shutdown_one,
.id_table = hfi1_pci_tbl,
.err_handler = &hfi1_pci_err_handler,
};
static void __init compute_krcvqs(void)
{
int i;
for (i = 0; i < krcvqsset; i++)
n_krcvqs += krcvqs[i];
}
/*
* Do all the generic driver unit- and chip-independent memory
* allocation and initialization.
*/
static int __init hfi1_mod_init(void)
{
int ret;
ret = dev_init();
if (ret)
goto bail;
ret = node_affinity_init();
if (ret)
goto bail;
/* validate max MTU before any devices start */
if (!valid_opa_max_mtu(hfi1_max_mtu)) {
pr_err("Invalid max_mtu 0x%x, using 0x%x instead\n",
hfi1_max_mtu, HFI1_DEFAULT_MAX_MTU);
hfi1_max_mtu = HFI1_DEFAULT_MAX_MTU;
}
/* valid CUs run from 1-128 in powers of 2 */
if (hfi1_cu > 128 || !is_power_of_2(hfi1_cu))
hfi1_cu = 1;
/* valid credit return threshold is 0-100, variable is unsigned */
if (user_credit_return_threshold > 100)
user_credit_return_threshold = 100;
compute_krcvqs();
/*
* sanitize receive interrupt count, time must wait until after
* the hardware type is known
*/
if (rcv_intr_count > RCV_HDR_HEAD_COUNTER_MASK)
rcv_intr_count = RCV_HDR_HEAD_COUNTER_MASK;
/* reject invalid combinations */
if (rcv_intr_count == 0 && rcv_intr_timeout == 0) {
pr_err("Invalid mode: both receive interrupt count and available timeout are zero - setting interrupt count to 1\n");
rcv_intr_count = 1;
}
if (rcv_intr_count > 1 && rcv_intr_timeout == 0) {
/*
* Avoid indefinite packet delivery by requiring a timeout
* if count is > 1.
*/
pr_err("Invalid mode: receive interrupt count greater than 1 and available timeout is zero - setting available timeout to 1\n");
rcv_intr_timeout = 1;
}
if (rcv_intr_dynamic && !(rcv_intr_count > 1 && rcv_intr_timeout > 0)) {
/*
* The dynamic algorithm expects a non-zero timeout
* and a count > 1.
*/
pr_err("Invalid mode: dynamic receive interrupt mitigation with invalid count and timeout - turning dynamic off\n");
rcv_intr_dynamic = 0;
}
/* sanitize link CRC options */
link_crc_mask &= SUPPORTED_CRCS;
ret = opfn_init();
if (ret < 0) {
pr_err("Failed to allocate opfn_wq");
goto bail_dev;
}
/*
* These must be called before the driver is registered with
* the PCI subsystem.
*/
hfi1_dbg_init();
ret = pci_register_driver(&hfi1_pci_driver);
Annotation
- Immediate include surface: `linux/pci.h`, `linux/netdevice.h`, `linux/vmalloc.h`, `linux/delay.h`, `linux/xarray.h`, `linux/module.h`, `linux/printk.h`, `linux/hrtimer.h`.
- Detected declarations: `function hfi1_create_kctxt`, `function hfi1_create_kctxts`, `function count`, `function hfi1_rcd_free`, `function hfi1_rcd_put`, `function hfi1_rcd_get`, `function allocate_rcd_index`, `function hfi1_rcd_get_by_index`, `function _put`, `function hfi1_create_ctxtdata`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.