drivers/infiniband/core/cq.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/cq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/cq.c- Extension
.c- Size
- 13020 bytes
- Lines
- 519
- 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/err.hlinux/slab.hrdma/ib_verbs.hcore_priv.htrace/events/rdma_core.h
Detected Declarations
function ib_cq_rdma_dim_workfunction rdma_dim_initfunction rdma_dim_destroyfunction __poll_cqfunction __ib_process_cqfunction befunction ib_process_cq_directfunction ib_cq_completion_directfunction ib_poll_handlerfunction ib_cq_completion_softirqfunction ib_cq_poll_workfunction ib_cq_completion_workqueuefunction ib_free_cqfunction ib_cq_pool_cleanupfunction list_for_each_entry_safefunction ib_alloc_cqsfunction ib_cq_pool_getfunction list_for_each_entryfunction ib_cq_pool_putexport ib_process_cq_directexport __ib_alloc_cqexport __ib_alloc_cq_anyexport ib_free_cqexport ib_cq_pool_getexport ib_cq_pool_put
Annotated Snippet
if (ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0) {
trace_cq_reschedule(cq);
irq_poll_sched(&cq->iop);
}
}
if (dim)
rdma_dim(dim, completed);
return completed;
}
static void ib_cq_completion_softirq(struct ib_cq *cq, void *private)
{
trace_cq_schedule(cq);
irq_poll_sched(&cq->iop);
}
static void ib_cq_poll_work(struct work_struct *work)
{
struct ib_cq *cq = container_of(work, struct ib_cq, work);
int completed;
completed = __ib_process_cq(cq, IB_POLL_BUDGET_WORKQUEUE, cq->wc,
IB_POLL_BATCH);
if (completed >= IB_POLL_BUDGET_WORKQUEUE ||
ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0)
queue_work(cq->comp_wq, &cq->work);
else if (cq->dim)
rdma_dim(cq->dim, completed);
}
static void ib_cq_completion_workqueue(struct ib_cq *cq, void *private)
{
trace_cq_schedule(cq);
queue_work(cq->comp_wq, &cq->work);
}
/**
* __ib_alloc_cq - allocate a completion queue
* @dev: device to allocate the CQ for
* @private: driver private data, accessible from cq->cq_context
* @nr_cqe: number of CQEs to allocate
* @comp_vector: HCA completion vectors for this CQ
* @poll_ctx: context to poll the CQ from.
* @caller: module owner name.
*
* This is the proper interface to allocate a CQ for in-kernel users. A
* CQ allocated with this interface will automatically be polled from the
* specified context. The ULP must use wr->wr_cqe instead of wr->wr_id
* to use this CQ abstraction.
*/
struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private, int nr_cqe,
int comp_vector, enum ib_poll_context poll_ctx,
const char *caller)
{
struct ib_cq_init_attr cq_attr = {
.cqe = nr_cqe,
.comp_vector = comp_vector,
};
struct ib_cq *cq;
int ret = -ENOMEM;
if (WARN_ON_ONCE(!nr_cqe))
return ERR_PTR(-EINVAL);
cq = rdma_zalloc_drv_obj(dev, ib_cq);
if (!cq)
return ERR_PTR(ret);
cq->device = dev;
cq->cq_context = private;
cq->poll_ctx = poll_ctx;
atomic_set(&cq->usecnt, 0);
cq->comp_vector = comp_vector;
cq->wc = kmalloc_objs(*cq->wc, IB_POLL_BATCH);
if (!cq->wc)
goto out_free_cq;
rdma_restrack_new(&cq->res, RDMA_RESTRACK_CQ);
rdma_restrack_set_name(&cq->res, caller);
ret = dev->ops.create_cq(cq, &cq_attr, NULL);
if (ret)
goto out_free_wc;
rdma_dim_init(cq);
switch (cq->poll_ctx) {
Annotation
- Immediate include surface: `linux/err.h`, `linux/slab.h`, `rdma/ib_verbs.h`, `core_priv.h`, `trace/events/rdma_core.h`.
- Detected declarations: `function ib_cq_rdma_dim_work`, `function rdma_dim_init`, `function rdma_dim_destroy`, `function __poll_cq`, `function __ib_process_cq`, `function be`, `function ib_process_cq_direct`, `function ib_cq_completion_direct`, `function ib_poll_handler`, `function ib_cq_completion_softirq`.
- 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.