netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dragos Tatulea <dtatulea@nvidia.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Saeed Mahameed" <saeedm@nvidia.com>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Tariq Toukan" <tariqt@nvidia.com>,
	"Si-Wei Liu" <si-wei.liu@oracle.com>
Cc: <virtualization@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<linux-rdma@vger.kernel.org>, <netdev@vger.kernel.org>,
	Dragos Tatulea <dtatulea@nvidia.com>,
	Cosmin Ratiu <cratiu@nvidia.com>
Subject: [PATCH vhost 16/23] vdpa/mlx5: Add error code for suspend/resume VQ
Date: Mon, 17 Jun 2024 18:07:50 +0300	[thread overview]
Message-ID: <20240617-stage-vdpa-vq-precreate-v1-16-8c0483f0ca2a@nvidia.com> (raw)
In-Reply-To: <20240617-stage-vdpa-vq-precreate-v1-0-8c0483f0ca2a@nvidia.com>

Instead of blindly calling suspend/resume_vqs(), make then return error
codes.

To keep compatibility, keep suspending or resuming VQs on error and
return the last error code. The assumption here is that the error code
would be the same.

Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 77 +++++++++++++++++++++++++++------------
 1 file changed, 54 insertions(+), 23 deletions(-)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index e4d68d2d0bb4..e3a82c43b44e 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1526,71 +1526,102 @@ static int setup_vq(struct mlx5_vdpa_net *ndev,
 	return err;
 }
 
-static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
+static int suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
 {
 	struct mlx5_virtq_attr attr;
+	int err;
 
 	if (!mvq->initialized)
-		return;
+		return 0;
 
 	if (mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY)
-		return;
+		return 0;
 
-	if (modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND))
-		mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed\n");
+	err = modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND);
+	if (err) {
+		mlx5_vdpa_warn(&ndev->mvdev, "modify to suspend failed, err: %d\n", err);
+		return err;
+	}
 
-	if (query_virtqueue(ndev, mvq, &attr)) {
-		mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue\n");
-		return;
+	err = query_virtqueue(ndev, mvq, &attr);
+	if (err) {
+		mlx5_vdpa_warn(&ndev->mvdev, "failed to query virtqueue, err: %d\n", err);
+		return err;
 	}
+
 	mvq->avail_idx = attr.available_index;
 	mvq->used_idx = attr.used_index;
+
+	return 0;
 }
 
-static void suspend_vqs(struct mlx5_vdpa_net *ndev)
+static int suspend_vqs(struct mlx5_vdpa_net *ndev)
 {
+	int err = 0;
 	int i;
 
-	for (i = 0; i < ndev->cur_num_vqs; i++)
-		suspend_vq(ndev, &ndev->vqs[i]);
+	for (i = 0; i < ndev->cur_num_vqs; i++) {
+		int local_err = suspend_vq(ndev, &ndev->vqs[i]);
+
+		err = local_err ? local_err : err;
+	}
+
+	return err;
 }
 
-static void resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
+static int resume_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
 {
+	int err;
+
 	if (!mvq->initialized)
-		return;
+		return 0;
 
 	switch (mvq->fw_state) {
 	case MLX5_VIRTIO_NET_Q_OBJECT_STATE_INIT:
 		/* Due to a FW quirk we need to modify the VQ fields first then change state.
 		 * This should be fixed soon. After that, a single command can be used.
 		 */
-		if (modify_virtqueue(ndev, mvq, 0))
+		err = modify_virtqueue(ndev, mvq, 0);
+		if (err) {
 			mlx5_vdpa_warn(&ndev->mvdev,
-				"modify vq properties failed for vq %u\n", mvq->index);
+				"modify vq properties failed for vq %u, err: %d\n",
+				mvq->index, err);
+			return err;
+		}
 		break;
 	case MLX5_VIRTIO_NET_Q_OBJECT_STATE_SUSPEND:
 		if (!is_resumable(ndev)) {
 			mlx5_vdpa_warn(&ndev->mvdev, "vq %d is not resumable\n", mvq->index);
-			return;
+			return -EINVAL;
 		}
 		break;
 	case MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY:
-		return;
+		return 0;
 	default:
 		mlx5_vdpa_warn(&ndev->mvdev, "resume vq %u called from bad state %d\n",
 			       mvq->index, mvq->fw_state);
-		return;
+		return -EINVAL;
 	}
 
-	if (modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY))
-		mlx5_vdpa_warn(&ndev->mvdev, "modify to resume failed for vq %u\n", mvq->index);
+	err = modify_virtqueue_state(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY);
+	if (err)
+		mlx5_vdpa_warn(&ndev->mvdev, "modify to resume failed for vq %u, err: %d\n",
+			       mvq->index, err);
+
+	return err;
 }
 
