| 1 | #include <stdio.h> |
| 2 | #include <inttypes.h> |
| 3 | #include "optgroup.h" |
| 4 | |
| 5 | /* |
| 6 | * Option grouping |
| 7 | */ |
| 8 | static const struct opt_group fio_opt_groups[] = { |
| 9 | { |
| 10 | .name = "General", |
| 11 | .mask = FIO_OPT_C_GENERAL, |
| 12 | }, |
| 13 | { |
| 14 | .name = "I/O", |
| 15 | .mask = FIO_OPT_C_IO, |
| 16 | }, |
| 17 | { |
| 18 | .name = "File", |
| 19 | .mask = FIO_OPT_C_FILE, |
| 20 | }, |
| 21 | { |
| 22 | .name = "Statistics", |
| 23 | .mask = FIO_OPT_C_STAT, |
| 24 | }, |
| 25 | { |
| 26 | .name = "Logging", |
| 27 | .mask = FIO_OPT_C_LOG, |
| 28 | }, |
| 29 | { |
| 30 | .name = "Profiles", |
| 31 | .mask = FIO_OPT_C_PROFILE, |
| 32 | }, |
| 33 | { |
| 34 | .name = NULL, |
| 35 | }, |
| 36 | }; |
| 37 | |
| 38 | static const struct opt_group fio_opt_cat_groups[] = { |
| 39 | { |
| 40 | .name = "Latency profiling", |
| 41 | .mask = FIO_OPT_G_LATPROF, |
| 42 | }, |
| 43 | { |
| 44 | .name = "Rate", |
| 45 | .mask = FIO_OPT_G_RATE, |
| 46 | }, |
| 47 | { |
| 48 | .name = "Zone", |
| 49 | .mask = FIO_OPT_G_ZONE, |
| 50 | }, |
| 51 | { |
| 52 | .name = "Read/write mix", |
| 53 | .mask = FIO_OPT_G_RWMIX, |
| 54 | }, |
| 55 | { |
| 56 | .name = "Verify", |
| 57 | .mask = FIO_OPT_G_VERIFY, |
| 58 | }, |
| 59 | { |
| 60 | .name = "Trim", |
| 61 | .mask = FIO_OPT_G_TRIM, |
| 62 | }, |
| 63 | { |
| 64 | .name = "I/O Logging", |
| 65 | .mask = FIO_OPT_G_IOLOG, |
| 66 | }, |
| 67 | { |
| 68 | .name = "I/O Depth", |
| 69 | .mask = FIO_OPT_G_IO_DEPTH, |
| 70 | }, |
| 71 | { |
| 72 | .name = "I/O Flow", |
| 73 | .mask = FIO_OPT_G_IO_FLOW, |
| 74 | }, |
| 75 | { |
| 76 | .name = "Description", |
| 77 | .mask = FIO_OPT_G_DESC, |
| 78 | }, |
| 79 | { |
| 80 | .name = "Filename", |
| 81 | .mask = FIO_OPT_G_FILENAME, |
| 82 | }, |
| 83 | { |
| 84 | .name = "General I/O", |
| 85 | .mask = FIO_OPT_G_IO_BASIC, |
| 86 | }, |
| 87 | { |
| 88 | .name = "Cgroups", |
| 89 | .mask = FIO_OPT_G_CGROUP, |
| 90 | }, |
| 91 | { |
| 92 | .name = "Runtime", |
| 93 | .mask = FIO_OPT_G_RUNTIME, |
| 94 | }, |
| 95 | { |
| 96 | .name = "Process", |
| 97 | .mask = FIO_OPT_G_PROCESS, |
| 98 | }, |
| 99 | { |
| 100 | .name = "Job credentials / priority", |
| 101 | .mask = FIO_OPT_G_CRED, |
| 102 | }, |
| 103 | { |
| 104 | .name = "Clock settings", |
| 105 | .mask = FIO_OPT_G_CLOCK, |
| 106 | }, |
| 107 | { |
| 108 | .name = "I/O Type", |
| 109 | .mask = FIO_OPT_G_IO_TYPE, |
| 110 | }, |
| 111 | { |
| 112 | .name = "I/O Thinktime", |
| 113 | .mask = FIO_OPT_G_THINKTIME, |
| 114 | }, |
| 115 | { |
| 116 | .name = "Randomizations", |
| 117 | .mask = FIO_OPT_G_RANDOM, |
| 118 | }, |
| 119 | { |
| 120 | .name = "I/O buffers", |
| 121 | .mask = FIO_OPT_G_IO_BUF, |
| 122 | }, |
| 123 | { |
| 124 | .name = "Tiobench profile", |
| 125 | .mask = FIO_OPT_G_TIOBENCH, |
| 126 | }, |
| 127 | { |
| 128 | .name = "MTD", |
| 129 | .mask = FIO_OPT_G_MTD, |
| 130 | }, |
| 131 | |
| 132 | { |
| 133 | .name = NULL, |
| 134 | } |
| 135 | }; |
| 136 | |
| 137 | static const struct opt_group *group_from_mask(const struct opt_group *ogs, |
| 138 | uint64_t *mask, |
| 139 | uint64_t inv_mask) |
| 140 | { |
| 141 | int i; |
| 142 | |
| 143 | if (*mask == inv_mask || !*mask) |
| 144 | return NULL; |
| 145 | |
| 146 | for (i = 0; ogs[i].name; i++) { |
| 147 | const struct opt_group *og = &ogs[i]; |
| 148 | |
| 149 | if (*mask & og->mask) { |
| 150 | *mask &= ~(og->mask); |
| 151 | return og; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | return NULL; |
| 156 | } |
| 157 | |
| 158 | const struct opt_group *opt_group_from_mask(uint64_t *mask) |
| 159 | { |
| 160 | return group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID); |
| 161 | } |
| 162 | |
| 163 | const struct opt_group *opt_group_cat_from_mask(uint64_t *mask) |
| 164 | { |
| 165 | return group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID); |
| 166 | } |