Commit e3910413 authored by Richael Zhuang's avatar Richael Zhuang Committed by Ben Walker
Browse files

Update spdk crc32c.c with ARM CRC32 intrinsics



Implement spdk_crc32c_update() with ARM CRC32 intrinsics.

Change-Id: I1daf7f21012aab02290f88a65bbae619eedf5087
Signed-off-by: default avatarRichael Zhuang <richael.zhuang@arm.com>
Reviewed-on: https://review.gerrithub.io/c/437218


Reviewed-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent e816c8fd
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -45,6 +45,17 @@
extern "C" {
#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)
 */
+27 −3
Original line number Diff line number Diff line
@@ -33,8 +33,7 @@

#include "spdk/crc32.h"

#if defined(__x86_64__) && defined(__SSE4_2__)
#include <x86intrin.h>
#ifdef SPDK_HAVE_SSE4_2

uint32_t
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;
}

#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;

+3 −0
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ endif
ifeq ($(TARGET_MACHINE),x86_64)
COMMON_CFLAGS += -march=native
endif
ifeq ($(TARGET_MACHINE),aarch64)
COMMON_CFLAGS += -march=armv8-a+crc
endif

ifeq ($(CONFIG_WERROR), y)
COMMON_CFLAGS += -Werror