]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/crc/aarch64: Added cpu feature pmull and make aarch64 specific crc function...
authorAdam Kupczyk <akupczyk@redhat.com>
Wed, 23 May 2018 13:06:19 +0000 (15:06 +0200)
committerAdam Kupczyk <akupczyk@redhat.com>
Wed, 23 May 2018 13:06:19 +0000 (15:06 +0200)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/arch/arm.c
src/arch/arm.h
src/common/crc32c_aarch64.c

index a8562f59674161bd4a81bce81e997191429bf967..c017b5d4d928ab7a00de75196d28bceff6a39f33 100644 (file)
@@ -4,6 +4,7 @@
 /* flags we export */
 int ceph_arch_neon = 0;
 int ceph_arch_aarch64_crc32 = 0;
+int ceph_arch_aarch64_pmull = 0;
 
 #include <stdio.h>
 
@@ -46,9 +47,8 @@ int ceph_arch_arm_probe(void)
        ceph_arch_neon = (get_hwcap() & HWCAP_NEON) == HWCAP_NEON;
 #elif __aarch64__ && __linux__
        ceph_arch_neon = (get_hwcap() & HWCAP_ASIMD) == HWCAP_ASIMD;
-# if defined(HAVE_ARMV8_CRC) && defined(HWCAP_CRC32)
        ceph_arch_aarch64_crc32 = (get_hwcap() & HWCAP_CRC32) == HWCAP_CRC32;
-# endif
+        ceph_arch_aarch64_pmull = (get_hwcap() & HWCAP_PMULL) == HWCAP_PMULL;
 #else
        if (0)
                get_hwcap();  // make compiler shut up
index 1659b2e94dec42cf6d1d9038f76dec7538d11863..dacc450b18f07af50072b0ebf6c815a6b47d43fe 100644 (file)
@@ -7,6 +7,7 @@ extern "C" {
 
 extern int ceph_arch_neon;  /* true if we have ARM NEON or ASIMD abilities */
 extern int ceph_arch_aarch64_crc32;  /* true if we have AArch64 CRC32/CRC32C abilities */
+extern int ceph_arch_aarch64_pmull;  /* true if we have AArch64 PMULL abilities */
 
 extern int ceph_arch_arm_probe(void);
 
index e4fbf23a7602a73846a9dc13c8043a42e398bd98..d15736a0cd9d0ff1b3c004402e7d42142d1e80fe 100644 (file)
@@ -1,6 +1,7 @@
 #include "acconfig.h"
 #include "include/int_types.h"
 #include "common/crc32c_aarch64.h"
+#include "arch/arm.h"
 
 #ifndef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS
 /* Request crc extension capabilities from the assembler */
@@ -96,6 +97,7 @@ uint32_t ceph_crc32c_aarch64(uint32_t crc, unsigned char const *buffer, unsigned
 
        if (buffer) {
 #ifdef HAVE_ARMV8_CRYPTO
+               if (ceph_arch_aarch64_pmull) {
 #ifdef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS
                /* Calculate reflected crc with PMULL Instruction */
                const poly64_t k1 = 0xe417f38a, k2 = 0x8f158014;
@@ -183,7 +185,7 @@ uint32_t ceph_crc32c_aarch64(uint32_t crc, unsigned char const *buffer, unsigned
 
                if(!(length += 1024))
                        return crc;
-
+               }
 #endif /* HAVE_ARMV8_CRYPTO */
                while ((length -= sizeof(uint64_t)) >= 0) {
                        CRC32CX(crc, *(uint64_t *)buffer);
@@ -203,6 +205,7 @@ uint32_t ceph_crc32c_aarch64(uint32_t crc, unsigned char const *buffer, unsigned
                        CRC32CB(crc, *buffer);
        } else {
 #ifdef HAVE_ARMV8_CRYPTO
+               if (ceph_arch_aarch64_pmull) {
 #ifdef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS
                const poly64_t k1 = 0xe417f38a;
                uint64_t t0;
@@ -250,7 +253,7 @@ uint32_t ceph_crc32c_aarch64(uint32_t crc, unsigned char const *buffer, unsigned
 
                if(!(length += 1024))
                        return crc;
-
+               }
 #endif /* HAVE_ARMV8_CRYPTO */
                while ((length -= sizeof(uint64_t)) >= 0)
                        CRC32CX(crc, 0);