Commit f29d20a2 authored by Jin Yu's avatar Jin Yu Committed by Tomasz Zawadzki
Browse files

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: default avatarJin 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: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent cebc20d9
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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) {
+2 −1
Original line number Diff line number Diff line
@@ -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);
+4 −0
Original line number Diff line number Diff line
@@ -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);
+2 −1
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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);