options: add debug code for failure to lookup option names
[fio.git] / options.h
1 #ifndef FIO_OPTION_H
2 #define FIO_OPTION_H
3
4 #define FIO_MAX_OPTS            512
5
6 #include <string.h>
7 #include "parse.h"
8 #include "flist.h"
9
10 #define td_var_offset(var)      ((size_t) &((struct thread_options *)0)->var)
11
12 int add_option(struct fio_option *);
13 void invalidate_profile_options(const char *);
14 extern char *exec_profile;
15
16 void add_opt_posval(const char *, const char *, const char *);
17 void del_opt_posval(const char *, const char *);
18 struct thread_data;
19 void fio_options_free(struct thread_data *);
20 char *get_name_idx(char *, int);
21 int set_name_idx(char *, char *, int);
22
23 extern struct fio_option fio_options[FIO_MAX_OPTS];
24
25 extern int __fio_option_is_set(struct thread_options *, unsigned int off);
26
27 #define fio_option_is_set(__td, name)                                   \
28 ({                                                                      \
29         int __r = __fio_option_is_set((__td), td_var_offset(name));     \
30         if (__r == -1) {                                                \
31                 log_err("fio: wanted %s\n", __fio_stringify(name));     \
32                 __r = 0;                                                \
33         }                                                               \
34         __r;                                                            \
35 })
36
37 extern void fio_option_mark_set(struct thread_options *, struct fio_option *);
38
39 static inline int o_match(struct fio_option *o, const char *opt)
40 {
41         if (!strcmp(o->name, opt))
42                 return 1;
43         else if (o->alias && !strcmp(o->alias, opt))
44                 return 1;
45
46         return 0;
47 }
48
49 static inline struct fio_option *find_option(struct fio_option *options,
50                                              const char *opt)
51 {
52         struct fio_option *o;
53
54         for (o = &options[0]; o->name; o++)
55                 if (o_match(o, opt))
56                         return o;
57
58         return NULL;
59 }
60
61 struct opt_group {
62         const char *name;
63         unsigned int mask;
64 };
65
66 enum opt_category {
67         __FIO_OPT_C_GENERAL     = 0,
68         __FIO_OPT_C_IO,
69         __FIO_OPT_C_FILE,
70         __FIO_OPT_C_STAT,
71         __FIO_OPT_C_LOG,
72         __FIO_OPT_C_PROFILE,
73         __FIO_OPT_C_ENGINE,
74         __FIO_OPT_C_NR,
75
76         FIO_OPT_C_GENERAL       = (1U << __FIO_OPT_C_GENERAL),
77         FIO_OPT_C_IO            = (1U << __FIO_OPT_C_IO),
78         FIO_OPT_C_FILE          = (1U << __FIO_OPT_C_FILE),
79         FIO_OPT_C_STAT          = (1U << __FIO_OPT_C_STAT),
80         FIO_OPT_C_LOG           = (1U << __FIO_OPT_C_LOG),
81         FIO_OPT_C_PROFILE       = (1U << __FIO_OPT_C_PROFILE),
82         FIO_OPT_C_ENGINE        = (1U << __FIO_OPT_C_ENGINE),
83         FIO_OPT_C_INVALID       = (1U << __FIO_OPT_C_NR),
84 };
85
86 enum opt_category_group {
87         __FIO_OPT_G_RATE        = 0,
88         __FIO_OPT_G_ZONE,
89         __FIO_OPT_G_RWMIX,
90         __FIO_OPT_G_VERIFY,
91         __FIO_OPT_G_TRIM,
92         __FIO_OPT_G_IOLOG,
93         __FIO_OPT_G_IO_DEPTH,
94         __FIO_OPT_G_IO_FLOW,
95         __FIO_OPT_G_DESC,
96         __FIO_OPT_G_FILENAME,
97         __FIO_OPT_G_IO_BASIC,
98         __FIO_OPT_G_CGROUP,
99         __FIO_OPT_G_RUNTIME,
100         __FIO_OPT_G_PROCESS,
101         __FIO_OPT_G_CRED,
102         __FIO_OPT_G_CLOCK,
103         __FIO_OPT_G_IO_TYPE,
104         __FIO_OPT_G_THINKTIME,
105         __FIO_OPT_G_RANDOM,
106         __FIO_OPT_G_IO_BUF,
107         __FIO_OPT_G_TIOBENCH,
108         __FIO_OPT_G_ERR,
109         __FIO_OPT_G_E4DEFRAG,
110         __FIO_OPT_G_NETIO,
111         __FIO_OPT_G_LIBAIO,
112         __FIO_OPT_G_ACT,
113         __FIO_OPT_G_LATPROF,
114         __FIO_OPT_G_RBD,
115         __FIO_OPT_G_GFAPI,
116         __FIO_OPT_G_NR,
117
118         FIO_OPT_G_RATE          = (1U << __FIO_OPT_G_RATE),
119         FIO_OPT_G_ZONE          = (1U << __FIO_OPT_G_ZONE),
120         FIO_OPT_G_RWMIX         = (1U << __FIO_OPT_G_RWMIX),
121         FIO_OPT_G_VERIFY        = (1U << __FIO_OPT_G_VERIFY),
122         FIO_OPT_G_TRIM          = (1U << __FIO_OPT_G_TRIM),
123         FIO_OPT_G_IOLOG         = (1U << __FIO_OPT_G_IOLOG),
124         FIO_OPT_G_IO_DEPTH      = (1U << __FIO_OPT_G_IO_DEPTH),
125         FIO_OPT_G_IO_FLOW       = (1U << __FIO_OPT_G_IO_FLOW),
126         FIO_OPT_G_DESC          = (1U << __FIO_OPT_G_DESC),
127         FIO_OPT_G_FILENAME      = (1U << __FIO_OPT_G_FILENAME),
128         FIO_OPT_G_IO_BASIC      = (1U << __FIO_OPT_G_IO_BASIC),
129         FIO_OPT_G_CGROUP        = (1U << __FIO_OPT_G_CGROUP),
130         FIO_OPT_G_RUNTIME       = (1U << __FIO_OPT_G_RUNTIME),
131         FIO_OPT_G_PROCESS       = (1U << __FIO_OPT_G_PROCESS),
132         FIO_OPT_G_CRED          = (1U << __FIO_OPT_G_CRED),
133         FIO_OPT_G_CLOCK         = (1U << __FIO_OPT_G_CLOCK),
134         FIO_OPT_G_IO_TYPE       = (1U << __FIO_OPT_G_IO_TYPE),
135         FIO_OPT_G_THINKTIME     = (1U << __FIO_OPT_G_THINKTIME),
136         FIO_OPT_G_RANDOM        = (1U << __FIO_OPT_G_RANDOM),
137         FIO_OPT_G_IO_BUF        = (1U << __FIO_OPT_G_IO_BUF),
138         FIO_OPT_G_TIOBENCH      = (1U << __FIO_OPT_G_TIOBENCH),
139         FIO_OPT_G_ERR           = (1U << __FIO_OPT_G_ERR),
140         FIO_OPT_G_E4DEFRAG      = (1U << __FIO_OPT_G_E4DEFRAG),
141         FIO_OPT_G_NETIO         = (1U << __FIO_OPT_G_NETIO),
142         FIO_OPT_G_LIBAIO        = (1U << __FIO_OPT_G_LIBAIO),
143         FIO_OPT_G_ACT           = (1U << __FIO_OPT_G_ACT),
144         FIO_OPT_G_LATPROF       = (1U << __FIO_OPT_G_LATPROF),
145         FIO_OPT_G_RBD           = (1U << __FIO_OPT_G_RBD),
146         FIO_OPT_G_GFAPI         = (1U << __FIO_OPT_G_GFAPI),
147         FIO_OPT_G_INVALID       = (1U << __FIO_OPT_G_NR),
148 };
149
150 extern struct opt_group *opt_group_from_mask(unsigned int *mask);
151 extern struct opt_group *opt_group_cat_from_mask(unsigned int *mask);
152 extern struct fio_option *fio_option_find(const char *name);
153 extern unsigned int fio_get_kb_base(void *);
154
155 #endif