[for-next v4 3/4] RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes

From: Abhijit Gangurde

Date: Thu Dec 03 2026 - 06:08:41 EST


Userspace can now pass each enabled CQ ring to create_cq as a
struct ib_uverbs_buffer_desc in a per-UDMA driver attribute, instead
of only as a raw address in ionic_cq_req.

Advertise support with IONIC_CTX_CMASK_CQ_QP_BUF_UMEM in the get_context
response. Register two optional UVERBS_ATTR_UMEM attributes,
IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0 and _1, on UVERBS_METHOD_CQ_CREATE
through ibdev->driver_def.

For each UDMA index in udma_mask, ionic_cq_get_user_umem() pins the
ring with ib_umem_get_attr() on the attribute for that index. The core
resolves the descriptor, so the ring can be a virtual address or a
dma-buf and the driver does not look inside it. req_cq->addr is not
used when the attribute is present. Without the attribute the ring is
pinned from req_cq->addr with DMA_FROM_DEVICE, as before.

A ring passed in the attribute must be exactly req_cq->size bytes, so
the page table given to the device covers the ring and nothing else.
Any other length is rejected with -EINVAL.

A ring passed as a virtual address descriptor is mapped
DMA_BIDIRECTIONAL, because ib_umem_get_attr() derives the direction
from the access flags. The core CQ helpers that map DMA_FROM_DEVICE
only take UVERBS_ATTR_CREATE_CQ_BUF_UMEM, not a driver attribute.

An attribute for a UDMA index that is not in udma_mask is rejected
with -EINVAL. The kernel admin CQ path passes no attribute bundle and
is unchanged.

ionic_cq_req and ionic_cq_resp are not changed, so older providers
continue to use the write command path.

Signed-off-by: Abhijit Gangurde <abhijit.gangurde@xxxxxxx>
---
MAINTAINERS | 1 +
drivers/infiniband/hw/ionic/ionic_admin.c | 2 +-
.../infiniband/hw/ionic/ionic_controlpath.c | 56 +++++++++++++++----
drivers/infiniband/hw/ionic/ionic_ibdev.c | 17 ++++++
drivers/infiniband/hw/ionic/ionic_ibdev.h | 2 +
include/uapi/rdma/ionic-abi.h | 3 +
include/uapi/rdma/ionic_user_ioctl_cmds.h | 15 +++++
7 files changed, 83 insertions(+), 13 deletions(-)
create mode 100644 include/uapi/rdma/ionic_user_ioctl_cmds.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 222b7fc2c3aa..9d79cea2ab84 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1293,6 +1293,7 @@ S: Maintained
F: Documentation/networking/device_drivers/ethernet/pensando/ionic_rdma.rst
F: drivers/infiniband/hw/ionic/
F: include/uapi/rdma/ionic-abi.h
+F: include/uapi/rdma/ionic_user_ioctl_cmds.h

AMD PMC DRIVER
M: Shyam Sundar S K <Shyam-sundar.S-k@xxxxxxx>
diff --git a/drivers/infiniband/hw/ionic/ionic_admin.c b/drivers/infiniband/hw/ionic/ionic_admin.c
index 859893568538..ae2a67daa9e8 100644
--- a/drivers/infiniband/hw/ionic/ionic_admin.c
+++ b/drivers/infiniband/hw/ionic/ionic_admin.c
@@ -575,7 +575,7 @@ static struct ionic_vcq *ionic_create_rdma_admincq(struct ionic_ibdev *dev,
vcq->udma_mask = 1;
cq = &vcq->cq[0];

- rc = ionic_create_cq_common(vcq, &buf, &attr, NULL, NULL,
+ rc = ionic_create_cq_common(vcq, &buf, &attr, NULL, NULL, NULL,
NULL, 0);
if (rc)
goto err_init;
diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 3abb8c01daf6..c3a47aa108e4 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -76,23 +76,42 @@ static void ionic_put_cqid(struct ionic_ibdev *dev, u32 cqid)
ionic_resid_put(&dev->inuse_cqid, bitid);
}

+static const u16 ionic_cq_buf_attrs[] = {
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0,
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1,
+};
+
static int ionic_cq_get_user_umem(struct ionic_ibdev *dev, struct ionic_cq *cq,
- const struct ionic_qdesc *req_cq)
+ const struct ionic_qdesc *req_cq,
+ const struct uverbs_attr_bundle *attrs,
+ int udma_idx)
{
struct ib_umem *umem;
int rc;

+ if (udma_idx < 0 || udma_idx >= ARRAY_SIZE(ionic_cq_buf_attrs))
+ return -EINVAL;
+
rc = ionic_validate_qdesc(req_cq);
if (rc)
return rc;

- umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, req_cq->addr,
- req_cq->size, IB_ACCESS_LOCAL_WRITE);
+ umem = ib_umem_get_attr(&dev->ibdev, attrs,
+ ionic_cq_buf_attrs[udma_idx], req_cq->size,
+ IB_ACCESS_LOCAL_WRITE);
if (IS_ERR(umem))
return PTR_ERR(umem);

