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