drivers/infiniband/sw/rdmavt/qp.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rdmavt/qp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/rdmavt/qp.c- Extension
.c- Size
- 82522 bytes
- Lines
- 3216
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/hash.hlinux/bitops.hlinux/lockdep.hlinux/vmalloc.hlinux/slab.hrdma/ib_verbs.hrdma/ib_hdrs.hrdma/opa_addr.hrdma/uverbs_ioctl.hqp.hvt.htrace.h
Detected Declarations
function rvt_wss_llc_sizefunction cacheless_memcpyfunction rvt_wss_exitfunction rvt_wss_initfunction wss_advance_clean_counterfunction wss_insertfunction wss_exceeds_thresholdfunction get_map_pagefunction init_qpn_tablefunction free_qpn_tablefunction rvt_driver_qp_initfunction rvt_free_qp_cbfunction rvt_free_all_qpsfunction rvt_qp_exitfunction mk_qpnfunction alloc_qpnfunction rvt_clear_mr_refsfunction rvt_swqe_has_lkeyfunction rvt_qp_sends_has_lkeyfunction rvt_qp_acks_has_lkeyfunction rvt_qp_mr_cleanfunction rvt_remove_qpfunction lockdep_is_heldfunction rvt_alloc_rqfunction rvt_create_qpfunction _rvt_reset_qpfunction _rvt_reset_qpfunction rvt_free_qpnfunction get_allowed_opsfunction free_ud_wq_attrfunction alloc_ud_wq_attrfunction ib_create_qpfunction rvt_mmapfunction rvt_error_qpfunction rvt_insert_qpfunction rvt_modify_qpfunction mtufunction rvt_destroy_qpfunction rvt_query_qpfunction rvt_post_recvfunction rvt_qp_valid_operationfunction rvt_qp_is_availfunction rvt_post_one_wrfunction rvt_post_sendfunction rvt_post_srq_recvfunction init_sgefunction get_rvt_headfunction rvt_get_rwqe
Annotated Snippet
if (!map->page) {
get_map_page(qpt, map);
if (!map->page) {
ret = -ENOMEM;
break;
}
}
set_bit(offset, map->page);
offset++;
if (offset == RVT_BITS_PER_PAGE) {
/* next page */
qpt->nmaps++;
map++;
offset = 0;
}
}
return ret;
}
/**
* free_qpn_table - free the QP number table for a device
* @qpt: the QPN table
*/
static void free_qpn_table(struct rvt_qpn_table *qpt)
{
int i;
for (i = 0; i < ARRAY_SIZE(qpt->map); i++)
free_page((unsigned long)qpt->map[i].page);
}
/**
* rvt_driver_qp_init - Init driver qp resources
* @rdi: rvt dev strucutre
*
* Return: 0 on success
*/
int rvt_driver_qp_init(struct rvt_dev_info *rdi)
{
int i;
int ret = -ENOMEM;
if (!rdi->dparms.qp_table_size)
return -EINVAL;
/*
* If driver is not doing any QP allocation then make sure it is
* providing the necessary QP functions.
*/
if (!rdi->driver_f.free_all_qps ||
!rdi->driver_f.qp_priv_alloc ||
!rdi->driver_f.qp_priv_free ||
!rdi->driver_f.notify_qp_reset ||
!rdi->driver_f.notify_restart_rc)
return -EINVAL;
/* allocate parent object */
rdi->qp_dev = kzalloc_node(sizeof(*rdi->qp_dev), GFP_KERNEL,
rdi->dparms.node);
if (!rdi->qp_dev)
return -ENOMEM;
/* allocate hash table */
rdi->qp_dev->qp_table_size = rdi->dparms.qp_table_size;
rdi->qp_dev->qp_table_bits = ilog2(rdi->dparms.qp_table_size);
rdi->qp_dev->qp_table =
kmalloc_array_node(rdi->qp_dev->qp_table_size,
sizeof(*rdi->qp_dev->qp_table),
GFP_KERNEL, rdi->dparms.node);
if (!rdi->qp_dev->qp_table)
goto no_qp_table;
for (i = 0; i < rdi->qp_dev->qp_table_size; i++)
RCU_INIT_POINTER(rdi->qp_dev->qp_table[i], NULL);
spin_lock_init(&rdi->qp_dev->qpt_lock);
/* initialize qpn map */
if (init_qpn_table(rdi, &rdi->qp_dev->qpn_table))
goto fail_table;
spin_lock_init(&rdi->n_qps_lock);
return 0;
fail_table:
kfree(rdi->qp_dev->qp_table);
free_qpn_table(&rdi->qp_dev->qpn_table);
no_qp_table:
Annotation
- Immediate include surface: `linux/hash.h`, `linux/bitops.h`, `linux/lockdep.h`, `linux/vmalloc.h`, `linux/slab.h`, `rdma/ib_verbs.h`, `rdma/ib_hdrs.h`, `rdma/opa_addr.h`.
- Detected declarations: `function rvt_wss_llc_size`, `function cacheless_memcpy`, `function rvt_wss_exit`, `function rvt_wss_init`, `function wss_advance_clean_counter`, `function wss_insert`, `function wss_exceeds_threshold`, `function get_map_page`, `function init_qpn_table`, `function free_qpn_table`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.