Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 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 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 21 | #include <stdint.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 22 | #include <linux/types.h> |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 23 | #include <linux/virtio_types.h> |
| 24 | #define VRING_DESC_F_NEXT 1 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 25 | #define VRING_DESC_F_WRITE 2 |
| 26 | #define VRING_DESC_F_INDIRECT 4 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 27 | #define VRING_PACKED_DESC_F_AVAIL 7 |
| 28 | #define VRING_PACKED_DESC_F_USED 15 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 29 | #define VRING_USED_F_NO_NOTIFY 1 |
| 30 | #define VRING_AVAIL_F_NO_INTERRUPT 1 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 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 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 35 | #define VIRTIO_RING_F_INDIRECT_DESC 28 |
| 36 | #define VIRTIO_RING_F_EVENT_IDX 29 |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 37 | #define VRING_AVAIL_ALIGN_SIZE 2 |
| 38 | #define VRING_USED_ALIGN_SIZE 4 |
| 39 | #define VRING_DESC_ALIGN_SIZE 16 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 40 | struct vring_desc { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 41 | __virtio64 addr; |
| 42 | __virtio32 len; |
| 43 | __virtio16 flags; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 44 | __virtio16 next; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 45 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 46 | struct vring_avail { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 47 | __virtio16 flags; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 48 | __virtio16 idx; |
| 49 | __virtio16 ring[]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 50 | }; |
| 51 | struct vring_used_elem { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 52 | __virtio32 id; |
| 53 | __virtio32 len; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 54 | }; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 55 | typedef struct vring_used_elem __attribute__((aligned(VRING_USED_ALIGN_SIZE))) vring_used_elem_t; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 56 | struct vring_used { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 57 | __virtio16 flags; |
| 58 | __virtio16 idx; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 59 | vring_used_elem_t ring[]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 60 | }; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 61 | typedef struct vring_desc __attribute__((aligned(VRING_DESC_ALIGN_SIZE))) vring_desc_t; |
| 62 | typedef struct vring_avail __attribute__((aligned(VRING_AVAIL_ALIGN_SIZE))) vring_avail_t; |
| 63 | typedef struct vring_used __attribute__((aligned(VRING_USED_ALIGN_SIZE))) vring_used_t; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 64 | struct vring { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 65 | unsigned int num; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 66 | vring_desc_t * desc; |
| 67 | vring_avail_t * avail; |
| 68 | vring_used_t * used; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 69 | }; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 70 | #ifndef VIRTIO_RING_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 71 | #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 72 | #define vring_avail_event(vr) (* (__virtio16 *) & (vr)->used->ring[(vr)->num]) |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 73 | #endif |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 74 | struct vring_packed_desc_event { |
| 75 | __le16 off_wrap; |
| 76 | __le16 flags; |
| 77 | }; |
| 78 | struct vring_packed_desc { |
| 79 | __le64 addr; |
| 80 | __le32 len; |
| 81 | __le16 id; |
| 82 | __le16 flags; |
| 83 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 84 | #endif |