1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * Header file for the io_uring interface.
5 * Copyright (C) 2019 Jens Axboe
6 * Copyright (C) 2019 Christoph Hellwig
8 #ifndef LINUX_IO_URING_H
9 #define LINUX_IO_URING_H
12 #include <linux/types.h>
15 * IO submission data structure (Submission Queue Entry)
18 __u8 opcode; /* type of operation for this sqe */
19 __u8 flags; /* IOSQE_ flags */
20 __u16 ioprio; /* ioprio for the request */
21 __s32 fd; /* file descriptor to do IO on */
23 __u64 off; /* offset into file */
26 __u64 addr; /* pointer to buffer or iovecs */
27 __u32 len; /* buffer size or number of iovecs */
29 __kernel_rwf_t rw_flags;
32 __u32 sync_range_flags;
40 __u64 user_data; /* data to be passed back at completion time */
42 __u16 buf_index; /* index into fixed buffers, if used */
50 #define IOSQE_FIXED_FILE (1U << 0) /* use fixed fileset */
51 #define IOSQE_IO_DRAIN (1U << 1) /* issue after inflight IO */
52 #define IOSQE_IO_LINK (1U << 2) /* links next sqe */
53 #define IOSQE_IO_HARDLINK (1U << 3) /* like LINK, but stronger */
54 #define IOSQE_ASYNC (1U << 4) /* always go async */
57 * io_uring_setup() flags
59 #define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */
60 #define IORING_SETUP_SQPOLL (1U << 1) /* SQ poll thread */
61 #define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */
62 #define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */
70 IORING_OP_WRITE_FIXED,
72 IORING_OP_POLL_REMOVE,
73 IORING_OP_SYNC_FILE_RANGE,
77 IORING_OP_TIMEOUT_REMOVE,
79 IORING_OP_ASYNC_CANCEL,
80 IORING_OP_LINK_TIMEOUT,
85 IORING_OP_FILES_UPDATE,
90 /* this goes last, obviously */
97 #define IORING_FSYNC_DATASYNC (1U << 0)
102 #define IORING_TIMEOUT_ABS (1U << 0)
105 * IO completion data structure (Completion Queue Entry)
107 struct io_uring_cqe {
108 __u64 user_data; /* sqe->data submission passed back */
109 __s32 res; /* result code for this event */
114 * Magic offsets for the application to mmap the data it needs
116 #define IORING_OFF_SQ_RING 0ULL
117 #define IORING_OFF_CQ_RING 0x8000000ULL
118 #define IORING_OFF_SQES 0x10000000ULL
121 * Filled with the offset for mmap(2)
123 struct io_sqring_offsets {
138 #define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */
140 struct io_cqring_offsets {
151 * io_uring_enter(2) flags
153 #define IORING_ENTER_GETEVENTS (1U << 0)
154 #define IORING_ENTER_SQ_WAKEUP (1U << 1)
157 * Passed in for io_uring_setup(2). Copied back with updated info on success
159 struct io_uring_params {
164 __u32 sq_thread_idle;
167 struct io_sqring_offsets sq_off;
168 struct io_cqring_offsets cq_off;
172 * io_uring_params->features flags
174 #define IORING_FEAT_SINGLE_MMAP (1U << 0)
175 #define IORING_FEAT_NODROP (1U << 1)
176 #define IORING_FEAT_SUBMIT_STABLE (1U << 2)
179 * io_uring_register(2) opcodes and arguments
181 #define IORING_REGISTER_BUFFERS 0
182 #define IORING_UNREGISTER_BUFFERS 1
183 #define IORING_REGISTER_FILES 2
184 #define IORING_UNREGISTER_FILES 3
185 #define IORING_REGISTER_EVENTFD 4
186 #define IORING_UNREGISTER_EVENTFD 5
187 #define IORING_REGISTER_FILES_UPDATE 6
189 struct io_uring_files_update {