[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [PATCH 03/16] virtio: implement "v1.0" bit.
From: Rusty Russell <rusty@rustcorp.com.au>
This is a test to see what it looks like.
I store a bool in the device structure: our test_bit() uses volatile,
so the code doesn't get eliminated even if gcc sees both sides are the
same :(
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/virtio/virtio.c | 7 +++++++
include/linux/virtio.h | 8 ++++++++
include/uapi/linux/virtio_config.h | 3 +++
3 files changed, 18 insertions(+)
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index e342692..179412d 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -133,6 +133,13 @@ static int virtio_dev_probe(struct device *_d)
if (device_features & (1ULL << i))
dev->features |= (1ULL << i);
+ /* Version 1.0 compliant devices set the VIRTIO_F_VERSION_1 bit */
+ if (device_features & (1ULL << VIRTIO_F_VERSION_1)) {
+ dev->legacy = false;
+ dev->features |= (1ULL << VIRTIO_F_VERSION_1);
+ } else
+ dev->legacy = true;
+
dev->config->finalize_features(dev);
err = drv->probe(dev);
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 838a395..2c3cbd4 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -9,6 +9,7 @@
#include <linux/mod_devicetable.h>
#include <linux/gfp.h>
#include <linux/vringh.h>
+#include <uapi/linux/virtio_config.h>
/**
* virtqueue - a queue to register buffers for sending or receiving.
@@ -76,6 +77,7 @@ unsigned int virtqueue_get_vring_size(struct virtqueue *vq);
/**
* virtio_device - representation of a device using virtio
* @index: unique position on the virtio bus
+ * @legacy: set if this is a pre-v1.0 device.
* @dev: underlying device.
* @id: the device type identification (used to match it with a driver).
* @config: the configuration ops for this device.
@@ -86,6 +88,7 @@ unsigned int virtqueue_get_vring_size(struct virtqueue *vq);
*/
struct virtio_device {
int index;
+ bool legacy;
struct device dev;
struct virtio_device_id id;
const struct virtio_config_ops *config;
@@ -100,6 +103,11 @@ static inline struct virtio_device *dev_to_virtio(struct device *_dev)
return container_of(_dev, struct virtio_device, dev);
}
+static inline bool virtio_device_legacy(const struct virtio_device *dev)
+{
+ return dev->legacy;
+}
+
int register_virtio_device(struct virtio_device *dev);
void unregister_virtio_device(struct virtio_device *dev);
diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h
index 3ce768c..80e7381 100644
--- a/include/uapi/linux/virtio_config.h
+++ b/include/uapi/linux/virtio_config.h
@@ -54,4 +54,7 @@
/* Can the device handle any descriptor layout? */
#define VIRTIO_F_ANY_LAYOUT 27
+/* v1.0 compliant. */
+#define VIRTIO_F_VERSION_1 32
+
#endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */
--
1.8.1.2
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]