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 DD571A0514; Tue, 2 Jun 2020 17:52:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5442B1C036; Tue, 2 Jun 2020 17:52:19 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 1E41E1C02E for ; Tue, 2 Jun 2020 17:52:18 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Jun 2020 18:52:17 +0300 Received: from pegasus25.mtr.labs.mlnx. (pegasus25.mtr.labs.mlnx [10.210.16.10]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 052FqBDD015290; Tue, 2 Jun 2020 18:52:17 +0300 From: Matan Azrad To: Viacheslav Ovsiienko Cc: dev@dpdk.org, Maxime Coquelin , stable@dpdk.org, Xueming Li Date: Tue, 2 Jun 2020 15:51:44 +0000 Message-Id: <1591113104-79071-2-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591113104-79071-1-git-send-email-matan@mellanox.com> References: <1591113104-79071-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH 2/2] vdpa/mlx5: adjust virtio queue protection domain 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" In other to fill the new requirement for virtq configuration, set the single PD managed by the driver for all the virtqs. Cc: stable@dpdk.org Signed-off-by: Matan Azrad Signed-off-by: Xueming Li --- drivers/vdpa/mlx5/mlx5_vdpa.c | 38 ++++++++++++++++++++++++++++++++++- drivers/vdpa/mlx5/mlx5_vdpa_mem.c | 40 ------------------------------------- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 1 + 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index a80e3f4..94cac66 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -192,6 +192,37 @@ } static int +mlx5_vdpa_pd_create(struct mlx5_vdpa_priv *priv) +{ +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + priv->pd = mlx5_glue->alloc_pd(priv->ctx); + if (priv->pd == NULL) { + DRV_LOG(ERR, "Failed to allocate PD."); + return errno ? -errno : -ENOMEM; + } + struct mlx5dv_obj obj; + struct mlx5dv_pd pd_info; + int ret = 0; + + obj.pd.in = priv->pd; + obj.pd.out = &pd_info; + ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD); + if (ret) { + DRV_LOG(ERR, "Fail to get PD object info."); + mlx5_glue->dealloc_pd(priv->pd); + priv->pd = NULL; + return -errno; + } + priv->pdn = pd_info.pdn; + return 0; +#else + (void)priv; + DRV_LOG(ERR, "Cannot get pdn - no DV support."); + return -ENOTSUP; +#endif /* HAVE_IBV_FLOW_DV_SUPPORT */ +} + +static int mlx5_vdpa_dev_close(int vid) { int did = rte_vhost_get_vdpa_device_id(vid); @@ -209,6 +240,10 @@ mlx5_vdpa_virtqs_release(priv); mlx5_vdpa_event_qp_global_release(priv); mlx5_vdpa_mem_dereg(priv); + if (priv->pd) { + claim_zero(mlx5_glue->dealloc_pd(priv->pd)); + priv->pd = NULL; + } priv->configured = 0; priv->vid = 0; DRV_LOG(INFO, "vDPA device %d was closed.", vid); @@ -230,7 +265,8 @@ return -1; } priv->vid = vid; - if (mlx5_vdpa_mem_register(priv) || mlx5_vdpa_direct_db_prepare(priv) || + if (mlx5_vdpa_pd_create(priv) || mlx5_vdpa_mem_register(priv) || + mlx5_vdpa_direct_db_prepare(priv) || mlx5_vdpa_virtqs_prepare(priv) || mlx5_vdpa_steer_setup(priv) || mlx5_vdpa_cqe_event_setup(priv)) { mlx5_vdpa_dev_close(vid); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c index da31b47..b6c7cb8 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_mem.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_mem.c @@ -14,39 +14,6 @@ #include "mlx5_vdpa_utils.h" #include "mlx5_vdpa.h" -static int -mlx5_vdpa_pd_prepare(struct mlx5_vdpa_priv *priv) -{ -#ifdef HAVE_IBV_FLOW_DV_SUPPORT - if (priv->pd) - return 0; - priv->pd = mlx5_glue->alloc_pd(priv->ctx); - if (priv->pd == NULL) { - DRV_LOG(ERR, "Failed to allocate PD."); - return errno ? -errno : -ENOMEM; - } - struct mlx5dv_obj obj; - struct mlx5dv_pd pd_info; - int ret = 0; - - obj.pd.in = priv->pd; - obj.pd.out = &pd_info; - ret = mlx5_glue->dv_init_obj(&obj, MLX5DV_OBJ_PD); - if (ret) { - DRV_LOG(ERR, "Fail to get PD object info."); - mlx5_glue->dealloc_pd(priv->pd); - priv->pd = NULL; - return -errno; - } - priv->pdn = pd_info.pdn; - return 0; -#else - (void)priv; - DRV_LOG(ERR, "Cannot get pdn - no DV support."); - return -ENOTSUP; -#endif /* HAVE_IBV_FLOW_DV_SUPPORT */ -} - void mlx5_vdpa_mem_dereg(struct mlx5_vdpa_priv *priv) { @@ -68,10 +35,6 @@ claim_zero(mlx5_glue->dereg_mr(priv->null_mr)); priv->null_mr = NULL; } - if (priv->pd) { - claim_zero(mlx5_glue->dealloc_pd(priv->pd)); - priv->pd = NULL; - } if (priv->vmem) { free(priv->vmem); priv->vmem = NULL; @@ -230,9 +193,6 @@ if (!mem) return -rte_errno; priv->vmem = mem; - ret = mlx5_vdpa_pd_prepare(priv); - if (ret) - goto error; priv->null_mr = mlx5_glue->alloc_null_mr(priv->pd); if (!priv->null_mr) { DRV_LOG(ERR, "Failed to allocate null MR."); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c index d57ed59..86aded2 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c @@ -284,6 +284,7 @@ attr.mkey = priv->gpa_mkey_index; attr.tis_id = priv->tis->id; attr.queue_index = index; + attr.pd = priv->pdn; virtq->virtq = mlx5_devx_cmd_create_virtq(priv->ctx, &attr); virtq->priv = priv; if (!virtq->virtq) -- 1.8.3.1