diff --git a/uadk_mk.sh b/uadk_mk.sh old mode 100644 new mode 100755 diff --git a/uadk_tool/Makefile.am b/uadk_tool/Makefile.am index 6fa0d9dd..9d644a5e 100644 --- a/uadk_tool/Makefile.am +++ b/uadk_tool/Makefile.am @@ -12,14 +12,14 @@ bin_PROGRAMS=uadk_tool uadk_tool_SOURCES=uadk_tool.c dfx/uadk_dfx.c dfx/uadk_dfx.h \ benchmark/uadk_benchmark.c benchmark/uadk_benchmark.h \ benchmark/sec_uadk_benchmark.c benchmark/sec_uadk_benchmark.h \ - benchmark/sec_wd_benchmark.c benchmark/sec_wd_benchmark.h \ - benchmark/hpre_uadk_benchmark.c benchmark/hpre_uadk_benchmark.h \ - benchmark/hpre_wd_benchmark.c hpre_wd_benchmark.h \ - benchmark/zip_uadk_benchmark.c benchmark/zip_uadk_benchmark.h \ - benchmark/zip_wd_benchmark.c benchmark/zip_wd_benchmark.h \ - benchmark/trng_wd_benchmark.c benchmark/trng_wd_benchmark.h \ - test/uadk_test.c test/uadk_test.h \ - test/test_sec.c test/test_sec.h test/sec_template_tv.h + benchmark/zip_uadk_benchmark.c benchmark/zip_uadk_benchmark.h +# benchmark/sec_wd_benchmark.c benchmark/sec_wd_benchmark.h \ +# benchmark/hpre_uadk_benchmark.c benchmark/hpre_uadk_benchmark.h \ +# benchmark/hpre_wd_benchmark.c hpre_wd_benchmark.h \ +# benchmark/zip_wd_benchmark.c benchmark/zip_wd_benchmark.h +# benchmark/trng_wd_benchmark.c benchmark/trng_wd_benchmark.h +# test/uadk_test.c test/uadk_test.h \ +# test/test_sec.c test/test_sec.h test/sec_template_tv.h if WD_STATIC_DRV AM_CFLAGS+=-Bstatic @@ -27,9 +27,7 @@ uadk_tool_LDADD=$(libwd_la_OBJECTS) \ $(libwd_crypto_la_OBJECTS) \ ../.libs/libwd_comp.a \ ../.libs/libhisi_sec.a \ - ../.libs/libhisi_hpre.a \ ../.libs/libhisi_zip.a \ - ../.libs/libisa_ce.a \ -ldl -lnuma else uadk_tool_LDADD=-L../.libs -l:libwd.so.2 -l:libwd_crypto.so.2 \ diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c index c4e4e278..52f6befe 100644 --- a/uadk_tool/benchmark/sec_uadk_benchmark.c +++ b/uadk_tool/benchmark/sec_uadk_benchmark.c @@ -6,7 +6,7 @@ #include "sec_uadk_benchmark.h" #include "include/wd_cipher.h" #include "include/wd_digest.h" -#include "include/wd_aead.h" +//#include "include/wd_aead.h" #include "include/wd_sched.h" #define SEC_TST_PRT printf @@ -132,10 +132,6 @@ static void *cipher_async_cb(struct wd_cipher_req *req, void *data) return NULL; } -static void *aead_async_cb(struct wd_aead_req *req, void *data) -{ - return NULL; -} static void *digest_async_cb(void *data) { @@ -150,8 +146,6 @@ 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; - u8 dalg; u8 mode; u8 alg; @@ -396,81 +390,6 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options) mode = WD_CIPHER_XTS_GB; alg = WD_CIPHER_SM4; break; - case AES_128_CCM: - keysize = 16; - ivsize = 16; - mode = WD_CIPHER_CCM; - alg = WD_CIPHER_AES; - break; - case AES_192_CCM: - keysize = 24; - ivsize = 16; - mode = WD_CIPHER_CCM; - alg = WD_CIPHER_AES; - break; - case AES_256_CCM: - keysize = 32; - ivsize = 16; - mode = WD_CIPHER_CCM; - alg = WD_CIPHER_AES; - break; - case AES_128_GCM: - keysize = 16; - ivsize = 12; - mode = WD_CIPHER_GCM; - alg = WD_CIPHER_AES; - break; - case AES_192_GCM: - keysize = 24; - ivsize = 12; - mode = WD_CIPHER_GCM; - alg = WD_CIPHER_AES; - break; - case AES_256_GCM: - keysize = 32; - ivsize = 12; - mode = WD_CIPHER_GCM; - alg = WD_CIPHER_AES; - break; - case AES_128_CBC_SHA256_HMAC: - keysize = 16; - ivsize = 16; - mode = WD_CIPHER_CBC; - alg = WD_CIPHER_AES; - is_union = true; - dalg = WD_DIGEST_SHA256; - dmode = WD_DIGEST_HMAC; - break; - case AES_192_CBC_SHA256_HMAC: - keysize = 24; - ivsize = 16; - mode = WD_CIPHER_CBC; - alg = WD_CIPHER_AES; - is_union = true; - dalg = WD_DIGEST_SHA256; - dmode = WD_DIGEST_HMAC; - break; - case AES_256_CBC_SHA256_HMAC: - keysize = 32; - ivsize = 16; - mode = WD_CIPHER_CBC; - alg = WD_CIPHER_AES; - is_union = true; - dalg = WD_DIGEST_SHA256; - dmode = WD_DIGEST_HMAC; - break; - case SM4_128_CCM: - keysize = 16; - ivsize = 16; - mode = WD_CIPHER_CCM; - alg = WD_CIPHER_SM4; - break; - case SM4_128_GCM: - keysize = 16; - ivsize = 12; - mode = WD_CIPHER_GCM; - alg = WD_CIPHER_SM4; - break; case SM3_ALG: // digest mode is optype keysize = 4; mode = optype; @@ -532,8 +451,6 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options) tddata->alg = alg; tddata->mode = mode; - tddata->dalg = dalg; - tddata->dmode = dmode; tddata->ivsize = ivsize; tddata->keysize = keysize; tddata->is_union = is_union; @@ -688,9 +605,6 @@ static int init_ctx_config(struct acc_option *options) case CIPHER_TYPE: g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, max_node, wd_cipher_poll_ctx); break; - case AEAD_TYPE: - g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, max_node, wd_aead_poll_ctx); - break; case DIGEST_TYPE: g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, max_node, wd_digest_poll_ctx); break; @@ -720,9 +634,6 @@ static int init_ctx_config(struct acc_option *options) case CIPHER_TYPE: ret = wd_cipher_init(&g_ctx_cfg, g_sched); break; - case AEAD_TYPE: - ret = wd_aead_init(&g_ctx_cfg, g_sched); - break; case DIGEST_TYPE: ret = wd_digest_init(&g_ctx_cfg, g_sched); break; @@ -756,9 +667,6 @@ static void uninit_ctx_config(int subtype) case CIPHER_TYPE: wd_cipher_uninit(); break; - case AEAD_TYPE: - wd_aead_uninit(); - break; case DIGEST_TYPE: wd_digest_uninit(); break; @@ -781,9 +689,6 @@ static void uninit_ctx_config2(int subtype) case CIPHER_INSTR_TYPE: wd_cipher_uninit2(); break; - case AEAD_TYPE: - wd_aead_uninit2(); - break; case DIGEST_TYPE: wd_digest_uninit2(); break; @@ -793,10 +698,15 @@ static void uninit_ctx_config2(int subtype) } } +struct wd_ctx_nums ctx_set_num[2]; +struct wd_cap_config cap; + static int init_ctx_config2(struct acc_option *options) { int subtype = options->subtype; char alg_name[MAX_ALG_NAME]; + struct wd_ctx_params ctx_params = {0}; + struct bitmask bmp; int ret; ret = get_alg_name(options->algtype, alg_name); @@ -805,31 +715,38 @@ static int init_ctx_config2(struct acc_option *options) return -EINVAL; } + numa_bitmask_setbit(&bmp, 0); + cap.ctx_msg_num = 1024; + ctx_set_num[0].sync_ctx_num = options->ctxnums; + ctx_set_num[0].async_ctx_num = options->ctxnums; + ctx_set_num[1].sync_ctx_num = options->ctxnums; + ctx_set_num[1].async_ctx_num = options->ctxnums; + ctx_params.op_type_num = 2; + ctx_params.bmp = &bmp; + ctx_params.cap = ∩ + ctx_params.ctx_set_num = &ctx_set_num[0]; + /* init */ switch(subtype) { case CIPHER_TYPE: - ret = wd_cipher_init2(alg_name, SCHED_POLICY_RR, TASK_HW); + ret = wd_cipher_init2_(alg_name, SCHED_POLICY_LOOP, TASK_MIX, &ctx_params); if (ret) SEC_TST_PRT("failed to do cipher init2!\n"); break; case CIPHER_INSTR_TYPE: - ret = wd_cipher_init2(alg_name, SCHED_POLICY_NONE, TASK_INSTR); + ret = wd_cipher_init2_(alg_name, SCHED_POLICY_NONE, TASK_INSTR, &ctx_params); if (ret) 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); - 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); + ctx_params.op_type_num = 1; + ret = wd_digest_init2_(alg_name, SCHED_POLICY_RTE_LOOP, TASK_MIX, &ctx_params); if (ret) SEC_TST_PRT("failed to do digest init2!\n"); break; } if (ret) { - SEC_TST_PRT("failed to do cipher init2!\n"); + SEC_TST_PRT("failed to do sec init2!\n"); return ret; } @@ -1102,9 +1019,6 @@ static void *sec_uadk_poll(void *data) case CIPHER_TYPE: uadk_poll_ctx = wd_cipher_poll_ctx; break; - case AEAD_TYPE: - uadk_poll_ctx = wd_aead_poll_ctx; - break; case DIGEST_TYPE: uadk_poll_ctx = wd_digest_poll_ctx; break; @@ -1147,9 +1061,6 @@ static void *sec_uadk_poll2(void *data) case CIPHER_TYPE: uadk_poll_policy = wd_cipher_poll; break; - case AEAD_TYPE: - uadk_poll_policy = wd_aead_poll; - break; case DIGEST_TYPE: uadk_poll_policy = wd_digest_poll; break; @@ -1249,107 +1160,6 @@ static void *sec_uadk_cipher_async(void *arg) 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_hash; - u32 auth_size = SEC_PERF_AUTH_SIZE; - struct wd_aead_req areq = {0}; - struct bd_pool *uadk_pool; - int try_cnt = 0; - handle_t h_sess; - 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]; - - 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, HASH_ZISE); - if (ret) { - 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 = uadk_pool->bds[0].mac; - areq.iv_bytes = pdata->ivsize; - areq.mac_bytes = auth_size; - areq.assoc_bytes = SEC_AEAD_LEN; - areq.in_bytes = g_pktlen; - areq.msg_state = 0; - 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.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; - areq.mac = uadk_pool->bds[i].mac; - - 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; - } - 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; @@ -1481,95 +1291,6 @@ static void *sec_uadk_cipher_sync(void *arg) 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; - u32 auth_size = SEC_PERF_AUTH_SIZE; - struct wd_aead_req areq = {0}; - struct bd_pool *uadk_pool; - handle_t h_sess; - 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]; - - 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, HASH_ZISE); - if (ret) { - 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 = uadk_pool->bds[0].mac; - areq.iv_bytes = pdata->ivsize; - areq.assoc_bytes = SEC_AEAD_LEN; - areq.in_bytes = g_pktlen; - areq.mac_bytes = g_maclen; - areq.msg_state = 0; - 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); - - cal_avg_latency(count); - add_recv_data(count, g_pktlen); - - return NULL; -} static void *sec_uadk_digest_sync(void *arg) { @@ -1650,9 +1371,6 @@ int sec_uadk_sync_threads(struct acc_option *options) case CIPHER_INSTR_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; @@ -1711,9 +1429,6 @@ int sec_uadk_async_threads(struct acc_option *options) 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; diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c index fcb28c42..9f7c8df3 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -7,16 +7,16 @@ #include "uadk_benchmark.h" #include "sec_uadk_benchmark.h" -#include "sec_wd_benchmark.h" -#include "sec_soft_benchmark.h" +//#include "sec_wd_benchmark.h" +//#include "sec_soft_benchmark.h" -#include "hpre_uadk_benchmark.h" -#include "hpre_wd_benchmark.h" +//#include "hpre_uadk_benchmark.h" +//#include "hpre_wd_benchmark.h" #include "zip_uadk_benchmark.h" -#include "zip_wd_benchmark.h" +//#include "zip_wd_benchmark.h" -#include "trng_wd_benchmark.h" +//#include "trng_wd_benchmark.h" #define TABLE_SPACE_SIZE 8 @@ -495,13 +495,16 @@ static int benchmark_run(struct acc_option *option) (option->modetype == MULTIBUF_MODE)) { ret = sec_uadk_benchmark(option); usleep(20000); +#if 0 } else if (option->modetype == NOSVA_MODE) { ret = sec_wd_benchmark(option); usleep(20000); } else if (option->modetype == SOFT_MODE) { ret = sec_soft_benchmark(option); +#endif } break; +#if 0 case HPRE_TYPE: if (option->modetype == SVA_MODE) { ret = hpre_uadk_benchmark(option); @@ -509,13 +512,15 @@ static int benchmark_run(struct acc_option *option) ret = hpre_wd_benchmark(option); } break; +#endif case ZIP_TYPE: if (option->modetype == SVA_MODE) { ret = zip_uadk_benchmark(option); - } else if (option->modetype == NOSVA_MODE) { - ret = zip_wd_benchmark(option); +// } else if (option->modetype == NOSVA_MODE) { +// ret = zip_wd_benchmark(option); } break; +#if 0 case TRNG_TYPE: if (option->modetype == SVA_MODE) ACC_TST_PRT("TRNG not support sva mode..\n"); @@ -523,6 +528,7 @@ static int benchmark_run(struct acc_option *option) ret = trng_wd_benchmark(option); break; +#endif } return ret; diff --git a/uadk_tool/uadk_tool.c b/uadk_tool/uadk_tool.c index 63e6d0f4..a3a7b757 100644 --- a/uadk_tool/uadk_tool.c +++ b/uadk_tool/uadk_tool.c @@ -38,7 +38,7 @@ int main(int argc, char **argv) (void)acc_benchmark_run(&option); } else if (!strcmp("test", argv[index])) { printf("start UADK acc algorithm test.\n"); - acc_test_run(argc, argv); + //acc_test_run(argc, argv); } else { print_tool_help(); }