• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is auto-generated. Modifications will be lost.
3  *
4  * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5  * for more information.
6  */
7 #ifndef _UAPI_LINUX_VIRTIO_RING_H
8 #define _UAPI_LINUX_VIRTIO_RING_H
9 #include <stdint.h>
10 #include <linux/types.h>
11 #include <linux/virtio_types.h>
12 #define VRING_DESC_F_NEXT 1
13 #define VRING_DESC_F_WRITE 2
14 #define VRING_DESC_F_INDIRECT 4
15 #define VRING_PACKED_DESC_F_AVAIL 7
16 #define VRING_PACKED_DESC_F_USED 15
17 #define VRING_USED_F_NO_NOTIFY 1
18 #define VRING_AVAIL_F_NO_INTERRUPT 1
19 #define VRING_PACKED_EVENT_FLAG_ENABLE 0x0
20 #define VRING_PACKED_EVENT_FLAG_DISABLE 0x1
21 #define VRING_PACKED_EVENT_FLAG_DESC 0x2
22 #define VRING_PACKED_EVENT_F_WRAP_CTR 15
23 #define VIRTIO_RING_F_INDIRECT_DESC 28
24 #define VIRTIO_RING_F_EVENT_IDX 29
25 #define VRING_AVAIL_ALIGN_SIZE 2
26 #define VRING_USED_ALIGN_SIZE 4
27 #define VRING_DESC_ALIGN_SIZE 16
28 struct vring_desc {
29   __virtio64 addr;
30   __virtio32 len;
31   __virtio16 flags;
32   __virtio16 next;
33 };
34 struct vring_avail {
35   __virtio16 flags;
36   __virtio16 idx;
37   __virtio16 ring[];
38 };
39 struct vring_used_elem {
40   __virtio32 id;
41   __virtio32 len;
42 };
43 typedef struct vring_used_elem __attribute__((aligned(VRING_USED_ALIGN_SIZE))) vring_used_elem_t;
44 struct vring_used {
45   __virtio16 flags;
46   __virtio16 idx;
47   vring_used_elem_t ring[];
48 };
49 typedef struct vring_desc __attribute__((aligned(VRING_DESC_ALIGN_SIZE))) vring_desc_t;
50 typedef struct vring_avail __attribute__((aligned(VRING_AVAIL_ALIGN_SIZE))) vring_avail_t;
51 typedef struct vring_used __attribute__((aligned(VRING_USED_ALIGN_SIZE))) vring_used_t;
52 struct vring {
53   unsigned int num;
54   vring_desc_t * desc;
55   vring_avail_t * avail;
56   vring_used_t * used;
57 };
58 #ifndef VIRTIO_RING_NO_LEGACY
59 #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
60 #define vring_avail_event(vr) (* (__virtio16 *) & (vr)->used->ring[(vr)->num])
61 #endif
62 struct vring_packed_desc_event {
63   __le16 off_wrap;
64   __le16 flags;
65 };
66 struct vring_packed_desc {
67   __le64 addr;
68   __le32 len;
69   __le16 id;
70   __le16 flags;
71 };
72 #endif
73