xref: /freebsd/sys/contrib/openzfs/cmd/raidz_test/raidz_test.h (revision e716630d4cf89e69ec3f675ebfceee09f1a85e05)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or https://opensource.org/licenses/CDDL-1.0.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (C) 2016 Gvozden Nešković. All rights reserved.
24  */
25 
26 #ifndef	RAIDZ_TEST_H
27 #define	RAIDZ_TEST_H
28 
29 #include <sys/spa.h>
30 
31 static const char *const raidz_impl_names[] = {
32 	"original",
33 	"scalar",
34 	"sse2",
35 	"ssse3",
36 	"avx2",
37 	"avx512f",
38 	"avx512bw",
39 	"aarch64_neon",
40 	"aarch64_neonx2",
41 	"powerpc_altivec",
42 	NULL
43 };
44 
45 enum raidz_verbosity {
46 	D_ALL,
47 	D_INFO,
48 	D_DEBUG,
49 };
50 
51 typedef struct raidz_test_opts {
52 	size_t rto_ashift;
53 	uint64_t rto_offset;
54 	size_t rto_dcols;
55 	size_t rto_dsize;
56 	enum raidz_verbosity rto_v;
57 	size_t rto_sweep;
58 	size_t rto_sweep_timeout;
59 	size_t rto_benchmark;
60 	size_t rto_expand;
61 	uint64_t rto_expand_offset;
62 	size_t rto_sanity;
63 	size_t rto_gdb;
64 
65 	/* non-user options */
66 	boolean_t rto_should_stop;
67 
68 	zio_t *zio_golden;
69 	raidz_map_t *rm_golden;
70 } raidz_test_opts_t;
71 
72 static const raidz_test_opts_t rto_opts_defaults = {
73 	.rto_ashift = 9,
74 	.rto_offset = 1ULL << 0,
75 	.rto_dcols = 8,
76 	.rto_dsize = 1<<19,
77 	.rto_v = D_ALL,
78 	.rto_sweep = 0,
79 	.rto_benchmark = 0,
80 	.rto_expand = 0,
81 	.rto_expand_offset = -1ULL,
82 	.rto_sanity = 0,
83 	.rto_gdb = 0,
84 	.rto_should_stop = B_FALSE
85 };
86 
87 extern raidz_test_opts_t rto_opts;
88 
ilog2(size_t a)89 static inline size_t ilog2(size_t a)
90 {
91 	return (a > 1 ? 1 + ilog2(a >> 1) : 0);
92 }
93 
94 
95 #define	LOG(lvl, ...)				\
96 {						\
97 	if (rto_opts.rto_v >= lvl)		\
98 		(void) fprintf(stdout, __VA_ARGS__);	\
99 }						\
100 
101 #define	LOG_OPT(lvl, opt, ...)			\
102 {						\
103 	if (opt->rto_v >= lvl)			\
104 		(void) fprintf(stdout, __VA_ARGS__);	\
105 }						\
106 
107 #define	ERR(...)	(void) fprintf(stderr, __VA_ARGS__)
108 
109 
110 #define	DBLSEP "================\n"
111 #define	SEP    "----------------\n"
112 
113 
114 #define	raidz_alloc(size)	abd_alloc(size, B_FALSE)
115 #define	raidz_free(p, size)	abd_free(p)
116 
117 
118 void init_zio_abd(zio_t *zio);
119 
120 void run_raidz_benchmark(void);
121 
122 #endif /* RAIDZ_TEST_H */
123