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