blob: 4589d56d0b68a90469d898a272e91acc6eb82f36 [file] [log] [blame]
Jens Axboe2b188cc2019-01-07 10:46:33 -07001/* 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 */
19 __u8 flags; /* as of now unused */
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;
Christoph Hellwigc992fe22019-01-11 09:43:02 -070027 __u32 fsync_flags;
Jens Axboe2b188cc2019-01-07 10:46:33 -070028 };
29 __u64 user_data; /* data to be passed back at completion time */
30 __u64 __pad2[3];
31};
32
33#define IORING_OP_NOP 0
34#define IORING_OP_READV 1
35#define IORING_OP_WRITEV 2
Christoph Hellwigc992fe22019-01-11 09:43:02 -070036#define IORING_OP_FSYNC 3
37
38/*
39 * sqe->fsync_flags
40 */
41#define IORING_FSYNC_DATASYNC (1U << 0)
Jens Axboe2b188cc2019-01-07 10:46:33 -070042
43/*
44 * IO completion data structure (Completion Queue Entry)
45 */
46struct io_uring_cqe {
47 __u64 user_data; /* sqe->data submission passed back */
48 __s32 res; /* result code for this event */
49 __u32 flags;
50};
51
52/*
53 * Magic offsets for the application to mmap the data it needs
54 */
55#define IORING_OFF_SQ_RING 0ULL
56#define IORING_OFF_CQ_RING 0x8000000ULL
57#define IORING_OFF_SQES 0x10000000ULL
58
59/*
60 * Filled with the offset for mmap(2)
61 */
62struct io_sqring_offsets {
63 __u32 head;
64 __u32 tail;
65 __u32 ring_mask;
66 __u32 ring_entries;
67 __u32 flags;
68 __u32 dropped;
69 __u32 array;
70 __u32 resv1;
71 __u64 resv2;
72};
73
74struct io_cqring_offsets {
75 __u32 head;
76 __u32 tail;
77 __u32 ring_mask;
78 __u32 ring_entries;
79 __u32 overflow;
80 __u32 cqes;
81 __u64 resv[2];
82};
83
84/*
85 * io_uring_enter(2) flags
86 */
87#define IORING_ENTER_GETEVENTS (1U << 0)
88
89/*
90 * Passed in for io_uring_setup(2). Copied back with updated info on success
91 */
92struct io_uring_params {
93 __u32 sq_entries;
94 __u32 cq_entries;
95 __u32 flags;
96 __u32 resv[7];
97 struct io_sqring_offsets sq_off;
98 struct io_cqring_offsets cq_off;
99};
100
101#endif