drivers/infiniband/sw/rdmavt/cq.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rdmavt/cq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/rdmavt/cq.c- Extension
.c- Size
- 12940 bytes
- Lines
- 538
- 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/slab.hlinux/vmalloc.hrdma/uverbs_ioctl.hcq.hvt.htrace.h
Detected Declarations
function rvt_cq_enterfunction send_completefunction ib_create_cqfunction vmallocfunction rvt_mmapfunction ib_destroy_cqfunction ib_req_notify_cqfunction rvt_resize_cqfunction vmallocfunction rvt_mmapfunction rvt_poll_cqfunction rvt_driver_cq_initfunction rvt_cq_exitexport rvt_cq_enter
Annotated Snippet
if (cq->ibcq.event_handler) {
struct ib_event ev;
ev.device = cq->ibcq.device;
ev.element.cq = &cq->ibcq;
ev.event = IB_EVENT_CQ_ERR;
cq->ibcq.event_handler(&ev, cq->ibcq.cq_context);
}
return false;
}
trace_rvt_cq_enter(cq, entry, head);
if (uqueue) {
uqueue[head].wr_id = entry->wr_id;
uqueue[head].status = entry->status;
uqueue[head].opcode = entry->opcode;
uqueue[head].vendor_err = entry->vendor_err;
uqueue[head].byte_len = entry->byte_len;
uqueue[head].ex.imm_data = entry->ex.imm_data;
uqueue[head].qp_num = entry->qp->qp_num;
uqueue[head].src_qp = entry->src_qp;
uqueue[head].wc_flags = entry->wc_flags;
uqueue[head].pkey_index = entry->pkey_index;
uqueue[head].slid = ib_lid_cpu16(entry->slid);
uqueue[head].sl = entry->sl;
uqueue[head].dlid_path_bits = entry->dlid_path_bits;
uqueue[head].port_num = entry->port_num;
/* Make sure entry is written before the head index. */
RDMA_WRITE_UAPI_ATOMIC(u_wc->head, next);
} else {
kqueue[head] = *entry;
k_wc->head = next;
}
if (cq->notify == IB_CQ_NEXT_COMP ||
(cq->notify == IB_CQ_SOLICITED &&
(solicited || entry->status != IB_WC_SUCCESS))) {
/*
* This will cause send_complete() to be called in
* another thread.
*/
cq->notify = RVT_CQ_NONE;
cq->triggered++;
queue_work_on(cq->comp_vector_cpu, comp_vector_wq,
&cq->comptask);
}
spin_unlock_irqrestore(&cq->lock, flags);
return true;
}
EXPORT_SYMBOL(rvt_cq_enter);
static void send_complete(struct work_struct *work)
{
struct rvt_cq *cq = container_of(work, struct rvt_cq, comptask);
/*
* The completion handler will most likely rearm the notification
* and poll for all pending entries. If a new completion entry
* is added while we are in this routine, queue_work()
* won't call us again until we return so we check triggered to
* see if we need to call the handler again.
*/
for (;;) {
u8 triggered = cq->triggered;
/*
* IPoIB connected mode assumes the callback is from a
* soft IRQ. We simulate this by blocking "bottom halves".
* See the implementation for ipoib_cm_handle_tx_wc(),
* netif_tx_lock_bh() and netif_tx_lock().
*/
local_bh_disable();
cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
local_bh_enable();
if (cq->triggered == triggered)
return;
}
}
/**
* rvt_create_cq - create a completion queue
* @ibcq: Allocated CQ
* @attr: creation attributes
* @attrs: uverbs bundle
*
* Called by ib_create_cq() in the generic verbs code.
*
* Return: 0 on success
*/
Annotation
- Immediate include surface: `linux/slab.h`, `linux/vmalloc.h`, `rdma/uverbs_ioctl.h`, `cq.h`, `vt.h`, `trace.h`.
- Detected declarations: `function rvt_cq_enter`, `function send_complete`, `function ib_create_cq`, `function vmalloc`, `function rvt_mmap`, `function ib_destroy_cq`, `function ib_req_notify_cq`, `function rvt_resize_cq`, `function vmalloc`, `function rvt_mmap`.
- 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.