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 _GF_VECT_MUL_H
0032 #define _GF_VECT_MUL_H
0033 
0034 /**
0035  *  @file gf_vect_mul.h
0036  *  @brief Interface to functions for vector (block) multiplication in GF(2^8).
0037  *
0038  *  This file defines the interface to routines used in fast RAID rebuild and
0039  *  erasure codes.
0040  */
0041 
0042 #ifdef __cplusplus
0043 extern "C" {
0044 #endif
0045 
0046 // x86 only
0047 #if defined(__i386__) || defined(__x86_64__)
0048 
0049  /**
0050  * @brief GF(2^8) vector multiply by constant.
0051  *
0052  * Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C
0053  * is a single field element in GF(2^8). Can be used for RAID6 rebuild
0054  * and partial write functions. Function requires pre-calculation of a
0055  * 32-element constant array based on constant C. gftbl(C) = {C{00},
0056  * C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, C{20}, ... , C{f0} }. Len
0057  * and src must be aligned to 32B.
0058  * @requires SSE4.1
0059  *
0060  * @param len   Length of vector in bytes. Must be aligned to 32B.
0061  * @param gftbl Pointer to 32-byte array of pre-calculated constants based on C.
0062  * @param src   Pointer to src data array. Must be aligned to 32B.
0063  * @param dest  Pointer to destination data array. Must be aligned to 32B.
0064  * @returns 0 pass, other fail
0065  */
0066 
0067 int gf_vect_mul_sse(int len, unsigned char *gftbl, void *src, void *dest);
0068 
0069 
0070  /**
0071  * @brief GF(2^8) vector multiply by constant.
0072  *
0073  * Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C
0074  * is a single field element in GF(2^8). Can be used for RAID6 rebuild
0075  * and partial write functions. Function requires pre-calculation of a
0076  * 32-element constant array based on constant C. gftbl(C) = {C{00},
0077  * C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, C{20}, ... , C{f0} }. Len
0078  * and src must be aligned to 32B.
0079  * @requires AVX
0080  *
0081  * @param len   Length of vector in bytes. Must be aligned to 32B.
0082  * @param gftbl Pointer to 32-byte array of pre-calculated constants based on C.
0083  * @param src   Pointer to src data array. Must be aligned to 32B.
0084  * @param dest  Pointer to destination data array. Must be aligned to 32B.
0085  * @returns 0 pass, other fail
0086  */
0087 
0088 int gf_vect_mul_avx(int len, unsigned char *gftbl, void *src, void *dest);
0089 
0090 #endif
0091 
0092 /**
0093  * @brief GF(2^8) vector multiply by constant, runs appropriate version.
0094  *
0095  * Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C
0096  * is a single field element in GF(2^8). Can be used for RAID6 rebuild
0097  * and partial write functions. Function requires pre-calculation of a
0098  * 32-element constant array based on constant C. gftbl(C) = {C{00},
0099  * C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, C{20}, ... , C{f0} }.
0100  * Len and src must be aligned to 32B.
0101  *
0102  * This function determines what instruction sets are enabled
0103  * and selects the appropriate version at runtime.
0104  *
0105  * @param len   Length of vector in bytes. Must be aligned to 32B.
0106  * @param gftbl Pointer to 32-byte array of pre-calculated constants based on C.
0107  * @param src   Pointer to src data array. Must be aligned to 32B.
0108  * @param dest  Pointer to destination data array. Must be aligned to 32B.
0109  * @returns 0 pass, other fail
0110  */
0111 
0112 int gf_vect_mul(int len, unsigned char *gftbl, void *src, void *dest);
0113 
0114 
0115 /**
0116  * @brief Initialize 32-byte constant array for GF(2^8) vector multiply
0117  *
0118  * Calculates array {C{00}, C{01}, C{02}, ... , C{0f} }, {C{00}, C{10},
0119  * C{20}, ... , C{f0} } as required by other fast vector multiply
0120  * functions.
0121  * @param c     Constant input.
0122  * @param gftbl Table output.
0123  */
0124 
0125 void gf_vect_mul_init(unsigned char c, unsigned char* gftbl);
0126 
0127 
0128 /**
0129  * @brief GF(2^8) vector multiply by constant, runs baseline version.
0130  *
0131  * Does a GF(2^8) vector multiply b = Ca where a and b are arrays and C
0132  * is a single field element in GF(2^8). Can be used for RAID6 rebuild
0133  * and partial write functions. Function requires pre-calculation of a
0134  * 32-element constant array based on constant C. gftbl(C) = {C{00},
0135  * C{01}, C{02}, ... , C{0f} }, {C{00}, C{10}, C{20}, ... , C{f0} }. Len
0136  * and src must be aligned to 32B.
0137  *
0138  * @param len   Length of vector in bytes. Must be aligned to 32B.
0139  * @param a     Pointer to 32-byte array of pre-calculated constants based on C.
0140  *      only use 2nd element is used.
0141  * @param src   Pointer to src data array. Must be aligned to 32B.
0142  * @param dest  Pointer to destination data array. Must be aligned to 32B.
0143  */
0144 
0145 void gf_vect_mul_base(int len, unsigned char *a, unsigned char *src,
0146             unsigned char *dest);
0147 
0148 #ifdef __cplusplus
0149 }
0150 #endif
0151 
0152 #endif //_GF_VECT_MUL_H