Synchronize the code of the test tool UADK Tools to ensure that the test tool code is normal before adding new functions
Signed-off-by: Longfang Liu liulongfang@huawei.com --- uadk_tool/benchmark/hpre_protocol_data.h | 2 +- uadk_tool/benchmark/hpre_uadk_benchmark.c | 40 +++------------------ uadk_tool/benchmark/hpre_wd_benchmark.c | 11 +++--- uadk_tool/benchmark/sec_soft_benchmark.c | 4 --- uadk_tool/benchmark/sec_uadk_benchmark.c | 43 ++++------------------- uadk_tool/benchmark/sec_wd_benchmark.c | 11 +++--- uadk_tool/benchmark/trng_wd_benchmark.c | 3 +- uadk_tool/benchmark/uadk_benchmark.c | 10 +++--- uadk_tool/benchmark/zip_uadk_benchmark.c | 37 ++----------------- uadk_tool/benchmark/zip_wd_benchmark.c | 3 +- 10 files changed, 36 insertions(+), 128 deletions(-)
diff --git a/uadk_tool/benchmark/hpre_protocol_data.h b/uadk_tool/benchmark/hpre_protocol_data.h index 7bdb942..fdbac35 100644 --- a/uadk_tool/benchmark/hpre_protocol_data.h +++ b/uadk_tool/benchmark/hpre_protocol_data.h @@ -246,7 +246,7 @@ static unsigned char rsa_qinv_3072[] = { };
static unsigned char rsa_d_3072[] = { - 0x33, 0x49, 0x58, 0xb0, 0x89, 0x3d, 0x96, 0x78, 0xb7, 0x2a, 0x99, 0x5e, 0x0c, 0x56, 0xae, 0x08, + 0x33, 0x49, 0x58, 0xb0, 0x89, 0x3d, 0x96, 0x78, 0xb7, 0x2a, 0x99, 0x5e, 0x0c, 0x56, 0xae, 0x08, 0x32, 0xe1, 0xb9, 0x1c, 0x17, 0xd7, 0x71, 0xaa, 0x57, 0x37, 0x58, 0xbf, 0x94, 0xf8, 0xa0, 0xdf, 0xdb, 0x0a, 0xfd, 0x2f, 0xce, 0x8a, 0x82, 0x43, 0x11, 0x48, 0x6b, 0xec, 0x61, 0x72, 0x77, 0x98, 0x53, 0x00, 0x32, 0x5e, 0xbe, 0x3d, 0x37, 0xaf, 0x53, 0x55, 0x13, 0xc7, 0x61, 0x03, 0x6a, 0x28, diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c index bc0687d..47ee5b5 100644 --- a/uadk_tool/benchmark/hpre_uadk_benchmark.c +++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c @@ -610,10 +610,7 @@ static void uninit_hpre_ctx_config2(int subtype)
static int init_hpre_ctx_config2(struct acc_option *options) { - struct wd_ctx_params cparams = {0}; - struct wd_ctx_nums *ctx_set_num; int subtype = options->subtype; - int mode = options->syncmode; char alg_name[MAX_ALG_NAME]; int ret;
@@ -623,49 +620,22 @@ static int init_hpre_ctx_config2(struct acc_option *options) return -EINVAL; }
- ctx_set_num = calloc(1, sizeof(*ctx_set_num)); - if (!ctx_set_num) { - WD_ERR("failed to alloc ctx_set_size!\n"); - return -WD_ENOMEM; - } - - cparams.op_type_num = 1; - cparams.ctx_set_num = ctx_set_num; - cparams.bmp = numa_allocate_nodemask(); - if (!cparams.bmp) { - WD_ERR("failed to create nodemask!\n"); - ret = -WD_ENOMEM; - goto out_freectx; - } - - numa_bitmask_setall(cparams.bmp); - - if (mode == CTX_MODE_SYNC) - ctx_set_num->sync_ctx_num = g_ctxnum; - else - ctx_set_num->async_ctx_num = g_ctxnum; - /* init2 */ switch (subtype) { case RSA_TYPE: - return wd_rsa_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &cparams); + return wd_rsa_init2(alg_name, SCHED_POLICY_RR, TASK_HW); case DH_TYPE: - return wd_dh_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &cparams); + return wd_dh_init2(alg_name, SCHED_POLICY_RR, TASK_HW); case ECDH_TYPE: case ECDSA_TYPE: case SM2_TYPE: case X25519_TYPE: case X448_TYPE: - return wd_ecc_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &cparams); + return wd_ecc_init2(alg_name, SCHED_POLICY_RR, TASK_HW); default: HPRE_TST_PRT("failed to parse alg subtype on uninit2!\n"); return -EINVAL; } - -out_freectx: - free(ctx_set_num); - - return ret; }
/*-------------------------------uadk benchmark main code-------------------------------------*/ @@ -2263,7 +2233,7 @@ static void *ecc_uadk_sync_run(void *arg) memset(&req, 0, sizeof(req));
memset(&setup, 0, sizeof(setup)); - if (subtype != X448_TYPE && subtype != X25519_TYPE) { + if (subtype != X448_TYPE || subtype != X25519_TYPE) { ret = get_ecc_curve(&setup, cid); if (ret) return NULL; @@ -2422,7 +2392,7 @@ static void *ecc_uadk_async_run(void *arg) memset(&req, 0, sizeof(req));
memset(&setup, 0, sizeof(setup)); - if (subtype != X448_TYPE && subtype != X25519_TYPE) { + if (subtype != X448_TYPE || subtype != X25519_TYPE) { ret = get_ecc_curve(&setup, cid); if (ret) return NULL; diff --git a/uadk_tool/benchmark/hpre_wd_benchmark.c b/uadk_tool/benchmark/hpre_wd_benchmark.c index 0196e62..6e9f208 100644 --- a/uadk_tool/benchmark/hpre_wd_benchmark.c +++ b/uadk_tool/benchmark/hpre_wd_benchmark.c @@ -459,7 +459,8 @@ static int init_hpre_wd_queue(struct acc_option *options) PATH_STR_SIZE, "%s", options->device); if (ret < 0) { WD_ERR("failed to copy dev file path!\n"); - return -WD_EINVAL; + ret = -WD_EINVAL; + goto queue_out; } }
@@ -556,8 +557,8 @@ void *hpre_wd_poll(void *data) while (last_time) { recv = wd_poll_ctx(queue, expt); /* - * async mode poll easy to 100% with small package. - * SEC_TST_PRT("poll %d recv: %u!\n", i, recv); + * warpdrive async mode poll easy to 100% with small package. + * SEC_TST_PRT("warpdrive poll %d recv: %u!\n", i, recv); */
if (unlikely(recv < 0)) { @@ -2115,7 +2116,7 @@ static void *ecc_wd_sync_run(void *arg) queue = g_thread_queue.bd_res[pdata->td_id].queue;
memset(&setup, 0, sizeof(setup)); - if (subtype != X448_TYPE && subtype != X25519_TYPE) { + if (subtype != X448_TYPE || subtype != X25519_TYPE) { ret = get_ecc_curve(&setup, cid); if (ret) return NULL; @@ -2273,7 +2274,7 @@ static void *ecc_wd_async_run(void *arg) queue = g_thread_queue.bd_res[pdata->td_id].queue;
memset(&setup, 0, sizeof(setup)); - if (subtype != X448_TYPE && subtype != X25519_TYPE) { + if (subtype != X448_TYPE || subtype != X25519_TYPE) { ret = get_ecc_curve(&setup, cid); if (ret) return NULL; diff --git a/uadk_tool/benchmark/sec_soft_benchmark.c b/uadk_tool/benchmark/sec_soft_benchmark.c index 8fa523c..850a0db 100644 --- a/uadk_tool/benchmark/sec_soft_benchmark.c +++ b/uadk_tool/benchmark/sec_soft_benchmark.c @@ -280,7 +280,6 @@ static int sec_soft_param_parse(soft_thread *tddata, struct acc_option *options) mode = WD_CIPHER_CBC; tddata->evp_cipher = EVP_des_ede3_cbc(); break; -#ifndef OPENSSL_NO_SM4 case SM4_128_ECB: keysize = 16; mode = WD_CIPHER_ECB; @@ -310,7 +309,6 @@ static int sec_soft_param_parse(soft_thread *tddata, struct acc_option *options) keysize = 16; mode = WD_CIPHER_XTS; break; -#endif case AES_128_CCM: keysize = 16; mode = WD_CIPHER_CCM; @@ -356,7 +354,6 @@ static int sec_soft_param_parse(soft_thread *tddata, struct acc_option *options) mode = WD_CIPHER_CBC; tddata->evp_cipher = EVP_aes_256_cbc(); break; -#ifndef OPENSSL_NO_SM4 case SM4_128_CCM: keysize = 16; mode = WD_CIPHER_CCM; @@ -365,7 +362,6 @@ static int sec_soft_param_parse(soft_thread *tddata, struct acc_option *options) keysize = 16; mode = WD_CIPHER_GCM; break; -#endif case SM3_ALG: // digest mode is optype keysize = 4; mode = optype; diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c index 411d0c4..c4e4e27 100644 --- a/uadk_tool/benchmark/sec_uadk_benchmark.c +++ b/uadk_tool/benchmark/sec_uadk_benchmark.c @@ -150,10 +150,10 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options) u32 out_bytes = 32; u8 keysize = 0; u8 ivsize = 0; - u8 dmode = 0; - u8 dalg = 0; - u8 mode = 0; - u8 alg = 0; + u8 dmode; + u8 dalg; + u8 mode; + u8 alg;
switch(algtype) { case AES_128_ECB: @@ -795,10 +795,7 @@ static void uninit_ctx_config2(int subtype)
static int init_ctx_config2(struct acc_option *options) { - struct wd_ctx_params cparams = {0}; - struct wd_ctx_nums *ctx_set_num; int subtype = options->subtype; - int mode = options->syncmode; char alg_name[MAX_ALG_NAME]; int ret;
@@ -808,32 +805,10 @@ static int init_ctx_config2(struct acc_option *options) return -EINVAL; }
- ctx_set_num = calloc(1, sizeof(*ctx_set_num)); - if (!ctx_set_num) { - WD_ERR("failed to alloc ctx_set_size!\n"); - return -WD_ENOMEM; - } - - cparams.op_type_num = 1; - cparams.ctx_set_num = ctx_set_num; - cparams.bmp = numa_allocate_nodemask(); - if (!cparams.bmp) { - WD_ERR("failed to create nodemask!\n"); - ret = -WD_ENOMEM; - goto out_freectx; - } - - numa_bitmask_setall(cparams.bmp); - - if (mode == CTX_MODE_SYNC) - ctx_set_num->sync_ctx_num = g_ctxnum; - else - ctx_set_num->async_ctx_num = g_ctxnum; - /* init */ switch(subtype) { case CIPHER_TYPE: - ret = wd_cipher_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &cparams); + ret = wd_cipher_init2(alg_name, SCHED_POLICY_RR, TASK_HW); if (ret) SEC_TST_PRT("failed to do cipher init2!\n"); break; @@ -843,12 +818,12 @@ static int init_ctx_config2(struct acc_option *options) SEC_TST_PRT("failed to do cipher intruction init2!\n"); break; case AEAD_TYPE: - ret = wd_aead_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &cparams); + ret = wd_aead_init2(alg_name, SCHED_POLICY_RR, TASK_HW); if (ret) SEC_TST_PRT("failed to do aead init2!\n"); break; case DIGEST_TYPE: - ret = wd_digest_init2_(alg_name, options->sched_type, options->task_type, &cparams); + ret = wd_digest_init2(alg_name, options->sched_type, options->task_type); if (ret) SEC_TST_PRT("failed to do digest init2!\n"); break; @@ -858,11 +833,7 @@ static int init_ctx_config2(struct acc_option *options) return ret; }
-out_freectx: - free(ctx_set_num); - return ret; - }
static void get_aead_data(u8 *addr, u32 size) diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c index e022dcb..86aef7a 100644 --- a/uadk_tool/benchmark/sec_wd_benchmark.c +++ b/uadk_tool/benchmark/sec_wd_benchmark.c @@ -214,10 +214,10 @@ static int sec_wd_param_parse(thread_data *tddata, struct acc_option *options) bool is_union = false; u8 keysize = 0; u8 ivsize = 0; - u8 dmode = 0; - u8 dalg = 0; - u8 mode = 0; - u8 alg = 0; + u8 dmode; + u8 dalg; + u8 mode; + u8 alg;
switch(algtype) { case AES_128_ECB: @@ -623,7 +623,8 @@ static int init_wd_queue(struct acc_option *options) PATH_STR_SIZE, "%s", options->device); if (ret < 0) { WD_ERR("failed to copy dev file path!\n"); - return -WD_EINVAL; + ret = -WD_EINVAL; + goto queue_out; } }
diff --git a/uadk_tool/benchmark/trng_wd_benchmark.c b/uadk_tool/benchmark/trng_wd_benchmark.c index 2f058d4..2fa437c 100644 --- a/uadk_tool/benchmark/trng_wd_benchmark.c +++ b/uadk_tool/benchmark/trng_wd_benchmark.c @@ -56,7 +56,8 @@ static int init_trng_wd_queue(struct acc_option *options) PATH_STR_SIZE, "%s", options->device); if (ret < 0) { WD_ERR("failed to copy dev file path!\n"); - return -WD_EINVAL; + ret = -WD_EINVAL; + goto free_mem; } }
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c index 0f01fdf..fcb28c4 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -480,7 +480,7 @@ void cal_perfermance_data(struct acc_option *option, u32 sttime) ops = perfops / option->times;
ACC_TST_PRT("algname:\tlength:\t\tperf:\t\tiops:\t\tCPU_rate:\n" - "%s\t%-2uBytes \t%.2f%s\t%.1fKops \t%.2f%%\n", + "%s\t%-2uBytes \t%.2f%s\t%.2fKops\t%.2f%%\n", palgname, option->pktlen, perfermance, unit, ops, cpu_rate); }
@@ -494,15 +494,13 @@ static int benchmark_run(struct acc_option *option) (option->modetype == INSTR_MODE) || (option->modetype == MULTIBUF_MODE)) { ret = sec_uadk_benchmark(option); + usleep(20000); } else if (option->modetype == NOSVA_MODE) { ret = sec_wd_benchmark(option); - } - usleep(20000); -#ifdef HAVE_CRYPTO - if (option->modetype == SOFT_MODE) { + usleep(20000); + } else if (option->modetype == SOFT_MODE) { ret = sec_soft_benchmark(option); } -#endif break; case HPRE_TYPE: if (option->modetype == SVA_MODE) { diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c index 2133297..1e98d95 100644 --- a/uadk_tool/benchmark/zip_uadk_benchmark.c +++ b/uadk_tool/benchmark/zip_uadk_benchmark.c @@ -17,6 +17,7 @@ #define COMPRESSION_RATIO_FACTOR 0.7 #define CHUNK_SIZE (128 * 1024) #define MAX_UNRECV_PACKET_NUM 2 + struct uadk_bd { u8 *src; u8 *dst; @@ -299,11 +300,8 @@ static void uninit_ctx_config2(void)
static int init_ctx_config2(struct acc_option *options) { - struct wd_ctx_params cparams = {0}; - struct wd_ctx_nums *ctx_set_num; - int mode = options->syncmode; char alg_name[MAX_ALG_NAME]; - int ret; + int ret = 0;
ret = get_alg_name(options->algtype, alg_name); if (ret) { @@ -311,43 +309,14 @@ static int init_ctx_config2(struct acc_option *options) return -EINVAL; }
- ctx_set_num = calloc(WD_DIR_MAX, sizeof(*ctx_set_num)); - if (!ctx_set_num) { - WD_ERR("failed to alloc ctx_set_size!\n"); - return -WD_ENOMEM; - } - - cparams.op_type_num = WD_DIR_MAX; - cparams.ctx_set_num = ctx_set_num; - cparams.bmp = numa_allocate_nodemask(); - if (!cparams.bmp) { - WD_ERR("failed to create nodemask!\n"); - ret = -WD_ENOMEM; - goto out_freectx; - } - - numa_bitmask_setall(cparams.bmp); - - for (int i = 0; i < WD_DIR_MAX; i++) { - if (mode == CTX_MODE_SYNC) - ctx_set_num[i].sync_ctx_num = g_ctxnum; - else - ctx_set_num[i].async_ctx_num = g_ctxnum; - } - /* init */ - ret = wd_comp_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &cparams); + ret = wd_comp_init2(alg_name, SCHED_POLICY_RR, TASK_HW); if (ret) { ZIP_TST_PRT("failed to do comp init2!\n"); return ret; }
return 0; - -out_freectx: - free(ctx_set_num); - - return ret; }
static int specified_device_request_ctx(struct acc_option *options) diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c index 8ad3e96..bdae79f 100644 --- a/uadk_tool/benchmark/zip_wd_benchmark.c +++ b/uadk_tool/benchmark/zip_wd_benchmark.c @@ -323,7 +323,8 @@ static int init_zip_wd_queue(struct acc_option *options) PATH_STR_SIZE, "%s", options->device); if (ret < 0) { WD_ERR("failed to copy dev file path!\n"); - return -WD_EINVAL; + ret = -WD_EINVAL; + goto queue_out; } }