Line data Source code
1 : #ifndef HEADER_fd_src_util_io_fd_io_uring_sys_h 2 : #define HEADER_fd_src_util_io_fd_io_uring_sys_h 3 : 4 : /* fd_io_uring_sys.h provides the io_uring syscall API. */ 5 : 6 : #include "../fd_util_base.h" 7 : 8 : #ifndef IORING_SETUP_R_DISABLED 9 : #define IORING_SETUP_R_DISABLED (1U<<6) 10 : #endif 11 : 12 : #ifndef IORING_SETUP_COOP_TASKRUN 13 : #define IORING_SETUP_COOP_TASKRUN (1U << 8) 14 : #endif 15 : 16 : #ifndef IORING_SETUP_SINGLE_ISSUER 17 : #define IORING_SETUP_SINGLE_ISSUER (1U<<12) 18 : #endif 19 : 20 : #ifndef IORING_SETUP_DEFER_TASKRUN 21 : #define IORING_SETUP_DEFER_TASKRUN (1U << 13) 22 : #endif 23 : 24 : #ifndef IORING_SETUP_NO_MMAP 25 : #define IORING_SETUP_NO_MMAP (1U<<14) 26 : #endif 27 : 28 0 : #define FD_IORING_REGISTER_FILES 2 29 0 : #define FD_IORING_REGISTER_RESTRICTIONS 11 30 0 : #define FD_IORING_REGISTER_ENABLE_RINGS 12 31 : 32 0 : #define FD_IORING_RESTRICTION_SQE_OP 1 33 0 : #define FD_IORING_RESTRICTION_SQE_FLAGS_ALLOWED 2 34 0 : #define FD_IORING_RESTRICTION_SQE_FLAGS_REQUIRED 3 35 : 36 : #ifndef IOSQE_CQE_SKIP_SUCCESS 37 : #define IOSQE_CQE_SKIP_SUCCESS (1U<<6) 38 : #endif 39 : 40 : struct fd_io_uring_restriction { 41 : ushort opcode; 42 : union { 43 : uchar register_op; 44 : uchar sqe_op; 45 : uchar sqe_flags; 46 : }; 47 : uchar resv; 48 : uint resv2[3]; 49 : }; 50 : 51 : typedef struct fd_io_uring_restriction fd_io_uring_restriction_t; 52 : 53 : struct fd_io_sqring_offsets { 54 : uint head; 55 : uint tail; 56 : uint ring_mask; 57 : uint ring_entries; 58 : uint flags; 59 : uint dropped; 60 : uint array; 61 : uint resv1; 62 : ulong user_addr; 63 : }; 64 : 65 : typedef struct fd_io_sqring_offsets fd_io_sqring_offsets_t; 66 : 67 : struct fd_io_cqring_offsets { 68 : uint head; 69 : uint tail; 70 : uint ring_mask; 71 : uint ring_entries; 72 : uint overflow; 73 : uint cqes; 74 : uint flags; 75 : uint resv1; 76 : ulong user_addr; 77 : }; 78 : 79 : typedef struct fd_io_cqring_offsets fd_io_cqring_offsets_t; 80 : 81 : struct fd_io_uring_params { 82 : uint sq_entries; 83 : uint cq_entries; 84 : uint flags; 85 : uint sq_thread_cpu; 86 : uint sq_thread_idle; 87 : uint features; 88 : uint wq_fd; 89 : uint resv[3]; 90 : fd_io_sqring_offsets_t sq_off; 91 : fd_io_cqring_offsets_t cq_off; 92 : }; 93 : 94 : typedef struct fd_io_uring_params fd_io_uring_params_t; 95 : 96 : FD_PROTOTYPES_BEGIN 97 : 98 : /* fd_io_uring_enter wraps the fd_io_uring_enter(2) syscall. */ 99 : 100 : int 101 : fd_io_uring_enter( int ring_fd, 102 : uint to_submit, 103 : uint min_complete, 104 : uint flags, 105 : void * arg, 106 : ulong arg_sz ); 107 : 108 : /* fd_io_uring_register wraps the io_uring_register(2) syscall. */ 109 : 110 : int 111 : fd_io_uring_register( int ring_fd, 112 : uint opcode, 113 : void const * arg, 114 : uint arg_cnt ); 115 : 116 : /* fd_io_uring_setup wraps the io_uring_setup(2) syscall. */ 117 : 118 : int 119 : fd_io_uring_setup( uint entry_cnt, 120 : fd_io_uring_params_t * p ); 121 : 122 : FD_PROTOTYPES_END 123 : 124 : #endif /* HEADER_fd_src_util_io_fd_io_uring_sys_h */