Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:25

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 
0031 #ifndef _RAID_H_
0032 #define _RAID_H_
0033 
0034 /**
0035  *  @file  raid.h
0036  *  @brief Interface to RAID functions - XOR and P+Q calculation.
0037  *
0038  *  This file defines the interface to optimized XOR calculation (RAID5) or P+Q
0039  *  dual parity (RAID6).  Operations are carried out on an array of pointers to
0040  *  sources and output arrays.
0041  */
0042 
0043 #ifdef __cplusplus
0044 extern "C" {
0045 #endif
0046 
0047 /* Multi-binary functions */
0048 
0049 /**
0050  * @brief Generate XOR parity vector from N sources, runs appropriate version.
0051  *
0052  * This function determines what instruction sets are enabled and
0053  * selects the appropriate version at runtime.
0054  *
0055  * @param vects   Number of source+dest vectors in array.
0056  * @param len     Length of each vector in bytes.
0057  * @param array   Array of pointers to source and dest. For XOR the dest is
0058  *                the last pointer. ie array[vects-1]. Src and dest
0059  *                pointers must be aligned to 32B.
0060  *
0061  * @returns 0 pass, other fail
0062  */
0063 
0064 int xor_gen(int vects, int len, void **array);
0065 
0066 
0067 /**
0068  * @brief Checks that array has XOR parity sum of 0 across all vectors, runs appropriate version.
0069  *
0070  * This function determines what instruction sets are enabled and
0071  * selects the appropriate version at runtime.
0072  *
0073  * @param vects   Number of vectors in array.
0074  * @param len     Length of each vector in bytes.
0075  * @param array   Array of pointers to vectors. Src and dest pointers
0076  *                must be aligned to 16B.
0077  *
0078  * @returns 0 pass, other fail
0079  */
0080 
0081 int xor_check(int vects, int len, void **array);
0082 
0083 
0084 /**
0085  * @brief Generate P+Q parity vectors from N sources, runs appropriate version.
0086  *
0087  * This function determines what instruction sets are enabled and
0088  * selects the appropriate version at runtime.
0089  *
0090  * @param vects   Number of source+dest vectors in array.
0091  * @param len     Length of each vector in bytes. Must be 32B aligned.
0092  * @param array   Array of pointers to source and dest. For P+Q the dest
0093  *                is the last two pointers. ie array[vects-2],
0094  *                array[vects-1].  P and Q parity vectors are
0095  *                written to these last two pointers. Src and dest
0096  *                pointers must be aligned to 32B.
0097  *
0098  * @returns 0 pass, other fail
0099  */
0100 
0101 int pq_gen(int vects, int len, void **array);
0102 
0103 
0104 /**
0105  * @brief Checks that array of N sources, P and Q are consistent across all vectors, runs 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.
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 pq_check(int vects, int len, void **array);
0120 
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.
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 xor_gen_sse(int vects, int len, void **array);
0140 
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.
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 xor_gen_avx(int vects, int len, void **array);
0156 
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.
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 xor_check_sse(int vects, int len, void **array);
0171 
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.
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 pq_gen_sse(int vects, int len, void **array);
0189 
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.
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 pq_gen_avx(int vects, int len, void **array);
0207 
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.
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 pq_gen_avx2(int vects, int len, void **array);
0225 
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.
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 pq_check_sse(int vects, int len, void **array);
0240 
0241 #endif
0242 
0243 /**
0244  * @brief Generate P+Q parity vectors from N sources, runs baseline version.
0245  * @param vects   Number of source+dest vectors in array.
0246  * @param len     Length of each vector in bytes. Must be 16B aligned.
0247  * @param array   Array of pointers to source and dest. For P+Q the dest
0248  *        is the last two pointers. ie array[vects-2],
0249  *        array[vects-1]. P and Q parity vectors are
0250  *        written to these last two pointers. Src and dest pointers
0251  *        must be aligned to 16B.
0252  *
0253  * @returns 0 pass, other fail
0254  */
0255 
0256 int pq_gen_base(int vects, int len, void **array);
0257 
0258 
0259 /**
0260  * @brief Generate XOR parity vector from N sources, runs baseline version.
0261  * @param vects   Number of source+dest vectors in array.
0262  * @param len     Length of each vector in bytes.
0263  * @param array   Array of pointers to source and dest. For XOR the dest is
0264  *        the last pointer. ie array[vects-1]. Src and dest pointers
0265  *        must be aligned to 32B.
0266  *
0267  * @returns 0 pass, other fail
0268  */
0269 
0270 int xor_gen_base(int vects, int len, void **array);
0271 
0272 
0273 /**
0274  * @brief Checks that array has XOR parity sum of 0 across all vectors, runs baseline version.
0275  *
0276  * @param vects   Number of vectors in array.
0277  * @param len     Length of each vector in bytes.
0278  * @param array   Array of pointers to vectors. Src and dest pointers
0279  *                must be aligned to 16B.
0280  *
0281  * @returns 0 pass, other fail
0282  */
0283 
0284 int xor_check_base(int vects, int len, void **array);
0285 
0286 
0287 /**
0288  * @brief Checks that array of N sources, P and Q are consistent across all vectors, runs baseline version.
0289  *
0290  * @param vects  Number of vectors in array including P&Q.
0291  * @param len    Length of each vector in bytes. Must be 16B aligned.
0292  * @param array  Array of pointers to source and P, Q. P and Q parity
0293  *               are assumed to be the last two pointers in the array.
0294  *               All pointers must be aligned to 16B.
0295  *
0296  * @returns 0 pass, other fail
0297  */
0298 
0299 int pq_check_base(int vects, int len, void **array);
0300 
0301 #ifdef __cplusplus
0302 }
0303 #endif
0304 
0305 #endif //_RAID_H_