]>
git.proxmox.com Git - ceph.git/blob - ceph/src/isa-l/include/crc64.h
1 /**********************************************************************
2 Copyright(c) 2011-2016 Intel Corporation All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
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
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.
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 **********************************************************************/
33 * @brief CRC64 functions.
47 /* Multi-binary functions */
50 * @brief Generate CRC from ECMA-182 standard in reflected format, runs
51 * appropriate version.
53 * This function determines what instruction sets are enabled and
54 * selects the appropriate version at runtime.
57 uint64_t crc64_ecma_refl(
58 uint64_t init_crc
, //!< initial CRC value, 64 bits
59 const unsigned char *buf
, //!< buffer to calculate CRC on
60 uint64_t len
//!< buffer length in bytes (64-bit data)
64 * @brief Generate CRC from ECMA-182 standard in normal format, runs
65 * appropriate version.
67 * This function determines what instruction sets are enabled and
68 * selects the appropriate version at runtime.
71 uint64_t crc64_ecma_norm(
72 uint64_t init_crc
, //!< initial CRC value, 64 bits
73 const unsigned char *buf
, //!< buffer to calculate CRC on
74 uint64_t len
//!< buffer length in bytes (64-bit data)
78 * @brief Generate CRC from ISO standard in reflected format, runs
79 * appropriate version.
81 * This function determines what instruction sets are enabled and
82 * selects the appropriate version at runtime.
85 uint64_t crc64_iso_refl(
86 uint64_t init_crc
, //!< initial CRC value, 64 bits
87 const unsigned char *buf
, //!< buffer to calculate CRC on
88 uint64_t len
//!< buffer length in bytes (64-bit data)
92 * @brief Generate CRC from ISO standard in normal format, runs
93 * appropriate version.
95 * This function determines what instruction sets are enabled and
96 * selects the appropriate version at runtime.
99 uint64_t crc64_iso_norm(
100 uint64_t init_crc
, //!< initial CRC value, 64 bits
101 const unsigned char *buf
, //!< buffer to calculate CRC on
102 uint64_t len
//!< buffer length in bytes (64-bit data)
106 * @brief Generate CRC from "Jones" coefficients in reflected format, runs
107 * appropriate version.
109 * This function determines what instruction sets are enabled and
110 * selects the appropriate version at runtime.
111 * @returns 64 bit CRC
113 uint64_t crc64_jones_refl(
114 uint64_t init_crc
, //!< initial CRC value, 64 bits
115 const unsigned char *buf
, //!< buffer to calculate CRC on
116 uint64_t len
//!< buffer length in bytes (64-bit data)
120 * @brief Generate CRC from "Jones" coefficients in normal format, runs
121 * appropriate version.
123 * This function determines what instruction sets are enabled and
124 * selects the appropriate version at runtime.
125 * @returns 64 bit CRC
127 uint64_t crc64_jones_norm(
128 uint64_t init_crc
, //!< initial CRC value, 64 bits
129 const unsigned char *buf
, //!< buffer to calculate CRC on
130 uint64_t len
//!< buffer length in bytes (64-bit data)
133 /* Arch specific versions */
136 * @brief Generate CRC from ECMA-182 standard in reflected format.
137 * @requires SSE3, CLMUL
139 * @returns 64 bit CRC
142 uint64_t crc64_ecma_refl_by8(
143 uint64_t init_crc
, //!< initial CRC value, 64 bits
144 const unsigned char *buf
, //!< buffer to calculate CRC on
145 uint64_t len
//!< buffer length in bytes (64-bit data)
149 * @brief Generate CRC from ECMA-182 standard in normal format.
150 * @requires SSE3, CLMUL
152 * @returns 64 bit CRC
155 uint64_t crc64_ecma_norm_by8(
156 uint64_t init_crc
, //!< initial CRC value, 64 bits
157 const unsigned char *buf
, //!< buffer to calculate CRC on
158 uint64_t len
//!< buffer length in bytes (64-bit data)
162 * @brief Generate CRC from ECMA-182 standard in reflected format, runs baseline version
163 * @returns 64 bit CRC
165 uint64_t crc64_ecma_refl_base(
166 uint64_t init_crc
, //!< initial CRC value, 64 bits
167 const unsigned char *buf
, //!< buffer to calculate CRC on
168 uint64_t len
//!< buffer length in bytes (64-bit data)
172 * @brief Generate CRC from ECMA-182 standard in normal format, runs baseline version
173 * @returns 64 bit CRC
175 uint64_t crc64_ecma_norm_base(
176 uint64_t init_crc
, //!< initial CRC value, 64 bits
177 const unsigned char *buf
, //!< buffer to calculate CRC on
178 uint64_t len
//!< buffer length in bytes (64-bit data)
182 * @brief Generate CRC from ISO standard in reflected format.
183 * @requires SSE3, CLMUL
185 * @returns 64 bit CRC
188 uint64_t crc64_iso_refl_by8(
189 uint64_t init_crc
, //!< initial CRC value, 64 bits
190 const unsigned char *buf
, //!< buffer to calculate CRC on
191 uint64_t len
//!< buffer length in bytes (64-bit data)
195 * @brief Generate CRC from ISO standard in normal format.
196 * @requires SSE3, CLMUL
198 * @returns 64 bit CRC
201 uint64_t crc64_iso_norm_by8(
202 uint64_t init_crc
, //!< initial CRC value, 64 bits
203 const unsigned char *buf
, //!< buffer to calculate CRC on
204 uint64_t len
//!< buffer length in bytes (64-bit data)
208 * @brief Generate CRC from ISO standard in reflected format, runs baseline version
209 * @returns 64 bit CRC
211 uint64_t crc64_iso_refl_base(
212 uint64_t init_crc
, //!< initial CRC value, 64 bits
213 const unsigned char *buf
, //!< buffer to calculate CRC on
214 uint64_t len
//!< buffer length in bytes (64-bit data)
218 * @brief Generate CRC from ISO standard in normal format, runs baseline version
219 * @returns 64 bit CRC
221 uint64_t crc64_iso_norm_base(
222 uint64_t init_crc
, //!< initial CRC value, 64 bits
223 const unsigned char *buf
, //!< buffer to calculate CRC on
224 uint64_t len
//!< buffer length in bytes (64-bit data)
228 * @brief Generate CRC from "Jones" coefficients in reflected format.
229 * @requires SSE3, CLMUL
231 * @returns 64 bit CRC
234 uint64_t crc64_jones_refl_by8(
235 uint64_t init_crc
, //!< initial CRC value, 64 bits
236 const unsigned char *buf
, //!< buffer to calculate CRC on
237 uint64_t len
//!< buffer length in bytes (64-bit data)
241 * @brief Generate CRC from "Jones" coefficients in normal format.
242 * @requires SSE3, CLMUL
244 * @returns 64 bit CRC
247 uint64_t crc64_jones_norm_by8(
248 uint64_t init_crc
, //!< initial CRC value, 64 bits
249 const unsigned char *buf
, //!< buffer to calculate CRC on
250 uint64_t len
//!< buffer length in bytes (64-bit data)
254 * @brief Generate CRC from "Jones" coefficients in reflected format, runs baseline version
255 * @returns 64 bit CRC
257 uint64_t crc64_jones_refl_base(
258 uint64_t init_crc
, //!< initial CRC value, 64 bits
259 const unsigned char *buf
, //!< buffer to calculate CRC on
260 uint64_t len
//!< buffer length in bytes (64-bit data)
264 * @brief Generate CRC from "Jones" coefficients in normal format, runs baseline version
265 * @returns 64 bit CRC
267 uint64_t crc64_jones_norm_base(
268 uint64_t init_crc
, //!< initial CRC value, 64 bits
269 const unsigned char *buf
, //!< buffer to calculate CRC on
270 uint64_t len
//!< buffer length in bytes (64-bit data)