From: Abhijit Gangurde <abhijit.gangurde@amd.com>
To: <jgg@ziepe.ca>, <leon@kernel.org>
Cc: <allen.hubbe@amd.com>, <nikhil.agarwal@amd.com>,
<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Abhijit Gangurde" <abhijit.gangurde@amd.com>
Subject: [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
Date: Wed, 18 Nov 2026 20:53:13 +0530 [thread overview]
Message-ID: <20261118152313.113714-3-abhijit.gangurde@amd.com> (raw)
In-Reply-To: <20261118152313.113714-1-abhijit.gangurde@amd.com>
Userspace passes each QP ring to create_qp as a
struct ib_uverbs_buffer_desc on the core attributes
UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM and
UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM. Those attributes are already
optional on UVERBS_METHOD_QP_CREATE. The get_context bit
IONIC_CTX_CMASK_CQ_QP_BUF_UMEM tells userspace it may send them.
ionic_get_user_q_umem() resolves one ring:
- No attribute: validate the qdesc address and pin it with
ib_umem_get_va, as before.
- VA descriptor: length equals the qdesc size and the address matches
the qdesc; pin through ib_umem_get_attr_or_va.
- DMABUF descriptor: qdesc.addr is zero. Check queue geometry only,
require a page-aligned dma-buf offset, and pin through
ib_umem_get_attr_or_va.
Any other descriptor is -EINVAL. Access is 0, so the VA mapping
direction stays DMA_TO_DEVICE. SRQ creation passes no attribute
bundle and keeps ib_umem_get_va. An SRQ QP still only checks that
the RQ qdesc is zero.
ionic_qp_req is not changed, so a provider that does not send the
attributes still creates a QP on the write path.
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
.../infiniband/hw/ionic/ionic_controlpath.c | 94 ++++++++++++++-----
1 file changed, 73 insertions(+), 21 deletions(-)
diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 11458262f280..02f1972126ed 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -14,13 +14,9 @@
#define ionic_set_ecn(tos) (((tos) | 2u) & ~1u)
#define ionic_clear_ecn(tos) ((tos) & ~3u)
-static int ionic_validate_qdesc(struct ionic_qdesc *q)
+static int ionic_validate_qdesc_geom(struct ionic_qdesc *q)
{
- if (!q->addr || !q->size || !q->mask ||
- !q->depth_log2 || !q->stride_log2)
- return -EINVAL;
-
- if (q->addr & (PAGE_SIZE - 1))
+ if (!q->size || !q->mask || !q->depth_log2 || !q->stride_log2)
return -EINVAL;
if (q->mask != BIT(q->depth_log2) - 1)
@@ -32,6 +28,14 @@ static int ionic_validate_qdesc(struct ionic_qdesc *q)
return 0;
}
+static int ionic_validate_qdesc(struct ionic_qdesc *q)
+{
+ if (!q->addr || (q->addr & (PAGE_SIZE - 1)))
+ return -EINVAL;
+
+ return ionic_validate_qdesc_geom(q);
+}
+
static u32 ionic_get_eqid(struct ionic_ibdev *dev, u32 comp_vector, u8 udma_idx)
{
/* EQ per vector per udma, and the first eqs reserved for async events.
@@ -1993,10 +1997,57 @@ static void ionic_qp_sq_destroy_cmb(struct ionic_ibdev *dev,
ionic_put_cmb(dev->lif_cfg.lif, qp->sq_cmb_pgid, qp->sq_cmb_order);
}
+static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q,
+ const struct uverbs_attr_bundle *attrs,
+ u16 attr_id, struct ib_umem **umem_out)
+{
+ struct ib_uverbs_buffer_desc desc;
+ struct ib_umem *umem;
+ int rc;
+
+ if (attrs && uverbs_attr_is_valid(attrs, attr_id)) {
+ rc = uverbs_get_buffer_desc(attrs, attr_id, &desc);
+ if (rc)
+ return rc;
+
+ if (desc.length != q->size)
+ return -EINVAL;
+
+ if (desc.type == IB_UVERBS_BUFFER_TYPE_DMABUF) {
+ if (desc.addr & (PAGE_SIZE - 1))
+ return -EINVAL;
+
+ rc = ionic_validate_qdesc_geom(q);
+ } else if (desc.type == IB_UVERBS_BUFFER_TYPE_VA &&
+ desc.addr == q->addr) {
+ rc = ionic_validate_qdesc(q);
+ } else {
+ rc = -EINVAL;
+ }
+ if (rc)
+ return rc;
+
+ umem = ib_umem_get_attr_or_va(&dev->ibdev, attrs, attr_id,
+ q->addr, q->size, 0);
+ } else {
+ rc = ionic_validate_qdesc(q);
+ if (rc)
+ return rc;
+
+ umem = ib_umem_get_va(&dev->ibdev, q->addr, q->size, 0);
+ }
+ if (IS_ERR(umem))
+ return PTR_ERR(umem);
+
+ *umem_out = umem;
+ return 0;
+}
+
static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
struct ionic_qp *qp, struct ionic_qdesc *sq,
struct ionic_tbl_buf *buf, int max_wr, int max_sge,
- int max_data, int sq_spec, struct ib_udata *udata)
+ int max_data, int sq_spec, struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs)
{
u32 wqe_size;
int rc = 0;
@@ -2040,7 +2091,9 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
return rc;
if (udata) {
- rc = ionic_validate_qdesc(sq);
+ rc = ionic_get_user_q_umem(dev, sq, attrs,
+ UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM,
+ &qp->sq_umem);
if (rc)
return rc;
@@ -2054,10 +2107,6 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
qp->sq_meta = NULL;
qp->sq_msn_idx = NULL;
-
- qp->sq_umem = ib_umem_get_va(&dev->ibdev, sq->addr, sq->size, 0);
- if (IS_ERR(qp->sq_umem))
- return PTR_ERR(qp->sq_umem);
} else {
qp->sq_umem = NULL;
@@ -2260,7 +2309,8 @@ static void ionic_rq_destroy_cmb(struct ionic_ibdev *dev,
static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
struct ionic_rq *rq, struct ionic_qdesc *qdesc,
struct ionic_tbl_buf *buf, int max_wr, int max_sge,
- int rq_spec, struct ib_udata *udata)
+ int rq_spec, struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs)
{
u32 wqe_size;
int rc = 0;
@@ -2278,7 +2328,9 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
return rc;
if (udata) {
- rc = ionic_validate_qdesc(qdesc);
+ rc = ionic_get_user_q_umem(dev, qdesc, attrs,
+ UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM,
+ &rq->umem);
if (rc)
return rc;
@@ -2291,10 +2343,6 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
rq->q.stride_log2 = qdesc->stride_log2;
rq->meta = NULL;
-
- rq->umem = ib_umem_get_va(&dev->ibdev, qdesc->addr, qdesc->size, 0);
- if (IS_ERR(rq->umem))
- return PTR_ERR(rq->umem);
} else {
rq->umem = NULL;
@@ -2380,6 +2428,7 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
struct ionic_qp *qp = to_ionic_qp(ibqp);
struct ionic_ctx *ctx =
rdma_udata_to_drv_context(udata, struct ionic_ctx, ibctx);
+ const struct uverbs_attr_bundle *attrs = NULL;
struct ionic_qp_resp resp = {};
struct ionic_qp_req req = {};
struct ionic_cq *cq;
@@ -2388,6 +2437,8 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
int rc;
if (udata) {
+ attrs = rdma_udata_to_uverbs_attr_bundle(udata);
+
rc = ib_copy_validate_udata_in(udata, req, rsvd);
if (rc)
return rc;
@@ -2466,7 +2517,8 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
rc = ionic_qp_sq_init(dev, ctx, qp, &req.sq, &sq_buf,
attr->cap.max_send_wr, attr->cap.max_send_sge,
- attr->cap.max_inline_data, req.sq_spec, udata);
+ attr->cap.max_inline_data, req.sq_spec, udata,
+ attrs);
if (rc)
goto err_sq;
@@ -2485,7 +2537,7 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
qp->rq.qid = qp->qpid;
rc = ionic_rq_init(dev, ctx, &qp->rq, &req.rq, &rq_buf,
attr->cap.max_recv_wr, attr->cap.max_recv_sge,
- req.rq_spec, udata);
+ req.rq_spec, udata, attrs);
}
if (rc)
goto err_rq;
@@ -3092,7 +3144,7 @@ int ionic_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *attr,
rc = ionic_rq_init(dev, ctx, &srq->rq, &req.rq, &buf,
attr->attr.max_wr, attr->attr.max_sge,
- req.rq_spec, udata);
+ req.rq_spec, udata, NULL);
if (rc)
return rc;
--
2.43.0
prev parent reply other threads:[~2026-11-18 15:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 15:23 [for-next v1 0/2] RDMA/ionic: Accept CQ, SQ, and RQ rings as " Abhijit Gangurde
2026-11-18 15:23 ` [for-next v1 1/2] RDMA/ionic: Accept CQ ring buffers as ioctl " Abhijit Gangurde
2026-11-18 15:23 ` Abhijit Gangurde [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118152313.113714-3-abhijit.gangurde@amd.com \
--to=abhijit.gangurde@amd.com \
--cc=allen.hubbe@amd.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=nikhil.agarwal@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®