drivers/infiniband/sw/siw/siw_verbs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/siw/siw_verbs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/siw/siw_verbs.c- Extension
.c- Size
- 44521 bytes
- Lines
- 1890
- 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.
- 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/errno.hlinux/types.hlinux/uaccess.hlinux/vmalloc.hlinux/xarray.hnet/addrconf.hrdma/iw_cm.hrdma/ib_verbs.hrdma/ib_user_verbs.hrdma/uverbs_ioctl.hsiw.hsiw_verbs.hsiw_mem.h
Detected Declarations
function siw_mmap_freefunction siw_mmapfunction siw_alloc_ucontextfunction siw_dealloc_ucontextfunction siw_query_devicefunction siw_query_portfunction siw_get_port_immutablefunction siw_query_gidfunction siw_alloc_pdfunction siw_dealloc_pdfunction siw_qp_get_reffunction siw_qp_put_reffunction siw_mmap_entry_insertfunction siw_create_qpfunction siw_query_qpfunction siw_verbs_modify_qpfunction siw_destroy_qpfunction siw_copy_inline_sglfunction siw_sq_flush_wrfunction siw_rq_flush_wrfunction siw_post_sendfunction errorsfunction siw_post_receivefunction siw_destroy_cqfunction siw_create_cqfunction siw_poll_cqfunction siw_req_notify_cqfunction siw_dereg_mrfunction siw_reg_user_mrfunction siw_set_pbl_pagefunction siw_map_mr_sgfunction siw_get_dma_mrfunction siw_create_srqfunction siw_modify_srqfunction siw_query_srqfunction siw_destroy_srqfunction siw_post_srq_recvfunction siw_qp_eventfunction siw_cq_eventfunction siw_srq_eventfunction siw_port_event
Annotated Snippet
if (qp->recvq == NULL) {
rv = -ENOMEM;
goto err_out_xa;
}
qp->attrs.rq_size = num_rqe;
}
qp->attrs.sq_size = num_sqe;
qp->attrs.sq_max_sges = attrs->cap.max_send_sge;
qp->attrs.rq_max_sges = attrs->cap.max_recv_sge;
/* Make those two tunables fixed for now. */
qp->tx_ctx.gso_seg_limit = 1;
qp->tx_ctx.zcopy_tx = zcopy_tx;
qp->attrs.state = SIW_QP_STATE_IDLE;
if (udata) {
struct siw_uresp_create_qp uresp = {};
uresp.num_sqe = num_sqe;
uresp.num_rqe = num_rqe;
uresp.qp_id = qp_id(qp);
if (qp->sendq) {
length = num_sqe * sizeof(struct siw_sqe);
qp->sq_entry =
siw_mmap_entry_insert(uctx, qp->sendq,
length, &uresp.sq_key);
if (!qp->sq_entry) {
rv = -ENOMEM;
goto err_out_xa;
}
}
if (qp->recvq) {
length = num_rqe * sizeof(struct siw_rqe);
qp->rq_entry =
siw_mmap_entry_insert(uctx, qp->recvq,
length, &uresp.rq_key);
if (!qp->rq_entry) {
uresp.sq_key = SIW_INVAL_UOBJ_KEY;
rv = -ENOMEM;
goto err_out_xa;
}
}
if (udata->outlen < sizeof(uresp)) {
rv = -EINVAL;
goto err_out_xa;
}
rv = ib_respond_udata(udata, uresp);
if (rv)
goto err_out_xa;
}
qp->tx_cpu = siw_get_tx_cpu(sdev);
if (qp->tx_cpu < 0) {
rv = -EINVAL;
goto err_out_xa;
}
INIT_LIST_HEAD(&qp->devq);
spin_lock_irqsave(&sdev->lock, flags);
list_add_tail(&qp->devq, &sdev->qp_list);
spin_unlock_irqrestore(&sdev->lock, flags);
init_completion(&qp->qp_free);
return 0;
err_out_xa:
xa_erase(&sdev->qp_xa, qp_id(qp));
if (uctx) {
rdma_user_mmap_entry_remove(qp->sq_entry);
rdma_user_mmap_entry_remove(qp->rq_entry);
}
vfree(qp->sendq);
vfree(qp->recvq);
err_atomic:
atomic_dec(&sdev->num_qp);
return rv;
}
/*
* Minimum siw_query_qp() verb interface.
*
* @qp_attr_mask is not used but all available information is provided
*/
int siw_query_qp(struct ib_qp *base_qp, struct ib_qp_attr *qp_attr,
int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr)
{
Annotation
- Immediate include surface: `linux/errno.h`, `linux/types.h`, `linux/uaccess.h`, `linux/vmalloc.h`, `linux/xarray.h`, `net/addrconf.h`, `rdma/iw_cm.h`, `rdma/ib_verbs.h`.
- Detected declarations: `function siw_mmap_free`, `function siw_mmap`, `function siw_alloc_ucontext`, `function siw_dealloc_ucontext`, `function siw_query_device`, `function siw_query_port`, `function siw_get_port_immutable`, `function siw_query_gid`, `function siw_alloc_pd`, `function siw_dealloc_pd`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source 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.