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 <jin.yu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478814
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jin Yu 2019-12-25 18:01:18 +08:00 committed by Tomasz Zawadzki
parent cebc20d9be
commit f29d20a21e
5 changed files with 14 additions and 8 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);