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