Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:02:13

0001 /**********************************************************************
0002   Copyright(c) 2011-2015 Intel Corporation All rights reserved.
0003 
0004   Redistribution and use in source and binary forms, with or without
0005   modification, are permitted provided that the following conditions
0006   are met:
0007     * Redistributions of source code must retain the above copyright
0008       notice, this list of conditions and the following disclaimer.
0009     * Redistributions in binary form must reproduce the above copyright
0010       notice, this list of conditions and the following disclaimer in
0011       the documentation and/or other materials provided with the
0012       distribution.
0013     * Neither the name of Intel Corporation nor the names of its
0014       contributors may be used to endorse or promote products derived
0015       from this software without specific prior written permission.
0016 
0017   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0018   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0019   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0020   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0021   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0022   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0023   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0024   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0025   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0026   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0027   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0028 **********************************************************************/
0029 
0030 #ifndef _RAID_H_
0031 #define _RAID_H_
0032 
0033 /**
0034  *  @file  raid.h
0035  *  @brief Interface to RAID functions - XOR and P+Q calculation.
0036  *
0037  *  This file defines the interface to optimized XOR calculation (RAID5) or P+Q
0038  *  dual parity (RAID6).  Operations are carried out on an array of pointers to
0039  *  sources and output arrays.
0040  */
0041 
0042 #ifdef __cplusplus
0043 extern "C" {
0044 #endif
0045 
0046 /* Multi-binary functions */
0047 
0048 /**
0049  * @brief Generate XOR parity vector from N sources, runs appropriate version.
0050  *
0051  * This function determines what instruction sets are enabled and
0052  * selects the appropriate version at runtime.
0053  *
0054  * @param vects   Number of source+dest vectors in array. Must be > 2.
0055  * @param len     Length of each vector in bytes.
0056  * @param array   Array of pointers to source and dest. For XOR the dest is
0057  *                the last pointer. ie array[vects-1]. Src and dest
0058  *                pointers must be aligned to 32B.
0059  *
0060  * @returns 0 pass, other fail
0061  */
0062 
0063 int
0064 xor_gen(int vects, int len, void **array);
0065 
0066 /**
0067  * @brief Checks that array has XOR parity sum of 0 across all vectors, runs appropriate version.
0068  *
0069  * This function determines what instruction sets are enabled and
0070  * selects the appropriate version at runtime.
0071  *
0072  * @param vects   Number of vectors in array. Must be > 1.
0073  * @param len     Length of each vector in bytes.
0074  * @param array   Array of pointers to vectors. Src and dest pointers
0075  *                must be aligned to 16B.
0076  *
0077  * @returns 0 pass, other fail
0078  */
0079 
0080 int
0081 xor_check(int vects, int len, void **array);
0082 
0083 /**
0084  * @brief Generate P+Q parity vectors from N sources, runs appropriate version.
0085  *
0086  * This function determines what instruction sets are enabled and
0087  * selects the appropriate version at runtime.
0088  *
0089  * @param vects   Number of source+dest vectors in array. Must be > 3.
0090  * @param len     Length of each vector in bytes. Must be 32B aligned.
0091  * @param array   Array of pointers to source and dest. For P+Q the dest
0092  *                is the last two pointers. ie array[vects-2],
0093  *                array[vects-1].  P and Q parity vectors are
0094  *                written to these last two pointers. Src and dest
0095  *                pointers must be aligned to 32B.
0096  *
0097  * @returns 0 pass, other fail
0098  */
0099 
0100 int
0101 pq_gen(int vects, int len, void **array);
0102 
0103 /**
0104  * @brief Checks that array of N sources, P and Q are consistent across all vectors, runs
0105  * appropriate version.
0106  *
0107  * This function determines what instruction sets are enabled and
0108  * selects the appropriate version at runtime.
0109  *
0110  * @param vects  Number of vectors in array including P&Q. Must be > 3.
0111  * @param len    Length of each vector in bytes. Must be 16B aligned.
0112  * @param array  Array of pointers to source and P, Q. P and Q parity
0113  *               are assumed to be the last two pointers in the array.
0114  *               All pointers must be aligned to 16B.
0115  *
0116  * @returns 0 pass, other fail
0117  */
0118 
0119 int
0120 pq_check(int vects, int len, void **array);
0121 
0122 /* Arch specific versions */
0123 // x86 only
0124 #if defined(__i386__) || defined(__x86_64__)
0125 
0126 /**
0127  * @brief Generate XOR parity vector from N sources.
0128  * @requires SSE4.1
0129  *
0130  * @param vects   Number of source+dest vectors in array. Must be > 2.
0131  * @param len     Length of each vector in bytes.
0132  * @param array   Array of pointers to source and dest. For XOR the dest is
0133  *                the last pointer. ie array[vects-1]. Src and dest pointers
0134  *                must be aligned to 16B.
0135  *
0136  * @returns 0 pass, other fail
0137  */
0138 
0139 int
0140 xor_gen_sse(int vects, int len, void **array);
0141 
0142 /**
0143  * @brief Generate XOR parity vector from N sources.
0144  * @requires AVX
0145  *
0146  * @param vects   Number of source+dest vectors in array. Must be > 2.
0147  * @param len     Length of each vector in bytes.
0148  * @param array   Array of pointers to source and dest. For XOR the dest is
0149  *                the last pointer. ie array[vects-1]. Src and dest pointers
0150  *                must be aligned to 32B.
0151  *
0152  * @returns 0 pass, other fail
0153  */
0154 
0155 int
0156 xor_gen_avx(int vects, int len, void **array);
0157 
0158 /**
0159  * @brief Checks that array has XOR parity sum of 0 across all vectors.
0160  * @requires SSE4.1
0161  *
0162  * @param vects   Number of vectors in array. Must be > 1.
0163  * @param len     Length of each vector in bytes.
0164  * @param array   Array of pointers to vectors. Src and dest pointers
0165  *                must be aligned to 16B.
0166  *
0167  * @returns 0 pass, other fail
0168  */
0169 
0170 int
0171 xor_check_sse(int vects, int len, void **array);
0172 
0173 /**
0174  * @brief Generate P+Q parity vectors from N sources.
0175  * @requires SSE4.1
0176  *
0177  * @param vects   Number of source+dest vectors in array. Must be > 3.
0178  * @param len     Length of each vector in bytes. Must be 16B aligned.
0179  * @param array   Array of pointers to source and dest. For P+Q the dest
0180  *                is the last two pointers. ie array[vects-2],
0181  *                array[vects-1]. P and Q parity vectors are
0182  *                written to these last two pointers. Src and dest
0183  *                pointers must be aligned to 16B.
0184  *
0185  * @returns 0 pass, other fail
0186  */
0187 
0188 int
0189 pq_gen_sse(int vects, int len, void **array);
0190 
0191 /**
0192  * @brief Generate P+Q parity vectors from N sources.
0193  * @requires AVX
0194  *
0195  * @param vects   Number of source+dest vectors in array. Must be > 3.
0196  * @param len     Length of each vector in bytes. Must be 16B aligned.
0197  * @param array   Array of pointers to source and dest. For P+Q the dest
0198  *                is the last two pointers. ie array[vects-2],
0199  *                array[vects-1]. P and Q parity vectors are
0200  *                written to these last two pointers. Src and dest
0201  *                pointers must be aligned to 16B.
0202  *
0203  * @returns 0 pass, other fail
0204  */
0205 
0206 int
0207 pq_gen_avx(int vects, int len, void **array);
0208 
0209 /**
0210  * @brief Generate P+Q parity vectors from N sources.
0211  * @requires AVX2
0212  *
0213  * @param vects   Number of source+dest vectors in array. Must be > 3.
0214  * @param len     Length of each vector in bytes. Must be 32B aligned.
0215  * @param array   Array of pointers to source and dest. For P+Q the dest
0216  *                is the last two pointers. ie array[vects-2],
0217  *                array[vects-1]. P and Q parity vectors are
0218  *                written to these last two pointers. Src and dest
0219  *                pointers must be aligned to 32B.
0220  *
0221  * @returns 0 pass, other fail
0222  */
0223 
0224 int
0225 pq_gen_avx2(int vects, int len, void **array);
0226 
0227 /**
0228  * @brief Checks that array of N sources, P and Q are consistent across all vectors.
0229  * @requires SSE4.1
0230  *
0231  * @param vects  Number of vectors in array including P&Q. Must be > 3.
0232  * @param len    Length of each vector in bytes. Must be 16B aligned.
0233  * @param array  Array of pointers to source and P, Q. P and Q parity
0234                  are assumed to be the last two pointers in the array.
0235                  All pointers must be aligned to 16B.
0236  * @returns 0 pass, other fail
0237  */
0238 
0239 int
0240 pq_check_sse(int vects, int len, void **array);
0241 
0242 #endif
0243 
0244 /**
0245  * @brief Generate P+Q parity vectors from N sources, runs baseline version.
0246  * @param vects   Number of source+dest vectors in array. Must be > 3.
0247  * @param len     Length of each vector in bytes. Must be 16B aligned.
0248  * @param array   Array of pointers to source and dest. For P+Q the dest
0249  *        is the last two pointers. ie array[vects-2],
0250  *        array[vects-1]. P and Q parity vectors are
0251  *        written to these last two pointers. Src and dest pointers
0252  *        must be aligned to 16B.
0253  *
0254  * @returns 0 pass, other fail
0255  */
0256 
0257 int
0258 pq_gen_base(int vects, int len, void **array);
0259 
0260 /**
0261  * @brief Generate XOR parity vector from N sources, runs baseline version.
0262  * @param vects   Number of source+dest vectors in array. Must be > 2.
0263  * @param len     Length of each vector in bytes.
0264  * @param array   Array of pointers to source and dest. For XOR the dest is
0265  *        the last pointer. ie array[vects-1]. Src and dest pointers
0266  *        must be aligned to 32B.
0267  *
0268  * @returns 0 pass, other fail
0269  */
0270 
0271 int
0272 xor_gen_base(int vects, int len, void **array);
0273 
0274 /**
0275  * @brief Checks that array has XOR parity sum of 0 across all vectors, runs baseline version.
0276  *
0277  * @param vects   Number of vectors in array. Must be > 1.
0278  * @param len     Length of each vector in bytes.
0279  * @param array   Array of pointers to vectors. Src and dest pointers
0280  *                must be aligned to 16B.
0281  *
0282  * @returns 0 pass, other fail
0283  */
0284 
0285 int
0286 xor_check_base(int vects, int len, void **array);
0287 
0288 /**
0289  * @brief Checks that array of N sources, P and Q are consistent across all vectors, runs baseline
0290  * version.
0291  *
0292  * @param vects  Number of vectors in array including P&Q. Must be > 3.
0293  * @param len    Length of each vector in bytes. Must be 16B aligned.
0294  * @param array  Array of pointers to source and P, Q. P and Q parity
0295  *               are assumed to be the last two pointers in the array.
0296  *               All pointers must be aligned to 16B.
0297  *
0298  * @returns 0 pass, other fail
0299  */
0300 
0301 int
0302 pq_check_base(int vects, int len, void **array);
0303 
0304 #ifdef __cplusplus
0305 }
0306 #endif
0307 
0308 #endif //_RAID_H_