]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - cmd/raidz_test/raidz_test.h
Add RAID-Z routines for SSE2 instruction set, in x86_64 mode.
[FreeBSD/FreeBSD.git] / cmd / raidz_test / raidz_test.h
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 http://www.opensolaris.org/os/licensing.
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 *raidz_impl_names[] = {
32         "original",
33         "scalar",
34         "sse2",
35         "ssse3",
36         "avx2",
37         NULL
38 };
39
40 typedef struct raidz_test_opts {
41         size_t rto_ashift;
42         size_t rto_offset;
43         size_t rto_dcols;
44         size_t rto_dsize;
45         size_t rto_v;
46         size_t rto_sweep;
47         size_t rto_sweep_timeout;
48         size_t rto_benchmark;
49         size_t rto_sanity;
50         size_t rto_gdb;
51
52         zio_t *zio_golden;
53         raidz_map_t *rm_golden;
54 } raidz_test_opts_t;
55
56 static const raidz_test_opts_t rto_opts_defaults = {
57         .rto_ashift = 9,
58         .rto_offset = 1ULL << 0,
59         .rto_dcols = 8,
60         .rto_dsize = 1<<19,
61         .rto_v = 0,
62         .rto_sweep = 0,
63         .rto_benchmark = 0,
64         .rto_sanity = 0,
65         .rto_gdb = 0
66 };
67
68 extern raidz_test_opts_t rto_opts;
69
70 static inline size_t ilog2(size_t a)
71 {
72         return (a > 1 ? 1 + ilog2(a >> 1) : 0);
73 }
74
75
76 #define D_ALL   0
77 #define D_INFO  1
78 #define D_DEBUG 2
79
80 #define LOG(lvl, a...)                          \
81 {                                               \
82         if (rto_opts.rto_v >= lvl)              \
83                 (void) fprintf(stdout, a);      \
84 }                                               \
85
86 #define LOG_OPT(lvl, opt, a...)                 \
87 {                                               \
88         if (opt->rto_v >= lvl)                  \
89                 (void) fprintf(stdout, a);      \
90 }                                               \
91
92 #define ERR(a...)       (void) fprintf(stderr, a)
93
94
95 #define DBLSEP "================\n"
96 #define SEP    "----------------\n"
97
98
99 #define raidz_alloc(size)       zio_data_buf_alloc(size)
100 #define raidz_free(p, size)     zio_data_buf_free(p, size)
101
102
103 void init_zio_data(zio_t *zio);
104
105 void run_raidz_benchmark(void);
106
107 #endif /* RAIDZ_TEST_H */