io_uring.h should include <linux/fs.h>
[fio.git] / os / io_uring.h
... / ...
CommitLineData
1#ifndef IO_URING_H
2#define IO_URING_H
3
4#include <linux/fs.h>
5
6/*
7 * IO submission data structure
8 */
9struct io_uring_iocb {
10 u8 opcode;
11 u8 flags;
12 u16 ioprio;
13 s32 fd;
14 u64 off;
15 union {
16 void *addr;
17 u64 __pad;
18 };
19 u32 len;
20 union {
21 __kernel_rwf_t rw_flags;
22 u32 __resv;
23 };
24};
25
26/*
27 * io_uring_setup() flags
28 */
29#define IORING_SETUP_IOPOLL (1 << 0) /* io_context is polled */
30#define IORING_SETUP_FIXEDBUFS (1 << 1) /* IO buffers are fixed */
31#define IORING_SETUP_SQTHREAD (1 << 2) /* Use SQ thread */
32#define IORING_SETUP_SQWQ (1 << 3) /* Use SQ workqueue */
33#define IORING_SETUP_SQPOLL (1 << 4) /* SQ thread polls */
34
35#define IORING_OP_READ 1
36#define IORING_OP_WRITE 2
37#define IORING_OP_FSYNC 3
38#define IORING_OP_FDSYNC 4
39#define IORING_OP_READ_FIXED 5
40#define IORING_OP_WRITE_FIXED 6
41
42/*
43 * IO completion data structure
44 */
45struct io_uring_event {
46 __u64 index; /* what iocb this event came from */
47 s32 res; /* result code for this event */
48 u32 flags;
49};
50
51#define IOEV_FLAG_CACHEHIT (1 << 0) /* IO did not hit media */
52
53/*
54 * Magic offsets for the application to mmap the data it needs
55 */
56#define IORING_OFF_SQ_RING 0ULL
57#define IORING_OFF_CQ_RING 0x8000000ULL
58#define IORING_OFF_IOCB 0x10000000ULL
59
60/*
61 * Filled with the offset for mmap(2)
62 */
63struct io_sqring_offsets {
64 u32 head;
65 u32 tail;
66 u32 ring_mask;
67 u32 ring_entries;
68 u32 flags;
69 u32 dropped;
70 u32 array;
71 u32 resv[3];
72};
73
74#define IORING_SQ_NEED_WAKEUP (1 << 0) /* needs io_uring_enter wakeup */
75
76struct io_cqring_offsets {
77 u32 head;
78 u32 tail;
79 u32 ring_mask;
80 u32 ring_entries;
81 u32 overflow;
82 u32 events;
83 u32 resv[4];
84};
85
86#define IORING_ENTER_GETEVENTS (1 << 0)
87
88/*
89 * Passed in for io_uring_setup(2). Copied back with updated info on success
90 */
91struct io_uring_params {
92 u32 sq_entries;
93 u32 cq_entries;
94 u32 flags;
95 u16 sq_thread_cpu;
96 u16 resv[9];
97 struct io_sqring_offsets sq_off;
98 struct io_cqring_offsets cq_off;
99};
100
101#endif