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