drivers/infiniband/sw/rdmavt/srq.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rdmavt/srq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/rdmavt/srq.c- Extension
.c- Size
- 7487 bytes
- Lines
- 306
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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.hlinux/vmalloc.hrdma/uverbs_ioctl.hsrq.hvt.hqp.h
Detected Declarations
function Copyrightfunction rvt_create_srqfunction rvt_mmapfunction rvt_modify_srqfunction rvt_mmapfunction rvt_query_srqfunction rvt_destroy_srq
Annotated Snippet
if (IS_ERR(srq->ip)) {
ret = PTR_ERR(srq->ip);
goto bail_wq;
}
ret = ib_copy_to_udata(udata, &srq->ip->offset,
sizeof(srq->ip->offset));
if (ret)
goto bail_ip;
}
/*
* ib_create_srq() will initialize srq->ibsrq.
*/
spin_lock_init(&srq->rq.lock);
srq->limit = srq_init_attr->attr.srq_limit;
spin_lock(&dev->n_srqs_lock);
if (dev->n_srqs_allocated == dev->dparms.props.max_srq) {
spin_unlock(&dev->n_srqs_lock);
ret = -ENOMEM;
goto bail_ip;
}
dev->n_srqs_allocated++;
spin_unlock(&dev->n_srqs_lock);
if (srq->ip) {
spin_lock_irq(&dev->pending_lock);
list_add(&srq->ip->pending_mmaps, &dev->pending_mmaps);
spin_unlock_irq(&dev->pending_lock);
}
return 0;
bail_ip:
kfree(srq->ip);
bail_wq:
rvt_free_rq(&srq->rq);
bail_srq:
return ret;
}
/**
* rvt_modify_srq - modify a shared receive queue
* @ibsrq: the SRQ to modify
* @attr: the new attributes of the SRQ
* @attr_mask: indicates which attributes to modify
* @udata: user data for libibverbs.so
*
* Return: 0 on success
*/
int rvt_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask attr_mask,
struct ib_udata *udata)
{
struct rvt_srq *srq = ibsrq_to_rvtsrq(ibsrq);
struct rvt_dev_info *dev = ib_to_rvt(ibsrq->device);
struct rvt_rq tmp_rq = {};
__u64 offset_addr;
int ret = 0;
if (attr_mask & IB_SRQ_MAX_WR) {
struct rvt_krwq *okwq = NULL;
struct rvt_rwq *owq = NULL;
struct rvt_rwqe *p;
u32 sz, size, n, head, tail;
/* Check that the requested sizes are below the limits. */
if ((attr->max_wr > dev->dparms.props.max_srq_wr) ||
((attr_mask & IB_SRQ_LIMIT) ?
attr->srq_limit : srq->limit) > attr->max_wr)
return -EINVAL;
sz = sizeof(struct rvt_rwqe) +
srq->rq.max_sge * sizeof(struct ib_sge);
size = attr->max_wr + 1;
if (rvt_alloc_rq(&tmp_rq, size * sz, dev->dparms.node,
udata))
return -ENOMEM;
/* Check that we can write the offset to mmap. */
if (udata && udata->inlen >= sizeof(__u64)) {
__u64 offset = 0;
ret = ib_copy_from_udata(&offset_addr, udata,
sizeof(offset_addr));
if (ret)
goto bail_free;
if (copy_to_user(u64_to_user_ptr(offset_addr), &offset,
sizeof(offset))) {
ret = -EFAULT;
Annotation
- Immediate include surface: `linux/err.h`, `linux/slab.h`, `linux/vmalloc.h`, `rdma/uverbs_ioctl.h`, `srq.h`, `vt.h`, `qp.h`.
- Detected declarations: `function Copyright`, `function rvt_create_srq`, `function rvt_mmap`, `function rvt_modify_srq`, `function rvt_mmap`, `function rvt_query_srq`, `function rvt_destroy_srq`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.