From: Maxime Coquelin Date: Sun, 12 Mar 2017 16:34:00 +0000 (+0100) Subject: vhost: add new ready status flag X-Git-Tag: spdx-start~3913 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4c5d8459d2e2206161a78203f5fb737c67c52c42;p=dpdk.git vhost: add new ready status flag This patch adds a new status flag indicating the Virtio device is ready to operate. This is required to be able to call rte_vhost_mtu_get() in the .new_device() callback, as rte_vhost_mtu_get needs that the negotiation is done, but it is too early to rely on running status flag, which is set just after .new_device() returns. Signed-off-by: Maxime Coquelin Acked-by: Yuanhan Liu --- diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index 02a05f93db..daa9328144 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -46,6 +46,8 @@ /* Used to indicate that the device is running on a data core */ #define VIRTIO_DEV_RUNNING 1 +/* Used to indicate that the device is ready to operate */ +#define VIRTIO_DEV_READY 2 /* Backend value set by guest. */ #define VIRTIO_DEV_STOPPED -1 diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 640661b3e2..1806c0ff76 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -678,14 +678,18 @@ vhost_user_set_vring_kick(struct virtio_net *dev, struct VhostUserMsg *pmsg) close(vq->kickfd); vq->kickfd = file.fd; - if (virtio_is_ready(dev) && !(dev->flags & VIRTIO_DEV_RUNNING)) { - if (dev->dequeue_zero_copy) { - RTE_LOG(INFO, VHOST_CONFIG, - "dequeue zero copy is enabled\n"); - } + if (virtio_is_ready(dev)) { + dev->flags |= VIRTIO_DEV_READY; + + if (!(dev->flags & VIRTIO_DEV_RUNNING)) { + if (dev->dequeue_zero_copy) { + RTE_LOG(INFO, VHOST_CONFIG, + "dequeue zero copy is enabled\n"); + } - if (notify_ops->new_device(dev->vid) == 0) - dev->flags |= VIRTIO_DEV_RUNNING; + if (notify_ops->new_device(dev->vid) == 0) + dev->flags |= VIRTIO_DEV_RUNNING; + } } } @@ -720,6 +724,8 @@ vhost_user_get_vring_base(struct virtio_net *dev, notify_ops->destroy_device(dev->vid); } + dev->flags &= ~VIRTIO_DEV_READY; + /* Here we are safe to get the last used index */ state->num = vq->last_used_idx;