1 /**************************************************************************** 2 **************************************************************************** 3 *** 4 *** This header was automatically generated from a Linux kernel header 5 *** of the same name, to make information necessary for userspace to 6 *** call into the kernel available to libc. It contains only constants, 7 *** structures, and macros generated from the original header, and thus, 8 *** contains no copyrightable information. 9 *** 10 *** To edit the content of this header, modify the corresponding 11 *** source file (e.g. under external/kernel-headers/original/) then 12 *** run bionic/libc/kernel/tools/update_all.py 13 *** 14 *** Any manual change here will be lost the next time this script will 15 *** be run. You've been warned! 16 *** 17 **************************************************************************** 18 ****************************************************************************/ 19 #ifndef _UAPI_LINUX_VIRTIO_RING_H 20 #define _UAPI_LINUX_VIRTIO_RING_H 21 #include <stdint.h> 22 #include <linux/types.h> 23 #include <linux/virtio_types.h> 24 #define VRING_DESC_F_NEXT 1 25 #define VRING_DESC_F_WRITE 2 26 #define VRING_DESC_F_INDIRECT 4 27 #define VRING_PACKED_DESC_F_AVAIL 7 28 #define VRING_PACKED_DESC_F_USED 15 29 #define VRING_USED_F_NO_NOTIFY 1 30 #define VRING_AVAIL_F_NO_INTERRUPT 1 31 #define VRING_PACKED_EVENT_FLAG_ENABLE 0x0 32 #define VRING_PACKED_EVENT_FLAG_DISABLE 0x1 33 #define VRING_PACKED_EVENT_FLAG_DESC 0x2 34 #define VRING_PACKED_EVENT_F_WRAP_CTR 15 35 #define VIRTIO_RING_F_INDIRECT_DESC 28 36 #define VIRTIO_RING_F_EVENT_IDX 29 37 struct vring_desc { 38 __virtio64 addr; 39 __virtio32 len; 40 __virtio16 flags; 41 __virtio16 next; 42 }; 43 struct vring_avail { 44 __virtio16 flags; 45 __virtio16 idx; 46 __virtio16 ring[]; 47 }; 48 struct vring_used_elem { 49 __virtio32 id; 50 __virtio32 len; 51 }; 52 struct vring_used { 53 __virtio16 flags; 54 __virtio16 idx; 55 struct vring_used_elem ring[]; 56 }; 57 struct vring { 58 unsigned int num; 59 struct vring_desc * desc; 60 struct vring_avail * avail; 61 struct vring_used * used; 62 }; 63 #define VRING_AVAIL_ALIGN_SIZE 2 64 #define VRING_USED_ALIGN_SIZE 4 65 #define VRING_DESC_ALIGN_SIZE 16 66 #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) 67 #define vring_avail_event(vr) (* (__virtio16 *) & (vr)->used->ring[(vr)->num]) 68 struct vring_packed_desc_event { 69 __le16 off_wrap; 70 __le16 flags; 71 }; 72 struct vring_packed_desc { 73 __le64 addr; 74 __le32 len; 75 __le16 id; 76 __le16 flags; 77 }; 78 #endif 79