polyphony 0.83 → 0.84

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,343 +0,0 @@
1
- /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */
2
- /*
3
- * Header file for the io_uring interface.
4
- *
5
- * Copyright (C) 2019 Jens Axboe
6
- * Copyright (C) 2019 Christoph Hellwig
7
- */
8
- #ifndef LINUX_IO_URING_H
9
- #define LINUX_IO_URING_H
10
-
11
- #include <linux/fs.h>
12
- #include <linux/types.h>
13
-
14
- #ifdef __cplusplus
15
- extern "C" {
16
- #endif
17
-
18
- /*
19
- * IO submission data structure (Submission Queue Entry)
20
- */
21
- struct io_uring_sqe {
22
- __u8 opcode; /* type of operation for this sqe */
23
- __u8 flags; /* IOSQE_ flags */
24
- __u16 ioprio; /* ioprio for the request */
25
- __s32 fd; /* file descriptor to do IO on */
26
- union {
27
- __u64 off; /* offset into file */
28
- __u64 addr2;
29
- };
30
- union {
31
- __u64 addr; /* pointer to buffer or iovecs */
32
- __u64 splice_off_in;
33
- };
34
- __u32 len; /* buffer size or number of iovecs */
35
- union {
36
- __kernel_rwf_t rw_flags;
37
- __u32 fsync_flags;
38
- __u16 poll_events; /* compatibility */
39
- __u32 poll32_events; /* word-reversed for BE */
40
- __u32 sync_range_flags;
41
- __u32 msg_flags;
42
- __u32 timeout_flags;
43
- __u32 accept_flags;
44
- __u32 cancel_flags;
45
- __u32 open_flags;
46
- __u32 statx_flags;
47
- __u32 fadvise_advice;
48
- __u32 splice_flags;
49
- };
50
- __u64 user_data; /* data to be passed back at completion time */
51
- union {
52
- struct {
53
- /* pack this to avoid bogus arm OABI complaints */
54
- union {
55
- /* index into fixed buffers, if used */
56
- __u16 buf_index;
57
- /* for grouped buffer selection */
58
- __u16 buf_group;
59
- } __attribute__((packed));
60
- /* personality to use, if used */
61
- __u16 personality;
62
- __s32 splice_fd_in;
63
- };
64
- __u64 __pad2[3];
65
- };
66
- };
67
-
68
- enum {
69
- IOSQE_FIXED_FILE_BIT,
70
- IOSQE_IO_DRAIN_BIT,
71
- IOSQE_IO_LINK_BIT,
72
- IOSQE_IO_HARDLINK_BIT,
73
- IOSQE_ASYNC_BIT,
74
- IOSQE_BUFFER_SELECT_BIT,
75
- };
76
-
77
- /*
78
- * sqe->flags
79
- */
80
- /* use fixed fileset */
81
- #define IOSQE_FIXED_FILE (1U << IOSQE_FIXED_FILE_BIT)
82
- /* issue after inflight IO */
83
- #define IOSQE_IO_DRAIN (1U << IOSQE_IO_DRAIN_BIT)
84
- /* links next sqe */
85
- #define IOSQE_IO_LINK (1U << IOSQE_IO_LINK_BIT)
86
- /* like LINK, but stronger */
87
- #define IOSQE_IO_HARDLINK (1U << IOSQE_IO_HARDLINK_BIT)
88
- /* always go async */
89
- #define IOSQE_ASYNC (1U << IOSQE_ASYNC_BIT)
90
- /* select buffer from sqe->buf_group */
91
- #define IOSQE_BUFFER_SELECT (1U << IOSQE_BUFFER_SELECT_BIT)
92
-
93
- /*
94
- * io_uring_setup() flags
95
- */
96
- #define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */
97
- #define IORING_SETUP_SQPOLL (1U << 1) /* SQ poll thread */
98
- #define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */
99
- #define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */
100
- #define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */
101
- #define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */
102
- #define IORING_SETUP_R_DISABLED (1U << 6) /* start with ring disabled */
103
-
104
- enum {
105
- IORING_OP_NOP,
106
- IORING_OP_READV,
107
- IORING_OP_WRITEV,
108
- IORING_OP_FSYNC,
109
- IORING_OP_READ_FIXED,
110
- IORING_OP_WRITE_FIXED,
111
- IORING_OP_POLL_ADD,
112
- IORING_OP_POLL_REMOVE,
113
- IORING_OP_SYNC_FILE_RANGE,
114
- IORING_OP_SENDMSG,
115
- IORING_OP_RECVMSG,
116
- IORING_OP_TIMEOUT,
117
- IORING_OP_TIMEOUT_REMOVE,
118
- IORING_OP_ACCEPT,
119
- IORING_OP_ASYNC_CANCEL,
120
- IORING_OP_LINK_TIMEOUT,
121
- IORING_OP_CONNECT,
122
- IORING_OP_FALLOCATE,
123
- IORING_OP_OPENAT,
124
- IORING_OP_CLOSE,
125
- IORING_OP_FILES_UPDATE,
126
- IORING_OP_STATX,
127
- IORING_OP_READ,
128
- IORING_OP_WRITE,
129
- IORING_OP_FADVISE,
130
- IORING_OP_MADVISE,
131
- IORING_OP_SEND,
132
- IORING_OP_RECV,
133
- IORING_OP_OPENAT2,
134
- IORING_OP_EPOLL_CTL,
135
- IORING_OP_SPLICE,
136
- IORING_OP_PROVIDE_BUFFERS,
137
- IORING_OP_REMOVE_BUFFERS,
138
- IORING_OP_TEE,
139
- IORING_OP_SHUTDOWN,
140
-
141
- /* this goes last, obviously */
142
- IORING_OP_LAST,
143
- };
144
-
145
- /*
146
- * sqe->fsync_flags
147
- */
148
- #define IORING_FSYNC_DATASYNC (1U << 0)
149
-
150
- /*
151
- * sqe->timeout_flags
152
- */
153
- #define IORING_TIMEOUT_ABS (1U << 0)
154
-
155
- /*
156
- * sqe->splice_flags
157
- * extends splice(2) flags
158
- */
159
- #define SPLICE_F_FD_IN_FIXED (1U << 31) /* the last bit of __u32 */
160
-
161
- /*
162
- * IO completion data structure (Completion Queue Entry)
163
- */
164
- struct io_uring_cqe {
165
- __u64 user_data; /* sqe->data submission passed back */
166
- __s32 res; /* result code for this event */
167
- __u32 flags;
168
- };
169
-
170
- /*
171
- * cqe->flags
172
- *
173
- * IORING_CQE_F_BUFFER If set, the upper 16 bits are the buffer ID
174
- */
175
- #define IORING_CQE_F_BUFFER (1U << 0)
176
-
177
- enum {
178
- IORING_CQE_BUFFER_SHIFT = 16,
179
- };
180
-
181
- /*
182
- * Magic offsets for the application to mmap the data it needs
183
- */
184
- #define IORING_OFF_SQ_RING 0ULL
185
- #define IORING_OFF_CQ_RING 0x8000000ULL
186
- #define IORING_OFF_SQES 0x10000000ULL
187
-
188
- /*
189
- * Filled with the offset for mmap(2)
190
- */
191
- struct io_sqring_offsets {
192
- __u32 head;
193
- __u32 tail;
194
- __u32 ring_mask;
195
- __u32 ring_entries;
196
- __u32 flags;
197
- __u32 dropped;
198
- __u32 array;
199
- __u32 resv1;
200
- __u64 resv2;
201
- };
202
-
203
- /*
204
- * sq_ring->flags
205
- */
206
- #define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */
207
- #define IORING_SQ_CQ_OVERFLOW (1U << 1) /* CQ ring is overflown */
208
-
209
- struct io_cqring_offsets {
210
- __u32 head;
211
- __u32 tail;
212
- __u32 ring_mask;
213
- __u32 ring_entries;
214
- __u32 overflow;
215
- __u32 cqes;
216
- __u32 flags;
217
- __u32 resv1;
218
- __u64 resv2;
219
- };
220
-
221
- /*
222
- * cq_ring->flags
223
- */
224
-
225
- /* disable eventfd notifications */
226
- #define IORING_CQ_EVENTFD_DISABLED (1U << 0)
227
-
228
- /*
229
- * io_uring_enter(2) flags
230
- */
231
- #define IORING_ENTER_GETEVENTS (1U << 0)
232
- #define IORING_ENTER_SQ_WAKEUP (1U << 1)
233
- #define IORING_ENTER_SQ_WAIT (1U << 2)
234
-
235
- /*
236
- * Passed in for io_uring_setup(2). Copied back with updated info on success
237
- */
238
- struct io_uring_params {
239
- __u32 sq_entries;
240
- __u32 cq_entries;
241
- __u32 flags;
242
- __u32 sq_thread_cpu;
243
- __u32 sq_thread_idle;
244
- __u32 features;
245
- __u32 wq_fd;
246
- __u32 resv[3];
247
- struct io_sqring_offsets sq_off;
248
- struct io_cqring_offsets cq_off;
249
- };
250
-
251
- /*
252
- * io_uring_params->features flags
253
- */
254
- #define IORING_FEAT_SINGLE_MMAP (1U << 0)
255
- #define IORING_FEAT_NODROP (1U << 1)
256
- #define IORING_FEAT_SUBMIT_STABLE (1U << 2)
257
- #define IORING_FEAT_RW_CUR_POS (1U << 3)
258
- #define IORING_FEAT_CUR_PERSONALITY (1U << 4)
259
- #define IORING_FEAT_FAST_POLL (1U << 5)
260
- #define IORING_FEAT_POLL_32BITS (1U << 6)
261
- #define IORING_FEAT_SQPOLL_NONFIXED (1U << 7)
262
-
263
- /*
264
- * io_uring_register(2) opcodes and arguments
265
- */
266
- enum {
267
- IORING_REGISTER_BUFFERS = 0,
268
- IORING_UNREGISTER_BUFFERS = 1,
269
- IORING_REGISTER_FILES = 2,
270
- IORING_UNREGISTER_FILES = 3,
271
- IORING_REGISTER_EVENTFD = 4,
272
- IORING_UNREGISTER_EVENTFD = 5,
273
- IORING_REGISTER_FILES_UPDATE = 6,
274
- IORING_REGISTER_EVENTFD_ASYNC = 7,
275
- IORING_REGISTER_PROBE = 8,
276
- IORING_REGISTER_PERSONALITY = 9,
277
- IORING_UNREGISTER_PERSONALITY = 10,
278
- IORING_REGISTER_RESTRICTIONS = 11,
279
- IORING_REGISTER_ENABLE_RINGS = 12,
280
-
281
- /* this goes last */
282
- IORING_REGISTER_LAST
283
- };
284
-
285
- struct io_uring_files_update {
286
- __u32 offset;
287
- __u32 resv;
288
- __aligned_u64 /* __s32 * */ fds;
289
- };
290
-
291
- #define IO_URING_OP_SUPPORTED (1U << 0)
292
-
293
- struct io_uring_probe_op {
294
- __u8 op;
295
- __u8 resv;
296
- __u16 flags; /* IO_URING_OP_* flags */
297
- __u32 resv2;
298
- };
299
-
300
- struct io_uring_probe {
301
- __u8 last_op; /* last opcode supported */
302
- __u8 ops_len; /* length of ops[] array below */
303
- __u16 resv;
304
- __u32 resv2[3];
305
- struct io_uring_probe_op ops[0];
306
- };
307
-
308
- struct io_uring_restriction {
309
- __u16 opcode;
310
- union {
311
- __u8 register_op; /* IORING_RESTRICTION_REGISTER_OP */
312
- __u8 sqe_op; /* IORING_RESTRICTION_SQE_OP */
313
- __u8 sqe_flags; /* IORING_RESTRICTION_SQE_FLAGS_* */
314
- };
315
- __u8 resv;
316
- __u32 resv2[3];
317
- };
318
-
319
- /*
320
- * io_uring_restriction->opcode values
321
- */
322
- enum {
323
- /* Allow an io_uring_register(2) opcode */
324
- IORING_RESTRICTION_REGISTER_OP = 0,
325
-
326
- /* Allow an sqe opcode */
327
- IORING_RESTRICTION_SQE_OP = 1,
328
-
329
- /* Allow sqe flags */
330
- IORING_RESTRICTION_SQE_FLAGS_ALLOWED = 2,
331
-
332
- /* Require sqe flags (these flags must be set on each submission) */
333
- IORING_RESTRICTION_SQE_FLAGS_REQUIRED = 3,
334
-
335
- IORING_RESTRICTION_LAST
336
- };
337
-
338
-
339
- #ifdef __cplusplus
340
- }
341
- #endif
342
-
343
- #endif