- /* The ring is given to the device as whole pages */
- if (ib_umem_offset(umem)) {
+ if (!umem) {
+ umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL,
+ req_cq->addr, req_cq->size,
+ IB_ACCESS_LOCAL_WRITE);
+ if (IS_ERR(umem))
+ return PTR_ERR(umem);
+ }
+
+ /* The device is given whole pages, and only those of the ring */
+ if (umem->length != req_cq->size || ib_umem_offset(umem)) {
ib_umem_release(umem);
return -EINVAL;
}
@@ -106,6 +125,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
const struct ib_cq_init_attr *attr,
struct ionic_ctx *ctx,
struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs,
struct ionic_qdesc *req_cq,
int udma_idx)
{
@@ -134,7 +154,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
INIT_LIST_HEAD(&cq->flush_rq);

if (udata) {
- rc = ionic_cq_get_user_umem(dev, cq, req_cq);
+ rc = ionic_cq_get_user_umem(dev, cq, req_cq, attrs, udma_idx);
if (rc)
goto err_qdesc;

@@ -448,7 +468,8 @@ int ionic_alloc_ucontext(struct ib_ucontext *ibctx, struct ib_udata *udata)
resp.udma_count = dev->lif_cfg.udma_count;
resp.expdb_mask = dev->lif_cfg.expdb_mask;
resp.rcq_sign_bit = dev->lif_cfg.rcq_sign_bit;
- resp.comp_mask |= IONIC_CTX_CMASK_IONIC_FLAGS;
+ resp.comp_mask |= IONIC_CTX_CMASK_IONIC_FLAGS |
+ IONIC_CTX_CMASK_CQ_QP_BUF_UMEM;

if (dev->lif_cfg.sq_expdb)
resp.expdb_qtypes |= IONIC_EXPDB_SQ;
@@ -1393,7 +1414,7 @@ int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ionic_vcq *vcq = to_ionic_vcq(ibcq);
struct ionic_tbl_buf buf = {};
struct ionic_cq_resp resp = {};
- struct ionic_cq_req req;
+ struct ionic_cq_req req = {};
int udma_idx = 0, rc;

if (udata) {
@@ -1412,13 +1433,24 @@ int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
goto err_init;
}

- for (; udma_idx < dev->lif_cfg.udma_count; ++udma_idx) {
+ for (udma_idx = 0; udma_idx < ARRAY_SIZE(ionic_cq_buf_attrs);
+ udma_idx++) {
+ if (vcq->udma_mask & BIT(udma_idx))
+ continue;
+
+ if (uverbs_attr_is_valid(attrs, ionic_cq_buf_attrs[udma_idx])) {
+ rc = -EINVAL;
+ udma_idx = 0;
+ goto err_init;
+ }
+ }
+
+ for (udma_idx = 0; udma_idx < dev->lif_cfg.udma_count; ++udma_idx) {
if (!(vcq->udma_mask & BIT(udma_idx)))
continue;

- rc = ionic_create_cq_common(vcq, &buf, attr, ctx, udata,
- &req.cq[udma_idx],
- udma_idx);
+ rc = ionic_create_cq_common(vcq, &buf, attr, ctx, udata, attrs,
+ &req.cq[udma_idx], udma_idx);
if (rc)
goto err_init;

diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.c b/drivers/infiniband/hw/ionic/ionic_ibdev.c
index b4d4544bb7ac..e64c8e891f30 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.c
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.c
@@ -11,6 +11,9 @@

#include "ionic_ibdev.h"

+#define UVERBS_MODULE_NAME ionic_rdma
+#include <rdma/uverbs_named_ioctl.h>
+
#define DRIVER_DESCRIPTION "AMD Pensando RoCE HCA driver"
#define DEVICE_DESCRIPTION "AMD Pensando RoCE HCA"

@@ -217,6 +220,18 @@ static void ionic_disassociate_ucontext(struct ib_ucontext *ibcontext)
*/
}

+ADD_UVERBS_ATTRIBUTES_SIMPLE(
+ ionic_cq_create,
+ UVERBS_OBJECT_CQ,
+ UVERBS_METHOD_CQ_CREATE,
+ UVERBS_ATTR_UMEM(IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0, UA_OPTIONAL),
+ UVERBS_ATTR_UMEM(IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1, UA_OPTIONAL));
+
+static const struct uapi_definition ionic_uapi_defs[] = {
+ UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_CQ, &ionic_cq_create),
+ {},
+};
+
static const struct ib_device_ops ionic_dev_ops = {
.owner = THIS_MODULE,
.driver_id = RDMA_DRIVER_IONIC,
@@ -376,6 +391,8 @@ static struct ionic_ibdev *ionic_create_ibdev(struct ionic_aux_dev *ionic_adev)

ionic_stats_init(dev);

+ ibdev->driver_def = ionic_uapi_defs;
+
rc = ib_register_device(ibdev, "ionic_%d", ibdev->dev.parent);
if (rc)
goto err_register;
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
index 8e7e52c9f492..6cf8bad98672 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.h
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
@@ -10,6 +10,7 @@
#include <rdma/uverbs_ioctl.h>

#include <rdma/ionic-abi.h>
+#include <rdma/ionic_user_ioctl_cmds.h>
#include <ionic_api.h>
#include <ionic_regs.h>

@@ -490,6 +491,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
const struct ib_cq_init_attr *attr,
struct ionic_ctx *ctx,
struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs,
struct ionic_qdesc *req_cq,
int udma_idx);
int ionic_post_create_cq_cmd(struct ionic_cq *cq,
diff --git a/include/uapi/rdma/ionic-abi.h b/include/uapi/rdma/ionic-abi.h
index ac48fcd19a4f..f499f083059c 100644
--- a/include/uapi/rdma/ionic-abi.h
+++ b/include/uapi/rdma/ionic-abi.h
@@ -24,6 +24,9 @@

enum ionic_ctx_resp_comp_mask {
IONIC_CTX_CMASK_IONIC_FLAGS = 1 << 0,
+ IONIC_CTX_CMASK_UDP_SPORT = 1 << 1,
+ IONIC_CTX_CMASK_CQ_NOTIFY_IOCTL = 1 << 2,
+ IONIC_CTX_CMASK_CQ_QP_BUF_UMEM = 1 << 3,
};

struct ionic_ctx_req {
diff --git a/include/uapi/rdma/ionic_user_ioctl_cmds.h b/include/uapi/rdma/ionic_user_ioctl_cmds.h
new file mode 100644
index 000000000000..98bb8d7238e6
--- /dev/null
+++ b/include/uapi/rdma/ionic_user_ioctl_cmds.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* Copyright (C) 2026, Advanced Micro Devices, Inc */
+
+#ifndef IONIC_USER_IOCTL_CMDS_H
+#define IONIC_USER_IOCTL_CMDS_H
+
+#include <linux/types.h>
+#include <rdma/ib_user_ioctl_cmds.h>
+
+enum ionic_ib_create_cq_attrs {
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0 = UVERBS_ID_DRIVER_NS_WITH_UHW,
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1,
+};
+
+#endif
--
2.43.0