RE: [PATCH rdma-next v2 2/3] RDMA/mana_ib: support of the zero based MRs

Long Li
2025-04-16T18:09:25Z

> Subject: [PATCH rdma-next v2 2/3] RDMA/mana_ib: support of the zero based
> MRs
>
> From: Konstantin Taranov <kotaranov@microsoft.com>
>
> Add IB_ZERO_BASED to the valid flags and use the corresponding MR creation
> request for the zero based memory.
>
> Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>

Reviewed-by: Long Li <longli@microsoft.com>

> ---
> drivers/infiniband/hw/mana/mr.c | 24 +++++++++++++++++-------
> include/net/mana/gdma.h | 11 ++++++++++-
> 2 files changed, 27 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mana/mr.c b/drivers/infiniband/hw/mana/mr.c
> index e4a9f53..6d974d0 100644
> --- a/drivers/infiniband/hw/mana/mr.c
> +++ b/drivers/infiniband/hw/mana/mr.c
> @@ -6,7 +6,7 @@
> #include "mana_ib.h"
>
> #define VALID_MR_FLAGS (IB_ACCESS_LOCAL_WRITE |
> IB_ACCESS_REMOTE_WRITE | IB_ACCESS_REMOTE_READ |\
> - IB_ACCESS_REMOTE_ATOMIC)
> + IB_ACCESS_REMOTE_ATOMIC | IB_ZERO_BASED)
>
> #define VALID_DMA_MR_FLAGS (IB_ACCESS_LOCAL_WRITE)
>
> @@ -51,7 +51,10 @@ static int mana_ib_gd_create_mr(struct mana_ib_dev
> *dev, struct mana_ib_mr *mr,
> req.gva.virtual_address = mr_params->gva.virtual_address;
> req.gva.access_flags = mr_params->gva.access_flags;
> break;
> -
> + case GDMA_MR_TYPE_ZBVA:
> + req.zbva.dma_region_handle = mr_params-
> >zbva.dma_region_handle;
> + req.zbva.access_flags = mr_params->zbva.access_flags;
> + break;
> default:
> ibdev_dbg(&dev->ib_dev,
> "invalid param (GDMA_MR_TYPE) passed, type %d\n",
> @@ -147,11 +150,18 @@ struct ib_mr *mana_ib_reg_user_mr(struct ib_pd
> *ibpd, u64 start, u64 length,
> dma_region_handle);
>
> mr_params.pd_handle = pd->pd_handle;
> - mr_params.mr_type = GDMA_MR_TYPE_GVA;
> - mr_params.gva.dma_region_handle = dma_region_handle;
> - mr_params.gva.virtual_address = iova;
> - mr_params.gva.access_flags =
> - mana_ib_verbs_to_gdma_access_flags(access_flags);
> + if (access_flags & IB_ZERO_BASED) {
> + mr_params.mr_type = GDMA_MR_TYPE_ZBVA;
> + mr_params.zbva.dma_region_handle = dma_region_handle;
> + mr_params.zbva.access_flags =
> + mana_ib_verbs_to_gdma_access_flags(access_flags);
> + } else {
> + mr_params.mr_type = GDMA_MR_TYPE_GVA;
> + mr_params.gva.dma_region_handle = dma_region_handle;
> + mr_params.gva.virtual_address = iova;
> + mr_params.gva.access_flags =
> + mana_ib_verbs_to_gdma_access_flags(access_flags);
> + }
>
> err = mana_ib_gd_create_mr(dev, mr, &mr_params);
> if (err)
> diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h index
> 50ffbc4..3db506d 100644
> --- a/include/net/mana/gdma.h
> +++ b/include/net/mana/gdma.h
> @@ -812,6 +812,8 @@ enum gdma_mr_type {
> * address that is set up in the MST
> */
> GDMA_MR_TYPE_GVA = 2,
> + /* Guest zero-based address MRs */
> + GDMA_MR_TYPE_ZBVA = 4,
> };
>
> struct gdma_create_mr_params {
> @@ -823,6 +825,10 @@ struct gdma_create_mr_params {
> u64 virtual_address;
> enum gdma_mr_access_flags access_flags;
> } gva;
> + struct {
> + u64 dma_region_handle;
> + enum gdma_mr_access_flags access_flags;
> + } zbva;
> };
> };
>
> @@ -838,7 +844,10 @@ struct gdma_create_mr_request {
> u64 virtual_address;
> enum gdma_mr_access_flags access_flags;
> } gva;
> -
> + struct {
> + u64 dma_region_handle;
> + enum gdma_mr_access_flags access_flags;
> + } zbva;
> };
> u32 reserved_2;
> };/* HW DATA */
> --
> 2.43.0