From a23b8c8c0aa09f1908606c70f5a18eb171e062b1 Mon Sep 17 00:00:00 2001 From: Richael Zhuang Date: Thu, 17 Jan 2019 10:04:31 +0800 Subject: [PATCH] Update spdk crc32.c with ARM CRC32 intrinsics Implement spdk_crc32_update() with ARM CRC32 intrinsics. Change-Id: I6a64122f5dd3b804408cfae61a205e78fd8c4547 Signed-off-by: Richael Zhuang Reviewed-on: https://review.gerrithub.io/c/440828 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/util/crc32.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/util/crc32.c b/lib/util/crc32.c index dfef9c54a..6fbb004ce 100644 --- a/lib/util/crc32.c +++ b/lib/util/crc32.c @@ -52,6 +52,32 @@ spdk_crc32_table_init(struct spdk_crc32_table *table, uint32_t polynomial_reflec } } +#ifdef SPDK_HAVE_ARM_CRC + +uint32_t +spdk_crc32_update(const struct spdk_crc32_table *table, const void *buf, size_t len, uint32_t crc) +{ + size_t count; + const uint64_t *dword_buf; + + count = len & 7; + while (count--) { + crc = __crc32b(crc, *(const uint8_t *)buf); + buf++; + } + dword_buf = (const uint64_t *)buf; + + count = len / 8; + while (count--) { + crc = __crc32d(crc, *dword_buf); + dword_buf++; + } + + return crc; +} + +#else + uint32_t spdk_crc32_update(const struct spdk_crc32_table *table, const void *buf, size_t len, uint32_t crc) { @@ -64,3 +90,5 @@ spdk_crc32_update(const struct spdk_crc32_table *table, const void *buf, size_t return crc; } + +#endif