iou 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (297) hide show
  1. checksums.yaml +7 -0
  2. data/.github/dependabot.yml +12 -0
  3. data/.gitignore +59 -0
  4. data/.gitmodules +3 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE +21 -0
  7. data/README.md +106 -0
  8. data/Rakefile +39 -0
  9. data/TODO.md +4 -0
  10. data/examples/echo_server.rb +52 -0
  11. data/examples/event_loop.rb +69 -0
  12. data/examples/http_server.rb +56 -0
  13. data/examples/http_server_multishot.rb +59 -0
  14. data/ext/iou/extconf.rb +71 -0
  15. data/ext/iou/iou.c +729 -0
  16. data/ext/iou/iou.h +66 -0
  17. data/ext/iou/iou_ext.c +9 -0
  18. data/ext/iou/op_spec_data.c +61 -0
  19. data/iou.gemspec +27 -0
  20. data/lib/iou/version.rb +5 -0
  21. data/lib/iou.rb +3 -0
  22. data/test/helper.rb +59 -0
  23. data/test/test_iou.rb +794 -0
  24. data/vendor/liburing/.github/actions/codespell/stopwords +7 -0
  25. data/vendor/liburing/.github/pull_request_template.md +86 -0
  26. data/vendor/liburing/.github/workflows/build.yml +137 -0
  27. data/vendor/liburing/.github/workflows/codespell.yml +25 -0
  28. data/vendor/liburing/.github/workflows/shellcheck.yml +20 -0
  29. data/vendor/liburing/.gitignore +41 -0
  30. data/vendor/liburing/CHANGELOG +111 -0
  31. data/vendor/liburing/CITATION.cff +11 -0
  32. data/vendor/liburing/COPYING +502 -0
  33. data/vendor/liburing/COPYING.GPL +339 -0
  34. data/vendor/liburing/LICENSE +20 -0
  35. data/vendor/liburing/Makefile +96 -0
  36. data/vendor/liburing/Makefile.common +7 -0
  37. data/vendor/liburing/Makefile.quiet +11 -0
  38. data/vendor/liburing/README +106 -0
  39. data/vendor/liburing/SECURITY.md +6 -0
  40. data/vendor/liburing/configure +624 -0
  41. data/vendor/liburing/debian/README.Debian +7 -0
  42. data/vendor/liburing/debian/changelog +38 -0
  43. data/vendor/liburing/debian/control +39 -0
  44. data/vendor/liburing/debian/copyright +49 -0
  45. data/vendor/liburing/debian/liburing-dev.install +4 -0
  46. data/vendor/liburing/debian/liburing-dev.manpages +5 -0
  47. data/vendor/liburing/debian/liburing2.install +1 -0
  48. data/vendor/liburing/debian/liburing2.symbols +56 -0
  49. data/vendor/liburing/debian/patches/series +1 -0
  50. data/vendor/liburing/debian/rules +29 -0
  51. data/vendor/liburing/debian/source/format +1 -0
  52. data/vendor/liburing/debian/source/local-options +2 -0
  53. data/vendor/liburing/debian/source/options +1 -0
  54. data/vendor/liburing/debian/watch +3 -0
  55. data/vendor/liburing/examples/Makefile +53 -0
  56. data/vendor/liburing/examples/helpers.c +62 -0
  57. data/vendor/liburing/examples/helpers.h +7 -0
  58. data/vendor/liburing/examples/io_uring-close-test.c +123 -0
  59. data/vendor/liburing/examples/io_uring-cp.c +282 -0
  60. data/vendor/liburing/examples/io_uring-test.c +112 -0
  61. data/vendor/liburing/examples/io_uring-udp.c +403 -0
  62. data/vendor/liburing/examples/link-cp.c +193 -0
  63. data/vendor/liburing/examples/napi-busy-poll-client.c +509 -0
  64. data/vendor/liburing/examples/napi-busy-poll-server.c +450 -0
  65. data/vendor/liburing/examples/poll-bench.c +101 -0
  66. data/vendor/liburing/examples/proxy.c +2461 -0
  67. data/vendor/liburing/examples/proxy.h +102 -0
  68. data/vendor/liburing/examples/rsrc-update-bench.c +100 -0
  69. data/vendor/liburing/examples/send-zerocopy.c +658 -0
  70. data/vendor/liburing/examples/ucontext-cp.c +258 -0
  71. data/vendor/liburing/liburing-ffi.pc.in +12 -0
  72. data/vendor/liburing/liburing.pc.in +12 -0
  73. data/vendor/liburing/liburing.spec +66 -0
  74. data/vendor/liburing/make-debs.sh +55 -0
  75. data/vendor/liburing/src/Makefile +129 -0
  76. data/vendor/liburing/src/arch/aarch64/lib.h +47 -0
  77. data/vendor/liburing/src/arch/aarch64/syscall.h +91 -0
  78. data/vendor/liburing/src/arch/generic/lib.h +17 -0
  79. data/vendor/liburing/src/arch/generic/syscall.h +100 -0
  80. data/vendor/liburing/src/arch/riscv64/lib.h +48 -0
  81. data/vendor/liburing/src/arch/riscv64/syscall.h +100 -0
  82. data/vendor/liburing/src/arch/syscall-defs.h +94 -0
  83. data/vendor/liburing/src/arch/x86/lib.h +11 -0
  84. data/vendor/liburing/src/arch/x86/syscall.h +296 -0
  85. data/vendor/liburing/src/ffi.c +15 -0
  86. data/vendor/liburing/src/include/liburing/barrier.h +81 -0
  87. data/vendor/liburing/src/include/liburing/io_uring.h +818 -0
  88. data/vendor/liburing/src/include/liburing.h +1602 -0
  89. data/vendor/liburing/src/int_flags.h +11 -0
  90. data/vendor/liburing/src/lib.h +52 -0
  91. data/vendor/liburing/src/liburing-ffi.map +211 -0
  92. data/vendor/liburing/src/liburing.map +104 -0
  93. data/vendor/liburing/src/nolibc.c +55 -0
  94. data/vendor/liburing/src/queue.c +468 -0
  95. data/vendor/liburing/src/register.c +374 -0
  96. data/vendor/liburing/src/setup.c +689 -0
  97. data/vendor/liburing/src/setup.h +9 -0
  98. data/vendor/liburing/src/syscall.c +29 -0
  99. data/vendor/liburing/src/syscall.h +53 -0
  100. data/vendor/liburing/src/version.c +21 -0
  101. data/vendor/liburing/test/232c93d07b74.c +305 -0
  102. data/vendor/liburing/test/35fa71a030ca.c +329 -0
  103. data/vendor/liburing/test/500f9fbadef8.c +91 -0
  104. data/vendor/liburing/test/7ad0e4b2f83c.c +94 -0
  105. data/vendor/liburing/test/8a9973408177.c +107 -0
  106. data/vendor/liburing/test/917257daa0fe.c +54 -0
  107. data/vendor/liburing/test/Makefile +297 -0
  108. data/vendor/liburing/test/a0908ae19763.c +59 -0
  109. data/vendor/liburing/test/a4c0b3decb33.c +181 -0
  110. data/vendor/liburing/test/accept-link.c +255 -0
  111. data/vendor/liburing/test/accept-non-empty.c +256 -0
  112. data/vendor/liburing/test/accept-reuse.c +163 -0
  113. data/vendor/liburing/test/accept-test.c +83 -0
  114. data/vendor/liburing/test/accept.c +919 -0
  115. data/vendor/liburing/test/across-fork.c +284 -0
  116. data/vendor/liburing/test/b19062a56726.c +54 -0
  117. data/vendor/liburing/test/b5837bd5311d.c +78 -0
  118. data/vendor/liburing/test/bind-listen.c +408 -0
  119. data/vendor/liburing/test/buf-ring-nommap.c +123 -0
  120. data/vendor/liburing/test/buf-ring-put.c +83 -0
  121. data/vendor/liburing/test/buf-ring.c +473 -0
  122. data/vendor/liburing/test/ce593a6c480a.c +139 -0
  123. data/vendor/liburing/test/close-opath.c +123 -0
  124. data/vendor/liburing/test/config +14 -0
  125. data/vendor/liburing/test/connect-rep.c +204 -0
  126. data/vendor/liburing/test/connect.c +442 -0
  127. data/vendor/liburing/test/coredump.c +60 -0
  128. data/vendor/liburing/test/cq-full.c +97 -0
  129. data/vendor/liburing/test/cq-overflow.c +530 -0
  130. data/vendor/liburing/test/cq-peek-batch.c +103 -0
  131. data/vendor/liburing/test/cq-ready.c +95 -0
  132. data/vendor/liburing/test/cq-size.c +65 -0
  133. data/vendor/liburing/test/d4ae271dfaae.c +96 -0
  134. data/vendor/liburing/test/d77a67ed5f27.c +65 -0
  135. data/vendor/liburing/test/defer-taskrun.c +391 -0
  136. data/vendor/liburing/test/defer-tw-timeout.c +173 -0
  137. data/vendor/liburing/test/defer.c +319 -0
  138. data/vendor/liburing/test/double-poll-crash.c +195 -0
  139. data/vendor/liburing/test/drop-submit.c +94 -0
  140. data/vendor/liburing/test/eeed8b54e0df.c +120 -0
  141. data/vendor/liburing/test/empty-eownerdead.c +45 -0
  142. data/vendor/liburing/test/eploop.c +74 -0
  143. data/vendor/liburing/test/eventfd-disable.c +179 -0
  144. data/vendor/liburing/test/eventfd-reg.c +77 -0
  145. data/vendor/liburing/test/eventfd-ring.c +98 -0
  146. data/vendor/liburing/test/eventfd.c +113 -0
  147. data/vendor/liburing/test/evloop.c +73 -0
  148. data/vendor/liburing/test/exec-target.c +6 -0
  149. data/vendor/liburing/test/exit-no-cleanup.c +117 -0
  150. data/vendor/liburing/test/fadvise.c +202 -0
  151. data/vendor/liburing/test/fallocate.c +265 -0
  152. data/vendor/liburing/test/fc2a85cb02ef.c +132 -0
  153. data/vendor/liburing/test/fd-install.c +500 -0
  154. data/vendor/liburing/test/fd-pass.c +237 -0
  155. data/vendor/liburing/test/fdinfo.c +419 -0
  156. data/vendor/liburing/test/file-register.c +1189 -0
  157. data/vendor/liburing/test/file-update.c +231 -0
  158. data/vendor/liburing/test/file-verify.c +654 -0
  159. data/vendor/liburing/test/files-exit-hang-poll.c +114 -0
  160. data/vendor/liburing/test/files-exit-hang-timeout.c +137 -0
  161. data/vendor/liburing/test/fixed-buf-iter.c +115 -0
  162. data/vendor/liburing/test/fixed-buf-merge.c +101 -0
  163. data/vendor/liburing/test/fixed-hugepage.c +411 -0
  164. data/vendor/liburing/test/fixed-link.c +90 -0
  165. data/vendor/liburing/test/fixed-reuse.c +160 -0
  166. data/vendor/liburing/test/fpos.c +255 -0
  167. data/vendor/liburing/test/fsnotify.c +118 -0
  168. data/vendor/liburing/test/fsync.c +224 -0
  169. data/vendor/liburing/test/futex.c +571 -0
  170. data/vendor/liburing/test/hardlink.c +170 -0
  171. data/vendor/liburing/test/helpers.c +318 -0
  172. data/vendor/liburing/test/helpers.h +108 -0
  173. data/vendor/liburing/test/ignore-single-mmap.c +48 -0
  174. data/vendor/liburing/test/init-mem.c +164 -0
  175. data/vendor/liburing/test/io-cancel.c +561 -0
  176. data/vendor/liburing/test/io_uring_enter.c +264 -0
  177. data/vendor/liburing/test/io_uring_passthrough.c +482 -0
  178. data/vendor/liburing/test/io_uring_register.c +503 -0
  179. data/vendor/liburing/test/io_uring_setup.c +110 -0
  180. data/vendor/liburing/test/iopoll-leak.c +85 -0
  181. data/vendor/liburing/test/iopoll-overflow.c +118 -0
  182. data/vendor/liburing/test/iopoll.c +465 -0
  183. data/vendor/liburing/test/lfs-openat-write.c +119 -0
  184. data/vendor/liburing/test/lfs-openat.c +273 -0
  185. data/vendor/liburing/test/link-timeout.c +1108 -0
  186. data/vendor/liburing/test/link.c +497 -0
  187. data/vendor/liburing/test/link_drain.c +255 -0
  188. data/vendor/liburing/test/madvise.c +195 -0
  189. data/vendor/liburing/test/min-timeout-wait.c +354 -0
  190. data/vendor/liburing/test/min-timeout.c +233 -0
  191. data/vendor/liburing/test/mkdir.c +112 -0
  192. data/vendor/liburing/test/msg-ring-fd.c +331 -0
  193. data/vendor/liburing/test/msg-ring-flags.c +212 -0
  194. data/vendor/liburing/test/msg-ring-overflow.c +159 -0
  195. data/vendor/liburing/test/msg-ring.c +467 -0
  196. data/vendor/liburing/test/multicqes_drain.c +429 -0
  197. data/vendor/liburing/test/napi-test.c +215 -0
  198. data/vendor/liburing/test/napi-test.sh +48 -0
  199. data/vendor/liburing/test/no-mmap-inval.c +42 -0
  200. data/vendor/liburing/test/nolibc.c +62 -0
  201. data/vendor/liburing/test/nop-all-sizes.c +99 -0
  202. data/vendor/liburing/test/nop.c +177 -0
  203. data/vendor/liburing/test/nvme.h +169 -0
  204. data/vendor/liburing/test/ooo-file-unreg.c +82 -0
  205. data/vendor/liburing/test/open-close.c +261 -0
  206. data/vendor/liburing/test/open-direct-link.c +188 -0
  207. data/vendor/liburing/test/open-direct-pick.c +180 -0
  208. data/vendor/liburing/test/openat2.c +312 -0
  209. data/vendor/liburing/test/personality.c +204 -0
  210. data/vendor/liburing/test/pipe-bug.c +95 -0
  211. data/vendor/liburing/test/pipe-eof.c +83 -0
  212. data/vendor/liburing/test/pipe-reuse.c +105 -0
  213. data/vendor/liburing/test/poll-cancel-all.c +496 -0
  214. data/vendor/liburing/test/poll-cancel-ton.c +135 -0
  215. data/vendor/liburing/test/poll-cancel.c +228 -0
  216. data/vendor/liburing/test/poll-link.c +221 -0
  217. data/vendor/liburing/test/poll-many.c +230 -0
  218. data/vendor/liburing/test/poll-mshot-overflow.c +265 -0
  219. data/vendor/liburing/test/poll-mshot-update.c +323 -0
  220. data/vendor/liburing/test/poll-race-mshot.c +276 -0
  221. data/vendor/liburing/test/poll-race.c +105 -0
  222. data/vendor/liburing/test/poll-ring.c +48 -0
  223. data/vendor/liburing/test/poll-v-poll.c +353 -0
  224. data/vendor/liburing/test/poll.c +327 -0
  225. data/vendor/liburing/test/probe.c +135 -0
  226. data/vendor/liburing/test/read-before-exit.c +129 -0
  227. data/vendor/liburing/test/read-mshot-empty.c +153 -0
  228. data/vendor/liburing/test/read-mshot.c +404 -0
  229. data/vendor/liburing/test/read-write.c +1013 -0
  230. data/vendor/liburing/test/recv-msgall-stream.c +398 -0
  231. data/vendor/liburing/test/recv-msgall.c +263 -0
  232. data/vendor/liburing/test/recv-multishot.c +602 -0
  233. data/vendor/liburing/test/recvsend_bundle.c +691 -0
  234. data/vendor/liburing/test/reg-fd-only.c +131 -0
  235. data/vendor/liburing/test/reg-hint.c +56 -0
  236. data/vendor/liburing/test/reg-reg-ring.c +90 -0
  237. data/vendor/liburing/test/regbuf-merge.c +91 -0
  238. data/vendor/liburing/test/register-restrictions.c +633 -0
  239. data/vendor/liburing/test/rename.c +132 -0
  240. data/vendor/liburing/test/ring-leak.c +283 -0
  241. data/vendor/liburing/test/ring-leak2.c +249 -0
  242. data/vendor/liburing/test/ringbuf-read.c +196 -0
  243. data/vendor/liburing/test/ringbuf-status.c +242 -0
  244. data/vendor/liburing/test/rsrc_tags.c +461 -0
  245. data/vendor/liburing/test/runtests-loop.sh +16 -0
  246. data/vendor/liburing/test/runtests-quiet.sh +11 -0
  247. data/vendor/liburing/test/runtests.sh +168 -0
  248. data/vendor/liburing/test/rw_merge_test.c +98 -0
  249. data/vendor/liburing/test/self.c +91 -0
  250. data/vendor/liburing/test/send-zerocopy.c +971 -0
  251. data/vendor/liburing/test/send_recv.c +412 -0
  252. data/vendor/liburing/test/send_recvmsg.c +444 -0
  253. data/vendor/liburing/test/shared-wq.c +84 -0
  254. data/vendor/liburing/test/short-read.c +75 -0
  255. data/vendor/liburing/test/shutdown.c +165 -0
  256. data/vendor/liburing/test/sigfd-deadlock.c +88 -0
  257. data/vendor/liburing/test/single-issuer.c +169 -0
  258. data/vendor/liburing/test/skip-cqe.c +428 -0
  259. data/vendor/liburing/test/socket-getsetsock-cmd.c +346 -0
  260. data/vendor/liburing/test/socket-io-cmd.c +237 -0
  261. data/vendor/liburing/test/socket-rw-eagain.c +149 -0
  262. data/vendor/liburing/test/socket-rw-offset.c +149 -0
  263. data/vendor/liburing/test/socket-rw.c +137 -0
  264. data/vendor/liburing/test/socket.c +408 -0
  265. data/vendor/liburing/test/splice.c +512 -0
  266. data/vendor/liburing/test/sq-full-cpp.cc +45 -0
  267. data/vendor/liburing/test/sq-full.c +45 -0
  268. data/vendor/liburing/test/sq-poll-dup.c +211 -0
  269. data/vendor/liburing/test/sq-poll-kthread.c +169 -0
  270. data/vendor/liburing/test/sq-poll-share.c +138 -0
  271. data/vendor/liburing/test/sq-space_left.c +159 -0
  272. data/vendor/liburing/test/sqpoll-disable-exit.c +196 -0
  273. data/vendor/liburing/test/sqpoll-exec.c +132 -0
  274. data/vendor/liburing/test/sqpoll-exit-hang.c +78 -0
  275. data/vendor/liburing/test/sqpoll-sleep.c +69 -0
  276. data/vendor/liburing/test/statx.c +172 -0
  277. data/vendor/liburing/test/stdout.c +232 -0
  278. data/vendor/liburing/test/submit-and-wait.c +108 -0
  279. data/vendor/liburing/test/submit-link-fail.c +156 -0
  280. data/vendor/liburing/test/submit-reuse.c +237 -0
  281. data/vendor/liburing/test/symlink.c +117 -0
  282. data/vendor/liburing/test/sync-cancel.c +235 -0
  283. data/vendor/liburing/test/teardowns.c +58 -0
  284. data/vendor/liburing/test/test.h +36 -0
  285. data/vendor/liburing/test/thread-exit.c +143 -0
  286. data/vendor/liburing/test/timeout-new.c +256 -0
  287. data/vendor/liburing/test/timeout.c +1798 -0
  288. data/vendor/liburing/test/truncate.c +186 -0
  289. data/vendor/liburing/test/tty-write-dpoll.c +60 -0
  290. data/vendor/liburing/test/unlink.c +112 -0
  291. data/vendor/liburing/test/version.c +25 -0
  292. data/vendor/liburing/test/wait-timeout.c +287 -0
  293. data/vendor/liburing/test/waitid.c +373 -0
  294. data/vendor/liburing/test/wakeup-hang.c +162 -0
  295. data/vendor/liburing/test/wq-aff.c +146 -0
  296. data/vendor/liburing/test/xattr.c +442 -0
  297. metadata +402 -0
