io_uring: add file set registration
[linux-2.6-block.git] / include / uapi / linux / io_uring.h
CommitLineData
2b188cc1
JA
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/*
15 * IO submission data structure (Submission Queue Entry)
16 */
17struct io_uring_sqe {
18 __u8 opcode; /* type of operation for this sqe */
6b06314c 19 __u8 flags; /* IOSQE_ flags */
2b188cc1
JA
20 __u16 ioprio; /* ioprio for the request */
21 __s32 fd; /* file descriptor to do IO on */
22 __u64 off; /* offset into file */
23 __u64 addr; /* pointer to buffer or iovecs */
24 __u32 len; /* buffer size or number of iovecs */
25 union {
26 __kernel_rwf_t rw_flags;
c992fe29 27 __u32 fsync_flags;
2b188cc1
JA
28 };
29 __u64 user_data; /* data to be passed back at completion time */
edafccee
JA
30 union {
31 __u16 buf_index; /* index into fixed buffers, if used */
32 __u64 __pad2[3];
33 };
2b188cc1
JA
34};
35
6b06314c
JA
36/*
37 * sqe->flags
38 */
39#define IOSQE_FIXED_FILE (1U << 0) /* use fixed fileset */
40
def596e9
JA
41/*
42 * io_uring_setup() flags
43 */
44#define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */
45
2b188cc1
JA
46#define IORING_OP_NOP 0
47#define IORING_OP_READV 1
48#define IORING_OP_WRITEV 2
c992fe29 49#define IORING_OP_FSYNC 3
edafccee
JA
50#define IORING_OP_READ_FIXED 4
51#define IORING_OP_WRITE_FIXED 5
c992fe29
CH
52
53/*
54 * sqe->fsync_flags
55 */
56#define IORING_FSYNC_DATASYNC (1U << 0)
2b188cc1
JA
57
58/*
59 * IO completion data structure (Completion Queue Entry)
60 */
61struct io_uring_cqe {
62 __u64 user_data; /* sqe->data submission passed back */
63 __s32 res; /* result code for this event */
64 __u32 flags;
65};
66
67/*
68 * Magic offsets for the application to mmap the data it needs
69 */
70#define IORING_OFF_SQ_RING 0ULL
71#define IORING_OFF_CQ_RING 0x8000000ULL
72#define IORING_OFF_SQES 0x10000000ULL
73
74/*
75 * Filled with the offset for mmap(2)
76 */
77struct io_sqring_offsets {
78 __u32 head;
79 __u32 tail;
80 __u32 ring_mask;
81 __u32 ring_entries;
82 __u32 flags;
83 __u32 dropped;
84 __u32 array;
85 __u32 resv1;
86 __u64 resv2;
87};
88
89struct io_cqring_offsets {
90 __u32 head;
91 __u32 tail;
92 __u32 ring_mask;
93 __u32 ring_entries;
94 __u32 overflow;
95 __u32 cqes;
96 __u64 resv[2];
97};
98
99/*
100 * io_uring_enter(2) flags
101 */
102#define IORING_ENTER_GETEVENTS (1U << 0)
103
104/*
105 * Passed in for io_uring_setup(2). Copied back with updated info on success
106 */
107struct io_uring_params {
108 __u32 sq_entries;
109 __u32 cq_entries;
110 __u32 flags;
111 __u32 resv[7];
112 struct io_sqring_offsets sq_off;
113 struct io_cqring_offsets cq_off;
114};
115
edafccee
JA
116/*
117 * io_uring_register(2) opcodes and arguments
118 */
119#define IORING_REGISTER_BUFFERS 0
120#define IORING_UNREGISTER_BUFFERS 1
6b06314c
JA
121#define IORING_REGISTER_FILES 2
122#define IORING_UNREGISTER_FILES 3
edafccee 123
2b188cc1 124#endif