Created
July 11, 2024 14:06
-
-
Save fadhil-riyanto/4c6a73184e051adcb34f7618397996bd to your computer and use it in GitHub Desktop.
io_uring.h (documented), finally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct io_sqring_offsets { | |
__u32 head; /* offset of ring head */ | |
__u32 tail; /* offset of ring tail */ | |
__u32 ring_mask; /* ring mask value */ | |
__u32 ring_entries; /* entries in ring */ | |
__u32 flags; /* ring flags */ | |
__u32 dropped; /* number of sqes not submitted */ | |
__u32 array; /* sqe index array */ | |
__u32 resv1; | |
__u64 resv2; | |
}; | |
struct io_cqring_offsets { | |
__u32 head; | |
__u32 tail; | |
__u32 ring_mask; | |
__u32 ring_entries; | |
__u32 overflow; | |
__u32 cqes; | |
__u32 flags; | |
__u32 resv1; | |
__u64 user_addr; | |
}; | |
struct io_uring_params { | |
__u32 sq_entries; /* filled by kernel, how many sqe entries this ring supports */ | |
__u32 cq_entries; /* this field tell how big cq_ring */ | |
__u32 flags; | |
__u32 sq_thread_cpu; | |
__u32 sq_thread_idle; | |
__u32 features; /* if this field filled with | |
IORING_FEAT_SINGLE_MMAP, we can do second mmap() */ | |
__u32 wq_fd; | |
__u32 resv[3]; | |
struct io_sqring_offsets sq_off; /* sq_off and cq_off are essential for setup offset */ | |
struct io_cqring_offsets cq_off; | |
}; | |
-------- submission struct ------------ | |
struct io_uring_sqe { | |
__u8 opcode; /* type of operation for this sqe */ | |
__u8 flags; /* IOSQE_ flags */ | |
__u16 ioprio; /* ioprio for the request */ | |
__s32 fd; /* file descriptor to do IO on */ | |
__u64 off; /* offset into file */ | |
__u64 addr; /* addr contains the address at which | |
the operation should perform IO, | |
if the op-code describes an operation that | |
transfers data. If the operation is a vectored | |
read/write of some sort, this will be a pointer | |
to an struct iovec array, as used by preadv(2), for | |
example. For a non-vectored IO transfer, | |
addr must contain the address directly */ | |
__u32 len; /* This carries into len, which is either | |
a byte count for a non-vectored IO transfer, | |
or a number of vectors described by | |
addr for a vectored IO transfer | |
*/ | |
union { | |
__kernel_rwf_t rw_flags; /* Next follows a union of | |
flags that are specific to the op-code */ | |
__u32 fsync_flags; | |
__u16 poll_events; | |
__u32 sync_range_flags; | |
__u32 msg_flags; | |
}; | |
__u64 user_data; /* untouched by the kernel */ | |
union { | |
__u16 buf_index; /* buf_index will be described | |
in the advanced use cases section */ | |
__u64 __pad2[3]; /* unused, for future and padding in 64 */ | |
}; | |
}; | |
--------- completion struct ------------- | |
struct io_uring_cqe { | |
__u64 user_data; /* sqe->data submission passed back */ | |
__s32 res; /* result code for this event */ | |
__u32 flags; | |
/* | |
* If the ring is initialized with IORING_SETUP_CQE32, then this field | |
* contains 16-bytes of padding, doubling the size of the CQE. | |
*/ | |
__u64 big_cqe[]; | |
}; | |
------- opcode list ---------------- | |
enum io_uring_op { | |
IORING_OP_NOP, | |
IORING_OP_READV, | |
IORING_OP_WRITEV, | |
IORING_OP_FSYNC, | |
IORING_OP_READ_FIXED, | |
IORING_OP_WRITE_FIXED, | |
IORING_OP_POLL_ADD, | |
IORING_OP_POLL_REMOVE, | |
IORING_OP_SYNC_FILE_RANGE, | |
IORING_OP_SENDMSG, | |
IORING_OP_RECVMSG, | |
IORING_OP_TIMEOUT, | |
IORING_OP_TIMEOUT_REMOVE, | |
IORING_OP_ACCEPT, | |
IORING_OP_ASYNC_CANCEL, | |
IORING_OP_LINK_TIMEOUT, | |
IORING_OP_CONNECT, | |
IORING_OP_FALLOCATE, | |
IORING_OP_OPENAT, | |
IORING_OP_CLOSE, | |
IORING_OP_FILES_UPDATE, | |
IORING_OP_STATX, | |
IORING_OP_READ, | |
IORING_OP_WRITE, | |
IORING_OP_FADVISE, | |
IORING_OP_MADVISE, | |
IORING_OP_SEND, | |
IORING_OP_RECV, | |
IORING_OP_OPENAT2, | |
IORING_OP_EPOLL_CTL, | |
IORING_OP_SPLICE, | |
IORING_OP_PROVIDE_BUFFERS, | |
IORING_OP_REMOVE_BUFFERS, | |
IORING_OP_TEE, | |
IORING_OP_SHUTDOWN, | |
IORING_OP_RENAMEAT, | |
IORING_OP_UNLINKAT, | |
IORING_OP_MKDIRAT, | |
IORING_OP_SYMLINKAT, | |
IORING_OP_LINKAT, | |
IORING_OP_MSG_RING, | |
IORING_OP_FSETXATTR, | |
IORING_OP_SETXATTR, | |
IORING_OP_FGETXATTR, | |
IORING_OP_GETXATTR, | |
IORING_OP_SOCKET, | |
IORING_OP_URING_CMD, | |
IORING_OP_SEND_ZC, | |
IORING_OP_SENDMSG_ZC, | |
IORING_OP_READ_MULTISHOT, | |
IORING_OP_WAITID, | |
IORING_OP_FUTEX_WAIT, | |
IORING_OP_FUTEX_WAKE, | |
IORING_OP_FUTEX_WAITV, | |
IORING_OP_FIXED_FD_INSTALL, | |
IORING_OP_FTRUNCATE, | |
/* this goes last, obviously */ | |
IORING_OP_LAST, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment