Commit | Line | Data |
---|---|---|
e31b8288 JA |
1 | #ifndef IO_URING_H |
2 | #define IO_URING_H | |
3 | ||
4 | /* | |
5 | * IO submission data structure | |
6 | */ | |
7 | struct io_uring_iocb { | |
8 | u8 opcode; | |
9 | u8 flags; | |
10 | u16 ioprio; | |
11 | s32 fd; | |
12 | u64 off; | |
13 | union { | |
14 | void *addr; | |
15 | u64 __pad; | |
16 | }; | |
17 | u32 len; | |
18 | union { | |
19 | __kernel_rwf_t rw_flags; | |
20 | u32 __resv; | |
21 | }; | |
22 | }; | |
23 | ||
24 | /* | |
25 | * io_uring_setup() flags | |
26 | */ | |
27 | #define IORING_SETUP_IOPOLL (1 << 0) /* io_context is polled */ | |
28 | #define IORING_SETUP_FIXEDBUFS (1 << 1) /* IO buffers are fixed */ | |
29 | #define IORING_SETUP_SQTHREAD (1 << 2) /* Use SQ thread */ | |
30 | #define IORING_SETUP_SQWQ (1 << 3) /* Use SQ workqueue */ | |
31 | #define IORING_SETUP_SQPOLL (1 << 4) /* SQ thread polls */ | |
32 | ||
33 | #define IORING_OP_READ 1 | |
34 | #define IORING_OP_WRITE 2 | |
35 | #define IORING_OP_FSYNC 3 | |
36 | #define IORING_OP_FDSYNC 4 | |
37 | #define IORING_OP_READ_FIXED 5 | |
38 | #define IORING_OP_WRITE_FIXED 6 | |
39 | ||
40 | /* | |
41 | * IO completion data structure | |
42 | */ | |
43 | struct io_uring_event { | |
44 | __u64 index; /* what iocb this event came from */ | |
45 | s32 res; /* result code for this event */ | |
46 | u32 flags; | |
47 | }; | |
48 | ||
49 | #define IOEV_FLAG_CACHEHIT (1 << 0) /* IO did not hit media */ | |
50 | ||
51 | /* | |
52 | * Magic offsets for the application to mmap the data it needs | |
53 | */ | |
54 | #define IORING_OFF_SQ_RING 0ULL | |
55 | #define IORING_OFF_CQ_RING 0x8000000ULL | |
56 | #define IORING_OFF_IOCB 0x10000000ULL | |
57 | ||
58 | /* | |
59 | * Filled with the offset for mmap(2) | |
60 | */ | |
61 | struct io_sqring_offsets { | |
62 | u32 head; | |
63 | u32 tail; | |
64 | u32 ring_mask; | |
65 | u32 ring_entries; | |
66 | u32 flags; | |
67 | u32 dropped; | |
68 | u32 array; | |
69 | u32 resv[3]; | |
70 | }; | |
71 | ||
72 | #define IORING_SQ_NEED_WAKEUP (1 << 0) /* needs io_uring_enter wakeup */ | |
73 | ||
74 | struct io_cqring_offsets { | |
75 | u32 head; | |
76 | u32 tail; | |
77 | u32 ring_mask; | |
78 | u32 ring_entries; | |
79 | u32 overflow; | |
80 | u32 events; | |
81 | u32 resv[4]; | |
82 | }; | |
83 | ||
84 | #define IORING_ENTER_GETEVENTS (1 << 0) | |
85 | ||
86 | /* | |
87 | * Passed in for io_uring_setup(2). Copied back with updated info on success | |
88 | */ | |
89 | struct io_uring_params { | |
90 | u32 sq_entries; | |
91 | u32 cq_entries; | |
92 | u32 flags; | |
93 | u16 sq_thread_cpu; | |
94 | u16 resv[9]; | |
95 | struct io_sqring_offsets sq_off; | |
96 | struct io_cqring_offsets cq_off; | |
97 | }; | |
98 | ||
99 | #endif |