From e34a0bb0cc5c381f45877e05d927fd4bc5dc98f6 Mon Sep 17 00:00:00 2001 From: Hao Fang Date: Sat, 22 Oct 2022 15:27:20 +0800 Subject: uadk_engine: use HW_V2/HW_V3 to distinguish different hardware platforms Hardware version numbers are used to distinguish different hardware. Signed-off-by: Hao Fang Tested-by: Junchong Pan --- src/uadk.h | 4 ++-- src/uadk_cipher.c | 22 +++++++++++----------- test/sanity_test.sh | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/uadk.h b/src/uadk.h index cd3447c..99c65c7 100644 --- a/src/uadk.h +++ b/src/uadk.h @@ -27,8 +27,8 @@ #define ENGINE_RECV_MAX_CNT 60000000 enum { - KUNPENG920, - KUNPENG930, + HW_V2, + HW_V3, }; extern const char *engine_uadk_id; diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c index c5bc7af..c6878c3 100644 --- a/src/uadk_cipher.c +++ b/src/uadk_cipher.c @@ -77,7 +77,7 @@ static int platform; #define SMALL_PACKET_OFFLOAD_THRESHOLD_DEFAULT 192 -static int cipher_920_nids[] = { +static int cipher_hw_v2_nids[] = { NID_aes_128_cbc, NID_aes_192_cbc, NID_aes_256_cbc, @@ -93,7 +93,7 @@ static int cipher_920_nids[] = { 0, }; -static int cipher_930_nids[] = { +static int cipher_hw_v3_nids[] = { NID_aes_128_cbc, NID_aes_192_cbc, NID_aes_256_cbc, @@ -342,9 +342,9 @@ static int uadk_get_accel_platform(char *alg_name) return 0; if (!strcmp(dev->api, "hisi_qm_v2")) - platform = KUNPENG920; + platform = HW_V2; else - platform = KUNPENG930; + platform = HW_V3; free(dev); return 1; @@ -358,12 +358,12 @@ static int uadk_e_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher, int size; int i; - if (platform == KUNPENG920) { - size = (sizeof(cipher_920_nids) - 1) / sizeof(int); - cipher_nids = cipher_920_nids; + if (platform == HW_V2) { + size = (sizeof(cipher_hw_v2_nids) - 1) / sizeof(int); + cipher_nids = cipher_hw_v2_nids; } else { - size = (sizeof(cipher_930_nids) - 1) / sizeof(int); - cipher_nids = cipher_930_nids; + size = (sizeof(cipher_hw_v3_nids) - 1) / sizeof(int); + cipher_nids = cipher_hw_v3_nids; } if (!cipher) { @@ -1073,7 +1073,7 @@ int uadk_e_bind_cipher(ENGINE *e) } bind_v2_cipher(); - if (platform > KUNPENG920) + if (platform > HW_V2) bind_v3_cipher(); return ENGINE_set_ciphers(e, uadk_e_engine_ciphers); @@ -1155,7 +1155,7 @@ void uadk_e_destroy_cipher(void) pthread_spin_destroy(&engine.lock); destroy_v2_cipher(); - if (platform > KUNPENG920) + if (platform > HW_V2) destroy_v3_cipher(); } diff --git a/test/sanity_test.sh b/test/sanity_test.sh index 2c0c504..bdedc15 100755 --- a/test/sanity_test.sh +++ b/test/sanity_test.sh @@ -103,7 +103,7 @@ if [[ $algs =~ "RSA" ]]; then openssl speed -elapsed -engine $engine_id -async_jobs 1 rsa4096 fi -#ecdsa only supported in Kunpeng930 or later +#ecdsa only supported in HW_V3 or later if [[ $algs =~ "id-ecPublicKey" ]]; then echo "testing ECDSA" openssl speed -elapsed -engine $engine_id ecdsap224 @@ -116,21 +116,21 @@ if [[ $algs =~ "id-ecPublicKey" ]]; then openssl speed -elapsed -engine $engine_id -async_jobs 1 ecdsap521 fi -#X25519 only supported in Kunpeng930 or later +#X25519 only supported in HW_V3 or later if [[ $algs =~ "X25519" ]]; then echo "testing X25519" openssl speed -elapsed -engine $engine_id ecdhx25519 openssl speed -elapsed -engine $engine_id -async_jobs 1 ecdhx25519 fi -#X448 only supported in Kunpeng930 or later +#X448 only supported in HW_V3 or later if [[ $algs =~ "X448" ]]; then echo "testing X448" openssl speed -elapsed -engine $engine_id ecdhx448 openssl speed -elapsed -engine $engine_id -async_jobs 1 ecdhx448 fi -#ecdh only supported in Kunpeng930 or later +#ecdh only supported in HW_V3 or later if [[ $algs =~ "id-ecPublicKey" ]]; then echo "testing ECDH" openssl speed -elapsed -engine $engine_id ecdhp192 -- 1.8.3.1