#define DEBUG_SUBSYSTEM S_RPC
-#ifndef CONFIG_CRYPTO_CRC32
#include <linux/crc32.h>
-#endif
#include <libcfs/libcfs.h>
__u32 crc;
LASSERTF(pb != NULL, "invalid msg %p: no ptlrpc body!\n", msg);
-#ifdef CONFIG_CRYPTO_CRC32
+#if IS_ENABLED(CONFIG_CRC32)
+ /* about 10x faster than crypto_hash for small buffers */
+ crc = crc32_le(~(__u32)0, (unsigned char *)pb, len);
+#elif IS_ENABLED(CONFIG_CRYPTO_CRC32)
unsigned int hsize = 4;
cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
len, NULL, 0, (unsigned char *)&crc,
&hsize);
#else
- crc = crc32_le(~(__u32)0, (unsigned char *)pb, len);
+#error "need either CONFIG_CRC32 or CONFIG_CRYPTO_CRC32 enabled in the kernel"
#endif
return crc;
}