From: Asaf Penso <asafp@mellanox.com>
Date: Mon, 23 Mar 2020 17:50:13 +0000 (+0000)
Subject: vdpa/mlx5: set default queue indices
X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6d6cd38f4586beeb40e25fb86c6bb441ede77797;p=dpdk.git

vdpa/mlx5: set default queue indices

The rte_vhost_get_vring_base function is being called to get the values
of last_avail_idx and last_used_idx.
These fields will not have the correct values in case the function
returns an error.

Adding a check for the function return value, and in the case of an
error, set the fields to be zero and print a warning message.

Fixes: bff735011078 ("vdpa/mlx5: prepare virtio queues")
Cc: stable@dpdk.org

Signed-off-by: Asaf Penso <asafp@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
index 2312331993..cb2d61bd06 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
@@ -236,10 +236,17 @@ mlx5_vdpa_virtq_setup(struct mlx5_vdpa_priv *priv,
 		}
 		attr.available_addr = gpa;
 	}
-	rte_vhost_get_vring_base(priv->vid, index, &last_avail_idx,
+	ret = rte_vhost_get_vring_base(priv->vid, index, &last_avail_idx,
 				 &last_used_idx);
-	DRV_LOG(INFO, "vid %d: Init last_avail_idx=%d, last_used_idx=%d for "
-		"virtq %d.", priv->vid, last_avail_idx, last_used_idx, index);
+	if (ret) {
+		last_avail_idx = 0;
+		last_used_idx = 0;
+		DRV_LOG(WARNING, "Couldn't get vring base, idx are set to 0");
+	} else {
+		DRV_LOG(INFO, "vid %d: Init last_avail_idx=%d, last_used_idx=%d for "
+				"virtq %d.", priv->vid, last_avail_idx,
+				last_used_idx, index);
+	}
 	attr.hw_available_index = last_avail_idx;
 	attr.hw_used_index = last_used_idx;
 	attr.q_size = vq.size;