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