source: libcfa/src/concurrency/io/types.hfa @ b44959f

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since b44959f was 9db2c92, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

fixed missing include

  • Property mode set to 100644
File size: 3.8 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// io/types.hfa -- PRIVATE
8// Types used by the I/O subsystem
9//
10// Author           : Thierry Delisle
11// Created On       : Fri Jul 31 16:22:47 2020
12// Last Modified By :
13// Last Modified On :
14// Update Count     :
15//
16
17#pragma once
18
19extern "C" {
20        #include <linux/types.h>
21}
22
23#include "bits/locks.hfa"
24#include "kernel/fwd.hfa"
25
26#if defined(CFA_HAVE_LINUX_IO_URING_H)
27        #define LEADER_LOCK
28        struct __leaderlock_t {
29                struct $thread * volatile value;        // ($thread) next_leader | (bool:1) is_locked
30        };
31
32        static inline void ?{}( __leaderlock_t & this ) { this.value = 0p; }
33
34        //-----------------------------------------------------------------------
35        // Ring Data structure
36      struct __submition_data {
37                // Head and tail of the ring (associated with array)
38                volatile __u32 * head;
39                volatile __u32 * tail;
40                volatile __u32 prev_head;
41
42                // The actual kernel ring which uses head/tail
43                // indexes into the sqes arrays
44                __u32 * array;
45
46                // number of entries and mask to go with it
47                const __u32 * num;
48                const __u32 * mask;
49
50                // Submission flags (Not sure what for)
51                __u32 * flags;
52
53                // number of sqes not submitted (whatever that means)
54                __u32 * dropped;
55
56                // Like head/tail but not seen by the kernel
57                volatile __u32 * ready;
58                __u32 ready_cnt;
59                __u32 prev_ready;
60
61                #if defined(LEADER_LOCK)
62                        __leaderlock_t submit_lock;
63                #else
64                        __spinlock_t submit_lock;
65                #endif
66                __spinlock_t  release_lock;
67
68                // A buffer of sqes (not the actual ring)
69                volatile struct io_uring_sqe * sqes;
70
71                // The location and size of the mmaped area
72                void * ring_ptr;
73                size_t ring_sz;
74        };
75
76        struct __completion_data {
77                // Head and tail of the ring
78                volatile __u32 * head;
79                volatile __u32 * tail;
80
81                // number of entries and mask to go with it
82                const __u32 * mask;
83                const __u32 * num;
84
85                // number of cqes not submitted (whatever that means)
86                __u32 * overflow;
87
88                // the kernel ring
89                volatile struct io_uring_cqe * cqes;
90
91                // The location and size of the mmaped area
92                void * ring_ptr;
93                size_t ring_sz;
94        };
95
96        struct __io_data {
97                struct __submition_data submit_q;
98                struct __completion_data completion_q;
99                __u32 ring_flags;
100                int fd;
101                int efd;
102                bool eager_submits:1;
103                bool poller_submits:1;
104        };
105
106        //-----------------------------------------------------------------------
107        // Misc
108        // Weirdly, some systems that do support io_uring don't actually define these
109        #ifdef __alpha__
110                /*
111                * alpha is the only exception, all other architectures
112                * have common numbers for new system calls.
113                */
114                #ifndef __NR_io_uring_setup
115                        #define __NR_io_uring_setup           535
116                #endif
117                #ifndef __NR_io_uring_enter
118                        #define __NR_io_uring_enter           536
119                #endif
120                #ifndef __NR_io_uring_register
121                        #define __NR_io_uring_register        537
122                #endif
123        #else /* !__alpha__ */
124                #ifndef __NR_io_uring_setup
125                        #define __NR_io_uring_setup           425
126                #endif
127                #ifndef __NR_io_uring_enter
128                        #define __NR_io_uring_enter           426
129                #endif
130                #ifndef __NR_io_uring_register
131                        #define __NR_io_uring_register        427
132                #endif
133        #endif
134
135        struct $io_ctx_thread;
136        void __ioctx_register($io_ctx_thread & ctx);
137        void __ioctx_unregister($io_ctx_thread & ctx);
138        void __ioctx_prepare_block($io_ctx_thread & ctx);
139        void __sqe_clean( volatile struct io_uring_sqe * sqe );
140#endif
141
142//-----------------------------------------------------------------------
143// IO user data
144struct io_future_t {
145        future_t self;
146        __s32 result;
147};
148
149static inline {
150        bool fulfil( io_future_t & this, __s32 result ) {
151                this.result = result;
152                return fulfil(this.self);
153        }
154
155        // Wait for the future to be fulfilled
156        bool wait( io_future_t & this ) {
157                return wait(this.self);
158        }
159}
Note: See TracBrowser for help on using the repository browser.