libwd/0039-uadk_tool-support-sm3-md5-multibuff-benchmark-test.patch
JangShui Yang e072f742a4 libwd: update the source code
(cherry picked from commit dc42b3a676205c1a1c922628a993887e1ad2988f)
2024-04-07 18:59:45 +08:00

273 lines
8.2 KiB
Diff

From 7b3f79fedc187ded4dc7d6bdc976d0e560cc746d Mon Sep 17 00:00:00 2001
From: Weili Qian <qianweili@huawei.com>
Date: Mon, 11 Mar 2024 16:33:58 +0800
Subject: [PATCH 39/44] uadk_tool: support sm3/md5 multibuff benchmark test
Support sm3/md5 multibuff benchmark test
Signed-off-by: Weili Qian <qianweili@huawei.com>
---
uadk_tool/benchmark/sec_uadk_benchmark.c | 31 +++++++++++++++---------
uadk_tool/benchmark/uadk_benchmark.c | 26 ++++++++++++++------
uadk_tool/benchmark/uadk_benchmark.h | 3 ++-
3 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
index f8b19ba..2c12c20 100644
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
@@ -53,6 +53,7 @@ typedef struct uadk_thread_res {
bool is_union;
u32 dalg;
u32 dmode;
+ u32 d_outbytes;
} thread_data;
static struct wd_ctx_config g_ctx_cfg;
@@ -146,6 +147,7 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
u32 algtype = options->algtype;
u32 optype = options->optype;
bool is_union = false;
+ u32 out_bytes = 32;
u8 keysize = 0;
u8 ivsize = 0;
u8 dmode = 0;
@@ -472,45 +474,54 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
case SM3_ALG: // digest mode is optype
keysize = 4;
mode = optype;
+ out_bytes = 32;
alg = WD_DIGEST_SM3;
break;
case MD5_ALG:
keysize = 4;
+ out_bytes = 16;
mode = optype;
alg = WD_DIGEST_MD5;
break;
case SHA1_ALG:
keysize = 4;
+ out_bytes = 20;
mode = optype;
alg = WD_DIGEST_SHA1;
break;
case SHA256_ALG:
keysize = 4;
+ out_bytes = 32;
mode = optype;
alg = WD_DIGEST_SHA256;
break;
case SHA224_ALG:
keysize = 4;
+ out_bytes = 28;
mode = optype;
alg = WD_DIGEST_SHA224;
break;
case SHA384_ALG:
keysize = 4;
+ out_bytes = 48;
mode = optype;
alg = WD_DIGEST_SHA384;
break;
case SHA512_ALG:
keysize = 4;
+ out_bytes = 64;
mode = optype;
alg = WD_DIGEST_SHA512;
break;
case SHA512_224:
keysize = 4;
+ out_bytes = 28;
mode = optype;
alg = WD_DIGEST_SHA512_224;
break;
case SHA512_256:
keysize = 4;
+ out_bytes = 32;
mode = optype;
alg = WD_DIGEST_SHA512_256;
break;
@@ -528,6 +539,7 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
tddata->is_union = is_union;
tddata->optype = options->optype;
tddata->subtype = options->subtype;
+ tddata->d_outbytes = out_bytes;
return 0;
}
@@ -698,7 +710,6 @@ static void uninit_ctx_config2(int subtype)
wd_aead_uninit2();
break;
case DIGEST_TYPE:
- case DIGEST_INSTR_TYPE:
wd_digest_uninit2();
break;
default:
@@ -737,15 +748,10 @@ static int init_ctx_config2(struct acc_option *options)
SEC_TST_PRT("failed to do aead init2!\n");
break;
case DIGEST_TYPE:
- ret = wd_digest_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
+ ret = wd_digest_init2(alg_name, options->sched_type, options->task_type);
if (ret)
SEC_TST_PRT("failed to do digest init2!\n");
break;
- case DIGEST_INSTR_TYPE:
- ret = wd_digest_init2(alg_name, SCHED_POLICY_NONE, TASK_INSTR);
- if (ret)
- SEC_TST_PRT("failed to do digest intruction init2!\n");
- break;
}
if (ret) {
SEC_TST_PRT("failed to do cipher init2!\n");
@@ -1305,8 +1311,8 @@ static void *sec_uadk_digest_async(void *arg)
}
}
dreq.in_bytes = g_pktlen;
- dreq.out_bytes = 16;
- dreq.out_buf_bytes = 16;
+ dreq.out_bytes = pdata->d_outbytes;
+ dreq.out_buf_bytes = pdata->d_outbytes;
dreq.data_fmt = 0;
dreq.state = 0;
dreq.has_next = 0;
@@ -1525,8 +1531,8 @@ static void *sec_uadk_digest_sync(void *arg)
}
}
dreq.in_bytes = g_pktlen;
- dreq.out_bytes = 32;
- dreq.out_buf_bytes = 32;
+ dreq.out_bytes = pdata->d_outbytes;
+ dreq.out_buf_bytes = pdata->d_outbytes;
dreq.data_fmt = 0;
dreq.state = 0;
dreq.has_next = 0;
@@ -1573,7 +1579,6 @@ 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:
@@ -1591,6 +1596,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;
+ threads_args[i].d_outbytes = threads_option.d_outbytes;
ret = pthread_create(&tdid[i], NULL, uadk_sec_sync_run, &threads_args[i]);
if (ret) {
SEC_TST_PRT("Create sync thread fail!\n");
@@ -1662,6 +1668,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;
+ threads_args[i].d_outbytes = threads_option.d_outbytes;
ret = pthread_create(&tdid[i], NULL, uadk_sec_async_run, &threads_args[i]);
if (ret) {
SEC_TST_PRT("Create async thread fail!\n");
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
index f9bb69c..c1accc6 100644
--- a/uadk_tool/benchmark/uadk_benchmark.c
+++ b/uadk_tool/benchmark/uadk_benchmark.c
@@ -2,6 +2,8 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include "include/wd_alg_common.h"
+#include "include/wd_sched.h"
#include "uadk_benchmark.h"
#include "sec_uadk_benchmark.h"
@@ -38,7 +40,8 @@ enum test_type {
SVA_SOFT = 0x5,
NOSVA_SOFT = 0x6,
INSTR_MODE = 0x7,
- INVALID_MODE = 0x8,
+ MULTIBUF_MODE = 0x8,
+ INVALID_MODE = 0x9,
};
struct acc_sva_item {
@@ -53,6 +56,7 @@ static struct acc_sva_item sys_name_item[] = {
{"sva-soft", SVA_SOFT},
{"nosva-soft", NOSVA_SOFT},
{"instr", INSTR_MODE},
+ {"multibuff", MULTIBUF_MODE},
};
struct acc_alg_item {
@@ -493,11 +497,15 @@ static void parse_alg_param(struct acc_option *option)
option->subtype = AEAD_TYPE;
} else if (option->algtype <= SHA512_256) {
snprintf(option->algclass, MAX_ALG_NAME, "%s", "digest");
- if (option->modetype == INSTR_MODE)
- option->subtype = DIGEST_INSTR_TYPE;
- else
- option->subtype = DIGEST_TYPE;
+ option->subtype = DIGEST_TYPE;
option->acctype = SEC_TYPE;
+ if (option->modetype == INSTR_MODE) {
+ option->sched_type = SCHED_POLICY_NONE;
+ option->task_type = TASK_INSTR;
+ } else if (option->modetype == MULTIBUF_MODE) {
+ option->sched_type = SCHED_POLICY_SINGLE;
+ option->task_type = TASK_INSTR;
+ }
}
}
}
@@ -559,7 +567,9 @@ static int benchmark_run(struct acc_option *option)
switch(option->acctype) {
case SEC_TYPE:
- if ((option->modetype == SVA_MODE) || (option->modetype == INSTR_MODE)) {
+ if ((option->modetype == SVA_MODE) ||
+ (option->modetype == INSTR_MODE) ||
+ (option->modetype == MULTIBUF_MODE)) {
ret = sec_uadk_benchmark(option);
} else if (option->modetype == NOSVA_MODE) {
ret = sec_wd_benchmark(option);
@@ -623,6 +633,8 @@ int acc_benchmark_run(struct acc_option *option)
int i, ret = 0;
int status;
+ option->sched_type = SCHED_POLICY_RR;
+ option->task_type = TASK_HW;
parse_alg_param(option);
dump_param(option);
g_run_options = option;
@@ -712,7 +724,7 @@ static void print_help(void)
ACC_TST_PRT("DESCRIPTION\n");
ACC_TST_PRT(" [--alg aes-128-cbc ]:\n");
ACC_TST_PRT(" The name of the algorithm for benchmarking\n");
- ACC_TST_PRT(" [--mode sva/nosva/soft/sva-soft/nosva-soft/instr]: start UADK or Warpdrive or Openssl or Instruction mode test\n");
+ ACC_TST_PRT(" [--mode sva/nosva/soft/sva-soft/nosva-soft/instr/multibuff]: start UADK or Warpdrive or Openssl or Instruction mode test\n");
ACC_TST_PRT(" [--sync/--async]: start asynchronous/synchronous mode test\n");
ACC_TST_PRT(" [--opt 0,1,2,3,4,5]:\n");
ACC_TST_PRT(" SEC/ZIP: 0/1:encryption/decryption or compression/decompression\n");
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
index ea8e437..c493ac3 100644
--- a/uadk_tool/benchmark/uadk_benchmark.h
+++ b/uadk_tool/benchmark/uadk_benchmark.h
@@ -77,6 +77,8 @@ struct acc_option {
u32 complevel;
u32 inittype;
bool latency;
+ u32 sched_type;
+ int task_type;
};
enum acc_type {
@@ -104,7 +106,6 @@ enum alg_type {
SM2_TYPE,
X25519_TYPE,
X448_TYPE,
- DIGEST_INSTR_TYPE,
CIPHER_INSTR_TYPE,
};
--
2.25.1