RDMA: add per-attribute UMEM for SRQ create
Subsystems (2)
v3 cover RDMA: add per-attribute UMEM for SRQ create
From: Jiri Pirko <[email protected]>
This series continues extending the per-attribute UMEM model to the SRQ create uverb flow, so that userspace can back related buffers using previously introduce descriptor infrastructure.
The underlying infrastructure - ib_umem_get_attr_or_va() and the per-command UMEM attributes - is already in place and used by the CQ and QP create uverbs. This series applies the same model to the SRQ create flow (the WQE buffer and the mlx5 doorbell record) and wire this up in mlx5 driver.
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
v2->v3:
- dropped resize CQ support
see individual patches for changelog
Jiri Pirko (3):
RDMA/uverbs: Add SRQ buffer UMEM attribute RDMA/mlx5: Use UMEM attribute for SRQ buffer in create_srq RDMA/mlx5: Use UMEM attribute for SRQ doorbell record
.../infiniband/core/uverbs_std_types_srq.c | 2 ++ drivers/infiniband/hw/mlx5/main.c | 1 + drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 + drivers/infiniband/hw/mlx5/srq.c | 25 +++++++++++++++++-- include/uapi/rdma/ib_user_ioctl_cmds.h | 1 + include/uapi/rdma/mlx5_user_ioctl_cmds.h | 4 +++ 6 files changed, 32 insertions(+), 2 deletions(-)
Signature · 1 line
2.54.0
PATCH v3 1/3 RDMA/uverbs: Add SRQ buffer UMEM attribute
From: Jiri Pirko <[email protected]>
Apply the per-attribute UMEM model to the SRQ create method. Add an optional UMEM attribute that backs the SRQ WQE buffer, so userspace can supply it as either a VA or a dma-buf through a single descriptor, consistent with the CQ and QP create methods.
mlx5 is the only driver that pins an SRQ WQE buffer via umem; it maps a single ucmd->buf_addr region through this attribute. No other driver implements a user SRQ buffer, so none of them use the attribute.
--- drivers/infiniband/core/uverbs_std_types_srq.c | 2 ++ include/uapi/rdma/ib_user_ioctl_cmds.h | 1 + 2 files changed, 3 insertions(+)
drivers/infiniband/core/uverbs_std_types_srq.c +2 -0
@@ -192,6 +192,8 @@ DECLARE_UVERBS_NAMED_METHOD(UVERBS_ATTR_PTR_OUT (UVERBS_ATTR_CREATE_SRQ_RESP_SRQ_NUM ,UVERBS_ATTR_TYPE (u32),UA_OPTIONAL ), +UVERBS_ATTR_UMEM (UVERBS_ATTR_CREATE_SRQ_BUF_UMEM , +UA_OPTIONAL ), UVERBS_ATTR_UHW()); static int UVERBS_HANDLER(UVERBS_METHOD_SRQ_DESTROY)(
include/uapi/rdma/ib_user_ioctl_cmds.h +1 -0
@@ -189,6 +189,7 @@ enum uverbs_attrs_create_srq_cmd_attr_ids {UVERBS_ATTR_CREATE_SRQ_RESP_MAX_WR ,UVERBS_ATTR_CREATE_SRQ_RESP_MAX_SGE ,UVERBS_ATTR_CREATE_SRQ_RESP_SRQ_NUM , + UVERBS_ATTR_CREATE_SRQ_BUF_UMEM, }; enum uverbs_attrs_destroy_srq_cmd_attr_ids {
Signature · 1 line
2.54.0
PATCH v3 2/3 RDMA/mlx5: Use UMEM attribute for SRQ buffer in create_srq
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Use the per-attribute UMEM helper to pin the SRQ buffer umem on demand. ib_umem_get_attr_or_va() resolves the new CREATE_SRQ_BUF_UMEM attribute when present and otherwise falls back to the existing UHW ucmd->buf_addr VA, preserving the legacy behavior.
--- drivers/infiniband/hw/mlx5/srq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/srq.c +5 -1
@@ -48,6 +48,8 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,struct mlx5_ib_create_srq ucmd;struct mlx5_ib_ucontext *ucontext =rdma_udata_to_drv_context ( udata, struct mlx5_ib_ucontext, ibucontext); +struct uverbs_attr_bundle *attrs = +rdma_udata_to_uverbs_attr_bundle (udata);int err;u32 uidx =MLX5_IB_DEFAULT_UIDX ;
@@ -66,7 +68,9 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, srq->wq_sig = !!(ucmd.flags &MLX5_SRQ_FLAG_SIGNATURE ); - srq->umem =ib_umem_get_va (pd->device, ucmd.buf_addr, buf_size,0 ); + srq->umem =ib_umem_get_attr_or_va (pd->device, attrs, +UVERBS_ATTR_CREATE_SRQ_BUF_UMEM , + 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);
Signature · 1 line
2.54.0
PATCH v3 3/3 RDMA/mlx5: Use UMEM attribute for SRQ doorbell record
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Add an optional mlx5 driver-namespace UMEM attribute on SRQ create so userspace can supply the doorbell record umem explicitly, symmetric to the CQ and QP sides. Resolve it inside mlx5_ib_db_map_user() and use it as a private DBR page when present; otherwise take the existing UHW share-or-pin path that preserves per-page DBR sharing across CQ/QP/SRQ in the same process.
Add mlx5's first UVERBS_OBJECT_SRQ UAPI definition chain to attach the new attr.
--- drivers/infiniband/hw/mlx5/main.c | 1 + drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 + drivers/infiniband/hw/mlx5/srq.c | 19 ++++++++++++++++++- include/uapi/rdma/mlx5_user_ioctl_cmds.h | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +1 -0
@@ -4477,6 +4477,7 @@ static const struct uapi_definition mlx5_ib_defs[] = {UAPI_DEF_CHAIN (mlx5_ib_dm_defs),UAPI_DEF_CHAIN (mlx5_ib_create_cq_defs),UAPI_DEF_CHAIN (mlx5_ib_create_qp_defs), +UAPI_DEF_CHAIN (mlx5_ib_create_srq_defs),UAPI_DEF_CHAIN_OBJ_TREE (UVERBS_OBJECT_DEVICE , &mlx5_ib_query_context), UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_MR, &mlx5_ib_reg_dmabuf_mr),
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -0
@@ -1517,6 +1517,7 @@ extern const struct uapi_definition mlx5_ib_qos_defs[];extern const struct uapi_definition mlx5_ib_std_types_defs[];extern const struct uapi_definition mlx5_ib_create_cq_defs[];extern const struct uapi_definition mlx5_ib_create_qp_defs[]; +extern const struct uapi_definition mlx5_ib_create_srq_defs[];static inline int is_qp1 (enum ib_qp_type qp_type) {
drivers/infiniband/hw/mlx5/srq.c +18 -1
@@ -10,6 +10,9 @@#include "mlx5_ib.h" #include "srq.h" +#define UVERBS_MODULE_NAME mlx5_ib +#include <rdma/uverbs_named_ioctl.h> +static void *get_wqe (struct mlx5_ib_srq *srq,int n) {return mlx5_frag_buf_get_wqe (&srq->fbc, n);
@@ -78,7 +81,9 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, } in->umem = srq->umem; - err =mlx5_ib_db_map_user (ucontext,NULL ,0 , ucmd.db_addr, &srq->db); + err =mlx5_ib_db_map_user (ucontext, attrs, +MLX5_IB_ATTR_CREATE_SRQ_DBR_BUF_UMEM , + ucmd.db_addr, &srq->db);if (err) {mlx5_ib_dbg (dev,"map doorbell failed\n" ); goto err_umem;
@@ -466,3 +471,15 @@ int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,return err; } + +ADD_UVERBS_ATTRIBUTES_SIMPLE ( + mlx5_ib_srq_create, +UVERBS_OBJECT_SRQ , +UVERBS_METHOD_SRQ_CREATE , +UVERBS_ATTR_UMEM (MLX5_IB_ATTR_CREATE_SRQ_DBR_BUF_UMEM , +UA_OPTIONAL )); + +const struct uapi_definition mlx5_ib_create_srq_defs[] = { +UAPI_DEF_CHAIN_OBJ_TREE (UVERBS_OBJECT_SRQ , &mlx5_ib_srq_create), + {}, +};
include/uapi/rdma/mlx5_user_ioctl_cmds.h +4 -0
@@ -281,6 +281,10 @@ enum mlx5_ib_create_qp_attrs { MLX5_IB_ATTR_CREATE_QP_DBR_BUF_UMEM = UVERBS_ID_DRIVER_NS_WITH_UHW, }; +enum mlx5_ib_create_srq_attrs { +MLX5_IB_ATTR_CREATE_SRQ_DBR_BUF_UMEM =UVERBS_ID_DRIVER_NS_WITH_UHW , +}; +enum mlx5_ib_reg_dmabuf_mr_attrs {MLX5_IB_ATTR_REG_DMABUF_MR_ACCESS_FLAGS = (1U <<UVERBS_ID_NS_SHIFT ), };
Signature · 1 line
2.54.0
Leon Romanovsky
AppliedQuoted 6 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
This series continues extending the per-attribute UMEM model to the SRQ create uverb flow, so that userspace can back related buffers using previously introduce descriptor infrastructure.
Quoted 7 lines
The underlying infrastructure -
ib_umem_get_attr_or_va()and the per-command UMEM attributes - is already in place and used by the CQ and QP create uverbs. This series applies the same model to the SRQ create flow (the WQE buffer and the mlx5 doorbell record) and wire this up in mlx5 driver.[...]
Applied, thanks!
[1/3] RDMA/uverbs: Add SRQ buffer UMEM attribute
https://git.kernel.org/rdma/rdma/c/fe34dc1fa08224 [2/3] RDMA/mlx5: Use UMEM attribute for SRQ buffer in create_srq https://git.kernel.org/rdma/rdma/c/023349192e79cf [3/3] RDMA/mlx5: Use UMEM attribute for SRQ doorbell record https://git.kernel.org/rdma/rdma/c/aac287f4f1ebeb
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>