net/mlx5: wrap glue reg/dereg UMEM per OS
authorTal Shnaiderman <talshn@nvidia.com>
Mon, 28 Dec 2020 09:54:14 +0000 (11:54 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:07 +0000 (16:03 +0100)
Wrap glue calls for UMEM registration and deregistration with generic OS
calls since each OS (Linux or Windows) has a different glue API
parameters.

Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
Signed-off-by: Ophir Munk <ophirmu@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/common/mlx5/linux/mlx5_common_os.h
drivers/common/mlx5/mlx5_common.c
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5_devx.c
drivers/net/mlx5/mlx5_flow.c
drivers/net/mlx5/mlx5_txpp.c

index c9f8d7c..f8b215c 100644 (file)
@@ -212,4 +212,16 @@ mlx5_os_dealloc_pd(void *pd)
 {
        return mlx5_glue->dealloc_pd(pd);
 }
+
+static inline void *
+mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access)
+{
+       return mlx5_glue->devx_umem_reg(ctx, addr, size, access);
+}
+
+static inline int
+mlx5_os_umem_dereg(void *pumem)
+{
+       return mlx5_glue->devx_umem_dereg(pumem);
+}
 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
index 0445132..a00ffcb 100644 (file)
@@ -148,7 +148,7 @@ mlx5_alloc_dbr_page(void *ctx)
                return NULL;
        }
        /* Register allocated memory. */
-       page->umem = mlx5_glue->devx_umem_reg(ctx, page->dbrs,
+       page->umem = mlx5_os_umem_reg(ctx, page->dbrs,
                                              MLX5_DBR_PAGE_SIZE, 0);
        if (!page->umem) {
                DRV_LOG(ERR, "cannot umem reg dbr page");
@@ -232,7 +232,7 @@ mlx5_release_dbr(struct mlx5_dbr_page_list *head, uint32_t umem_id,
                /* Page not used, free it and remove from list. */
                LIST_REMOVE(page, next);
                if (page->umem)
-                       ret = -mlx5_glue->devx_umem_dereg(page->umem);
+                       ret = -mlx5_os_umem_dereg(page->umem);
                mlx5_free(page);
        } else {
                /* Mark in bitmap that this door-bell is not in use. */
index 7d1b4fb..84123f8 100644 (file)
@@ -482,7 +482,7 @@ mlx5_flow_destroy_counter_stat_mem_mng(struct mlx5_counter_stats_mem_mng *mng)
 
        LIST_REMOVE(mng, next);
        claim_zero(mlx5_devx_cmd_destroy(mng->dm));
-       claim_zero(mlx5_glue->devx_umem_dereg(mng->umem));
+       claim_zero(mlx5_os_umem_dereg(mng->umem));
        mlx5_free(mem);
 }
 
index de9b204..235fd57 100644 (file)
@@ -155,7 +155,7 @@ mlx5_rxq_release_devx_rq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
        struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->rq_dbrec_page;
 
        if (rxq_ctrl->wq_umem) {
-               mlx5_glue->devx_umem_dereg(rxq_ctrl->wq_umem);
+               mlx5_os_umem_dereg(rxq_ctrl->wq_umem);
                rxq_ctrl->wq_umem = NULL;
        }
        if (rxq_ctrl->rxq.wqes) {
@@ -182,7 +182,7 @@ mlx5_rxq_release_devx_cq_resources(struct mlx5_rxq_ctrl *rxq_ctrl)
        struct mlx5_devx_dbr_page *dbr_page = rxq_ctrl->cq_dbrec_page;
 
        if (rxq_ctrl->cq_umem) {
-               mlx5_glue->devx_umem_dereg(rxq_ctrl->cq_umem);
+               mlx5_os_umem_dereg(rxq_ctrl->cq_umem);
                rxq_ctrl->cq_umem = NULL;
        }
        if (rxq_ctrl->rxq.cqes) {
@@ -375,7 +375,7 @@ mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, uint16_t idx)
        if (!buf)
                return NULL;
        rxq_data->wqes = buf;
-       rxq_ctrl->wq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+       rxq_ctrl->wq_umem = mlx5_os_umem_reg(priv->sh->ctx,
                                                     buf, wq_size, 0);
        if (!rxq_ctrl->wq_umem)
                goto error;
@@ -497,7 +497,7 @@ mlx5_rxq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
                goto error;
        }
        rxq_data->cqes = (volatile struct mlx5_cqe (*)[])(uintptr_t)buf;
-       rxq_ctrl->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx, buf,
+       rxq_ctrl->cq_umem = mlx5_os_umem_reg(priv->sh->ctx, buf,
                                                     cq_size,
                                                     IBV_ACCESS_LOCAL_WRITE);
        if (!rxq_ctrl->cq_umem) {
@@ -1127,7 +1127,7 @@ mlx5_txq_release_devx_sq_resources(struct mlx5_txq_obj *txq_obj)
                txq_obj->sq_devx = NULL;
        }
        if (txq_obj->sq_umem) {
-               claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->sq_umem));
+               claim_zero(mlx5_os_umem_dereg(txq_obj->sq_umem));
                txq_obj->sq_umem = NULL;
        }
        if (txq_obj->sq_buf) {
@@ -1155,7 +1155,7 @@ mlx5_txq_release_devx_cq_resources(struct mlx5_txq_obj *txq_obj)
        if (txq_obj->cq_devx)
                claim_zero(mlx5_devx_cmd_destroy(txq_obj->cq_devx));
        if (txq_obj->cq_umem)
-               claim_zero(mlx5_glue->devx_umem_dereg(txq_obj->cq_umem));
+               claim_zero(mlx5_os_umem_dereg(txq_obj->cq_umem));
        if (txq_obj->cq_buf)
                mlx5_free(txq_obj->cq_buf);
        if (txq_obj->cq_dbrec_page)
@@ -1243,7 +1243,7 @@ mlx5_txq_create_devx_cq_resources(struct rte_eth_dev *dev, uint16_t idx)
                return 0;
        }
        /* Register allocated buffer in user space with DevX. */
