1 /********************************************************************** 2 Copyright(c) 2011-2023 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 * @file crc64.h 32 * @brief CRC64 functions. 33 */ 34 35 #ifndef _CRC64_H_ 36 #define _CRC64_H_ 37 38 #include <stdint.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Multi-binary functions */ 45 46 /** 47 * @brief Generate CRC from ECMA-182 standard in reflected format, runs 48 * appropriate version. 49 * 50 * This function determines what instruction sets are enabled and 51 * selects the appropriate version at runtime. 52 * @returns 64 bit CRC 53 */ 54 uint64_t 55 crc64_ecma_refl(uint64_t init_crc, //!< initial CRC value, 64 bits 56 const unsigned char *buf, //!< buffer to calculate CRC on 57 uint64_t len //!< buffer length in bytes (64-bit data) 58 ); 59 60 /** 61 * @brief Generate CRC from ECMA-182 standard in normal format, runs 62 * appropriate version. 63 * 64 * This function determines what instruction sets are enabled and 65 * selects the appropriate version at runtime. 66 * @returns 64 bit CRC 67 */ 68 uint64_t 69 crc64_ecma_norm(uint64_t init_crc, //!< initial CRC value, 64 bits 70 const unsigned char *buf, //!< buffer to calculate CRC on 71 uint64_t len //!< buffer length in bytes (64-bit data) 72 ); 73 74 /** 75 * @brief Generate CRC from ISO standard in reflected format, runs 76 * appropriate version. 77 * 78 * This function determines what instruction sets are enabled and 79 * selects the appropriate version at runtime. 80 * @returns 64 bit CRC 81 */ 82 uint64_t 83 crc64_iso_refl(uint64_t init_crc, //!< initial CRC value, 64 bits 84 const unsigned char *buf, //!< buffer to calculate CRC on 85 uint64_t len //!< buffer length in bytes (64-bit data) 86 ); 87 88 /** 89 * @brief Generate CRC from ISO standard in normal format, runs 90 * appropriate version. 91 * 92 * This function determines what instruction sets are enabled and 93 * selects the appropriate version at runtime. 94 * @returns 64 bit CRC 95 */ 96 uint64_t 97 crc64_iso_norm(uint64_t init_crc, //!< initial CRC value, 64 bits 98 const unsigned char *buf, //!< buffer to calculate CRC on 99 uint64_t len //!< buffer length in bytes (64-bit data) 100 ); 101 102 /** 103 * @brief Generate CRC from "Jones" coefficients in reflected format, runs 104 * appropriate version. 105 * 106 * This function determines what instruction sets are enabled and 107 * selects the appropriate version at runtime. 108 * @returns 64 bit CRC 109 */ 110 uint64_t 111 crc64_jones_refl(uint64_t init_crc, //!< initial CRC value, 64 bits 112 const unsigned char *buf, //!< buffer to calculate CRC on 113 uint64_t len //!< buffer length in bytes (64-bit data) 114 ); 115 116 /** 117 * @brief Generate CRC from "Jones" coefficients in normal format, runs 118 * appropriate version. 119 * 120 * This function determines what instruction sets are enabled and 121 * selects the appropriate version at runtime. 122 * @returns 64 bit CRC 123 */ 124 uint64_t 125 crc64_jones_norm(uint64_t init_crc, //!< initial CRC value, 64 bits 126 const unsigned char *buf, //!< buffer to calculate CRC on 127 uint64_t len //!< buffer length in bytes (64-bit data) 128 ); 129 130 /** 131 * @brief Generate CRC from "Rocksoft" coefficients in reflected format, runs 132 * appropriate version. 133 * 134 * This function determines what instruction sets are enabled and 135 * selects the appropriate version at runtime. 136 * @returns 64 bit CRC 137 */ 138 uint64_t 139 crc64_rocksoft_refl(uint64_t init_crc, //!< initial CRC value, 64 bits 140 const unsigned char *buf, //!< buffer to calculate CRC on 141 uint64_t len //!< buffer length in bytes (64-bit data) 142 ); 143 144 /** 145 * @brief Generate CRC from "Rocksoft" coefficients in normal format, runs 146 * appropriate version. 147 * 148 * This function determines what instruction sets are enabled and 149 * selects the appropriate version at runtime. 150 * @returns 64 bit CRC 151 */ 152 uint64_t 153 crc64_rocksoft_norm(uint64_t init_crc, //!< initial CRC value, 64 bits 154 const unsigned char *buf, //!< buffer to calculate CRC on 155 uint64_t len //!< buffer length in bytes (64-bit data) 156 ); 157 158 /* Arch specific versions */ 159 160 /** 161 * @brief Generate CRC from ECMA-182 standard in reflected format. 162 * @requires SSE3, CLMUL 163 * 164 * @returns 64 bit CRC 165 */ 166 167 uint64_t 168 crc64_ecma_refl_by8(uint64_t init_crc, //!< initial CRC value, 64 bits 169 const unsigned char *buf, //!< buffer to calculate CRC on 170 uint64_t len //!< buffer length in bytes (64-bit data) 171 ); 172 173 /** 174 * @brief Generate CRC from ECMA-182 standard in normal format. 175 * @requires SSE3, CLMUL 176 * 177 * @returns 64 bit CRC 178 */ 179 180 uint64_t 181 crc64_ecma_norm_by8(uint64_t init_crc, //!< initial CRC value, 64 bits 182 const unsigned char *buf, //!< buffer to calculate CRC on 183 uint64_t len //!< buffer length in bytes (64-bit data) 184 ); 185 186 /** 187 * @brief Generate CRC from ECMA-182 standard in reflected format, runs baseline version 188 * @returns 64 bit CRC 189 */ 190 uint64_t 191 crc64_ecma_refl_base(uint64_t init_crc, //!< initial CRC value, 64 bits 192 const unsigned char *buf, //!< buffer to calculate CRC on 193 uint64_t len //!< buffer length in bytes (64-bit data) 194 ); 195 196 /** 197 * @brief Generate CRC from ECMA-182 standard in normal format, runs baseline version 198 * @returns 64 bit CRC 199 */ 200 uint64_t 201 crc64_ecma_norm_base(uint64_t init_crc, //!< initial CRC value, 64 bits 202 const unsigned char *buf, //!< buffer to calculate CRC on 203 uint64_t len //!< buffer length in bytes (64-bit data) 204 ); 205 206 /** 207 * @brief Generate CRC from ISO standard in reflected format. 208 * @requires SSE3, CLMUL 209 * 210 * @returns 64 bit CRC 211 */ 212 213 uint64_t 214 crc64_iso_refl_by8(uint64_t init_crc, //!< initial CRC value, 64 bits 215 const unsigned char *buf, //!< buffer to calculate CRC on 216 uint64_t len //!< buffer length in bytes (64-bit data) 217 ); 218 219 /** 220 * @brief Generate CRC from ISO standard in normal format. 221 * @requires SSE3, CLMUL 222 * 223 * @returns 64 bit CRC 224 */ 225 226 uint64_t 227 crc64_iso_norm_by8(uint64_t init_crc, //!< initial CRC value, 64 bits 228 const unsigned char *buf, //!< buffer to calculate CRC on 229 uint64_t len //!< buffer length in bytes (64-bit data) 230 ); 231 232 /** 233 * @brief Generate CRC from ISO standard in reflected format, runs baseline version 234 * @returns 64 bit CRC 235 */ 236 uint64_t 237 crc64_iso_refl_base(uint64_t init_crc, //!< initial CRC value, 64 bits 238 const unsigned char *buf, //!< buffer to calculate CRC on 239 uint64_t len //!< buffer length in bytes (64-bit data) 240 ); 241 242 /** 243 * @brief Generate CRC from ISO standard in normal format, runs baseline version 244 * @returns 64 bit CRC 245 */ 246 uint64_t 247 crc64_iso_norm_base(uint64_t init_crc, //!< initial CRC value, 64 bits 248 const unsigned char *buf, //!< buffer to calculate CRC on 249 uint64_t len //!< buffer length in bytes (64-bit data) 250 ); 251 252 /** 253 * @brief Generate CRC from "Jones" coefficients in reflected format. 254 * @requires SSE3, CLMUL 255 * 256 * @returns 64 bit CRC 257 */ 258 259 uint64_t 260 crc64_jones_refl_by8(uint64_t init_crc, //!< initial CRC value, 64 bits 261 const unsigned char *buf, //!< buffer to calculate CRC on 262 uint64_t len //!< buffer length in bytes (64-bit data) 263 ); 264 265 /** 266 * @brief Generate CRC from "Jones" coefficients in normal format. 267 * @requires SSE3, CLMUL 268 * 269 * @returns 64 bit CRC 270 */ 271 272 uint64_t 273 crc64_jones_norm_by8(uint64_t init_crc, //!< initial CRC value, 64 bits 274 const unsigned char *buf, //!< buffer to calculate CRC on 275 uint64_t len //!< buffer length in bytes (64-bit data) 276 ); 277 278 /** 279 * @brief Generate CRC from "Jones" coefficients in reflected format, runs baseline version 280 * @returns 64 bit CRC 281 */ 282 uint64_t 283 crc64_jones_refl_base(uint64_t init_crc, //!< initial CRC value, 64 bits 284 const unsigned char *buf, //!< buffer to calculate CRC on 285 uint64_t len //!< buffer length in bytes (64-bit data) 286 ); 287 288 /** 289 * @brief Generate CRC from "Jones" coefficients in normal format, runs baseline version 290 * @returns 64 bit CRC 291 */ 292 uint64_t 293 crc64_jones_norm_base(uint64_t init_crc, //!< initial CRC value, 64 bits 294 const unsigned char *buf, //!< buffer to calculate CRC on 295 uint64_t len //!< buffer length in bytes (64-bit data) 296 ); 297 298 /** 299 * @brief Generate CRC from "Rocksoft" coefficients in reflected format. 300 * @requires SSE3, CLMUL 301 * 302 * @returns 64 bit CRC 303 */ 304 305 uint64_t 306 crc64_rocksoft_refl_by8(uint64_t init_crc, //!< initial CRC value, 64 bits 307 const unsigned char *buf, //!< buffer to calculate CRC on 308 uint64_t len //!< buffer length in bytes (64-bit data) 309 ); 310 311 /** 312 * @brief Generate CRC from "Rocksoft" coefficients in reflected format, runs baseline version 313 * @returns 64 bit CRC 314 */ 315 uint64_t 316 crc64_rocksoft_refl_base(uint64_t init_crc, //!< initial CRC value, 64 bits 317 const unsigned char *buf, //!< buffer to calculate CRC on 318 uint64_t len //!< buffer length in bytes (64-bit data) 319 ); 320 321 /** 322 * @brief Generate CRC from "Rocksoft" coefficients in normal format. 323 * @requires SSE3, CLMUL 324 * 325 * @returns 64 bit CRC 326 */ 327 328 uint64_t 329 crc64_rocksoft_norm_by8(uint64_t init_crc, //!< initial CRC value, 64 bits 330 const unsigned char *buf, //!< buffer to calculate CRC on 331 uint64_t len //!< buffer length in bytes (64-bit data) 332 ); 333 334 /** 335 * @brief Generate CRC from "Rocksoft" coefficients in normal format, runs baseline version 336 * @returns 64 bit CRC 337 */ 338 uint64_t 339 crc64_rocksoft_norm_base(uint64_t init_crc, //!< initial CRC value, 64 bits 340 const unsigned char *buf, //!< buffer to calculate CRC on 341 uint64_t len //!< buffer length in bytes (64-bit data) 342 ); 343 344 #ifdef __cplusplus 345 } 346 #endif 347 348 #endif // _CRC64_H_ 349