From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0845A04B5; Wed, 28 Oct 2020 00:30:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C9B816A16; Wed, 28 Oct 2020 00:24:46 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 781592C2E for ; Wed, 28 Oct 2020 00:24:00 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 28 Oct 2020 01:23:54 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09RNNrrO026642; Wed, 28 Oct 2020 01:23:54 +0200 From: Ophir Munk To: dev@dpdk.org, Raslan Darawsheh Cc: Ophir Munk , Matan Azrad , Tal Shnaiderman , Thomas Monjalon Date: Tue, 27 Oct 2020 23:22:35 +0000 Message-Id: <20201027232335.31427-13-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201027232335.31427-1-ophirmu@nvidia.com> References: <20201027232335.31427-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v1 12/72] net/mlx5: wrap glue reg/dereg UMEM with OS calls X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Tal Shnaiderman 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 Signed-off-by: Ophir Munk --- drivers/common/mlx5/linux/mlx5_common_os.h | 12 ++++++++++++ drivers/common/mlx5/mlx5_common.c | 4 ++-- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5_devx.c | 16 ++++++++-------- drivers/net/mlx5/mlx5_flow.c | 4 ++-- drivers/net/mlx5/mlx5_txpp.c | 12 ++++++------ 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h index c9f8d7c..f8b215c 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.h +++ b/drivers/common/mlx5/linux/mlx5_common_os.h @@ -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_ */ diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 06f0a64..df2ba34 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -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. */ diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 1d89615..cb131da 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -508,7 +508,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); } diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index 5fce4cd..563e56d 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -159,7 +159,7 @@ mlx5_rxq_release_devx_rq_resources(struct mlx5_rxq_ctrl *rxq_ctrl) rxq_ctrl->rxq.wqes = NULL; } 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 (dbr_page) { @@ -186,7 +186,7 @@ mlx5_rxq_release_devx_cq_resources(struct mlx5_rxq_ctrl *rxq_ctrl) rxq_ctrl->rxq.cqes = NULL; } 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 (dbr_page) { @@ -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; @@ -475,7 +475,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) { @@ -1038,7 +1038,7 @@ mlx5_txq_release_devx_sq_resources(struct mlx5_txq_obj *txq_obj) if (txq_obj->sq_devx) claim_zero(mlx5_devx_cmd_destroy(txq_obj->sq_devx)); 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)); if (txq_obj->sq_buf) mlx5_free(txq_obj->sq_buf); if (txq_obj->sq_dbrec_page) @@ -1060,7 +1060,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) @@ -1148,7 +1148,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); @@ -1247,7 +1247,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), diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 43d3acd..93ed113 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7207,7 +7207,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; @@ -7226,7 +7226,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; diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c index 85bbea9..9d6b921 100644 --- a/drivers/net/mlx5/mlx5_txpp.c +++ b/drivers/net/mlx5/mlx5_txpp.c @@ -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); -- 2.8.4