From: Siva Reddy Kallam <siva.kallam@broadcom.com>
To: leonro@nvidia.com, jgg@nvidia.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rdma@vger.kernel.org, vikas.gupta@broadcom.com,
ajit.khaparde@broadcom.com, dharmender.garg@broadcom.com,
sachin.holla@broadcom.com,
Suresh Rupanagudi <suresh.rupanagudi@broadcom.com>,
Siva Reddy Kallam <siva.kallam@broadcom.com>
Subject: [RDMA v2 09/13] RDMA/bng_re: Add SRQ verbs
Date: Fri, 4 Dec 2026 07:48:01 -0800 [thread overview]
Message-ID: <20261204155249.1002019-10-siva.kallam@broadcom.com> (raw)
In-Reply-To: <20261204155249.1002019-1-siva.kallam@broadcom.com>
From: Suresh Rupanagudi <suresh.rupanagudi@broadcom.com>
This patch adds below verbs.
- bng_re_create_srq
- bng_re_modify_srq
- bng_re_query_srq
- bng_re_destroy_srq
Signed-off-by: Suresh Rupanagudi <suresh.rupanagudi@broadcom.com>
Signed-off-by: Siva Reddy Kallam <siva.kallam@broadcom.com>
Signed-off-by: Sachin Holla <sachin.holla@broadcom.com>
---
drivers/infiniband/hw/bng_re/bng_dev.c | 5 +
drivers/infiniband/hw/bng_re/bng_res.h | 8 +
drivers/infiniband/hw/bng_re/bng_roce_hsi.h | 6 +-
drivers/infiniband/hw/bng_re/bng_sp.c | 151 +++++++++++-
drivers/infiniband/hw/bng_re/bng_sp.h | 26 +++
drivers/infiniband/hw/bng_re/bng_verbs.c | 241 ++++++++++++++++++++
drivers/infiniband/hw/bng_re/bng_verbs.h | 24 ++
include/uapi/rdma/bng_re-abi.h | 11 +
8 files changed, 469 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/bng_re/bng_dev.c b/drivers/infiniband/hw/bng_re/bng_dev.c
index 43bd58d88430..2748c9b9b984 100644
--- a/drivers/infiniband/hw/bng_re/bng_dev.c
+++ b/drivers/infiniband/hw/bng_re/bng_dev.c
@@ -58,6 +58,11 @@ static const struct ib_device_ops bng_re_dev_ops = {
.pre_destroy_cq = bng_re_pre_destroy_cq,
.destroy_cq = bng_re_destroy_cq,
.poll_cq = bng_re_poll_cq,
+ .create_srq = bng_re_create_srq,
+ .modify_srq = bng_re_modify_srq,
+ .query_srq = bng_re_query_srq,
+ .destroy_srq = bng_re_destroy_srq,
+ INIT_RDMA_OBJ_SIZE(ib_srq, bng_re_srq, ib_srq),
INIT_RDMA_OBJ_SIZE(ib_cq, bng_re_cq, ib_cq),
INIT_RDMA_OBJ_SIZE(ib_pd, bng_re_pd, ib_pd),
INIT_RDMA_OBJ_SIZE(ib_ucontext, bng_re_ucontext, ib_uctx),
diff --git a/drivers/infiniband/hw/bng_re/bng_res.h b/drivers/infiniband/hw/bng_re/bng_res.h
index 93df8af08a54..e9c20d5eea22 100644
--- a/drivers/infiniband/hw/bng_re/bng_res.h
+++ b/drivers/infiniband/hw/bng_re/bng_res.h
@@ -305,6 +305,14 @@ static inline void bng_re_ring_nq_db(struct bng_re_db_info *info,
bng_re_ring_db(info, type);
}
+static inline void bng_re_srq_arm_db(struct bng_re_db_info *info, u32 th)
+{
+ u64 key = 0;
+
+ key = BNG_RE_INIT_DBHDR(info->xid, DBC_DBC_TYPE_SRQ_ARM, th, info->toggle);
+ writeq(key, info->priv_db);
+}
+
static inline void bng_re_hwq_incr_cons(u32 max_elements, u32 *cons, u32 cnt,
u32 *dbinfo_flags)
{
diff --git a/drivers/infiniband/hw/bng_re/bng_roce_hsi.h b/drivers/infiniband/hw/bng_re/bng_roce_hsi.h
index 6c9d45464ef6..68361e5812fa 100644
--- a/drivers/infiniband/hw/bng_re/bng_roce_hsi.h
+++ b/drivers/infiniband/hw/bng_re/bng_roce_hsi.h
@@ -1119,7 +1119,8 @@ struct cmdq_create_srq {
#define CMDQ_CREATE_SRQ_PBL_PG_SIZE_PG_8M 0x4UL
#define CMDQ_CREATE_SRQ_PBL_PG_SIZE_PG_1G 0x5UL
#define CMDQ_CREATE_SRQ_PBL_PG_SIZE_LAST CMDQ_CREATE_SRQ_PBL_PG_SIZE_PG_1G
- u8 reserved40[5];
+ u8 srq_size_hi;
+ u8 reserved32[4];
__le64 reserved64;
};
@@ -1224,7 +1225,8 @@ struct creq_query_srq_resp_sb {
u8 reserved8;
__le32 xid;
__le16 srq_limit;
- __le16 reserved16;
+ u8 srq_limit_hi;
+ u8 reserved8_1;
__le32 data[4];
};
diff --git a/drivers/infiniband/hw/bng_re/bng_sp.c b/drivers/infiniband/hw/bng_re/bng_sp.c
index a4e6692a48ba..40fe509db724 100644
--- a/drivers/infiniband/hw/bng_re/bng_sp.c
+++ b/drivers/infiniband/hw/bng_re/bng_sp.c
@@ -112,7 +112,10 @@ int bng_re_get_dev_attr(struct bng_re_rcfw *rcfw)
attr->max_srq = le16_to_cpu(sb->max_srq);
attr->max_srq_wqes = le32_to_cpu(sb->max_srq_wr) - 1;
- attr->max_srq_sges = sb->max_srq_sge;
+ /* The CREATE_SRQ SGE field is only 4 bits wide */
+ attr->max_srq_sges = min_t(u32, sb->max_srq_sge,
+ CMDQ_CREATE_SRQ_SRQ_SGE_MASK >>
+ CMDQ_CREATE_SRQ_SRQ_SGE_SFT);
attr->max_pkey = 1;
attr->max_inline_data = le32_to_cpu(sb->max_inline_data);
/*
@@ -766,3 +769,149 @@ int bng_sp_destroy_cq(struct bng_re_res *res, struct bng_sp_cq *cq)
return 0;
}
+int bng_sp_create_srq(struct bng_re_res *res, struct bng_sp_srq *srq)
+{
+ struct bng_re_rcfw *rcfw = res->rcfw;
+ struct bng_re_hwq_attr hwq_attr = {};
+ struct creq_create_srq_resp resp = {};
+ struct bng_re_cmdqmsg msg = {};
+ struct cmdq_create_srq req = {};
+ struct bng_re_pbl *pbl;
+ u16 pg_sz_lvl;
+ int rc;
+
+ if (srq->max_wqe > BNG_SP_SRQ_SIZE_MAX) {
+ dev_err(&res->pdev->dev, "SRQ size %u exceeds max %u\n",
+ srq->max_wqe, BNG_SP_SRQ_SIZE_MAX);
+ return -EINVAL;
+ }
+
+ hwq_attr.res = res;
+ hwq_attr.sginfo = &srq->sginfo;
+ hwq_attr.depth = srq->max_wqe;
+ hwq_attr.stride = srq->wqe_size;
+ hwq_attr.type = BNG_HWQ_TYPE_QUEUE;
+ rc = bng_re_alloc_init_hwq(&srq->hwq, &hwq_attr);
+ if (rc)
+ return rc;
+
+ srq->dbinfo.flags = 0;
+ bng_re_rcfw_cmd_prep((struct cmdq_base *)&req,
+ CMDQ_BASE_OPCODE_CREATE_SRQ,
+ sizeof(req));
+
+ /* Configure the request */
+ req.dpi = cpu_to_le32(srq->dpi->dpi);
+ req.srq_handle = cpu_to_le64((uintptr_t)srq);
+
+ req.srq_size = cpu_to_le16(srq->hwq.max_elements & U16_MAX);
+ req.srq_size_hi = (srq->hwq.max_elements >> 16) & U8_MAX;
+ pbl = &srq->hwq.pbl[BNG_PBL_LVL_0];
+ pg_sz_lvl = ((u16)bng_re_base_pg_size(&srq->hwq) <<
+ CMDQ_CREATE_SRQ_PG_SIZE_SFT);
+ pg_sz_lvl |= (srq->hwq.level & CMDQ_CREATE_SRQ_LVL_MASK) <<
+ CMDQ_CREATE_SRQ_LVL_SFT;
+ req.pg_size_lvl = cpu_to_le16(pg_sz_lvl);
+ req.pbl = cpu_to_le64(pbl->pg_map_arr[0]);
+ req.pd_id = cpu_to_le32(srq->pd->id);
+ req.eventq_id = cpu_to_le16(srq->eventq_hw_ring_id);
+ req.srq_fwo = cpu_to_le16(((res->dattr->max_srq_sges <<
+ CMDQ_CREATE_SRQ_SRQ_SGE_SFT) &
+ CMDQ_CREATE_SRQ_SRQ_SGE_MASK) |
+ (((srq->fwo_offset >> BNG_SP_FWO_4K_SHIFT) <<
+ CMDQ_CREATE_SRQ_SRQ_FWO_SFT) &
+ CMDQ_CREATE_SRQ_SRQ_FWO_MASK));
+
+ bng_re_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req), sizeof(resp), 0);
+ rc = bng_re_rcfw_send_message(rcfw, &msg);
+ if (rc)
+ goto fail;
+
+ srq->id = le32_to_cpu(resp.xid);
+
+ srq->dbinfo.hwq = &srq->hwq;
+ srq->dbinfo.xid = srq->id;
+ srq->dbinfo.db = srq->dpi->dbr;
+ srq->dbinfo.max_slot = 1;
+ srq->dbinfo.priv_db = res->dpi_tbl.priv_db;
+ srq->dbinfo.toggle = 0;
+ srq->dbinfo.seed = 0;
+ spin_lock_init(&srq->dbinfo.lock);
+ srq->dbinfo.res = res;
+ srq->dbinfo.is_l2 = false;
+
+ /* Arm the SRQ */
+ bng_re_armen_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ_ARMENA);
+
+ return 0;
+
+fail:
+ bng_re_free_hwq(res, &srq->hwq);
+
+ return rc;
+}
+
+int bng_sp_query_srq(struct bng_re_res *res, struct bng_sp_srq *srq)
+{
+ struct bng_re_rcfw *rcfw = res->rcfw;
+ struct creq_query_srq_resp resp = {};
+ struct bng_re_cmdqmsg msg = {};
+ struct bng_re_rcfw_sbuf sbuf;
+ struct creq_query_srq_resp_sb *sb;
+ struct cmdq_query_srq req = {};
+ int rc;
+
+ bng_re_rcfw_cmd_prep((struct cmdq_base *)&req,
+ CMDQ_BASE_OPCODE_QUERY_SRQ,
+ sizeof(req));
+
+ /* Configure the request */
+ sbuf.size = ALIGN(sizeof(*sb), BNG_FW_CMDQE_UNITS);
+ sbuf.sb = dma_alloc_coherent(&rcfw->pdev->dev, sbuf.size,
+ &sbuf.dma_addr, GFP_KERNEL);
+ if (!sbuf.sb)
+ return -ENOMEM;
+ req.resp_size = sbuf.size / BNG_FW_CMDQE_UNITS;
+ req.srq_cid = cpu_to_le32(srq->id);
+ sb = sbuf.sb;
+
+ bng_re_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req),
+ sizeof(resp), 0);
+ rc = bng_re_rcfw_send_message(rcfw, &msg);
+ if (!rc)
+ srq->threshold = le16_to_cpu(sb->srq_limit) |
+ ((u32)sb->srq_limit_hi << 16);
+
+ /* After a timeout the command is only abandoned, firmware may still
+ * write the response. Leave the small buffer allocated in that case.
+ */
+ if (rc != -ETIMEDOUT)
+ dma_free_coherent(&rcfw->pdev->dev, sbuf.size,
+ sbuf.sb, sbuf.dma_addr);
+
+ return rc;
+}
+
+int bng_sp_destroy_srq(struct bng_re_res *res, struct bng_sp_srq *srq)
+{
+ struct bng_re_rcfw *rcfw = res->rcfw;
+ struct creq_destroy_srq_resp resp = {};
+ struct bng_re_cmdqmsg msg = {};
+ struct cmdq_destroy_srq req = {};
+ int rc;
+
+ bng_re_rcfw_cmd_prep((struct cmdq_base *)&req,
+ CMDQ_BASE_OPCODE_DESTROY_SRQ,
+ sizeof(req));
+
+ /* Configure the request */
+ req.srq_cid = cpu_to_le32(srq->id);
+
+ bng_re_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req), sizeof(resp), 0);
+ rc = bng_re_rcfw_send_message(rcfw, &msg);
+ if (rc)
+ return rc;
+ bng_re_free_hwq(res, &srq->hwq);
+
+ return 0;
+}
diff --git a/drivers/infiniband/hw/bng_re/bng_sp.h b/drivers/infiniband/hw/bng_re/bng_sp.h
index 26a5178d63a5..bdc046be1ffc 100644
--- a/drivers/infiniband/hw/bng_re/bng_sp.h
+++ b/drivers/infiniband/hw/bng_re/bng_sp.h
@@ -105,6 +105,28 @@ struct bng_sp_cq {
atomic_t nq_users;
};
+/* SRQ SP layer structure */
+/* The firmware takes a 24-bit SRQ size and limit */
+#define BNG_SP_SRQ_SIZE_MAX 0xFFFFFFU
+/* The first-WQE offset is passed to firmware in 4K units */
+#define BNG_SP_FWO_4K_SHIFT 12
+
+struct bng_sp_srq {
+ struct bng_sp_pd *pd;
+ struct bng_re_dpi *dpi;
+ struct bng_re_hwq hwq;
+ struct bng_re_db_info dbinfo;
+ struct bng_re_sg_info sginfo;
+ u32 id;
+ u16 wqe_size;
+ u32 max_wqe;
+ u32 max_sge;
+ u32 threshold;
+ /* Offset of the ring inside the first pinned page, 4K multiple */
+ u32 fwo_offset;
+ u16 eventq_hw_ring_id;
+};
+
int bng_re_get_dev_attr(struct bng_re_rcfw *rcfw);
int bng_sp_alloc_sgid_tbl(struct bng_re_sgid_tbl *sgid_tbl, u16 size);
@@ -141,4 +163,8 @@ int bng_sp_resize_cq(struct bng_re_res *res, struct bng_sp_cq *cq,
void bng_sp_cq_untrack(struct bng_sp_cq *cq);
int bng_sp_destroy_cq(struct bng_re_res *res, struct bng_sp_cq *cq);
+int bng_sp_create_srq(struct bng_re_res *res, struct bng_sp_srq *srq);
+int bng_sp_query_srq(struct bng_re_res *res, struct bng_sp_srq *srq);
+int bng_sp_destroy_srq(struct bng_re_res *res, struct bng_sp_srq *srq);
+
#endif
diff --git a/drivers/infiniband/hw/bng_re/bng_verbs.c b/drivers/infiniband/hw/bng_re/bng_verbs.c
index 8ec0a19867b5..0f71740a254f 100644
--- a/drivers/infiniband/hw/bng_re/bng_verbs.c
+++ b/drivers/infiniband/hw/bng_re/bng_verbs.c
@@ -1327,3 +1327,244 @@ int bng_re_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
*/
return 0;
}
+
+/* SRQ helper function */
+static int bng_re_init_user_srq(struct bng_re_dev *rdev,
+ struct bng_re_srq *srq,
+ struct ib_udata *udata)
+{
+ struct bng_re_ucontext *cntx =
+ rdma_udata_to_drv_context(udata, struct bng_re_ucontext,
+ ib_uctx);
+ struct bng_sp_srq *sp_srq = &srq->sp_srq;
+ struct bng_re_srq_req ureq = {};
+ struct ib_umem *umem;
+ size_t bytes;
+
+ /* srqva is mandatory, a shorter request cannot describe the ring.
+ * Fields past inlen (from an older library) stay zero.
+ */
+ if (udata->inlen < offsetofend(struct bng_re_srq_req, srqva))
+ return -EINVAL;
+
+ if (ib_copy_from_udata(&ureq, udata, min(udata->inlen, sizeof(ureq))))
+ return -EFAULT;
+
+ /* The ring may start inside a page, firmware takes the offset in 4K
+ * units, so a finer alignment cannot be described.
+ */
+ if (!IS_ALIGNED(ureq.srqva, BIT(BNG_SP_FWO_4K_SHIFT)))
+ return -EINVAL;
+
+ /* Bound the ring size before pinning any user memory */
+ if (sp_srq->max_wqe > BNG_SP_SRQ_SIZE_MAX ||
+ check_mul_overflow((size_t)sp_srq->max_wqe,
+ (size_t)sp_srq->wqe_size, &bytes))
+ return -EINVAL;
+
+ bytes = PAGE_ALIGN(bytes);
+ umem = ib_umem_get_va(&rdev->ibdev, ureq.srqva, bytes,
+ IB_ACCESS_LOCAL_WRITE);
+ if (IS_ERR(umem))
+ return PTR_ERR(umem);
+
+ srq->umem = umem;
+ sp_srq->sginfo.umem = umem;
+ sp_srq->sginfo.pgsize = PAGE_SIZE;
+ sp_srq->sginfo.pgshft = PAGE_SHIFT;
+ sp_srq->fwo_offset = ureq.srqva & ~PAGE_MASK;
+ sp_srq->dpi = &cntx->dpi;
+
+ return 0;
+}
+
+/* SRQ operations */
+int bng_re_create_srq(struct ib_srq *ib_srq,
+ struct ib_srq_init_attr *srq_init_attr,
+ struct ib_udata *udata)
+{
+ struct bng_re_dev_attr *dev_attr;
+ struct bng_re_ucontext *uctx;
+ struct bng_re_dev *rdev;
+ struct bng_re_srq *srq;
+ struct bng_re_srq_resp resp = {};
+ struct bng_re_pd *pd;
+ struct ib_pd *ib_pd;
+ int rc, entries;
+
+ ib_pd = ib_srq->pd;
+ pd = container_of(ib_pd, struct bng_re_pd, ib_pd);
+ rdev = pd->rdev;
+ dev_attr = rdev->dev_attr;
+ srq = container_of(ib_srq, struct bng_re_srq, ib_srq);
+ spin_lock_init(&srq->lock);
+
+ if (srq_init_attr->attr.max_wr > dev_attr->max_srq_wqes) {
+ ibdev_err(&rdev->ibdev, "Create SRQ failed - max exceeded\n");
+ rc = -EINVAL;
+ goto exit;
+ }
+
+ if (srq_init_attr->attr.max_sge > dev_attr->max_srq_sges) {
+ ibdev_err(&rdev->ibdev,
+ "Create SRQ failed - max_sge %u exceeds supported %u\n",
+ srq_init_attr->attr.max_sge, dev_attr->max_srq_sges);
+ rc = -EINVAL;
+ goto exit;
+ }
+
+ if (srq_init_attr->srq_type != IB_SRQT_BASIC) {
+ rc = -EOPNOTSUPP;
+ goto exit;
+ }
+
+ /* Kernel SRQs need post_srq_recv, which is not supported yet */
+ if (!udata) {
+ rc = -EOPNOTSUPP;
+ goto exit;
+ }
+
+ uctx = rdma_udata_to_drv_context(udata, struct bng_re_ucontext, ib_uctx);
+ srq->rdev = rdev;
+ srq->sp_srq.pd = &pd->sp_pd;
+ srq->sp_srq.dpi = &rdev->dpi_privileged;
+ /* Allocate 1 more than what's provided so posting max doesn't
+ * mean empty
+ */
+ entries = bng_re_init_depth(srq_init_attr->attr.max_wr + 1, uctx);
+ /* max_srq_wqes is already one below the firmware maximum */
+ if (entries > dev_attr->max_srq_wqes + 1)
+ entries = dev_attr->max_srq_wqes + 1;
+ srq->sp_srq.max_wqe = entries;
+ srq->max_wr = srq_init_attr->attr.max_wr;
+
+ srq->sp_srq.max_sge = srq_init_attr->attr.max_sge;
+ /* Size every WQE for the device maximum number of SGEs */
+ srq->sp_srq.wqe_size = bng_re_get_rwqe_size(dev_attr->max_srq_sges);
+ srq->sp_srq.eventq_hw_ring_id = rdev->nqr->nq[0].ring_id;
+ srq->sp_srq.sginfo.pgsize = PAGE_SIZE;
+ srq->sp_srq.sginfo.pgshft = PAGE_SHIFT;
+
+ rc = bng_re_init_user_srq(rdev, srq, udata);
+ if (rc)
+ goto fail;
+
+ rc = bng_sp_create_srq(&rdev->bng_res, &srq->sp_srq);
+ if (rc) {
+ ibdev_err(&rdev->ibdev, "Create HW SRQ failed!\n");
+ goto fail;
+ }
+
+ resp.srqid = srq->sp_srq.id;
+ rc = ib_copy_to_udata(udata, &resp, min(sizeof(resp), udata->outlen));
+ if (rc) {
+ ibdev_err(&rdev->ibdev, "SRQ copy to udata failed!\n");
+ if (bng_sp_destroy_srq(&rdev->bng_res, &srq->sp_srq)) {
+ /* Create fails, so the core drops the SRQ and nothing
+ * can retry the destroy. Release the queue memory
+ * instead of leaking it.
+ */
+ ibdev_err(&rdev->ibdev, "Rollback of SRQ %u failed\n",
+ srq->sp_srq.id);
+ bng_re_free_hwq(&rdev->bng_res, &srq->sp_srq.hwq);
+ }
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ ib_umem_release(srq->umem);
+exit:
+ return rc;
+}
+
+int bng_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr,
+ enum ib_srq_attr_mask srq_attr_mask,
+ struct ib_udata *udata)
+{
+ struct bng_re_srq *srq = container_of(ib_srq, struct bng_re_srq, ib_srq);
+ struct bng_re_dev *rdev = srq->rdev;
+
+ if (srq_attr_mask & IB_SRQ_MAX_WR) {
+ /* SRQ resize is not supported */
+ ibdev_dbg(&rdev->ibdev, "SRQ resize is not supported\n");
+ return -EINVAL;
+ }
+
+ if (srq_attr_mask & IB_SRQ_LIMIT) {
+ unsigned long flags;
+
+ /* The limit is a count of posted WRs, so it cannot exceed the
+ * depth reported by query_srq (max_wr), which is one below the
+ * ring size.
+ */
+ if (srq_attr->srq_limit > srq->max_wr)
+ return -EINVAL;
+
+ /* The limit is programmed into HW, but the resulting
+ * NQ_BASE_TYPE_SRQ_EVENT is not decoded yet, so
+ * IB_EVENT_SRQ_LIMIT_REACHED is not delivered. The NQ event
+ * handler is added with the NQ servicing patches.
+ */
+ dev_warn_once(rdev_to_dev(rdev),
+ "SRQ limit event delivery is not supported yet\n");
+
+ spin_lock_irqsave(&srq->lock, flags);
+ srq->sp_srq.threshold = srq_attr->srq_limit;
+ bng_re_srq_arm_db(&srq->sp_srq.dbinfo, srq->sp_srq.threshold);
+
+ spin_unlock_irqrestore(&srq->lock, flags);
+ return 0;
+ }
+
+ ibdev_err(&rdev->ibdev, "Unsupported srq_attr_mask 0x%x\n", srq_attr_mask);
+ return -EINVAL;
+}
+
+int bng_re_query_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr)
+{
+ struct bng_re_srq *srq = container_of(ib_srq, struct bng_re_srq, ib_srq);
+ struct bng_re_dev *rdev = srq->rdev;
+ struct bng_sp_srq sp_srq = {};
+ int rc;
+
+ /* Get live SRQ attr */
+ sp_srq.id = srq->sp_srq.id;
+ rc = bng_sp_query_srq(&rdev->bng_res, &sp_srq);
+ if (rc) {
+ ibdev_err(&rdev->ibdev, "Query HW SRQ failed!\n");
+ return rc;
+ }
+
+ /* Report the user-visible depth, not the ring size with its spare slot */
+ srq_attr->max_wr = srq->max_wr;
+ srq_attr->max_sge = srq->sp_srq.max_sge;
+ srq_attr->srq_limit = sp_srq.threshold;
+
+ return 0;
+}
+
+int bng_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)
+{
+ struct bng_re_dev *rdev;
+ struct bng_re_srq *srq;
+ int rc;
+
+ srq = container_of(ib_srq, struct bng_re_srq, ib_srq);
+ rdev = srq->rdev;
+
+ rc = bng_sp_destroy_srq(&rdev->bng_res, &srq->sp_srq);
+ if (rc) {
+ /* The SRQ may still be live in firmware, keep its queue memory
+ * pinned. The core keeps the SRQ and may call destroy again.
+ */
+ ibdev_err(&rdev->ibdev, "Destroy SRQ failed: %d\n", rc);
+ return rc;
+ }
+
+ ib_umem_release(srq->umem);
+ srq->umem = NULL;
+
+ return 0;
+}
diff --git a/drivers/infiniband/hw/bng_re/bng_verbs.h b/drivers/infiniband/hw/bng_re/bng_verbs.h
index b11294558e8d..76263cf1b8a8 100644
--- a/drivers/infiniband/hw/bng_re/bng_verbs.h
+++ b/drivers/infiniband/hw/bng_re/bng_verbs.h
@@ -59,6 +59,15 @@ struct bng_re_cq {
struct mutex resize_lock;
};
+struct bng_re_srq {
+ struct ib_srq ib_srq;
+ struct bng_re_dev *rdev;
+ u32 max_wr;
+ struct bng_sp_srq sp_srq;
+ struct ib_umem *umem;
+ spinlock_t lock; /* protect srq */
+};
+
static inline u32 bng_re_init_depth(u32 ent, struct bng_re_ucontext *uctx)
{
/* @ent must be non-zero: roundup_pow_of_two(0) is undefined */
@@ -66,6 +75,12 @@ static inline u32 bng_re_init_depth(u32 ent, struct bng_re_ucontext *uctx)
ent : roundup_pow_of_two(ent) : ent;
}
+static inline u16 bng_re_get_rwqe_size(int nsge)
+{
+ /* RQ WQE header + SGEs */
+ return 16 + (nsge * 16); /* header=16, each sge=16 bytes */
+}
+
int bng_re_query_device(struct ib_device *ibdev, struct ib_device_attr *ib_attr,
struct ib_udata *udata);
int bng_re_modify_device(struct ib_device *ibdev, int device_modify_mask,
@@ -114,4 +129,13 @@ int bng_re_pre_destroy_cq(struct ib_cq *cq);
int bng_re_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
int bng_re_poll_cq(struct ib_cq *ib_cq, int num_entries, struct ib_wc *wc);
+int bng_re_create_srq(struct ib_srq *ib_srq,
+ struct ib_srq_init_attr *srq_init_attr,
+ struct ib_udata *udata);
+int bng_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr,
+ enum ib_srq_attr_mask srq_attr_mask,
+ struct ib_udata *udata);
+int bng_re_query_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr);
+int bng_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata);
+
#endif /* __BNG_RE_VERBS_H__ */
diff --git a/include/uapi/rdma/bng_re-abi.h b/include/uapi/rdma/bng_re-abi.h
index ebf2ff965fc9..dfba021bc69f 100644
--- a/include/uapi/rdma/bng_re-abi.h
+++ b/include/uapi/rdma/bng_re-abi.h
@@ -62,4 +62,15 @@ struct bng_re_resize_cq_req {
__aligned_u64 cq_va;
};
+struct bng_re_srq_req {
+ __aligned_u64 srqva;
+ __aligned_u64 srq_handle;
+};
+
+struct bng_re_srq_resp {
+ __u32 srqid;
+ __u32 reserved;
+ __aligned_u64 comp_mask;
+};
+
#endif /* __BNG_RE_UVERBS_ABI_H__*/
--
2.43.5
next prev parent reply other threads:[~2026-12-04 16:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 15:47 [RDMA v2 00/13] Add BNG_RE control path verbs Siva Reddy Kallam
2026-12-04 15:47 ` [RDMA v2 01/13] bnge: Keep the RoCE MSI-X minimum for the MPC vector Siva Reddy Kallam
2026-12-04 15:47 ` [RDMA v2 02/13] RDMA/bng_re: Add MPC, XID management, doorbell infrastructure Siva Reddy Kallam
2026-12-04 15:47 ` [RDMA v2 03/13] RDMA/bng_re: Add support verbs Siva Reddy Kallam
2026-12-04 15:47 ` [RDMA v2 04/13] RDMA/bng_re: Add ucontext/mmap verbs Siva Reddy Kallam
2026-12-04 15:47 ` [RDMA v2 05/13] RDMA/bng_re: Add GID verbs Siva Reddy Kallam
2026-12-04 15:47 ` [RDMA v2 06/13] RDMA/bng_re: Add PD verbs Siva Reddy Kallam
2026-12-04 15:47 ` [RDMA v2 07/13] RDMA/bng_re: Add MR verbs Siva Reddy Kallam
2026-12-04 15:48 ` [RDMA v2 08/13] RDMA/bng_re: Add CQ verbs Siva Reddy Kallam
2026-12-04 15:48 ` Siva Reddy Kallam [this message]
2026-12-04 15:48 ` [RDMA v2 10/13] RDMA/bng_re: Add Stats verbs Siva Reddy Kallam
2026-12-04 15:48 ` [RDMA v2 11/13] RDMA/bng_re: Add AH verbs Siva Reddy Kallam
2026-12-04 15:48 ` [RDMA v2 12/13] RDMA/bng_re: Add QP verbs Siva Reddy Kallam
2026-12-04 15:48 ` [RDMA v2 13/13] RDMA/bng_re: Register with ib-core Siva Reddy Kallam
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=20261204155249.1002019-10-siva.kallam@broadcom.com \
--to=siva.kallam@broadcom.com \
--cc=ajit.khaparde@broadcom.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dharmender.garg@broadcom.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jgg@nvidia.com \
--cc=kuba@kernel.org \
--cc=leonro@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sachin.holla@broadcom.com \
--cc=suresh.rupanagudi@broadcom.com \
--cc=vikas.gupta@broadcom.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