]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | /********************************************************************** |
2 | Copyright(c) 2011-2015 Intel Corporation All rights reserved. | |
3 | ||
4 | Redistribution and use in source and binary forms, with or without | |
5 | modification, are permitted provided that the following conditions | |
6 | are met: | |
7 | * Redistributions of source code must retain the above copyright | |
8 | notice, this list of conditions and the following disclaimer. | |
9 | * Redistributions in binary form must reproduce the above copyright | |
10 | notice, this list of conditions and the following disclaimer in | |
11 | the documentation and/or other materials provided with the | |
12 | distribution. | |
13 | * Neither the name of Intel Corporation nor the names of its | |
14 | contributors may be used to endorse or promote products derived | |
15 | from this software without specific prior written permission. | |
16 | ||
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | **********************************************************************/ | |
29 | ||
30 | ||
31 | #ifndef _GF_VECT_MUL_H | |
32 | #define _GF_VECT_MUL_H | |
33 | ||
34 | /** | |
35 | * @file gf_vect_mul.h | |
36 | * @brief Interface to functions for vector (block) multiplication in GF(2^8). | |
37 | * | |
38 | * This file defines the interface to routines used in fast RAID rebuild and | |
39 | * erasure codes. | |
40 | */ | |
41 | ||
42 | #ifdef __cplusplus | |
43 | extern "C" { | |
44 | #endif | |
45 | ||
46 | /** | |
47 | * @brief GF(2^8) vector multiply by constant. | |
48 | * | |
49 | * Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C | |
50 | * is a single field element in GF(2^8). Can be used for RAID6 rebuild | |
51 | * and partial write functions. Function requires pre-calculation of a | |
52 | * 32-element constant array based on constant C. gftbl(C) = {C{00}, | |
53 | * C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, C{20}, ... , C{f0} }. Len | |
54 | * and src must be aligned to 32B. | |
55 | * @requires SSE4.1 | |
56 | * | |
57 | * @param len Length of vector in bytes. Must be aligned to 32B. | |
58 | * @param gftbl Pointer to 32-byte array of pre-calculated constants based on C. | |
59 | * @param src Pointer to src data array. Must be aligned to 32B. | |
60 | * @param dest Pointer to destination data array. Must be aligned to 32B. | |
61 | * @returns 0 pass, other fail | |
62 | */ | |
63 | ||
64 | int gf_vect_mul_sse(int len, unsigned char *gftbl, void *src, void *dest); | |
65 | ||
66 | ||
67 | /** | |
68 | * @brief GF(2^8) vector multiply by constant. | |
69 | * | |
70 | * Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C | |
71 | * is a single field element in GF(2^8). Can be used for RAID6 rebuild | |
72 | * and partial write functions. Function requires pre-calculation of a | |
73 | * 32-element constant array based on constant C. gftbl(C) = {C{00}, | |
74 | * C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, C{20}, ... , C{f0} }. Len | |
75 | * and src must be aligned to 32B. | |
76 | * @requires AVX | |
77 | * | |
78 | * @param len Length of vector in bytes. Must be aligned to 32B. | |
79 | * @param gftbl Pointer to 32-byte array of pre-calculated constants based on C. | |
80 | * @param src Pointer to src data array. Must be aligned to 32B. | |
81 | * @param dest Pointer to destination data array. Must be aligned to 32B. | |
82 | * @returns 0 pass, other fail | |
83 | */ | |
84 | ||
85 | int gf_vect_mul_avx(int len, unsigned char *gftbl, void *src, void *dest); | |
86 | ||
87 | ||
88 | /** | |
89 | * @brief GF(2^8) vector multiply by constant, runs appropriate version. | |
90 | * | |
91 | * Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C | |
92 | * is a single field element in GF(2^8). Can be used for RAID6 rebuild | |
93 | * and partial write functions. Function requires pre-calculation of a | |
94 | * 32-element constant array based on constant C. gftbl(C) = {C{00}, | |
95 | * C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, C{20}, ... , C{f0} }. | |
96 | * Len and src must be aligned to 32B. | |
97 | * | |
98 | * This function determines what instruction sets are enabled | |
99 | * and selects the appropriate version at runtime. | |
100 | * | |
101 | * @param len Length of vector in bytes. Must be aligned to 32B. | |
102 | * @param gftbl Pointer to 32-byte array of pre-calculated constants based on C. | |
103 | * @param src Pointer to src data array. Must be aligned to 32B. | |
104 | * @param dest Pointer to destination data array. Must be aligned to 32B. | |
105 | * @returns 0 pass, other fail | |
106 | */ | |
107 | ||
108 | int gf_vect_mul(int len, unsigned char *gftbl, void *src, void *dest); | |
109 | ||
110 | ||
111 | /** | |
112 | * @brief Initialize 32-byte constant array for GF(2^8) vector multiply | |
113 | * | |
114 | * Calculates array {C{00}, C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, | |
115 | * C{20}, ... , C{f0} } as required by other fast vector multiply | |
116 | * functions. | |
117 | * @param c Constant input. | |
118 | * @param gftbl Table output. | |
119 | */ | |
120 | ||
121 | void gf_vect_mul_init(unsigned char c, unsigned char* gftbl); | |
122 | ||
123 | ||
124 | /** | |
125 | * @brief GF(2^8) vector multiply by constant, runs baseline version. | |
126 | * | |
127 | * Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C | |
128 | * is a single field element in GF(2^8). Can be used for RAID6 rebuild | |
129 | * and partial write functions. Function requires pre-calculation of a | |
130 | * 32-element constant array based on constant C. gftbl(C) = {C{00}, | |
131 | * C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, C{20}, ... , C{f0} }. Len | |
132 | * and src must be aligned to 32B. | |
133 | * | |
134 | * @param len Length of vector in bytes. Must be aligned to 32B. | |
135 | * @param a Pointer to 32-byte array of pre-calculated constants based on C. | |
136 | * only use 2nd element is used. | |
137 | * @param src Pointer to src data array. Must be aligned to 32B. | |
138 | * @param dest Pointer to destination data array. Must be aligned to 32B. | |
139 | */ | |
140 | ||
141 | void gf_vect_mul_base(int len, unsigned char *a, unsigned char *src, | |
142 | unsigned char *dest); | |
143 | ||
144 | #ifdef __cplusplus | |
145 | } | |
146 | #endif | |
147 | ||
148 | #endif //_GF_VECT_MUL_H |