io_uring: update to kernel struct io_uring_params
[fio.git] / os / linux / io_uring.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
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#define IORING_MAX_ENTRIES 4096
15
16/*
17 * IO submission data structure (Submission Queue Entry)
18 */
19struct io_uring_sqe {
20 __u8 opcode; /* type of operation for this sqe */
21 __u8 flags; /* IOSQE_ flags */
22 __u16 ioprio; /* ioprio for the request */
23 __s32 fd; /* file descriptor to do IO on */
24 __u64 off; /* offset into file */
25 __u64 addr; /* pointer to buffer or iovecs */
26 __u32 len; /* buffer size or number of iovecs */
27 union {
28 __kernel_rwf_t rw_flags;
29 __u32 fsync_flags;
30 __u16 poll_events;
31 };
32 __u64 user_data; /* data to be passed back at completion time */
33 union {
34 __u16 buf_index; /* index into fixed buffers, if used */
35 __u64 __pad2[3];
36 };
37};
38
39/*
40 * sqe->flags
41 */
42#define IOSQE_FIXED_FILE (1U << 0) /* use fixed fileset */
43
44/*
45 * io_uring_setup() flags
46 */
47#define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */
48#define IORING_SETUP_SQPOLL (1U << 1) /* SQ poll thread */
49#define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */
50
51#define IORING_OP_NOP 0
52#define IORING_OP_READV 1
53#define IORING_OP_WRITEV 2
54#define IORING_OP_FSYNC 3
55#define IORING_OP_READ_FIXED 4
56#define IORING_OP_WRITE_FIXED 5
57#define IORING_OP_POLL_ADD 6
58#define IORING_OP_POLL_REMOVE 7
59
60/*
61 * sqe->fsync_flags
62 */
63#define IORING_FSYNC_DATASYNC (1U << 0)
64
65/*
66 * IO completion data structure (Completion Queue Entry)
67 */
68struct io_uring_cqe {
69 __u64 user_data; /* sqe->data submission passed back */
70 __s32 res; /* result code for this event */
71 __u32 flags;
72};
73
74/*
75 * io_uring_event->flags
76 */
77#define IOCQE_FLAG_CACHEHIT (1U << 0) /* IO did not hit media */
78
79/*
80 * Magic offsets for the application to mmap the data it needs
81 */
82#define IORING_OFF_SQ_RING 0ULL
83#define IORING_OFF_CQ_RING 0x8000000ULL
84#define IORING_OFF_SQES 0x10000000ULL
85
86/*
87 * Filled with the offset for mmap(2)
88 */
89struct io_sqring_offsets {
90 __u32 head;
91 __u32 tail;
92 __u32 ring_mask;
93 __u32 ring_entries;
94 __u32 flags;
95 __u32 dropped;
96 __u32 array;
97 __u32 resv[3];
98};
99
100/*
101 * sq_ring->flags
102 */
103#define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */
104
105struct io_cqring_offsets {
106 __u32 head;
107 __u32 tail;
108 __u32 ring_mask;
109 __u32 ring_entries;
110 __u32 overflow;
111 __u32 cqes;
112 __u32 resv[4];
113};
114
115/*
116 * io_uring_enter(2) flags
117 */
118#define IORING_ENTER_GETEVENTS (1U << 0)
119#define IORING_ENTER_SQ_WAKEUP (1U << 1)
120
121/*
122 * Passed in for io_uring_setup(2). Copied back with updated info on success
123 */
124struct io_uring_params {
125 __u32 sq_entries;
126 __u32 cq_entries;
127 __u32 flags;
128 __u32 sq_thread_cpu;
129 __u32 sq_thread_idle;
130 __u32 resv[5];
131 struct io_sqring_offsets sq_off;
132 struct io_cqring_offsets cq_off;
133};
134
135/*
136 * io_uring_register(2) opcodes and arguments
137 */
138#define IORING_REGISTER_BUFFERS 0
139#define IORING_UNREGISTER_BUFFERS 1
140#define IORING_REGISTER_FILES 2
141#define IORING_UNREGISTER_FILES 3
142
143#endif