19f5834c8SLukas Bulwahn /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ 22b188cc1SJens Axboe /* 32b188cc1SJens Axboe * Header file for the io_uring interface. 42b188cc1SJens Axboe * 52b188cc1SJens Axboe * Copyright (C) 2019 Jens Axboe 62b188cc1SJens Axboe * Copyright (C) 2019 Christoph Hellwig 72b188cc1SJens Axboe */ 82b188cc1SJens Axboe #ifndef LINUX_IO_URING_H 92b188cc1SJens Axboe #define LINUX_IO_URING_H 102b188cc1SJens Axboe 112b188cc1SJens Axboe #include <linux/fs.h> 122b188cc1SJens Axboe #include <linux/types.h> 139eb80340SStefan Metzmacher /* 149eb80340SStefan Metzmacher * this file is shared with liburing and that has to autodetect 159eb80340SStefan Metzmacher * if linux/time_types.h is available or not, it can 169eb80340SStefan Metzmacher * define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 179eb80340SStefan Metzmacher * if linux/time_types.h is not available 189eb80340SStefan Metzmacher */ 199eb80340SStefan Metzmacher #ifndef UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 2078a861b9SJens Axboe #include <linux/time_types.h> 219eb80340SStefan Metzmacher #endif 222b188cc1SJens Axboe 23e1d0c6d0SAmmar Faizi #ifdef __cplusplus 24e1d0c6d0SAmmar Faizi extern "C" { 25e1d0c6d0SAmmar Faizi #endif 26e1d0c6d0SAmmar Faizi 272b188cc1SJens Axboe /* 282b188cc1SJens Axboe * IO submission data structure (Submission Queue Entry) 292b188cc1SJens Axboe */ 302b188cc1SJens Axboe struct io_uring_sqe { 312b188cc1SJens Axboe __u8 opcode; /* type of operation for this sqe */ 326b06314cSJens Axboe __u8 flags; /* IOSQE_ flags */ 332b188cc1SJens Axboe __u16 ioprio; /* ioprio for the request */ 342b188cc1SJens Axboe __s32 fd; /* file descriptor to do IO on */ 3517f2fe35SJens Axboe union { 362b188cc1SJens Axboe __u64 off; /* offset into file */ 3717f2fe35SJens Axboe __u64 addr2; 38bdb2c48eSPavel Begunkov struct { 39ee692a21SJens Axboe __u32 cmd_op; 40bdb2c48eSPavel Begunkov __u32 __pad1; 41bdb2c48eSPavel Begunkov }; 4217f2fe35SJens Axboe }; 437d67af2cSPavel Begunkov union { 442b188cc1SJens Axboe __u64 addr; /* pointer to buffer or iovecs */ 457d67af2cSPavel Begunkov __u64 splice_off_in; 46a5d2f99aSBreno Leitao struct { 47a5d2f99aSBreno Leitao __u32 level; 48a5d2f99aSBreno Leitao __u32 optname; 49a5d2f99aSBreno Leitao }; 507d67af2cSPavel Begunkov }; 512b188cc1SJens Axboe __u32 len; /* buffer size or number of iovecs */ 522b188cc1SJens Axboe union { 532b188cc1SJens Axboe __kernel_rwf_t rw_flags; 54c992fe29SChristoph Hellwig __u32 fsync_flags; 555769a351SJiufei Xue __u16 poll_events; /* compatibility */ 565769a351SJiufei Xue __u32 poll32_events; /* word-reversed for BE */ 575d17b4a4SJens Axboe __u32 sync_range_flags; 580fa03c62SJens Axboe __u32 msg_flags; 595262f567SJens Axboe __u32 timeout_flags; 6017f2fe35SJens Axboe __u32 accept_flags; 6162755e35SJens Axboe __u32 cancel_flags; 6215b71abeSJens Axboe __u32 open_flags; 63eddc7ef5SJens Axboe __u32 statx_flags; 644840e418SJens Axboe __u32 fadvise_advice; 657d67af2cSPavel Begunkov __u32 splice_flags; 6680a261fdSJens Axboe __u32 rename_flags; 6714a1143bSJens Axboe __u32 unlink_flags; 68cf30da90SDmitry Kadashev __u32 hardlink_flags; 69e9621e2bSStefan Roesch __u32 xattr_flags; 70e6130ebaSJens Axboe __u32 msg_ring_flags; 719cda70f6SAnuj Gupta __u32 uring_cmd_flags; 72f31ecf67SJens Axboe __u32 waitid_flags; 73194bb58cSJens Axboe __u32 futex_flags; 74dc18b89aSJens Axboe __u32 install_fd_flags; 75deb1e496SMing Lei __u32 nop_flags; 762b188cc1SJens Axboe }; 772b188cc1SJens Axboe __u64 user_data; /* data to be passed back at completion time */ 78ddf0322dSJens Axboe /* pack this to avoid bogus arm OABI complaints */ 79ddf0322dSJens Axboe union { 8075c6a039SJens Axboe /* index into fixed buffers, if used */ 8175c6a039SJens Axboe __u16 buf_index; 82ddf0322dSJens Axboe /* for grouped buffer selection */ 83ddf0322dSJens Axboe __u16 buf_group; 84ddf0322dSJens Axboe } __attribute__((packed)); 8575c6a039SJens Axboe /* personality to use, if used */ 8675c6a039SJens Axboe __u16 personality; 87b9445598SPavel Begunkov union { 887d67af2cSPavel Begunkov __s32 splice_fd_in; 89b9445598SPavel Begunkov __u32 file_index; 9011ed914bSDavid Wei __u32 zcrx_ifq_idx; 91a5d2f99aSBreno Leitao __u32 optlen; 9206a5464bSPavel Begunkov struct { 93092aeedbSPavel Begunkov __u16 addr_len; 94b48c312bSPavel Begunkov __u16 __pad3[1]; 9506a5464bSPavel Begunkov }; 96b9445598SPavel Begunkov }; 97ee692a21SJens Axboe union { 98ee692a21SJens Axboe struct { 99e9621e2bSStefan Roesch __u64 addr3; 100e9621e2bSStefan Roesch __u64 __pad2[1]; 101edafcceeSJens Axboe }; 10259a7d12aSAnuj Gupta struct { 10359a7d12aSAnuj Gupta __u64 attr_ptr; /* pointer to attribute information */ 10459a7d12aSAnuj Gupta __u64 attr_type_mask; /* bit mask of attributes */ 10559a7d12aSAnuj Gupta }; 106a5d2f99aSBreno Leitao __u64 optval; 107ebdeb7c0SJens Axboe /* 108ee692a21SJens Axboe * If the ring is initialized with IORING_SETUP_SQE128, then 109ee692a21SJens Axboe * this field is used for 80 bytes of arbitrary command data 110ebdeb7c0SJens Axboe */ 111ee692a21SJens Axboe __u8 cmd[0]; 112ee692a21SJens Axboe }; 1132b188cc1SJens Axboe }; 1142b188cc1SJens Axboe 11559a7d12aSAnuj Gupta /* sqe->attr_type_mask flags */ 11659a7d12aSAnuj Gupta #define IORING_RW_ATTR_FLAG_PI (1U << 0) 11759a7d12aSAnuj Gupta /* PI attribute information */ 11859a7d12aSAnuj Gupta struct io_uring_attr_pi { 11959a7d12aSAnuj Gupta __u16 flags; 12059a7d12aSAnuj Gupta __u16 app_tag; 12159a7d12aSAnuj Gupta __u32 len; 12259a7d12aSAnuj Gupta __u64 addr; 12359a7d12aSAnuj Gupta __u64 seed; 12459a7d12aSAnuj Gupta __u64 rsvd; 12559a7d12aSAnuj Gupta }; 12659a7d12aSAnuj Gupta 1271339f24bSJens Axboe /* 1281339f24bSJens Axboe * If sqe->file_index is set to this for opcodes that instantiate a new 1291339f24bSJens Axboe * direct descriptor (like openat/openat2/accept), then io_uring will allocate 1301339f24bSJens Axboe * an available direct descriptor instead of having the application pass one 1311339f24bSJens Axboe * in. The picked direct descriptor will be returned in cqe->res, or -ENFILE 1321339f24bSJens Axboe * if the space is full. 1331339f24bSJens Axboe */ 1341339f24bSJens Axboe #define IORING_FILE_INDEX_ALLOC (~0U) 1351339f24bSJens Axboe 1360f21a957SGabriel Krisman Bertazi enum io_uring_sqe_flags_bit { 1376b47ee6eSPavel Begunkov IOSQE_FIXED_FILE_BIT, 1386b47ee6eSPavel Begunkov IOSQE_IO_DRAIN_BIT, 1396b47ee6eSPavel Begunkov IOSQE_IO_LINK_BIT, 1406b47ee6eSPavel Begunkov IOSQE_IO_HARDLINK_BIT, 1416b47ee6eSPavel Begunkov IOSQE_ASYNC_BIT, 142bcda7baaSJens Axboe IOSQE_BUFFER_SELECT_BIT, 14304c76b41SPavel Begunkov IOSQE_CQE_SKIP_SUCCESS_BIT, 1446b47ee6eSPavel Begunkov }; 1456b47ee6eSPavel Begunkov 146def596e9SJens Axboe /* 1476b06314cSJens Axboe * sqe->flags 1486b06314cSJens Axboe */ 1496b47ee6eSPavel Begunkov /* use fixed fileset */ 1506b47ee6eSPavel Begunkov #define IOSQE_FIXED_FILE (1U << IOSQE_FIXED_FILE_BIT) 1516b47ee6eSPavel Begunkov /* issue after inflight IO */ 1526b47ee6eSPavel Begunkov #define IOSQE_IO_DRAIN (1U << IOSQE_IO_DRAIN_BIT) 1536b47ee6eSPavel Begunkov /* links next sqe */ 1546b47ee6eSPavel Begunkov #define IOSQE_IO_LINK (1U << IOSQE_IO_LINK_BIT) 1556b47ee6eSPavel Begunkov /* like LINK, but stronger */ 1566b47ee6eSPavel Begunkov #define IOSQE_IO_HARDLINK (1U << IOSQE_IO_HARDLINK_BIT) 1576b47ee6eSPavel Begunkov /* always go async */ 1586b47ee6eSPavel Begunkov #define IOSQE_ASYNC (1U << IOSQE_ASYNC_BIT) 159bcda7baaSJens Axboe /* select buffer from sqe->buf_group */ 160bcda7baaSJens Axboe #define IOSQE_BUFFER_SELECT (1U << IOSQE_BUFFER_SELECT_BIT) 16104c76b41SPavel Begunkov /* don't post CQE if request succeeded */ 16204c76b41SPavel Begunkov #define IOSQE_CQE_SKIP_SUCCESS (1U << IOSQE_CQE_SKIP_SUCCESS_BIT) 1636b06314cSJens Axboe 1646b06314cSJens Axboe /* 165def596e9SJens Axboe * io_uring_setup() flags 166def596e9SJens Axboe */ 167def596e9SJens Axboe #define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */ 1686c271ce2SJens Axboe #define IORING_SETUP_SQPOLL (1U << 1) /* SQ poll thread */ 1696c271ce2SJens Axboe #define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */ 17033a107f0SJens Axboe #define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */ 1718110c1a6SJens Axboe #define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */ 17224369c2eSPavel Begunkov #define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */ 1737e84e1c7SStefano Garzarella #define IORING_SETUP_R_DISABLED (1U << 6) /* start with ring disabled */ 174bcbb7bf6SJens Axboe #define IORING_SETUP_SUBMIT_ALL (1U << 7) /* continue submit on error */ 175e1169f06SJens Axboe /* 176e1169f06SJens Axboe * Cooperative task running. When requests complete, they often require 177e1169f06SJens Axboe * forcing the submitter to transition to the kernel to complete. If this 178e1169f06SJens Axboe * flag is set, work will be done when the task transitions anyway, rather 179e1169f06SJens Axboe * than force an inter-processor interrupt reschedule. This avoids interrupting 180e1169f06SJens Axboe * a task running in userspace, and saves an IPI. 181e1169f06SJens Axboe */ 182e1169f06SJens Axboe #define IORING_SETUP_COOP_TASKRUN (1U << 8) 183ef060ea9SJens Axboe /* 184ef060ea9SJens Axboe * If COOP_TASKRUN is set, get notified if task work is available for 185ef060ea9SJens Axboe * running and a kernel transition would be needed to run it. This sets 186ef060ea9SJens Axboe * IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN. 187ef060ea9SJens Axboe */ 188ef060ea9SJens Axboe #define IORING_SETUP_TASKRUN_FLAG (1U << 9) 189ebdeb7c0SJens Axboe #define IORING_SETUP_SQE128 (1U << 10) /* SQEs are 128 byte */ 1907a51e5b4SStefan Roesch #define IORING_SETUP_CQE32 (1U << 11) /* CQEs are 32 byte */ 19197bbdc06SPavel Begunkov /* 19297bbdc06SPavel Begunkov * Only one task is allowed to submit requests 19397bbdc06SPavel Begunkov */ 19497bbdc06SPavel Begunkov #define IORING_SETUP_SINGLE_ISSUER (1U << 12) 195ebdeb7c0SJens Axboe 196c0e0d6baSDylan Yudaken /* 197c0e0d6baSDylan Yudaken * Defer running task work to get events. 198c0e0d6baSDylan Yudaken * Rather than running bits of task work whenever the task transitions 199c0e0d6baSDylan Yudaken * try to do it just before it is needed. 200c0e0d6baSDylan Yudaken */ 201c0e0d6baSDylan Yudaken #define IORING_SETUP_DEFER_TASKRUN (1U << 13) 202c0e0d6baSDylan Yudaken 20303d89a2dSJens Axboe /* 20403d89a2dSJens Axboe * Application provides the memory for the rings 20503d89a2dSJens Axboe */ 20603d89a2dSJens Axboe #define IORING_SETUP_NO_MMAP (1U << 14) 20703d89a2dSJens Axboe 2086e76ac59SJosh Triplett /* 2096e76ac59SJosh Triplett * Register the ring fd in itself for use with 2106e76ac59SJosh Triplett * IORING_REGISTER_USE_REGISTERED_RING; return a registered fd index rather 2116e76ac59SJosh Triplett * than an fd. 2126e76ac59SJosh Triplett */ 2136e76ac59SJosh Triplett #define IORING_SETUP_REGISTERED_FD_ONLY (1U << 15) 2146e76ac59SJosh Triplett 2152af89abdSPavel Begunkov /* 2162af89abdSPavel Begunkov * Removes indirection through the SQ index array. 2172af89abdSPavel Begunkov */ 2182af89abdSPavel Begunkov #define IORING_SETUP_NO_SQARRAY (1U << 16) 2192af89abdSPavel Begunkov 22001ee194dShexue /* Use hybrid poll in iopoll process */ 22101ee194dShexue #define IORING_SETUP_HYBRID_IOPOLL (1U << 17) 22201ee194dShexue 223cc51eaa8SDylan Yudaken enum io_uring_op { 2249e3aa61aSJens Axboe IORING_OP_NOP, 2259e3aa61aSJens Axboe IORING_OP_READV, 2269e3aa61aSJens Axboe IORING_OP_WRITEV, 2279e3aa61aSJens Axboe IORING_OP_FSYNC, 2289e3aa61aSJens Axboe IORING_OP_READ_FIXED, 2299e3aa61aSJens Axboe IORING_OP_WRITE_FIXED, 2309e3aa61aSJens Axboe IORING_OP_POLL_ADD, 2319e3aa61aSJens Axboe IORING_OP_POLL_REMOVE, 2329e3aa61aSJens Axboe IORING_OP_SYNC_FILE_RANGE, 2339e3aa61aSJens Axboe IORING_OP_SENDMSG, 2349e3aa61aSJens Axboe IORING_OP_RECVMSG, 2359e3aa61aSJens Axboe IORING_OP_TIMEOUT, 2369e3aa61aSJens Axboe IORING_OP_TIMEOUT_REMOVE, 2379e3aa61aSJens Axboe IORING_OP_ACCEPT, 2389e3aa61aSJens Axboe IORING_OP_ASYNC_CANCEL, 2399e3aa61aSJens Axboe IORING_OP_LINK_TIMEOUT, 2409e3aa61aSJens Axboe IORING_OP_CONNECT, 241d63d1b5eSJens Axboe IORING_OP_FALLOCATE, 24215b71abeSJens Axboe IORING_OP_OPENAT, 243b5dba59eSJens Axboe IORING_OP_CLOSE, 244d9808cebSPavel Begunkov IORING_OP_FILES_UPDATE, 245eddc7ef5SJens Axboe IORING_OP_STATX, 2463a6820f2SJens Axboe IORING_OP_READ, 2473a6820f2SJens Axboe IORING_OP_WRITE, 2484840e418SJens Axboe IORING_OP_FADVISE, 249c1ca757bSJens Axboe IORING_OP_MADVISE, 250fddafaceSJens Axboe IORING_OP_SEND, 251fddafaceSJens Axboe IORING_OP_RECV, 252cebdb986SJens Axboe IORING_OP_OPENAT2, 2533e4827b0SJens Axboe IORING_OP_EPOLL_CTL, 2547d67af2cSPavel Begunkov IORING_OP_SPLICE, 255ddf0322dSJens Axboe IORING_OP_PROVIDE_BUFFERS, 256067524e9SJens Axboe IORING_OP_REMOVE_BUFFERS, 257f2a8d5c7SPavel Begunkov IORING_OP_TEE, 25836f4fa68SJens Axboe IORING_OP_SHUTDOWN, 25980a261fdSJens Axboe IORING_OP_RENAMEAT, 26014a1143bSJens Axboe IORING_OP_UNLINKAT, 261e34a02dcSDmitry Kadashev IORING_OP_MKDIRAT, 2627a8721f8SDmitry Kadashev IORING_OP_SYMLINKAT, 263cf30da90SDmitry Kadashev IORING_OP_LINKAT, 2644f57f06cSJens Axboe IORING_OP_MSG_RING, 265e9621e2bSStefan Roesch IORING_OP_FSETXATTR, 266e9621e2bSStefan Roesch IORING_OP_SETXATTR, 267a56834e0SStefan Roesch IORING_OP_FGETXATTR, 268a56834e0SStefan Roesch IORING_OP_GETXATTR, 2691374e08eSJens Axboe IORING_OP_SOCKET, 270ee692a21SJens Axboe IORING_OP_URING_CMD, 271b48c312bSPavel Begunkov IORING_OP_SEND_ZC, 272493108d9SPavel Begunkov IORING_OP_SENDMSG_ZC, 273fc68fcdaSJens Axboe IORING_OP_READ_MULTISHOT, 274f31ecf67SJens Axboe IORING_OP_WAITID, 275194bb58cSJens Axboe IORING_OP_FUTEX_WAIT, 276194bb58cSJens Axboe IORING_OP_FUTEX_WAKE, 2778f350194SJens Axboe IORING_OP_FUTEX_WAITV, 278dc18b89aSJens Axboe IORING_OP_FIXED_FD_INSTALL, 279b4bb1900STony Solomonik IORING_OP_FTRUNCATE, 2807481fd93SGabriel Krisman Bertazi IORING_OP_BIND, 281ff140cc8SGabriel Krisman Bertazi IORING_OP_LISTEN, 28211ed914bSDavid Wei IORING_OP_RECV_ZC, 28319f7e942SJens Axboe IORING_OP_EPOLL_WAIT, 284bdabba04SPavel Begunkov IORING_OP_READV_FIXED, 285bdabba04SPavel Begunkov IORING_OP_WRITEV_FIXED, 2869e3aa61aSJens Axboe 2879e3aa61aSJens Axboe /* this goes last, obviously */ 2889e3aa61aSJens Axboe IORING_OP_LAST, 2899e3aa61aSJens Axboe }; 290c992fe29SChristoph Hellwig 291c992fe29SChristoph Hellwig /* 292528ce678SMing Lei * sqe->uring_cmd_flags top 8bits aren't available for userspace 2936dcabcd3SJens Axboe * IORING_URING_CMD_FIXED use registered buffer; pass this flag 2949cda70f6SAnuj Gupta * along with setting sqe->buf_index. 2959cda70f6SAnuj Gupta */ 2969cda70f6SAnuj Gupta #define IORING_URING_CMD_FIXED (1U << 0) 297528ce678SMing Lei #define IORING_URING_CMD_MASK IORING_URING_CMD_FIXED 2989cda70f6SAnuj Gupta 2999cda70f6SAnuj Gupta 3009cda70f6SAnuj Gupta /* 301c992fe29SChristoph Hellwig * sqe->fsync_flags 302c992fe29SChristoph Hellwig */ 303c992fe29SChristoph Hellwig #define IORING_FSYNC_DATASYNC (1U << 0) 3042b188cc1SJens Axboe 3052b188cc1SJens Axboe /* 306a41525abSJens Axboe * sqe->timeout_flags 307a41525abSJens Axboe */ 308a41525abSJens Axboe #define IORING_TIMEOUT_ABS (1U << 0) 3099c8e11b3SPavel Begunkov #define IORING_TIMEOUT_UPDATE (1U << 1) 31050c1df2bSJens Axboe #define IORING_TIMEOUT_BOOTTIME (1U << 2) 31150c1df2bSJens Axboe #define IORING_TIMEOUT_REALTIME (1U << 3) 312f1042b6cSPavel Begunkov #define IORING_LINK_TIMEOUT_UPDATE (1U << 4) 3136224590dSPavel Begunkov #define IORING_TIMEOUT_ETIME_SUCCESS (1U << 5) 314ea97f6c8SDavid Wei #define IORING_TIMEOUT_MULTISHOT (1U << 6) 31550c1df2bSJens Axboe #define IORING_TIMEOUT_CLOCK_MASK (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME) 316f1042b6cSPavel Begunkov #define IORING_TIMEOUT_UPDATE_MASK (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE) 317a41525abSJens Axboe /* 3187d67af2cSPavel Begunkov * sqe->splice_flags 3197d67af2cSPavel Begunkov * extends splice(2) flags 3207d67af2cSPavel Begunkov */ 3217d67af2cSPavel Begunkov #define SPLICE_F_FD_IN_FIXED (1U << 31) /* the last bit of __u32 */ 3227d67af2cSPavel Begunkov 3237d67af2cSPavel Begunkov /* 32488e41cf9SJens Axboe * POLL_ADD flags. Note that since sqe->poll_events is the flag space, the 32588e41cf9SJens Axboe * command flags for POLL_ADD are stored in sqe->len. 32688e41cf9SJens Axboe * 32788e41cf9SJens Axboe * IORING_POLL_ADD_MULTI Multishot poll. Sets IORING_CQE_F_MORE if 32888e41cf9SJens Axboe * the poll handler will continue to report 32988e41cf9SJens Axboe * CQEs on behalf of the same SQE. 330b69de288SJens Axboe * 331b69de288SJens Axboe * IORING_POLL_UPDATE Update existing poll request, matching 332b69de288SJens Axboe * sqe->addr as the old user_data field. 333b9ba8a44SJens Axboe * 334b9ba8a44SJens Axboe * IORING_POLL_LEVEL Level triggered poll. 33588e41cf9SJens Axboe */ 33688e41cf9SJens Axboe #define IORING_POLL_ADD_MULTI (1U << 0) 337b69de288SJens Axboe #define IORING_POLL_UPDATE_EVENTS (1U << 1) 338b69de288SJens Axboe #define IORING_POLL_UPDATE_USER_DATA (1U << 2) 339b9ba8a44SJens Axboe #define IORING_POLL_ADD_LEVEL (1U << 3) 34088e41cf9SJens Axboe 34188e41cf9SJens Axboe /* 3428e29da69SJens Axboe * ASYNC_CANCEL flags. 3438e29da69SJens Axboe * 3448e29da69SJens Axboe * IORING_ASYNC_CANCEL_ALL Cancel all requests that match the given key 3454bf94615SJens Axboe * IORING_ASYNC_CANCEL_FD Key off 'fd' for cancelation rather than the 3464bf94615SJens Axboe * request 'user_data' 347970f256eSJens Axboe * IORING_ASYNC_CANCEL_ANY Match any request 3487d8ca725SJens Axboe * IORING_ASYNC_CANCEL_FD_FIXED 'fd' passed in is a fixed descriptor 3498165b566SJens Axboe * IORING_ASYNC_CANCEL_USERDATA Match on user_data, default for no other key 350d7b8b079SJens Axboe * IORING_ASYNC_CANCEL_OP Match request based on opcode 3518e29da69SJens Axboe */ 3528e29da69SJens Axboe #define IORING_ASYNC_CANCEL_ALL (1U << 0) 3534bf94615SJens Axboe #define IORING_ASYNC_CANCEL_FD (1U << 1) 354970f256eSJens Axboe #define IORING_ASYNC_CANCEL_ANY (1U << 2) 3557d8ca725SJens Axboe #define IORING_ASYNC_CANCEL_FD_FIXED (1U << 3) 3568165b566SJens Axboe #define IORING_ASYNC_CANCEL_USERDATA (1U << 4) 357d7b8b079SJens Axboe #define IORING_ASYNC_CANCEL_OP (1U << 5) 3588e29da69SJens Axboe 3598e29da69SJens Axboe /* 36029c1ac23SPavel Begunkov * send/sendmsg and recv/recvmsg flags (sqe->ioprio) 3610455d4ccSJens Axboe * 3620455d4ccSJens Axboe * IORING_RECVSEND_POLL_FIRST If set, instead of first attempting to send 3630455d4ccSJens Axboe * or receive and arm poll if that yields an 3640455d4ccSJens Axboe * -EAGAIN result, arm poll upfront and skip 3650455d4ccSJens Axboe * the initial transfer attempt. 366b3fdea6eSDylan Yudaken * 367b3fdea6eSDylan Yudaken * IORING_RECV_MULTISHOT Multishot recv. Sets IORING_CQE_F_MORE if 368b3fdea6eSDylan Yudaken * the handler will continue to report 369b3fdea6eSDylan Yudaken * CQEs on behalf of the same SQE. 37010c7d33eSPavel Begunkov * 37110c7d33eSPavel Begunkov * IORING_RECVSEND_FIXED_BUF Use registered buffers, the index is stored in 37210c7d33eSPavel Begunkov * the buf_index field. 373e307e669SStefan Metzmacher * 374e307e669SStefan Metzmacher * IORING_SEND_ZC_REPORT_USAGE 375e307e669SStefan Metzmacher * If set, SEND[MSG]_ZC should report 376e307e669SStefan Metzmacher * the zerocopy usage in cqe.res 377e307e669SStefan Metzmacher * for the IORING_CQE_F_NOTIF cqe. 378e307e669SStefan Metzmacher * 0 is reported if zerocopy was actually possible. 379e307e669SStefan Metzmacher * IORING_NOTIF_USAGE_ZC_COPIED if data was copied 380e307e669SStefan Metzmacher * (at least partially). 381a05d1f62SJens Axboe * 3822f9c9515SJens Axboe * IORING_RECVSEND_BUNDLE Used with IOSQE_BUFFER_SELECT. If set, send or 3832f9c9515SJens Axboe * recv will grab as many buffers from the buffer 3842f9c9515SJens Axboe * group ID given and send them all. The completion 3852f9c9515SJens Axboe * result will be the number of buffers send, with 3862f9c9515SJens Axboe * the starting buffer ID in cqe->flags as per 3872f9c9515SJens Axboe * usual for provided buffer usage. The buffers 3881fc61eeeSJens Axboe * will be contiguous from the starting buffer ID. 3890455d4ccSJens Axboe */ 3900455d4ccSJens Axboe #define IORING_RECVSEND_POLL_FIRST (1U << 0) 391b3fdea6eSDylan Yudaken #define IORING_RECV_MULTISHOT (1U << 1) 39210c7d33eSPavel Begunkov #define IORING_RECVSEND_FIXED_BUF (1U << 2) 393e307e669SStefan Metzmacher #define IORING_SEND_ZC_REPORT_USAGE (1U << 3) 394a05d1f62SJens Axboe #define IORING_RECVSEND_BUNDLE (1U << 4) 395e307e669SStefan Metzmacher 396e307e669SStefan Metzmacher /* 397e307e669SStefan Metzmacher * cqe.res for IORING_CQE_F_NOTIF if 398e307e669SStefan Metzmacher * IORING_SEND_ZC_REPORT_USAGE was requested 399e307e669SStefan Metzmacher * 400e307e669SStefan Metzmacher * It should be treated as a flag, all other 401e307e669SStefan Metzmacher * bits of cqe.res should be treated as reserved! 402e307e669SStefan Metzmacher */ 403e307e669SStefan Metzmacher #define IORING_NOTIF_USAGE_ZC_COPIED (1U << 31) 4040455d4ccSJens Axboe 4050455d4ccSJens Axboe /* 406390ed29bSHao Xu * accept flags stored in sqe->ioprio 407390ed29bSHao Xu */ 408390ed29bSHao Xu #define IORING_ACCEPT_MULTISHOT (1U << 0) 4097dcc758cSJens Axboe #define IORING_ACCEPT_DONTWAIT (1U << 1) 410d3da8e98SJens Axboe #define IORING_ACCEPT_POLL_FIRST (1U << 2) 411390ed29bSHao Xu 412390ed29bSHao Xu /* 413e6130ebaSJens Axboe * IORING_OP_MSG_RING command types, stored in sqe->addr 414e6130ebaSJens Axboe */ 4150f21a957SGabriel Krisman Bertazi enum io_uring_msg_ring_flags { 416e6130ebaSJens Axboe IORING_MSG_DATA, /* pass sqe->len as 'res' and off as user_data */ 417e6130ebaSJens Axboe IORING_MSG_SEND_FD, /* send a registered fd to another ring */ 418e6130ebaSJens Axboe }; 419e6130ebaSJens Axboe 420e6130ebaSJens Axboe /* 421e6130ebaSJens Axboe * IORING_OP_MSG_RING flags (sqe->msg_ring_flags) 422e6130ebaSJens Axboe * 423e6130ebaSJens Axboe * IORING_MSG_RING_CQE_SKIP Don't post a CQE to the target ring. Not 424e6130ebaSJens Axboe * applicable for IORING_MSG_DATA, obviously. 425e6130ebaSJens Axboe */ 426e6130ebaSJens Axboe #define IORING_MSG_RING_CQE_SKIP (1U << 0) 427cbeb47a7SBreno Leitao /* Pass through the flags from sqe->file_index to cqe->flags */ 428cbeb47a7SBreno Leitao #define IORING_MSG_RING_FLAGS_PASS (1U << 1) 429e6130ebaSJens Axboe 430e6130ebaSJens Axboe /* 431dc18b89aSJens Axboe * IORING_OP_FIXED_FD_INSTALL flags (sqe->install_fd_flags) 432dc18b89aSJens Axboe * 433dc18b89aSJens Axboe * IORING_FIXED_FD_NO_CLOEXEC Don't mark the fd as O_CLOEXEC 434dc18b89aSJens Axboe */ 435dc18b89aSJens Axboe #define IORING_FIXED_FD_NO_CLOEXEC (1U << 0) 436dc18b89aSJens Axboe 437dc18b89aSJens Axboe /* 438deb1e496SMing Lei * IORING_OP_NOP flags (sqe->nop_flags) 439deb1e496SMing Lei * 440deb1e496SMing Lei * IORING_NOP_INJECT_RESULT Inject result from sqe->result 441deb1e496SMing Lei */ 442deb1e496SMing Lei #define IORING_NOP_INJECT_RESULT (1U << 0) 443a85f3105SJens Axboe #define IORING_NOP_FILE (1U << 1) 444a85f3105SJens Axboe #define IORING_NOP_FIXED_FILE (1U << 2) 445a85f3105SJens Axboe #define IORING_NOP_FIXED_BUFFER (1U << 3) 446deb1e496SMing Lei 447deb1e496SMing Lei /* 4482b188cc1SJens Axboe * IO completion data structure (Completion Queue Entry) 4492b188cc1SJens Axboe */ 4502b188cc1SJens Axboe struct io_uring_cqe { 4511fc2ac42SCaleb Sander Mateos __u64 user_data; /* sqe->user_data value passed back */ 4522b188cc1SJens Axboe __s32 res; /* result code for this event */ 4532b188cc1SJens Axboe __u32 flags; 4547a51e5b4SStefan Roesch 4557a51e5b4SStefan Roesch /* 4567a51e5b4SStefan Roesch * If the ring is initialized with IORING_SETUP_CQE32, then this field 4577a51e5b4SStefan Roesch * contains 16-bytes of padding, doubling the size of the CQE. 4587a51e5b4SStefan Roesch */ 4597a51e5b4SStefan Roesch __u64 big_cqe[]; 4602b188cc1SJens Axboe }; 4612b188cc1SJens Axboe 4622b188cc1SJens Axboe /* 463bcda7baaSJens Axboe * cqe->flags 464bcda7baaSJens Axboe * 465bcda7baaSJens Axboe * IORING_CQE_F_BUFFER If set, the upper 16 bits are the buffer ID 46688e41cf9SJens Axboe * IORING_CQE_F_MORE If set, parent SQE will generate more CQE entries 467f548a12eSJens Axboe * IORING_CQE_F_SOCK_NONEMPTY If set, more data to read after socket recv 468b48c312bSPavel Begunkov * IORING_CQE_F_NOTIF Set for notification CQEs. Can be used to distinct 469b48c312bSPavel Begunkov * them from sends. 470ae98dbf4SJens Axboe * IORING_CQE_F_BUF_MORE If set, the buffer ID set in the completion will get 471ae98dbf4SJens Axboe * more completions. In other words, the buffer is being 472ae98dbf4SJens Axboe * partially consumed, and will be used by the kernel for 473ae98dbf4SJens Axboe * more completions. This is only set for buffers used via 474ae98dbf4SJens Axboe * the incremental buffer consumption, as provided by 475ae98dbf4SJens Axboe * a ring buffer setup with IOU_PBUF_RING_INC. For any 476ae98dbf4SJens Axboe * other provided buffer type, all completions with a 477ae98dbf4SJens Axboe * buffer passed back is automatically returned to the 478ae98dbf4SJens Axboe * application. 479bcda7baaSJens Axboe */ 480bcda7baaSJens Axboe #define IORING_CQE_F_BUFFER (1U << 0) 48188e41cf9SJens Axboe #define IORING_CQE_F_MORE (1U << 1) 482f548a12eSJens Axboe #define IORING_CQE_F_SOCK_NONEMPTY (1U << 2) 483b48c312bSPavel Begunkov #define IORING_CQE_F_NOTIF (1U << 3) 484ae98dbf4SJens Axboe #define IORING_CQE_F_BUF_MORE (1U << 4) 485bcda7baaSJens Axboe 4860f21a957SGabriel Krisman Bertazi #define IORING_CQE_BUFFER_SHIFT 16 487bcda7baaSJens Axboe 488bcda7baaSJens Axboe /* 4892b188cc1SJens Axboe * Magic offsets for the application to mmap the data it needs 4902b188cc1SJens Axboe */ 4912b188cc1SJens Axboe #define IORING_OFF_SQ_RING 0ULL 4922b188cc1SJens Axboe #define IORING_OFF_CQ_RING 0x8000000ULL 4932b188cc1SJens Axboe #define IORING_OFF_SQES 0x10000000ULL 494c56e022cSJens Axboe #define IORING_OFF_PBUF_RING 0x80000000ULL 495c56e022cSJens Axboe #define IORING_OFF_PBUF_SHIFT 16 496c56e022cSJens Axboe #define IORING_OFF_MMAP_MASK 0xf8000000ULL 4972b188cc1SJens Axboe 4982b188cc1SJens Axboe /* 4992b188cc1SJens Axboe * Filled with the offset for mmap(2) 5002b188cc1SJens Axboe */ 5012b188cc1SJens Axboe struct io_sqring_offsets { 5022b188cc1SJens Axboe __u32 head; 5032b188cc1SJens Axboe __u32 tail; 5042b188cc1SJens Axboe __u32 ring_mask; 5052b188cc1SJens Axboe __u32 ring_entries; 5062b188cc1SJens Axboe __u32 flags; 5072b188cc1SJens Axboe __u32 dropped; 5082b188cc1SJens Axboe __u32 array; 5092b188cc1SJens Axboe __u32 resv1; 51003d89a2dSJens Axboe __u64 user_addr; 5112b188cc1SJens Axboe }; 5122b188cc1SJens Axboe 5136c271ce2SJens Axboe /* 5146c271ce2SJens Axboe * sq_ring->flags 5156c271ce2SJens Axboe */ 5166c271ce2SJens Axboe #define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */ 5176d5f9049SXiaoguang Wang #define IORING_SQ_CQ_OVERFLOW (1U << 1) /* CQ ring is overflown */ 518ef060ea9SJens Axboe #define IORING_SQ_TASKRUN (1U << 2) /* task should enter the kernel */ 5196c271ce2SJens Axboe 5202b188cc1SJens Axboe struct io_cqring_offsets { 5212b188cc1SJens Axboe __u32 head; 5222b188cc1SJens Axboe __u32 tail; 5232b188cc1SJens Axboe __u32 ring_mask; 5242b188cc1SJens Axboe __u32 ring_entries; 5252b188cc1SJens Axboe __u32 overflow; 5262b188cc1SJens Axboe __u32 cqes; 5270d9b5b3aSStefano Garzarella __u32 flags; 5280d9b5b3aSStefano Garzarella __u32 resv1; 52903d89a2dSJens Axboe __u64 user_addr; 5302b188cc1SJens Axboe }; 5312b188cc1SJens Axboe 5322b188cc1SJens Axboe /* 5337e55a19cSStefano Garzarella * cq_ring->flags 5347e55a19cSStefano Garzarella */ 5357e55a19cSStefano Garzarella 5367e55a19cSStefano Garzarella /* disable eventfd notifications */ 5377e55a19cSStefano Garzarella #define IORING_CQ_EVENTFD_DISABLED (1U << 0) 5387e55a19cSStefano Garzarella 5397e55a19cSStefano Garzarella /* 5402b188cc1SJens Axboe * io_uring_enter(2) flags 5412b188cc1SJens Axboe */ 5422b188cc1SJens Axboe #define IORING_ENTER_GETEVENTS (1U << 0) 5436c271ce2SJens Axboe #define IORING_ENTER_SQ_WAKEUP (1U << 1) 54490554200SJens Axboe #define IORING_ENTER_SQ_WAIT (1U << 2) 545c73ebb68SHao Xu #define IORING_ENTER_EXT_ARG (1U << 3) 546e7a6c00dSJens Axboe #define IORING_ENTER_REGISTERED_RING (1U << 4) 547d29cb372SPavel Begunkov #define IORING_ENTER_ABS_TIMER (1U << 5) 548aa00f67aSJens Axboe #define IORING_ENTER_EXT_ARG_REG (1U << 6) 54907754bfdSJens Axboe #define IORING_ENTER_NO_IOWAIT (1U << 7) 5502b188cc1SJens Axboe 5512b188cc1SJens Axboe /* 5522b188cc1SJens Axboe * Passed in for io_uring_setup(2). Copied back with updated info on success 5532b188cc1SJens Axboe */ 5542b188cc1SJens Axboe struct io_uring_params { 5552b188cc1SJens Axboe __u32 sq_entries; 5562b188cc1SJens Axboe __u32 cq_entries; 5572b188cc1SJens Axboe __u32 flags; 5586c271ce2SJens Axboe __u32 sq_thread_cpu; 5596c271ce2SJens Axboe __u32 sq_thread_idle; 560ac90f249SJens Axboe __u32 features; 56124369c2eSPavel Begunkov __u32 wq_fd; 56224369c2eSPavel Begunkov __u32 resv[3]; 5632b188cc1SJens Axboe struct io_sqring_offsets sq_off; 5642b188cc1SJens Axboe struct io_cqring_offsets cq_off; 5652b188cc1SJens Axboe }; 5662b188cc1SJens Axboe 567edafcceeSJens Axboe /* 568ac90f249SJens Axboe * io_uring_params->features flags 569ac90f249SJens Axboe */ 570ac90f249SJens Axboe #define IORING_FEAT_SINGLE_MMAP (1U << 0) 5711d7bb1d5SJens Axboe #define IORING_FEAT_NODROP (1U << 1) 572da8c9690SJens Axboe #define IORING_FEAT_SUBMIT_STABLE (1U << 2) 573ba04291eSJens Axboe #define IORING_FEAT_RW_CUR_POS (1U << 3) 574cccf0ee8SJens Axboe #define IORING_FEAT_CUR_PERSONALITY (1U << 4) 575d7718a9dSJens Axboe #define IORING_FEAT_FAST_POLL (1U << 5) 5765769a351SJiufei Xue #define IORING_FEAT_POLL_32BITS (1U << 6) 57728cea78aSJens Axboe #define IORING_FEAT_SQPOLL_NONFIXED (1U << 7) 578c73ebb68SHao Xu #define IORING_FEAT_EXT_ARG (1U << 8) 5791c0aa1faSJens Axboe #define IORING_FEAT_NATIVE_WORKERS (1U << 9) 5809690557eSPavel Begunkov #define IORING_FEAT_RSRC_TAGS (1U << 10) 58104c76b41SPavel Begunkov #define IORING_FEAT_CQE_SKIP (1U << 11) 582c4212f3eSJens Axboe #define IORING_FEAT_LINKED_FILE (1U << 12) 5837d3fd88dSJosh Triplett #define IORING_FEAT_REG_REG_RING (1U << 13) 5842f9c9515SJens Axboe #define IORING_FEAT_RECVSEND_BUNDLE (1U << 14) 5857ed9e09eSJens Axboe #define IORING_FEAT_MIN_TIMEOUT (1U << 15) 58694d57442SAnuj Gupta #define IORING_FEAT_RW_ATTR (1U << 16) 58707754bfdSJens Axboe #define IORING_FEAT_NO_IOWAIT (1U << 17) 588ac90f249SJens Axboe 589ac90f249SJens Axboe /* 590edafcceeSJens Axboe * io_uring_register(2) opcodes and arguments 591edafcceeSJens Axboe */ 5920f21a957SGabriel Krisman Bertazi enum io_uring_register_op { 5939d4a75efSStefano Garzarella IORING_REGISTER_BUFFERS = 0, 5949d4a75efSStefano Garzarella IORING_UNREGISTER_BUFFERS = 1, 5959d4a75efSStefano Garzarella IORING_REGISTER_FILES = 2, 5969d4a75efSStefano Garzarella IORING_UNREGISTER_FILES = 3, 5979d4a75efSStefano Garzarella IORING_REGISTER_EVENTFD = 4, 5989d4a75efSStefano Garzarella IORING_UNREGISTER_EVENTFD = 5, 5999d4a75efSStefano Garzarella IORING_REGISTER_FILES_UPDATE = 6, 6009d4a75efSStefano Garzarella IORING_REGISTER_EVENTFD_ASYNC = 7, 6019d4a75efSStefano Garzarella IORING_REGISTER_PROBE = 8, 6029d4a75efSStefano Garzarella IORING_REGISTER_PERSONALITY = 9, 6039d4a75efSStefano Garzarella IORING_UNREGISTER_PERSONALITY = 10, 60421b55dbcSStefano Garzarella IORING_REGISTER_RESTRICTIONS = 11, 6057e84e1c7SStefano Garzarella IORING_REGISTER_ENABLE_RINGS = 12, 606992da01aSPavel Begunkov 607992da01aSPavel Begunkov /* extended with tagging */ 608992da01aSPavel Begunkov IORING_REGISTER_FILES2 = 13, 609992da01aSPavel Begunkov IORING_REGISTER_FILES_UPDATE2 = 14, 610992da01aSPavel Begunkov IORING_REGISTER_BUFFERS2 = 15, 611992da01aSPavel Begunkov IORING_REGISTER_BUFFERS_UPDATE = 16, 6129d4a75efSStefano Garzarella 613fe76421dSJens Axboe /* set/clear io-wq thread affinities */ 614fe76421dSJens Axboe IORING_REGISTER_IOWQ_AFF = 17, 615fe76421dSJens Axboe IORING_UNREGISTER_IOWQ_AFF = 18, 616fe76421dSJens Axboe 617dd47c104SEugene Syromiatnikov /* set/get max number of io-wq workers */ 6182e480058SJens Axboe IORING_REGISTER_IOWQ_MAX_WORKERS = 19, 6192e480058SJens Axboe 620e7a6c00dSJens Axboe /* register/unregister io_uring fd with the ring */ 621e7a6c00dSJens Axboe IORING_REGISTER_RING_FDS = 20, 622e7a6c00dSJens Axboe IORING_UNREGISTER_RING_FDS = 21, 623e7a6c00dSJens Axboe 624c7fb1942SJens Axboe /* register ring based provide buffer group */ 625c7fb1942SJens Axboe IORING_REGISTER_PBUF_RING = 22, 626c7fb1942SJens Axboe IORING_UNREGISTER_PBUF_RING = 23, 627c7fb1942SJens Axboe 62878a861b9SJens Axboe /* sync cancelation API */ 62978a861b9SJens Axboe IORING_REGISTER_SYNC_CANCEL = 24, 63078a861b9SJens Axboe 6316e73dffbSPavel Begunkov /* register a range of fixed file slots for automatic slot allocation */ 6326e73dffbSPavel Begunkov IORING_REGISTER_FILE_ALLOC_RANGE = 25, 6336e73dffbSPavel Begunkov 634d293b1a8SJens Axboe /* return status information for a buffer group */ 635d293b1a8SJens Axboe IORING_REGISTER_PBUF_STATUS = 26, 636d293b1a8SJens Axboe 637ef1186c1SStefan Roesch /* set/clear busy poll settings */ 638ef1186c1SStefan Roesch IORING_REGISTER_NAPI = 27, 639ef1186c1SStefan Roesch IORING_UNREGISTER_NAPI = 28, 640ef1186c1SStefan Roesch 6412b8e976bSPavel Begunkov IORING_REGISTER_CLOCK = 29, 6422b8e976bSPavel Begunkov 643636119afSJens Axboe /* clone registered buffers from source ring to current ring */ 644636119afSJens Axboe IORING_REGISTER_CLONE_BUFFERS = 30, 6457cc2a6eaSJens Axboe 646a3771321SJens Axboe /* send MSG_RING without having a ring */ 647a3771321SJens Axboe IORING_REGISTER_SEND_MSG_RING = 31, 648a3771321SJens Axboe 6496f377873SDavid Wei /* register a netdev hw rx queue for zerocopy */ 6506f377873SDavid Wei IORING_REGISTER_ZCRX_IFQ = 32, 65179cfe9e5SJens Axboe 65279cfe9e5SJens Axboe /* resize CQ ring */ 65379cfe9e5SJens Axboe IORING_REGISTER_RESIZE_RINGS = 33, 65479cfe9e5SJens Axboe 65593238e66SPavel Begunkov IORING_REGISTER_MEM_REGION = 34, 65693238e66SPavel Begunkov 6579d4a75efSStefano Garzarella /* this goes last */ 6587d3fd88dSJosh Triplett IORING_REGISTER_LAST, 6597d3fd88dSJosh Triplett 6607d3fd88dSJosh Triplett /* flag added to the opcode to use a registered ring fd */ 6617d3fd88dSJosh Triplett IORING_REGISTER_USE_REGISTERED_RING = 1U << 31 6629d4a75efSStefano Garzarella }; 663c3a31e60SJens Axboe 664dd47c104SEugene Syromiatnikov /* io-wq worker categories */ 6650f21a957SGabriel Krisman Bertazi enum io_wq_type { 666dd47c104SEugene Syromiatnikov IO_WQ_BOUND, 667dd47c104SEugene Syromiatnikov IO_WQ_UNBOUND, 668dd47c104SEugene Syromiatnikov }; 669dd47c104SEugene Syromiatnikov 670269bbe5fSBijan Mottahedeh /* deprecated, see struct io_uring_rsrc_update */ 671c3a31e60SJens Axboe struct io_uring_files_update { 672c3a31e60SJens Axboe __u32 offset; 6731292e972SEugene Syromiatnikov __u32 resv; 6741292e972SEugene Syromiatnikov __aligned_u64 /* __s32 * */ fds; 675c3a31e60SJens Axboe }; 676edafcceeSJens Axboe 677dfbbfbf1SPavel Begunkov enum { 678dfbbfbf1SPavel Begunkov /* initialise with user provided memory pointed by user_addr */ 679dfbbfbf1SPavel Begunkov IORING_MEM_REGION_TYPE_USER = 1, 680dfbbfbf1SPavel Begunkov }; 681dfbbfbf1SPavel Begunkov 682dfbbfbf1SPavel Begunkov struct io_uring_region_desc { 683dfbbfbf1SPavel Begunkov __u64 user_addr; 684dfbbfbf1SPavel Begunkov __u64 size; 685dfbbfbf1SPavel Begunkov __u32 flags; 686dfbbfbf1SPavel Begunkov __u32 id; 687dfbbfbf1SPavel Begunkov __u64 mmap_offset; 688dfbbfbf1SPavel Begunkov __u64 __resv[4]; 689dfbbfbf1SPavel Begunkov }; 690dfbbfbf1SPavel Begunkov 691d617b314SPavel Begunkov enum { 692d617b314SPavel Begunkov /* expose the region as registered wait arguments */ 693d617b314SPavel Begunkov IORING_MEM_REGION_REG_WAIT_ARG = 1, 694d617b314SPavel Begunkov }; 695d617b314SPavel Begunkov 69693238e66SPavel Begunkov struct io_uring_mem_region_reg { 69793238e66SPavel Begunkov __u64 region_uptr; /* struct io_uring_region_desc * */ 69893238e66SPavel Begunkov __u64 flags; 69993238e66SPavel Begunkov __u64 __resv[2]; 70093238e66SPavel Begunkov }; 70193238e66SPavel Begunkov 702a8da73a3SJens Axboe /* 703a8da73a3SJens Axboe * Register a fully sparse file space, rather than pass in an array of all 704a8da73a3SJens Axboe * -1 file descriptors. 705a8da73a3SJens Axboe */ 706a8da73a3SJens Axboe #define IORING_RSRC_REGISTER_SPARSE (1U << 0) 707a8da73a3SJens Axboe 708792e3582SPavel Begunkov struct io_uring_rsrc_register { 709792e3582SPavel Begunkov __u32 nr; 710a8da73a3SJens Axboe __u32 flags; 711992da01aSPavel Begunkov __u64 resv2; 712792e3582SPavel Begunkov __aligned_u64 data; 713792e3582SPavel Begunkov __aligned_u64 tags; 714792e3582SPavel Begunkov }; 715792e3582SPavel Begunkov 716c3bdad02SPavel Begunkov struct io_uring_rsrc_update { 717c3bdad02SPavel Begunkov __u32 offset; 718c3bdad02SPavel Begunkov __u32 resv; 719c3bdad02SPavel Begunkov __aligned_u64 data; 720c3bdad02SPavel Begunkov }; 721c3bdad02SPavel Begunkov 722c3bdad02SPavel Begunkov struct io_uring_rsrc_update2 { 723c3bdad02SPavel Begunkov __u32 offset; 724c3bdad02SPavel Begunkov __u32 resv; 725c3bdad02SPavel Begunkov __aligned_u64 data; 726c3bdad02SPavel Begunkov __aligned_u64 tags; 727c3bdad02SPavel Begunkov __u32 nr; 728992da01aSPavel Begunkov __u32 resv2; 729c3bdad02SPavel Begunkov }; 730c3bdad02SPavel Begunkov 7314e0377a1Snoah /* Skip updating fd indexes set to this value in the fd table */ 7324e0377a1Snoah #define IORING_REGISTER_FILES_SKIP (-2) 7334e0377a1Snoah 73466f4af93SJens Axboe #define IO_URING_OP_SUPPORTED (1U << 0) 73566f4af93SJens Axboe 73666f4af93SJens Axboe struct io_uring_probe_op { 73766f4af93SJens Axboe __u8 op; 73866f4af93SJens Axboe __u8 resv; 73966f4af93SJens Axboe __u16 flags; /* IO_URING_OP_* flags */ 74066f4af93SJens Axboe __u32 resv2; 74166f4af93SJens Axboe }; 74266f4af93SJens Axboe 74366f4af93SJens Axboe struct io_uring_probe { 74466f4af93SJens Axboe __u8 last_op; /* last opcode supported */ 74566f4af93SJens Axboe __u8 ops_len; /* length of ops[] array below */ 74666f4af93SJens Axboe __u16 resv; 74766f4af93SJens Axboe __u32 resv2[3]; 7488fcf4c48SGustavo A. R. Silva struct io_uring_probe_op ops[]; 74966f4af93SJens Axboe }; 75066f4af93SJens Axboe 75121b55dbcSStefano Garzarella struct io_uring_restriction { 75221b55dbcSStefano Garzarella __u16 opcode; 75321b55dbcSStefano Garzarella union { 75421b55dbcSStefano Garzarella __u8 register_op; /* IORING_RESTRICTION_REGISTER_OP */ 75521b55dbcSStefano Garzarella __u8 sqe_op; /* IORING_RESTRICTION_SQE_OP */ 75621b55dbcSStefano Garzarella __u8 sqe_flags; /* IORING_RESTRICTION_SQE_FLAGS_* */ 75721b55dbcSStefano Garzarella }; 75821b55dbcSStefano Garzarella __u8 resv; 75921b55dbcSStefano Garzarella __u32 resv2[3]; 76021b55dbcSStefano Garzarella }; 76121b55dbcSStefano Garzarella 7622b8e976bSPavel Begunkov struct io_uring_clock_register { 7632b8e976bSPavel Begunkov __u32 clockid; 7642b8e976bSPavel Begunkov __u32 __resv[3]; 7652b8e976bSPavel Begunkov }; 7662b8e976bSPavel Begunkov 7677cc2a6eaSJens Axboe enum { 768c1329532SJens Axboe IORING_REGISTER_SRC_REGISTERED = (1U << 0), 769c1329532SJens Axboe IORING_REGISTER_DST_REPLACE = (1U << 1), 7707cc2a6eaSJens Axboe }; 7717cc2a6eaSJens Axboe 772636119afSJens Axboe struct io_uring_clone_buffers { 7737cc2a6eaSJens Axboe __u32 src_fd; 7747cc2a6eaSJens Axboe __u32 flags; 775b16e920aSJens Axboe __u32 src_off; 776b16e920aSJens Axboe __u32 dst_off; 777b16e920aSJens Axboe __u32 nr; 778b16e920aSJens Axboe __u32 pad[3]; 7797cc2a6eaSJens Axboe }; 7807cc2a6eaSJens Axboe 781c7fb1942SJens Axboe struct io_uring_buf { 782c7fb1942SJens Axboe __u64 addr; 783c7fb1942SJens Axboe __u32 len; 784c7fb1942SJens Axboe __u16 bid; 785c7fb1942SJens Axboe __u16 resv; 786c7fb1942SJens Axboe }; 787c7fb1942SJens Axboe 788c7fb1942SJens Axboe struct io_uring_buf_ring { 789c7fb1942SJens Axboe union { 790c7fb1942SJens Axboe /* 791c7fb1942SJens Axboe * To avoid spilling into more pages than we need to, the 792c7fb1942SJens Axboe * ring tail is overlaid with the io_uring_buf->resv field. 793c7fb1942SJens Axboe */ 794c7fb1942SJens Axboe struct { 795c7fb1942SJens Axboe __u64 resv1; 796c7fb1942SJens Axboe __u32 resv2; 797c7fb1942SJens Axboe __u16 resv3; 798c7fb1942SJens Axboe __u16 tail; 799c7fb1942SJens Axboe }; 80036632d06SKees Cook __DECLARE_FLEX_ARRAY(struct io_uring_buf, bufs); 801c7fb1942SJens Axboe }; 802c7fb1942SJens Axboe }; 803c7fb1942SJens Axboe 804c56e022cSJens Axboe /* 805c56e022cSJens Axboe * Flags for IORING_REGISTER_PBUF_RING. 806c56e022cSJens Axboe * 807c56e022cSJens Axboe * IOU_PBUF_RING_MMAP: If set, kernel will allocate the memory for the ring. 808c56e022cSJens Axboe * The application must not set a ring_addr in struct 809c56e022cSJens Axboe * io_uring_buf_reg, instead it must subsequently call 810c56e022cSJens Axboe * mmap(2) with the offset set as: 811c56e022cSJens Axboe * IORING_OFF_PBUF_RING | (bgid << IORING_OFF_PBUF_SHIFT) 812c56e022cSJens Axboe * to get a virtual mapping for the ring. 813ae98dbf4SJens Axboe * IOU_PBUF_RING_INC: If set, buffers consumed from this buffer ring can be 814ae98dbf4SJens Axboe * consumed incrementally. Normally one (or more) buffers 815ae98dbf4SJens Axboe * are fully consumed. With incremental consumptions, it's 816ae98dbf4SJens Axboe * feasible to register big ranges of buffers, and each 817ae98dbf4SJens Axboe * use of it will consume only as much as it needs. This 818ae98dbf4SJens Axboe * requires that both the kernel and application keep 819ae98dbf4SJens Axboe * track of where the current read/recv index is at. 820c56e022cSJens Axboe */ 8210f21a957SGabriel Krisman Bertazi enum io_uring_register_pbuf_ring_flags { 822c56e022cSJens Axboe IOU_PBUF_RING_MMAP = 1, 823ae98dbf4SJens Axboe IOU_PBUF_RING_INC = 2, 824c56e022cSJens Axboe }; 825c56e022cSJens Axboe 826c7fb1942SJens Axboe /* argument for IORING_(UN)REGISTER_PBUF_RING */ 827c7fb1942SJens Axboe struct io_uring_buf_reg { 828c7fb1942SJens Axboe __u64 ring_addr; 829c7fb1942SJens Axboe __u32 ring_entries; 830c7fb1942SJens Axboe __u16 bgid; 83181cf17cdSJens Axboe __u16 flags; 832c7fb1942SJens Axboe __u64 resv[3]; 833c7fb1942SJens Axboe }; 834c7fb1942SJens Axboe 835d293b1a8SJens Axboe /* argument for IORING_REGISTER_PBUF_STATUS */ 836d293b1a8SJens Axboe struct io_uring_buf_status { 837d293b1a8SJens Axboe __u32 buf_group; /* input */ 838d293b1a8SJens Axboe __u32 head; /* output */ 839d293b1a8SJens Axboe __u32 resv[8]; 840d293b1a8SJens Axboe }; 841d293b1a8SJens Axboe 8426bf90bd8SOlivier Langlois enum io_uring_napi_op { 8436bf90bd8SOlivier Langlois /* register/ungister backward compatible opcode */ 8446bf90bd8SOlivier Langlois IO_URING_NAPI_REGISTER_OP = 0, 8456bf90bd8SOlivier Langlois 8466bf90bd8SOlivier Langlois /* opcodes to update napi_list when static tracking is used */ 8476bf90bd8SOlivier Langlois IO_URING_NAPI_STATIC_ADD_ID = 1, 8486bf90bd8SOlivier Langlois IO_URING_NAPI_STATIC_DEL_ID = 2 8496bf90bd8SOlivier Langlois }; 8506bf90bd8SOlivier Langlois 8516bf90bd8SOlivier Langlois enum io_uring_napi_tracking_strategy { 8526bf90bd8SOlivier Langlois /* value must be 0 for backward compatibility */ 8536bf90bd8SOlivier Langlois IO_URING_NAPI_TRACKING_DYNAMIC = 0, 8546bf90bd8SOlivier Langlois IO_URING_NAPI_TRACKING_STATIC = 1, 8556bf90bd8SOlivier Langlois IO_URING_NAPI_TRACKING_INACTIVE = 255 8566bf90bd8SOlivier Langlois }; 8576bf90bd8SOlivier Langlois 858ef1186c1SStefan Roesch /* argument for IORING_(UN)REGISTER_NAPI */ 859ef1186c1SStefan Roesch struct io_uring_napi { 860ef1186c1SStefan Roesch __u32 busy_poll_to; 861ef1186c1SStefan Roesch __u8 prefer_busy_poll; 8626bf90bd8SOlivier Langlois 8636bf90bd8SOlivier Langlois /* a io_uring_napi_op value */ 8646bf90bd8SOlivier Langlois __u8 opcode; 8656bf90bd8SOlivier Langlois __u8 pad[2]; 8666bf90bd8SOlivier Langlois 8676bf90bd8SOlivier Langlois /* 8686bf90bd8SOlivier Langlois * for IO_URING_NAPI_REGISTER_OP, it is a 8696bf90bd8SOlivier Langlois * io_uring_napi_tracking_strategy value. 8706bf90bd8SOlivier Langlois * 8716bf90bd8SOlivier Langlois * for IO_URING_NAPI_STATIC_ADD_ID/IO_URING_NAPI_STATIC_DEL_ID 8726bf90bd8SOlivier Langlois * it is the napi id to add/del from napi_list. 8736bf90bd8SOlivier Langlois */ 8746bf90bd8SOlivier Langlois __u32 op_param; 8756bf90bd8SOlivier Langlois __u32 resv; 876ef1186c1SStefan Roesch }; 877ef1186c1SStefan Roesch 87821b55dbcSStefano Garzarella /* 87921b55dbcSStefano Garzarella * io_uring_restriction->opcode values 88021b55dbcSStefano Garzarella */ 8810f21a957SGabriel Krisman Bertazi enum io_uring_register_restriction_op { 88221b55dbcSStefano Garzarella /* Allow an io_uring_register(2) opcode */ 88321b55dbcSStefano Garzarella IORING_RESTRICTION_REGISTER_OP = 0, 88421b55dbcSStefano Garzarella 88521b55dbcSStefano Garzarella /* Allow an sqe opcode */ 88621b55dbcSStefano Garzarella IORING_RESTRICTION_SQE_OP = 1, 88721b55dbcSStefano Garzarella 88821b55dbcSStefano Garzarella /* Allow sqe flags */ 88921b55dbcSStefano Garzarella IORING_RESTRICTION_SQE_FLAGS_ALLOWED = 2, 89021b55dbcSStefano Garzarella 89121b55dbcSStefano Garzarella /* Require sqe flags (these flags must be set on each submission) */ 89221b55dbcSStefano Garzarella IORING_RESTRICTION_SQE_FLAGS_REQUIRED = 3, 89321b55dbcSStefano Garzarella 89421b55dbcSStefano Garzarella IORING_RESTRICTION_LAST 89521b55dbcSStefano Garzarella }; 89621b55dbcSStefano Garzarella 897aa00f67aSJens Axboe enum { 898aa00f67aSJens Axboe IORING_REG_WAIT_TS = (1U << 0), 899aa00f67aSJens Axboe }; 900aa00f67aSJens Axboe 901aa00f67aSJens Axboe /* 902aa00f67aSJens Axboe * Argument for io_uring_enter(2) with 903aa00f67aSJens Axboe * IORING_GETEVENTS | IORING_ENTER_EXT_ARG_REG set, where the actual argument 904aa00f67aSJens Axboe * is an index into a previously registered fixed wait region described by 905aa00f67aSJens Axboe * the below structure. 906aa00f67aSJens Axboe */ 907aa00f67aSJens Axboe struct io_uring_reg_wait { 908aa00f67aSJens Axboe struct __kernel_timespec ts; 909aa00f67aSJens Axboe __u32 min_wait_usec; 910aa00f67aSJens Axboe __u32 flags; 911aa00f67aSJens Axboe __u64 sigmask; 912aa00f67aSJens Axboe __u32 sigmask_sz; 913aa00f67aSJens Axboe __u32 pad[3]; 914aa00f67aSJens Axboe __u64 pad2[2]; 915aa00f67aSJens Axboe }; 916aa00f67aSJens Axboe 917aa00f67aSJens Axboe /* 918aa00f67aSJens Axboe * Argument for io_uring_enter(2) with IORING_GETEVENTS | IORING_ENTER_EXT_ARG 919aa00f67aSJens Axboe */ 920c73ebb68SHao Xu struct io_uring_getevents_arg { 921c73ebb68SHao Xu __u64 sigmask; 922c73ebb68SHao Xu __u32 sigmask_sz; 9237ed9e09eSJens Axboe __u32 min_wait_usec; 924c73ebb68SHao Xu __u64 ts; 925c73ebb68SHao Xu }; 926c73ebb68SHao Xu 92778a861b9SJens Axboe /* 92878a861b9SJens Axboe * Argument for IORING_REGISTER_SYNC_CANCEL 92978a861b9SJens Axboe */ 93078a861b9SJens Axboe struct io_uring_sync_cancel_reg { 93178a861b9SJens Axboe __u64 addr; 93278a861b9SJens Axboe __s32 fd; 93378a861b9SJens Axboe __u32 flags; 93478a861b9SJens Axboe struct __kernel_timespec timeout; 935f77569d2SJens Axboe __u8 opcode; 936f77569d2SJens Axboe __u8 pad[7]; 937f77569d2SJens Axboe __u64 pad2[3]; 93878a861b9SJens Axboe }; 93978a861b9SJens Axboe 9406e73dffbSPavel Begunkov /* 9416e73dffbSPavel Begunkov * Argument for IORING_REGISTER_FILE_ALLOC_RANGE 9426e73dffbSPavel Begunkov * The range is specified as [off, off + len) 9436e73dffbSPavel Begunkov */ 9446e73dffbSPavel Begunkov struct io_uring_file_index_range { 9456e73dffbSPavel Begunkov __u32 off; 9466e73dffbSPavel Begunkov __u32 len; 9476e73dffbSPavel Begunkov __u64 resv; 9486e73dffbSPavel Begunkov }; 9496e73dffbSPavel Begunkov 9509bb66906SDylan Yudaken struct io_uring_recvmsg_out { 9519bb66906SDylan Yudaken __u32 namelen; 9529bb66906SDylan Yudaken __u32 controllen; 9539bb66906SDylan Yudaken __u32 payloadlen; 9549bb66906SDylan Yudaken __u32 flags; 9559bb66906SDylan Yudaken }; 9569bb66906SDylan Yudaken 9578e9fad0eSBreno Leitao /* 9588e9fad0eSBreno Leitao * Argument for IORING_OP_URING_CMD when file is a socket 9598e9fad0eSBreno Leitao */ 9600f21a957SGabriel Krisman Bertazi enum io_uring_socket_op { 9618e9fad0eSBreno Leitao SOCKET_URING_OP_SIOCINQ = 0, 9628e9fad0eSBreno Leitao SOCKET_URING_OP_SIOCOUTQ, 963a5d2f99aSBreno Leitao SOCKET_URING_OP_GETSOCKOPT, 9644232c6e3SBreno Leitao SOCKET_URING_OP_SETSOCKOPT, 9658e9fad0eSBreno Leitao }; 9668e9fad0eSBreno Leitao 9676f377873SDavid Wei /* Zero copy receive refill queue entry */ 9686f377873SDavid Wei struct io_uring_zcrx_rqe { 9696f377873SDavid Wei __u64 off; 9706f377873SDavid Wei __u32 len; 9716f377873SDavid Wei __u32 __pad; 9726f377873SDavid Wei }; 9736f377873SDavid Wei 9746f377873SDavid Wei struct io_uring_zcrx_cqe { 9756f377873SDavid Wei __u64 off; 9766f377873SDavid Wei __u64 __pad; 9776f377873SDavid Wei }; 9786f377873SDavid Wei 9796f377873SDavid Wei /* The bit from which area id is encoded into offsets */ 9806f377873SDavid Wei #define IORING_ZCRX_AREA_SHIFT 48 9816f377873SDavid Wei #define IORING_ZCRX_AREA_MASK (~(((__u64)1 << IORING_ZCRX_AREA_SHIFT) - 1)) 9826f377873SDavid Wei 9836f377873SDavid Wei struct io_uring_zcrx_offsets { 9846f377873SDavid Wei __u32 head; 9856f377873SDavid Wei __u32 tail; 9866f377873SDavid Wei __u32 rqes; 9876f377873SDavid Wei __u32 __resv2; 9886f377873SDavid Wei __u64 __resv[2]; 9896f377873SDavid Wei }; 9906f377873SDavid Wei 991cf96310cSDavid Wei struct io_uring_zcrx_area_reg { 992cf96310cSDavid Wei __u64 addr; 993cf96310cSDavid Wei __u64 len; 994cf96310cSDavid Wei __u64 rq_area_token; 995cf96310cSDavid Wei __u32 flags; 996cf96310cSDavid Wei __u32 __resv1; 997cf96310cSDavid Wei __u64 __resv2[2]; 998cf96310cSDavid Wei }; 999cf96310cSDavid Wei 10006f377873SDavid Wei /* 10016f377873SDavid Wei * Argument for IORING_REGISTER_ZCRX_IFQ 10026f377873SDavid Wei */ 10036f377873SDavid Wei struct io_uring_zcrx_ifq_reg { 10046f377873SDavid Wei __u32 if_idx; 10056f377873SDavid Wei __u32 if_rxq; 10066f377873SDavid Wei __u32 rq_entries; 10076f377873SDavid Wei __u32 flags; 10086f377873SDavid Wei 10096f377873SDavid Wei __u64 area_ptr; /* pointer to struct io_uring_zcrx_area_reg */ 10106f377873SDavid Wei __u64 region_ptr; /* struct io_uring_region_desc * */ 10116f377873SDavid Wei 10126f377873SDavid Wei struct io_uring_zcrx_offsets offsets; 1013*25744f84SPavel Begunkov __u32 zcrx_id; 1014*25744f84SPavel Begunkov __u32 __resv2; 1015*25744f84SPavel Begunkov __u64 __resv[3]; 10166f377873SDavid Wei }; 10176f377873SDavid Wei 1018e1d0c6d0SAmmar Faizi #ifdef __cplusplus 1019e1d0c6d0SAmmar Faizi } 1020e1d0c6d0SAmmar Faizi #endif 1021e1d0c6d0SAmmar Faizi 10222b188cc1SJens Axboe #endif 1023