DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: dev@dpdk.org
Cc: Viacheslav Ovsiienko <viacheslavo@mellanox.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH 2/3] vdpa/mlx5: separate virtq stop
Date: Tue, 31 Mar 2020 11:12:22 +0000	[thread overview]
Message-ID: <1585653143-21987-3-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1585653143-21987-1-git-send-email-matan@mellanox.com>

In live migration, before loging 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 <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 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 3575272..0bb6416 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)
 {
-- 
1.8.3.1


  parent reply	other threads:[~2020-03-31 11:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 11:12 [dpdk-dev] [PATCH 0/3] vdpa/mlx5: recteate a virtq becoming enabled Matan Azrad
2020-03-31 11:12 ` [dpdk-dev] [PATCH 1/3] vdpa/mlx5: manage virtqs by array Matan Azrad
2020-04-09 15:18   ` Maxime Coquelin
2020-04-10 13:58     ` Matan Azrad
2020-04-10 13:59       ` Maxime Coquelin
2020-04-15 14:06   ` Maxime Coquelin
2020-03-31 11:12 ` Matan Azrad [this message]
2020-04-09 15:28   ` [dpdk-dev] [PATCH 2/3] vdpa/mlx5: separate virtq stop Maxime Coquelin
2020-04-10 13:59     ` Matan Azrad
2020-04-10 14:04       ` Maxime Coquelin
2020-03-31 11:12 ` [dpdk-dev] [PATCH 3/3] vdpa/mlx5: recteate a virtq becoming enabled Matan Azrad
2020-04-15 14:06   ` Maxime Coquelin
2020-04-17 14:58 ` [dpdk-dev] [PATCH 0/3] " Maxime Coquelin
2020-04-26 12:07 ` [dpdk-dev] [PATCH 0/3] vdpa/mlx5: recreate " Matan Azrad
2020-04-26 12:07   ` [dpdk-dev] [PATCH 1/3] vdpa/mlx5: manage virtqs by array Matan Azrad
2020-04-27  7:45     ` Maxime Coquelin
2020-04-26 12:07   ` [dpdk-dev] [PATCH 2/3] vdpa/mlx5: separate virtq stop Matan Azrad
2020-04-26 12:07   ` [dpdk-dev] [PATCH 3/3] vdpa/mlx5: recreate a virtq becoming enabled Matan Azrad
2020-04-28 16:07   ` [dpdk-dev] [PATCH 0/3] " Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1585653143-21987-3-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=shahafs@mellanox.com \
    --cc=viacheslavo@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).