-static void resume_vqs(struct mlx5_vdpa_net *ndev)
+static int resume_vqs(struct mlx5_vdpa_net *ndev)
 {
-	for (int i = 0; i < ndev->cur_num_vqs; i++)
-		resume_vq(ndev, &ndev->vqs[i]);
+	int err = 0;
+
+	for (int i = 0; i < ndev->cur_num_vqs; i++) {
+		int local_err = resume_vq(ndev, &ndev->vqs[i]);
+
+		err = local_err ? local_err : err;
+	}
+
+	return err;
 }
 
 static void teardown_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)

-- 
2.45.1


  parent reply	other threads:[~2024-06-17 15:09 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 15:07 [PATCH vhost 00/23] vdpa/mlx5: Pre-create HW VQs to reduce LM downtime Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 01/23] vdpa/mlx5: Clarify meaning thorough function rename Dragos Tatulea
2024-06-19 10:37   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 02/23] vdpa/mlx5: Make setup/teardown_vq_resources() symmetrical Dragos Tatulea
2024-06-19 10:38   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 03/23] vdpa/mlx5: Drop redundant code Dragos Tatulea
2024-06-19 10:55   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 04/23] vdpa/mlx5: Drop redundant check in teardown_virtqueues() Dragos Tatulea
2024-06-19 10:56   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 05/23] vdpa/mlx5: Iterate over active VQs during suspend/resume Dragos Tatulea
2024-06-19 11:04   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 06/23] vdpa/mlx5: Remove duplicate suspend code Dragos Tatulea
2024-06-19 11:02   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 07/23] vdpa/mlx5: Initialize and reset device with one queue pair Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 08/23] vdpa/mlx5: Clear and reinitialize software VQ data on reset Dragos Tatulea
2024-06-19 11:28   ` Eugenio Perez Martin
2024-06-19 17:03     ` Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 09/23] vdpa/mlx5: Add support for modifying the virtio_version VQ field Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 10/23] vdpa/mlx5: Add support for modifying the VQ features field Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 11/23] vdpa/mlx5: Set an initial size on the VQ Dragos Tatulea
2024-06-19 15:08   ` Eugenio Perez Martin
2024-06-19 17:06     ` Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 12/23] vdpa/mlx5: Start off rqt_size with max VQPs Dragos Tatulea
2024-06-19 15:33   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 13/23] vdpa/mlx5: Set mkey modified flags on all VQs Dragos Tatulea
2024-06-19 15:33   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 14/23] vdpa/mlx5: Allow creation of blank VQs Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 15/23] vdpa/mlx5: Accept Init -> Ready VQ transition in resume_vq() Dragos Tatulea
2024-06-17 15:07 ` Dragos Tatulea [this message]
2024-06-19 15:41   ` [PATCH vhost 16/23] vdpa/mlx5: Add error code for suspend/resume VQ Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 17/23] vdpa/mlx5: Consolidate all VQ modify to Ready to use resume_vq() Dragos Tatulea
2024-06-19 15:43   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 18/23] vdpa/mlx5: Forward error in suspend/resume device Dragos Tatulea
2024-06-23 11:19   ` Zhu Yanjun
2024-06-26  9:28     ` Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 19/23] vdpa/mlx5: Use suspend/resume during VQP change Dragos Tatulea
2024-06-19 15:46   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 20/23] vdpa/mlx5: Pre-create hardware VQs at vdpa .dev_add time Dragos Tatulea
2024-06-19 15:54   ` Eugenio Perez Martin
2024-06-26  9:27     ` Dragos Tatulea
2024-07-03 16:01       ` Eugenio Perez Martin
2024-07-08 11:01         ` Dragos Tatulea
2024-07-08 11:11           ` Michael S. Tsirkin
2024-07-08 11:17             ` Dragos Tatulea
2024-07-08 11:25               ` Michael S. Tsirkin
2024-07-08 16:22   ` Zhu Yanjun
2024-07-08 16:43     ` Dragos Tatulea
2024-06-17 15:07 ` [PATCH vhost 21/23] vdpa/mlx5: Re-create HW VQs under certain conditions Dragos Tatulea
2024-06-19 16:04   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 22/23] vdpa/mlx5: Don't reset VQs more than necessary Dragos Tatulea
2024-06-19 16:14   ` Eugenio Perez Martin
2024-06-17 15:07 ` [PATCH vhost 23/23] vdpa/mlx5: Don't enable non-active VQs in .set_vq_ready() Dragos Tatulea
2024-06-19 16:39   ` Eugenio Perez Martin

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=20240617-stage-vdpa-vq-precreate-v1-16-8c0483f0ca2a@nvidia.com \
    --to=dtatulea@nvidia.com \
    --cc=cratiu@nvidia.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=si-wei.liu@oracle.com \
    --cc=tariqt@nvidia.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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).