drivers/infiniband/hw/mlx5/srq.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/srq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/srq.c- Extension
.c- Size
- 11266 bytes
- Lines
- 465
- 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/mlx5/qp.hlinux/slab.hrdma/ib_umem.hrdma/ib_user_verbs.hmlx5_ib.hsrq.h
Detected Declarations
function Copyrightfunction mlx5_ib_srq_eventfunction create_srq_userfunction create_srq_kernelfunction destroy_srq_userfunction destroy_srq_kernelfunction mlx5_ib_create_srqfunction mlx5_ib_modify_srqfunction mlx5_ib_query_srqfunction mlx5_ib_destroy_srqfunction mlx5_ib_free_srq_wqefunction mlx5_ib_post_srq_recv
Annotated Snippet
switch (type) {
case MLX5_EVENT_TYPE_SRQ_RQ_LIMIT:
event.event = IB_EVENT_SRQ_LIMIT_REACHED;
break;
case MLX5_EVENT_TYPE_SRQ_CATAS_ERROR:
event.event = IB_EVENT_SRQ_ERR;
break;
default:
pr_warn("mlx5_ib: Unexpected event type %d on SRQ %06x\n",
type, srq->srqn);
return;
}
ibsrq->event_handler(&event, ibsrq->srq_context);
}
}
static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
struct mlx5_srq_attr *in,
struct ib_udata *udata, int buf_size)
{
struct mlx5_ib_dev *dev = to_mdev(pd->device);
struct mlx5_ib_create_srq ucmd;
struct mlx5_ib_ucontext *ucontext = rdma_udata_to_drv_context(
udata, struct mlx5_ib_ucontext, ibucontext);
int err;
u32 uidx = MLX5_IB_DEFAULT_UIDX;
err = ib_copy_validate_udata_in(udata, ucmd, flags);
if (err)
return err;
if (ucmd.reserved0 || ucmd.reserved1)
return -EINVAL;
if (in->type != IB_SRQT_BASIC) {
err = get_srq_user_index(ucontext, &ucmd, udata->inlen, &uidx);
if (err)
return err;
}
srq->wq_sig = !!(ucmd.flags & MLX5_SRQ_FLAG_SIGNATURE);
srq->umem = ib_umem_get_va(pd->device, ucmd.buf_addr, buf_size, 0);
if (IS_ERR(srq->umem)) {
mlx5_ib_dbg(dev, "failed umem get, size %d\n", buf_size);
err = PTR_ERR(srq->umem);
return err;
}
in->umem = srq->umem;
err = mlx5_ib_db_map_user(ucontext, NULL, 0, ucmd.db_addr, &srq->db);
if (err) {
mlx5_ib_dbg(dev, "map doorbell failed\n");
goto err_umem;
}
in->uid = (in->type != IB_SRQT_XRC) ? to_mpd(pd)->uid : 0;
if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 &&
in->type != IB_SRQT_BASIC)
in->user_index = uidx;
return 0;
err_umem:
ib_umem_release(srq->umem);
return err;
}
static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
struct mlx5_srq_attr *in, int buf_size)
{
int err;
int i;
struct mlx5_wqe_srq_next_seg *next;
err = mlx5_db_alloc(dev->mdev, &srq->db);
if (err) {
mlx5_ib_warn(dev, "alloc dbell rec failed\n");
return err;
}
if (mlx5_frag_buf_alloc_node(dev->mdev, buf_size, &srq->buf,
dev->mdev->priv.numa_node)) {
mlx5_ib_dbg(dev, "buf alloc failed\n");
err = -ENOMEM;
goto err_db;
}
Annotation
- Immediate include surface: `linux/mlx5/qp.h`, `linux/slab.h`, `rdma/ib_umem.h`, `rdma/ib_user_verbs.h`, `mlx5_ib.h`, `srq.h`.
- Detected declarations: `function Copyright`, `function mlx5_ib_srq_event`, `function create_srq_user`, `function create_srq_kernel`, `function destroy_srq_user`, `function destroy_srq_kernel`, `function mlx5_ib_create_srq`, `function mlx5_ib_modify_srq`, `function mlx5_ib_query_srq`, `function mlx5_ib_destroy_srq`.
- 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.