diff mbox series

[v7,09/18] examples/vdpa: add vDPA blk support in example

Message ID 1651048206-282372-10-git-send-email-andy.pei@intel.com (mailing list archive)
State Superseded
Delegated to: Maxime Coquelin
Headers show
Series add virtio_blk device support to vdpa/ifc | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andy Pei April 27, 2022, 8:29 a.m. UTC
Add virtio blk device support to vDPA example.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 examples/vdpa/main.c             | 57 +++++++++++++++++++++++++++++++++++
 examples/vdpa/vdpa_blk_compact.h | 65 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+)
 create mode 100644 examples/vdpa/vdpa_blk_compact.h

Comments

Xia, Chenbo May 12, 2022, 1:34 p.m. UTC | #1
> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Wednesday, April 27, 2022 4:30 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; maxime.coquelin@redhat.com; Cao,
> Gang <gang.cao@intel.com>; Liu, Changpeng <changpeng.liu@intel.com>
> Subject: [PATCH v7 09/18] examples/vdpa: add vDPA blk support in example

Better be: examples/vdpa: add virtio blk support

> 
> Add virtio blk device support to vDPA example.
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>  examples/vdpa/main.c             | 57 +++++++++++++++++++++++++++++++++++
>  examples/vdpa/vdpa_blk_compact.h | 65
> ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 122 insertions(+)
>  create mode 100644 examples/vdpa/vdpa_blk_compact.h
> 
> diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
> index 5ab0765..2544141 100644
> --- a/examples/vdpa/main.c
> +++ b/examples/vdpa/main.c
> @@ -20,6 +20,7 @@
>  #include <cmdline_parse_string.h>
>  #include <cmdline_parse_num.h>
>  #include <cmdline.h>
> +#include "vdpa_blk_compact.h"
> 
>  #define MAX_PATH_LEN 128
>  #define MAX_VDPA_SAMPLE_PORTS 1024
> @@ -159,8 +160,54 @@ struct vdpa_port {
>  };
> 
>  static int
> +vdpa_blk_device_set_features_and_protocol(const char *path)
> +{
> +	uint64_t protocol_features = 0;
> +	int ret;
> +
> +	ret = rte_vhost_driver_set_features(path, VHOST_BLK_FEATURES);
> +	if (ret != 0) {
> +		RTE_LOG(ERR, VDPA,
> +			"rte_vhost_driver_set_features for %s failed.\n",
> +			path);
> +		goto out;
> +	}
> +
> +	ret = rte_vhost_driver_disable_features(path,
> +		VHOST_BLK_DISABLED_FEATURES);
> +	if (ret != 0) {
> +		RTE_LOG(ERR, VDPA,
> +			"rte_vhost_driver_disable_features for %s failed.\n",
> +			path);
> +		goto out;
> +	}
> +
> +	ret = rte_vhost_driver_get_protocol_features(path,
> &protocol_features);
> +	if (ret != 0) {
> +		RTE_LOG(ERR, VDPA,
> +			"rte_vhost_driver_get_protocol_features for %s
> failed.\n",
> +			path);
> +		goto out;
> +	}
> +
> +	protocol_features |= VHOST_BLK_PROTOCOL_FEATURES;
> +
> +	ret = rte_vhost_driver_set_protocol_features(path,
> protocol_features);
> +	if (ret != 0) {
> +		RTE_LOG(ERR, VDPA,
> +			"rte_vhost_driver_set_protocol_features for %s
> failed.\n",
> +			path);
> +		goto out;

This goto is not needed.

> +	}
> +
> +out:
> +	return ret;
> +}
> +
> +static int
>  start_vdpa(struct vdpa_port *vport)
>  {
> +	uint32_t device_type = 0;
>  	int ret;
>  	char *socket_path = vport->ifname;
> 
> @@ -192,6 +239,16 @@ struct vdpa_port {
>  			"attach vdpa device failed: %s\n",
>  			socket_path);
> 
> +	ret = rte_vhost_driver_get_vdpa_dev_type(socket_path, &device_type);
> +	if (ret == 0 && device_type == VDPA_DEVICE_TYPE_BLK) {
> +		RTE_LOG(NOTICE, VDPA, "is a blk device\n");

Should add info of socket path

> +		ret = vdpa_blk_device_set_features_and_protocol(socket_path);
> +		if (ret != 0)
> +			rte_exit(EXIT_FAILURE,
> +				"set vhost blk driver features and protocol
> features failed: %s\n",
> +				socket_path);
> +	}
> +
>  	if (rte_vhost_driver_start(socket_path) < 0)
>  		rte_exit(EXIT_FAILURE,
>  			"start vhost driver failed: %s\n",
> diff --git a/examples/vdpa/vdpa_blk_compact.h
> b/examples/vdpa/vdpa_blk_compact.h
> new file mode 100644
> index 0000000..136c3f6
> --- /dev/null
> +++ b/examples/vdpa/vdpa_blk_compact.h
> @@ -0,0 +1,65 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2022 Intel Corporation
> + */
> +
> +#ifndef _VDPA_BLK_COMPACT_H_
> +#define _VDPA_BLK_COMPACT_H_
> +
> +/**
> + * @file
> + *
> + * Device specific vhost lib
> + */
> +
> +#include <stdbool.h>
> +
> +#include <rte_pci.h>

above two headers are not used in this file?

> +#include <rte_vhost.h>
> +
> +/* Feature bits */
> +#define VIRTIO_BLK_F_SIZE_MAX     1    /* Indicates maximum segment size
> */
> +#define VIRTIO_BLK_F_SEG_MAX      2    /* Indicates maximum # of segments
> */
> +#define VIRTIO_BLK_F_GEOMETRY     4    /* Legacy geometry available  */
> +#define VIRTIO_BLK_F_BLK_SIZE     6    /* Block size of disk is available
> */
> +#define VIRTIO_BLK_F_TOPOLOGY     10   /* Topology information is
> available */
> +#define VIRTIO_BLK_F_MQ           12   /* support more than one vq */
> +
> +/* Legacy feature bits */
> +#ifndef VIRTIO_BLK_NO_LEGACY
> +#define VIRTIO_BLK_F_BARRIER      0    /* Does host support barriers? */
> +#define VIRTIO_BLK_F_SCSI         7    /* Supports scsi command passthru
> */
> +#define VIRTIO_BLK_F_CONFIG_WCE   11   /* Writeback mode available in
> config */
> +#endif /* !VIRTIO_BLK_NO_LEGACY */
> +
> +#ifndef VHOST_USER_F_PROTOCOL_FEATURES
> +#define VHOST_USER_F_PROTOCOL_FEATURES 30
> +#endif

It's already in rte_vhost.h, so no need to re-define.

Thanks,
Chenbo

> +
> +#define VHOST_BLK_FEATURES_BASE ((1ULL << VHOST_F_LOG_ALL) | \
> +	(1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
> +	(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
> +	(1ULL << VIRTIO_RING_F_EVENT_IDX) | \
> +	(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
> +	(1ULL << VIRTIO_F_VERSION_1))
> +
> +#define VHOST_BLK_DISABLED_FEATURES_BASE ((1ULL <<
> VIRTIO_F_NOTIFY_ON_EMPTY) | \
> +	(1ULL << VIRTIO_RING_F_EVENT_IDX))
> +
> +#define VHOST_BLK_FEATURES (VHOST_BLK_FEATURES_BASE | \
> +	(1ULL << VIRTIO_BLK_F_SIZE_MAX) | (1ULL << VIRTIO_BLK_F_SEG_MAX) | \
> +	(1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL << VIRTIO_BLK_F_BLK_SIZE) |
> \
> +	(1ULL << VIRTIO_BLK_F_TOPOLOGY) | (1ULL << VIRTIO_BLK_F_BARRIER)  |
> \
> +	(1ULL << VIRTIO_BLK_F_SCSI)     | (1ULL << VIRTIO_BLK_F_CONFIG_WCE)
> | \
> +	(1ULL << VIRTIO_BLK_F_MQ))
> +
> +/* Not supported features */
> +#define VHOST_BLK_DISABLED_FEATURES (VHOST_BLK_DISABLED_FEATURES_BASE | \
> +	(1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL << VIRTIO_BLK_F_BARRIER) | \
> +	(1ULL << VIRTIO_BLK_F_SCSI)  | (1ULL << VIRTIO_BLK_F_CONFIG_WCE))
> +
> +/* Vhost-blk support protocol features */
> +#define VHOST_BLK_PROTOCOL_FEATURES \
> +	((1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \
> +	(1ULL << VHOST_USER_PROTOCOL_F_CONFIG))
> +
> +#endif /* _VDPA_BLK_COMPACT_H_ */
> --
> 1.8.3.1
Andy Pei May 13, 2022, 8:16 a.m. UTC | #2
HI Chenbo,

Thanks for your reply.
My reply is inline.

> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Thursday, May 12, 2022 9:34 PM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Cao, Gang <gang.cao@intel.com>; Liu,
> Changpeng <changpeng.liu@intel.com>
> Subject: RE: [PATCH v7 09/18] examples/vdpa: add vDPA blk support in
> example
> 
> > -----Original Message-----
> > From: Pei, Andy <andy.pei@intel.com>
> > Sent: Wednesday, April 27, 2022 4:30 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <chenbo.xia@intel.com>; maxime.coquelin@redhat.com;
> > Cao, Gang <gang.cao@intel.com>; Liu, Changpeng
> > <changpeng.liu@intel.com>
> > Subject: [PATCH v7 09/18] examples/vdpa: add vDPA blk support in
> > example
> 
> Better be: examples/vdpa: add virtio blk support
> 
Sure.
> >
> > Add virtio blk device support to vDPA example.
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > ---
> >  examples/vdpa/main.c             | 57
> +++++++++++++++++++++++++++++++++++
> >  examples/vdpa/vdpa_blk_compact.h | 65
> > ++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 122 insertions(+)
> >  create mode 100644 examples/vdpa/vdpa_blk_compact.h
> >
> > diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c index
> > 5ab0765..2544141 100644
> > --- a/examples/vdpa/main.c
> > +++ b/examples/vdpa/main.c
> > @@ -20,6 +20,7 @@
> >  #include <cmdline_parse_string.h>
> >  #include <cmdline_parse_num.h>
> >  #include <cmdline.h>
> > +#include "vdpa_blk_compact.h"
> >
> >  #define MAX_PATH_LEN 128
> >  #define MAX_VDPA_SAMPLE_PORTS 1024
> > @@ -159,8 +160,54 @@ struct vdpa_port {  };
> >
> >  static int
> > +vdpa_blk_device_set_features_and_protocol(const char *path) {
> > +	uint64_t protocol_features = 0;
> > +	int ret;
> > +
> > +	ret = rte_vhost_driver_set_features(path, VHOST_BLK_FEATURES);
> > +	if (ret != 0) {
> > +		RTE_LOG(ERR, VDPA,
> > +			"rte_vhost_driver_set_features for %s failed.\n",
> > +			path);
> > +		goto out;
> > +	}
> > +
> > +	ret = rte_vhost_driver_disable_features(path,
> > +		VHOST_BLK_DISABLED_FEATURES);
> > +	if (ret != 0) {
> > +		RTE_LOG(ERR, VDPA,
> > +			"rte_vhost_driver_disable_features for %s failed.\n",
> > +			path);
> > +		goto out;
> > +	}
> > +
> > +	ret = rte_vhost_driver_get_protocol_features(path,
> > &protocol_features);
> > +	if (ret != 0) {
> > +		RTE_LOG(ERR, VDPA,
> > +			"rte_vhost_driver_get_protocol_features for %s
> > failed.\n",
> > +			path);
> > +		goto out;
> > +	}
> > +
> > +	protocol_features |= VHOST_BLK_PROTOCOL_FEATURES;
> > +
> > +	ret = rte_vhost_driver_set_protocol_features(path,
> > protocol_features);
> > +	if (ret != 0) {
> > +		RTE_LOG(ERR, VDPA,
> > +			"rte_vhost_driver_set_protocol_features for %s
> > failed.\n",
> > +			path);
> > +		goto out;
> 
> This goto is not needed.
> 
Yes, you are right. I will fix it.
> > +	}
> > +
> > +out:
> > +	return ret;
> > +}
> > +
> > +static int
> >  start_vdpa(struct vdpa_port *vport)
> >  {
> > +	uint32_t device_type = 0;
> >  	int ret;
> >  	char *socket_path = vport->ifname;
> >
> > @@ -192,6 +239,16 @@ struct vdpa_port {
> >  			"attach vdpa device failed: %s\n",
> >  			socket_path);
> >
> > +	ret = rte_vhost_driver_get_vdpa_dev_type(socket_path,
> &device_type);
> > +	if (ret == 0 && device_type == VDPA_DEVICE_TYPE_BLK) {
> > +		RTE_LOG(NOTICE, VDPA, "is a blk device\n");
> 
> Should add info of socket path
> 
Yes, you are right. I will fix it.
> > +		ret =
> vdpa_blk_device_set_features_and_protocol(socket_path);
> > +		if (ret != 0)
> > +			rte_exit(EXIT_FAILURE,
> > +				"set vhost blk driver features and protocol
> > features failed: %s\n",
> > +				socket_path);
> > +	}
> > +
> >  	if (rte_vhost_driver_start(socket_path) < 0)
> >  		rte_exit(EXIT_FAILURE,
> >  			"start vhost driver failed: %s\n", diff --git
> > a/examples/vdpa/vdpa_blk_compact.h
> > b/examples/vdpa/vdpa_blk_compact.h
> > new file mode 100644
> > index 0000000..136c3f6
> > --- /dev/null
> > +++ b/examples/vdpa/vdpa_blk_compact.h
> > @@ -0,0 +1,65 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(c) 2022 Intel Corporation  */
> > +
> > +#ifndef _VDPA_BLK_COMPACT_H_
> > +#define _VDPA_BLK_COMPACT_H_
> > +
> > +/**
> > + * @file
> > + *
> > + * Device specific vhost lib
> > + */
> > +
> > +#include <stdbool.h>
> > +
> > +#include <rte_pci.h>
> 
> above two headers are not used in this file?
> 
I will remove these two include.
> > +#include <rte_vhost.h>
> > +
> > +/* Feature bits */
> > +#define VIRTIO_BLK_F_SIZE_MAX     1    /* Indicates maximum segment
> size
> > */
> > +#define VIRTIO_BLK_F_SEG_MAX      2    /* Indicates maximum # of
> segments
> > */
> > +#define VIRTIO_BLK_F_GEOMETRY     4    /* Legacy geometry available  */
> > +#define VIRTIO_BLK_F_BLK_SIZE     6    /* Block size of disk is available
> > */
> > +#define VIRTIO_BLK_F_TOPOLOGY     10   /* Topology information is
> > available */
> > +#define VIRTIO_BLK_F_MQ           12   /* support more than one vq */
> > +
> > +/* Legacy feature bits */
> > +#ifndef VIRTIO_BLK_NO_LEGACY
> > +#define VIRTIO_BLK_F_BARRIER      0    /* Does host support barriers? */
> > +#define VIRTIO_BLK_F_SCSI         7    /* Supports scsi command passthru
> > */
> > +#define VIRTIO_BLK_F_CONFIG_WCE   11   /* Writeback mode available in
> > config */
> > +#endif /* !VIRTIO_BLK_NO_LEGACY */
> > +
> > +#ifndef VHOST_USER_F_PROTOCOL_FEATURES #define
> > +VHOST_USER_F_PROTOCOL_FEATURES 30 #endif
> 
> It's already in rte_vhost.h, so no need to re-define.
> 
> Thanks,
> Chenbo
> 
Yes, you are right. I will fix it.
> > +
> > +#define VHOST_BLK_FEATURES_BASE ((1ULL << VHOST_F_LOG_ALL) | \
> > +	(1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
> > +	(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
> > +	(1ULL << VIRTIO_RING_F_EVENT_IDX) | \
> > +	(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
> > +	(1ULL << VIRTIO_F_VERSION_1))
> > +
> > +#define VHOST_BLK_DISABLED_FEATURES_BASE ((1ULL <<
> > VIRTIO_F_NOTIFY_ON_EMPTY) | \
> > +	(1ULL << VIRTIO_RING_F_EVENT_IDX))
> > +
> > +#define VHOST_BLK_FEATURES (VHOST_BLK_FEATURES_BASE | \
> > +	(1ULL << VIRTIO_BLK_F_SIZE_MAX) | (1ULL <<
> VIRTIO_BLK_F_SEG_MAX) | \
> > +	(1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL <<
> VIRTIO_BLK_F_BLK_SIZE) |
> > \
> > +	(1ULL << VIRTIO_BLK_F_TOPOLOGY) | (1ULL <<
> VIRTIO_BLK_F_BARRIER)  |
> > \
> > +	(1ULL << VIRTIO_BLK_F_SCSI)     | (1ULL <<
> VIRTIO_BLK_F_CONFIG_WCE)
> > | \
> > +	(1ULL << VIRTIO_BLK_F_MQ))
> > +
> > +/* Not supported features */
> > +#define VHOST_BLK_DISABLED_FEATURES
> (VHOST_BLK_DISABLED_FEATURES_BASE | \
> > +	(1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL <<
> VIRTIO_BLK_F_BARRIER) | \
> > +	(1ULL << VIRTIO_BLK_F_SCSI)  | (1ULL <<
> VIRTIO_BLK_F_CONFIG_WCE))
> > +
> > +/* Vhost-blk support protocol features */ #define
> > +VHOST_BLK_PROTOCOL_FEATURES \
> > +	((1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \
> > +	(1ULL << VHOST_USER_PROTOCOL_F_CONFIG))
> > +
> > +#endif /* _VDPA_BLK_COMPACT_H_ */
> > --
> > 1.8.3.1
>
diff mbox series

Patch

diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
index 5ab0765..2544141 100644
--- a/examples/vdpa/main.c
+++ b/examples/vdpa/main.c
@@ -20,6 +20,7 @@ 
 #include <cmdline_parse_string.h>
 #include <cmdline_parse_num.h>
 #include <cmdline.h>
+#include "vdpa_blk_compact.h"
 
 #define MAX_PATH_LEN 128
 #define MAX_VDPA_SAMPLE_PORTS 1024
@@ -159,8 +160,54 @@  struct vdpa_port {
 };
 
 static int
+vdpa_blk_device_set_features_and_protocol(const char *path)
+{
+	uint64_t protocol_features = 0;
+	int ret;
+
+	ret = rte_vhost_driver_set_features(path, VHOST_BLK_FEATURES);
+	if (ret != 0) {
+		RTE_LOG(ERR, VDPA,
+			"rte_vhost_driver_set_features for %s failed.\n",
+			path);
+		goto out;
+	}
+
+	ret = rte_vhost_driver_disable_features(path,
+		VHOST_BLK_DISABLED_FEATURES);
+	if (ret != 0) {
+		RTE_LOG(ERR, VDPA,
+			"rte_vhost_driver_disable_features for %s failed.\n",
+			path);
+		goto out;
+	}
+
+	ret = rte_vhost_driver_get_protocol_features(path, &protocol_features);
+	if (ret != 0) {
+		RTE_LOG(ERR, VDPA,
+			"rte_vhost_driver_get_protocol_features for %s failed.\n",
+			path);
+		goto out;
+	}
+
+	protocol_features |= VHOST_BLK_PROTOCOL_FEATURES;
+
+	ret = rte_vhost_driver_set_protocol_features(path, protocol_features);
+	if (ret != 0) {
+		RTE_LOG(ERR, VDPA,
+			"rte_vhost_driver_set_protocol_features for %s failed.\n",
+			path);
+		goto out;
+	}
+
+out:
+	return ret;
+}
+
+static int
 start_vdpa(struct vdpa_port *vport)
 {
+	uint32_t device_type = 0;
 	int ret;
 	char *socket_path = vport->ifname;
 
@@ -192,6 +239,16 @@  struct vdpa_port {
 			"attach vdpa device failed: %s\n",
 			socket_path);
 
+	ret = rte_vhost_driver_get_vdpa_dev_type(socket_path, &device_type);
+	if (ret == 0 && device_type == VDPA_DEVICE_TYPE_BLK) {
+		RTE_LOG(NOTICE, VDPA, "is a blk device\n");
+		ret = vdpa_blk_device_set_features_and_protocol(socket_path);
+		if (ret != 0)
+			rte_exit(EXIT_FAILURE,
+				"set vhost blk driver features and protocol features failed: %s\n",
+				socket_path);
+	}
+
 	if (rte_vhost_driver_start(socket_path) < 0)
 		rte_exit(EXIT_FAILURE,
 			"start vhost driver failed: %s\n",
diff --git a/examples/vdpa/vdpa_blk_compact.h b/examples/vdpa/vdpa_blk_compact.h
new file mode 100644
index 0000000..136c3f6
--- /dev/null
+++ b/examples/vdpa/vdpa_blk_compact.h
@@ -0,0 +1,65 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#ifndef _VDPA_BLK_COMPACT_H_
+#define _VDPA_BLK_COMPACT_H_
+
+/**
+ * @file
+ *
+ * Device specific vhost lib
+ */
+
+#include <stdbool.h>
+
+#include <rte_pci.h>
+#include <rte_vhost.h>
+
+/* Feature bits */
+#define VIRTIO_BLK_F_SIZE_MAX     1    /* Indicates maximum segment size */
+#define VIRTIO_BLK_F_SEG_MAX      2    /* Indicates maximum # of segments */
+#define VIRTIO_BLK_F_GEOMETRY     4    /* Legacy geometry available  */
+#define VIRTIO_BLK_F_BLK_SIZE     6    /* Block size of disk is available */
+#define VIRTIO_BLK_F_TOPOLOGY     10   /* Topology information is available */
+#define VIRTIO_BLK_F_MQ           12   /* support more than one vq */
+
+/* Legacy feature bits */
+#ifndef VIRTIO_BLK_NO_LEGACY
+#define VIRTIO_BLK_F_BARRIER      0    /* Does host support barriers? */
+#define VIRTIO_BLK_F_SCSI         7    /* Supports scsi command passthru */
+#define VIRTIO_BLK_F_CONFIG_WCE   11   /* Writeback mode available in config */
+#endif /* !VIRTIO_BLK_NO_LEGACY */
+
+#ifndef VHOST_USER_F_PROTOCOL_FEATURES
+#define VHOST_USER_F_PROTOCOL_FEATURES 30
+#endif
+
+#define VHOST_BLK_FEATURES_BASE ((1ULL << VHOST_F_LOG_ALL) | \
+	(1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
+	(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
+	(1ULL << VIRTIO_RING_F_EVENT_IDX) | \
+	(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
+	(1ULL << VIRTIO_F_VERSION_1))
+
+#define VHOST_BLK_DISABLED_FEATURES_BASE ((1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
+	(1ULL << VIRTIO_RING_F_EVENT_IDX))
+
+#define VHOST_BLK_FEATURES (VHOST_BLK_FEATURES_BASE | \
+	(1ULL << VIRTIO_BLK_F_SIZE_MAX) | (1ULL << VIRTIO_BLK_F_SEG_MAX) | \
+	(1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL << VIRTIO_BLK_F_BLK_SIZE) | \
+	(1ULL << VIRTIO_BLK_F_TOPOLOGY) | (1ULL << VIRTIO_BLK_F_BARRIER)  | \
+	(1ULL << VIRTIO_BLK_F_SCSI)     | (1ULL << VIRTIO_BLK_F_CONFIG_WCE) | \
+	(1ULL << VIRTIO_BLK_F_MQ))
+
+/* Not supported features */
+#define VHOST_BLK_DISABLED_FEATURES (VHOST_BLK_DISABLED_FEATURES_BASE | \
+	(1ULL << VIRTIO_BLK_F_GEOMETRY) | (1ULL << VIRTIO_BLK_F_BARRIER) | \
+	(1ULL << VIRTIO_BLK_F_SCSI)  | (1ULL << VIRTIO_BLK_F_CONFIG_WCE))
+
+/* Vhost-blk support protocol features */
+#define VHOST_BLK_PROTOCOL_FEATURES \
+	((1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \
+	(1ULL << VHOST_USER_PROTOCOL_F_CONFIG))
+
+#endif /* _VDPA_BLK_COMPACT_H_ */