From: Longfang Liu liulongfang@huawei.com
Update the performance test code of sec's sva mode, and optimize the performance test code of sec's sva mode by splitting sub-functions.
Signed-off-by: Longfang Liu liulongfang@huawei.com Signed-off-by: Zhiqi Song songzhiqi1@huawei.com --- uadk_tool/benchmark/sec_uadk_benchmark.c | 677 ++++++++++++++--------- 1 file changed, 411 insertions(+), 266 deletions(-)
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c index 09cd8f4..11cf8a1 100644 --- a/uadk_tool/benchmark/sec_uadk_benchmark.c +++ b/uadk_tool/benchmark/sec_uadk_benchmark.c @@ -24,9 +24,10 @@ struct bd_pool {
struct thread_pool { struct bd_pool *pool; - u8 *iv; - u8 *key; - u8 *mac; + u8 **iv; + u8 **key; + u8 **mac; + u8 **hash; } g_uadk_pool;
typedef struct uadk_thread_res { @@ -37,6 +38,9 @@ typedef struct uadk_thread_res { u32 ivsize; u32 optype; u32 td_id; + bool is_union; + u32 dalg; + u32 dmode; } thread_data;
static struct wd_ctx_config g_ctx_cfg; @@ -601,20 +605,15 @@ recv_error: return NULL; }
-static void *sec_uadk_async_run(void *arg) +static void *sec_uadk_cipher_async(void *arg) { thread_data *pdata = (thread_data *)arg; struct wd_cipher_sess_setup cipher_setup = {0}; - struct wd_aead_sess_setup aead_setup = {0}; - struct wd_digest_sess_setup digest_setup = {0}; struct wd_cipher_req creq; - struct wd_aead_req areq; - struct wd_digest_req dreq; struct bd_pool *uadk_pool; - u8 *priv_iv, *priv_key, *priv_mac; + u8 *priv_iv, *priv_key; int try_cnt = 0; handle_t h_sess; - u32 auth_size = 16; u32 count = 0; int ret, i = 0;
@@ -622,313 +621,431 @@ static void *sec_uadk_async_run(void *arg) return NULL;
uadk_pool = &g_uadk_pool.pool[pdata->td_id]; - priv_iv = &g_uadk_pool.iv[pdata->td_id]; - priv_key = &g_uadk_pool.key[pdata->td_id]; - priv_mac = &g_uadk_pool.mac[pdata->td_id]; + priv_iv = g_uadk_pool.iv[pdata->td_id]; + priv_key = g_uadk_pool.key[pdata->td_id];
memset(priv_iv, DEF_IVK_DATA, MAX_IVK_LENTH); memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH);
- switch(pdata->subtype) { - case CIPHER_TYPE: - cipher_setup.alg = pdata->alg; - cipher_setup.mode = pdata->mode; - h_sess = wd_cipher_alloc_sess(&cipher_setup); - if (!h_sess) - return NULL; - ret = wd_cipher_set_key(h_sess, (const __u8*)priv_key, pdata->keysize); - if (ret) { - SEC_TST_PRT("test sec cipher set key is failed!\n"); - wd_cipher_free_sess(h_sess); - return NULL; - } + cipher_setup.alg = pdata->alg; + cipher_setup.mode = pdata->mode; + h_sess = wd_cipher_alloc_sess(&cipher_setup); + if (!h_sess) + return NULL; + ret = wd_cipher_set_key(h_sess, (const __u8*)priv_key, pdata->keysize); + if (ret) { + SEC_TST_PRT("test sec cipher set key is failed!\n"); + wd_cipher_free_sess(h_sess); + return NULL; + }
- creq.op_type = pdata->optype; - creq.iv = priv_iv; - creq.iv_bytes = pdata->ivsize; - creq.in_bytes = g_pktlen; - creq.out_bytes = g_pktlen; - creq.out_buf_bytes = g_pktlen; - creq.data_fmt = 0; - creq.state = 0; - creq.cb = cipher_async_cb; - - while(1) { - if (get_run_state() == 0) - break; - try_cnt = 0; - i = count % MAX_POOL_LENTH; - creq.src = uadk_pool->bds[i].src; - creq.dst = uadk_pool->bds[i].dst; - - ret = wd_do_cipher_async(h_sess, &creq); - if (ret < 0) { - usleep(SEND_USLEEP * try_cnt); - try_cnt++; - if (try_cnt > MAX_TRY_CNT) { - SEC_TST_PRT("Test cipher send fail %d times!\n", MAX_TRY_CNT); - try_cnt = 0; - } - continue; + creq.op_type = pdata->optype; + creq.iv = priv_iv; + creq.iv_bytes = pdata->ivsize; + creq.in_bytes = g_pktlen; + creq.out_bytes = g_pktlen; + creq.out_buf_bytes = g_pktlen; + creq.data_fmt = 0; + creq.state = 0; + creq.cb = cipher_async_cb; + + while(1) { + if (get_run_state() == 0) + break; + try_cnt = 0; + i = count % MAX_POOL_LENTH; + creq.src = uadk_pool->bds[i].src; + creq.dst = uadk_pool->bds[i].dst; + + ret = wd_do_cipher_async(h_sess, &creq); + if (ret < 0) { + usleep(SEND_USLEEP * try_cnt); + try_cnt++; + if (try_cnt > MAX_TRY_CNT) { + SEC_TST_PRT("Test cipher send fail %d times!\n", MAX_TRY_CNT); + try_cnt = 0; } - count++; + continue; } - wd_cipher_free_sess(h_sess); - break; - case AEAD_TYPE: // just ccm and gcm - aead_setup.calg = pdata->alg; - aead_setup.cmode = pdata->mode; - h_sess = wd_aead_alloc_sess(&aead_setup); - if (!h_sess) - return NULL; - ret = wd_aead_set_ckey(h_sess, (const __u8*)priv_key, pdata->keysize); - if (ret) { - SEC_TST_PRT("test sec cipher set key is failed!\n"); - wd_aead_free_sess(h_sess); - return NULL; - } - ret = wd_aead_set_authsize(h_sess, auth_size); + count++; + } + wd_cipher_free_sess(h_sess); + + add_send_complete(); + + return NULL; +} + +static void *sec_uadk_aead_async(void *arg) +{ + thread_data *pdata = (thread_data *)arg; + struct wd_aead_sess_setup aead_setup = {0}; + u8 *priv_iv, *priv_key, *priv_mac, *priv_hash; + struct wd_aead_req areq; + struct bd_pool *uadk_pool; + int try_cnt = 0; + handle_t h_sess; + u32 auth_size = 16; + u32 count = 0; + int ret, i; + + if (pdata->td_id > g_thread_num) + return NULL; + + uadk_pool = &g_uadk_pool.pool[pdata->td_id]; + priv_iv = g_uadk_pool.iv[pdata->td_id]; + priv_key = g_uadk_pool.key[pdata->td_id]; + priv_hash = g_uadk_pool.hash[pdata->td_id]; + priv_mac = g_uadk_pool.mac[pdata->td_id]; + + memset(priv_iv, DEF_IVK_DATA, MAX_IVK_LENTH); + memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH); + + aead_setup.calg = pdata->alg; + aead_setup.cmode = pdata->mode; + if (pdata->is_union) { + aead_setup.dalg = pdata->dalg; + aead_setup.dmode = pdata->dmode; + } + h_sess = wd_aead_alloc_sess(&aead_setup); + if (!h_sess) + return NULL; + ret = wd_aead_set_ckey(h_sess, (const __u8*)priv_key, pdata->keysize); + if (ret) { + SEC_TST_PRT("test sec cipher set key is failed!\n"); + wd_aead_free_sess(h_sess); + return NULL; + } + if (pdata->is_union) { + ret = wd_aead_set_akey(h_sess, (const __u8*)priv_hash, 16); if (ret) { - SEC_TST_PRT("set auth size fail, authsize: 16\n"); + SEC_TST_PRT("test sec aead set akey is failed!\n"); wd_aead_free_sess(h_sess); return NULL; } + } + ret = wd_aead_set_authsize(h_sess, auth_size); + if (ret) { + SEC_TST_PRT("set auth size fail, authsize: 16\n"); + wd_aead_free_sess(h_sess); + return NULL; + } + + areq.op_type = pdata->optype; + areq.iv = priv_iv; // aead IV need update with param + areq.mac = priv_mac; + areq.iv_bytes = pdata->ivsize; + areq.mac_bytes = auth_size; + areq.assoc_bytes = 16; + areq.in_bytes = g_pktlen; + if (pdata->is_union) + areq.mac_bytes = 32; + if (areq.op_type) // decrypto + areq.out_bytes = g_pktlen + 16; // aadsize = 16; + else + areq.out_bytes = g_pktlen + 32; // aadsize + authsize = 32;
- areq.op_type = pdata->optype; - areq.iv = priv_iv; // aead IV need update with param - areq.mac = priv_mac; - areq.iv_bytes = pdata->ivsize; - areq.mac_bytes = auth_size; - areq.assoc_bytes = 16; - areq.in_bytes = g_pktlen; - if (areq.op_type)// decrypto - areq.out_bytes = g_pktlen + 16; // aadsize = 16; - else - areq.out_bytes = g_pktlen + 32; // aadsize + authsize = 32; - - areq.data_fmt = 0; - areq.state = 0; - areq.cb = aead_async_cb; - - while(1) { - if (get_run_state() == 0) - break; - try_cnt = 0; - i = count % MAX_POOL_LENTH; - areq.src = uadk_pool->bds[i].src; - areq.dst = uadk_pool->bds[i].dst; - - ret = wd_do_aead_async(h_sess, &areq); - if (ret < 0) { - usleep(SEND_USLEEP * try_cnt); - try_cnt++; - if (try_cnt > MAX_TRY_CNT) { - SEC_TST_PRT("Test aead send fail %d times!\n", MAX_TRY_CNT); - try_cnt = 0; - } - continue; + areq.data_fmt = 0; + areq.state = 0; + areq.cb = aead_async_cb; + + while(1) { + if (get_run_state() == 0) + break; + try_cnt = 0; + i = count % MAX_POOL_LENTH; + areq.src = uadk_pool->bds[i].src; + areq.dst = uadk_pool->bds[i].dst; + + ret = wd_do_aead_async(h_sess, &areq); + if (ret < 0) { + usleep(SEND_USLEEP * try_cnt); + try_cnt++; + if (try_cnt > MAX_TRY_CNT) { + SEC_TST_PRT("Test aead send fail %d times!\n", MAX_TRY_CNT); + try_cnt = 0; } - count++; + continue; } - wd_aead_free_sess(h_sess); - break; - case DIGEST_TYPE: - digest_setup.alg = pdata->alg; - digest_setup.mode = pdata->mode; // digest mode is optype - h_sess = wd_digest_alloc_sess(&digest_setup); - if (!h_sess) + count++; + } + wd_aead_free_sess(h_sess); + + add_send_complete(); + + return NULL; +} + +static void *sec_uadk_digest_async(void *arg) +{ + thread_data *pdata = (thread_data *)arg; + struct wd_digest_sess_setup digest_setup = {0}; + struct wd_digest_req dreq; + struct bd_pool *uadk_pool; + u8 *priv_iv, *priv_key; + int try_cnt = 0; + handle_t h_sess; + u32 count = 0; + int ret, i = 0; + + if (pdata->td_id > g_thread_num) + return NULL; + + uadk_pool = &g_uadk_pool.pool[pdata->td_id]; + priv_iv = g_uadk_pool.iv[pdata->td_id]; + priv_key = g_uadk_pool.key[pdata->td_id]; + + memset(priv_iv, DEF_IVK_DATA, MAX_IVK_LENTH); + memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH); + + digest_setup.alg = pdata->alg; + digest_setup.mode = pdata->mode; // digest mode is optype + h_sess = wd_digest_alloc_sess(&digest_setup); + if (!h_sess) + return NULL; + if (digest_setup.mode == WD_DIGEST_HMAC) { + ret = wd_digest_set_key(h_sess, (const __u8*)priv_key, 4); + if (ret) { + SEC_TST_PRT("test sec_digest set key is failed!\n"); + wd_digest_free_sess(h_sess); return NULL; - if (digest_setup.mode == WD_DIGEST_HMAC) { - ret = wd_digest_set_key(h_sess, (const __u8*)priv_key, 4); - if (ret) { - SEC_TST_PRT("test sec digest set key is failed!\n"); - wd_digest_free_sess(h_sess); - return NULL; - } } - dreq.in_bytes = g_pktlen; - dreq.out_bytes = 16; - dreq.out_buf_bytes = 16; - dreq.data_fmt = 0; - dreq.state = 0; - dreq.has_next = 0; - dreq.cb = digest_async_cb; - - while(1) { - if (get_run_state() == 0) - break; - try_cnt = 0; - i = count % MAX_POOL_LENTH; - dreq.in = uadk_pool->bds[i].src; - dreq.out = uadk_pool->bds[i].dst; - - ret = wd_do_digest_async(h_sess, &dreq); - if (ret < 0) { - usleep(SEND_USLEEP * try_cnt); - try_cnt++; - if (try_cnt > MAX_TRY_CNT) { - SEC_TST_PRT("Test digest send fail %d times!\n", MAX_TRY_CNT); - try_cnt = 0; - } - continue; + } + dreq.in_bytes = g_pktlen; + dreq.out_bytes = 16; + dreq.out_buf_bytes = 16; + dreq.data_fmt = 0; + dreq.state = 0; + dreq.has_next = 0; + dreq.cb = digest_async_cb; + + while(1) { + if (get_run_state() == 0) + break; + try_cnt = 0; + i = count % MAX_POOL_LENTH; + dreq.in = uadk_pool->bds[i].src; + dreq.out = uadk_pool->bds[i].dst; + + ret = wd_do_digest_async(h_sess, &dreq); + if (ret < 0) { + usleep(SEND_USLEEP * try_cnt); + try_cnt++; + if (try_cnt > MAX_TRY_CNT) { + SEC_TST_PRT("Test digest send fail %d times!\n", MAX_TRY_CNT); + try_cnt = 0; } - count++; + continue; } - wd_digest_free_sess(h_sess); - break; + count++; } + wd_digest_free_sess(h_sess);
add_send_complete();
return NULL; }
-static void *sec_uadk_sync_run(void *arg) +static void *sec_uadk_cipher_sync(void *arg) { thread_data *pdata = (thread_data *)arg; struct wd_cipher_sess_setup cipher_setup = {0}; - struct wd_aead_sess_setup aead_setup = {0}; - struct wd_digest_sess_setup digest_setup = {0}; struct wd_cipher_req creq; + struct bd_pool *uadk_pool; + u8 *priv_iv, *priv_key; + handle_t h_sess; + u32 count = 0; + int ret, i = 0; + + if (pdata->td_id > g_thread_num) + return NULL; + + uadk_pool = &g_uadk_pool.pool[pdata->td_id]; + priv_iv = g_uadk_pool.iv[pdata->td_id]; + priv_key = g_uadk_pool.key[pdata->td_id]; + + memset(priv_iv, DEF_IVK_DATA, MAX_IVK_LENTH); + memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH); + + cipher_setup.alg = pdata->alg; + cipher_setup.mode = pdata->mode; + h_sess = wd_cipher_alloc_sess(&cipher_setup); + if (!h_sess) + return NULL; + ret = wd_cipher_set_key(h_sess, (const __u8*)priv_key, pdata->keysize); + if (ret) { + SEC_TST_PRT("test sec cipher set key is failed!\n"); + wd_cipher_free_sess(h_sess); + return NULL; + } + + creq.op_type = pdata->optype; + creq.iv = priv_iv; + creq.iv_bytes = pdata->ivsize; + creq.in_bytes = g_pktlen; + creq.out_bytes = g_pktlen; + creq.out_buf_bytes = g_pktlen; + creq.data_fmt = 0; + creq.state = 0; + + while(1) { + i = count % MAX_POOL_LENTH; + creq.src = uadk_pool->bds[i].src; + creq.dst = uadk_pool->bds[i].dst; + ret = wd_do_cipher_sync(h_sess, &creq); + if ((ret < 0 && ret != -WD_EBUSY) || creq.state) + break; + count++; + if (get_run_state() == 0) + break; + } + wd_cipher_free_sess(h_sess); + + add_recv_data(count, g_pktlen); + + return NULL; +} + +static void *sec_uadk_aead_sync(void *arg) +{ + thread_data *pdata = (thread_data *)arg; + struct wd_aead_sess_setup aead_setup = {0}; + u8 *priv_iv, *priv_key, *priv_hash, *priv_mac; struct wd_aead_req areq; - struct wd_digest_req dreq; struct bd_pool *uadk_pool; - u8 *priv_iv, *priv_key, *priv_mac; 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;
uadk_pool = &g_uadk_pool.pool[pdata->td_id]; - priv_iv = &g_uadk_pool.iv[pdata->td_id]; - priv_key = &g_uadk_pool.key[pdata->td_id]; - priv_mac = &g_uadk_pool.mac[pdata->td_id]; + + priv_iv = g_uadk_pool.iv[pdata->td_id]; + priv_key = g_uadk_pool.key[pdata->td_id]; + priv_hash = g_uadk_pool.hash[pdata->td_id]; + priv_mac = g_uadk_pool.mac[pdata->td_id];
memset(priv_iv, DEF_IVK_DATA, MAX_IVK_LENTH); memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH);
- switch(pdata->subtype) { - case CIPHER_TYPE: - cipher_setup.alg = pdata->alg; - cipher_setup.mode = pdata->mode; - h_sess = wd_cipher_alloc_sess(&cipher_setup); - if (!h_sess) - return NULL; - ret = wd_cipher_set_key(h_sess, (const __u8*)priv_key, pdata->keysize); - if (ret) { - SEC_TST_PRT("test sec cipher set key is failed!\n"); - wd_cipher_free_sess(h_sess); - return NULL; - } + aead_setup.calg = pdata->alg; + aead_setup.cmode = pdata->mode; + h_sess = wd_aead_alloc_sess(&aead_setup); + if (!h_sess) + return NULL; + ret = wd_aead_set_ckey(h_sess, (const __u8*)priv_key, pdata->keysize); + if (ret) { + SEC_TST_PRT("test sec cipher set key is failed!\n"); + wd_aead_free_sess(h_sess); + return NULL; + }
- creq.op_type = pdata->optype; - creq.iv = priv_iv; - creq.iv_bytes = pdata->ivsize; - creq.in_bytes = g_pktlen; - creq.out_bytes = g_pktlen; - creq.out_buf_bytes = g_pktlen; - creq.data_fmt = 0; - creq.state = 0; - - while(1) { - i = count % MAX_POOL_LENTH; - creq.src = uadk_pool->bds[i].src; - creq.dst = uadk_pool->bds[i].dst; - ret = wd_do_cipher_sync(h_sess, &creq); - if ((ret < 0 && ret != -WD_EBUSY) || creq.state) - break; - count++; - if (get_run_state() == 0) - break; - } - wd_cipher_free_sess(h_sess); - break; - case AEAD_TYPE: // just ccm and gcm - aead_setup.calg = pdata->alg; - aead_setup.cmode = pdata->mode; - h_sess = wd_aead_alloc_sess(&aead_setup); - if (!h_sess) - return NULL; - ret = wd_aead_set_ckey(h_sess, (const __u8*)priv_key, pdata->keysize); + if (pdata->is_union) { + ret = wd_aead_set_akey(h_sess, (const __u8*)priv_hash, 16); if (ret) { - SEC_TST_PRT("test sec cipher set key is failed!\n"); - wd_aead_free_sess(h_sess); - return NULL; - } - ret = wd_aead_set_authsize(h_sess, auth_size); - if (ret) { - SEC_TST_PRT("set auth size fail, authsize: 16\n"); + SEC_TST_PRT("test sec aead set akey is failed!\n"); wd_aead_free_sess(h_sess); return NULL; } + }
- areq.op_type = pdata->optype; - areq.iv = priv_iv; // aead IV need update with param - areq.mac = priv_mac; - areq.mac_bytes = 16; - areq.iv_bytes = pdata->ivsize; - areq.assoc_bytes = 16; - areq.in_bytes = g_pktlen; - areq.mac_bytes = auth_size; - if (areq.op_type)// decrypto - areq.out_bytes = g_pktlen + 16; // aadsize = 16; - else - areq.out_bytes = g_pktlen + 32; // aadsize + authsize = 32; - - areq.data_fmt = 0; - areq.state = 0; - - while(1) { - i = count % MAX_POOL_LENTH; - areq.src = uadk_pool->bds[i].src; - areq.dst = uadk_pool->bds[i].dst; - count++; - ret = wd_do_aead_sync(h_sess, &areq); - if (ret || areq.state) - break; - if (get_run_state() == 0) - break; - } + ret = wd_aead_set_authsize(h_sess, auth_size); + if (ret) { + SEC_TST_PRT("set auth size fail, authsize: 16\n"); wd_aead_free_sess(h_sess); - break; - case DIGEST_TYPE: - digest_setup.alg = pdata->alg; - digest_setup.mode = pdata->mode; // digest mode is optype - h_sess = wd_digest_alloc_sess(&digest_setup); - if (!h_sess) + return NULL; + } + + areq.op_type = pdata->optype; + areq.iv = priv_iv; // aead IV need update with param + areq.mac = priv_mac; + areq.mac_bytes = 16; + areq.iv_bytes = pdata->ivsize; + areq.assoc_bytes = 16; + areq.in_bytes = g_pktlen; + areq.mac_bytes = auth_size; + if (areq.op_type)// decrypto + areq.out_bytes = g_pktlen + 16; // aadsize = 16; + else + areq.out_bytes = g_pktlen + 32; // aadsize + authsize = 32; + + areq.data_fmt = 0; + areq.state = 0; + + while(1) { + i = count % MAX_POOL_LENTH; + areq.src = uadk_pool->bds[i].src; + areq.dst = uadk_pool->bds[i].dst; + count++; + ret = wd_do_aead_sync(h_sess, &areq); + if (ret || areq.state) + break; + if (get_run_state() == 0) + break; + } + wd_aead_free_sess(h_sess); + + add_recv_data(count, g_pktlen); + + return NULL; +} + +static void *sec_uadk_digest_sync(void *arg) +{ + thread_data *pdata = (thread_data *)arg; + struct wd_digest_sess_setup digest_setup = {0}; + struct wd_digest_req dreq; + struct bd_pool *uadk_pool; + u8 *priv_iv, *priv_key; + handle_t h_sess; + u32 count = 0; + int ret, i = 0; + + if (pdata->td_id > g_thread_num) + return NULL; + + uadk_pool = &g_uadk_pool.pool[pdata->td_id]; + priv_iv = g_uadk_pool.iv[pdata->td_id]; + priv_key = g_uadk_pool.key[pdata->td_id]; + + memset(priv_iv, DEF_IVK_DATA, MAX_IVK_LENTH); + memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH); + + digest_setup.alg = pdata->alg; + digest_setup.mode = pdata->mode; // digest mode is optype + h_sess = wd_digest_alloc_sess(&digest_setup); + if (!h_sess) + return NULL; + if (digest_setup.mode == WD_DIGEST_HMAC) { + ret = wd_digest_set_key(h_sess, (const __u8*)priv_key, 4); + if (ret) { + SEC_TST_PRT("test sec digest set key is failed!\n"); + wd_digest_free_sess(h_sess); return NULL; - if (digest_setup.mode == WD_DIGEST_HMAC) { - ret = wd_digest_set_key(h_sess, (const __u8*)priv_key, 4); - if (ret) { - SEC_TST_PRT("test sec digest set key is failed!\n"); - wd_digest_free_sess(h_sess); - return NULL; - } - } - dreq.in_bytes = g_pktlen; - dreq.out_bytes = 16; - dreq.out_buf_bytes = 16; - dreq.data_fmt = 0; - dreq.state = 0; - dreq.has_next = 0; - - while(1) { - i = count % MAX_POOL_LENTH; - dreq.in = uadk_pool->bds[i].src; - dreq.out = uadk_pool->bds[i].dst; - ret = wd_do_digest_sync(h_sess, &dreq); - if (ret || dreq.state) - break; - count++; - if (get_run_state() == 0) - break; } - wd_digest_free_sess(h_sess); - break; } + dreq.in_bytes = g_pktlen; + dreq.out_bytes = 16; + dreq.out_buf_bytes = 16; + dreq.data_fmt = 0; + dreq.state = 0; + dreq.has_next = 0; + + while(1) { + i = count % MAX_POOL_LENTH; + dreq.in = uadk_pool->bds[i].src; + dreq.out = uadk_pool->bds[i].dst; + ret = wd_do_digest_sync(h_sess, &dreq); + if (ret || dreq.state) + break; + count++; + if (get_run_state() == 0) + break; + } + wd_digest_free_sess(h_sess);
add_recv_data(count, g_pktlen);
@@ -937,6 +1054,8 @@ static void *sec_uadk_sync_run(void *arg)
int sec_uadk_sync_threads(struct acc_option *options) { + typedef void *(*sec_sync_run)(void *arg); + sec_sync_run uadk_sec_sync_run = NULL; thread_data threads_args[THREADS_NUM]; thread_data threads_option; pthread_t tdid[THREADS_NUM]; @@ -947,6 +1066,18 @@ int sec_uadk_sync_threads(struct acc_option *options) if (ret) return ret;
+ switch (options->subtype) { + case CIPHER_TYPE: + uadk_sec_sync_run = sec_uadk_cipher_sync; + break; + case AEAD_TYPE: + uadk_sec_sync_run = sec_uadk_aead_sync; + break; + case DIGEST_TYPE: + uadk_sec_sync_run = sec_uadk_digest_sync; + break; + } + for (i = 0; i < g_thread_num; i++) { threads_args[i].subtype = threads_option.subtype; threads_args[i].alg = threads_option.alg; @@ -955,7 +1086,7 @@ int sec_uadk_sync_threads(struct acc_option *options) threads_args[i].ivsize = threads_option.ivsize; threads_args[i].optype = threads_option.optype; threads_args[i].td_id = i; - ret = pthread_create(&tdid[i], NULL, sec_uadk_sync_run, &threads_args[i]); + ret = pthread_create(&tdid[i], NULL, uadk_sec_sync_run, &threads_args[i]); if (ret) { SEC_TST_PRT("Create sync thread fail!\n"); goto sync_error; @@ -977,6 +1108,8 @@ sync_error:
int sec_uadk_async_threads(struct acc_option *options) { + typedef void *(*sec_async_run)(void *arg); + sec_async_run uadk_sec_async_run = NULL; thread_data threads_args[THREADS_NUM]; thread_data threads_option; pthread_t tdid[THREADS_NUM]; @@ -988,6 +1121,18 @@ int sec_uadk_async_threads(struct acc_option *options) if (ret) return ret;
+ switch (options->subtype) { + case CIPHER_TYPE: + uadk_sec_async_run = sec_uadk_cipher_async; + break; + case AEAD_TYPE: + uadk_sec_async_run = sec_uadk_aead_async; + break; + case DIGEST_TYPE: + uadk_sec_async_run = sec_uadk_digest_async; + break; + } + for (i = 0; i < g_ctxnum; i++) { threads_args[i].subtype = threads_option.subtype; threads_args[i].td_id = i; @@ -1007,7 +1152,7 @@ int sec_uadk_async_threads(struct acc_option *options) threads_args[i].ivsize = threads_option.ivsize; threads_args[i].optype = threads_option.optype; threads_args[i].td_id = i; - ret = pthread_create(&tdid[i], NULL, sec_uadk_async_run, &threads_args[i]); + ret = pthread_create(&tdid[i], NULL, uadk_sec_async_run, &threads_args[i]); if (ret) { SEC_TST_PRT("Create async thread fail!\n"); goto async_error;