diff mbox series

[v2,4/5] vhost: notify virtq file descriptor update

Message ID 1593092298-52257-5-git-send-email-matan@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers show
Series vhost: improve ready state | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Matan Azrad June 25, 2020, 1:38 p.m. UTC
When virtq call or kick file descriptors are changed in the device
configuration when the queue is ready, the application and the vDPA
driver should be notified to be aligned to the new file descriptors.

Notify the state to be disabled before the file descriptor update and
return it back to be enabled after the update.

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 lib/librte_vhost/vhost_user.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Maxime Coquelin June 26, 2020, 12:19 p.m. UTC | #1
On 6/25/20 3:38 PM, Matan Azrad wrote:
> When virtq call or kick file descriptors are changed in the device
> configuration when the queue is ready, the application and the vDPA
> driver should be notified to be aligned to the new file descriptors.
> 
> Notify the state to be disabled before the file descriptor update and
> return it back to be enabled after the update.
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
>  lib/librte_vhost/vhost_user.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index f690fdb..f3966b6 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1624,6 +1624,12 @@
>  		"vring call idx:%d file:%d\n", file.index, file.fd);
>  
>  	vq = dev->virtqueue[file.index];
> +
> +	if (vq->ready) {
> +		vhost_user_notify_queue_state(dev, file.index, 0);
> +		vq->ready = 0;
> +	}
> +
>  	if (vq->callfd >= 0)
>  		close(vq->callfd);
>  
> @@ -1882,6 +1888,11 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused,
>  				dev->vid, file.index, 1);
>  	}
>  
> +	if (vq->ready) {
> +		vhost_user_notify_queue_state(dev, file.index, 0);
> +		vq->ready = 0;
> +	}
> +
>  	if (vq->kickfd >= 0)
>  		close(vq->kickfd);
>  	vq->kickfd = file.fd;
> 

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

Thanks,
Maxime
Xia, Chenbo June 28, 2020, 3:19 a.m. UTC | #2
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Matan Azrad
> Sent: Thursday, June 25, 2020 9:38 PM
> To: Maxime Coquelin <maxime.coquelin@redhat.com>
> Cc: dev@dpdk.org; Wang, Xiao W <xiao.w.wang@intel.com>
> Subject: [dpdk-dev] [PATCH v2 4/5] vhost: notify virtq file descriptor update
> 
> When virtq call or kick file descriptors are changed in the device configuration
> when the queue is ready, the application and the vDPA driver should be notified
> to be aligned to the new file descriptors.
> 
> Notify the state to be disabled before the file descriptor update and return it
> back to be enabled after the update.
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
>  lib/librte_vhost/vhost_user.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index
> f690fdb..f3966b6 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1624,6 +1624,12 @@
>  		"vring call idx:%d file:%d\n", file.index, file.fd);
> 
>  	vq = dev->virtqueue[file.index];
> +
> +	if (vq->ready) {
> +		vhost_user_notify_queue_state(dev, file.index, 0);
> +		vq->ready = 0;
> +	}
> +
>  	if (vq->callfd >= 0)
>  		close(vq->callfd);
> 
> @@ -1882,6 +1888,11 @@ static int vhost_user_set_vring_err(struct virtio_net
> **pdev __rte_unused,
>  				dev->vid, file.index, 1);
>  	}
> 
> +	if (vq->ready) {
> +		vhost_user_notify_queue_state(dev, file.index, 0);
> +		vq->ready = 0;
> +	}
> +
>  	if (vq->kickfd >= 0)
>  		close(vq->kickfd);
>  	vq->kickfd = file.fd;
> --
> 1.8.3.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
diff mbox series

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index f690fdb..f3966b6 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1624,6 +1624,12 @@ 
 		"vring call idx:%d file:%d\n", file.index, file.fd);
 
 	vq = dev->virtqueue[file.index];
+
+	if (vq->ready) {
+		vhost_user_notify_queue_state(dev, file.index, 0);
+		vq->ready = 0;
+	}
+
 	if (vq->callfd >= 0)
 		close(vq->callfd);
 
@@ -1882,6 +1888,11 @@  static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused,
 				dev->vid, file.index, 1);
 	}
 
+	if (vq->ready) {
+		vhost_user_notify_queue_state(dev, file.index, 0);
+		vq->ready = 0;
+	}
+
 	if (vq->kickfd >= 0)
 		close(vq->kickfd);
 	vq->kickfd = file.fd;