Update spdk crc32c.c with ARM CRC32 intrinsics
Implement spdk_crc32c_update() with ARM CRC32 intrinsics. Change-Id: I1daf7f21012aab02290f88a65bbae619eedf5087 Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> Reviewed-on: https://review.gerrithub.io/c/437218 Reviewed-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
e816c8fda8
commit
e3910413b2
@ -45,6 +45,17 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__aarch64__) || defined(__AARCH64__)
|
||||||
|
#ifdef __ARM_FEATURE_CRC32
|
||||||
|
#define SPDK_HAVE_ARM_CRC
|
||||||
|
#include <arm_acle.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__x86_64__) && defined(__SSE4_2__)
|
||||||
|
#define SPDK_HAVE_SSE4_2
|
||||||
|
#include <x86intrin.h>
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* IEEE CRC-32 polynomial (bit reflected)
|
* IEEE CRC-32 polynomial (bit reflected)
|
||||||
*/
|
*/
|
||||||
|
@ -33,8 +33,7 @@
|
|||||||
|
|
||||||
#include "spdk/crc32.h"
|
#include "spdk/crc32.h"
|
||||||
|
|
||||||
#if defined(__x86_64__) && defined(__SSE4_2__)
|
#ifdef SPDK_HAVE_SSE4_2
|
||||||
#include <x86intrin.h>
|
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
spdk_crc32c_update(const void *buf, size_t len, uint32_t crc)
|
spdk_crc32c_update(const void *buf, size_t len, uint32_t crc)
|
||||||
@ -70,7 +69,32 @@ spdk_crc32c_update(const void *buf, size_t len, uint32_t crc)
|
|||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* SSE 4.2 (CRC32 instruction) not available */
|
#elif defined(SPDK_HAVE_ARM_CRC)
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
spdk_crc32c_update(const void *buf, size_t len, uint32_t crc)
|
||||||
|
{
|
||||||
|
size_t count;
|
||||||
|
|
||||||
|
count = len / 8;
|
||||||
|
while (count--) {
|
||||||
|
uint64_t block;
|
||||||
|
|
||||||
|
memcpy(&block, buf, sizeof(block));
|
||||||
|
crc = __crc32cd(crc, block);
|
||||||
|
buf += sizeof(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
count = len & 7;
|
||||||
|
while (count--) {
|
||||||
|
crc = __crc32cb(crc, *(const uint8_t *)buf);
|
||||||
|
buf++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* Neither SSE 4.2 nor ARM CRC32 instructions available */
|
||||||
|
|
||||||
static struct spdk_crc32_table g_crc32c_table;
|
static struct spdk_crc32_table g_crc32c_table;
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ endif
|
|||||||
ifeq ($(TARGET_MACHINE),x86_64)
|
ifeq ($(TARGET_MACHINE),x86_64)
|
||||||
COMMON_CFLAGS += -march=native
|
COMMON_CFLAGS += -march=native
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(TARGET_MACHINE),aarch64)
|
||||||
|
COMMON_CFLAGS += -march=armv8-a+crc
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_WERROR), y)
|
ifeq ($(CONFIG_WERROR), y)
|
||||||
COMMON_CFLAGS += -Werror
|
COMMON_CFLAGS += -Werror
|
||||||
|
Loading…
Reference in New Issue
Block a user