From 9f39076b71a8f6526e8da0612f365ef2c682efe0 Mon Sep 17 00:00:00 2001 From: Shiri Kuzin Date: Fri, 7 May 2021 10:01:22 +0300 Subject: [PATCH] common/mlx5: fix mkey attributes initialization The crypto driver added new fields to the mkey attributes struct: crypto_en and set_remote_rw. The entire mkey struct was not initialized, only specific fields in it, which caused the new added fields not to be initialized resulting in a mkey creation error. This is fixed by initializing the entire mkey attributes struct to 0 which will prevent this issue from reoccurring if any fields are added to the mkey struct in the future. Fixes: 0111a74e13dd ("common/mlx5: adjust DevX mkey fields for crypto") Signed-off-by: Shiri Kuzin Acked-by: Matan Azrad --- drivers/common/mlx5/windows/mlx5_common_os.c | 7 +------ drivers/net/mlx5/mlx5_flow.c | 5 +---- drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 4 ---- drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 5 +---- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c index 78975d9d4d..5031bdca26 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.c +++ b/drivers/common/mlx5/windows/mlx5_common_os.c @@ -168,16 +168,11 @@ mlx5_os_reg_mr(void *pd, IBV_ACCESS_LOCAL_WRITE); if (!obj) return -1; + memset(&mkey_attr, 0, sizeof(mkey_attr)); mkey_attr.addr = (uintptr_t)addr; mkey_attr.size = length; mkey_attr.umem_id = ((struct mlx5_devx_umem *)(obj))->umem_id; mkey_attr.pd = mlx5_pd->pdn; - mkey_attr.log_entity_size = 0; - mkey_attr.pg_access = 0; - mkey_attr.klm_array = NULL; - mkey_attr.klm_num = 0; - mkey_attr.relaxed_ordering_read = 0; - mkey_attr.relaxed_ordering_write = 0; if (!haswell_broadwell_cpu) { mkey_attr.relaxed_ordering_write = attr.relaxed_ordering_write; mkey_attr.relaxed_ordering_read = attr.relaxed_ordering_read; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 3194cd5633..2811537226 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7378,14 +7378,11 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh) mlx5_free(mem); return -rte_errno; } + memset(&mkey_attr, 0, sizeof(mkey_attr)); mkey_attr.addr = (uintptr_t)mem; mkey_attr.size = size; mkey_attr.umem_id = mlx5_os_get_umem_id(mem_mng->umem); mkey_attr.pd = sh->pdn; - mkey_attr.log_entity_size = 0; - mkey_attr.pg_access = 0; - mkey_attr.klm_array = NULL; - mkey_attr.klm_num = 0; mkey_attr.relaxed_ordering_write = sh->cmng.relaxed_ordering_write; mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read; mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_lm.c b/drivers/vdpa/mlx5/mlx5_vdpa_lm.c index 6c4284f7f7..f391813745 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_lm.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_lm.c @@ -41,10 +41,6 @@ mlx5_vdpa_dirty_bitmap_set(struct mlx5_vdpa_priv *priv, uint64_t log_base, .size = log_size, .pd = priv->pdn, .pg_access = 1, - .klm_array = NULL, - .klm_num = 0, - .relaxed_ordering_read = 0, - .relaxed_ordering_write = 0, }; struct mlx5_devx_virtq_attr attr = { .type = MLX5_VIRTQ_MODIFY_TYPE_DIRTY_BITMAP_PARAMS, diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c index f8861d5d26..a13bde5a0b 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c @@ -200,6 +200,7 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) goto error; } DRV_LOG(DEBUG, "Dump fill Mkey = %u.", priv->null_mr->lkey); + memset(&mkey_attr, 0, sizeof(mkey_attr)); for (i = 0; i < mem->nregions; i++) { reg = &mem->regions[i]; entry = rte_zmalloc(__func__, sizeof(*entry), 0); @@ -221,10 +222,6 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv) mkey_attr.umem_id = entry->umem->umem_id; mkey_attr.pd = priv->pdn; mkey_attr.pg_access = 1; - mkey_attr.klm_array = NULL; - mkey_attr.klm_num = 0; - mkey_attr.relaxed_ordering_read = 0; - mkey_attr.relaxed_ordering_write = 0; entry->mkey = mlx5_devx_cmd_mkey_create(priv->ctx, &mkey_attr); if (!entry->mkey) { DRV_LOG(ERR, "Failed to create direct Mkey."); -- 2.20.1