From: Longfang Liu liulongfang@huawei.com
Add support for init2 performance test function for uadk_tools.
Signed-off-by: Longfang Liu liulongfang@huawei.com Signed-off-by: Zhiqi Song songzhiqi1@huawei.com --- uadk_tool/benchmark/uadk_benchmark.c | 113 ++++++++++++++++++++++++++- uadk_tool/benchmark/uadk_benchmark.h | 15 +++- 2 files changed, 126 insertions(+), 2 deletions(-)
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c index 6313ac6..1524291 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -117,6 +117,9 @@ static struct acc_alg_item alg_options[] = { {"aes-128-gcm", AES_128_GCM}, {"aes-192-gcm", AES_192_GCM}, {"aes-256-gcm", AES_256_GCM}, + {"aes-128-cbc-sha256-hmac", AES_128_CBC_SHA256_HMAC}, + {"aes-192-cbc-sha256-hmac", AES_192_CBC_SHA256_HMAC}, + {"aes-256-cbc-sha256-hmac", AES_256_CBC_SHA256_HMAC}, {"sm4-128-ccm", SM4_128_CCM}, {"sm4-128-gcm", SM4_128_GCM}, {"sm3", SM3_ALG}, @@ -128,9 +131,90 @@ static struct acc_alg_item alg_options[] = { {"sha512", SHA512_ALG}, {"sha512-224", SHA512_224}, {"sha512-256", SHA512_256}, + {"trng", TRNG}, {"", ALG_MAX} };
+static struct acc_alg_item alg_name_options[] = { + {"zlib", ZLIB}, + {"gzip", GZIP}, + {"deflate", DEFLATE}, + {"lz77_zstd", LZ77_ZSTD}, + {"rsa", RSA_1024}, + {"rsa", RSA_2048}, + {"rsa", RSA_3072}, + {"rsa", RSA_4096}, + {"rsa", RSA_1024_CRT}, + {"rsa", RSA_2048_CRT}, + {"rsa", RSA_3072_CRT}, + {"rsa", RSA_4096_CRT}, + {"dh", DH_768}, + {"dh", DH_1024}, + {"dh", DH_1536}, + {"dh", DH_2048}, + {"dh", DH_3072}, + {"dh", DH_4096}, + {"ecdh", ECDH_256}, + {"ecdh", ECDH_384}, + {"ecdh", ECDH_521}, + {"ecdsa", ECDSA_256}, + {"ecdsa", ECDSA_384}, + {"ecdsa", ECDSA_521}, + {"sm2", SM2_ALG}, + {"x25519", X25519_ALG}, + {"x448", X448_ALG}, + {"ecb(aes)", AES_128_ECB}, + {"ecb(aes)", AES_192_ECB}, + {"ecb(aes)", AES_256_ECB}, + {"cbc(aes)", AES_128_CBC}, + {"cbc(aes)", AES_192_CBC}, + {"cbc(aes)", AES_256_CBC}, + {"ctr(aes)", AES_128_CTR}, + {"ctr(aes)", AES_192_CTR}, + {"ctr(aes)", AES_256_CTR}, + {"ofb(aes)", AES_128_OFB}, + {"ofb(aes)", AES_192_OFB}, + {"ofb(aes)", AES_256_OFB}, + {"cfb(aes)", AES_128_CFB}, + {"cfb(aes)", AES_192_CFB}, + {"cfb(aes)", AES_256_CFB}, + {"xts(aes)", AES_256_XTS}, + {"xts(aes)", AES_512_XTS}, + {"ecb(des3_ede)", DES3_128_ECB}, + {"ecb(des3_ede)", DES3_192_ECB}, + {"cbc(des3_ede)", DES3_128_CBC}, + {"cbc(des3_ede)", DES3_192_CBC}, + {"ecb(sm4)", SM4_128_ECB}, + {"cbc(sm4)", SM4_128_CBC}, + {"ctr(sm4)", SM4_128_CTR}, + {"ofb(sm4)", SM4_128_OFB}, + {"cfb(sm4)", SM4_128_CFB}, + {"xts(sm4)", SM4_128_XTS}, + {"ccm(aes)", AES_128_CCM}, + {"ccm(aes)", AES_192_CCM}, + {"ccm(aes)", AES_256_CCM}, + {"gcm(aes)", AES_128_GCM}, + {"gcm(aes)", AES_192_GCM}, + {"gcm(aes)", AES_256_GCM}, + {"authenc(hmac(sha256),cbc(aes))", AES_128_CBC_SHA256_HMAC}, + {"authenc(hmac(sha256),cbc(aes))", AES_192_CBC_SHA256_HMAC}, + {"authenc(hmac(sha256),cbc(aes))", AES_256_CBC_SHA256_HMAC}, + {"ccm(sm4)", SM4_128_CCM}, + {"gcm(sm4)", SM4_128_GCM}, + {"sm3", SM3_ALG}, + {"md5", MD5_ALG}, + {"sha1", SHA1_ALG}, + {"sha256", SHA256_ALG}, + {"sha224", SHA224_ALG}, + {"sha384", SHA384_ALG}, + {"sha512", SHA512_ALG}, + {"sha512-224", SHA512_224}, + {"sha512-256", SHA512_256}, + {"trng", TRNG}, + {"", ALG_MAX} +}; + + /*-------------------------------------tool code------------------------------------------------------*/ void add_send_complete(void) { @@ -188,6 +272,20 @@ static int get_alg_type(const char *alg_name) return alg; }
+int get_alg_name(int alg, char *alg_name) +{ + int i; + + for (i = 0; i < ALG_MAX; i++) { + if (alg == alg_name_options[i].alg) { + strcpy(alg_name, alg_name_options[i].name); + return 0; + } + } + + return -EINVAL; +} + static int get_mode_type(const char *mode_name) { u32 modetype = INVALID_MODE; @@ -475,6 +573,8 @@ static void dump_param(struct acc_option *option) ACC_TST_PRT(" [--acctype]: %u\n", option->acctype); ACC_TST_PRT(" [--prefetch]:%u\n", option->prefetch); ACC_TST_PRT(" [--engine]: %s\n", option->engine); + ACC_TST_PRT(" [--latency]: %u\n", option->latency); + ACC_TST_PRT(" [--init2]: %u\n", option->inittype); }
int acc_benchmark_run(struct acc_option *option) @@ -596,6 +696,8 @@ static void print_help(void) ACC_TST_PRT(" list the all support alg\n"); ACC_TST_PRT(" [--latency]:\n"); ACC_TST_PRT(" test the running time of packets\n"); + ACC_TST_PRT(" [--init2]:\n"); + ACC_TST_PRT(" select init2 mode in the init interface of UADK SVA\n"); ACC_TST_PRT(" [--help] = usage\n"); ACC_TST_PRT("Example\n"); ACC_TST_PRT(" ./uadk_tool benchmark --alg aes-128-cbc --mode sva --opt 0 --sync\n"); @@ -633,7 +735,8 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option) {"engine", required_argument, 0, 13}, {"alglist", no_argument, 0, 14}, {"latency", no_argument, 0, 15}, - {"help", no_argument, 0, 16}, + {"init2", no_argument, 0, 16}, + {"help", no_argument, 0, 17}, {0, 0, 0, 0} };
@@ -687,6 +790,9 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option) option->latency = true; break; case 16: + option->inittype = INIT2_TYPE; + break; + case 17: print_help(); goto to_exit; default: @@ -760,6 +866,11 @@ int acc_option_convert(struct acc_option *option) goto param_err; }
+ if (option->inittype == INIT2_TYPE && option->modetype != SVA_MODE) { + ACC_TST_PRT("uadk benchmark No-SVA mode can't use init2\n"); + goto param_err; + } + return 0;
param_err: diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h index 5071457..e75a99d 100644 --- a/uadk_tool/benchmark/uadk_benchmark.h +++ b/uadk_tool/benchmark/uadk_benchmark.h @@ -44,12 +44,13 @@ typedef unsigned long long u64; /** * struct acc_option - Define the test acc app option list. * @algclass: 0:cipher 1:digest - * @acctype: The sub alg type, reference func get_cipher_resource. + * @acctype: The sub alg type, reference func get_cipher_resource * @syncmode: 0:sync mode 1:async mode * @modetype: sva, no-sva, soft mode * @optype: enc/dec, comp/decomp * @prefetch: write allocated memory to prevent page faults * @latency: test packet running time + * @inittype: source init method type, defined in enum acc_init_type */ struct acc_option { char algname[64]; @@ -69,6 +70,7 @@ struct acc_option { u32 engine_flag; u32 prefetch; bool latency; + u32 inittype; };
enum acc_type { @@ -77,6 +79,12 @@ enum acc_type { ZIP_TYPE, };
+enum acc_init_type { + INIT_TYPE = 0, + INIT2_TYPE, + MAX_TYPE, +}; + enum alg_type { DEFAULT_TYPE, CIPHER_TYPE, @@ -157,6 +165,9 @@ enum test_alg { AES_128_GCM, AES_192_GCM, AES_256_GCM, + AES_128_CBC_SHA256_HMAC, + AES_192_CBC_SHA256_HMAC, + AES_256_CBC_SHA256_HMAC, SM4_128_CCM, SM4_128_GCM, SM3_ALG, // digest @@ -168,6 +179,7 @@ enum test_alg { SHA512_ALG, SHA512_224, SHA512_256, // digest key all set 4 Bytes + TRNG, ALG_MAX, };
@@ -182,6 +194,7 @@ extern void add_recv_data(u32 cnt, u32 pkglen); extern void add_send_complete(void); extern u32 get_recv_time(void); extern void cal_avg_latency(u32 count); +extern int get_alg_name(int alg, char *alg_name);
int acc_cmd_parse(int argc, char *argv[], struct acc_option *option); int acc_default_case(struct acc_option *option);