@@ -0,0 +1,818 @@
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
+ * this file is shared with liburing and that has to autodetect
15
+ * if linux/time_types.h is available or not, it can
16
+ * define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H
17
+ * if linux/time_types.h is not available
18
+ */
19
+ #ifndef UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H
20
+ #include <linux/time_types.h>
21
+ #endif
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ /*
28
+ * IO submission data structure (Submission Queue Entry)
29
+ */
30
+ struct io_uring_sqe {
31
+ __u8 opcode; /* type of operation for this sqe */
32
+ __u8 flags; /* IOSQE_ flags */
33
+ __u16 ioprio; /* ioprio for the request */
34
+ __s32 fd; /* file descriptor to do IO on */
35
+ union {
36
+ __u64 off; /* offset into file */
37
+ __u64 addr2;
38
+ struct {
39
+ __u32 cmd_op;
40
+ __u32 __pad1;
41
+ };
42
+ };
43
+ union {
44
+ __u64 addr; /* pointer to buffer or iovecs */
45
+ __u64 splice_off_in;
46
+ struct {
47
+ __u32 level;
48
+ __u32 optname;
49
+ };
50
+ };
51
+ __u32 len; /* buffer size or number of iovecs */
52
+ union {
53
+ __kernel_rwf_t rw_flags;
54
+ __u32 fsync_flags;
55
+ __u16 poll_events; /* compatibility */
56
+ __u32 poll32_events; /* word-reversed for BE */
57
+ __u32 sync_range_flags;
58
+ __u32 msg_flags;
59
+ __u32 timeout_flags;
60
+ __u32 accept_flags;
61
+ __u32 cancel_flags;
62
+ __u32 open_flags;
63
+ __u32 statx_flags;
64
+ __u32 fadvise_advice;
65
+ __u32 splice_flags;
66
+ __u32 rename_flags;
67
+ __u32 unlink_flags;
68
+ __u32 hardlink_flags;
69
+ __u32 xattr_flags;
70
+ __u32 msg_ring_flags;
71
+ __u32 uring_cmd_flags;
72
+ __u32 waitid_flags;
73
+ __u32 futex_flags;
74
+ __u32 install_fd_flags;
75
+ __u32 nop_flags;
76
+ };
77
+ __u64 user_data; /* data to be passed back at completion time */
78
+ /* pack this to avoid bogus arm OABI complaints */
79
+ union {
80
+ /* index into fixed buffers, if used */
81
+ __u16 buf_index;
82
+ /* for grouped buffer selection */
83
+ __u16 buf_group;
84
+ } __attribute__((packed));
85
+ /* personality to use, if used */
86
+ __u16 personality;
87
+ union {
88
+ __s32 splice_fd_in;
89
+ __u32 file_index;
90
+ __u32 optlen;
91
+ struct {
92
+ __u16 addr_len;
93
+ __u16 __pad3[1];
94
+ };
95
+ };
96
+ union {
97
+ struct {
98
+ __u64 addr3;
99
+ __u64 __pad2[1];
100
+ };
101
+ __u64 optval;
102
+ /*
103
+ * If the ring is initialized with IORING_SETUP_SQE128, then
104
+ * this field is used for 80 bytes of arbitrary command data
105
+ */
106
+ __u8 cmd[0];
107
+ };
108
+ };
109
+
110
+ /*
111
+ * If sqe->file_index is set to this for opcodes that instantiate a new
112
+ * direct descriptor (like openat/openat2/accept), then io_uring will allocate
113
+ * an available direct descriptor instead of having the application pass one
114
+ * in. The picked direct descriptor will be returned in cqe->res, or -ENFILE
115
+ * if the space is full.
116
+ */
117
+ #define IORING_FILE_INDEX_ALLOC (~0U)
118
+
119
+ enum io_uring_sqe_flags_bit {
120
+ IOSQE_FIXED_FILE_BIT,
121
+ IOSQE_IO_DRAIN_BIT,
122
+ IOSQE_IO_LINK_BIT,
123
+ IOSQE_IO_HARDLINK_BIT,
124
+ IOSQE_ASYNC_BIT,
125
+ IOSQE_BUFFER_SELECT_BIT,
126
+ IOSQE_CQE_SKIP_SUCCESS_BIT,
127
+ };
128
+
129
+ /*
130
+ * sqe->flags
131
+ */
132
+ /* use fixed fileset */
133
+ #define IOSQE_FIXED_FILE (1U << IOSQE_FIXED_FILE_BIT)
134
+ /* issue after inflight IO */
135
+ #define IOSQE_IO_DRAIN (1U << IOSQE_IO_DRAIN_BIT)
136
+ /* links next sqe */
137
+ #define IOSQE_IO_LINK (1U << IOSQE_IO_LINK_BIT)
138
+ /* like LINK, but stronger */
139
+ #define IOSQE_IO_HARDLINK (1U << IOSQE_IO_HARDLINK_BIT)
140
+ /* always go async */
141
+ #define IOSQE_ASYNC (1U << IOSQE_ASYNC_BIT)
142
+ /* select buffer from sqe->buf_group */
143
+ #define IOSQE_BUFFER_SELECT (1U << IOSQE_BUFFER_SELECT_BIT)
144
+ /* don't post CQE if request succeeded */
145
+ #define IOSQE_CQE_SKIP_SUCCESS (1U << IOSQE_CQE_SKIP_SUCCESS_BIT)
146
+
147
+ /*
148
+ * io_uring_setup() flags
149
+ */
150
+ #define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */
151
+ #define IORING_SETUP_SQPOLL (1U << 1) /* SQ poll thread */
152
+ #define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */
153
+ #define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */
154
+ #define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */
155
+ #define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */
156
+ #define IORING_SETUP_R_DISABLED (1U << 6) /* start with ring disabled */
157
+ #define IORING_SETUP_SUBMIT_ALL (1U << 7) /* continue submit on error */
158
+ /*
159
+ * Cooperative task running. When requests complete, they often require
160
+ * forcing the submitter to transition to the kernel to complete. If this
161
+ * flag is set, work will be done when the task transitions anyway, rather
162
+ * than force an inter-processor interrupt reschedule. This avoids interrupting
163
+ * a task running in userspace, and saves an IPI.
164
+ */
165
+ #define IORING_SETUP_COOP_TASKRUN (1U << 8)
166
+ /*
167
+ * If COOP_TASKRUN is set, get notified if task work is available for
168
+ * running and a kernel transition would be needed to run it. This sets
169
+ * IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN.
170
+ */
171
+ #define IORING_SETUP_TASKRUN_FLAG (1U << 9)
172
+ #define IORING_SETUP_SQE128 (1U << 10) /* SQEs are 128 byte */
173
+ #define IORING_SETUP_CQE32 (1U << 11) /* CQEs are 32 byte */
174
+ /*
175
+ * Only one task is allowed to submit requests
176
+ */
177
+ #define IORING_SETUP_SINGLE_ISSUER (1U << 12)
178
+
179
+ /*
180
+ * Defer running task work to get events.
181
+ * Rather than running bits of task work whenever the task transitions
182
+ * try to do it just before it is needed.
183
+ */
184
+ #define IORING_SETUP_DEFER_TASKRUN (1U << 13)
185
+
186
+ /*
187
+ * Application provides the memory for the rings
188
+ */
189
+ #define IORING_SETUP_NO_MMAP (1U << 14)
190
+
191
+ /*
192
+ * Register the ring fd in itself for use with
193
+ * IORING_REGISTER_USE_REGISTERED_RING; return a registered fd index rather
194
+ * than an fd.
195
+ */
196
+ #define IORING_SETUP_REGISTERED_FD_ONLY (1U << 15)
197
+
198
+ /*
199
+ * Removes indirection through the SQ index array.
200
+ */
201
+ #define IORING_SETUP_NO_SQARRAY (1U << 16)
202
+
203
+ enum io_uring_op {
204
+ IORING_OP_NOP,
205
+ IORING_OP_READV,
206
+ IORING_OP_WRITEV,
207
+ IORING_OP_FSYNC,
208
+ IORING_OP_READ_FIXED,
209
+ IORING_OP_WRITE_FIXED,
210
+ IORING_OP_POLL_ADD,
211
+ IORING_OP_POLL_REMOVE,
212
+ IORING_OP_SYNC_FILE_RANGE,
213
+ IORING_OP_SENDMSG,
214
+ IORING_OP_RECVMSG,
215
+ IORING_OP_TIMEOUT,
216
+ IORING_OP_TIMEOUT_REMOVE,
217
+ IORING_OP_ACCEPT,
218
+ IORING_OP_ASYNC_CANCEL,
219
+ IORING_OP_LINK_TIMEOUT,
220
+ IORING_OP_CONNECT,
221
+ IORING_OP_FALLOCATE,
222
+ IORING_OP_OPENAT,
223
+ IORING_OP_CLOSE,
224
+ IORING_OP_FILES_UPDATE,
225
+ IORING_OP_STATX,
226
+ IORING_OP_READ,
227
+ IORING_OP_WRITE,
228
+ IORING_OP_FADVISE,
229
+ IORING_OP_MADVISE,
230
+ IORING_OP_SEND,
231
+ IORING_OP_RECV,
232
+ IORING_OP_OPENAT2,
233
+ IORING_OP_EPOLL_CTL,
234
+ IORING_OP_SPLICE,
235
+ IORING_OP_PROVIDE_BUFFERS,
236
+ IORING_OP_REMOVE_BUFFERS,
237
+ IORING_OP_TEE,
238
+ IORING_OP_SHUTDOWN,
239
+ IORING_OP_RENAMEAT,
240
+ IORING_OP_UNLINKAT,
241
+ IORING_OP_MKDIRAT,
242
+ IORING_OP_SYMLINKAT,
243
+ IORING_OP_LINKAT,
244
+ IORING_OP_MSG_RING,
245
+ IORING_OP_FSETXATTR,
246
+ IORING_OP_SETXATTR,
247
+ IORING_OP_FGETXATTR,
248
+ IORING_OP_GETXATTR,
249
+ IORING_OP_SOCKET,
250
+ IORING_OP_URING_CMD,
251
+ IORING_OP_SEND_ZC,
252
+ IORING_OP_SENDMSG_ZC,
253
+ IORING_OP_READ_MULTISHOT,
254
+ IORING_OP_WAITID,
255
+ IORING_OP_FUTEX_WAIT,
256
+ IORING_OP_FUTEX_WAKE,
257
+ IORING_OP_FUTEX_WAITV,
258
+ IORING_OP_FIXED_FD_INSTALL,
259
+ IORING_OP_FTRUNCATE,
260
+ IORING_OP_BIND,
261
+ IORING_OP_LISTEN,
262
+
263
+ /* this goes last, obviously */
264
+ IORING_OP_LAST,
265
+ };
266
+
267
+ /*
268
+ * sqe->uring_cmd_flags top 8bits aren't available for userspace
269
+ * IORING_URING_CMD_FIXED use registered buffer; pass this flag
270
+ * along with setting sqe->buf_index.
271
+ */
272
+ #define IORING_URING_CMD_FIXED (1U << 0)
273
+ #define IORING_URING_CMD_MASK IORING_URING_CMD_FIXED
274
+
275
+
276
+ /*
277
+ * sqe->fsync_flags
278
+ */
279
+ #define IORING_FSYNC_DATASYNC (1U << 0)
280
+
281
+ /*
282
+ * sqe->timeout_flags
283
+ */
284
+ #define IORING_TIMEOUT_ABS (1U << 0)
285
+ #define IORING_TIMEOUT_UPDATE (1U << 1)
286
+ #define IORING_TIMEOUT_BOOTTIME (1U << 2)
287
+ #define IORING_TIMEOUT_REALTIME (1U << 3)
288
+ #define IORING_LINK_TIMEOUT_UPDATE (1U << 4)
289
+ #define IORING_TIMEOUT_ETIME_SUCCESS (1U << 5)
290
+ #define IORING_TIMEOUT_MULTISHOT (1U << 6)
291
+ #define IORING_TIMEOUT_CLOCK_MASK (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME)
292
+ #define IORING_TIMEOUT_UPDATE_MASK (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)
293
+ /*
294
+ * sqe->splice_flags
295
+ * extends splice(2) flags
296
+ */
297
+ #define SPLICE_F_FD_IN_FIXED (1U << 31) /* the last bit of __u32 */
298
+
299
+ /*
300
+ * POLL_ADD flags. Note that since sqe->poll_events is the flag space, the
301
+ * command flags for POLL_ADD are stored in sqe->len.
302
+ *
303
+ * IORING_POLL_ADD_MULTI Multishot poll. Sets IORING_CQE_F_MORE if
304
+ * the poll handler will continue to report
305
+ * CQEs on behalf of the same SQE.
306
+ *
307
+ * IORING_POLL_UPDATE Update existing poll request, matching
308
+ * sqe->addr as the old user_data field.
309
+ *
310
+ * IORING_POLL_LEVEL Level triggered poll.
311
+ */
312
+ #define IORING_POLL_ADD_MULTI (1U << 0)
313
+ #define IORING_POLL_UPDATE_EVENTS (1U << 1)
314
+ #define IORING_POLL_UPDATE_USER_DATA (1U << 2)
315
+ #define IORING_POLL_ADD_LEVEL (1U << 3)
316
+
317
+ /*
318
+ * ASYNC_CANCEL flags.
319
+ *
320
+ * IORING_ASYNC_CANCEL_ALL Cancel all requests that match the given key
321
+ * IORING_ASYNC_CANCEL_FD Key off 'fd' for cancelation rather than the
322
+ * request 'user_data'
323
+ * IORING_ASYNC_CANCEL_ANY Match any request
324
+ * IORING_ASYNC_CANCEL_FD_FIXED 'fd' passed in is a fixed descriptor
325
+ * IORING_ASYNC_CANCEL_USERDATA Match on user_data, default for no other key
326
+ * IORING_ASYNC_CANCEL_OP Match request based on opcode
327
+ */
328
+ #define IORING_ASYNC_CANCEL_ALL (1U << 0)
329
+ #define IORING_ASYNC_CANCEL_FD (1U << 1)
330
+ #define IORING_ASYNC_CANCEL_ANY (1U << 2)
331
+ #define IORING_ASYNC_CANCEL_FD_FIXED (1U << 3)
332
+ #define IORING_ASYNC_CANCEL_USERDATA (1U << 4)
333
+ #define IORING_ASYNC_CANCEL_OP (1U << 5)
334
+
335
+ /*
336
+ * send/sendmsg and recv/recvmsg flags (sqe->ioprio)
337
+ *
338
+ * IORING_RECVSEND_POLL_FIRST If set, instead of first attempting to send
339
+ * or receive and arm poll if that yields an
340
+ * -EAGAIN result, arm poll upfront and skip
341
+ * the initial transfer attempt.
342
+ *
343
+ * IORING_RECV_MULTISHOT Multishot recv. Sets IORING_CQE_F_MORE if
344
+ * the handler will continue to report
345
+ * CQEs on behalf of the same SQE.
346
+ *
347
+ * IORING_RECVSEND_FIXED_BUF Use registered buffers, the index is stored in
348
+ * the buf_index field.
349
+ *
350
+ * IORING_SEND_ZC_REPORT_USAGE
351
+ * If set, SEND[MSG]_ZC should report
352
+ * the zerocopy usage in cqe.res
353
+ * for the IORING_CQE_F_NOTIF cqe.
354
+ * 0 is reported if zerocopy was actually possible.
355
+ * IORING_NOTIF_USAGE_ZC_COPIED if data was copied
356
+ * (at least partially).
357
+ *
358
+ * IORING_RECVSEND_BUNDLE Used with IOSQE_BUFFER_SELECT. If set, send or
359
+ * recv will grab as many buffers from the buffer
360
+ * group ID given and send them all. The completion
361
+ * result will be the number of buffers send, with
362
+ * the starting buffer ID in cqe->flags as per
363
+ * usual for provided buffer usage. The buffers
364
+ * will be contiguous from the starting buffer ID.
365
+ */
366
+ #define IORING_RECVSEND_POLL_FIRST (1U << 0)
367
+ #define IORING_RECV_MULTISHOT (1U << 1)
368
+ #define IORING_RECVSEND_FIXED_BUF (1U << 2)
369
+ #define IORING_SEND_ZC_REPORT_USAGE (1U << 3)
370
+ #define IORING_RECVSEND_BUNDLE (1U << 4)
371
+
372
+ /*
373
+ * cqe.res for IORING_CQE_F_NOTIF if
374
+ * IORING_SEND_ZC_REPORT_USAGE was requested
375
+ *
376
+ * It should be treated as a flag, all other
377
+ * bits of cqe.res should be treated as reserved!
378
+ */
379
+ #define IORING_NOTIF_USAGE_ZC_COPIED (1U << 31)
380
+
381
+ /*
382
+ * accept flags stored in sqe->ioprio
383
+ */
384
+ #define IORING_ACCEPT_MULTISHOT (1U << 0)
385
+ #define IORING_ACCEPT_DONTWAIT (1U << 1)
386
+ #define IORING_ACCEPT_POLL_FIRST (1U << 2)
387
+
388
+ /*
389
+ * IORING_OP_MSG_RING command types, stored in sqe->addr
390
+ */
391
+ enum io_uring_msg_ring_flags {
392
+ IORING_MSG_DATA, /* pass sqe->len as 'res' and off as user_data */
393
+ IORING_MSG_SEND_FD, /* send a registered fd to another ring */
394
+ };
395
+
396
+ /*
397
+ * IORING_OP_MSG_RING flags (sqe->msg_ring_flags)
398
+ *
399
+ * IORING_MSG_RING_CQE_SKIP Don't post a CQE to the target ring. Not
400
+ * applicable for IORING_MSG_DATA, obviously.
401
+ */
402
+ #define IORING_MSG_RING_CQE_SKIP (1U << 0)
403
+ /* Pass through the flags from sqe->file_index to cqe->flags */
404
+ #define IORING_MSG_RING_FLAGS_PASS (1U << 1)
405
+
406
+ /*
407
+ * IORING_OP_FIXED_FD_INSTALL flags (sqe->install_fd_flags)
408
+ *
409
+ * IORING_FIXED_FD_NO_CLOEXEC Don't mark the fd as O_CLOEXEC
410
+ */
411
+ #define IORING_FIXED_FD_NO_CLOEXEC (1U << 0)
412
+
413
+ /*
414
+ * IORING_OP_NOP flags (sqe->nop_flags)
415
+ *
416
+ * IORING_NOP_INJECT_RESULT Inject result from sqe->result
417
+ */
418
+ #define IORING_NOP_INJECT_RESULT (1U << 0)
419
+
420
+ /*
421
+ * IO completion data structure (Completion Queue Entry)
422
+ */
423
+ struct io_uring_cqe {
424
+ __u64 user_data; /* sqe->user_data submission passed back */
425
+ __s32 res; /* result code for this event */
426
+ __u32 flags;
427
+
428
+ /*
429
+ * If the ring is initialized with IORING_SETUP_CQE32, then this field
430
+ * contains 16-bytes of padding, doubling the size of the CQE.
431
+ */
432
+ __u64 big_cqe[];
433
+ };
434
+
435
+ /*
436
+ * cqe->flags
437
+ *
438
+ * IORING_CQE_F_BUFFER If set, the upper 16 bits are the buffer ID
439
+ * IORING_CQE_F_MORE If set, parent SQE will generate more CQE entries
440
+ * IORING_CQE_F_SOCK_NONEMPTY If set, more data to read after socket recv
441
+ * IORING_CQE_F_NOTIF Set for notification CQEs. Can be used to distinct
442
+ * them from sends.
443
+ */
444
+ #define IORING_CQE_F_BUFFER (1U << 0)
445
+ #define IORING_CQE_F_MORE (1U << 1)
446
+ #define IORING_CQE_F_SOCK_NONEMPTY (1U << 2)
447
+ #define IORING_CQE_F_NOTIF (1U << 3)
448
+
449
+ #define IORING_CQE_BUFFER_SHIFT 16
450
+
451
+ /*
452
+ * Magic offsets for the application to mmap the data it needs
453
+ */
454
+ #define IORING_OFF_SQ_RING 0ULL
455
+ #define IORING_OFF_CQ_RING 0x8000000ULL
456
+ #define IORING_OFF_SQES 0x10000000ULL
457
+ #define IORING_OFF_PBUF_RING 0x80000000ULL
458
+ #define IORING_OFF_PBUF_SHIFT 16
459
+ #define IORING_OFF_MMAP_MASK 0xf8000000ULL
460
+
461
+ /*
462
+ * Filled with the offset for mmap(2)
463
+ */
464
+ struct io_sqring_offsets {
465
+ __u32 head;
466
+ __u32 tail;
467
+ __u32 ring_mask;
468
+ __u32 ring_entries;
469
+ __u32 flags;
470
+ __u32 dropped;
471
+ __u32 array;
472
+ __u32 resv1;
473
+ __u64 user_addr;
474
+ };
475
+
476
+ /*
477
+ * sq_ring->flags
478
+ */
479
+ #define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */
480
+ #define IORING_SQ_CQ_OVERFLOW (1U << 1) /* CQ ring is overflown */
481
+ #define IORING_SQ_TASKRUN (1U << 2) /* task should enter the kernel */
482
+
483
+ struct io_cqring_offsets {
484
+ __u32 head;
485
+ __u32 tail;
486
+ __u32 ring_mask;
487
+ __u32 ring_entries;
488
+ __u32 overflow;
489
+ __u32 cqes;
490
+ __u32 flags;
491
+ __u32 resv1;
492
+ __u64 user_addr;
493
+ };
494
+
495
+ /*
496
+ * cq_ring->flags
497
+ */
498
+
499
+ /* disable eventfd notifications */
500
+ #define IORING_CQ_EVENTFD_DISABLED (1U << 0)
501
+
502
+ /*
503
+ * io_uring_enter(2) flags
504
+ */
505
+ #define IORING_ENTER_GETEVENTS (1U << 0)
506
+ #define IORING_ENTER_SQ_WAKEUP (1U << 1)
507
+ #define IORING_ENTER_SQ_WAIT (1U << 2)
508
+ #define IORING_ENTER_EXT_ARG (1U << 3)
509
+ #define IORING_ENTER_REGISTERED_RING (1U << 4)
510
+ #define IORING_ENTER_ABS_TIMER (1U << 5)
511
+
512
+ /*
513
+ * Passed in for io_uring_setup(2). Copied back with updated info on success
514
+ */
515
+ struct io_uring_params {
516
+ __u32 sq_entries;
517
+ __u32 cq_entries;
518
+ __u32 flags;
519
+ __u32 sq_thread_cpu;
520
+ __u32 sq_thread_idle;
521
+ __u32 features;
522
+ __u32 wq_fd;
523
+ __u32 resv[3];
524
+ struct io_sqring_offsets sq_off;
525
+ struct io_cqring_offsets cq_off;
526
+ };
527
+
528
+ /*
529
+ * io_uring_params->features flags
530
+ */
531
+ #define IORING_FEAT_SINGLE_MMAP (1U << 0)
532
+ #define IORING_FEAT_NODROP (1U << 1)
533
+ #define IORING_FEAT_SUBMIT_STABLE (1U << 2)
534
+ #define IORING_FEAT_RW_CUR_POS (1U << 3)
535
+ #define IORING_FEAT_CUR_PERSONALITY (1U << 4)
536
+ #define IORING_FEAT_FAST_POLL (1U << 5)
537
+ #define IORING_FEAT_POLL_32BITS (1U << 6)
538
+ #define IORING_FEAT_SQPOLL_NONFIXED (1U << 7)
539
+ #define IORING_FEAT_EXT_ARG (1U << 8)
540
+ #define IORING_FEAT_NATIVE_WORKERS (1U << 9)
541
+ #define IORING_FEAT_RSRC_TAGS (1U << 10)
542
+ #define IORING_FEAT_CQE_SKIP (1U << 11)
543
+ #define IORING_FEAT_LINKED_FILE (1U << 12)
544
+ #define IORING_FEAT_REG_REG_RING (1U << 13)
545
+ #define IORING_FEAT_RECVSEND_BUNDLE (1U << 14)
546
+ #define IORING_FEAT_MIN_TIMEOUT (1U << 15)
547
+
548
+ /*
549
+ * io_uring_register(2) opcodes and arguments
550
+ */
551
+ enum io_uring_register_op {
552
+ IORING_REGISTER_BUFFERS = 0,
553
+ IORING_UNREGISTER_BUFFERS = 1,
554
+ IORING_REGISTER_FILES = 2,
555
+ IORING_UNREGISTER_FILES = 3,
556
+ IORING_REGISTER_EVENTFD = 4,
557
+ IORING_UNREGISTER_EVENTFD = 5,
558
+ IORING_REGISTER_FILES_UPDATE = 6,
559
+ IORING_REGISTER_EVENTFD_ASYNC = 7,
560
+ IORING_REGISTER_PROBE = 8,
561
+ IORING_REGISTER_PERSONALITY = 9,
562
+ IORING_UNREGISTER_PERSONALITY = 10,
563
+ IORING_REGISTER_RESTRICTIONS = 11,
564
+ IORING_REGISTER_ENABLE_RINGS = 12,
565
+
566
+ /* extended with tagging */
567
+ IORING_REGISTER_FILES2 = 13,
568
+ IORING_REGISTER_FILES_UPDATE2 = 14,
569
+ IORING_REGISTER_BUFFERS2 = 15,
570
+ IORING_REGISTER_BUFFERS_UPDATE = 16,
571
+
572
+ /* set/clear io-wq thread affinities */
573
+ IORING_REGISTER_IOWQ_AFF = 17,
574
+ IORING_UNREGISTER_IOWQ_AFF = 18,
575
+
576
+ /* set/get max number of io-wq workers */
577
+ IORING_REGISTER_IOWQ_MAX_WORKERS = 19,
578
+
579
+ /* register/unregister io_uring fd with the ring */
580
+ IORING_REGISTER_RING_FDS = 20,
581
+ IORING_UNREGISTER_RING_FDS = 21,
582
+
583
+ /* register ring based provide buffer group */
584
+ IORING_REGISTER_PBUF_RING = 22,
585
+ IORING_UNREGISTER_PBUF_RING = 23,
586
+
587
+ /* sync cancelation API */
588
+ IORING_REGISTER_SYNC_CANCEL = 24,
589
+
590
+ /* register a range of fixed file slots for automatic slot allocation */
591
+ IORING_REGISTER_FILE_ALLOC_RANGE = 25,
592
+
593
+ /* return status information for a buffer group */
594
+ IORING_REGISTER_PBUF_STATUS = 26,
595
+
596
+ /* set/clear busy poll settings */
597
+ IORING_REGISTER_NAPI = 27,
598
+ IORING_UNREGISTER_NAPI = 28,
599
+
600
+ IORING_REGISTER_CLOCK = 29,
601
+
602
+ /* this goes last */
603
+ IORING_REGISTER_LAST,
604
+
605
+ /* flag added to the opcode to use a registered ring fd */
606
+ IORING_REGISTER_USE_REGISTERED_RING = 1U << 31
607
+ };
608
+
609
+ /* io-wq worker categories */
610
+ enum io_wq_type {
611
+ IO_WQ_BOUND,
612
+ IO_WQ_UNBOUND,
613
+ };
614
+
615
+ /* deprecated, see struct io_uring_rsrc_update */
616
+ struct io_uring_files_update {
617
+ __u32 offset;
618
+ __u32 resv;
619
+ __aligned_u64 /* __s32 * */ fds;
620
+ };
621
+
622
+ /*
623
+ * Register a fully sparse file space, rather than pass in an array of all
624
+ * -1 file descriptors.
625
+ */
626
+ #define IORING_RSRC_REGISTER_SPARSE (1U << 0)
627
+
628
+ struct io_uring_rsrc_register {
629
+ __u32 nr;
630
+ __u32 flags;
631
+ __u64 resv2;
632
+ __aligned_u64 data;
633
+ __aligned_u64 tags;
634
+ };
635
+
636
+ struct io_uring_rsrc_update {
637
+ __u32 offset;
638
+ __u32 resv;
639
+ __aligned_u64 data;
640
+ };
641
+
642
+ struct io_uring_rsrc_update2 {
643
+ __u32 offset;
644
+ __u32 resv;
645
+ __aligned_u64 data;
646
+ __aligned_u64 tags;
647
+ __u32 nr;
648
+ __u32 resv2;
649
+ };
650
+
651
+ /* Skip updating fd indexes set to this value in the fd table */
652
+ #define IORING_REGISTER_FILES_SKIP (-2)
653
+
654
+ #define IO_URING_OP_SUPPORTED (1U << 0)
655
+
656
+ struct io_uring_probe_op {
657
+ __u8 op;
658
+ __u8 resv;
659
+ __u16 flags; /* IO_URING_OP_* flags */
660
+ __u32 resv2;
661
+ };
662
+
663
+ struct io_uring_probe {
664
+ __u8 last_op; /* last opcode supported */
665
+ __u8 ops_len; /* length of ops[] array below */
666
+ __u16 resv;
667
+ __u32 resv2[3];
668
+ struct io_uring_probe_op ops[];
669
+ };
670
+
671
+ struct io_uring_restriction {
672
+ __u16 opcode;
673
+ union {
674
+ __u8 register_op; /* IORING_RESTRICTION_REGISTER_OP */
675
+ __u8 sqe_op; /* IORING_RESTRICTION_SQE_OP */
676
+ __u8 sqe_flags; /* IORING_RESTRICTION_SQE_FLAGS_* */
677
+ };
678
+ __u8 resv;
679
+ __u32 resv2[3];
680
+ };
681
+
682
+ struct io_uring_clock_register {
683
+ __u32 clockid;
684
+ __u32 __resv[3];
685
+ };
686
+
687
+ struct io_uring_buf {
688
+ __u64 addr;
689
+ __u32 len;
690
+ __u16 bid;
691
+ __u16 resv;
692
+ };
693
+
694
+ struct io_uring_buf_ring {
695
+ union {
696
+ /*
697
+ * To avoid spilling into more pages than we need to, the
698
+ * ring tail is overlaid with the io_uring_buf->resv field.
699
+ */
700
+ struct {
701
+ __u64 resv1;
702
+ __u32 resv2;
703
+ __u16 resv3;
704
+ __u16 tail;
705
+ };
706
+ struct io_uring_buf bufs[0];
707
+ };
708
+ };
709
+
710
+ /*
711
+ * Flags for IORING_REGISTER_PBUF_RING.
712
+ *
713
+ * IOU_PBUF_RING_MMAP: If set, kernel will allocate the memory for the ring.
714
+ * The application must not set a ring_addr in struct
715
+ * io_uring_buf_reg, instead it must subsequently call
716
+ * mmap(2) with the offset set as:
717
+ * IORING_OFF_PBUF_RING | (bgid << IORING_OFF_PBUF_SHIFT)
718
+ * to get a virtual mapping for the ring.
719
+ */
720
+ enum io_uring_register_pbuf_ring_flags {
721
+ IOU_PBUF_RING_MMAP = 1,
722
+ };
723
+
724
+ /* argument for IORING_(UN)REGISTER_PBUF_RING */
725
+ struct io_uring_buf_reg {
726
+ __u64 ring_addr;
727
+ __u32 ring_entries;
728
+ __u16 bgid;
729
+ __u16 flags;
730
+ __u64 resv[3];
731
+ };
732
+
733
+ /* argument for IORING_REGISTER_PBUF_STATUS */
734
+ struct io_uring_buf_status {
735
+ __u32 buf_group; /* input */
736
+ __u32 head; /* output */
737
+ __u32 resv[8];
738
+ };
739
+
740
+ /* argument for IORING_(UN)REGISTER_NAPI */
741
+ struct io_uring_napi {
742
+ __u32 busy_poll_to;
743
+ __u8 prefer_busy_poll;
744
+ __u8 pad[3];
745
+ __u64 resv;
746
+ };
747
+
748
+ /*
749
+ * io_uring_restriction->opcode values
750
+ */
751
+ enum io_uring_register_restriction_op {
752
+ /* Allow an io_uring_register(2) opcode */
753
+ IORING_RESTRICTION_REGISTER_OP = 0,
754
+
755
+ /* Allow an sqe opcode */
756
+ IORING_RESTRICTION_SQE_OP = 1,
757
+
758
+ /* Allow sqe flags */
759
+ IORING_RESTRICTION_SQE_FLAGS_ALLOWED = 2,
760
+
761
+ /* Require sqe flags (these flags must be set on each submission) */
762
+ IORING_RESTRICTION_SQE_FLAGS_REQUIRED = 3,
763
+
764
+ IORING_RESTRICTION_LAST
765
+ };
766
+
767
+ struct io_uring_getevents_arg {
768
+ __u64 sigmask;
769
+ __u32 sigmask_sz;
770
+ __u32 min_wait_usec;
771
+ __u64 ts;
772
+ };
773
+
774
+ /*
775
+ * Argument for IORING_REGISTER_SYNC_CANCEL
776
+ */
777
+ struct io_uring_sync_cancel_reg {
778
+ __u64 addr;
779
+ __s32 fd;
780
+ __u32 flags;
781
+ struct __kernel_timespec timeout;
782
+ __u8 opcode;
783
+ __u8 pad[7];
784
+ __u64 pad2[3];
785
+ };
786
+
787
+ /*
788
+ * Argument for IORING_REGISTER_FILE_ALLOC_RANGE
789
+ * The range is specified as [off, off + len)
790
+ */
791
+ struct io_uring_file_index_range {
792
+ __u32 off;
793
+ __u32 len;
794
+ __u64 resv;
795
+ };
796
+
797
+ struct io_uring_recvmsg_out {
798
+ __u32 namelen;
799
+ __u32 controllen;
800
+ __u32 payloadlen;
801
+ __u32 flags;
802
+ };
803
+
804
+ /*
805
+ * Argument for IORING_OP_URING_CMD when file is a socket
806
+ */
807
+ enum io_uring_socket_op {
808
+ SOCKET_URING_OP_SIOCINQ = 0,
809
+ SOCKET_URING_OP_SIOCOUTQ,
810
+ SOCKET_URING_OP_GETSOCKOPT,
811
+ SOCKET_URING_OP_SETSOCKOPT,
812
+ };
813
+
814
+ #ifdef __cplusplus
815
+ }
816
+ #endif
817
+
818
+ #endif