From 0b9e4c8ff7a553e48dd71081fa7e4cf6e8e08f2f Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Mon, 2 Jul 2018 12:54:11 +0200 Subject: [PATCH] virtio/user: negotiate VHOST_USER_PROTOCOL_F_MQ Required by the vhost-user spec. Change-Id: Id7143a0f6cc34463ad5f22d8db96ac5c51e04081 Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/417457 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Daniel Verkamp --- lib/virtio/virtio_user.c | 11 ++++++++++- lib/virtio/virtio_user/vhost.h | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/virtio/virtio_user.c b/lib/virtio/virtio_user.c index e7fc65a8a7..bdffde5db5 100644 --- a/lib/virtio/virtio_user.c +++ b/lib/virtio/virtio_user.c @@ -47,7 +47,7 @@ #include "spdk_internal/virtio.h" #define VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES \ - (0) + ((1ULL << VHOST_USER_PROTOCOL_F_MQ)) static int virtio_user_create_queue(struct virtio_dev *vdev, uint32_t queue_sel) @@ -145,6 +145,15 @@ virtio_user_start_device(struct virtio_dev *vdev) uint64_t host_max_queues; int ret; + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ)) == 0 && + vdev->max_queues > 1 + vdev->fixed_queues_num) { + SPDK_WARNLOG("%s: requested %"PRIu16" request queues, but the " + "host doesn't support VHOST_USER_PROTOCOL_F_MQ. " + "Only one request queue will be used.\n", + vdev->name, vdev->max_queues - vdev->fixed_queues_num); + vdev->max_queues = 1 + vdev->fixed_queues_num; + } + /* negotiate the number of I/O queues. */ ret = dev->ops->send_request(dev, VHOST_USER_GET_QUEUE_NUM, &host_max_queues); if (ret < 0) { diff --git a/lib/virtio/virtio_user/vhost.h b/lib/virtio/virtio_user/vhost.h index 69bedb177b..7a434064a8 100644 --- a/lib/virtio/virtio_user/vhost.h +++ b/lib/virtio/virtio_user/vhost.h @@ -43,6 +43,10 @@ #define VHOST_USER_MAX_CONFIG_SIZE 256 +#ifndef VHOST_USER_PROTOCOL_F_MQ +#define VHOST_USER_PROTOCOL_F_MQ 0 +#endif + enum vhost_user_request { VHOST_USER_NONE = 0, VHOST_USER_GET_FEATURES = 1,