Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame^] | 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 | */ |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 7 | #ifndef _UAPI_LINUX_VIRTIO_RING_H |
| 8 | #define _UAPI_LINUX_VIRTIO_RING_H |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 9 | #include <stdint.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 10 | #include <linux/types.h> |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 11 | #include <linux/virtio_types.h> |
| 12 | #define VRING_DESC_F_NEXT 1 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 13 | #define VRING_DESC_F_WRITE 2 |
| 14 | #define VRING_DESC_F_INDIRECT 4 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 15 | #define VRING_PACKED_DESC_F_AVAIL 7 |
| 16 | #define VRING_PACKED_DESC_F_USED 15 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 17 | #define VRING_USED_F_NO_NOTIFY 1 |
| 18 | #define VRING_AVAIL_F_NO_INTERRUPT 1 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 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 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 23 | #define VIRTIO_RING_F_INDIRECT_DESC 28 |
| 24 | #define VIRTIO_RING_F_EVENT_IDX 29 |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 25 | #define VRING_AVAIL_ALIGN_SIZE 2 |
| 26 | #define VRING_USED_ALIGN_SIZE 4 |
| 27 | #define VRING_DESC_ALIGN_SIZE 16 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 28 | struct vring_desc { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 29 | __virtio64 addr; |
| 30 | __virtio32 len; |
| 31 | __virtio16 flags; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 32 | __virtio16 next; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 33 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 34 | struct vring_avail { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 35 | __virtio16 flags; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 36 | __virtio16 idx; |
| 37 | __virtio16 ring[]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 38 | }; |
| 39 | struct vring_used_elem { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 40 | __virtio32 id; |
| 41 | __virtio32 len; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 42 | }; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 43 | 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] | 44 | struct vring_used { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 45 | __virtio16 flags; |
| 46 | __virtio16 idx; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 47 | vring_used_elem_t ring[]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 48 | }; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 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; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 52 | struct vring { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 53 | unsigned int num; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 54 | vring_desc_t * desc; |
| 55 | vring_avail_t * avail; |
| 56 | vring_used_t * used; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 57 | }; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 58 | #ifndef VIRTIO_RING_NO_LEGACY |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 59 | #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 60 | #define vring_avail_event(vr) (* (__virtio16 *) & (vr)->used->ring[(vr)->num]) |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 61 | #endif |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 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 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 72 | #endif |