blob: 256bf60e6fe6f50129551faa1c6cdcc0017e41a8 [file] [log] [blame]
Jens Axboe9f988e22010-03-04 10:42:38 +01001#ifndef FIO_OPTION_H
2#define FIO_OPTION_H
3
Jens Axboe07b32322010-03-05 09:48:44 +01004#define FIO_MAX_OPTS 512
5
Jens Axboef5b6bb82010-03-05 10:09:59 +01006#include <string.h>
Jens Axboe9f988e22010-03-04 10:42:38 +01007#include "parse.h"
8#include "flist.h"
9
10#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
11
Jens Axboe07b32322010-03-05 09:48:44 +010012int add_option(struct fio_option *);
13void invalidate_profile_options(const char *);
14extern char *exec_profile;
Jens Axboe9f988e22010-03-04 10:42:38 +010015
Jens Axboef5b6bb82010-03-05 10:09:59 +010016void add_opt_posval(const char *, const char *, const char *);
17void del_opt_posval(const char *, const char *);
Jens Axboe7e356b22011-10-14 10:55:16 +020018struct thread_data;
19void fio_options_free(struct thread_data *);
Jens Axboef5b6bb82010-03-05 10:09:59 +010020
Jens Axboe9af4a242012-03-16 10:13:49 +010021extern struct fio_option fio_options[FIO_MAX_OPTS];
22
Jens Axboef5b6bb82010-03-05 10:09:59 +010023static inline int o_match(struct fio_option *o, const char *opt)
24{
25 if (!strcmp(o->name, opt))
26 return 1;
27 else if (o->alias && !strcmp(o->alias, opt))
28 return 1;
29
30 return 0;
31}
32
33static inline struct fio_option *find_option(struct fio_option *options,
34 const char *opt)
35{
36 struct fio_option *o;
37
38 for (o = &options[0]; o->name; o++)
39 if (o_match(o, opt))
40 return o;
41
42 return NULL;
43}
44
Jens Axboe9af4a242012-03-16 10:13:49 +010045struct opt_group {
46 const char *name;
47 unsigned int mask;
48};
49
50enum opt_category {
Jens Axboee8b0e952012-03-19 14:37:08 +010051 __FIO_OPT_C_GENERAL = 0,
52 __FIO_OPT_C_IO,
53 __FIO_OPT_C_FILE,
54 __FIO_OPT_C_STAT,
55 __FIO_OPT_C_LOG,
56 __FIO_OPT_C_NR,
57
58 FIO_OPT_C_GENERAL = (1U << __FIO_OPT_C_GENERAL),
59 FIO_OPT_C_IO = (1U << __FIO_OPT_C_IO),
60 FIO_OPT_C_FILE = (1U << __FIO_OPT_C_FILE),
61 FIO_OPT_C_STAT = (1U << __FIO_OPT_C_STAT),
62 FIO_OPT_C_LOG = (1U << __FIO_OPT_C_LOG),
63 FIO_OPT_C_INVALID = (1U << __FIO_OPT_C_NR),
64};
65
66enum opt_category_group {
67 __FIO_OPT_G_RATE = 0,
Jens Axboee231bbe2012-03-16 19:16:27 +010068 __FIO_OPT_G_ZONE,
Jens Axboee8b0e952012-03-19 14:37:08 +010069 __FIO_OPT_G_RWMIX,
70 __FIO_OPT_G_VERIFY,
71 __FIO_OPT_G_TRIM,
72 __FIO_OPT_G_IOLOG,
73 __FIO_OPT_G_IO_DEPTH,
74 __FIO_OPT_G_IO_FLOW,
Jens Axboee231bbe2012-03-16 19:16:27 +010075 __FIO_OPT_G_NR,
Jens Axboe9af4a242012-03-16 10:13:49 +010076
Jens Axboee8b0e952012-03-19 14:37:08 +010077 FIO_OPT_G_RATE = (1U << __FIO_OPT_G_RATE),
Jens Axboe9af4a242012-03-16 10:13:49 +010078 FIO_OPT_G_ZONE = (1U << __FIO_OPT_G_ZONE),
Jens Axboee8b0e952012-03-19 14:37:08 +010079 FIO_OPT_G_RWMIX = (1U << __FIO_OPT_G_RWMIX),
80 FIO_OPT_G_VERIFY = (1U << __FIO_OPT_G_VERIFY),
81 FIO_OPT_G_TRIM = (1U << __FIO_OPT_G_TRIM),
82 FIO_OPT_G_IOLOG = (1U << __FIO_OPT_G_IOLOG),
83 FIO_OPT_G_IO_DEPTH = (1U << __FIO_OPT_G_IO_DEPTH),
84 FIO_OPT_G_IO_FLOW = (1U << __FIO_OPT_G_IO_FLOW),
Jens Axboe9af4a242012-03-16 10:13:49 +010085 FIO_OPT_G_INVALID = (1U << __FIO_OPT_G_NR),
86};
87
88extern struct opt_group *opt_group_from_mask(unsigned int *mask);
Jens Axboee8b0e952012-03-19 14:37:08 +010089extern struct opt_group *opt_group_cat_from_mask(unsigned int *mask);
Jens Axboe9af4a242012-03-16 10:13:49 +010090
Jens Axboe9f988e22010-03-04 10:42:38 +010091#endif