brintos

brintos / linux-shallow public Read only

0
0
Text · 1.6 KiB · 0c8fb59 Raw
60 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2 3/* Try to choose an implementation variant via Kconfig */4#ifdef CONFIG_CRC32_SLICEBY85# define CRC_LE_BITS 646# define CRC_BE_BITS 647#endif8#ifdef CONFIG_CRC32_SLICEBY49# define CRC_LE_BITS 3210# define CRC_BE_BITS 3211#endif12#ifdef CONFIG_CRC32_SARWATE13# define CRC_LE_BITS 814# define CRC_BE_BITS 815#endif16#ifdef CONFIG_CRC32_BIT17# define CRC_LE_BITS 118# define CRC_BE_BITS 119#endif20 21/*22 * How many bits at a time to use.  Valid values are 1, 2, 4, 8, 32 and 64.23 * For less performance-sensitive, use 4 or 8 to save table size.24 * For larger systems choose same as CPU architecture as default.25 * This works well on X86_64, SPARC64 systems. This may require some26 * elaboration after experiments with other architectures.27 */28#ifndef CRC_LE_BITS29#  ifdef CONFIG_64BIT30#  define CRC_LE_BITS 6431#  else32#  define CRC_LE_BITS 3233#  endif34#endif35#ifndef CRC_BE_BITS36#  ifdef CONFIG_64BIT37#  define CRC_BE_BITS 6438#  else39#  define CRC_BE_BITS 3240#  endif41#endif42 43/*44 * Little-endian CRC computation.  Used with serial bit streams sent45 * lsbit-first.  Be sure to use cpu_to_le32() to append the computed CRC.46 */47#if CRC_LE_BITS > 64 || CRC_LE_BITS < 1 || CRC_LE_BITS == 16 || \48	CRC_LE_BITS & CRC_LE_BITS-149# error "CRC_LE_BITS must be one of {1, 2, 4, 8, 32, 64}"50#endif51 52/*53 * Big-endian CRC computation.  Used with serial bit streams sent54 * msbit-first.  Be sure to use cpu_to_be32() to append the computed CRC.55 */56#if CRC_BE_BITS > 64 || CRC_BE_BITS < 1 || CRC_BE_BITS == 16 || \57	CRC_BE_BITS & CRC_BE_BITS-158# error "CRC_BE_BITS must be one of {1, 2, 4, 8, 32, 64}"59#endif60