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

ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change on this file since d9d8b9f was 40a606d2, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

Modified io headers so io/types.hfa can stay private

  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[3e2b9c9]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//
[454f478]7// io/types.hfa -- PRIVATE
8// Types used by the I/O subsystem
[3e2b9c9]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
[930e57e]19extern "C" {
20        #include <linux/types.h>
21}
[4998155]22
[9db2c92]23#include "bits/locks.hfa"
[11054eb]24#include "bits/queue.hfa"
[40a606d2]25#include "iofwd.hfa"
[454f478]26#include "kernel/fwd.hfa"
[3e2b9c9]27
[930e57e]28#if defined(CFA_HAVE_LINUX_IO_URING_H)
[78da4ab]29        #include "bits/sequence.hfa"
30        #include "monitor.hfa"
[2fafe7e]31
[78da4ab]32        struct processor;
33        monitor $io_arbiter;
[2fafe7e]34
[3e2b9c9]35        //-----------------------------------------------------------------------
36        // Ring Data structure
[78da4ab]37      struct __sub_ring_t {
38                struct {
39                        // Head and tail of the ring (associated with array)
40                        volatile __u32 * head;   // one passed last index consumed by the kernel
41                        volatile __u32 * tail;   // one passed last index visible to the kernel
42                        volatile __u32 released; // one passed last index released back to the free list
43
44                        // The actual kernel ring which uses head/tail
45                        // indexes into the sqes arrays
46                        __u32 * array;
47                } kring;
48
49                struct {
50                        volatile __u32 head;
51                        volatile __u32 tail;
52                        // The ring which contains free allocations
53                        // indexes into the sqes arrays
54                        __u32 * array;
55                } free_ring;
56
57                // number of sqes to submit on next system call.
58                __u32 to_submit;
[3e2b9c9]59
60                // number of entries and mask to go with it
[4998155]61                const __u32 * num;
62                const __u32 * mask;
[3e2b9c9]63
[78da4ab]64                // Submission flags, currently only IORING_SETUP_SQPOLL
[4998155]65                __u32 * flags;
[3e2b9c9]66
[78da4ab]67                // number of sqes not submitted
68                // From documentation : [dropped] is incremented for each invalid submission queue entry encountered in the ring buffer.
[4998155]69                __u32 * dropped;
[3e2b9c9]70
71                // A buffer of sqes (not the actual ring)
[78da4ab]72                struct io_uring_sqe * sqes;
[3e2b9c9]73
74                // The location and size of the mmaped area
75                void * ring_ptr;
76                size_t ring_sz;
77        };
78
[78da4ab]79        struct __cmp_ring_t {
[3e2b9c9]80                // Head and tail of the ring
[4998155]81                volatile __u32 * head;
82                volatile __u32 * tail;
[3e2b9c9]83
84                // number of entries and mask to go with it
[4998155]85                const __u32 * mask;
86                const __u32 * num;
[3e2b9c9]87
[78da4ab]88                // I don't know what this value is for
[4998155]89                __u32 * overflow;
[3e2b9c9]90
91                // the kernel ring
[426f60c]92                volatile struct io_uring_cqe * cqes;
[3e2b9c9]93
94                // The location and size of the mmaped area
95                void * ring_ptr;
96                size_t ring_sz;
97        };
98
[11054eb]99        struct __outstanding_io {
100                inline Colable;
101                single_sem sem;
102        };
103        static inline __outstanding_io *& Next( __outstanding_io * n ) { return (__outstanding_io *)Next( (Colable *)n ); }
104
105        struct __outstanding_io_queue {
106                __spinlock_t lock;
107                Queue(__outstanding_io) queue;
108                volatile bool empty;
109        };
110
111        struct __external_io {
112                inline __outstanding_io;
113                __u32 * idxs;
114                __u32 have;
115                bool lazy;
116        };
117
118
[78da4ab]119        struct __attribute__((aligned(128))) $io_context {
120                $io_arbiter * arbiter;
[dddb3dd0]121                processor * proc;
[78da4ab]122
[11054eb]123                __outstanding_io_queue ext_sq;
[78da4ab]124
125                struct __sub_ring_t sq;
126                struct __cmp_ring_t cq;
[4998155]127                __u32 ring_flags;
[3e2b9c9]128                int fd;
[78da4ab]129        };
130
[11054eb]131        struct __pending_alloc {
132                inline __outstanding_io;
133                __u32 * idxs;
134                __u32 want;
135                $io_context * ctx;
136        };
137
138        struct __attribute__((aligned(128))) $io_arbiter {
139                __outstanding_io_queue pending;
[3e2b9c9]140        };
141
142        //-----------------------------------------------------------------------
143        // Misc
144        // Weirdly, some systems that do support io_uring don't actually define these
145        #ifdef __alpha__
146                /*
147                * alpha is the only exception, all other architectures
148                * have common numbers for new system calls.
149                */
150                #ifndef __NR_io_uring_setup
151                        #define __NR_io_uring_setup           535
152                #endif
153                #ifndef __NR_io_uring_enter
154                        #define __NR_io_uring_enter           536
155                #endif
156                #ifndef __NR_io_uring_register
157                        #define __NR_io_uring_register        537
158                #endif
159        #else /* !__alpha__ */
160                #ifndef __NR_io_uring_setup
161                        #define __NR_io_uring_setup           425
162                #endif
163                #ifndef __NR_io_uring_enter
164                        #define __NR_io_uring_enter           426
165                #endif
166                #ifndef __NR_io_uring_register
167                        #define __NR_io_uring_register        427
168                #endif
169        #endif
170
[dddb3dd0]171        // void __ioctx_prepare_block($io_context & ctx);
[40a606d2]172#endif
Note: See TracBrowser for help on using the repository browser.