-       txq_obj->cq_umem = mlx5_glue->devx_umem_reg(priv->sh->ctx,
+       txq_obj->cq_umem = mlx5_os_umem_reg(priv->sh->ctx,
                                                (void *)txq_obj->cq_buf,
                                                cqe_n * sizeof(struct mlx5_cqe),
                                                IBV_ACCESS_LOCAL_WRITE);
@@ -1342,7 +1342,7 @@ mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx)
                goto error;
        }
        /* Register allocated buffer in user space with DevX. */
-       txq_obj->sq_umem = mlx5_glue->devx_umem_reg
+       txq_obj->sq_umem = mlx5_os_umem_reg
                                        (priv->sh->ctx,
                                         (void *)txq_obj->sq_buf,
                                         wqe_n * sizeof(struct mlx5_wqe),
index bf86aaa..66491bb 100644 (file)
@@ -6446,7 +6446,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
        }
        mem_mng = (struct mlx5_counter_stats_mem_mng *)(mem + size) - 1;
        size = sizeof(*raw_data) * MLX5_COUNTERS_PER_POOL * raws_n;
-       mem_mng->umem = mlx5_glue->devx_umem_reg(sh->ctx, mem, size,
+       mem_mng->umem = mlx5_os_umem_reg(sh->ctx, mem, size,
                                                 IBV_ACCESS_LOCAL_WRITE);
        if (!mem_mng->umem) {
                rte_errno = errno;
@@ -6465,7 +6465,7 @@ mlx5_flow_create_counter_stat_mem_mng(struct mlx5_dev_ctx_shared *sh)
        mkey_attr.relaxed_ordering_read = sh->cmng.relaxed_ordering_read;
        mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);
        if (!mem_mng->dm) {
-               mlx5_glue->devx_umem_dereg(mem_mng->umem);
+               mlx5_os_umem_dereg(mem_mng->umem);
                rte_errno = errno;
                mlx5_free(mem);
                return -rte_errno;
index d61e43e..749529c 100644 (file)
@@ -131,13 +131,13 @@ mlx5_txpp_destroy_send_queue(struct mlx5_txpp_wq *wq)
        if (wq->sq)
                claim_zero(mlx5_devx_cmd_destroy(wq->sq));
        if (wq->sq_umem)
-               claim_zero(mlx5_glue->devx_umem_dereg(wq->sq_umem));
+               claim_zero(mlx5_os_umem_dereg(wq->sq_umem));
        if (wq->sq_buf)
                mlx5_free((void *)(uintptr_t)wq->sq_buf);
        if (wq->cq)
                claim_zero(mlx5_devx_cmd_destroy(wq->cq));
        if (wq->cq_umem)
-               claim_zero(mlx5_glue->devx_umem_dereg(wq->cq_umem));
+               claim_zero(mlx5_os_umem_dereg(wq->cq_umem));
        if (wq->cq_buf)
                mlx5_free((void *)(uintptr_t)wq->cq_buf);
        memset(wq, 0, sizeof(*wq));
@@ -268,7 +268,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
                return -ENOMEM;
        }
        /* Register allocated buffer in user space with DevX. */
-       wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+       wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
                                               (void *)(uintptr_t)wq->cq_buf,
                                               umem_size,
                                               IBV_ACCESS_LOCAL_WRITE);
@@ -318,7 +318,7 @@ mlx5_txpp_create_rearm_queue(struct mlx5_dev_ctx_shared *sh)
                goto error;
        }
        /* Register allocated buffer in user space with DevX. */
-       wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+       wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
                                               (void *)(uintptr_t)wq->sq_buf,
                                               umem_size,
                                               IBV_ACCESS_LOCAL_WRITE);
@@ -506,7 +506,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
                return -ENOMEM;
        }
        /* Register allocated buffer in user space with DevX. */
-       wq->cq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+       wq->cq_umem = mlx5_os_umem_reg(sh->ctx,
                                               (void *)(uintptr_t)wq->cq_buf,
                                               umem_size,
                                               IBV_ACCESS_LOCAL_WRITE);
@@ -562,7 +562,7 @@ mlx5_txpp_create_clock_queue(struct mlx5_dev_ctx_shared *sh)
                goto error;
        }
        /* Register allocated buffer in user space with DevX. */
-       wq->sq_umem = mlx5_glue->devx_umem_reg(sh->ctx,
+       wq->sq_umem = mlx5_os_umem_reg(sh->ctx,
                                               (void *)(uintptr_t)wq->sq_buf,
                                               umem_size,
                                               IBV_ACCESS_LOCAL_WRITE);