Commit | Line | Data |
---|---|---|
4f5af7b2 JA |
1 | #ifndef FIO_VERIFY_H |
2 | #define FIO_VERIFY_H | |
3 | ||
03e20d68 BC |
4 | #include <stdint.h> |
5 | ||
d3a173a9 | 6 | #define FIO_HDR_MAGIC 0xacca |
4f5af7b2 JA |
7 | |
8 | enum { | |
9 | VERIFY_NONE = 0, /* no verification */ | |
10 | VERIFY_MD5, /* md5 sum data blocks */ | |
11 | VERIFY_CRC64, /* crc64 sum data blocks */ | |
12 | VERIFY_CRC32, /* crc32 sum data blocks */ | |
13 | VERIFY_CRC32C, /* crc32c sum data blocks */ | |
14 | VERIFY_CRC32C_INTEL, /* crc32c sum data blocks with hw */ | |
15 | VERIFY_CRC16, /* crc16 sum data blocks */ | |
16 | VERIFY_CRC7, /* crc7 sum data blocks */ | |
17 | VERIFY_SHA256, /* sha256 sum data blocks */ | |
18 | VERIFY_SHA512, /* sha512 sum data blocks */ | |
844ea602 | 19 | VERIFY_XXHASH, /* xxhash sum data blocks */ |
4f5af7b2 | 20 | VERIFY_META, /* block_num, timestamp etc. */ |
7c353ceb | 21 | VERIFY_SHA1, /* sha1 sum data blocks */ |
92bf48d5 | 22 | VERIFY_PATTERN, /* verify specific patterns */ |
59245381 | 23 | VERIFY_PATTERN_NO_HDR, /* verify specific patterns, no hdr */ |
4f5af7b2 JA |
24 | VERIFY_NULL, /* pretend to verify */ |
25 | }; | |
26 | ||
27 | /* | |
28 | * A header structure associated with each checksummed data block. It is | |
29 | * followed by a checksum specific header that contains the verification | |
30 | * data. | |
31 | */ | |
32 | struct verify_header { | |
d3a173a9 JA |
33 | uint16_t magic; |
34 | uint16_t verify_type; | |
f65d1c26 | 35 | uint32_t len; |
f65d1c26 | 36 | uint64_t rand_seed; |
f65d1c26 | 37 | uint32_t crc32; |
4f5af7b2 JA |
38 | }; |
39 | ||
40 | struct vhdr_md5 { | |
34644af5 | 41 | uint32_t md5_digest[4]; |
4f5af7b2 JA |
42 | }; |
43 | struct vhdr_sha512 { | |
44 | uint8_t sha512[128]; | |
45 | }; | |
46 | struct vhdr_sha256 { | |
bc77f56f | 47 | uint8_t sha256[64]; |
4f5af7b2 | 48 | }; |
7c353ceb JA |
49 | struct vhdr_sha1 { |
50 | uint32_t sha1[5]; | |
51 | }; | |
4f5af7b2 JA |
52 | struct vhdr_crc64 { |
53 | uint64_t crc64; | |
54 | }; | |
55 | struct vhdr_crc32 { | |
56 | uint32_t crc32; | |
57 | }; | |
58 | struct vhdr_crc16 { | |
59 | uint16_t crc16; | |
60 | }; | |
61 | struct vhdr_crc7 { | |
62 | uint8_t crc7; | |
63 | }; | |
64 | struct vhdr_meta { | |
65 | uint64_t offset; | |
66 | unsigned char thread; | |
67 | unsigned short numberio; | |
68 | unsigned long time_sec; | |
69 | unsigned long time_usec; | |
70 | }; | |
844ea602 JA |
71 | struct vhdr_xxhash { |
72 | uint32_t hash; | |
73 | }; | |
4f5af7b2 JA |
74 | |
75 | /* | |
76 | * Verify helpers | |
77 | */ | |
78 | extern void populate_verify_io_u(struct thread_data *, struct io_u *); | |
79 | extern int __must_check get_next_verify(struct thread_data *td, struct io_u *); | |
f8b0bd10 JA |
80 | extern int __must_check verify_io_u(struct thread_data *, struct io_u **); |
81 | extern int verify_io_u_async(struct thread_data *, struct io_u **); | |
ce35b1ec JA |
82 | extern void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len, struct io_u *io_u, unsigned long seed, int use_seed); |
83 | extern void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len); | |
dc5bfbb2 | 84 | extern void fio_verify_init(struct thread_data *td); |
e8462bd8 JA |
85 | |
86 | /* | |
87 | * Async verify offload | |
88 | */ | |
89 | extern int verify_async_init(struct thread_data *); | |
90 | extern void verify_async_exit(struct thread_data *); | |
4f5af7b2 | 91 | |
c3546b53 | 92 | struct thread_rand32_state { |
ca09be4b JA |
93 | uint32_t s[4]; |
94 | }; | |
95 | ||
c3546b53 JA |
96 | struct thread_rand64_state { |
97 | uint64_t s[6]; | |
98 | }; | |
99 | ||
100 | struct thread_rand_state { | |
101 | uint64_t use64; | |
102 | union { | |
103 | struct thread_rand32_state state32; | |
104 | struct thread_rand64_state state64; | |
105 | }; | |
106 | }; | |
107 | ||
ca09be4b JA |
108 | /* |
109 | * For dumping current write state | |
110 | */ | |
111 | struct thread_io_list { | |
112 | uint64_t no_comps; | |
113 | uint64_t depth; | |
114 | uint64_t numberio; | |
115 | uint64_t index; | |
116 | struct thread_rand_state rand; | |
117 | uint8_t name[64]; | |
118 | uint64_t offsets[0]; | |
119 | }; | |
120 | ||
c3546b53 JA |
121 | struct thread_io_list_v1 { |
122 | uint64_t no_comps; | |
123 | uint64_t depth; | |
124 | uint64_t numberio; | |
125 | uint64_t index; | |
126 | struct thread_rand32_state rand; | |
127 | uint8_t name[64]; | |
128 | uint64_t offsets[0]; | |
129 | }; | |
130 | ||
ca09be4b JA |
131 | struct all_io_list { |
132 | uint64_t threads; | |
133 | struct thread_io_list state[0]; | |
134 | }; | |
135 | ||
c3546b53 JA |
136 | #define VSTATE_HDR_VERSION_V1 0x01 |
137 | #define VSTATE_HDR_VERSION 0x02 | |
ca09be4b JA |
138 | |
139 | struct verify_state_hdr { | |
140 | uint64_t version; | |
141 | uint64_t size; | |
142 | uint64_t crc; | |
143 | }; | |
144 | ||
145 | #define IO_LIST_ALL 0xffffffff | |
146 | extern struct all_io_list *get_all_io_list(int, size_t *); | |
147 | extern void __verify_save_state(struct all_io_list *, const char *); | |
148 | extern void verify_save_state(void); | |
149 | extern int verify_load_state(struct thread_data *, const char *); | |
150 | extern void verify_free_state(struct thread_data *); | |
151 | extern int verify_state_should_stop(struct thread_data *, struct io_u *); | |
c3546b53 JA |
152 | extern void verify_convert_assign_state(struct thread_data *, void *, int); |
153 | extern int verify_state_hdr(struct verify_state_hdr *, struct thread_io_list *, | |
154 | int *); | |
155 | ||
156 | static inline size_t __thread_io_list_sz(uint64_t depth) | |
157 | { | |
158 | return sizeof(struct thread_io_list) + depth * sizeof(uint64_t); | |
159 | } | |
ca09be4b JA |
160 | |
161 | static inline size_t thread_io_list_sz(struct thread_io_list *s) | |
162 | { | |
c3546b53 | 163 | return __thread_io_list_sz(le64_to_cpu(s->depth)); |
ca09be4b JA |
164 | } |
165 | ||
166 | static inline struct thread_io_list *io_list_next(struct thread_io_list *s) | |
167 | { | |
168 | return (void *) s + thread_io_list_sz(s); | |
169 | } | |
170 | ||
e499aedc JA |
171 | static inline void verify_state_gen_name(char *out, size_t size, |
172 | const char *name, const char *prefix, | |
173 | int num) | |
ca09be4b | 174 | { |
e499aedc JA |
175 | snprintf(out, size, "%s-%s-%d-verify.state", prefix, name, num); |
176 | out[size - 1] = '\0'; | |
ca09be4b JA |
177 | } |
178 | ||
4f5af7b2 | 179 | #endif |