As a workaround to kernel driver/FW issues of the mlx5 devices, it is needed to use MR, which is an indirect mkey pointing to direct mkey created by the kernel for any DevX command uses an MR.
Fix any direct mkey usage to be configured by the ibv_reg_mr API.
If the direct mkey is for DevX command usage, werap it with an indiect mkey
to workaround the issues.
Matan Azrad (2):
common/mlx5: add wrapped MR create API
vdpa/mlx5: workaround dirty bitmap MR creation
Michael Baum (3):
common/mlx5: glue MR registration with IOVA
vdpa/mlx5: workaround guest MR registrations
net/mlx5: workaround counter memory region creation
drivers/common/mlx5/linux/meson.build | 2 +
drivers/common/mlx5/linux/mlx5_common_os.c | 56 ++++++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.c | 18 +++++++
drivers/common/mlx5/linux/mlx5_glue.h | 3 ++
drivers/common/mlx5/mlx5_common.h | 18 +++++++
drivers/common/mlx5/version.map | 3 ++
drivers/net/mlx5/mlx5.c | 8 +---
drivers/net/mlx5/mlx5.h | 5 +-
drivers/net/mlx5/mlx5_flow.c | 25 +++-------
drivers/vdpa/mlx5/mlx5_vdpa.h | 9 ++--
drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 37 +++-----------
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 43 ++++++-----------
12 files changed, 134 insertions(+), 93 deletions(-)
--
2.25.1
From: Michael Baum <redacted>
Add support for rdma-core API to register IOVA MR.
The API gets the process VA, size, and IOVA and returns a memory region
with space pointed by a specific IOVA.
So any access in this MR should come with an address that is relative to
the IOVA specified in the API.
Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/common/mlx5/linux/meson.build | 2 ++
drivers/common/mlx5/linux/mlx5_glue.c | 18 ++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.h | 3 +++
3 files changed, 23 insertions(+)
As a workaround to kernel driver/FW issues of the mlx5 devices, it is
needed to use MR, which is an indirect mkey pointing to direct mkey
created by the kernel for any DevX command uses an MR.
Add an API to create and destroy this wrapped MR.
Fixes: 5382d28c2110 ("net/mlx5: accelerate DV flow counter transactions")
Fixes: 9d39e57f21ac ("vdpa/mlx5: support live migration")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/common/mlx5/linux/mlx5_common_os.c | 56 ++++++++++++++++++++++
drivers/common/mlx5/mlx5_common.h | 18 +++++++
drivers/common/mlx5/version.map | 3 ++
3 files changed, 77 insertions(+)
Due to kernel driver/FW issues in direct MKEY creation using the DevX
API, this patch replaces the dirty bitmap MR creation to use wrapped
mkey instead.
Fixes: 9d39e57f21ac ("vdpa/mlx5: support live migration")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/vdpa/mlx5/mlx5_vdpa.h | 1 +
drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 37 ++++++-------------------------
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 2 ++
3 files changed, 10 insertions(+), 30 deletions(-)
@@ -36,38 +36,21 @@ intmlx5_vdpa_dirty_bitmap_set(structmlx5_vdpa_priv*priv,uint64_tlog_base,uint64_tlog_size){-structmlx5_devx_mkey_attrmkey_attr={-.addr=(uintptr_t)log_base,-.size=log_size,-.pd=priv->cdev->pdn,-.pg_access=1,-};structmlx5_devx_virtq_attrattr={.type=MLX5_VIRTQ_MODIFY_TYPE_DIRTY_BITMAP_PARAMS,.dirty_bitmap_addr=log_base,.dirty_bitmap_size=log_size,};-structmlx5_vdpa_query_mr*mr=rte_malloc(__func__,sizeof(*mr),0);inti;+intret=mlx5_os_wrapped_mkey_create(priv->cdev->ctx,priv->cdev->pd,+priv->cdev->pdn,(void*)log_base,+log_size,&priv->lm_mr);-if(!mr){-DRV_LOG(ERR,"Failed to allocate mem for lm mr.");+if(!ret){+DRV_LOG(ERR,"Failed to allocate wrapped MR for lm.");return-1;}-mr->umem=mlx5_glue->devx_umem_reg(priv->cdev->ctx,-(void*)(uintptr_t)log_base,-log_size,IBV_ACCESS_LOCAL_WRITE);-if(!mr->umem){-DRV_LOG(ERR,"Failed to register umem for lm mr.");-gotoerr;-}-mkey_attr.umem_id=mr->umem->umem_id;-mr->mkey=mlx5_devx_cmd_mkey_create(priv->cdev->ctx,&mkey_attr);-if(!mr->mkey){-DRV_LOG(ERR,"Failed to create Mkey for lm.");-gotoerr;-}-attr.dirty_bitmap_mkey=mr->mkey->id;+attr.dirty_bitmap_mkey=priv->lm_mr.lkey;for(i=0;i<priv->nr_virtqs;++i){attr.queue_index=i;if(!priv->virtqs[i].virtq){
From: Michael Baum <redacted>
Due to kernel issue in direct MKEY creation using the DevX API, this
patch replaces the virtio MR creation to use Verbs API.
Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +++---
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 41 +++++++++----------------------
2 files changed, 16 insertions(+), 33 deletions(-)
@@ -211,28 +211,15 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv)DRV_LOG(ERR,"Failed to allocate mem entry memory.");gotoerror;}-entry->umem=mlx5_glue->devx_umem_reg(priv->cdev->ctx,-(void*)(uintptr_t)reg->host_user_addr,-reg->size,IBV_ACCESS_LOCAL_WRITE);-if(!entry->umem){-DRV_LOG(ERR,"Failed to register Umem by Devx.");-ret=-errno;-gotoerror;-}-mkey_attr.addr=(uintptr_t)(reg->guest_phys_addr);-mkey_attr.size=reg->size;-mkey_attr.umem_id=entry->umem->umem_id;-mkey_attr.pd=priv->cdev->pdn;-mkey_attr.pg_access=1;-entry->mkey=mlx5_devx_cmd_mkey_create(priv->cdev->ctx,-&mkey_attr);-if(!entry->mkey){+entry->mr=mlx5_glue->reg_mr_iova(priv->cdev->pd,+(void*)(uintptr_t)(reg->host_user_addr),+reg->size,reg->guest_phys_addr,+IBV_ACCESS_LOCAL_WRITE);+if(!entry->mr){DRV_LOG(ERR,"Failed to create direct Mkey.");ret=-rte_errno;gotoerror;}-entry->addr=(void*)(uintptr_t)(reg->host_user_addr);-entry->length=reg->size;entry->is_indirect=0;if(i>0){uint64_tsadd;
@@ -462,8 +462,7 @@ struct mlx5_flow_counter_pool {structmlx5_counter_stats_mem_mng{LIST_ENTRY(mlx5_counter_stats_mem_mng)next;structmlx5_counter_stats_raw*raws;-structmlx5_devx_obj*dm;-void*umem;+structmlx5_pmd_wrapped_mrwm;};/* Raw memory structure for the counter statistics values of a pool. */
The mlx5 PMD uses the kernel mlx5 driver to map physical
memory to the HW.
Using the Verbs API ibv_reg_mr, a mkey can be created for that.
In this case, the mkey is signed on the user ID of the kernel driver.
Using the DevX API, a mkey also can be created, but it should point an
umem object (represents the specific buffer mapping).
In this case, the mkey is signed on the user ID of the process DevX
context.
In FW DevX control commands which get mkey as a parameter, there is
a security check on the user ID and Verbs mkeys are rejected.
Unfortunately, also when using DevX mkey, there is an error in the FW
command on umem validation because the umem is not designed to be used
for any mkey parameters.
As a workaround to the kernel driver/FW issue, it is needed to use a
wrapped MR, which is an indirect mkey(created by the DevX API) pointing to
direct mkey created by the kernel for any DevX command uses an MR.
Add an API to create and destroy this wrapped MR and use it for any
control DevX command.
v2:
- fix compilation issue on Windows.
- improve logs.
Matan Azrad (2):
common/mlx5: add wrapped MR create API
vdpa/mlx5: workaround dirty bitmap MR creation
Michael Baum (3):
common/mlx5: glue MR registration with IOVA
vdpa/mlx5: workaround guest MR registrations
net/mlx5: workaround MR creation for flow counter
drivers/common/mlx5/linux/meson.build | 2 +
drivers/common/mlx5/linux/mlx5_common_os.c | 56 ++++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.c | 18 +++++++
drivers/common/mlx5/linux/mlx5_glue.h | 3 ++
drivers/common/mlx5/mlx5_common.h | 18 +++++++
drivers/common/mlx5/version.map | 3 ++
drivers/common/mlx5/windows/mlx5_common_os.c | 40 ++++++++++++++
drivers/net/mlx5/mlx5.c | 8 +--
drivers/net/mlx5/mlx5.h | 5 +-
drivers/net/mlx5/mlx5_flow.c | 25 +++------
drivers/vdpa/mlx5/mlx5_vdpa.h | 9 ++--
drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 37 +++----------
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 43 +++++----------
13 files changed, 174 insertions(+), 93 deletions(-)
--
2.25.1
From: Michael Baum <redacted>
Add support for rdma-core API to register IOVA MR.
The API gets the process VA, size, and IOVA and returns a memory region
with space pointed by a specific IOVA.
So any access in this MR should come with an address that is relative to
the IOVA specified in the API.
Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/common/mlx5/linux/meson.build | 2 ++
drivers/common/mlx5/linux/mlx5_glue.c | 18 ++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.h | 3 +++
3 files changed, 23 insertions(+)
The mlx5 PMD uses the kernel mlx5 driver to map physical memory to the
HW.
Using the Verbs API ibv_reg_mr, a mkey can be created for that.
In this case, the mkey is signed on the user ID of the kernel driver.
Using the DevX API, a mkey also can be created, but it should point an
umem object (represents the specific buffer mapping) created by the
kernel. In this case, the mkey is signed on the user ID of the process
DevX context.
In FW DevX control commands which get mkey as a parameter, there is
a security check on the user ID and Verbs mkeys are rejected.
Unfortunately, also when using DevX mkey, there is an error in the FW
command on umem validation because the umem is not designed to be used
for any mkey parameters.
As a workaround to the kernel driver/FW issue, it is needed to use a
wrapped MR, which is an indirect mkey(created by the DevX API) pointing to
direct mkey created by the kernel for any DevX command uses an MR.
Add an API to create and destroy this wrapped MR.
Fixes: 5382d28c2110 ("net/mlx5: accelerate DV flow counter transactions")
Fixes: 9d39e57f21ac ("vdpa/mlx5: support live migration")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/common/mlx5/linux/mlx5_common_os.c | 56 ++++++++++++++++++++
drivers/common/mlx5/mlx5_common.h | 18 +++++++
drivers/common/mlx5/version.map | 3 ++
drivers/common/mlx5/windows/mlx5_common_os.c | 40 ++++++++++++++
4 files changed, 117 insertions(+)
From: Michael Baum <redacted>
Due to kernel issue in direct MKEY creation using the DevX API, this
patch replaces the virtio MR creation to use Verbs API.
Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +++---
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 41 +++++++++----------------------
2 files changed, 16 insertions(+), 33 deletions(-)
@@ -211,28 +211,15 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv)DRV_LOG(ERR,"Failed to allocate mem entry memory.");gotoerror;}-entry->umem=mlx5_glue->devx_umem_reg(priv->cdev->ctx,-(void*)(uintptr_t)reg->host_user_addr,-reg->size,IBV_ACCESS_LOCAL_WRITE);-if(!entry->umem){-DRV_LOG(ERR,"Failed to register Umem by Devx.");-ret=-errno;-gotoerror;-}-mkey_attr.addr=(uintptr_t)(reg->guest_phys_addr);-mkey_attr.size=reg->size;-mkey_attr.umem_id=entry->umem->umem_id;-mkey_attr.pd=priv->cdev->pdn;-mkey_attr.pg_access=1;-entry->mkey=mlx5_devx_cmd_mkey_create(priv->cdev->ctx,-&mkey_attr);-if(!entry->mkey){+entry->mr=mlx5_glue->reg_mr_iova(priv->cdev->pd,+(void*)(uintptr_t)(reg->host_user_addr),+reg->size,reg->guest_phys_addr,+IBV_ACCESS_LOCAL_WRITE);+if(!entry->mr){DRV_LOG(ERR,"Failed to create direct Mkey.");ret=-rte_errno;gotoerror;}-entry->addr=(void*)(uintptr_t)(reg->host_user_addr);-entry->length=reg->size;entry->is_indirect=0;if(i>0){uint64_tsadd;
Due to kernel driver/FW issues in direct MKEY creation using the DevX
API, this patch replaces the dirty bitmap MR creation to use wrapped
mkey instead.
Fixes: 9d39e57f21ac ("vdpa/mlx5: support live migration")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/vdpa/mlx5/mlx5_vdpa.h | 1 +
drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 37 ++++++-------------------------
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 2 ++
3 files changed, 10 insertions(+), 30 deletions(-)
@@ -36,38 +36,21 @@ intmlx5_vdpa_dirty_bitmap_set(structmlx5_vdpa_priv*priv,uint64_tlog_base,uint64_tlog_size){-structmlx5_devx_mkey_attrmkey_attr={-.addr=(uintptr_t)log_base,-.size=log_size,-.pd=priv->cdev->pdn,-.pg_access=1,-};structmlx5_devx_virtq_attrattr={.type=MLX5_VIRTQ_MODIFY_TYPE_DIRTY_BITMAP_PARAMS,.dirty_bitmap_addr=log_base,.dirty_bitmap_size=log_size,};-structmlx5_vdpa_query_mr*mr=rte_malloc(__func__,sizeof(*mr),0);inti;+intret=mlx5_os_wrapped_mkey_create(priv->cdev->ctx,priv->cdev->pd,+priv->cdev->pdn,(void*)log_base,+log_size,&priv->lm_mr);-if(!mr){-DRV_LOG(ERR,"Failed to allocate mem for lm mr.");+if(!ret){+DRV_LOG(ERR,"Failed to allocate wrapped MR for lm.");return-1;}-mr->umem=mlx5_glue->devx_umem_reg(priv->cdev->ctx,-(void*)(uintptr_t)log_base,-log_size,IBV_ACCESS_LOCAL_WRITE);-if(!mr->umem){-DRV_LOG(ERR,"Failed to register umem for lm mr.");-gotoerr;-}-mkey_attr.umem_id=mr->umem->umem_id;-mr->mkey=mlx5_devx_cmd_mkey_create(priv->cdev->ctx,&mkey_attr);-if(!mr->mkey){-DRV_LOG(ERR,"Failed to create Mkey for lm.");-gotoerr;-}-attr.dirty_bitmap_mkey=mr->mkey->id;+attr.dirty_bitmap_mkey=priv->lm_mr.lkey;for(i=0;i<priv->nr_virtqs;++i){attr.queue_index=i;if(!priv->virtqs[i].virtq){
@@ -462,8 +462,7 @@ struct mlx5_flow_counter_pool {structmlx5_counter_stats_mem_mng{LIST_ENTRY(mlx5_counter_stats_mem_mng)next;structmlx5_counter_stats_raw*raws;-structmlx5_devx_obj*dm;-void*umem;+structmlx5_pmd_wrapped_mrwm;};/* Raw memory structure for the counter statistics values of a pool. */
From: Thomas Monjalon <hidden> Date: 2021-11-08 19:38:25
08/11/2021 18:21, Matan Azrad:
Due to kernel driver/FW issues in direct MKEY creation using the DevX
API, this patch replaces the dirty bitmap MR creation to use wrapped
mkey instead.
Fixes: 9d39e57f21ac ("vdpa/mlx5: support live migration")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
32-bit compilation is broken:
drivers/vdpa/mlx5/mlx5_vdpa_lm.c:46:64: error:
cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
46 | priv->cdev->pdn, (void *)log_base,
| ^
The mlx5 PMD uses the kernel mlx5 driver to map physical memory to the HW.
Using the Verbs API ibv_reg_mr, a mkey can be created for that.
In this case, the mkey is signed on the user ID of the kernel driver.
Using the DevX API, a mkey also can be created, but it should point an umem object (represents the specific buffer mapping) created by the kernel.
In this case, the mkey is signed on the user ID of the process DevX context.
In FW DevX control commands which get mkey as a parameter, there is a security check on the user ID and Verbs mkeys are rejected.
Unfortunately, also when using DevX mkey, there is an error in the FW
command on umem validation because the umem is not designed to be used
for any mkey parameter.
As a workaround to the kernel driver/FW issue, it is needed to use a wrapped MR, which is an indirect mkey(created by the DevX API) pointing to direct mkey created by the kernel for any DevX command uses an MR.
Add an API to create and destroy this wrapped MR.
Use this logic for counters and LM management.
V3:
Fix 32-bit compilation issue.
V2:
Fix Windows compilation issue.
Improve logs.
Matan Azrad (2):
common/mlx5: add wrapped MR create API
vdpa/mlx5: workaround dirty bitmap MR creation
Michael Baum (3):
common/mlx5: glue MR registration with IOVA
vdpa/mlx5: workaround guest MR registrations
net/mlx5: workaround MR creation for flow counter
drivers/common/mlx5/linux/meson.build | 2 +
drivers/common/mlx5/linux/mlx5_common_os.c | 56 ++++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.c | 18 +++++++
drivers/common/mlx5/linux/mlx5_glue.h | 3 ++
drivers/common/mlx5/mlx5_common.h | 18 +++++++
drivers/common/mlx5/version.map | 3 ++
drivers/common/mlx5/windows/mlx5_common_os.c | 40 ++++++++++++++
drivers/net/mlx5/mlx5.c | 8 +--
drivers/net/mlx5/mlx5.h | 5 +-
drivers/net/mlx5/mlx5_flow.c | 25 +++------
drivers/vdpa/mlx5/mlx5_vdpa.h | 9 ++--
drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 38 +++----------
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 43 +++++----------
13 files changed, 175 insertions(+), 93 deletions(-)
--
2.25.1
From: Michael Baum <redacted>
Add support for rdma-core API to register IOVA MR.
The API gets the process VA, size, and IOVA and returns a memory region
with space pointed by a specific IOVA.
So any access in this MR should come with an address that is relative to
the IOVA specified in the API.
Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/common/mlx5/linux/meson.build | 2 ++
drivers/common/mlx5/linux/mlx5_glue.c | 18 ++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.h | 3 +++
3 files changed, 23 insertions(+)
The mlx5 PMD uses the kernel mlx5 driver to map physical memory to the
HW.
Using the Verbs API ibv_reg_mr, a mkey can be created for that.
In this case, the mkey is signed on the user ID of the kernel driver.
Using the DevX API, a mkey also can be created, but it should point an
umem object (represents the specific buffer mapping) created by the
kernel. In this case, the mkey is signed on the user ID of the process
DevX context.
In FW DevX control commands which get mkey as a parameter, there is
a security check on the user ID and Verbs mkeys are rejected.
Unfortunately, also when using DevX mkey, there is an error in the FW
command on umem validation because the umem is not designed to be used
for any mkey parameters.
As a workaround to the kernel driver/FW issue, it is needed to use a
wrapped MR, which is an indirect mkey(created by the DevX API) pointing to
direct mkey created by the kernel for any DevX command uses an MR.
Add an API to create and destroy this wrapped MR.
Fixes: 5382d28c2110 ("net/mlx5: accelerate DV flow counter transactions")
Fixes: 9d39e57f21ac ("vdpa/mlx5: support live migration")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/common/mlx5/linux/mlx5_common_os.c | 56 ++++++++++++++++++++
drivers/common/mlx5/mlx5_common.h | 18 +++++++
drivers/common/mlx5/version.map | 3 ++
drivers/common/mlx5/windows/mlx5_common_os.c | 40 ++++++++++++++
4 files changed, 117 insertions(+)
Due to kernel driver/FW issues in direct MKEY creation using the DevX
API, this patch replaces the dirty bitmap MR creation to use wrapped
mkey instead.
Fixes: 9d39e57f21ac ("vdpa/mlx5: support live migration")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/vdpa/mlx5/mlx5_vdpa.h | 1 +
drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 38 +++++++------------------------
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 2 ++
3 files changed, 11 insertions(+), 30 deletions(-)
@@ -36,38 +36,22 @@ intmlx5_vdpa_dirty_bitmap_set(structmlx5_vdpa_priv*priv,uint64_tlog_base,uint64_tlog_size){-structmlx5_devx_mkey_attrmkey_attr={-.addr=(uintptr_t)log_base,-.size=log_size,-.pd=priv->cdev->pdn,-.pg_access=1,-};structmlx5_devx_virtq_attrattr={.type=MLX5_VIRTQ_MODIFY_TYPE_DIRTY_BITMAP_PARAMS,.dirty_bitmap_addr=log_base,.dirty_bitmap_size=log_size,};-structmlx5_vdpa_query_mr*mr=rte_malloc(__func__,sizeof(*mr),0);inti;+intret=mlx5_os_wrapped_mkey_create(priv->cdev->ctx,priv->cdev->pd,+priv->cdev->pdn,+(void*)(uintptr_t)log_base,+log_size,&priv->lm_mr);-if(!mr){-DRV_LOG(ERR,"Failed to allocate mem for lm mr.");+if(!ret){+DRV_LOG(ERR,"Failed to allocate wrapped MR for lm.");return-1;}-mr->umem=mlx5_glue->devx_umem_reg(priv->cdev->ctx,-(void*)(uintptr_t)log_base,-log_size,IBV_ACCESS_LOCAL_WRITE);-if(!mr->umem){-DRV_LOG(ERR,"Failed to register umem for lm mr.");-gotoerr;-}-mkey_attr.umem_id=mr->umem->umem_id;-mr->mkey=mlx5_devx_cmd_mkey_create(priv->cdev->ctx,&mkey_attr);-if(!mr->mkey){-DRV_LOG(ERR,"Failed to create Mkey for lm.");-gotoerr;-}-attr.dirty_bitmap_mkey=mr->mkey->id;+attr.dirty_bitmap_mkey=priv->lm_mr.lkey;for(i=0;i<priv->nr_virtqs;++i){attr.queue_index=i;if(!priv->virtqs[i].virtq){
From: Michael Baum <redacted>
Due to kernel issue in direct MKEY creation using the DevX API, this
patch replaces the virtio MR creation to use Verbs API.
Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/vdpa/mlx5/mlx5_vdpa.h | 8 +++---
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 41 +++++++++----------------------
2 files changed, 16 insertions(+), 33 deletions(-)
@@ -211,28 +211,15 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv)DRV_LOG(ERR,"Failed to allocate mem entry memory.");gotoerror;}-entry->umem=mlx5_glue->devx_umem_reg(priv->cdev->ctx,-(void*)(uintptr_t)reg->host_user_addr,-reg->size,IBV_ACCESS_LOCAL_WRITE);-if(!entry->umem){-DRV_LOG(ERR,"Failed to register Umem by Devx.");-ret=-errno;-gotoerror;-}-mkey_attr.addr=(uintptr_t)(reg->guest_phys_addr);-mkey_attr.size=reg->size;-mkey_attr.umem_id=entry->umem->umem_id;-mkey_attr.pd=priv->cdev->pdn;-mkey_attr.pg_access=1;-entry->mkey=mlx5_devx_cmd_mkey_create(priv->cdev->ctx,-&mkey_attr);-if(!entry->mkey){+entry->mr=mlx5_glue->reg_mr_iova(priv->cdev->pd,+(void*)(uintptr_t)(reg->host_user_addr),+reg->size,reg->guest_phys_addr,+IBV_ACCESS_LOCAL_WRITE);+if(!entry->mr){DRV_LOG(ERR,"Failed to create direct Mkey.");ret=-rte_errno;gotoerror;}-entry->addr=(void*)(uintptr_t)(reg->host_user_addr);-entry->length=reg->size;entry->is_indirect=0;if(i>0){uint64_tsadd;
@@ -462,8 +462,7 @@ struct mlx5_flow_counter_pool {structmlx5_counter_stats_mem_mng{LIST_ENTRY(mlx5_counter_stats_mem_mng)next;structmlx5_counter_stats_raw*raws;-structmlx5_devx_obj*dm;-void*umem;+structmlx5_pmd_wrapped_mrwm;};/* Raw memory structure for the counter statistics values of a pool. */
The mlx5 PMD uses the kernel mlx5 driver to map physical memory to the
HW.
Using the Verbs API ibv_reg_mr, a mkey can be created for that.
In this case, the mkey is signed on the user ID of the kernel driver.
Using the DevX API, a mkey also can be created, but it should point an
umem object (represents the specific buffer mapping) created by the
kernel. In this case, the mkey is signed on the user ID of the process
DevX context.
In FW DevX control commands which get mkey as a parameter, there is
a security check on the user ID and Verbs mkeys are rejected.
Unfortunately, also when using DevX mkey, there is an error in the FW
command on umem validation because the umem is not designed to be used
for any mkey parameters.
As a workaround to the kernel driver/FW issue, it is needed to use a
wrapped MR, which is an indirect mkey(created by the DevX API) pointing to
direct mkey created by the kernel for any DevX command uses an MR.
Add an API to create and destroy this wrapped MR.
Use this logic in flow counter query management and in LM.
V3:
Fix issue in 32bit compilation.
V2:
Fix missing implementation for Windows.
Improve logs.
Matan Azrad (2):
common/mlx5: add wrapped MR create API
vdpa/mlx5: workaround dirty bitmap MR creation
Michael Baum (3):
common/mlx5: glue MR registration with IOVA
vdpa/mlx5: workaround guest MR registrations
net/mlx5: workaround MR creation for flow counter
drivers/common/mlx5/linux/meson.build | 2 +
drivers/common/mlx5/linux/mlx5_common_os.c | 56 ++++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.c | 18 +++++++
drivers/common/mlx5/linux/mlx5_glue.h | 3 ++
drivers/common/mlx5/mlx5_common.h | 18 +++++++
drivers/common/mlx5/version.map | 3 ++
drivers/common/mlx5/windows/mlx5_common_os.c | 40 ++++++++++++++
drivers/net/mlx5/mlx5.c | 8 +--
drivers/net/mlx5/mlx5.h | 5 +-
drivers/net/mlx5/mlx5_flow.c | 25 +++------
drivers/vdpa/mlx5/mlx5_vdpa.h | 9 ++--
drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 38 +++----------
drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 43 +++++----------
13 files changed, 175 insertions(+), 93 deletions(-)
--
2.25.1