aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/virtio_ring.h
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2011-05-19 19:10:17 -0400
committerRusty Russell <rusty@rustcorp.com.au>2011-05-29 21:44:14 -0400
commit770b31a85e000b0194974922f238a30ade4246b6 (patch)
treeeed81e23f3116858b49af76bcc5831c38662de96 /include/linux/virtio_ring.h
parenta1b383870a28cfbd1657d4922c0fafc634a62ebd (diff)
virtio: event index interface
Define a new feature bit for the guest and host to utilize an event index (like Xen) instead if a flag bit to enable/disable interrupts and kicks. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/linux/virtio_ring.h')
-rw-r--r--include/linux/virtio_ring.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index a813e5d460e..c4eef73deb3 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -52,6 +52,12 @@
52/* We support indirect buffer descriptors */ 52/* We support indirect buffer descriptors */
53#define VIRTIO_RING_F_INDIRECT_DESC 28 53#define VIRTIO_RING_F_INDIRECT_DESC 28
54 54
55/* The Guest publishes the used index for which it expects an interrupt
56 * at the end of the avail ring. Host should ignore the avail->flags field. */
57/* The Host publishes the avail index for which it expects a kick
58 * at the end of the used ring. Guest should ignore the used->flags field. */
59#define VIRTIO_RING_F_EVENT_IDX 29
60
55/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ 61/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
56struct vring_desc { 62struct vring_desc {
57 /* Address (guest-physical). */ 63 /* Address (guest-physical). */
@@ -106,6 +112,7 @@ struct vring {
106 * __u16 avail_flags; 112 * __u16 avail_flags;
107 * __u16 avail_idx; 113 * __u16 avail_idx;
108 * __u16 available[num]; 114 * __u16 available[num];
115 * __u16 used_event_idx;
109 * 116 *
110 * // Padding to the next align boundary. 117 * // Padding to the next align boundary.
111 * char pad[]; 118 * char pad[];
@@ -114,8 +121,14 @@ struct vring {
114 * __u16 used_flags; 121 * __u16 used_flags;
115 * __u16 used_idx; 122 * __u16 used_idx;
116 * struct vring_used_elem used[num]; 123 * struct vring_used_elem used[num];
124 * __u16 avail_event_idx;
117 * }; 125 * };
118 */ 126 */
127/* We publish the used event index at the end of the available ring, and vice
128 * versa. They are at the end for backwards compatibility. */
129#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
130#define vring_avail_event(vr) (*(__u16 *)&(vr)->used->ring[(vr)->num])
131
119static inline void vring_init(struct vring *vr, unsigned int num, void *p, 132static inline void vring_init(struct vring *vr, unsigned int num, void *p,
120 unsigned long align) 133 unsigned long align)
121{ 134{
@@ -130,7 +143,7 @@ static inline unsigned vring_size(unsigned int num, unsigned long align)
130{ 143{
131 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) 144 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
132 + align - 1) & ~(align - 1)) 145 + align - 1) & ~(align - 1))
133 + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num; 146 + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
134} 147}
135 148
136#ifdef __KERNEL__ 149#ifdef __KERNEL__