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 -- |
---|
8 | // |
---|
9 | // Author : Thierry Delisle |
---|
10 | // Created On : Fri Jul 31 16:22:47 2020 |
---|
11 | // Last Modified By : |
---|
12 | // Last Modified On : |
---|
13 | // Update Count : |
---|
14 | // |
---|
15 | |
---|
16 | #pragma once |
---|
17 | |
---|
18 | #if defined(CFA_HAVE_LINUX_IO_URING_H) |
---|
19 | #include "bits/locks.hfa" |
---|
20 | |
---|
21 | //----------------------------------------------------------------------- |
---|
22 | // Ring Data structure |
---|
23 | struct __submition_data { |
---|
24 | // Head and tail of the ring (associated with array) |
---|
25 | volatile uint32_t * head; |
---|
26 | volatile uint32_t * tail; |
---|
27 | volatile uint32_t prev_head; |
---|
28 | |
---|
29 | // The actual kernel ring which uses head/tail |
---|
30 | // indexes into the sqes arrays |
---|
31 | uint32_t * array; |
---|
32 | |
---|
33 | // number of entries and mask to go with it |
---|
34 | const uint32_t * num; |
---|
35 | const uint32_t * mask; |
---|
36 | |
---|
37 | // Submission flags (Not sure what for) |
---|
38 | uint32_t * flags; |
---|
39 | |
---|
40 | // number of sqes not submitted (whatever that means) |
---|
41 | uint32_t * dropped; |
---|
42 | |
---|
43 | // Like head/tail but not seen by the kernel |
---|
44 | volatile uint32_t * ready; |
---|
45 | uint32_t ready_cnt; |
---|
46 | |
---|
47 | __spinlock_t lock; |
---|
48 | __spinlock_t release_lock; |
---|
49 | |
---|
50 | // A buffer of sqes (not the actual ring) |
---|
51 | struct io_uring_sqe * sqes; |
---|
52 | |
---|
53 | // The location and size of the mmaped area |
---|
54 | void * ring_ptr; |
---|
55 | size_t ring_sz; |
---|
56 | }; |
---|
57 | |
---|
58 | struct __completion_data { |
---|
59 | // Head and tail of the ring |
---|
60 | volatile uint32_t * head; |
---|
61 | volatile uint32_t * tail; |
---|
62 | |
---|
63 | // number of entries and mask to go with it |
---|
64 | const uint32_t * mask; |
---|
65 | const uint32_t * num; |
---|
66 | |
---|
67 | // number of cqes not submitted (whatever that means) |
---|
68 | uint32_t * overflow; |
---|
69 | |
---|
70 | // the kernel ring |
---|
71 | struct io_uring_cqe * cqes; |
---|
72 | |
---|
73 | // The location and size of the mmaped area |
---|
74 | void * ring_ptr; |
---|
75 | size_t ring_sz; |
---|
76 | }; |
---|
77 | |
---|
78 | struct __io_data { |
---|
79 | struct __submition_data submit_q; |
---|
80 | struct __completion_data completion_q; |
---|
81 | uint32_t ring_flags; |
---|
82 | int fd; |
---|
83 | bool eager_submits:1; |
---|
84 | bool poller_submits:1; |
---|
85 | }; |
---|
86 | |
---|
87 | |
---|
88 | //----------------------------------------------------------------------- |
---|
89 | // IO user data |
---|
90 | struct __io_user_data_t { |
---|
91 | int32_t result; |
---|
92 | $thread * thrd; |
---|
93 | }; |
---|
94 | |
---|
95 | //----------------------------------------------------------------------- |
---|
96 | // Misc |
---|
97 | // Weirdly, some systems that do support io_uring don't actually define these |
---|
98 | #ifdef __alpha__ |
---|
99 | /* |
---|
100 | * alpha is the only exception, all other architectures |
---|
101 | * have common numbers for new system calls. |
---|
102 | */ |
---|
103 | #ifndef __NR_io_uring_setup |
---|
104 | #define __NR_io_uring_setup 535 |
---|
105 | #endif |
---|
106 | #ifndef __NR_io_uring_enter |
---|
107 | #define __NR_io_uring_enter 536 |
---|
108 | #endif |
---|
109 | #ifndef __NR_io_uring_register |
---|
110 | #define __NR_io_uring_register 537 |
---|
111 | #endif |
---|
112 | #else /* !__alpha__ */ |
---|
113 | #ifndef __NR_io_uring_setup |
---|
114 | #define __NR_io_uring_setup 425 |
---|
115 | #endif |
---|
116 | #ifndef __NR_io_uring_enter |
---|
117 | #define __NR_io_uring_enter 426 |
---|
118 | #endif |
---|
119 | #ifndef __NR_io_uring_register |
---|
120 | #define __NR_io_uring_register 427 |
---|
121 | #endif |
---|
122 | #endif |
---|
123 | |
---|
124 | struct epoll_event; |
---|
125 | struct $io_ctx_thread; |
---|
126 | void __ioctx_register($io_ctx_thread & ctx, struct epoll_event & ev); |
---|
127 | void __ioctx_prepare_block($io_ctx_thread & ctx, struct epoll_event & ev); |
---|
128 | #endif |
---|