diff options
Diffstat (limited to 'include/linux/virtio_ring.h')
-rw-r--r-- | include/linux/virtio_ring.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index a813e5d460eb..c4eef73deb3f 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". */ |
56 | struct vring_desc { | 62 | struct 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 | |||
119 | static inline void vring_init(struct vring *vr, unsigned int num, void *p, | 132 | static 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__ |