From: Longfang Liu <liulongfang@huawei.com> Completed the update of uadk test tool function to adapt to heterogeneous scheduling function Signed-off-by: Longfang Liu <liulongfang@huawei.com> --- uadk_tool/benchmark/sec_uadk_benchmark.c | 93 ++++++++++++++---------- uadk_tool/benchmark/uadk_benchmark.c | 3 +- uadk_tool/benchmark/uadk_benchmark.h | 1 + 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c index 4a64c94..dbf12cf 100644 --- a/uadk_tool/benchmark/sec_uadk_benchmark.c +++ b/uadk_tool/benchmark/sec_uadk_benchmark.c @@ -845,6 +845,7 @@ static void uninit_ctx_config2(int subtype) wd_aead_uninit2(); break; case DIGEST_TYPE: + case DIGEST_INSTR_TYPE: wd_digest_uninit2(); break; default: @@ -853,13 +854,15 @@ static void uninit_ctx_config2(int subtype) } } +struct wd_ctx_nums ctx_set_num[2]; +struct wd_ctx_nums ce_ctx_set_num[2]; +struct wd_cap_config cap; + 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]; + struct wd_ctx_params ctx_params = {0}; int ret; ret = get_alg_name(options->algtype, alg_name); @@ -868,70 +871,77 @@ 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; + cap.ctx_msg_num = 1024; + // HW ctx set + 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; + // CE ctx set + ce_ctx_set_num[0].sync_ctx_num = options->ctxnums; + ce_ctx_set_num[0].async_ctx_num = options->ctxnums; + ce_ctx_set_num[0].ctx_prop = UADK_CTX_CE_INS; + ce_ctx_set_num[0].other_ctx = NULL; + ce_ctx_set_num[1].sync_ctx_num = options->ctxnums; + ce_ctx_set_num[1].async_ctx_num = options->ctxnums; + ce_ctx_set_num[1].ctx_prop = UADK_CTX_CE_INS; + ce_ctx_set_num[1].other_ctx = NULL; + + ctx_set_num[0].other_ctx = &ce_ctx_set_num[0]; + ctx_set_num[1].other_ctx = &ce_ctx_set_num[1]; + + ctx_params.op_type_num = 2; + ctx_params.bmp = numa_allocate_nodemask(); + numa_bitmask_setbit(ctx_params.bmp, 0); + numa_bitmask_setbit(ctx_params.bmp, 1); + ctx_params.cap = ∩ + ctx_params.ctx_set_num = &ctx_set_num[0]; /* init */ switch(subtype) { case CIPHER_TYPE: if (options->mem_type == UADK_AUTO) - ret = wd_cipher_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &cparams); + ret = wd_cipher_init2_(alg_name, SCHED_POLICY_HUNGRY, TASK_HW, &ctx_params); else - ret = wd_cipher_init2_(alg_name, SCHED_POLICY_DEV, TASK_HW, &cparams); + ret = wd_cipher_init2_(alg_name, SCHED_POLICY_DEV, TASK_HW, &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_INSTR, TASK_INSTR); if (ret) SEC_TST_PRT("failed to do cipher intruction init2!\n"); break; case AEAD_TYPE: if (options->mem_type == UADK_AUTO) - ret = wd_aead_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &cparams); + ret = wd_aead_init2_(alg_name, SCHED_POLICY_RR, TASK_HW, &ctx_params); else - ret = wd_aead_init2_(alg_name, SCHED_POLICY_DEV, TASK_HW, &cparams); + ret = wd_aead_init2_(alg_name, SCHED_POLICY_DEV, TASK_HW, &ctx_params); if (ret) SEC_TST_PRT("failed to do aead init2!\n"); break; case DIGEST_TYPE: - if (options->mem_type == UADK_AUTO) - ret = wd_digest_init2_(alg_name, SCHED_POLICY_RR, options->task_type, &cparams); - else - ret = wd_digest_init2_(alg_name, SCHED_POLICY_DEV, options->task_type, &cparams); + if (options->mem_type == UADK_AUTO) { + ctx_params.op_type_num = 1; + ret = wd_digest_init2_(alg_name, SCHED_POLICY_RR, options->task_type, &ctx_params); + } else + ret = wd_digest_init2_(alg_name, SCHED_POLICY_DEV, options->task_type, &ctx_params); if (ret) SEC_TST_PRT("failed to do digest init2!\n"); break; + case DIGEST_INSTR_TYPE: + ctx_params.op_type_num = 1; + ret = wd_digest_init2_(alg_name, SCHED_POLICY_INSTR, TASK_INSTR, &ctx_params); + if (ret) + SEC_TST_PRT("failed to do digest instruction init2!\n"); + break; } if (ret) { SEC_TST_PRT("failed to do cipher init2!\n"); return ret; } -out_freectx: - free(ctx_set_num); - return ret; - } static void get_aead_data(u8 *addr, u32 size) @@ -1715,6 +1725,12 @@ static void *sec_uadk_poll2(void *data) case DIGEST_TYPE: uadk_poll_policy = wd_digest_poll; break; + case CIPHER_INSTR_TYPE: + uadk_poll_policy = wd_cipher_poll; + break; + case DIGEST_INSTR_TYPE: + uadk_poll_policy = wd_digest_poll; + break; default: SEC_TST_PRT("<<<<<<async poll interface is NULL!\n"); return NULL; @@ -2362,6 +2378,7 @@ int sec_uadk_sync_threads(struct acc_option *options) uadk_sec_sync_run = sec_uadk_aead_sync; break; case DIGEST_TYPE: + case DIGEST_INSTR_TYPE: uadk_sec_sync_run = sec_uadk_digest_sync; break; default: @@ -2418,12 +2435,14 @@ int sec_uadk_async_threads(struct acc_option *options) switch (options->subtype) { case CIPHER_TYPE: + case CIPHER_INSTR_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: + case DIGEST_INSTR_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 09e99e2..bfab093 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -493,9 +493,10 @@ static void parse_alg_param(struct acc_option *option) option->subtype = DIGEST_TYPE; option->acctype = SEC_TYPE; if (option->modetype == INSTR_MODE) { - option->sched_type = SCHED_POLICY_NONE; + option->subtype = DIGEST_INSTR_TYPE; option->task_type = TASK_INSTR; } else if (option->modetype == MULTIBUF_MODE) { + option->subtype = DIGEST_INSTR_TYPE; option->sched_type = SCHED_POLICY_SINGLE; option->task_type = TASK_INSTR; } diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h index 83fd7fa..816232b 100644 --- a/uadk_tool/benchmark/uadk_benchmark.h +++ b/uadk_tool/benchmark/uadk_benchmark.h @@ -117,6 +117,7 @@ enum alg_type { X25519_TYPE, X448_TYPE, CIPHER_INSTR_TYPE, + DIGEST_INSTR_TYPE, }; enum sync_type { -- 2.43.0