Commit | Line | Data |
---|---|---|
d220c761 JA |
1 | #include <stdio.h> |
2 | #include <inttypes.h> | |
3 | #include "optgroup.h" | |
96344ff0 | 4 | #include "compiler/compiler.h" |
d220c761 JA |
5 | |
6 | /* | |
7 | * Option grouping | |
8 | */ | |
9 | static const struct opt_group fio_opt_groups[] = { | |
10 | { | |
11 | .name = "General", | |
12 | .mask = FIO_OPT_C_GENERAL, | |
13 | }, | |
14 | { | |
15 | .name = "I/O", | |
16 | .mask = FIO_OPT_C_IO, | |
17 | }, | |
18 | { | |
19 | .name = "File", | |
20 | .mask = FIO_OPT_C_FILE, | |
21 | }, | |
22 | { | |
23 | .name = "Statistics", | |
24 | .mask = FIO_OPT_C_STAT, | |
25 | }, | |
26 | { | |
27 | .name = "Logging", | |
28 | .mask = FIO_OPT_C_LOG, | |
29 | }, | |
30 | { | |
31 | .name = "Profiles", | |
32 | .mask = FIO_OPT_C_PROFILE, | |
33 | }, | |
9cf163b0 TK |
34 | { |
35 | .name = "I/O engines", | |
36 | .mask = FIO_OPT_C_ENGINE, | |
37 | }, | |
d220c761 JA |
38 | { |
39 | .name = NULL, | |
40 | }, | |
41 | }; | |
42 | ||
43 | static const struct opt_group fio_opt_cat_groups[] = { | |
d220c761 JA |
44 | { |
45 | .name = "Rate", | |
46 | .mask = FIO_OPT_G_RATE, | |
47 | }, | |
48 | { | |
49 | .name = "Zone", | |
50 | .mask = FIO_OPT_G_ZONE, | |
51 | }, | |
52 | { | |
53 | .name = "Read/write mix", | |
54 | .mask = FIO_OPT_G_RWMIX, | |
55 | }, | |
56 | { | |
57 | .name = "Verify", | |
58 | .mask = FIO_OPT_G_VERIFY, | |
59 | }, | |
60 | { | |
61 | .name = "Trim", | |
62 | .mask = FIO_OPT_G_TRIM, | |
63 | }, | |
64 | { | |
65 | .name = "I/O Logging", | |
66 | .mask = FIO_OPT_G_IOLOG, | |
67 | }, | |
68 | { | |
69 | .name = "I/O Depth", | |
70 | .mask = FIO_OPT_G_IO_DEPTH, | |
71 | }, | |
72 | { | |
73 | .name = "I/O Flow", | |
74 | .mask = FIO_OPT_G_IO_FLOW, | |
75 | }, | |
76 | { | |
77 | .name = "Description", | |
78 | .mask = FIO_OPT_G_DESC, | |
79 | }, | |
80 | { | |
81 | .name = "Filename", | |
82 | .mask = FIO_OPT_G_FILENAME, | |
83 | }, | |
84 | { | |
85 | .name = "General I/O", | |
86 | .mask = FIO_OPT_G_IO_BASIC, | |
87 | }, | |
88 | { | |
89 | .name = "Cgroups", | |
90 | .mask = FIO_OPT_G_CGROUP, | |
91 | }, | |
92 | { | |
93 | .name = "Runtime", | |
94 | .mask = FIO_OPT_G_RUNTIME, | |
95 | }, | |
96 | { | |
97 | .name = "Process", | |
98 | .mask = FIO_OPT_G_PROCESS, | |
99 | }, | |
100 | { | |
101 | .name = "Job credentials / priority", | |
102 | .mask = FIO_OPT_G_CRED, | |
103 | }, | |
104 | { | |
105 | .name = "Clock settings", | |
106 | .mask = FIO_OPT_G_CLOCK, | |
107 | }, | |
108 | { | |
109 | .name = "I/O Type", | |
110 | .mask = FIO_OPT_G_IO_TYPE, | |
111 | }, | |
112 | { | |
113 | .name = "I/O Thinktime", | |
114 | .mask = FIO_OPT_G_THINKTIME, | |
115 | }, | |
116 | { | |
117 | .name = "Randomizations", | |
118 | .mask = FIO_OPT_G_RANDOM, | |
119 | }, | |
120 | { | |
121 | .name = "I/O buffers", | |
122 | .mask = FIO_OPT_G_IO_BUF, | |
123 | }, | |
124 | { | |
125 | .name = "Tiobench profile", | |
126 | .mask = FIO_OPT_G_TIOBENCH, | |
127 | }, | |
128 | { | |
9cf163b0 TK |
129 | .name = "Error handling", |
130 | .mask = FIO_OPT_G_ERR, | |
131 | }, | |
132 | { | |
133 | .name = "Ext4 defrag I/O engine", /* e4defrag */ | |
134 | .mask = FIO_OPT_G_E4DEFRAG, | |
135 | }, | |
136 | { | |
137 | .name = "Network I/O engine", /* net */ | |
138 | .mask = FIO_OPT_G_NETIO, | |
139 | }, | |
140 | { | |
141 | .name = "RDMA I/O engine", /* rdma */ | |
142 | .mask = FIO_OPT_G_RDMA, | |
143 | }, | |
144 | { | |
145 | .name = "libaio I/O engine", /* libaio */ | |
146 | .mask = FIO_OPT_G_LIBAIO, | |
147 | }, | |
148 | { | |
149 | .name = "ACT Aerospike like benchmark profile", | |
150 | .mask = FIO_OPT_G_ACT, | |
151 | }, | |
152 | { | |
153 | .name = "Latency profiling", | |
154 | .mask = FIO_OPT_G_LATPROF, | |
155 | }, | |
156 | { | |
157 | .name = "RBD I/O engine", /* rbd */ | |
158 | .mask = FIO_OPT_G_RBD, | |
159 | }, | |
160 | { | |
161 | .name = "GlusterFS I/O engine", /* gfapi,gfapi_async */ | |
162 | .mask = FIO_OPT_G_GFAPI, | |
163 | }, | |
164 | { | |
165 | .name = "MTD I/O engine", /* mtd */ | |
d220c761 JA |
166 | .mask = FIO_OPT_G_MTD, |
167 | }, | |
9cf163b0 TK |
168 | { |
169 | .name = "libhdfs I/O engine", /* libhdfs */ | |
170 | .mask = FIO_OPT_G_HDFS, | |
171 | }, | |
d220c761 JA |
172 | { |
173 | .name = NULL, | |
9cf163b0 | 174 | }, |
d220c761 JA |
175 | }; |
176 | ||
177 | static const struct opt_group *group_from_mask(const struct opt_group *ogs, | |
178 | uint64_t *mask, | |
179 | uint64_t inv_mask) | |
180 | { | |
181 | int i; | |
182 | ||
183 | if (*mask == inv_mask || !*mask) | |
184 | return NULL; | |
185 | ||
186 | for (i = 0; ogs[i].name; i++) { | |
187 | const struct opt_group *og = &ogs[i]; | |
188 | ||
189 | if (*mask & og->mask) { | |
190 | *mask &= ~(og->mask); | |
191 | return og; | |
192 | } | |
193 | } | |
194 | ||
195 | return NULL; | |
196 | } | |
197 | ||
198 | const struct opt_group *opt_group_from_mask(uint64_t *mask) | |
199 | { | |
200 | return group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID); | |
201 | } | |
202 | ||
203 | const struct opt_group *opt_group_cat_from_mask(uint64_t *mask) | |
204 | { | |
69c594d8 JA |
205 | compiletime_assert(__FIO_OPT_G_NR <= 8 * sizeof(uint64_t), |
206 | "__FIO_OPT_G_NR"); | |
207 | ||
d220c761 JA |
208 | return group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID); |
209 | } |