From f29d20a21e981919d5d1f302e8630afee48e00ab Mon Sep 17 00:00:00 2001 From: Jin Yu Date: Wed, 25 Dec 2019 18:01:18 +0800 Subject: [PATCH] vhost: add a protocol_features parameter in vdev Add the protocol_features in vdev. There are two features would be used in vhost device one is the virtio_features the other is the vhost-user protocol_features. For different vhost device, the supported features are different so we can separate them. Another reason is that I tested the VHOST_USER_PROTOCOL_F_ INFLIGHT_SHMFD in vhost-scsi with QEMU(version:4.0) and found that Qemu can not boot up. After investigating found that inflight flag is negotiated but the Qemu doesn't support this feature and in DPDK function it is handled as an error and disconnect with Qemu. It's a bug in DPDK and will fix it. Change-Id: I72e418cb1885bf7dcbd0285d9cec1ad6af0665de Signed-off-by: Jin Yu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478814 Community-CI: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Reviewed-by: GangCao Tested-by: SPDK CI Jenkins --- lib/vhost/rte_vhost_compat.c | 10 +++++----- lib/vhost/vhost.c | 3 ++- lib/vhost/vhost_blk.c | 4 ++++ lib/vhost/vhost_internal.h | 3 ++- test/unit/lib/vhost/vhost.c/vhost_ut.c | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/vhost/rte_vhost_compat.c b/lib/vhost/rte_vhost_compat.c index 607f1004c..0597300a2 100644 --- a/lib/vhost/rte_vhost_compat.c +++ b/lib/vhost/rte_vhost_compat.c @@ -329,11 +329,11 @@ vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession) int vhost_register_unix_socket(const char *path, const char *ctrl_name, - uint64_t virtio_features, uint64_t disabled_features) + uint64_t virtio_features, uint64_t disabled_features, uint64_t protocol_features) { struct stat file_stat; #ifndef SPDK_CONFIG_VHOST_INTERNAL_LIB - uint64_t protocol_features = 0; + uint64_t features = 0; #endif /* Register vhost driver to handle vhost messages. */ @@ -371,9 +371,9 @@ vhost_register_unix_socket(const char *path, const char *ctrl_name, } #ifndef SPDK_CONFIG_VHOST_INTERNAL_LIB - rte_vhost_driver_get_protocol_features(path, &protocol_features); - protocol_features |= (1ULL << VHOST_USER_PROTOCOL_F_CONFIG); - rte_vhost_driver_set_protocol_features(path, protocol_features); + rte_vhost_driver_get_protocol_features(path, &features); + features |= protocol_features; + rte_vhost_driver_set_protocol_features(path, features); #endif if (rte_vhost_driver_start(path) != 0) { diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 4420a6249..897d8e3ee 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -640,7 +640,8 @@ vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *ma vhost_dev_set_coalescing(vdev, SPDK_VHOST_COALESCING_DELAY_BASE_US, SPDK_VHOST_VQ_IOPS_COALESCING_THRESHOLD); - if (vhost_register_unix_socket(path, name, vdev->virtio_features, vdev->disabled_features)) { + if (vhost_register_unix_socket(path, name, vdev->virtio_features, vdev->disabled_features, + vdev->protocol_features)) { TAILQ_REMOVE(&g_vhost_devices, vdev, tailq); free(vdev->name); free(vdev->path); diff --git a/lib/vhost/vhost_blk.c b/lib/vhost/vhost_blk.c index ad6d1121f..2bd9198b5 100644 --- a/lib/vhost/vhost_blk.c +++ b/lib/vhost/vhost_blk.c @@ -58,6 +58,9 @@ (1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL << VIRTIO_BLK_F_CONFIG_WCE) | \ (1ULL << VIRTIO_BLK_F_BARRIER) | (1ULL << VIRTIO_BLK_F_SCSI)) +/* Vhost-blk support protocol features */ +#define SPDK_VHOST_BLK_PROTOCOL_FEATURES ((1ULL << VHOST_USER_PROTOCOL_F_CONFIG)) + struct spdk_vhost_blk_task { struct spdk_bdev_io *bdev_io; struct spdk_vhost_blk_session *bvsession; @@ -978,6 +981,7 @@ spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_ vdev = &bvdev->vdev; vdev->virtio_features = SPDK_VHOST_BLK_FEATURES_BASE; vdev->disabled_features = SPDK_VHOST_BLK_DISABLED_FEATURES; + vdev->protocol_features = SPDK_VHOST_BLK_PROTOCOL_FEATURES; if (spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_UNMAP)) { vdev->virtio_features |= (1ULL << VIRTIO_BLK_F_DISCARD); diff --git a/lib/vhost/vhost_internal.h b/lib/vhost/vhost_internal.h index 921459548..f8503701a 100644 --- a/lib/vhost/vhost_internal.h +++ b/lib/vhost/vhost_internal.h @@ -158,6 +158,7 @@ struct spdk_vhost_dev { uint64_t virtio_features; uint64_t disabled_features; + uint64_t protocol_features; const struct spdk_vhost_dev_backend *backend; @@ -392,7 +393,7 @@ void vhost_session_stop_done(struct spdk_vhost_session *vsession, int response); struct spdk_vhost_session *vhost_session_find_by_vid(int vid); void vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession); int vhost_register_unix_socket(const char *path, const char *ctrl_name, - uint64_t virtio_features, uint64_t disabled_features); + uint64_t virtio_features, uint64_t disabled_features, uint64_t protocol_features); int vhost_driver_unregister(const char *path); int vhost_get_mem_table(int vid, struct rte_vhost_memory **mem); int vhost_get_negotiated_features(int vid, uint64_t *negotiated_features); diff --git a/test/unit/lib/vhost/vhost.c/vhost_ut.c b/test/unit/lib/vhost/vhost.c/vhost_ut.c index 2059e768f..9c8e479ee 100644 --- a/test/unit/lib/vhost/vhost.c/vhost_ut.c +++ b/test/unit/lib/vhost/vhost.c/vhost_ut.c @@ -49,7 +49,7 @@ DEFINE_STUB(rte_vhost_get_vring_base, int, (int vid, uint16_t queue_id, DEFINE_STUB_V(vhost_session_install_rte_compat_hooks, (struct spdk_vhost_session *vsession)); DEFINE_STUB(vhost_register_unix_socket, int, (const char *path, const char *name, - uint64_t virtio_features, uint64_t disabled_features), 0); + uint64_t virtio_features, uint64_t disabled_features, uint64_t protocol_features), 0); DEFINE_STUB(vhost_driver_unregister, int, (const char *path), 0); DEFINE_STUB(spdk_mem_register, int, (void *vaddr, size_t len), 0); DEFINE_STUB(spdk_mem_unregister, int, (void *vaddr, size_t len), 0);