// // Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // io/types.hfa -- // // Author : Thierry Delisle // Created On : Fri Jul 31 16:22:47 2020 // Last Modified By : // Last Modified On : // Update Count : // #pragma once #if defined(CFA_HAVE_LINUX_IO_URING_H) extern "C" { #include } #include "bits/locks.hfa" #define LEADER_LOCK struct __leaderlock_t { struct $thread * volatile value; // ($thread) next_leader | (bool:1) is_locked }; static inline void ?{}( __leaderlock_t & this ) { this.value = 0p; } //----------------------------------------------------------------------- // Ring Data structure struct __submition_data { // Head and tail of the ring (associated with array) volatile __u32 * head; volatile __u32 * tail; volatile __u32 prev_head; // The actual kernel ring which uses head/tail // indexes into the sqes arrays __u32 * array; // number of entries and mask to go with it const __u32 * num; const __u32 * mask; // Submission flags (Not sure what for) __u32 * flags; // number of sqes not submitted (whatever that means) __u32 * dropped; // Like head/tail but not seen by the kernel volatile __u32 * ready; __u32 ready_cnt; __u32 prev_ready; #if defined(LEADER_LOCK) __leaderlock_t submit_lock; #else __spinlock_t submit_lock; #endif __spinlock_t release_lock; // A buffer of sqes (not the actual ring) struct io_uring_sqe * sqes; // The location and size of the mmaped area void * ring_ptr; size_t ring_sz; }; struct __completion_data { // Head and tail of the ring volatile __u32 * head; volatile __u32 * tail; // number of entries and mask to go with it const __u32 * mask; const __u32 * num; // number of cqes not submitted (whatever that means) __u32 * overflow; // the kernel ring struct io_uring_cqe * cqes; // The location and size of the mmaped area void * ring_ptr; size_t ring_sz; }; struct __io_data { struct __submition_data submit_q; struct __completion_data completion_q; __u32 ring_flags; int fd; bool eager_submits:1; bool poller_submits:1; }; //----------------------------------------------------------------------- // IO user data struct __io_user_data_t { __s32 result; oneshot sem; }; //----------------------------------------------------------------------- // Misc // Weirdly, some systems that do support io_uring don't actually define these #ifdef __alpha__ /* * alpha is the only exception, all other architectures * have common numbers for new system calls. */ #ifndef __NR_io_uring_setup #define __NR_io_uring_setup 535 #endif #ifndef __NR_io_uring_enter #define __NR_io_uring_enter 536 #endif #ifndef __NR_io_uring_register #define __NR_io_uring_register 537 #endif #else /* !__alpha__ */ #ifndef __NR_io_uring_setup #define __NR_io_uring_setup 425 #endif #ifndef __NR_io_uring_enter #define __NR_io_uring_enter 426 #endif #ifndef __NR_io_uring_register #define __NR_io_uring_register 427 #endif #endif struct epoll_event; struct $io_ctx_thread; void __ioctx_register($io_ctx_thread & ctx, struct epoll_event & ev); void __ioctx_prepare_block($io_ctx_thread & ctx, struct epoll_event & ev); #endif