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 | */ |
Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 7 | #ifndef _UAPI_VDUSE_H_ |
| 8 | #define _UAPI_VDUSE_H_ |
| 9 | #include <linux/types.h> |
| 10 | #define VDUSE_BASE 0x81 |
| 11 | #define VDUSE_API_VERSION 0 |
| 12 | #define VDUSE_GET_API_VERSION _IOR(VDUSE_BASE, 0x00, __u64) |
| 13 | #define VDUSE_SET_API_VERSION _IOW(VDUSE_BASE, 0x01, __u64) |
| 14 | struct vduse_dev_config { |
| 15 | #define VDUSE_NAME_MAX 256 |
| 16 | char name[VDUSE_NAME_MAX]; |
| 17 | __u32 vendor_id; |
| 18 | __u32 device_id; |
| 19 | __u64 features; |
| 20 | __u32 vq_num; |
| 21 | __u32 vq_align; |
| 22 | __u32 reserved[13]; |
| 23 | __u32 config_size; |
| 24 | __u8 config[]; |
| 25 | }; |
| 26 | #define VDUSE_CREATE_DEV _IOW(VDUSE_BASE, 0x02, struct vduse_dev_config) |
| 27 | #define VDUSE_DESTROY_DEV _IOW(VDUSE_BASE, 0x03, char[VDUSE_NAME_MAX]) |
| 28 | struct vduse_iotlb_entry { |
| 29 | __u64 offset; |
| 30 | __u64 start; |
| 31 | __u64 last; |
| 32 | #define VDUSE_ACCESS_RO 0x1 |
| 33 | #define VDUSE_ACCESS_WO 0x2 |
| 34 | #define VDUSE_ACCESS_RW 0x3 |
| 35 | __u8 perm; |
| 36 | }; |
| 37 | #define VDUSE_IOTLB_GET_FD _IOWR(VDUSE_BASE, 0x10, struct vduse_iotlb_entry) |
| 38 | #define VDUSE_DEV_GET_FEATURES _IOR(VDUSE_BASE, 0x11, __u64) |
| 39 | struct vduse_config_data { |
| 40 | __u32 offset; |
| 41 | __u32 length; |
| 42 | __u8 buffer[]; |
| 43 | }; |
| 44 | #define VDUSE_DEV_SET_CONFIG _IOW(VDUSE_BASE, 0x12, struct vduse_config_data) |
| 45 | #define VDUSE_DEV_INJECT_CONFIG_IRQ _IO(VDUSE_BASE, 0x13) |
| 46 | struct vduse_vq_config { |
| 47 | __u32 index; |
| 48 | __u16 max_size; |
| 49 | __u16 reserved[13]; |
| 50 | }; |
| 51 | #define VDUSE_VQ_SETUP _IOW(VDUSE_BASE, 0x14, struct vduse_vq_config) |
| 52 | struct vduse_vq_state_split { |
| 53 | __u16 avail_index; |
| 54 | }; |
| 55 | struct vduse_vq_state_packed { |
| 56 | __u16 last_avail_counter; |
| 57 | __u16 last_avail_idx; |
| 58 | __u16 last_used_counter; |
| 59 | __u16 last_used_idx; |
| 60 | }; |
| 61 | struct vduse_vq_info { |
| 62 | __u32 index; |
| 63 | __u32 num; |
| 64 | __u64 desc_addr; |
| 65 | __u64 driver_addr; |
| 66 | __u64 device_addr; |
| 67 | union { |
| 68 | struct vduse_vq_state_split split; |
| 69 | struct vduse_vq_state_packed packed; |
| 70 | }; |
| 71 | __u8 ready; |
| 72 | }; |
| 73 | #define VDUSE_VQ_GET_INFO _IOWR(VDUSE_BASE, 0x15, struct vduse_vq_info) |
| 74 | struct vduse_vq_eventfd { |
| 75 | __u32 index; |
| 76 | #define VDUSE_EVENTFD_DEASSIGN - 1 |
| 77 | int fd; |
| 78 | }; |
| 79 | #define VDUSE_VQ_SETUP_KICKFD _IOW(VDUSE_BASE, 0x16, struct vduse_vq_eventfd) |
| 80 | #define VDUSE_VQ_INJECT_IRQ _IOW(VDUSE_BASE, 0x17, __u32) |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 81 | struct vduse_iova_umem { |
| 82 | __u64 uaddr; |
| 83 | __u64 iova; |
| 84 | __u64 size; |
| 85 | __u64 reserved[3]; |
| 86 | }; |
| 87 | #define VDUSE_IOTLB_REG_UMEM _IOW(VDUSE_BASE, 0x18, struct vduse_iova_umem) |
| 88 | #define VDUSE_IOTLB_DEREG_UMEM _IOW(VDUSE_BASE, 0x19, struct vduse_iova_umem) |
| 89 | struct vduse_iova_info { |
| 90 | __u64 start; |
| 91 | __u64 last; |
| 92 | #define VDUSE_IOVA_CAP_UMEM (1 << 0) |
| 93 | __u64 capability; |
| 94 | __u64 reserved[3]; |
| 95 | }; |
| 96 | #define VDUSE_IOTLB_GET_INFO _IOWR(VDUSE_BASE, 0x1a, struct vduse_iova_info) |
Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 97 | enum vduse_req_type { |
| 98 | VDUSE_GET_VQ_STATE, |
| 99 | VDUSE_SET_STATUS, |
| 100 | VDUSE_UPDATE_IOTLB, |
| 101 | }; |
| 102 | struct vduse_vq_state { |
| 103 | __u32 index; |
| 104 | union { |
| 105 | struct vduse_vq_state_split split; |
| 106 | struct vduse_vq_state_packed packed; |
| 107 | }; |
| 108 | }; |
| 109 | struct vduse_dev_status { |
| 110 | __u8 status; |
| 111 | }; |
| 112 | struct vduse_iova_range { |
| 113 | __u64 start; |
| 114 | __u64 last; |
| 115 | }; |
| 116 | struct vduse_dev_request { |
| 117 | __u32 type; |
| 118 | __u32 request_id; |
| 119 | __u32 reserved[4]; |
| 120 | union { |
| 121 | struct vduse_vq_state vq_state; |
| 122 | struct vduse_dev_status s; |
| 123 | struct vduse_iova_range iova; |
| 124 | __u32 padding[32]; |
| 125 | }; |
| 126 | }; |
| 127 | struct vduse_dev_response { |
| 128 | __u32 request_id; |
| 129 | #define VDUSE_REQ_RESULT_OK 0x00 |
| 130 | #define VDUSE_REQ_RESULT_FAILED 0x01 |
| 131 | __u32 result; |
| 132 | __u32 reserved[4]; |
| 133 | union { |
| 134 | struct vduse_vq_state vq_state; |
| 135 | __u32 padding[32]; |
| 136 | }; |
| 137 | }; |
| 138 | #endif |