summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2024-06-13 10:08:03 +0000
committerDamjan Marion <dmarion@0xa5.net>2024-06-14 08:40:20 +0000
commit2aa0f0da5dedcf6301c74a39b5e3749359e07e6d (patch)
treed59c56e40e4f94da1b9d06015b7d4cf8e8878941 /src/plugins
parent75e8ffb2615d804e51b6d7538539f4eac2e74bee (diff)
crypto-native: fix CPU detection for SHA2 code
Type: fix Fixes: 9f2799f Change-Id: Ib2b2df17507c536350ec92eeb1eea58f3a240c76 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/crypto_native/sha2.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/plugins/crypto_native/sha2.c b/src/plugins/crypto_native/sha2.c
index 459ce6d8e79..6787f629104 100644
--- a/src/plugins/crypto_native/sha2.c
+++ b/src/plugins/crypto_native/sha2.c
@@ -118,13 +118,25 @@ sha2_key_add (vnet_crypto_key_t *key, clib_sha2_type_t type)
static int
probe ()
{
-#if defined(__SHA__) && defined(__x86_64__)
+#if defined(__x86_64__)
+
+#if defined(__SHA__) && defined(__AVX512F__)
+ if (clib_cpu_supports_sha () && clib_cpu_supports_avx512f ())
+ return 30;
+#elif defined(__SHA__) && defined(__AVX2__)
+ if (clib_cpu_supports_sha () && clib_cpu_supports_avx2 ())
+ return 20;
+#elif defined(__SHA__)
if (clib_cpu_supports_sha ())
- return 50;
-#elif defined(__ARM_FEATURE_SHA2)
+ return 10;
+#endif
+
+#elif defined(__aarch64__)
+#if defined(__ARM_FEATURE_SHA2)
if (clib_cpu_supports_sha2 ())
return 10;
#endif
+#endif
return -1;
}