From patchwork Sun Apr 26 12:07:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 69341 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C5D7A00C5; Sun, 26 Apr 2020 14:08:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1EF781C0CA; Sun, 26 Apr 2020 14:08:07 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id CDC6D1C0C6 for ; Sun, 26 Apr 2020 14:08:05 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from matan@mellanox.com) with ESMTPS (AES256-SHA encrypted); 26 Apr 2020 15:08:05 +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 03QC7krC016256; Sun, 26 Apr 2020 15:08:05 +0300 From: Matan Azrad To: dev@dpdk.org Cc: Viacheslav Ovsiienko , Shahaf Shuler , Maxime Coquelin Date: Sun, 26 Apr 2020 12:07:35 +0000 Message-Id: <1587902856-443267-3-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1587902856-443267-1-git-send-email-matan@mellanox.com> References: <1585653143-21987-1-git-send-email-matan@mellanox.com> <1587902856-443267-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH 2/3] vdpa/mlx5: separate virtq stop 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 live migration, before logging the virtq, the driver queries the virtq indexes after moving it to suspend mode. Separate this method to new function mlx5_vdpa_virtq_stop as a preparation for reusing. Signed-off-by: Matan Azrad Acked-by: Viacheslav Ovsiienko Reviewed-by: Maxime Coquelin --- drivers/vdpa/mlx5/mlx5_vdpa.h | 13 +++++++++++++ drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 17 ++--------------- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 26 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h index baec106..0edd688 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/mlx5_vdpa.h @@ -308,4 +308,17 @@ int mlx5_vdpa_dirty_bitmap_set(struct mlx5_vdpa_priv *priv, uint64_t log_base, */ int mlx5_vdpa_virtq_modify(struct mlx5_vdpa_virtq *virtq, int state); +/** + * Stop virtq before destroying it. + * + * @param[in] priv + * The vdpa driver private structure. + * @param[in] index + * The virtq index. + * + * @return + * 0 on success, a negative value otherwise. + */ +int mlx5_vdpa_virtq_stop(struct mlx5_vdpa_priv *priv, int index); + #endif /* RTE_PMD_MLX5_VDPA_H_ */ diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_lm.c b/drivers/vdpa/mlx5/mlx5_vdpa_lm.c index 77f2eda..26b7ce1 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_lm.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_lm.c @@ -91,7 +91,6 @@ int mlx5_vdpa_lm_log(struct mlx5_vdpa_priv *priv) { - struct mlx5_devx_virtq_attr attr = {0}; uint64_t features; int ret = rte_vhost_get_negotiated_features(priv->vid, &features); int i; @@ -103,21 +102,9 @@ if (!RTE_VHOST_NEED_LOG(features)) return 0; for (i = 0; i < priv->nr_virtqs; ++i) { - ret = mlx5_vdpa_virtq_modify(&priv->virtqs[i], 0); - if (ret) - return -1; - if (mlx5_devx_cmd_query_virtq(priv->virtqs[i].virtq, &attr)) { - DRV_LOG(ERR, "Failed to query virtq %d.", i); - return -1; - } - DRV_LOG(INFO, "Query vid %d vring %d: hw_available_idx=%d, " - "hw_used_index=%d", priv->vid, i, - attr.hw_available_index, attr.hw_used_index); - ret = rte_vhost_set_vring_base(priv->vid, i, - attr.hw_available_index, - attr.hw_used_index); + ret = mlx5_vdpa_virtq_stop(priv, i); if (ret) { - DRV_LOG(ERR, "Failed to set virtq %d base.", i); + DRV_LOG(ERR, "Failed to stop virtq %d.", i); return -1; } rte_vhost_log_used_vring(priv->vid, i, 0, diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c index e07c826..9c0284c 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c @@ -112,6 +112,32 @@ return mlx5_devx_cmd_modify_virtq(virtq->virtq, &attr); } +int +mlx5_vdpa_virtq_stop(struct mlx5_vdpa_priv *priv, int index) +{ + struct mlx5_devx_virtq_attr attr = {0}; + struct mlx5_vdpa_virtq *virtq = &priv->virtqs[index]; + int ret = mlx5_vdpa_virtq_modify(virtq, 0); + + if (ret) + return -1; + if (mlx5_devx_cmd_query_virtq(virtq->virtq, &attr)) { + DRV_LOG(ERR, "Failed to query virtq %d.", index); + return -1; + } + DRV_LOG(INFO, "Query vid %d vring %d: hw_available_idx=%d, " + "hw_used_index=%d", priv->vid, index, + attr.hw_available_index, attr.hw_used_index); + ret = rte_vhost_set_vring_base(priv->vid, index, + attr.hw_available_index, + attr.hw_used_index); + if (ret) { + DRV_LOG(ERR, "Failed to set virtq %d base.", index); + return -1; + } + return 0; +} + static uint64_t mlx5_vdpa_hva_to_gpa(struct rte_vhost_memory *mem, uint64_t hva) {