docs: update for new data placement options
[fio.git] / parse.h
... / ...
CommitLineData
1#ifndef FIO_PARSE_H
2#define FIO_PARSE_H
3
4#include <inttypes.h>
5#include "flist.h"
6
7/*
8 * Option types
9 */
10enum fio_opt_type {
11 FIO_OPT_INVALID = 0,
12 FIO_OPT_STR,
13 FIO_OPT_STR_ULL,
14 FIO_OPT_STR_MULTI,
15 FIO_OPT_STR_VAL,
16 FIO_OPT_STR_VAL_TIME,
17 FIO_OPT_STR_STORE,
18 FIO_OPT_RANGE,
19 FIO_OPT_INT,
20 FIO_OPT_ULL,
21 FIO_OPT_BOOL,
22 FIO_OPT_FLOAT_LIST,
23 FIO_OPT_STR_SET,
24 FIO_OPT_STR_VAL_ZONE,
25 FIO_OPT_DEPRECATED,
26 FIO_OPT_SOFT_DEPRECATED,
27 FIO_OPT_UNSUPPORTED, /* keep this last */
28};
29
30/*
31 * Match a possible value string with the integer option.
32 */
33struct value_pair {
34 const char *ival; /* string option */
35 unsigned long long oval;/* output value */
36 const char *help; /* help text for sub option */
37 int orval; /* OR value */
38 void *cb; /* sub-option callback */
39};
40
41#define OPT_LEN_MAX 8192
42#define PARSE_MAX_VP 32
43
44/*
45 * Option define
46 */
47struct fio_option {
48 const char *name; /* option name */
49 const char *lname; /* long option name */
50 const char *alias; /* possible old allowed name */
51 enum fio_opt_type type; /* option type */
52 unsigned int off1; /* potential parameters */
53 unsigned int off2;
54 unsigned int off3;
55 unsigned int off4;
56 unsigned int off5;
57 unsigned int off6;
58 unsigned long long maxval; /* max and min value */
59 int minval;
60 double maxfp; /* max and min floating value */
61 double minfp;
62 unsigned int interval; /* client hint for suitable interval */
63 unsigned int maxlen; /* max length */
64 int neg; /* negate value stored */
65 int prio;
66 void *cb; /* callback */
67 const char *help; /* help text for option */
68 const char *def; /* default setting */
69 struct value_pair posval[PARSE_MAX_VP];/* possible values */
70 const char *parent; /* parent option */
71 int hide; /* hide if parent isn't set */
72 int hide_on_set; /* hide on set, not on unset */
73 const char *inverse; /* if set, apply opposite action to this option */
74 struct fio_option *inv_opt; /* cached lookup */
75 int (*verify)(const struct fio_option *, void *);
76 const char *prof_name; /* only valid for specific profile */
77 void *prof_opts;
78 uint64_t category; /* what type of option */
79 uint64_t group; /* who to group with */
80 void *gui_data;
81 int is_seconds; /* time value with seconds base */
82 int is_time; /* time based value */
83 int no_warn_def;
84 int pow2; /* must be a power-of-2 */
85 int no_free;
86};
87
88extern int parse_option(char *, const char *, const struct fio_option *,
89 const struct fio_option **, void *,
90 struct flist_head *);
91extern void sort_options(char **, const struct fio_option *, int);
92extern int parse_cmd_option(const char *t, const char *l,
93 const struct fio_option *, void *,
94 struct flist_head *);
95extern int show_cmd_help(const struct fio_option *, const char *);
96extern void fill_default_options(void *, const struct fio_option *);
97extern void options_init(struct fio_option *);
98extern void options_mem_dupe(const struct fio_option *, void *);
99extern void options_free(const struct fio_option *, void *);
100
101extern void strip_blank_front(char **);
102extern void strip_blank_end(char *);
103extern int str_to_decimal(const char *, long long *, int, void *, int, int);
104extern int check_str_bytes(const char *p, long long *val, void *data);
105extern int check_str_time(const char *p, long long *val, int);
106extern int str_to_float(const char *str, double *val, int is_time);
107
108extern int string_distance(const char *s1, const char *s2);
109extern int string_distance_ok(const char *s1, int dist);
110
111/*
112 * Handlers for the options
113 */
114typedef int (fio_opt_str_fn)(void *, const char *);
115typedef int (fio_opt_str_val_fn)(void *, long long *);
116typedef int (fio_opt_int_fn)(void *, int *);
117
118struct thread_options;
119static inline void *td_var(void *to, const struct fio_option *o,
120 unsigned int offset)
121{
122 void *ret;
123
124 if (o->prof_opts)
125 ret = o->prof_opts;
126 else
127 ret = to;
128
129 return (void *) ((uintptr_t) ret + offset);
130}
131
132static inline int parse_is_percent(unsigned long long val)
133{
134 return val >= -101ULL;
135}
136
137#define ZONE_BASE_VAL ((-1ULL >> 1) + 1)
138static inline int parse_is_percent_uncapped(unsigned long long val)
139{
140 return ZONE_BASE_VAL + -1U < val;
141}
142
143static inline int parse_is_zone(unsigned long long val)
144{
145 return (val - ZONE_BASE_VAL) <= -1U;
146}
147
148struct print_option {
149 struct flist_head list;
150 char *name;
151 char *value;
152};
153
154#endif