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 06/13] RDMA/bng_re: Add PD verbs
Date: Fri, 4 Dec 2026 07:47:58 -0800 [thread overview]
Message-ID: <20261204155249.1002019-7-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_alloc_pd
- bng_re_dealloc_pd
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 | 3 ++
drivers/infiniband/hw/bng_re/bng_res.c | 7 +++-
drivers/infiniband/hw/bng_re/bng_res.h | 3 ++
drivers/infiniband/hw/bng_re/bng_sp.c | 27 ++++++++++++++-
drivers/infiniband/hw/bng_re/bng_sp.h | 8 +++++
drivers/infiniband/hw/bng_re/bng_verbs.c | 43 ++++++++++++++++++++++++
drivers/infiniband/hw/bng_re/bng_verbs.h | 8 +++++
include/uapi/rdma/bng_re-abi.h | 5 +++
8 files changed, 102 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/bng_re/bng_dev.c b/drivers/infiniband/hw/bng_re/bng_dev.c
index 34b65b52e7a2..cec881c28640 100644
--- a/drivers/infiniband/hw/bng_re/bng_dev.c
+++ b/drivers/infiniband/hw/bng_re/bng_dev.c
@@ -42,6 +42,9 @@ static const struct ib_device_ops bng_re_dev_ops = {
.mmap_free = bng_re_mmap_free,
.add_gid = bng_re_add_gid,
.del_gid = bng_re_del_gid,
+ .alloc_pd = bng_re_alloc_pd,
+ .dealloc_pd = bng_re_dealloc_pd,
+ 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.c b/drivers/infiniband/hw/bng_re/bng_res.c
index 08ac4d62fd57..471f3bfb71f7 100644
--- a/drivers/infiniband/hw/bng_re/bng_res.c
+++ b/drivers/infiniband/hw/bng_re/bng_res.c
@@ -409,6 +409,7 @@ static int bng_res_alloc_dpi_tbl(struct bng_re_res *res,
void bng_res_free_tbls(struct bng_re_res *res)
{
+ ida_destroy(&res->pd_ida);
mutex_lock(&res->dpi_tbl_lock);
bng_res_free_dpi_tbl(&res->dpi_tbl);
mutex_unlock(&res->dpi_tbl_lock);
@@ -419,10 +420,12 @@ int bng_res_alloc_init_tbls(struct bng_re_res *res)
{
int rc;
+ ida_init(&res->pd_ida);
+
rc = bng_res_alloc_dpi_tbl(res, res->dattr);
if (rc) {
dev_err(&res->pdev->dev, "DPI tbl alloc failed\n");
- return rc;
+ goto free_pd_ida;
}
rc = bng_sp_alloc_sgid_tbl(&res->sgid_tbl,
@@ -436,6 +439,8 @@ int bng_res_alloc_init_tbls(struct bng_re_res *res)
free_dpi_tbl:
bng_res_free_dpi_tbl(&res->dpi_tbl);
+free_pd_ida:
+ ida_destroy(&res->pd_ida);
return rc;
}
diff --git a/drivers/infiniband/hw/bng_re/bng_res.h b/drivers/infiniband/hw/bng_re/bng_res.h
index 77e7c5569833..0c7b7c286a35 100644
--- a/drivers/infiniband/hw/bng_re/bng_res.h
+++ b/drivers/infiniband/hw/bng_re/bng_res.h
@@ -8,6 +8,7 @@
#include "xid_allocator.h"
#include <linux/bnge/hsi.h>
#include <linux/sizes.h>
+#include <linux/idr.h>
#define BNG_NQE_MAX_CNT (128 * 1024)
@@ -226,6 +227,8 @@ struct bng_re_res {
struct xid_manager *qp_xids;
struct xid_manager *ah_xids;
struct bng_re_sgid_tbl sgid_tbl;
+ /* PD ids, 0 .. dattr->max_pd - 1 */
+ struct ida pd_ida;
};
#define to_bng_re_res(ptr, member) container_of(ptr, struct bng_re_res, member)
diff --git a/drivers/infiniband/hw/bng_re/bng_sp.c b/drivers/infiniband/hw/bng_re/bng_sp.c
index 83921f23a423..786d591a91b3 100644
--- a/drivers/infiniband/hw/bng_re/bng_sp.c
+++ b/drivers/infiniband/hw/bng_re/bng_sp.c
@@ -98,7 +98,7 @@ int bng_re_get_dev_attr(struct bng_re_rcfw *rcfw)
attr->max_mw = le32_to_cpu(sb->max_mw);
attr->max_mr_size = le64_to_cpu(sb->max_mr_size);
- attr->max_pd = 64 * 1024;
+ attr->max_pd = le32_to_cpu(sb->max_pd);
attr->max_raw_ethy_qp = le32_to_cpu(sb->max_raw_eth_qp);
attr->max_ah = le32_to_cpu(sb->max_ah);
@@ -329,3 +329,28 @@ int bng_sp_del_sgid(struct bng_re_sgid_tbl *sgid_tbl, u32 index, bool update)
index, hw_id, sgid_tbl->active);
return 0;
}
+
+/*
+ * PD ids are software only, no firmware command is involved. They are
+ * handed out by an IDA and range over 0 .. max_pd - 1.
+ */
+int bng_sp_alloc_pd(struct bng_re_res *res, struct bng_sp_pd *pd)
+{
+ u32 max_pd = res->dattr->max_pd;
+ int id;
+
+ if (!max_pd)
+ return -ENOSPC;
+
+ id = ida_alloc_max(&res->pd_ida, max_pd - 1, GFP_KERNEL);
+ if (id < 0)
+ return id;
+
+ pd->id = id;
+ return 0;
+}
+
+void bng_sp_dealloc_pd(struct bng_re_res *res, struct bng_sp_pd *pd)
+{
+ ida_free(&res->pd_ida, pd->id);
+}
diff --git a/drivers/infiniband/hw/bng_re/bng_sp.h b/drivers/infiniband/hw/bng_re/bng_sp.h
index c93fe6ec0bcc..e3fa2bcbeae2 100644
--- a/drivers/infiniband/hw/bng_re/bng_sp.h
+++ b/drivers/infiniband/hw/bng_re/bng_sp.h
@@ -52,6 +52,10 @@ static inline bool bng_re_is_internal_queue_memory(u16 dev_cap_flags)
return dev_cap_flags & CREQ_QUERY_FUNC_RESP_SB_INTERNAL_QUEUE_MEMORY;
}
+struct bng_sp_pd {
+ u32 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);
@@ -66,4 +70,8 @@ int bng_sp_add_sgid(struct bng_re_sgid_tbl *sgid_tbl,
int bng_sp_del_sgid(struct bng_re_sgid_tbl *sgid_tbl, u32 index, bool update);
+int bng_sp_alloc_pd(struct bng_re_res *res, struct bng_sp_pd *pd);
+
+void bng_sp_dealloc_pd(struct bng_re_res *res, struct bng_sp_pd *pd);
+
#endif
diff --git a/drivers/infiniband/hw/bng_re/bng_verbs.c b/drivers/infiniband/hw/bng_re/bng_verbs.c
index 59fa84040476..95317907d612 100644
--- a/drivers/infiniband/hw/bng_re/bng_verbs.c
+++ b/drivers/infiniband/hw/bng_re/bng_verbs.c
@@ -459,3 +459,46 @@ int bng_re_del_gid(const struct ib_gid_attr *attr, void **context)
return rc;
}
+
+int bng_re_alloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata)
+{
+ struct bng_re_pd *pd = container_of(ib_pd, struct bng_re_pd, ib_pd);
+ struct ib_device *ibdev = ib_pd->device;
+ struct bng_re_dev *rdev = container_of(ibdev, struct bng_re_dev, ibdev);
+ int rc;
+
+ pd->rdev = rdev;
+
+ rc = ib_is_udata_in_empty(udata);
+ if (rc)
+ return rc;
+
+ rc = bng_sp_alloc_pd(&rdev->bng_res, &pd->sp_pd);
+ if (rc) {
+ ibdev_err(&rdev->ibdev, "Failed to allocate PD: %d\n", rc);
+ return rc;
+ }
+
+ if (udata) {
+ struct bng_re_pd_resp resp = {};
+
+ resp.pdid = pd->sp_pd.id;
+ rc = ib_respond_udata(udata, resp);
+ if (rc) {
+ ibdev_err(&rdev->ibdev, "Failed to copy PD udata\n");
+ bng_sp_dealloc_pd(&rdev->bng_res, &pd->sp_pd);
+ return rc;
+ }
+ }
+
+ return 0;
+}
+
+int bng_re_dealloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata)
+{
+ struct bng_re_pd *pd = container_of(ib_pd, struct bng_re_pd, ib_pd);
+ struct bng_re_dev *rdev = pd->rdev;
+
+ bng_sp_dealloc_pd(&rdev->bng_res, &pd->sp_pd);
+ return 0;
+}
diff --git a/drivers/infiniband/hw/bng_re/bng_verbs.h b/drivers/infiniband/hw/bng_re/bng_verbs.h
index 0357ec9afda4..d73ffb34a56e 100644
--- a/drivers/infiniband/hw/bng_re/bng_verbs.h
+++ b/drivers/infiniband/hw/bng_re/bng_verbs.h
@@ -28,6 +28,12 @@ struct bng_re_user_mmap_entry {
u8 mmap_flag;
};
+struct bng_re_pd {
+ struct ib_pd ib_pd;
+ struct bng_re_dev *rdev;
+ struct bng_sp_pd sp_pd;
+};
+
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,
@@ -47,4 +53,6 @@ int bng_re_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
void bng_re_mmap_free(struct rdma_user_mmap_entry *rdma_entry);
int bng_re_add_gid(const struct ib_gid_attr *attr, void **context);
int bng_re_del_gid(const struct ib_gid_attr *attr, void **context);
+int bng_re_alloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata);
+int bng_re_dealloc_pd(struct ib_pd *ib_pd, 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 d5cda958b0f8..3f571fd35a23 100644
--- a/include/uapi/rdma/bng_re-abi.h
+++ b/include/uapi/rdma/bng_re-abi.h
@@ -39,4 +39,9 @@ struct bng_re_uctx_resp {
__aligned_u64 uc_db_mmap_key;
};
+struct bng_re_pd_resp {
+ __u32 pdid;
+ __u32 comp_mask;
+};
+
#endif /* __BNG_RE_UVERBS_ABI_H__*/
--
2.43.5
next prev parent reply other threads:[~2026-12-04 16:01 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 ` Siva Reddy Kallam [this message]
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 ` [RDMA v2 09/13] RDMA/bng_re: Add SRQ verbs Siva Reddy Kallam
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-7-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