vdpa/mlx5: set default queue indices
diff mbox series

Message ID 1584985813-14883-1-git-send-email-asafp@mellanox.com
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series
  • vdpa/mlx5: set default queue indices
Related show

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Asaf Penso March 23, 2020, 5:50 p.m. UTC
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.

Signed-off-by: Asaf Penso <asafp@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Maxime Coquelin April 15, 2020, 7:34 a.m. UTC | #1
Hi Asaf,

On 3/23/20 6:50 PM, Asaf Penso wrote:
> 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 tag is missing here.
I will add it while merging:

Fixes: bff735011078 ("vdpa/mlx5: prepare virtio queues")

> Signed-off-by: Asaf Penso <asafp@mellanox.com>
> Acked-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
Asaf Penso April 15, 2020, 11:52 a.m. UTC | #2
Thanks Maxime.

Regards,
Asaf Penso

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Wednesday, April 15, 2020 10:35 AM
> To: Asaf Penso <asafp@mellanox.com>; dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@mellanox.com>; Matan Azrad
> <matan@mellanox.com>
> Subject: Re: [dpdk-dev] [PATCH] vdpa/mlx5: set default queue indices
> 
> Hi Asaf,
> 
> On 3/23/20 6:50 PM, Asaf Penso wrote:
> > 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 tag is missing here.
> I will add it while merging:
> 
> Fixes: bff735011078 ("vdpa/mlx5: prepare virtio queues")
> 
> > Signed-off-by: Asaf Penso <asafp@mellanox.com>
> > Acked-by: Matan Azrad <matan@mellanox.com>
> > ---
> >  drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Thanks,
> Maxime
Maxime Coquelin April 17, 2020, 5:14 p.m. UTC | #3
On 3/23/20 6:50 PM, Asaf Penso wrote:
> 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.
> 
> Signed-off-by: Asaf Penso <asafp@mellanox.com>
> Acked-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)

Applied to dpdk-next-virtio/master

Thanks,
Maxime

Patch
diff mbox series

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
index 2312331..cb2d61b 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c
@@ -236,10 +236,17 @@ 
 		}
 		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;