1. update the code editing method for random number acquisition. 2. remove some remaining asset operations 3. fix a memory leak issue
Signed-off-by: Longfang Liu liulongfang@huawei.com --- uadk_tool/benchmark/hpre_uadk_benchmark.c | 15 ---------- uadk_tool/benchmark/hpre_wd_benchmark.c | 15 ---------- uadk_tool/benchmark/sec_soft_benchmark.c | 16 ++++++---- uadk_tool/benchmark/sec_uadk_benchmark.c | 13 ++++---- uadk_tool/benchmark/sec_wd_benchmark.c | 36 ++++++++++++++--------- uadk_tool/benchmark/uadk_benchmark.c | 19 ++++++------ uadk_tool/benchmark/zip_uadk_benchmark.c | 12 ++++---- uadk_tool/benchmark/zip_wd_benchmark.c | 12 ++++---- 8 files changed, 59 insertions(+), 79 deletions(-)
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c index 13e24ca..e3372fb 100644 --- a/uadk_tool/benchmark/hpre_uadk_benchmark.c +++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c @@ -1206,11 +1206,6 @@ key_release:
static void rsa_async_cb(void *req_t) { - //struct wd_rsa_req *req = req_t; - //struct rsa_async_tag *tag = req->cb_param; - //enum wd_rsa_op_type op_type = req->op_type; - //handle_t h_sess = tag->sess; - return; }
@@ -1517,11 +1512,6 @@ ag_error:
static void dh_async_cb(void *req_t) { - //struct wd_dh_req *req = req_t; - //struct rsa_async_tag *tag = req->cb_param; - //enum wd_rsa_op_type op_type = req->op_type; - //handle_t h_sess = tag->sess; - return; }
@@ -2112,11 +2102,6 @@ msg_release:
static void ecc_async_cb(void *req_t) { - //struct wd_ecc_req *req = req_t; - //struct rsa_async_tag *tag = req->cb_param; - //enum wd_rsa_op_type op_type = req->op_type; - //handle_t h_sess = tag->sess; - return; }
diff --git a/uadk_tool/benchmark/hpre_wd_benchmark.c b/uadk_tool/benchmark/hpre_wd_benchmark.c index 231b569..2e23c95 100644 --- a/uadk_tool/benchmark/hpre_wd_benchmark.c +++ b/uadk_tool/benchmark/hpre_wd_benchmark.c @@ -936,11 +936,6 @@ key_release:
static void rsa_async_cb(const void *msg, void *tag) { - //struct wcrypto_rsa_msg *massage = msg; - //struct rsa_async_tag *ptag = tag; - //u32 op_type = tag->op_type; - //void *ctx = tag->ctx; - return; }
@@ -1333,11 +1328,6 @@ ctx_release:
static void dh_async_cb(const void *msg, void *tag) { - //struct wcrypto_dh_msg *massage = msg; - //struct rsa_async_tag *ptag = tag; - //u32 op_type = tag->op_type; - //void *ctx = tag->ctx; - return; }
@@ -2203,11 +2193,6 @@ msg_release:
static void ecc_async_cb(const void *msg, void *tag) { - //struct wcrypto_ecc_msg *massage = msg; - //struct rsa_async_tag *ptag = tag; - //u32 op_type = tag->op_type; - //void *ctx = tag->ctx; - return; }
diff --git a/uadk_tool/benchmark/sec_soft_benchmark.c b/uadk_tool/benchmark/sec_soft_benchmark.c index f3510b1..3a38cbd 100644 --- a/uadk_tool/benchmark/sec_soft_benchmark.c +++ b/uadk_tool/benchmark/sec_soft_benchmark.c @@ -428,7 +428,7 @@ static int sec_soft_cipher_jobfunc(void *args) u32 jid = jdata->jobid; struct bd_pool *soft_pool; u8 *priv_iv, *priv_key; - int ret, outl, i = 0; + int ret, outl, i; EVP_CIPHER_CTX *ctx; ASYNC_JOB *currjob; u32 count = 0; @@ -509,9 +509,13 @@ static int sec_soft_aead_jobfunc(void *args) u32 jid = jdata->jobid; struct bd_pool *soft_pool; u8 *priv_iv, *priv_key; - int ret, outl, i = 0; + int ret, outl, i; EVP_CIPHER_CTX *ctx; ASYNC_JOB *currjob; + /* + * these length parameters specify the default + * length according to the GCM/CCM algorithm + */ u8 faketag[16] = {0xcc}; u8 aad[13] = {0xcc}; u8 tag[12] = {0}; @@ -615,7 +619,7 @@ static int sec_soft_digest_jobfunc(void *args) u32 ssl_size = 0; u8 *priv_key, *src; u32 count = 0; - int i = 0; + int i;
currjob = ASYNC_get_current_job(); if (!currjob) { @@ -821,7 +825,7 @@ static void *sec_soft_cipher_sync(void *arg) EVP_CIPHER_CTX *ctx = NULL; u32 count = 0; u8 *src, *dst; - int ret, i = 0; + int ret, i; int outl = 0;
if (!evp_cipher) { @@ -901,7 +905,7 @@ static void *sec_soft_aead_sync(void *arg) u8 tag[12] = {0}; u32 count = 0; u8 *src, *dst; - int ret, i = 0; + int ret, i; int outl = 0;
if (!evp_cipher) { @@ -1006,7 +1010,7 @@ static void *sec_soft_digest_sync(void *arg) u8 *priv_key, *src; u32 ssl_size = 0; u32 count = 0; - int i = 0; + int i;
if (!evp_cipher && !evp_md) { SSL_TST_PRT("Error: openssl not support!\n"); diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c index ff83769..16f96a2 100644 --- a/uadk_tool/benchmark/sec_uadk_benchmark.c +++ b/uadk_tool/benchmark/sec_uadk_benchmark.c @@ -62,7 +62,6 @@ static void *aead_async_cb(struct wd_aead_req *req, void *data)
static void *digest_async_cb(void *data) { - // struct wd_digest_req *req = (struct wd_digest_req *)data; return NULL; }
@@ -648,7 +647,7 @@ static void *sec_uadk_cipher_async(void *arg) int try_cnt = 0; handle_t h_sess; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -720,7 +719,7 @@ static void *sec_uadk_aead_async(void *arg) handle_t h_sess; u32 auth_size = 16; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -819,7 +818,7 @@ static void *sec_uadk_digest_async(void *arg) int try_cnt = 0; handle_t h_sess; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -888,7 +887,7 @@ static void *sec_uadk_cipher_sync(void *arg) u8 *priv_iv, *priv_key; handle_t h_sess; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -950,7 +949,7 @@ static void *sec_uadk_aead_sync(void *arg) handle_t h_sess; u32 auth_size = 16; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -1040,7 +1039,7 @@ static void *sec_uadk_digest_sync(void *arg) u8 *priv_iv, *priv_key; handle_t h_sess; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c index 5dd1501..739c49e 100644 --- a/uadk_tool/benchmark/sec_wd_benchmark.c +++ b/uadk_tool/benchmark/sec_wd_benchmark.c @@ -62,7 +62,6 @@ static void *aead_async_cb(void *message, void *cipher_tag)
static void *digest_async_cb(void *message, void *digest_tag) { - // struct WCRYPTO_req *req = (struct WCRYPTO_req *)data; return NULL; }
@@ -598,7 +597,7 @@ static void *sec_wd_cipher_async(void *arg) void **res_iv; u32 count = 0; int try_cnt = 0; - int ret, i = 0; + int ret, i; void *pool;
if (pdata->td_id > g_thread_num) @@ -632,7 +631,7 @@ static void *sec_wd_cipher_async(void *arg) ctx = wcrypto_create_cipher_ctx(queue, &cipher_setup); if (!ctx) { SEC_TST_PRT("wd create cipher ctx fail!\n"); - return NULL; + goto tag_err; } tag->ctx = ctx;
@@ -640,7 +639,7 @@ static void *sec_wd_cipher_async(void *arg) if (ret) { SEC_TST_PRT("wd cipher set key fail!\n"); wcrypto_del_cipher_ctx(ctx); - return NULL; + goto tag_err; }
if (queue->capa.priv.direction == 0) @@ -692,6 +691,9 @@ static void *sec_wd_cipher_async(void *arg)
wcrypto_del_cipher_ctx(ctx);
+tag_err: + free(tag); + return NULL; }
@@ -712,7 +714,7 @@ static void *sec_wd_aead_async(void *arg) u32 count = 0; int try_cnt = 0; u32 authsize; - int ret, i = 0; + int ret, i; void *pool;
if (pdata->td_id > g_thread_num) @@ -759,7 +761,7 @@ static void *sec_wd_aead_async(void *arg) if (ret) { SEC_TST_PRT("wd aead set key fail!\n"); wcrypto_del_aead_ctx(ctx); - return NULL; + goto tag_err; }
if (pdata->is_union) { @@ -767,7 +769,7 @@ static void *sec_wd_aead_async(void *arg) if (ret) { SEC_TST_PRT("set akey fail!\n"); wcrypto_del_aead_ctx(ctx); - return NULL; + goto tag_err; } }
@@ -776,7 +778,7 @@ static void *sec_wd_aead_async(void *arg) if (ret) { SEC_TST_PRT("set authsize fail!\n"); wcrypto_del_aead_ctx(ctx); - return NULL; + goto tag_err; }
if (queue->capa.priv.direction == 0) { @@ -833,6 +835,9 @@ static void *sec_wd_aead_async(void *arg)
wcrypto_del_aead_ctx(ctx);
+tag_err: + free(tag); + return NULL; }
@@ -850,7 +855,7 @@ static void *sec_wd_digest_async(void *arg) void **res_out; u32 count = 0; int try_cnt = 0; - int ret, i = 0; + int ret, i; void *pool;
if (pdata->td_id > g_thread_num) @@ -883,7 +888,7 @@ static void *sec_wd_digest_async(void *arg) ctx = wcrypto_create_digest_ctx(queue, &digest_setup); if (!ctx) { SEC_TST_PRT("wd create digest ctx fail!\n"); - return NULL; + goto tag_err; } tag->ctx = ctx;
@@ -893,7 +898,7 @@ static void *sec_wd_digest_async(void *arg) if (ret) { SEC_TST_PRT("wd digest set key fail!\n"); wcrypto_del_digest_ctx(ctx); - return NULL; + goto tag_err; } }
@@ -939,6 +944,9 @@ static void *sec_wd_digest_async(void *arg)
wcrypto_del_digest_ctx(ctx);
+tag_err: + free(tag); + return NULL; }
@@ -957,7 +965,7 @@ static void *sec_wd_cipher_sync(void *arg) void **res_iv; u32 count = 0; int try_cnt = 0; - int ret, i = 0; + int ret, i; void *pool;
if (pdata->td_id > g_thread_num) @@ -1055,7 +1063,7 @@ static void *sec_wd_aead_sync(void *arg) u32 count = 0; int try_cnt = 0; u32 authsize; - int ret, i = 0; + int ret, i; void *pool;
if (pdata->td_id > g_thread_num) @@ -1177,7 +1185,7 @@ static void *sec_wd_digest_sync(void *arg) void **res_out; u32 count = 0; int try_cnt = 0; - int ret, i = 0; + int ret, i; void *pool;
if (pdata->td_id > g_thread_num) diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c index 2791f84..f36cc4b 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -281,20 +281,20 @@ void get_rand_data(u8 *addr, u32 size) { unsigned short rand_state[3] = { (0xae >> 16) & 0xffff, 0xae & 0xffff, 0x330e}; + static __thread u64 rand_seed = 0x330eabcd; + u64 rand48 = 0; int i;
-#if 1 // only 32bit valid, other 32bit is zero - for (i = 0; i < size >> 3; i++) - *((u64 *)addr + i) = nrand48(rand_state); -#else - // full 64bit valid - for (i = 0; i < size >> 2; i++) - *((u32 *)addr + i) = nrand48(rand_state); -#endif + for (i = 0; i < size >> 3; i++) { + rand_state[0] = (u16)rand_seed; + rand_state[1] = (u16)(rand_seed >> 16); + rand48 = nrand48(rand_state); + *((u64 *)addr + i) = rand48; + rand_seed = rand48; + } }
- void cal_avg_latency(u32 count) { double latency; @@ -307,7 +307,6 @@ void cal_avg_latency(u32 count) }
/*-------------------------------------main code------------------------------------------------------*/ - static void parse_alg_param(struct acc_option *option) { switch(option->algtype) { diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c index ffffa9b..d74d3fb 100644 --- a/uadk_tool/benchmark/zip_uadk_benchmark.c +++ b/uadk_tool/benchmark/zip_uadk_benchmark.c @@ -535,7 +535,7 @@ static void *zip_uadk_blk_lz77_sync_run(void *arg) u32 first_len = 0; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -628,7 +628,7 @@ static void *zip_uadk_stm_lz77_sync_run(void *arg) u32 first_len = 0; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -722,7 +722,7 @@ static void *zip_uadk_blk_lz77_async_run(void *arg) u32 out_len = 0; u32 count = 0; u32 try_cnt = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -826,7 +826,7 @@ static void *zip_uadk_blk_sync_run(void *arg) handle_t h_sess; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -885,7 +885,7 @@ static void *zip_uadk_stm_sync_run(void *arg) handle_t h_sess; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -950,7 +950,7 @@ static void *zip_uadk_blk_async_run(void *arg) int try_cnt = 0; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c index 8d013c5..cbbbb5d 100644 --- a/uadk_tool/benchmark/zip_wd_benchmark.c +++ b/uadk_tool/benchmark/zip_wd_benchmark.c @@ -509,7 +509,7 @@ static void *zip_wd_blk_lz77_sync_run(void *arg) u32 first_len = 0; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -617,7 +617,7 @@ static void *zip_wd_stm_lz77_sync_run(void *arg) u32 first_len = 0; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -726,7 +726,7 @@ static void *zip_wd_blk_lz77_async_run(void *arg) u32 out_len = 0; u32 count = 0; u32 try_cnt = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -847,7 +847,7 @@ static void *zip_wd_blk_sync_run(void *arg) struct wd_bd *bd_pool; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -920,7 +920,7 @@ static void *zip_wd_stm_sync_run(void *arg) struct wd_bd *bd_pool; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL; @@ -999,7 +999,7 @@ static void *zip_wd_blk_async_run(void *arg) int try_cnt = 0; u32 out_len = 0; u32 count = 0; - int ret, i = 0; + int ret, i;
if (pdata->td_id > g_thread_num) return NULL;