Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 /* Try to choose an implementation variant via Kconfig */
0004 #ifdef CONFIG_CRC32_SLICEBY8
0005 # define CRC_LE_BITS 64
0006 # define CRC_BE_BITS 64
0007 #endif
0008 #ifdef CONFIG_CRC32_SLICEBY4
0009 # define CRC_LE_BITS 32
0010 # define CRC_BE_BITS 32
0011 #endif
0012 #ifdef CONFIG_CRC32_SARWATE
0013 # define CRC_LE_BITS 8
0014 # define CRC_BE_BITS 8
0015 #endif
0016 #ifdef CONFIG_CRC32_BIT
0017 # define CRC_LE_BITS 1
0018 # define CRC_BE_BITS 1
0019 #endif
0020 
0021 /*
0022  * How many bits at a time to use.  Valid values are 1, 2, 4, 8, 32 and 64.
0023  * For less performance-sensitive, use 4 or 8 to save table size.
0024  * For larger systems choose same as CPU architecture as default.
0025  * This works well on X86_64, SPARC64 systems. This may require some
0026  * elaboration after experiments with other architectures.
0027  */
0028 #ifndef CRC_LE_BITS
0029 #  ifdef CONFIG_64BIT
0030 #  define CRC_LE_BITS 64
0031 #  else
0032 #  define CRC_LE_BITS 32
0033 #  endif
0034 #endif
0035 #ifndef CRC_BE_BITS
0036 #  ifdef CONFIG_64BIT
0037 #  define CRC_BE_BITS 64
0038 #  else
0039 #  define CRC_BE_BITS 32
0040 #  endif
0041 #endif
0042 
0043 /*
0044  * Little-endian CRC computation.  Used with serial bit streams sent
0045  * lsbit-first.  Be sure to use cpu_to_le32() to append the computed CRC.
0046  */
0047 #if CRC_LE_BITS > 64 || CRC_LE_BITS < 1 || CRC_LE_BITS == 16 || \
0048     CRC_LE_BITS & CRC_LE_BITS-1
0049 # error "CRC_LE_BITS must be one of {1, 2, 4, 8, 32, 64}"
0050 #endif
0051 
0052 /*
0053  * Big-endian CRC computation.  Used with serial bit streams sent
0054  * msbit-first.  Be sure to use cpu_to_be32() to append the computed CRC.
0055  */
0056 #if CRC_BE_BITS > 64 || CRC_BE_BITS < 1 || CRC_BE_BITS == 16 || \
0057     CRC_BE_BITS & CRC_BE_BITS-1
0058 # error "CRC_BE_BITS must be one of {1, 2, 4, 8, 32, 64}"
0059 #endif