diff options
Diffstat (limited to 'include/linux/virtio.h')
| -rw-r--r-- | include/linux/virtio.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 533b1157f22e..cf8adb1f5b2c 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h | |||
| @@ -16,12 +16,20 @@ | |||
| 16 | * @name: the name of this virtqueue (mainly for debugging) | 16 | * @name: the name of this virtqueue (mainly for debugging) |
| 17 | * @vdev: the virtio device this queue was created for. | 17 | * @vdev: the virtio device this queue was created for. |
| 18 | * @priv: a pointer for the virtqueue implementation to use. | 18 | * @priv: a pointer for the virtqueue implementation to use. |
| 19 | * @index: the zero-based ordinal number for this queue. | ||
| 20 | * @num_free: number of elements we expect to be able to fit. | ||
| 21 | * | ||
| 22 | * A note on @num_free: with indirect buffers, each buffer needs one | ||
| 23 | * element in the queue, otherwise a buffer will need one element per | ||
| 24 | * sg element. | ||
| 19 | */ | 25 | */ |
| 20 | struct virtqueue { | 26 | struct virtqueue { |
| 21 | struct list_head list; | 27 | struct list_head list; |
| 22 | void (*callback)(struct virtqueue *vq); | 28 | void (*callback)(struct virtqueue *vq); |
| 23 | const char *name; | 29 | const char *name; |
| 24 | struct virtio_device *vdev; | 30 | struct virtio_device *vdev; |
| 31 | unsigned int index; | ||
| 32 | unsigned int num_free; | ||
| 25 | void *priv; | 33 | void *priv; |
| 26 | }; | 34 | }; |
| 27 | 35 | ||
| @@ -50,7 +58,11 @@ void *virtqueue_detach_unused_buf(struct virtqueue *vq); | |||
| 50 | 58 | ||
| 51 | unsigned int virtqueue_get_vring_size(struct virtqueue *vq); | 59 | unsigned int virtqueue_get_vring_size(struct virtqueue *vq); |
| 52 | 60 | ||
| 53 | int virtqueue_get_queue_index(struct virtqueue *vq); | 61 | /* FIXME: Obsolete accessor, but required for virtio_net merge. */ |
| 62 | static inline unsigned int virtqueue_get_queue_index(struct virtqueue *vq) | ||
| 63 | { | ||
| 64 | return vq->index; | ||
| 65 | } | ||
| 54 | 66 | ||
| 55 | /** | 67 | /** |
| 56 | * virtio_device - representation of a device using virtio | 68 | * virtio_device - representation of a device using virtio |
| @@ -73,7 +85,11 @@ struct virtio_device { | |||
| 73 | void *priv; | 85 | void *priv; |
| 74 | }; | 86 | }; |
| 75 | 87 | ||
| 76 | #define dev_to_virtio(dev) container_of(dev, struct virtio_device, dev) | 88 | static inline struct virtio_device *dev_to_virtio(struct device *_dev) |
| 89 | { | ||
| 90 | return container_of(_dev, struct virtio_device, dev); | ||
| 91 | } | ||
| 92 | |||
| 77 | int register_virtio_device(struct virtio_device *dev); | 93 | int register_virtio_device(struct virtio_device *dev); |
| 78 | void unregister_virtio_device(struct virtio_device *dev); | 94 | void unregister_virtio_device(struct virtio_device *dev); |
| 79 | 95 | ||
| @@ -103,6 +119,11 @@ struct virtio_driver { | |||
| 103 | #endif | 119 | #endif |
| 104 | }; | 120 | }; |
| 105 | 121 | ||
| 122 | static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv) | ||
| 123 | { | ||
| 124 | return container_of(drv, struct virtio_driver, driver); | ||
| 125 | } | ||
| 126 | |||
| 106 | int register_virtio_driver(struct virtio_driver *drv); | 127 | int register_virtio_driver(struct virtio_driver *drv); |
| 107 | void unregister_virtio_driver(struct virtio_driver *drv); | 128 | void unregister_virtio_driver(struct virtio_driver *drv); |
| 108 | #endif /* _LINUX_VIRTIO_H */ | 129 | #endif /* _LINUX_VIRTIO_H */ |
