libwd: update the source code
This commit is contained in:
parent
656899aaee
commit
5342f5b3e4
38
0043-uadk_tool-delete-redundant-memset-zero.patch
Normal file
38
0043-uadk_tool-delete-redundant-memset-zero.patch
Normal file
@ -0,0 +1,38 @@
|
||||
From d05210ffd7720e93758a940079c230692ef976ee Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:12 +0800
|
||||
Subject: [PATCH 43/85] uadk_tool: delete redundant memset zero
|
||||
|
||||
wd_rsa_del_kg_out() clears the data before freeing the memory.
|
||||
Therefore, no additional memset zero is required before
|
||||
calling wd_rsa_del_kg_out().
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/hpre_uadk_benchmark.c | 10 ----------
|
||||
1 file changed, 10 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
index e722c36..eaa8408 100644
|
||||
--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
@@ -1316,16 +1316,6 @@ static void *rsa_uadk_async_run(void *arg)
|
||||
|
||||
/* clean output buffer remainings in the last time operation */
|
||||
if (req.op_type == WD_RSA_GENKEY) {
|
||||
- char *data;
|
||||
- int len;
|
||||
-
|
||||
- len = wd_rsa_kg_out_data((void *)req.dst, &data);
|
||||
- if (len < 0) {
|
||||
- HPRE_TST_PRT("failed to wd rsa get key gen out data!\n");
|
||||
- goto tag_release;
|
||||
- }
|
||||
- memset(data, 0, len);
|
||||
-
|
||||
wd_rsa_del_kg_in(h_sess, req.src);
|
||||
req.src = NULL;
|
||||
wd_rsa_del_kg_out(h_sess, req.dst);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
162
0044-uadk_tool-fix-possible-memory-leak-in-alg-_uadk_asyn.patch
Normal file
162
0044-uadk_tool-fix-possible-memory-leak-in-alg-_uadk_asyn.patch
Normal file
@ -0,0 +1,162 @@
|
||||
From ddb0ffc17b5fffb4db3e36b12fe60a694eeafb5c Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:13 +0800
|
||||
Subject: [PATCH 44/85] uadk_tool: fix possible memory leak in
|
||||
<alg>_uadk_async_run
|
||||
|
||||
After a session is applied for, if subsequent
|
||||
operations fail, the session should be released.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/hpre_uadk_benchmark.c | 45 +++++++++++------------
|
||||
1 file changed, 21 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
index eaa8408..9d89f7e 100644
|
||||
--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
@@ -1238,7 +1238,7 @@ static void *rsa_uadk_async_run(void *arg)
|
||||
key_info = malloc(key_size * 16);
|
||||
if (!key_info) {
|
||||
HPRE_TST_PRT("failed to alloc RSA key info!\n");
|
||||
- return NULL;
|
||||
+ goto h_sess_release;
|
||||
}
|
||||
memset(key_info, 0, key_size * 16);
|
||||
|
||||
@@ -1251,13 +1251,20 @@ static void *rsa_uadk_async_run(void *arg)
|
||||
rsa_key_in->p = rsa_key_in->e + key_size;
|
||||
rsa_key_in->q = rsa_key_in->p + (key_size >> 1);
|
||||
|
||||
- ret = get_rsa_key_from_sample(h_sess, key_info, key_info,
|
||||
+ ret = get_rsa_key_from_sample(h_sess, key_info, key_info,
|
||||
pdata->keybits, pdata->kmode);
|
||||
if (ret) {
|
||||
HPRE_TST_PRT("failed to get sample key data!\n");
|
||||
- goto sample_release;
|
||||
+ goto key_in_release;
|
||||
}
|
||||
|
||||
+ tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
+ if (!tag) {
|
||||
+ HPRE_TST_PRT("failed to malloc rsa tag!\n");
|
||||
+ goto key_in_release;
|
||||
+ }
|
||||
+
|
||||
+ req.cb = rsa_async_cb;
|
||||
req.src_bytes = key_size;
|
||||
req.dst_bytes = key_size;
|
||||
req.op_type = pdata->optype;
|
||||
@@ -1265,13 +1272,13 @@ static void *rsa_uadk_async_run(void *arg)
|
||||
ret = get_hpre_keygen_opdata(h_sess, &req);
|
||||
if (ret){
|
||||
HPRE_TST_PRT("failed to fill rsa key gen req!\n");
|
||||
- goto sample_release;
|
||||
+ goto tag_release;
|
||||
}
|
||||
} else {
|
||||
req.src = malloc(key_size);
|
||||
if (!req.src) {
|
||||
HPRE_TST_PRT("failed to alloc rsa in buffer!\n");
|
||||
- goto sample_release;
|
||||
+ goto tag_release;
|
||||
}
|
||||
memset(req.src, 0, req.src_bytes);
|
||||
memcpy(req.src + key_size - sizeof(rsa_m), rsa_m, sizeof(rsa_m));
|
||||
@@ -1282,13 +1289,6 @@ static void *rsa_uadk_async_run(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
- tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
- if (!tag) {
|
||||
- HPRE_TST_PRT("failed to malloc rsa tag!\n");
|
||||
- goto dst_release;
|
||||
- }
|
||||
- req.cb = rsa_async_cb;
|
||||
-
|
||||
do {
|
||||
if (get_run_state() == 0)
|
||||
break;
|
||||
@@ -1309,7 +1309,7 @@ static void *rsa_uadk_async_run(void *arg)
|
||||
continue;
|
||||
} else if (ret) {
|
||||
HPRE_TST_PRT("failed to do rsa async task!\n");
|
||||
- goto tag_release;
|
||||
+ break;
|
||||
}
|
||||
count++;
|
||||
} while(true);
|
||||
@@ -1322,19 +1322,18 @@ static void *rsa_uadk_async_run(void *arg)
|
||||
req.dst = NULL;
|
||||
}
|
||||
|
||||
-tag_release:
|
||||
- free(tag);
|
||||
-dst_release:
|
||||
if (req.dst)
|
||||
free(req.dst);
|
||||
src_release:
|
||||
if (req.src)
|
||||
free(req.src);
|
||||
-sample_release:
|
||||
+tag_release:
|
||||
+ free(tag);
|
||||
+key_in_release:
|
||||
free(rsa_key_in);
|
||||
key_release:
|
||||
free(key_info);
|
||||
-
|
||||
+h_sess_release:
|
||||
wd_rsa_free_sess(h_sess);
|
||||
add_send_complete();
|
||||
|
||||
@@ -1542,7 +1541,7 @@ static void *dh_uadk_async_run(void *arg)
|
||||
ret = get_dh_opdata_param(h_sess, &req, ¶m, key_size);
|
||||
if (ret){
|
||||
HPRE_TST_PRT("failed to fill dh key gen req!\n");
|
||||
- goto param_release;
|
||||
+ goto sess_release;
|
||||
}
|
||||
|
||||
tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
@@ -1572,12 +1571,11 @@ static void *dh_uadk_async_run(void *arg)
|
||||
continue;
|
||||
} else if (ret) {
|
||||
HPRE_TST_PRT("failed to do DH async task!\n");
|
||||
- goto tag_release;
|
||||
+ break;
|
||||
}
|
||||
count++;
|
||||
} while(true);
|
||||
|
||||
-tag_release:
|
||||
free(tag);
|
||||
param_release:
|
||||
free(req.x_p);
|
||||
@@ -2200,7 +2198,7 @@ static void *ecc_uadk_async_run(void *arg)
|
||||
tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
if (!tag) {
|
||||
HPRE_TST_PRT("failed to malloc rsa tag!\n");
|
||||
- goto src_release;
|
||||
+ goto src_release;
|
||||
}
|
||||
req.cb = ecc_async_cb;
|
||||
|
||||
@@ -2224,12 +2222,11 @@ static void *ecc_uadk_async_run(void *arg)
|
||||
continue;
|
||||
} else if (ret) {
|
||||
HPRE_TST_PRT("failed to do ECC async task!\n");
|
||||
- goto tag_release;
|
||||
+ break;
|
||||
}
|
||||
count++;
|
||||
} while(true);
|
||||
|
||||
-tag_release:
|
||||
free(tag);
|
||||
src_release:
|
||||
if (req.src)
|
||||
--
|
||||
2.25.1
|
||||
|
||||
29
0045-uadk_tool-fix-the-called-function-interface.patch
Normal file
29
0045-uadk_tool-fix-the-called-function-interface.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From b36986f417bfbcfe37c822b4c9a9c7168b12554d Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:14 +0800
|
||||
Subject: [PATCH 45/85] uadk_tool: fix the called function interface
|
||||
|
||||
In asynchronous scenarios, call wd_do_rsa_async()
|
||||
instead of wd_do_rsa_sync().
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/hpre_uadk_benchmark.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
index 9d89f7e..653232f 100644
|
||||
--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
@@ -2211,7 +2211,7 @@ static void *ecc_uadk_async_run(void *arg)
|
||||
tag[i].sess = h_sess;
|
||||
req.cb_param = &tag[i];
|
||||
|
||||
- ret = wd_do_ecc_sync(h_sess, &req);
|
||||
+ ret = wd_do_ecc_async(h_sess, &req);
|
||||
if (ret == -WD_EBUSY) {
|
||||
usleep(SEND_USLEEP * try_cnt);
|
||||
try_cnt++;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
From 36363fb48e8653a6efbacc32a1374e76a86592a4 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:15 +0800
|
||||
Subject: [PATCH 46/85] uadk_tool: release memory after all tasks are complete
|
||||
|
||||
In asynchronous scenarios, memory is released after all tasks are complete.
|
||||
This prevents segmentation errors caused by the polling thread uses the
|
||||
memory after the memory is freed.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/hpre_uadk_benchmark.c | 49 ++++++++++++++++++++++-
|
||||
1 file changed, 48 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
index 653232f..5e84d61 100644
|
||||
--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
@@ -1314,7 +1314,22 @@ static void *rsa_uadk_async_run(void *arg)
|
||||
count++;
|
||||
} while(true);
|
||||
|
||||
- /* clean output buffer remainings in the last time operation */
|
||||
+ /* Release memory after all tasks are complete. */
|
||||
+ if (count) {
|
||||
+ i = 0;
|
||||
+ while (get_recv_time() != g_ctxnum) {
|
||||
+ if (i++ >= MAX_TRY_CNT) {
|
||||
+ HPRE_TST_PRT("failed to wait poll thread finish!\n");
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ usleep(SEND_USLEEP);
|
||||
+ }
|
||||
+
|
||||
+ /* Wait for the device to complete the tasks. */
|
||||
+ usleep(SEND_USLEEP * MAX_TRY_CNT);
|
||||
+ }
|
||||
+
|
||||
if (req.op_type == WD_RSA_GENKEY) {
|
||||
wd_rsa_del_kg_in(h_sess, req.src);
|
||||
req.src = NULL;
|
||||
@@ -1576,6 +1591,22 @@ static void *dh_uadk_async_run(void *arg)
|
||||
count++;
|
||||
} while(true);
|
||||
|
||||
+ /* Release memory after all tasks are complete. */
|
||||
+ if (count) {
|
||||
+ i = 0;
|
||||
+ while (get_recv_time() != g_ctxnum) {
|
||||
+ if (i++ >= MAX_TRY_CNT) {
|
||||
+ HPRE_TST_PRT("failed to wait poll thread finish!\n");
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ usleep(SEND_USLEEP);
|
||||
+ }
|
||||
+
|
||||
+ /* Wait for the device to complete the tasks. */
|
||||
+ usleep(SEND_USLEEP * MAX_TRY_CNT);
|
||||
+ }
|
||||
+
|
||||
free(tag);
|
||||
param_release:
|
||||
free(req.x_p);
|
||||
@@ -2227,6 +2258,22 @@ static void *ecc_uadk_async_run(void *arg)
|
||||
count++;
|
||||
} while(true);
|
||||
|
||||
+ /* Release memory after all tasks are complete. */
|
||||
+ if (count) {
|
||||
+ i = 0;
|
||||
+ while (get_recv_time() != g_ctxnum) {
|
||||
+ if (i++ >= MAX_TRY_CNT) {
|
||||
+ HPRE_TST_PRT("failed to wait poll thread finish!\n");
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ usleep(SEND_USLEEP);
|
||||
+ }
|
||||
+
|
||||
+ /* Wait for the device to complete the tasks. */
|
||||
+ usleep(SEND_USLEEP * MAX_TRY_CNT);
|
||||
+ }
|
||||
+
|
||||
free(tag);
|
||||
src_release:
|
||||
if (req.src)
|
||||
--
|
||||
2.25.1
|
||||
|
||||
905
0047-uadk_tool-Optimize-sec-s-sva-benchmark-code.patch
Normal file
905
0047-uadk_tool-Optimize-sec-s-sva-benchmark-code.patch
Normal file
@ -0,0 +1,905 @@
|
||||
From 44077a50fb4f259c59f86331e9ccd4a386e4b81f Mon Sep 17 00:00:00 2001
|
||||
From: Longfang Liu <liulongfang@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:16 +0800
|
||||
Subject: [PATCH 47/85] uadk_tool: Optimize sec's sva benchmark code
|
||||
|
||||
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>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 705 ++++++++++++++---------
|
||||
1 file changed, 443 insertions(+), 262 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index 09cd8f4..1ea57ee 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -27,6 +27,7 @@ struct thread_pool {
|
||||
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;
|
||||
@@ -66,8 +70,11 @@ 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;
|
||||
u8 keysize = 0;
|
||||
u8 ivsize = 0;
|
||||
+ u8 dmode;
|
||||
+ u8 dalg;
|
||||
u8 mode;
|
||||
u8 alg;
|
||||
|
||||
@@ -270,6 +277,33 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
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;
|
||||
@@ -334,8 +368,11 @@ 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;
|
||||
tddata->optype = options->optype;
|
||||
tddata->subtype = options->subtype;
|
||||
|
||||
@@ -382,7 +419,7 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
break;
|
||||
default:
|
||||
SEC_TST_PRT("Fail to parse alg subtype!\n");
|
||||
- goto out;
|
||||
+ return -EINVAL;
|
||||
}
|
||||
if (!g_sched) {
|
||||
SEC_TST_PRT("Fail to alloc sched!\n");
|
||||
@@ -416,8 +453,6 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
case DIGEST_TYPE:
|
||||
ret = wd_digest_init(&g_ctx_cfg, g_sched);
|
||||
break;
|
||||
- default:
|
||||
- goto out;
|
||||
}
|
||||
if (ret) {
|
||||
SEC_TST_PRT("Fail to cipher ctx!\n");
|
||||
@@ -471,6 +506,7 @@ static int init_uadk_bd_pool(void)
|
||||
g_uadk_pool.iv = malloc(g_thread_num * MAX_IVK_LENTH * sizeof(char));
|
||||
g_uadk_pool.key = malloc(g_thread_num * MAX_IVK_LENTH * sizeof(char));
|
||||
g_uadk_pool.mac = malloc(g_thread_num * MAX_IVK_LENTH * sizeof(char));
|
||||
+ g_uadk_pool.hash = malloc(g_thread_num * MAX_IVK_LENTH * sizeof(char));
|
||||
|
||||
g_uadk_pool.pool = malloc(g_thread_num * sizeof(struct bd_pool));
|
||||
if (!g_uadk_pool.pool) {
|
||||
@@ -523,6 +559,7 @@ malloc_error1:
|
||||
free(g_uadk_pool.iv);
|
||||
free(g_uadk_pool.key);
|
||||
free(g_uadk_pool.mac);
|
||||
+ free(g_uadk_pool.hash);
|
||||
|
||||
SEC_TST_PRT("init uadk bd pool alloc failed!\n");
|
||||
return -ENOMEM;
|
||||
@@ -601,20 +638,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;
|
||||
|
||||
@@ -624,176 +656,296 @@ static void *sec_uadk_async_run(void *arg)
|
||||
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];
|
||||
|
||||
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 = 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];
|
||||
+ priv_mac = &g_uadk_pool.mac[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("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.data_fmt = 0;
|
||||
+ areq.state = 0;
|
||||
+ areq.cb = aead_async_cb;
|
||||
|
||||
- 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;
|
||||
+ 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_mac, *priv_hash;
|
||||
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;
|
||||
@@ -806,129 +958,130 @@ static void *sec_uadk_sync_run(void *arg)
|
||||
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_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);
|
||||
|
||||
- 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;
|
||||
- }
|
||||
-
|
||||
- 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 (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);
|
||||
+ aead_setup.calg = pdata->alg;
|
||||
+ aead_setup.cmode = pdata->mode;
|
||||
+ if (pdata->is_union) {
|
||||
+ aead_setup.dalg = WD_DIGEST_SHA256;
|
||||
+ aead_setup.dmode = WD_DIGEST_HMAC;
|
||||
+ }
|
||||
+ 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("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 (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;
|
||||
+
|
||||
+ 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 +1090,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 +1102,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 +1122,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 +1144,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 +1157,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 +1188,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;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
1183
0048-uadk_tool-Optimize-sec-s-no-sva-benchmark-code.patch
Normal file
1183
0048-uadk_tool-Optimize-sec-s-no-sva-benchmark-code.patch
Normal file
File diff suppressed because it is too large
Load Diff
1205
0049-uadk_tool-Optimize-sec-s-software-benchmark-code.patch
Normal file
1205
0049-uadk_tool-Optimize-sec-s-software-benchmark-code.patch
Normal file
File diff suppressed because it is too large
Load Diff
531
0050-uadk_tool-add-latency-test-function-for-uadk_tools.patch
Normal file
531
0050-uadk_tool-add-latency-test-function-for-uadk_tools.patch
Normal file
@ -0,0 +1,531 @@
|
||||
From ca646cd14b69137795a90d8ec527743c43d0f897 Mon Sep 17 00:00:00 2001
|
||||
From: Longfang Liu <liulongfang@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:19 +0800
|
||||
Subject: [PATCH 50/85] uadk_tool: add latency test function for uadk_tools
|
||||
|
||||
Add latency test function for symmetric algorithm, asymmetric
|
||||
algorithm and compression algorithm in uadk_tools, and add this
|
||||
function for SVA mode and No-SVA mode at the same time.
|
||||
|
||||
Signed-off-by: Longfang Liu <liulongfang@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/hpre_uadk_benchmark.c | 3 +
|
||||
uadk_tool/benchmark/hpre_wd_benchmark.c | 3 +
|
||||
uadk_tool/benchmark/sec_soft_benchmark.c | 3 +
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 3 +
|
||||
uadk_tool/benchmark/sec_wd_benchmark.c | 3 +
|
||||
uadk_tool/benchmark/uadk_benchmark.c | 105 ++++++++++++++--------
|
||||
uadk_tool/benchmark/uadk_benchmark.h | 15 +++-
|
||||
uadk_tool/benchmark/zip_uadk_benchmark.c | 12 +--
|
||||
uadk_tool/benchmark/zip_wd_benchmark.c | 12 +--
|
||||
9 files changed, 102 insertions(+), 57 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
index 5e84d61..13e24ca 100644
|
||||
--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
@@ -1198,6 +1198,7 @@ key_release:
|
||||
free(key_info);
|
||||
|
||||
wd_rsa_free_sess(h_sess);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, key_size);
|
||||
|
||||
return NULL;
|
||||
@@ -1670,6 +1671,7 @@ param_release:
|
||||
free(req.pri);
|
||||
sess_release:
|
||||
wd_dh_free_sess(h_sess);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, key_size);
|
||||
|
||||
return NULL;
|
||||
@@ -2102,6 +2104,7 @@ msg_release:
|
||||
if (subtype == SM2_TYPE)
|
||||
free(setup.msg);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, key_size);
|
||||
|
||||
return NULL;
|
||||
diff --git a/uadk_tool/benchmark/hpre_wd_benchmark.c b/uadk_tool/benchmark/hpre_wd_benchmark.c
|
||||
index 354e0e1..231b569 100644
|
||||
--- a/uadk_tool/benchmark/hpre_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_wd_benchmark.c
|
||||
@@ -928,6 +928,7 @@ key_release:
|
||||
free(key_info);
|
||||
|
||||
wcrypto_del_rsa_ctx(ctx);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, key_size);
|
||||
|
||||
return NULL;
|
||||
@@ -1324,6 +1325,7 @@ param_release:
|
||||
wd_free_blk(pool, opdata.pri);
|
||||
ctx_release:
|
||||
wcrypto_del_dh_ctx(ctx);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, key_size);
|
||||
|
||||
return NULL;
|
||||
@@ -2193,6 +2195,7 @@ sess_release:
|
||||
msg_release:
|
||||
if (subtype == SM2_TYPE)
|
||||
free(setup.msg);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, key_size);
|
||||
|
||||
return NULL;
|
||||
diff --git a/uadk_tool/benchmark/sec_soft_benchmark.c b/uadk_tool/benchmark/sec_soft_benchmark.c
|
||||
index ea84393..f3510b1 100644
|
||||
--- a/uadk_tool/benchmark/sec_soft_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_soft_benchmark.c
|
||||
@@ -882,6 +882,7 @@ static void *sec_soft_cipher_sync(void *arg)
|
||||
EVP_CIPHER_CTX_cleanup(ctx);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
@@ -986,6 +987,7 @@ static void *sec_soft_aead_sync(void *arg)
|
||||
}
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
@@ -1056,6 +1058,7 @@ static void *sec_soft_digest_sync(void *arg)
|
||||
HMAC_CTX_free(hm_ctx);
|
||||
}
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index 1ea57ee..ff83769 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -934,6 +934,7 @@ static void *sec_uadk_cipher_sync(void *arg)
|
||||
}
|
||||
wd_cipher_free_sess(h_sess);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
@@ -1024,6 +1025,7 @@ static void *sec_uadk_aead_sync(void *arg)
|
||||
}
|
||||
wd_aead_free_sess(h_sess);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
@@ -1083,6 +1085,7 @@ static void *sec_uadk_digest_sync(void *arg)
|
||||
}
|
||||
wd_digest_free_sess(h_sess);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
index 038d3ab..5dd1501 100644
|
||||
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
@@ -1032,6 +1032,7 @@ static void *sec_wd_cipher_sync(void *arg)
|
||||
}
|
||||
wcrypto_del_cipher_ctx(ctx);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
@@ -1156,6 +1157,7 @@ static void *sec_wd_aead_sync(void *arg)
|
||||
}
|
||||
wcrypto_del_aead_ctx(ctx);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
@@ -1245,6 +1247,7 @@ static void *sec_wd_digest_sync(void *arg)
|
||||
}
|
||||
wcrypto_del_digest_ctx(ctx);
|
||||
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
index 752553d..2791f84 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
/*----------------------------------------head struct--------------------------------------------------------*/
|
||||
static unsigned int g_run_state = 1;
|
||||
+static struct acc_option *g_run_options;
|
||||
static pthread_mutex_t acc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static struct _recv_data {
|
||||
double pkg_len;
|
||||
@@ -116,6 +117,9 @@ static struct acc_alg_item alg_options[] = {
|
||||
{"aes-128-gcm", AES_128_GCM},
|
||||
{"aes-192-gcm", AES_192_GCM},
|
||||
{"aes-256-gcm", AES_256_GCM},
|
||||
+ {"aes-128-cbc-sha256-hmac", AES_128_CBC_SHA256_HMAC},
|
||||
+ {"aes-192-cbc-sha256-hmac", AES_192_CBC_SHA256_HMAC},
|
||||
+ {"aes-256-cbc-sha256-hmac", AES_256_CBC_SHA256_HMAC},
|
||||
{"sm4-128-ccm", SM4_128_CCM},
|
||||
{"sm4-128-gcm", SM4_128_GCM},
|
||||
{"sm3", SM3_ALG},
|
||||
@@ -290,6 +294,18 @@ void get_rand_data(u8 *addr, u32 size)
|
||||
#endif
|
||||
}
|
||||
|
||||
+
|
||||
+void cal_avg_latency(u32 count)
|
||||
+{
|
||||
+ double latency;
|
||||
+
|
||||
+ if (!g_run_options || !g_run_options->latency)
|
||||
+ return;
|
||||
+
|
||||
+ latency = (double)g_run_options->times * SEC_2_USEC / count;
|
||||
+ ACC_TST_PRT("thread<%lu> avg latency: %.1fus\n", gettid(), latency);
|
||||
+}
|
||||
+
|
||||
/*-------------------------------------main code------------------------------------------------------*/
|
||||
|
||||
static void parse_alg_param(struct acc_option *option)
|
||||
@@ -382,7 +398,7 @@ void cal_perfermance_data(struct acc_option *option, u32 sttime)
|
||||
if (get_recv_time() == option->threads)
|
||||
break;
|
||||
} else { // ASYNC_MODE
|
||||
- if (get_recv_time() == 1)
|
||||
+ if (get_recv_time() == 1) // poll complete
|
||||
break;
|
||||
}
|
||||
usleep(1000);
|
||||
@@ -471,9 +487,9 @@ int acc_benchmark_run(struct acc_option *option)
|
||||
int i, ret = 0;
|
||||
int status;
|
||||
|
||||
- ACC_TST_PRT("start UADK benchmark test.\n");
|
||||
parse_alg_param(option);
|
||||
dump_param(option);
|
||||
+ g_run_options = option;
|
||||
|
||||
pthread_mutex_init(&acc_mutex, NULL);
|
||||
if (option->multis <= 1) {
|
||||
@@ -549,12 +565,12 @@ int acc_default_case(struct acc_option *option)
|
||||
static void print_help(void)
|
||||
{
|
||||
ACC_TST_PRT("NAME\n");
|
||||
- ACC_TST_PRT(" uadk_tool benchmark: test UADK acc performance,etc\n");
|
||||
+ ACC_TST_PRT(" benchmark: test UADK acc performance,etc\n");
|
||||
ACC_TST_PRT("USAGE\n");
|
||||
- ACC_TST_PRT(" uadk_tool benchmark [--alg aes-128-cbc] [--alg rsa-2048]\n");
|
||||
- ACC_TST_PRT(" uadk_tool benchmark [--mode] [--pktlen] [--keylen] [--seconds]\n");
|
||||
- ACC_TST_PRT(" uadk_tool benchmark [--multi] [--sync] [--async] [--help]\n");
|
||||
- ACC_TST_PRT(" numactl --cpubind=0 --membind=0,1 ./uadk_tool benchmark xxxx\n");
|
||||
+ ACC_TST_PRT(" benchmark [--alg aes-128-cbc] [--alg rsa-2048]\n");
|
||||
+ ACC_TST_PRT(" benchmark [--mode] [--pktlen] [--keylen] [--seconds]\n");
|
||||
+ ACC_TST_PRT(" benchmark [--multi] [--sync] [--async] [--help]\n");
|
||||
+ ACC_TST_PRT(" numactl --cpubind=0 --membind=0,1 ./uadk_benchmark xxxx\n");
|
||||
ACC_TST_PRT(" specify numa nodes for cpu and memory\n");
|
||||
ACC_TST_PRT("DESCRIPTION\n");
|
||||
ACC_TST_PRT(" [--alg aes-128-cbc ]:\n");
|
||||
@@ -569,7 +585,7 @@ static void print_help(void)
|
||||
ACC_TST_PRT(" [--seconds]:\n");
|
||||
ACC_TST_PRT(" set the test times\n");
|
||||
ACC_TST_PRT(" [--multi]:\n");
|
||||
- ACC_TST_PRT(" set the number of process\n");
|
||||
+ ACC_TST_PRT(" set the number of threads\n");
|
||||
ACC_TST_PRT(" [--thread]:\n");
|
||||
ACC_TST_PRT(" set the number of threads\n");
|
||||
ACC_TST_PRT(" [--ctxnum]:\n");
|
||||
@@ -580,11 +596,13 @@ static void print_help(void)
|
||||
ACC_TST_PRT(" set the test openssl engine\n");
|
||||
ACC_TST_PRT(" [--alglist]:\n");
|
||||
ACC_TST_PRT(" list the all support alg\n");
|
||||
+ ACC_TST_PRT(" [--latency]:\n");
|
||||
+ ACC_TST_PRT(" test the running time of packets\n");
|
||||
ACC_TST_PRT(" [--help] = usage\n");
|
||||
ACC_TST_PRT("Example\n");
|
||||
ACC_TST_PRT(" ./uadk_tool benchmark --alg aes-128-cbc --mode sva --opt 0 --sync\n");
|
||||
- ACC_TST_PRT(" --pktlen 1024 --seconds 1 --multi 1 --thread 1 --ctxnum 4\n");
|
||||
- ACC_TST_PRT("UPDATE:2022-7-18\n");
|
||||
+ ACC_TST_PRT(" --pktlen 1024 --seconds 1 --multi 1 --thread 1 --ctxnum 2\n");
|
||||
+ ACC_TST_PRT("UPDATE:2022-3-28\n");
|
||||
}
|
||||
|
||||
static void print_support_alg(void)
|
||||
@@ -603,20 +621,21 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
||||
int c;
|
||||
|
||||
static struct option long_options[] = {
|
||||
- {"alg", required_argument, 0, 2},
|
||||
- {"mode", required_argument, 0, 3},
|
||||
- {"opt", required_argument, 0, 4},
|
||||
- {"sync", no_argument, 0, 5},
|
||||
- {"async", no_argument, 0, 6},
|
||||
- {"pktlen", required_argument, 0, 7},
|
||||
- {"seconds", required_argument, 0, 8},
|
||||
- {"thread", required_argument, 0, 9},
|
||||
- {"multi", required_argument, 0, 10},
|
||||
- {"ctxnum", required_argument, 0, 11},
|
||||
- {"prefetch", no_argument, 0, 12},
|
||||
- {"engine", required_argument, 0, 13},
|
||||
- {"alglist", no_argument, 0, 14},
|
||||
- {"help", no_argument, 0, 15},
|
||||
+ {"alg", required_argument, 0, 1},
|
||||
+ {"mode", required_argument, 0, 2},
|
||||
+ {"opt", required_argument, 0, 3},
|
||||
+ {"sync", no_argument, 0,4},
|
||||
+ {"async", no_argument, 0,5},
|
||||
+ {"pktlen", required_argument, 0, 6},
|
||||
+ {"seconds", required_argument, 0, 7},
|
||||
+ {"thread", required_argument, 0, 8},
|
||||
+ {"multi", required_argument, 0, 9},
|
||||
+ {"ctxnum", required_argument, 0, 10},
|
||||
+ {"prefetch", no_argument, 0,11},
|
||||
+ {"engine", required_argument, 0,12},
|
||||
+ {"alglist", no_argument, 0, 13},
|
||||
+ {"latency", no_argument, 0, 14},
|
||||
+ {"help", no_argument, 0, 15},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -626,46 +645,49 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
- case 2:
|
||||
+ case 1:
|
||||
option->algtype = get_alg_type(optarg);
|
||||
strcpy(option->algname, optarg);
|
||||
break;
|
||||
- case 3:
|
||||
+ case 2:
|
||||
option->modetype = get_mode_type(optarg);
|
||||
break;
|
||||
- case 4:
|
||||
+ case 3:
|
||||
option->optype = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
- case 5:
|
||||
+ case 4:
|
||||
option->syncmode = SYNC_MODE;
|
||||
break;
|
||||
- case 6:
|
||||
+ case 5:
|
||||
option->syncmode = ASYNC_MODE;
|
||||
break;
|
||||
- case 7:
|
||||
+ case 6:
|
||||
option->pktlen = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
- case 8:
|
||||
+ case 7:
|
||||
option->times = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
- case 9:
|
||||
+ case 8:
|
||||
option->threads = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
- case 10:
|
||||
+ case 9:
|
||||
option->multis = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
- case 11:
|
||||
+ case 10:
|
||||
option->ctxnums = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
- case 12:
|
||||
+ case 11:
|
||||
option->prefetch = 1;
|
||||
break;
|
||||
- case 13:
|
||||
+ case 12:
|
||||
strcpy(option->engine, optarg);
|
||||
break;
|
||||
- case 14:
|
||||
+ case 13:
|
||||
print_support_alg();
|
||||
goto to_exit;
|
||||
+ case 14:
|
||||
+ option->latency = true;
|
||||
+ break;
|
||||
case 15:
|
||||
print_help();
|
||||
goto to_exit;
|
||||
@@ -729,9 +751,14 @@ int acc_option_convert(struct acc_option *option)
|
||||
if (!strlen(option->engine)) {
|
||||
option->engine_flag = false;
|
||||
return 0;
|
||||
- } else if (strcmp(option->engine, "uadk")) {
|
||||
+ } else if (strcmp(option->engine, "uadk_engine")) {
|
||||
option->engine_flag = false;
|
||||
- ACC_TST_PRT("uadk benchmark just support engine: uadk\n");
|
||||
+ ACC_TST_PRT("uadk benchmark just support engine: uadk_engine\n");
|
||||
+ goto param_err;
|
||||
+ }
|
||||
+
|
||||
+ if (option->syncmode == ASYNC_MODE && option->latency) {
|
||||
+ ACC_TST_PRT("uadk benchmark async mode can't test latency\n");
|
||||
goto param_err;
|
||||
}
|
||||
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
index a344fac..2c8de11 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.h
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
@@ -32,12 +32,17 @@
|
||||
#define MAX_POOL_LENTH 4096
|
||||
#define MAX_TRY_CNT 5000
|
||||
#define SEND_USLEEP 100
|
||||
+#define SEC_2_USEC 1000000
|
||||
+#define HASH_ZISE 16
|
||||
|
||||
-typedef unsigned char u8;
|
||||
+typedef unsigned long long u64;
|
||||
typedef unsigned int u32;
|
||||
-typedef unsigned long long u64;
|
||||
+typedef unsigned short u16;
|
||||
+typedef unsigned char u8;
|
||||
+
|
||||
#define SCHED_SINGLE "sched_single"
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
+#define gettid() syscall(__NR_gettid)
|
||||
|
||||
/**
|
||||
* struct acc_option - Define the test acc app option list.
|
||||
@@ -47,6 +52,7 @@ typedef unsigned long long u64;
|
||||
* @modetype: sva, no-sva, soft mode
|
||||
* @optype: enc/dec, comp/decomp
|
||||
* @prefetch: write allocated memory to prevent page faults
|
||||
+ * @latency: test packet running time
|
||||
*/
|
||||
struct acc_option {
|
||||
char algname[64];
|
||||
@@ -65,6 +71,7 @@ struct acc_option {
|
||||
char engine[64];
|
||||
u32 engine_flag;
|
||||
u32 prefetch;
|
||||
+ bool latency;
|
||||
};
|
||||
|
||||
enum acc_type {
|
||||
@@ -153,6 +160,9 @@ enum test_alg {
|
||||
AES_128_GCM,
|
||||
AES_192_GCM,
|
||||
AES_256_GCM,
|
||||
+ AES_128_CBC_SHA256_HMAC,
|
||||
+ AES_192_CBC_SHA256_HMAC,
|
||||
+ AES_256_CBC_SHA256_HMAC,
|
||||
SM4_128_CCM,
|
||||
SM4_128_GCM,
|
||||
SM3_ALG, // digest
|
||||
@@ -177,6 +187,7 @@ extern void get_rand_data(u8 *addr, u32 size);
|
||||
extern void add_recv_data(u32 cnt, u32 pkglen);
|
||||
extern void add_send_complete(void);
|
||||
extern u32 get_recv_time(void);
|
||||
+extern void cal_avg_latency(u32 count);
|
||||
|
||||
int acc_cmd_parse(int argc, char *argv[], struct acc_option *option);
|
||||
int acc_default_case(struct acc_option *option);
|
||||
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
index ba18e6d..ffffa9b 100644
|
||||
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
@@ -603,8 +603,7 @@ fse_err:
|
||||
free(ftuple);
|
||||
wd_comp_free_sess(h_sess);
|
||||
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, creq.dst_len);
|
||||
+ cal_avg_latency(count);
|
||||
if (pdata->optype == WD_DIR_COMPRESS)
|
||||
add_recv_data(count, creq.src_len);
|
||||
else
|
||||
@@ -700,8 +699,7 @@ fse_err:
|
||||
free(ftuple);
|
||||
wd_comp_free_sess(h_sess);
|
||||
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, creq.dst_len);
|
||||
+ cal_avg_latency(count);
|
||||
if (pdata->optype == WD_DIR_COMPRESS)
|
||||
add_recv_data(count, creq.src_len);
|
||||
else
|
||||
@@ -872,8 +870,7 @@ static void *zip_uadk_blk_sync_run(void *arg)
|
||||
}
|
||||
wd_comp_free_sess(h_sess);
|
||||
|
||||
- //ZIP_TST_PRT("valid pool len: %u, send count BD: %u, input len: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, creq.src_len, g_pktlen);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
@@ -936,8 +933,7 @@ static void *zip_uadk_stm_sync_run(void *arg)
|
||||
}
|
||||
wd_comp_free_sess(h_sess);
|
||||
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, creq.dst_len);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
index 0df78cd..8d013c5 100644
|
||||
--- a/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
@@ -591,8 +591,7 @@ fse_err:
|
||||
free(ftuple);
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, opdata.produced);
|
||||
+ cal_avg_latency(count);
|
||||
if (pdata->optype == WCRYPTO_DEFLATE)
|
||||
add_recv_data(count, opdata.in_len);
|
||||
else
|
||||
@@ -703,8 +702,7 @@ fse_err:
|
||||
free(ftuple);
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, opdata.produced);
|
||||
+ cal_avg_latency(count);
|
||||
if (pdata->optype == WCRYPTO_DEFLATE)
|
||||
add_recv_data(count, opdata.in_len);
|
||||
else
|
||||
@@ -906,8 +904,7 @@ static void *zip_wd_blk_sync_run(void *arg)
|
||||
}
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, opdata.produced);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
@@ -983,8 +980,7 @@ static void *zip_wd_stm_sync_run(void *arg)
|
||||
}
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, opdata.produced);
|
||||
+ cal_avg_latency(count);
|
||||
add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
551
0051-uadk_tool-modify-the-clean-code-issue.patch
Normal file
551
0051-uadk_tool-modify-the-clean-code-issue.patch
Normal file
@ -0,0 +1,551 @@
|
||||
From c0466b8e9855bcb3eacd4b005a077b3c97c38e7b Mon Sep 17 00:00:00 2001
|
||||
From: Longfang Liu <liulongfang@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:20 +0800
|
||||
Subject: [PATCH 51/85] uadk_tool: modify the clean code issue
|
||||
|
||||
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;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
598
0052-uadk_tool-support-aead-algorithm-decrypto-perf-testi.patch
Normal file
598
0052-uadk_tool-support-aead-algorithm-decrypto-perf-testi.patch
Normal file
@ -0,0 +1,598 @@
|
||||
From a146fb0a7d68ceb327a45bcc1f74c79084c38fbd Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:21 +0800
|
||||
Subject: [PATCH 52/85] uadk_tool - support aead algorithm decrypto perf
|
||||
testing
|
||||
|
||||
The ciphertext and mac result are saved by a file. Can be reloaded
|
||||
it as decrypto. So the AEAD ecryption passes the hard icv checking.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 354 +++++++++++++++++++----
|
||||
1 file changed, 304 insertions(+), 50 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index 16f96a2..36c7381 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -12,6 +12,18 @@
|
||||
#define SEC_TST_PRT printf
|
||||
#define MAX_IVK_LENTH 64
|
||||
#define DEF_IVK_DATA 0xAA
|
||||
+#define SEC_AEAD_LEN 16
|
||||
+#define SEC_PERF_KEY_LEN 16
|
||||
+#define SEC_MAX_MAC_LEN 64
|
||||
+#define SEC_SAVE_FILE_LEN 64
|
||||
+#define SEC_PERF_AUTH_SIZE 16
|
||||
+
|
||||
+char aead_key[] = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
|
||||
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf";
|
||||
+
|
||||
+char aead_aad[] = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
|
||||
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf";
|
||||
+char g_save_mac[SEC_MAX_MAC_LEN];
|
||||
|
||||
struct uadk_bd {
|
||||
u8 *src;
|
||||
@@ -24,10 +36,10 @@ struct bd_pool {
|
||||
|
||||
struct thread_pool {
|
||||
struct bd_pool *pool;
|
||||
- u8 *iv;
|
||||
- u8 *key;
|
||||
- u8 *mac;
|
||||
- u8 *hash;
|
||||
+ u8 **iv;
|
||||
+ u8 **key;
|
||||
+ u8 **mac;
|
||||
+ u8 **hash;
|
||||
} g_uadk_pool;
|
||||
|
||||
typedef struct uadk_thread_res {
|
||||
@@ -49,6 +61,70 @@ static unsigned int g_thread_num;
|
||||
static unsigned int g_ctxnum;
|
||||
static unsigned int g_prefetch;
|
||||
static unsigned int g_pktlen;
|
||||
+static unsigned int g_alg;
|
||||
+static unsigned int g_algtype;
|
||||
+static unsigned int g_optype;
|
||||
+static unsigned int g_maclen;
|
||||
+
|
||||
+struct aead_alg_info {
|
||||
+ int index;
|
||||
+ char *name;
|
||||
+ unsigned int mac_len;
|
||||
+};
|
||||
+
|
||||
+struct aead_alg_info aead_info[] = {
|
||||
+ {
|
||||
+ .index = AES_128_CCM,
|
||||
+ .name = "AES_128_CCM",
|
||||
+ .mac_len = 16,
|
||||
+ }, {
|
||||
+ .index = AES_128_GCM,
|
||||
+ .name = "AES_128_GCM",
|
||||
+ .mac_len = 16,
|
||||
+ }, {
|
||||
+ .index = AES_128_CBC_SHA256_HMAC,
|
||||
+ .name = "AES_128_CBC_SHA256_HMAC",
|
||||
+ .mac_len = 32,
|
||||
+ }, {
|
||||
+ .index = SM4_128_GCM,
|
||||
+ .name = "SM4_128_GCM",
|
||||
+ .mac_len = 16,
|
||||
+ }, {
|
||||
+ .index = SM4_128_CCM,
|
||||
+ .name = "SM4_128_CCM",
|
||||
+ .mac_len = 16,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static u32 get_aead_mac_len(int algtype)
|
||||
+{
|
||||
+ int table_size = sizeof(aead_info) / sizeof(aead_info[0]);
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < table_size; i++) {
|
||||
+ if (algtype == aead_info[i].index)
|
||||
+ return aead_info[i].mac_len;
|
||||
+ }
|
||||
+
|
||||
+ SEC_TST_PRT("failed to get the aead mac len\n");
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static char *get_aead_alg_name(int algtype)
|
||||
+{
|
||||
+ int table_size = sizeof(aead_info) / sizeof(aead_info[0]);
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < table_size; i++) {
|
||||
+ if (algtype == aead_info[i].index)
|
||||
+ return aead_info[i].name;
|
||||
+ }
|
||||
+
|
||||
+ SEC_TST_PRT("failed to get the aead alg name\n");
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
|
||||
static void *cipher_async_cb(struct wd_cipher_req *req, void *data)
|
||||
{
|
||||
@@ -361,7 +437,7 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
alg = WD_DIGEST_SHA512_256;
|
||||
break;
|
||||
default:
|
||||
- SEC_TST_PRT("Fail to set sec alg\n");
|
||||
+ SEC_TST_PRT("failed to set sec alg\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -391,7 +467,7 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
|
||||
list = wd_get_accel_list(alg);
|
||||
if (!list) {
|
||||
- SEC_TST_PRT("Fail to get %s device\n", alg);
|
||||
+ SEC_TST_PRT("failed to get %s device\n", alg);
|
||||
return -ENODEV;
|
||||
}
|
||||
memset(&g_ctx_cfg, 0, sizeof(struct wd_ctx_config));
|
||||
@@ -417,11 +493,11 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, max_node, wd_digest_poll_ctx);
|
||||
break;
|
||||
default:
|
||||
- SEC_TST_PRT("Fail to parse alg subtype!\n");
|
||||
+ SEC_TST_PRT("failed to parse alg subtype!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!g_sched) {
|
||||
- SEC_TST_PRT("Fail to alloc sched!\n");
|
||||
+ SEC_TST_PRT("failed to alloc sched!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -437,7 +513,7 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
param.end = g_ctxnum - 1;
|
||||
ret = wd_sched_rr_instance(g_sched, ¶m);
|
||||
if (ret) {
|
||||
- SEC_TST_PRT("Fail to fill sched data!\n");
|
||||
+ SEC_TST_PRT("failed to fill sched data!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -454,7 +530,7 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
break;
|
||||
}
|
||||
if (ret) {
|
||||
- SEC_TST_PRT("Fail to cipher ctx!\n");
|
||||
+ SEC_TST_PRT("failed to cipher ctx!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -484,7 +560,7 @@ static void uninit_ctx_config(int subtype)
|
||||
wd_digest_uninit();
|
||||
break;
|
||||
default:
|
||||
- SEC_TST_PRT("Fail to parse alg subtype on uninit!\n");
|
||||
+ SEC_TST_PRT("failed to parse alg subtype on uninit!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -494,23 +570,172 @@ static void uninit_ctx_config(int subtype)
|
||||
wd_sched_rr_release(g_sched);
|
||||
}
|
||||
|
||||
+static void get_aead_data(u8 *addr, u32 size)
|
||||
+{
|
||||
+ memset(addr, 0, size);
|
||||
+ memcpy(addr, aead_aad, SEC_AEAD_LEN);
|
||||
+}
|
||||
+
|
||||
+static void save_aead_dst_data(u8 *addr, u32 size)
|
||||
+{
|
||||
+ char file_name[SEC_SAVE_FILE_LEN] = {0};
|
||||
+ char *alg_name;
|
||||
+ FILE *fp;
|
||||
+
|
||||
+ alg_name = get_aead_alg_name(g_algtype);
|
||||
+ if (!alg_name) {
|
||||
+ SEC_TST_PRT("failed to get the aead alg name!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(file_name, SEC_SAVE_FILE_LEN, "ctext_%s_%u", alg_name, g_pktlen);
|
||||
+
|
||||
+ fp = fopen(file_name, "w");
|
||||
+ if (!fp) {
|
||||
+ SEC_TST_PRT("failed to open the ctext file!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(addr + size, g_uadk_pool.mac[0], SEC_PERF_AUTH_SIZE);
|
||||
+
|
||||
+ for (int i = 0; i < size + SEC_PERF_AUTH_SIZE; i++)
|
||||
+ fputc((char)addr[i], fp);
|
||||
+
|
||||
+ fclose(fp);
|
||||
+}
|
||||
+
|
||||
+static void read_aead_dst_data(u8 *addr, u32 len)
|
||||
+{
|
||||
+ char file_name[SEC_SAVE_FILE_LEN] = {0};
|
||||
+ char *alg_name;
|
||||
+ FILE *fp;
|
||||
+ int size;
|
||||
+
|
||||
+ alg_name = get_aead_alg_name(g_algtype);
|
||||
+ if (!alg_name) {
|
||||
+ SEC_TST_PRT("failed to get the aead alg name!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(file_name, SEC_SAVE_FILE_LEN, "ctext_%s_%u", alg_name, g_pktlen);
|
||||
+
|
||||
+ fp = fopen(file_name, "r");
|
||||
+ if (!fp) {
|
||||
+ SEC_TST_PRT("failed to open the ctext file!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ fseek(fp, 0, SEEK_END);
|
||||
+ size = ftell(fp);
|
||||
+
|
||||
+ rewind(fp);
|
||||
+ size = fread(addr, 1, size, fp);
|
||||
+ addr[size] = '\0';
|
||||
+
|
||||
+ memcpy(g_save_mac, (char *)addr + len, SEC_MAX_MAC_LEN);
|
||||
+
|
||||
+ fclose(fp);
|
||||
+}
|
||||
+
|
||||
+static int init_ivkey_source(void)
|
||||
+{
|
||||
+ int i, j, k, m, idx;
|
||||
+
|
||||
+ g_uadk_pool.iv = malloc(sizeof(char *) * g_thread_num);
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ g_uadk_pool.iv[i] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
+ if (!g_uadk_pool.iv[i])
|
||||
+ goto free_iv;
|
||||
+ }
|
||||
+
|
||||
+ g_uadk_pool.key = malloc(sizeof(char *) * g_thread_num);
|
||||
+ for (j = 0; j < g_thread_num; j++) {
|
||||
+ g_uadk_pool.key[j] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
+ if (!g_uadk_pool.key[j])
|
||||
+ goto free_key;
|
||||
+
|
||||
+ memcpy(g_uadk_pool.key[j], aead_key, SEC_PERF_KEY_LEN);
|
||||
+ }
|
||||
+
|
||||
+ g_uadk_pool.mac = malloc(sizeof(char *) * g_thread_num);
|
||||
+ for (k = 0; k < g_thread_num; k++) {
|
||||
+ g_uadk_pool.mac[k] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
+ if (!g_uadk_pool.mac[k])
|
||||
+ goto free_mac;
|
||||
+ }
|
||||
+
|
||||
+ g_uadk_pool.hash = malloc(sizeof(char *) * g_thread_num);
|
||||
+ for (m = 0; m < g_thread_num; m++) {
|
||||
+ g_uadk_pool.hash[m] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
+ if (!g_uadk_pool.hash[m])
|
||||
+ goto free_hash;
|
||||
+
|
||||
+ memcpy(g_uadk_pool.hash[m], aead_key, SEC_PERF_KEY_LEN);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+free_hash:
|
||||
+ for (idx = m - 1; idx >= 0; idx--)
|
||||
+ free(g_uadk_pool.hash[idx]);
|
||||
+ free(g_uadk_pool.hash);
|
||||
+
|
||||
+free_mac:
|
||||
+ for (idx = k - 1; idx >= 0; idx--)
|
||||
+ free(g_uadk_pool.mac[idx]);
|
||||
+
|
||||
+ free(g_uadk_pool.mac);
|
||||
+
|
||||
+free_key:
|
||||
+ for (idx = j - 1; idx >= 0; idx--)
|
||||
+ free(g_uadk_pool.key[idx]);
|
||||
+
|
||||
+ free(g_uadk_pool.key);
|
||||
+free_iv:
|
||||
+ for (idx = i - 1; idx >= 0; idx--)
|
||||
+ free(g_uadk_pool.iv[idx]);
|
||||
+
|
||||
+ free(g_uadk_pool.iv);
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static void free_ivkey_source(void)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ free(g_uadk_pool.hash[i]);
|
||||
+ free(g_uadk_pool.mac[i]);
|
||||
+ free(g_uadk_pool.key[i]);
|
||||
+ free(g_uadk_pool.iv[i]);
|
||||
+ }
|
||||
+
|
||||
+ free(g_uadk_pool.hash);
|
||||
+ free(g_uadk_pool.mac);
|
||||
+ free(g_uadk_pool.key);
|
||||
+ free(g_uadk_pool.iv);
|
||||
+}
|
||||
+
|
||||
static int init_uadk_bd_pool(void)
|
||||
{
|
||||
unsigned long step;
|
||||
int i, j;
|
||||
+ int ret;
|
||||
|
||||
// make the block not align to 4K
|
||||
step = sizeof(char) * g_pktlen * 2;
|
||||
|
||||
- g_uadk_pool.iv = malloc(g_thread_num * MAX_IVK_LENTH * sizeof(char));
|
||||
- g_uadk_pool.key = malloc(g_thread_num * MAX_IVK_LENTH * sizeof(char));
|
||||
- g_uadk_pool.mac = malloc(g_thread_num * MAX_IVK_LENTH * sizeof(char));
|
||||
- g_uadk_pool.hash = malloc(g_thread_num * MAX_IVK_LENTH * sizeof(char));
|
||||
+ ret = init_ivkey_source();
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("init uadk ivkey resource failed!\n");
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
|
||||
g_uadk_pool.pool = malloc(g_thread_num * sizeof(struct bd_pool));
|
||||
if (!g_uadk_pool.pool) {
|
||||
SEC_TST_PRT("init uadk pool alloc thread failed!\n");
|
||||
- return -ENOMEM;
|
||||
+ goto free_ivkey;
|
||||
} else {
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
g_uadk_pool.pool[i].bds = malloc(MAX_POOL_LENTH *
|
||||
@@ -527,10 +752,23 @@ static int init_uadk_bd_pool(void)
|
||||
if (!g_uadk_pool.pool[i].bds[j].dst)
|
||||
goto malloc_error3;
|
||||
|
||||
- get_rand_data(g_uadk_pool.pool[i].bds[j].src, g_pktlen);
|
||||
- if (g_prefetch)
|
||||
- get_rand_data(g_uadk_pool.pool[i].bds[j].dst, g_pktlen);
|
||||
+ if (g_alg != AEAD_TYPE) {
|
||||
+ get_rand_data(g_uadk_pool.pool[i].bds[j].src, g_pktlen);
|
||||
+ if (g_prefetch)
|
||||
+ get_rand_data(g_uadk_pool.pool[i].bds[j].dst,
|
||||
+ g_pktlen);
|
||||
+ } else {
|
||||
+ if (!g_optype)
|
||||
+ get_aead_data(g_uadk_pool.pool[i].bds[j].src,
|
||||
+ g_pktlen + SEC_AEAD_LEN);
|
||||
+ else
|
||||
+ read_aead_dst_data(g_uadk_pool.pool[i].bds[j].src,
|
||||
+ g_pktlen + SEC_AEAD_LEN);
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+ if (g_alg == AEAD_TYPE && g_optype)
|
||||
+ memcpy(g_uadk_pool.mac[i], g_save_mac, SEC_MAX_MAC_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,10 +793,8 @@ malloc_error1:
|
||||
free(g_uadk_pool.pool);
|
||||
g_uadk_pool.pool = NULL;
|
||||
|
||||
- free(g_uadk_pool.iv);
|
||||
- free(g_uadk_pool.key);
|
||||
- free(g_uadk_pool.mac);
|
||||
- free(g_uadk_pool.hash);
|
||||
+free_ivkey:
|
||||
+ free_ivkey_source();
|
||||
|
||||
SEC_TST_PRT("init uadk bd pool alloc failed!\n");
|
||||
return -ENOMEM;
|
||||
@@ -568,6 +804,11 @@ static void free_uadk_bd_pool(void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
+ /* save aad + ctext + mac */
|
||||
+ if (g_alg == AEAD_TYPE && !g_optype)
|
||||
+ save_aead_dst_data(g_uadk_pool.pool[0].bds[0].dst,
|
||||
+ g_pktlen + SEC_AEAD_LEN);
|
||||
+
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
if (g_uadk_pool.pool[i].bds) {
|
||||
for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
@@ -581,9 +822,7 @@ static void free_uadk_bd_pool(void)
|
||||
free(g_uadk_pool.pool);
|
||||
g_uadk_pool.pool = NULL;
|
||||
|
||||
- free(g_uadk_pool.iv);
|
||||
- free(g_uadk_pool.key);
|
||||
- free(g_uadk_pool.mac);
|
||||
+ free_ivkey_source();
|
||||
}
|
||||
|
||||
/*-------------------------------uadk benchmark main code-------------------------------------*/
|
||||
@@ -653,8 +892,8 @@ static void *sec_uadk_cipher_async(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_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);
|
||||
@@ -713,11 +952,11 @@ 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;
|
||||
+ u32 auth_size = SEC_PERF_AUTH_SIZE;
|
||||
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;
|
||||
|
||||
@@ -725,10 +964,10 @@ static void *sec_uadk_aead_async(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_hash = &g_uadk_pool.hash[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_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);
|
||||
@@ -768,7 +1007,7 @@ static void *sec_uadk_aead_async(void *arg)
|
||||
areq.mac = priv_mac;
|
||||
areq.iv_bytes = pdata->ivsize;
|
||||
areq.mac_bytes = auth_size;
|
||||
- areq.assoc_bytes = 16;
|
||||
+ areq.assoc_bytes = SEC_AEAD_LEN;
|
||||
areq.in_bytes = g_pktlen;
|
||||
if (pdata->is_union)
|
||||
areq.mac_bytes = 32;
|
||||
@@ -824,8 +1063,8 @@ static void *sec_uadk_digest_async(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_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);
|
||||
@@ -893,8 +1132,8 @@ static void *sec_uadk_cipher_sync(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_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);
|
||||
@@ -944,10 +1183,10 @@ 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_mac, *priv_hash;
|
||||
+ u32 auth_size = SEC_PERF_AUTH_SIZE;
|
||||
struct wd_aead_req areq;
|
||||
struct bd_pool *uadk_pool;
|
||||
handle_t h_sess;
|
||||
- u32 auth_size = 16;
|
||||
u32 count = 0;
|
||||
int ret, i;
|
||||
|
||||
@@ -955,10 +1194,11 @@ static void *sec_uadk_aead_sync(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_hash = &g_uadk_pool.hash[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_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);
|
||||
@@ -996,13 +1236,10 @@ static void *sec_uadk_aead_sync(void *arg)
|
||||
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.assoc_bytes = SEC_AEAD_LEN;
|
||||
areq.in_bytes = g_pktlen;
|
||||
- areq.mac_bytes = auth_size;
|
||||
- if (pdata->is_union)
|
||||
- areq.mac_bytes = 32;
|
||||
+ areq.mac_bytes = g_maclen;
|
||||
if (areq.op_type) // decrypto
|
||||
areq.out_bytes = g_pktlen + 16; // aadsize = 16;
|
||||
else
|
||||
@@ -1016,6 +1253,7 @@ static void *sec_uadk_aead_sync(void *arg)
|
||||
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;
|
||||
@@ -1045,8 +1283,8 @@ static void *sec_uadk_digest_sync(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_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);
|
||||
@@ -1119,7 +1357,9 @@ int sec_uadk_sync_threads(struct acc_option *options)
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
threads_args[i].subtype = threads_option.subtype;
|
||||
threads_args[i].alg = threads_option.alg;
|
||||
+ threads_args[i].dalg = threads_option.dalg;
|
||||
threads_args[i].mode = threads_option.mode;
|
||||
+ threads_args[i].is_union = threads_option.is_union;
|
||||
threads_args[i].keysize = threads_option.keysize;
|
||||
threads_args[i].ivsize = threads_option.ivsize;
|
||||
threads_args[i].optype = threads_option.optype;
|
||||
@@ -1185,7 +1425,9 @@ int sec_uadk_async_threads(struct acc_option *options)
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
threads_args[i].subtype = threads_option.subtype;
|
||||
threads_args[i].alg = threads_option.alg;
|
||||
+ threads_args[i].dalg = threads_option.dalg;
|
||||
threads_args[i].mode = threads_option.mode;
|
||||
+ threads_args[i].is_union = threads_option.is_union;
|
||||
threads_args[i].keysize = threads_option.keysize;
|
||||
threads_args[i].ivsize = threads_option.ivsize;
|
||||
threads_args[i].optype = threads_option.optype;
|
||||
@@ -1227,6 +1469,18 @@ int sec_uadk_benchmark(struct acc_option *options)
|
||||
g_pktlen = options->pktlen;
|
||||
g_ctxnum = options->ctxnums;
|
||||
g_prefetch = options->prefetch;
|
||||
+ g_alg = options->subtype;
|
||||
+ g_optype = options->optype;
|
||||
+ g_algtype = options->algtype;
|
||||
+
|
||||
+ if (g_alg == AEAD_TYPE) {
|
||||
+ g_maclen = get_aead_mac_len(g_algtype);
|
||||
+ if (g_maclen < 0) {
|
||||
+ SEC_TST_PRT("SEC algtype error: %u\n", g_algtype);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (options->optype > WD_CIPHER_DECRYPTION) {
|
||||
SEC_TST_PRT("SEC optype error: %u\n", options->optype);
|
||||
return -EINVAL;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
452
0053-uadk_tool-fix-hpre-test-code-issues.patch
Normal file
452
0053-uadk_tool-fix-hpre-test-code-issues.patch
Normal file
@ -0,0 +1,452 @@
|
||||
From 9a0b4eba99f8390bcfe6d594afb159dac4c53355 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:22 +0800
|
||||
Subject: [PATCH 53/85] uadk_tool: fix hpre test code issues
|
||||
|
||||
1.Change the ECC_CURVE_ID to 2 for secp256k1 test.
|
||||
2.Increase the block size for the nosva test.
|
||||
3.Modify the sample data of ecdsa 256 verify.
|
||||
4.Queues on multiple devices can be obtained.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/hpre_protocol_data.h | 77 ++++++++++++++--
|
||||
uadk_tool/benchmark/hpre_uadk_benchmark.c | 107 ++++++++++++++++++----
|
||||
uadk_tool/benchmark/hpre_wd_benchmark.c | 80 ++++++++++------
|
||||
3 files changed, 210 insertions(+), 54 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/hpre_protocol_data.h b/uadk_tool/benchmark/hpre_protocol_data.h
|
||||
index 9c92138..7bdb942 100644
|
||||
--- a/uadk_tool/benchmark/hpre_protocol_data.h
|
||||
+++ b/uadk_tool/benchmark/hpre_protocol_data.h
|
||||
@@ -1292,8 +1292,9 @@ static unsigned char ecc_except_kinv_secp256k1[] = {
|
||||
};
|
||||
|
||||
static unsigned char ecc_except_e_secp256k1[] = {
|
||||
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04
|
||||
+ 0x3a, 0x10, 0x3a, 0x4e, 0x57, 0x29, 0xad, 0x68, 0xc0, 0x2a, 0x67, 0x8a,
|
||||
+ 0xe3, 0x9a, 0xcc, 0xfb, 0xc0, 0xae, 0x20, 0x80, 0x96, 0x43, 0x74, 0x01,
|
||||
+ 0xb7, 0xce, 0xab, 0x63, 0xcc, 0xa0, 0x62, 0x2f
|
||||
};
|
||||
|
||||
static unsigned char ecc_cp_sign_secp256k1[] = {
|
||||
@@ -1649,19 +1650,75 @@ static unsigned char sm2_ciphertext_l[609] = {
|
||||
|
||||
static unsigned char sm2_pubkey[] = {
|
||||
0x04,
|
||||
- 0x09, 0xf9, 0xdf, 0x31, 0x1e, 0x54, 0x21, 0xa1, 0x50, 0xdd, 0x7d, 0x16, 0x1e, 0x4b, 0xc5, 0xc6,
|
||||
- 0x72, 0x17, 0x9f, 0xad, 0x18, 0x33, 0xfc, 0x07, 0x6b, 0xb0, 0x8f, 0xf3, 0x56, 0xf3, 0x50, 0x20,
|
||||
- 0xcc, 0xea, 0x49, 0x0c, 0xe2, 0x67, 0x75, 0xa5, 0x2d, 0xc6, 0xea, 0x71, 0x8c, 0xc1, 0xaa, 0x60,
|
||||
- 0x0a, 0xed, 0x05, 0xfb, 0xf3, 0x5e, 0x08, 0x4a, 0x66, 0x32, 0xf6, 0x07, 0x2d, 0xa9, 0xad, 0x13
|
||||
+ 0x09, 0xf9, 0xdf, 0x31, 0x1e, 0x54, 0x21, 0xa1, 0x50, 0xdd, 0x7d, 0x16,
|
||||
+ 0x1e, 0x4b, 0xc5, 0xc6, 0x72, 0x17, 0x9f, 0xad, 0x18, 0x33, 0xfc, 0x07,
|
||||
+ 0x6b, 0xb0, 0x8f, 0xf3, 0x56, 0xf3, 0x50, 0x20,
|
||||
+ 0xcc, 0xea, 0x49, 0x0c, 0xe2, 0x67, 0x75, 0xa5, 0x2d, 0xc6, 0xea, 0x71,
|
||||
+ 0x8c, 0xc1, 0xaa, 0x60, 0x0a, 0xed, 0x05, 0xfb, 0xf3, 0x5e, 0x08, 0x4a,
|
||||
+ 0x66, 0x32, 0xf6, 0x07, 0x2d, 0xa9, 0xad, 0x13
|
||||
};
|
||||
|
||||
static unsigned char sm2_priv[] = {
|
||||
- 0x39, 0x45, 0x20, 0x8f, 0x7b, 0x21, 0x44, 0xb1, 0x3f, 0x36, 0xe3, 0x8a, 0xc6, 0xd3, 0x9f, 0x95,
|
||||
- 0x88, 0x93, 0x93, 0x69, 0x28, 0x60, 0xb5, 0x1a, 0x42, 0xfb, 0x81, 0xef, 0x4d, 0xf7, 0xc5, 0xb8
|
||||
+ 0x39, 0x45, 0x20, 0x8f, 0x7b, 0x21, 0x44, 0xb1, 0x3f, 0x36, 0xe3, 0x8a,
|
||||
+ 0xc6, 0xd3, 0x9f, 0x95, 0x88, 0x93, 0x93, 0x69, 0x28, 0x60, 0xb5, 0x1a,
|
||||
+ 0x42, 0xfb, 0x81, 0xef, 0x4d, 0xf7, 0xc5, 0xb8
|
||||
};
|
||||
|
||||
static unsigned char sm2_digest[] = {
|
||||
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
- 0x00, 0x00, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
+ 0x65, 0x20, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74
|
||||
+};
|
||||
+
|
||||
+static char ecdsa_verf_p_secp256k1[] = {
|
||||
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
||||
+};
|
||||
+
|
||||
+static char ecdsa_verf_a_secp256k1[] = {
|
||||
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC
|
||||
+};
|
||||
+
|
||||
+static char ecdsa_verf_b_secp256k1[] = {
|
||||
+ 0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7, 0xB3, 0xEB, 0xBD, 0x55,
|
||||
+ 0x76, 0x98, 0x86, 0xBC, 0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6,
|
||||
+ 0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B
|
||||
+};
|
||||
+
|
||||
+static char ecdsa_verf_g_secp256k1[] = {
|
||||
+ 0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 0x47, 0xF8, 0xBC, 0xE6, 0xE5,
|
||||
+ 0x63, 0xA4, 0x40, 0xF2, 0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 0xA0,
|
||||
+ 0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 0x96,
|
||||
+ 0x4F, 0xE3, 0x42, 0xE2, 0xFE, 0x1A, 0x7F, 0x9B, 0x8E, 0xE7, 0xEB, 0x4A,
|
||||
+ 0x7C, 0x0F, 0x9E, 0x16, 0x2B, 0xCE, 0x33, 0x57, 0x6B, 0x31, 0x5E, 0xCE,
|
||||
+ 0xCB, 0xB6, 0x40, 0x68, 0x37, 0xBF, 0x51, 0xF5
|
||||
+};
|
||||
+
|
||||
+static char ecdsa_verf_n_secp256k1[] = {
|
||||
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84,
|
||||
+ 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51
|
||||
+};
|
||||
+
|
||||
+static char ecdsa_verf_sign_secp256k1[] = {
|
||||
+ 0x31, 0x28, 0x18, 0x0d, 0x19, 0x7c, 0xd1, 0xa5, 0xcb, 0x32, 0x95, 0x98,
|
||||
+ 0xb6, 0x5f, 0x8c, 0xb8, 0xdf, 0x0b, 0x4e, 0xf3, 0xef, 0x5e, 0x22, 0x79,
|
||||
+ 0x7f, 0xe0, 0xdb, 0xf0, 0x33, 0x59, 0x67, 0x01,
|
||||
+ 0xeb, 0xd1, 0xca, 0x09, 0x55, 0x6a, 0xbe, 0xd5, 0x32, 0x34, 0xfb, 0xb2,
|
||||
+ 0x4f, 0xfc, 0x7d, 0xa3, 0xd1, 0x6d, 0xc9, 0x65, 0x30, 0xca, 0x76, 0x3b,
|
||||
+ 0x09, 0xd5, 0xef, 0x6a, 0x65, 0x05, 0x0d, 0x23
|
||||
+};
|
||||
+
|
||||
+static char ecdh_verf_pubkey_secp256k1[] = {
|
||||
+ 0x04,
|
||||
+ 0xab, 0xd2, 0xd9, 0xec, 0x43, 0x60, 0xcc, 0x5b, 0x23, 0x5a, 0x80, 0x74,
|
||||
+ 0x2e, 0xbc, 0xb8, 0x36, 0x27, 0xe7, 0xb5, 0x4f, 0x72, 0xc3, 0x4a, 0x05,
|
||||
+ 0xe9, 0x70, 0x5a, 0x12, 0x8f, 0xab, 0x95, 0x7c,
|
||||
+ 0x6b, 0xf1, 0x84, 0x92, 0x46, 0x7b, 0x81, 0x4e, 0x28, 0x83, 0x25, 0xfb,
|
||||
+ 0x1f, 0x60, 0xe9, 0x98, 0xb6, 0x9f, 0xa0, 0xf4, 0x50, 0x3f, 0xa4, 0x1d,
|
||||
+ 0x4a, 0x4d, 0x87, 0xb8, 0xe6, 0xe4, 0x81, 0xd4
|
||||
};
|
||||
#endif
|
||||
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
index e3372fb..ffa1a85 100644
|
||||
--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
@@ -346,30 +346,40 @@ static int hpre_uadk_param_parse(thread_data *tddata, struct acc_option *options
|
||||
|
||||
static int init_hpre_ctx_config(char *alg, int subtype, int mode)
|
||||
{
|
||||
- struct uacce_dev_list *list;
|
||||
struct sched_params param;
|
||||
- int i, max_node;
|
||||
+ struct uacce_dev *dev;
|
||||
+ int max_node;
|
||||
int ret = 0;
|
||||
+ int i = 0;
|
||||
|
||||
max_node = numa_max_node() + 1;
|
||||
if (max_node <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
- list = wd_get_accel_list(alg);
|
||||
- if (!list) {
|
||||
- HPRE_TST_PRT("failed to get %s device\n", alg);
|
||||
- return -ENODEV;
|
||||
- }
|
||||
memset(&g_ctx_cfg, 0, sizeof(struct wd_ctx_config));
|
||||
g_ctx_cfg.ctx_num = g_ctxnum;
|
||||
g_ctx_cfg.ctxs = calloc(g_ctxnum, sizeof(struct wd_ctx));
|
||||
if (!g_ctx_cfg.ctxs)
|
||||
return -ENOMEM;
|
||||
|
||||
- for (i = 0; i < g_ctxnum; i++) {
|
||||
- g_ctx_cfg.ctxs[i].ctx = wd_request_ctx(list->dev);
|
||||
- g_ctx_cfg.ctxs[i].op_type = 0; // default op_type
|
||||
- g_ctx_cfg.ctxs[i].ctx_mode = (__u8)mode;
|
||||
+ while (i < g_ctxnum) {
|
||||
+ dev = wd_get_accel_dev(alg);
|
||||
+ if (!dev) {
|
||||
+ HPRE_TST_PRT("failed to get %s device\n", alg);
|
||||
+ ret = -EINVAL;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ for (; i < g_ctxnum; i++) {
|
||||
+ g_ctx_cfg.ctxs[i].ctx = wd_request_ctx(dev);
|
||||
+ if (!g_ctx_cfg.ctxs[i].ctx)
|
||||
+ break;
|
||||
+
|
||||
+ g_ctx_cfg.ctxs[i].op_type = 0; // default op_type
|
||||
+ g_ctx_cfg.ctxs[i].ctx_mode = (__u8)mode;
|
||||
+ }
|
||||
+
|
||||
+ free(dev);
|
||||
}
|
||||
|
||||
switch(subtype) {
|
||||
@@ -395,12 +405,8 @@ static int init_hpre_ctx_config(char *alg, int subtype, int mode)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- /* If there is no numa, we defualt config to zero */
|
||||
- if (list->dev->numa_id < 0)
|
||||
- list->dev->numa_id = 0;
|
||||
-
|
||||
g_sched->name = SCHED_SINGLE;
|
||||
- param.numa_id = list->dev->numa_id;
|
||||
+ param.numa_id = 0;
|
||||
param.type = 0;
|
||||
param.mode = mode;
|
||||
param.begin = 0;
|
||||
@@ -434,10 +440,11 @@ static int init_hpre_ctx_config(char *alg, int subtype, int mode)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- wd_free_list_accels(list);
|
||||
-
|
||||
return 0;
|
||||
out:
|
||||
+ for (i = i - 1; i >= 0; i--)
|
||||
+ wd_release_ctx(g_ctx_cfg.ctxs[i].ctx);
|
||||
+
|
||||
free(g_ctx_cfg.ctxs);
|
||||
wd_sched_rr_release(g_sched);
|
||||
|
||||
@@ -1964,6 +1971,38 @@ del_ecc_out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static void fill_ecc_param_data(struct wd_ecc_curve *ecc_pa,
|
||||
+ struct hpre_ecc_setup *ecc_set,
|
||||
+ u32 key_bits)
|
||||
+{
|
||||
+ u32 key_size = (key_bits + 7) / 8;
|
||||
+
|
||||
+ ecc_pa->a.data = ecdsa_verf_a_secp256k1;
|
||||
+ ecc_pa->b.data = ecdsa_verf_b_secp256k1;
|
||||
+ ecc_pa->p.data = ecdsa_verf_p_secp256k1;
|
||||
+ ecc_pa->n.data = ecdsa_verf_n_secp256k1;
|
||||
+ ecc_pa->g.x.data = ecdsa_verf_g_secp256k1;
|
||||
+ ecc_pa->g.y.data = ecdsa_verf_g_secp256k1 + key_size;
|
||||
+
|
||||
+ ecc_set->sign = ecdsa_verf_sign_secp256k1;
|
||||
+ ecc_set->sign_size = sizeof(ecdsa_verf_sign_secp256k1);
|
||||
+ ecc_set->pub_key = ecdh_verf_pubkey_secp256k1;
|
||||
+ ecc_set->pub_key_size = sizeof(ecdh_verf_pubkey_secp256k1);
|
||||
+
|
||||
+ ecc_pa->a.bsize = key_size;
|
||||
+ ecc_pa->a.dsize = key_size;
|
||||
+ ecc_pa->b.bsize = key_size;
|
||||
+ ecc_pa->b.dsize = key_size;
|
||||
+ ecc_pa->p.bsize = key_size;
|
||||
+ ecc_pa->p.dsize = key_size;
|
||||
+ ecc_pa->n.bsize = key_size;
|
||||
+ ecc_pa->n.dsize = key_size;
|
||||
+ ecc_pa->g.x.bsize = key_size;
|
||||
+ ecc_pa->g.x.dsize = key_size;
|
||||
+ ecc_pa->g.y.bsize = key_size;
|
||||
+ ecc_pa->g.y.dsize = key_size;
|
||||
+}
|
||||
+
|
||||
static void *ecc_uadk_sync_run(void *arg)
|
||||
{
|
||||
thread_data *pdata = (thread_data *)arg;
|
||||
@@ -1971,6 +2010,8 @@ static void *ecc_uadk_sync_run(void *arg)
|
||||
u32 subtype = pdata->subtype;
|
||||
struct wd_ecc_sess_setup sess_setup;
|
||||
struct hpre_ecc_setup setup;
|
||||
+ struct wd_ecc_curve_cfg cfg;
|
||||
+ struct wd_ecc_curve cv;
|
||||
struct wd_ecc_curve param;
|
||||
struct wd_ecc_key *ecc_key;
|
||||
struct wd_ecc_point pbk;
|
||||
@@ -2015,6 +2056,12 @@ static void *ecc_uadk_sync_run(void *arg)
|
||||
case ECDSA_TYPE:
|
||||
sess_setup.alg = "ecdsa";
|
||||
break;
|
||||
+ case X448_TYPE:
|
||||
+ sess_setup.alg = "x448";
|
||||
+ break;
|
||||
+ case X25519_TYPE:
|
||||
+ sess_setup.alg = "x25519";
|
||||
+ break;
|
||||
}
|
||||
|
||||
// set def setting;
|
||||
@@ -2025,6 +2072,14 @@ static void *ecc_uadk_sync_run(void *arg)
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
+ if (subtype == ECDSA_TYPE && key_size == 32) {
|
||||
+ fill_ecc_param_data(&cv, &setup, pdata->keybits);
|
||||
+
|
||||
+ cfg.type = WD_CV_CFG_PARAM;
|
||||
+ cfg.cfg.pparam = &cv;
|
||||
+ sess_setup.cv = cfg;
|
||||
+ }
|
||||
+
|
||||
h_sess = wd_ecc_alloc_sess(&sess_setup);
|
||||
if (!h_sess)
|
||||
goto msg_release;
|
||||
@@ -2113,6 +2168,8 @@ static void *ecc_uadk_async_run(void *arg)
|
||||
struct wd_ecc_sess_setup sess_setup;
|
||||
struct rsa_async_tag *tag;
|
||||
struct hpre_ecc_setup setup;
|
||||
+ struct wd_ecc_curve_cfg cfg;
|
||||
+ struct wd_ecc_curve cv;
|
||||
struct wd_ecc_curve param;
|
||||
struct wd_ecc_key *ecc_key;
|
||||
struct wd_ecc_point pbk;
|
||||
@@ -2158,6 +2215,12 @@ static void *ecc_uadk_async_run(void *arg)
|
||||
case ECDSA_TYPE:
|
||||
sess_setup.alg = "ecdsa";
|
||||
break;
|
||||
+ case X448_TYPE:
|
||||
+ sess_setup.alg = "x448";
|
||||
+ break;
|
||||
+ case X25519_TYPE:
|
||||
+ sess_setup.alg = "x25519";
|
||||
+ break;
|
||||
}
|
||||
|
||||
// set def setting;
|
||||
@@ -2168,6 +2231,14 @@ static void *ecc_uadk_async_run(void *arg)
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
+ if (subtype == ECDSA_TYPE && key_size == 32) {
|
||||
+ fill_ecc_param_data(&cv, &setup, pdata->keybits);
|
||||
+
|
||||
+ cfg.type = WD_CV_CFG_PARAM;
|
||||
+ cfg.cfg.pparam = &cv;
|
||||
+ sess_setup.cv = cfg;
|
||||
+ }
|
||||
+
|
||||
h_sess = wd_ecc_alloc_sess(&sess_setup);
|
||||
if (!h_sess)
|
||||
goto msg_release;
|
||||
diff --git a/uadk_tool/benchmark/hpre_wd_benchmark.c b/uadk_tool/benchmark/hpre_wd_benchmark.c
|
||||
index 2e23c95..67d57c6 100644
|
||||
--- a/uadk_tool/benchmark/hpre_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_wd_benchmark.c
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "v1/wd_bmm.h"
|
||||
#include "v1/wd_util.h"
|
||||
|
||||
-#define ECC_CURVE_ID 0x3 /* def set secp256k1 */
|
||||
+#define ECC_CURVE_ID 0x2 /* def set secp256k1 */
|
||||
#define HPRE_TST_PRT printf
|
||||
#define ERR_OPTYPE 0xFF
|
||||
#define SM2_DG_SZ 1024
|
||||
@@ -403,33 +403,9 @@ static int hpre_wd_get_block(u32 algtype)
|
||||
case DH_4096:
|
||||
block_size = 8192;
|
||||
break;
|
||||
- case ECDH_256:
|
||||
- block_size = 256;
|
||||
- break;
|
||||
- case ECDH_384:
|
||||
- block_size = 384;
|
||||
- break;
|
||||
- case ECDH_521:
|
||||
- block_size = 576;
|
||||
- break;
|
||||
- case ECDSA_256:
|
||||
- block_size = 256;
|
||||
- break;
|
||||
- case ECDSA_384:
|
||||
- block_size = 384;
|
||||
- break;
|
||||
- case ECDSA_521:
|
||||
+ default:
|
||||
block_size = 576;
|
||||
break;
|
||||
- case SM2_ALG:
|
||||
- block_size = 4352;
|
||||
- break;
|
||||
- case X25519_ALG:
|
||||
- block_size = 256;
|
||||
- break;
|
||||
- case X448_ALG:
|
||||
- block_size = 384;
|
||||
- break;
|
||||
}
|
||||
|
||||
return block_size;
|
||||
@@ -1759,6 +1735,38 @@ static int get_ecc_param_from_sample(struct hpre_ecc_setup *setup,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void fill_ecc_cv_data(struct wcrypto_ecc_curve *cv,
|
||||
+ struct hpre_ecc_setup *ecc_setup,
|
||||
+ u32 key_bits)
|
||||
+{
|
||||
+ u32 key_size = (key_bits + 7) / 8;
|
||||
+
|
||||
+ cv->a.data = ecdsa_verf_a_secp256k1;
|
||||
+ cv->b.data = ecdsa_verf_b_secp256k1;
|
||||
+ cv->p.data = ecdsa_verf_p_secp256k1;
|
||||
+ cv->n.data = ecdsa_verf_n_secp256k1;
|
||||
+ cv->g.x.data = ecdsa_verf_g_secp256k1;
|
||||
+ cv->g.y.data = ecdsa_verf_g_secp256k1 + key_size;
|
||||
+
|
||||
+ ecc_setup->sign = ecdsa_verf_sign_secp256k1;
|
||||
+ ecc_setup->sign_size = sizeof(ecdsa_verf_sign_secp256k1);
|
||||
+ ecc_setup->pub_key = ecdh_verf_pubkey_secp256k1;
|
||||
+ ecc_setup->pub_key_size = sizeof(ecdh_verf_pubkey_secp256k1);
|
||||
+
|
||||
+ cv->a.bsize = key_size;
|
||||
+ cv->a.dsize = key_size;
|
||||
+ cv->b.bsize = key_size;
|
||||
+ cv->b.dsize = key_size;
|
||||
+ cv->p.bsize = key_size;
|
||||
+ cv->p.dsize = key_size;
|
||||
+ cv->n.bsize = key_size;
|
||||
+ cv->n.dsize = key_size;
|
||||
+ cv->g.x.bsize = key_size;
|
||||
+ cv->g.x.dsize = key_size;
|
||||
+ cv->g.y.bsize = key_size;
|
||||
+ cv->g.y.dsize = key_size;
|
||||
+}
|
||||
+
|
||||
static int ecdsa_param_fill(void *ctx, struct wcrypto_ecc_op_data *opdata,
|
||||
struct wcrypto_ecc_key *ecc_key, struct hpre_ecc_setup *setup,
|
||||
thread_data *pdata)
|
||||
@@ -2060,6 +2068,8 @@ static void *ecc_wd_sync_run(void *arg)
|
||||
struct wcrypto_ecc_ctx_setup ctx_setup;
|
||||
struct wcrypto_ecc_op_data opdata;
|
||||
struct wcrypto_ecc_curve param;
|
||||
+ struct wcrypto_ecc_curve_cfg cfg;
|
||||
+ struct wcrypto_ecc_curve cv;
|
||||
struct hpre_ecc_setup setup;
|
||||
struct wcrypto_ecc_key *ecc_key;
|
||||
struct wcrypto_ecc_point pbk;
|
||||
@@ -2114,6 +2124,14 @@ static void *ecc_wd_sync_run(void *arg)
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
+ if (subtype == ECDSA_TYPE && key_size == 32) {
|
||||
+ fill_ecc_cv_data(&cv, &setup, pdata->keybits);
|
||||
+
|
||||
+ cfg.type = WCRYPTO_CV_CFG_PARAM;
|
||||
+ cfg.cfg.pparam = &cv;
|
||||
+ ctx_setup.cv = cfg;
|
||||
+ }
|
||||
+
|
||||
ctx = wcrypto_create_ecc_ctx(queue, &ctx_setup);
|
||||
if (!ctx)
|
||||
goto msg_release;
|
||||
@@ -2208,6 +2226,8 @@ static void *ecc_wd_async_run(void *arg)
|
||||
struct wcrypto_ecc_ctx_setup ctx_setup;
|
||||
struct wcrypto_ecc_op_data opdata;
|
||||
struct wcrypto_ecc_curve param;
|
||||
+ struct wcrypto_ecc_curve_cfg cfg;
|
||||
+ struct wcrypto_ecc_curve cv;
|
||||
struct hpre_ecc_setup setup;
|
||||
struct wcrypto_ecc_key *ecc_key;
|
||||
struct wcrypto_ecc_point pbk;
|
||||
@@ -2263,6 +2283,14 @@ static void *ecc_wd_async_run(void *arg)
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
+ if (subtype == ECDSA_TYPE && key_size == 32) {
|
||||
+ fill_ecc_cv_data(&cv, &setup, pdata->keybits);
|
||||
+
|
||||
+ cfg.type = WCRYPTO_CV_CFG_PARAM;
|
||||
+ cfg.cfg.pparam = &cv;
|
||||
+ ctx_setup.cv = cfg;
|
||||
+ }
|
||||
+
|
||||
ctx = wcrypto_create_ecc_ctx(queue, &ctx_setup);
|
||||
if (!ctx)
|
||||
goto msg_release;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
101
0054-uadk_tool-support-dual-sec-engine-device-testing.patch
Normal file
101
0054-uadk_tool-support-dual-sec-engine-device-testing.patch
Normal file
@ -0,0 +1,101 @@
|
||||
From d15cd3c19573154337cd5ab974ebc1e6891d6fee Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:23 +0800
|
||||
Subject: [PATCH 54/85] uadk_tool - support dual sec engine device testing
|
||||
|
||||
Support dual sec engine device perfmance testing. Users
|
||||
can configure half of the number of queues for each device.
|
||||
one thread configures one queue.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 44 ++++++++++++++----------
|
||||
1 file changed, 25 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index 36c7381..aed1b26 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -456,30 +456,38 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
|
||||
static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
{
|
||||
- struct uacce_dev_list *list;
|
||||
struct sched_params param;
|
||||
- int i, max_node;
|
||||
- int ret = 0;
|
||||
+ struct uacce_dev *dev = NULL;
|
||||
+ int ret, max_node, i;
|
||||
|
||||
max_node = numa_max_node() + 1;
|
||||
if (max_node <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
- list = wd_get_accel_list(alg);
|
||||
- if (!list) {
|
||||
- SEC_TST_PRT("failed to get %s device\n", alg);
|
||||
- return -ENODEV;
|
||||
- }
|
||||
memset(&g_ctx_cfg, 0, sizeof(struct wd_ctx_config));
|
||||
g_ctx_cfg.ctx_num = g_ctxnum;
|
||||
g_ctx_cfg.ctxs = calloc(g_ctxnum, sizeof(struct wd_ctx));
|
||||
if (!g_ctx_cfg.ctxs)
|
||||
return -ENOMEM;
|
||||
|
||||
- for (i = 0; i < g_ctxnum; i++) {
|
||||
- g_ctx_cfg.ctxs[i].ctx = wd_request_ctx(list->dev);
|
||||
- g_ctx_cfg.ctxs[i].op_type = 0; // default op_type
|
||||
- g_ctx_cfg.ctxs[i].ctx_mode = (__u8)mode;
|
||||
+ i = 0;
|
||||
+ while (i < g_ctxnum) {
|
||||
+ dev = wd_get_accel_dev(alg);
|
||||
+ if (!dev) {
|
||||
+ SEC_TST_PRT("failed to get %s device\n", alg);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ for (; i < g_ctxnum; i++) {
|
||||
+ g_ctx_cfg.ctxs[i].ctx = wd_request_ctx(dev);
|
||||
+ if (!g_ctx_cfg.ctxs[i].ctx)
|
||||
+ break;
|
||||
+
|
||||
+ g_ctx_cfg.ctxs[i].op_type = 0; // default op_type
|
||||
+ g_ctx_cfg.ctxs[i].ctx_mode = (__u8)mode;
|
||||
+ }
|
||||
+
|
||||
+ free(dev);
|
||||
}
|
||||
|
||||
switch(subtype) {
|
||||
@@ -501,12 +509,8 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- /* If there is no numa, we defualt config to zero */
|
||||
- if (list->dev->numa_id < 0)
|
||||
- list->dev->numa_id = 0;
|
||||
-
|
||||
g_sched->name = SCHED_SINGLE;
|
||||
- param.numa_id = list->dev->numa_id;
|
||||
+ param.numa_id = 0;
|
||||
param.type = 0;
|
||||
param.mode = mode;
|
||||
param.begin = 0;
|
||||
@@ -534,10 +538,12 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- wd_free_list_accels(list);
|
||||
-
|
||||
return 0;
|
||||
+
|
||||
out:
|
||||
+ for (i--; i >= 0; i--)
|
||||
+ wd_release_ctx(g_ctx_cfg.ctxs[i].ctx);
|
||||
+
|
||||
free(g_ctx_cfg.ctxs);
|
||||
wd_sched_rr_release(g_sched);
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
442
0055-uadk_tool-Support-performance-test-for-TRNG.patch
Normal file
442
0055-uadk_tool-Support-performance-test-for-TRNG.patch
Normal file
@ -0,0 +1,442 @@
|
||||
From e018308c64d35b73779298ffb361031a30a9426e Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:24 +0800
|
||||
Subject: [PATCH 55/85] uadk_tool: Support performance test for TRNG.
|
||||
|
||||
Support performance test for TRNG.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/Makefile.am | 1 +
|
||||
uadk_tool/benchmark/trng_wd_benchmark.c | 324 ++++++++++++++++++++++++
|
||||
uadk_tool/benchmark/trng_wd_benchmark.h | 7 +
|
||||
uadk_tool/benchmark/uadk_benchmark.c | 14 +
|
||||
uadk_tool/benchmark/uadk_benchmark.h | 2 +
|
||||
5 files changed, 348 insertions(+)
|
||||
create mode 100644 uadk_tool/benchmark/trng_wd_benchmark.c
|
||||
create mode 100644 uadk_tool/benchmark/trng_wd_benchmark.h
|
||||
|
||||
diff --git a/uadk_tool/Makefile.am b/uadk_tool/Makefile.am
|
||||
index 62372d8..6b787f9 100644
|
||||
--- a/uadk_tool/Makefile.am
|
||||
+++ b/uadk_tool/Makefile.am
|
||||
@@ -15,6 +15,7 @@ uadk_tool_SOURCES=uadk_tool.c dfx/uadk_dfx.c dfx/uadk_dfx.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
|
||||
|
||||
diff --git a/uadk_tool/benchmark/trng_wd_benchmark.c b/uadk_tool/benchmark/trng_wd_benchmark.c
|
||||
new file mode 100644
|
||||
index 0000000..64942f0
|
||||
--- /dev/null
|
||||
+++ b/uadk_tool/benchmark/trng_wd_benchmark.c
|
||||
@@ -0,0 +1,324 @@
|
||||
+/* SPDX-License-Identifier: Apache-2.0 */
|
||||
+
|
||||
+#include <numa.h>
|
||||
+#include "uadk_benchmark.h"
|
||||
+
|
||||
+#include "trng_wd_benchmark.h"
|
||||
+#include "v1/wd.h"
|
||||
+#include "v1/wd_rng.h"
|
||||
+
|
||||
+struct thread_bd_res {
|
||||
+ struct wd_queue *queue;
|
||||
+ void *out;
|
||||
+ __u32 in_bytes;
|
||||
+};
|
||||
+
|
||||
+struct thread_queue_res {
|
||||
+ struct thread_bd_res *bd_res;
|
||||
+};
|
||||
+
|
||||
+struct wd_thread_res {
|
||||
+ u32 td_id;
|
||||
+ u32 pollid;
|
||||
+};
|
||||
+
|
||||
+struct trng_async_tag {
|
||||
+ void *ctx;
|
||||
+ int optype;
|
||||
+};
|
||||
+
|
||||
+static unsigned int g_thread_num;
|
||||
+static struct thread_queue_res g_thread_queue;
|
||||
+
|
||||
+static int init_trng_wd_queue(struct acc_option *options)
|
||||
+{
|
||||
+ int i, ret;
|
||||
+
|
||||
+ g_thread_queue.bd_res = malloc(g_thread_num * sizeof(struct thread_bd_res));
|
||||
+ if (!g_thread_queue.bd_res) {
|
||||
+ printf("failed to malloc thread res memory!\n");
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ g_thread_queue.bd_res[i].queue = malloc(sizeof(struct wd_queue));
|
||||
+ if (!g_thread_queue.bd_res[i].queue) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto free_mem;
|
||||
+ }
|
||||
+
|
||||
+ g_thread_queue.bd_res[i].queue->capa.alg = options->algclass;
|
||||
+ /* nodemask need to be clean */
|
||||
+ g_thread_queue.bd_res[i].queue->node_mask = 0x0;
|
||||
+ memset(g_thread_queue.bd_res[i].queue->dev_path, 0x0, PATH_STR_SIZE);
|
||||
+
|
||||
+ g_thread_queue.bd_res[i].in_bytes = options->pktlen;
|
||||
+ g_thread_queue.bd_res[i].out = malloc(options->pktlen);
|
||||
+ if (!g_thread_queue.bd_res[i].queue) {
|
||||
+ free(g_thread_queue.bd_res[i].queue);
|
||||
+ ret = -ENOMEM;
|
||||
+ goto free_mem;
|
||||
+ }
|
||||
+
|
||||
+ ret = wd_request_queue(g_thread_queue.bd_res[i].queue);
|
||||
+ if (ret) {
|
||||
+ printf("failed to request queue %d, ret = %d!\n", i, ret);
|
||||
+ free(g_thread_queue.bd_res[i].out);
|
||||
+ free(g_thread_queue.bd_res[i].queue);
|
||||
+ goto free_mem;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+free_mem:
|
||||
+ for (i = i - 1; i >= 0; i--) {
|
||||
+ wd_release_queue(g_thread_queue.bd_res[i].queue);
|
||||
+ free(g_thread_queue.bd_res[i].out);
|
||||
+ free(g_thread_queue.bd_res[i].queue);
|
||||
+ }
|
||||
+
|
||||
+ free(g_thread_queue.bd_res);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void uninit_trng_wd_queue(void)
|
||||
+{
|
||||
+ int j;
|
||||
+
|
||||
+ for (j = 0; j < g_thread_num; j++) {
|
||||
+ wd_release_queue(g_thread_queue.bd_res[j].queue);
|
||||
+ free(g_thread_queue.bd_res[j].out);
|
||||
+ free(g_thread_queue.bd_res[j].queue);
|
||||
+ }
|
||||
+
|
||||
+ free(g_thread_queue.bd_res);
|
||||
+}
|
||||
+
|
||||
+static void *trng_wd_sync_run(void *arg)
|
||||
+{
|
||||
+ struct wd_thread_res *pdata = (struct wd_thread_res *)arg;
|
||||
+ struct wcrypto_rng_ctx_setup trng_setup;
|
||||
+ struct wcrypto_rng_op_data opdata;
|
||||
+ struct wd_queue *queue;
|
||||
+ void *ctx = NULL;
|
||||
+ u32 count = 0;
|
||||
+ int ret;
|
||||
+
|
||||
+ queue = g_thread_queue.bd_res[pdata->td_id].queue;
|
||||
+ ctx = wcrypto_create_rng_ctx(queue, &trng_setup);
|
||||
+ if (!ctx)
|
||||
+ return NULL;
|
||||
+
|
||||
+ memset(&opdata, 0, sizeof(opdata));
|
||||
+ opdata.in_bytes = g_thread_queue.bd_res[pdata->td_id].in_bytes;
|
||||
+ opdata.out = g_thread_queue.bd_res[pdata->td_id].out;
|
||||
+ opdata.op_type = WCRYPTO_TRNG_GEN;
|
||||
+
|
||||
+ do {
|
||||
+ ret = wcrypto_do_rng(ctx, &opdata, NULL);
|
||||
+ if (ret) {
|
||||
+ printf("failed to do rng task, ret: %d\n", ret);
|
||||
+ goto ctx_release;
|
||||
+ }
|
||||
+
|
||||
+ count++;
|
||||
+ if (get_run_state() == 0)
|
||||
+ break;
|
||||
+ } while (true);
|
||||
+
|
||||
+ctx_release:
|
||||
+ wcrypto_del_rng_ctx(ctx);
|
||||
+ add_recv_data(count, opdata.in_bytes);
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void trng_wd_sync_threads(void)
|
||||
+{
|
||||
+ struct wd_thread_res threads_args[THREADS_NUM];
|
||||
+ pthread_t tdid[THREADS_NUM];
|
||||
+ int i, ret;
|
||||
+
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ threads_args[i].td_id = i;
|
||||
+ ret = pthread_create(&tdid[i], NULL, trng_wd_sync_run, &threads_args[i]);
|
||||
+ if (ret) {
|
||||
+ printf("failed to create sync thread!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* join thread */
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ ret = pthread_join(tdid[i], NULL);
|
||||
+ if (ret) {
|
||||
+ printf("failed to join sync thread!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void *wd_trng_poll(void *data)
|
||||
+{
|
||||
+ struct wd_thread_res *pdata = (struct wd_thread_res *)data;
|
||||
+ struct wd_queue *queue;
|
||||
+ u32 last_time = 2; // poll need one more recv time
|
||||
+ u32 count = 0;
|
||||
+ u32 in_bytes;
|
||||
+ int recv;
|
||||
+
|
||||
+ in_bytes = g_thread_queue.bd_res[pdata->pollid].in_bytes;
|
||||
+ queue = g_thread_queue.bd_res[pdata->pollid].queue;
|
||||
+
|
||||
+ while (last_time) {
|
||||
+ recv = wcrypto_rng_poll(queue, ACC_QUEUE_SIZE);
|
||||
+ if (recv < 0) {
|
||||
+ printf("failed to recv bd, ret: %d!\n", recv);
|
||||
+ goto recv_error;
|
||||
+ }
|
||||
+ count += recv;
|
||||
+
|
||||
+ if (get_run_state() == 0)
|
||||
+ last_time--;
|
||||
+ }
|
||||
+
|
||||
+recv_error:
|
||||
+ add_recv_data(count, in_bytes);
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void *trng_async_cb(const void *msg, void *tag)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void *wd_trng_async_run(void *arg)
|
||||
+{
|
||||
+ struct wd_thread_res *pdata = (struct wd_thread_res *)arg;
|
||||
+ struct wcrypto_rng_ctx_setup trng_setup;
|
||||
+ struct wcrypto_rng_op_data opdata;
|
||||
+ struct trng_async_tag *tag = NULL;
|
||||
+ struct wd_queue *queue;
|
||||
+ void *ctx = NULL;
|
||||
+ int ret, i;
|
||||
+
|
||||
+ memset(&opdata, 0, sizeof(opdata));
|
||||
+
|
||||
+ queue = g_thread_queue.bd_res[pdata->td_id].queue;
|
||||
+ trng_setup.cb = (void *)trng_async_cb;
|
||||
+
|
||||
+ ctx = wcrypto_create_rng_ctx(queue, &trng_setup);
|
||||
+ if (!ctx)
|
||||
+ return NULL;
|
||||
+
|
||||
+ opdata.in_bytes = g_thread_queue.bd_res[pdata->td_id].in_bytes;
|
||||
+ opdata.out = g_thread_queue.bd_res[pdata->td_id].out;
|
||||
+ opdata.op_type = WCRYPTO_TRNG_GEN;
|
||||
+
|
||||
+ tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
+ if (!tag) {
|
||||
+ printf("failed to malloc dh tag!\n");
|
||||
+ goto free_ctx;
|
||||
+ }
|
||||
+ tag->ctx = ctx;
|
||||
+
|
||||
+ do {
|
||||
+ ret = wcrypto_do_rng(ctx, &opdata, tag);
|
||||
+ if (ret && ret != -WD_EBUSY) {
|
||||
+ printf("failed to send trng task, ret = %d!\n", ret);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (get_run_state() == 0)
|
||||
+ break;
|
||||
+ } while (true);
|
||||
+
|
||||
+ /* Release memory after all tasks are complete. */
|
||||
+ i = 0;
|
||||
+ while (get_recv_time() != g_thread_num) {
|
||||
+ if (i++ >= MAX_TRY_CNT) {
|
||||
+ printf("failed to wait poll thread finish!\n");
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ usleep(SEND_USLEEP);
|
||||
+ }
|
||||
+
|
||||
+ if (tag)
|
||||
+ free(tag);
|
||||
+free_ctx:
|
||||
+ wcrypto_del_rng_ctx(ctx);
|
||||
+ add_send_complete();
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void trng_wd_async_threads(void)
|
||||
+{
|
||||
+ struct wd_thread_res threads_args[THREADS_NUM];
|
||||
+ pthread_t tdid[THREADS_NUM];
|
||||
+ pthread_t pollid[THREADS_NUM];
|
||||
+ int i, ret;
|
||||
+
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ threads_args[i].pollid = i;
|
||||
+ /* poll thread */
|
||||
+ ret = pthread_create(&pollid[i], NULL, wd_trng_poll, &threads_args[i]);
|
||||
+ if (ret) {
|
||||
+ printf("failed to create poll thread!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ threads_args[i].td_id = i;
|
||||
+ ret = pthread_create(&tdid[i], NULL, wd_trng_async_run, &threads_args[i]);
|
||||
+ if (ret) {
|
||||
+ printf("failed to create async thread!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* join thread */
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ ret = pthread_join(tdid[i], NULL);
|
||||
+ if (ret) {
|
||||
+ printf("failed to join async thread!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ ret = pthread_join(pollid[i], NULL);
|
||||
+ if (ret) {
|
||||
+ printf("failed to join poll thread!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int trng_wd_benchmark(struct acc_option *options)
|
||||
+{
|
||||
+ u32 ptime;
|
||||
+ int ret;
|
||||
+
|
||||
+ g_thread_num = options->threads;
|
||||
+
|
||||
+ ret = init_trng_wd_queue(options);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ get_pid_cpu_time(&ptime);
|
||||
+ time_start(options->times);
|
||||
+ if (options->syncmode)
|
||||
+ trng_wd_async_threads();
|
||||
+ else
|
||||
+ trng_wd_sync_threads();
|
||||
+ cal_perfermance_data(options, ptime);
|
||||
+
|
||||
+ uninit_trng_wd_queue();
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/uadk_tool/benchmark/trng_wd_benchmark.h b/uadk_tool/benchmark/trng_wd_benchmark.h
|
||||
new file mode 100644
|
||||
index 0000000..49453c8
|
||||
--- /dev/null
|
||||
+++ b/uadk_tool/benchmark/trng_wd_benchmark.h
|
||||
@@ -0,0 +1,7 @@
|
||||
+/* SPDX-License-Identifier: Apache-2.0 */
|
||||
+
|
||||
+#ifndef TRNG_WD_BENCHMARK_H
|
||||
+#define TRNG_WD_BENCHMARK_H
|
||||
+
|
||||
+extern int trng_wd_benchmark(struct acc_option *options);
|
||||
+#endif /* TRNG_WD_BENCHMARK_H */
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
index f36cc4b..f903829 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "zip_uadk_benchmark.h"
|
||||
#include "zip_wd_benchmark.h"
|
||||
|
||||
+#include "trng_wd_benchmark.h"
|
||||
+
|
||||
#define TABLE_SPACE_SIZE 8
|
||||
|
||||
/*----------------------------------------head struct--------------------------------------------------------*/
|
||||
@@ -131,6 +133,7 @@ static struct acc_alg_item alg_options[] = {
|
||||
{"sha512", SHA512_ALG},
|
||||
{"sha512-224", SHA512_224},
|
||||
{"sha512-256", SHA512_256},
|
||||
+ {"trng", TRNG},
|
||||
{"", ALG_MAX}
|
||||
};
|
||||
|
||||
@@ -345,6 +348,11 @@ static void parse_alg_param(struct acc_option *option)
|
||||
option->acctype = HPRE_TYPE;
|
||||
option->subtype = X448_TYPE;
|
||||
break;
|
||||
+ case TRNG:
|
||||
+ snprintf(option->algclass, MAX_ALG_NAME, "%s", "trng");
|
||||
+ option->acctype = TRNG_TYPE;
|
||||
+ option->subtype = DEFAULT_TYPE;
|
||||
+ break;
|
||||
default:
|
||||
if (option->algtype <= RSA_4096_CRT) {
|
||||
snprintf(option->algclass, MAX_ALG_NAME, "%s", "rsa");
|
||||
@@ -456,6 +464,12 @@ static int benchmark_run(struct acc_option *option)
|
||||
} else if (option->modetype & NOSVA_MODE) {
|
||||
ret = zip_wd_benchmark(option);
|
||||
}
|
||||
+ case TRNG_TYPE:
|
||||
+ if (option->modetype & SVA_MODE)
|
||||
+ ACC_TST_PRT("TRNG not support sva mode..\n");
|
||||
+ else if (option->modetype & NOSVA_MODE)
|
||||
+ ret = trng_wd_benchmark(option);
|
||||
+
|
||||
break;
|
||||
}
|
||||
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
index 2c8de11..44e2dd9 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.h
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
@@ -78,6 +78,7 @@ enum acc_type {
|
||||
SEC_TYPE,
|
||||
HPRE_TYPE,
|
||||
ZIP_TYPE,
|
||||
+ TRNG_TYPE,
|
||||
};
|
||||
|
||||
enum alg_type {
|
||||
@@ -174,6 +175,7 @@ enum test_alg {
|
||||
SHA512_ALG,
|
||||
SHA512_224,
|
||||
SHA512_256, // digest key all set 4 Bytes
|
||||
+ TRNG,
|
||||
ALG_MAX,
|
||||
};
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
427
0056-uadk-tools-support-new-parameters-for-compression.patch
Normal file
427
0056-uadk-tools-support-new-parameters-for-compression.patch
Normal file
@ -0,0 +1,427 @@
|
||||
From 8591a69ee1ce5a796390bde817813aaa61f40cf8 Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:25 +0800
|
||||
Subject: [PATCH 56/85] uadk/tools - support new parameters for compression
|
||||
|
||||
Support the new configure parameters for uadk compression.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/uadk_benchmark.c | 46 ++++++++++--------
|
||||
uadk_tool/benchmark/uadk_benchmark.h | 8 ++--
|
||||
uadk_tool/benchmark/zip_uadk_benchmark.c | 61 +++++++++++++++---------
|
||||
uadk_tool/benchmark/zip_wd_benchmark.c | 34 ++++++++-----
|
||||
4 files changed, 91 insertions(+), 58 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
index f903829..d869688 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
@@ -429,7 +429,7 @@ void cal_perfermance_data(struct acc_option *option, u32 sttime)
|
||||
ops = perfops / option->times;
|
||||
cpu_rate = (double)ptime / option->times;
|
||||
ACC_TST_PRT("algname: length: perf: iops: CPU_rate:\n"
|
||||
- "%s %-2uBytes %.1fKB/s %.1fKops %.2f%%\n",
|
||||
+ "%s %-2uBytes %.1fKB/s %.1fKops %.2f%%\n",
|
||||
palgname, option->pktlen, perfermance, ops, cpu_rate);
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ int acc_default_case(struct acc_option *option)
|
||||
option->multis = 1;
|
||||
option->ctxnums = 2;
|
||||
|
||||
- return acc_benchmark_run(option);
|
||||
+ return acc_benchmark_run(option);
|
||||
}
|
||||
|
||||
static void print_help(void)
|
||||
@@ -634,21 +634,23 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
||||
int c;
|
||||
|
||||
static struct option long_options[] = {
|
||||
- {"alg", required_argument, 0, 1},
|
||||
- {"mode", required_argument, 0, 2},
|
||||
- {"opt", required_argument, 0, 3},
|
||||
- {"sync", no_argument, 0,4},
|
||||
- {"async", no_argument, 0,5},
|
||||
- {"pktlen", required_argument, 0, 6},
|
||||
- {"seconds", required_argument, 0, 7},
|
||||
- {"thread", required_argument, 0, 8},
|
||||
- {"multi", required_argument, 0, 9},
|
||||
- {"ctxnum", required_argument, 0, 10},
|
||||
- {"prefetch", no_argument, 0,11},
|
||||
- {"engine", required_argument, 0,12},
|
||||
- {"alglist", no_argument, 0, 13},
|
||||
- {"latency", no_argument, 0, 14},
|
||||
- {"help", no_argument, 0, 15},
|
||||
+ {"help", no_argument, 0, 0},
|
||||
+ {"alg", required_argument, 0, 1},
|
||||
+ {"mode", required_argument, 0, 2},
|
||||
+ {"opt", required_argument, 0, 3},
|
||||
+ {"sync", no_argument, 0, 4},
|
||||
+ {"async", no_argument, 0, 5},
|
||||
+ {"pktlen", required_argument, 0, 6},
|
||||
+ {"seconds", required_argument, 0, 7},
|
||||
+ {"thread", required_argument, 0, 8},
|
||||
+ {"multi", required_argument, 0, 9},
|
||||
+ {"ctxnum", required_argument, 0, 10},
|
||||
+ {"prefetch", no_argument, 0, 11},
|
||||
+ {"engine", required_argument, 0, 12},
|
||||
+ {"alglist", no_argument, 0, 13},
|
||||
+ {"latency", no_argument, 0, 14},
|
||||
+ {"winsize", required_argument, 0, 15},
|
||||
+ {"complevel", required_argument, 0, 16},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -658,6 +660,9 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
+ case 0:
|
||||
+ print_help();
|
||||
+ goto to_exit;
|
||||
case 1:
|
||||
option->algtype = get_alg_type(optarg);
|
||||
strcpy(option->algname, optarg);
|
||||
@@ -702,8 +707,11 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
||||
option->latency = true;
|
||||
break;
|
||||
case 15:
|
||||
- print_help();
|
||||
- goto to_exit;
|
||||
+ option->winsize = strtol(optarg, NULL, 0);
|
||||
+ break;
|
||||
+ case 16:
|
||||
+ option->complevel = strtol(optarg, NULL, 0);
|
||||
+ break;
|
||||
default:
|
||||
ACC_TST_PRT("bad input test parameter!\n");
|
||||
print_help();
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
index 44e2dd9..71fe2dc 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.h
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
@@ -55,7 +55,9 @@ typedef unsigned char u8;
|
||||
* @latency: test packet running time
|
||||
*/
|
||||
struct acc_option {
|
||||
- char algname[64];
|
||||
+ char algname[64];
|
||||
+ char algclass[64];
|
||||
+ char engine[64];
|
||||
u32 algtype;
|
||||
u32 modetype;
|
||||
u32 optype;
|
||||
@@ -65,12 +67,12 @@ struct acc_option {
|
||||
u32 threads;
|
||||
u32 multis;
|
||||
u32 ctxnums;
|
||||
- char algclass[64];
|
||||
u32 acctype;
|
||||
u32 subtype;
|
||||
- char engine[64];
|
||||
u32 engine_flag;
|
||||
u32 prefetch;
|
||||
+ u32 winsize;
|
||||
+ u32 complevel;
|
||||
bool latency;
|
||||
};
|
||||
|
||||
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
index d74d3fb..747172a 100644
|
||||
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
@@ -8,11 +8,11 @@
|
||||
#include "include/wd_sched.h"
|
||||
#include "include/fse.h"
|
||||
|
||||
-#define ZIP_TST_PRT printf
|
||||
-#define PATH_SIZE 64
|
||||
-#define ZIP_FILE "./zip"
|
||||
-#define COMP_LEN_RATE 2
|
||||
-#define DECOMP_LEN_RATE 2
|
||||
+#define ZIP_TST_PRT printf
|
||||
+#define PATH_SIZE 64
|
||||
+#define ZIP_FILE "./zip"
|
||||
+#define COMP_LEN_RATE 2
|
||||
+#define DECOMP_LEN_RATE 2
|
||||
|
||||
struct uadk_bd {
|
||||
u8 *src;
|
||||
@@ -44,9 +44,11 @@ struct zip_async_tag {
|
||||
|
||||
typedef struct uadk_thread_res {
|
||||
u32 alg;
|
||||
- u32 mode; // block/stream
|
||||
+ u32 mode;
|
||||
u32 optype;
|
||||
u32 td_id;
|
||||
+ u32 win_sz;
|
||||
+ u32 comp_lv;
|
||||
} thread_data;
|
||||
|
||||
struct zip_file_head {
|
||||
@@ -240,10 +242,10 @@ static int zip_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
return -EINVAL;
|
||||
} else if (optype >= WD_DIR_MAX) {
|
||||
mode = STREAM_MODE;
|
||||
+ optype = optype % WD_DIR_MAX;
|
||||
+ options->optype = optype;
|
||||
}
|
||||
|
||||
- optype = optype % WD_DIR_MAX;
|
||||
-
|
||||
switch(algtype) {
|
||||
case ZLIB:
|
||||
alg = WD_ZLIB;
|
||||
@@ -268,17 +270,20 @@ static int zip_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
tddata->alg = alg;
|
||||
tddata->mode = mode;
|
||||
tddata->optype = optype;
|
||||
+ tddata->win_sz = options->winsize;
|
||||
+ tddata->comp_lv = options->complevel;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static struct sched_params param;
|
||||
static int init_ctx_config(char *alg, int mode, int optype)
|
||||
{
|
||||
struct uacce_dev_list *list;
|
||||
- struct sched_params param;
|
||||
int i, max_node;
|
||||
int ret = 0;
|
||||
|
||||
+ optype = optype % WD_DIR_MAX;
|
||||
max_node = numa_max_node() + 1;
|
||||
if (max_node <= 0)
|
||||
return -EINVAL;
|
||||
@@ -306,7 +311,7 @@ static int init_ctx_config(char *alg, int mode, int optype)
|
||||
|
||||
for (i = 0; i < g_ctxnum; i++) {
|
||||
g_ctx_cfg.ctxs[i].ctx = wd_request_ctx(list->dev);
|
||||
- g_ctx_cfg.ctxs[i].op_type = 0; // default op_type
|
||||
+ g_ctx_cfg.ctxs[i].op_type = optype; // default op_type
|
||||
g_ctx_cfg.ctxs[i].ctx_mode = (__u8)mode;
|
||||
}
|
||||
g_sched->name = SCHED_SINGLE;
|
||||
@@ -315,7 +320,6 @@ static int init_ctx_config(char *alg, int mode, int optype)
|
||||
* All contexts for 2 modes & 2 types.
|
||||
* The test only uses one kind of contexts at the same time.
|
||||
*/
|
||||
- optype = optype % WD_DIR_MAX;
|
||||
param.numa_id = list->dev->numa_id;
|
||||
param.type = optype;
|
||||
param.mode = mode;
|
||||
@@ -546,8 +550,9 @@ static void *zip_uadk_blk_lz77_sync_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WD_COMP_L8;
|
||||
- comp_setup.win_sz = WD_COMP_WS_8K;
|
||||
+ comp_setup.win_sz = pdata->win_sz;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.sched_param = ¶m;
|
||||
h_sess = wd_comp_alloc_sess(&comp_setup);
|
||||
if (!h_sess)
|
||||
return NULL;
|
||||
@@ -639,8 +644,9 @@ static void *zip_uadk_stm_lz77_sync_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WD_COMP_L8;
|
||||
- comp_setup.win_sz = WD_COMP_WS_8K;
|
||||
+ comp_setup.win_sz = pdata->win_sz;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.sched_param = ¶m;
|
||||
h_sess = wd_comp_alloc_sess(&comp_setup);
|
||||
if (!h_sess)
|
||||
return NULL;
|
||||
@@ -733,8 +739,9 @@ static void *zip_uadk_blk_lz77_async_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WD_COMP_L8;
|
||||
- comp_setup.win_sz = WD_COMP_WS_8K;
|
||||
+ comp_setup.win_sz = pdata->win_sz;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.sched_param = ¶m;
|
||||
h_sess = wd_comp_alloc_sess(&comp_setup);
|
||||
if (!h_sess)
|
||||
return NULL;
|
||||
@@ -837,8 +844,9 @@ static void *zip_uadk_blk_sync_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WD_COMP_L8;
|
||||
- comp_setup.win_sz = WD_COMP_WS_8K;
|
||||
+ comp_setup.win_sz = pdata->win_sz;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.sched_param = ¶m;
|
||||
h_sess = wd_comp_alloc_sess(&comp_setup);
|
||||
if (!h_sess)
|
||||
return NULL;
|
||||
@@ -896,8 +904,9 @@ static void *zip_uadk_stm_sync_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WD_COMP_L8;
|
||||
- comp_setup.win_sz = WD_COMP_WS_8K;
|
||||
+ comp_setup.win_sz = pdata->win_sz;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.sched_param = ¶m;
|
||||
h_sess = wd_comp_alloc_sess(&comp_setup);
|
||||
if (!h_sess)
|
||||
return NULL;
|
||||
@@ -961,8 +970,9 @@ static void *zip_uadk_blk_async_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WD_COMP_L8;
|
||||
- comp_setup.win_sz = WD_COMP_WS_8K;
|
||||
+ comp_setup.win_sz = pdata->win_sz;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.sched_param = ¶m;
|
||||
h_sess = wd_comp_alloc_sess(&comp_setup);
|
||||
if (!h_sess)
|
||||
return NULL;
|
||||
@@ -1044,6 +1054,7 @@ static int zip_uadk_sync_threads(struct acc_option *options)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
+ threads_option.optype = options->optype;
|
||||
if (threads_option.mode == 1) {// stream mode
|
||||
if (threads_option.alg == LZ77_ZSTD)
|
||||
uadk_zip_sync_run = zip_uadk_stm_lz77_sync_run;
|
||||
@@ -1059,6 +1070,8 @@ static int zip_uadk_sync_threads(struct acc_option *options)
|
||||
threads_args[i].alg = threads_option.alg;
|
||||
threads_args[i].mode = threads_option.mode;
|
||||
threads_args[i].optype = threads_option.optype;
|
||||
+ threads_args[i].win_sz = threads_option.win_sz;
|
||||
+ threads_args[i].comp_lv = threads_option.comp_lv;
|
||||
threads_args[i].td_id = i;
|
||||
ret = pthread_create(&tdid[i], NULL, uadk_zip_sync_run, &threads_args[i]);
|
||||
if (ret) {
|
||||
@@ -1119,6 +1132,8 @@ static int zip_uadk_async_threads(struct acc_option *options)
|
||||
threads_args[i].alg = threads_option.alg;
|
||||
threads_args[i].mode = threads_option.mode;
|
||||
threads_args[i].optype = threads_option.optype;
|
||||
+ threads_args[i].win_sz = threads_option.win_sz;
|
||||
+ threads_args[i].comp_lv = threads_option.comp_lv;
|
||||
threads_args[i].td_id = i;
|
||||
ret = pthread_create(&tdid[i], NULL, uadk_zip_async_run, &threads_args[i]);
|
||||
if (ret) {
|
||||
diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
index cbbbb5d..dc00631 100644
|
||||
--- a/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
@@ -57,9 +57,11 @@ struct zip_async_tag {
|
||||
|
||||
typedef struct uadk_thread_res {
|
||||
u32 alg;
|
||||
- u32 mode; // block/stream
|
||||
+ u32 mode;
|
||||
u32 optype;
|
||||
u32 td_id;
|
||||
+ u32 comp_lv;
|
||||
+ u32 win_size;
|
||||
} thread_data;
|
||||
|
||||
struct zip_file_head {
|
||||
@@ -277,6 +279,8 @@ static int zip_wd_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
tddata->alg = alg;
|
||||
tddata->mode = mode;
|
||||
tddata->optype = optype;
|
||||
+ tddata->win_size = options->winsize;
|
||||
+ tddata->comp_lv = options->complevel;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -528,8 +532,8 @@ static void *zip_wd_blk_lz77_sync_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
|
||||
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.win_size = pdata->win_size;
|
||||
comp_setup.stream_mode = WCRYPTO_COMP_STATELESS;
|
||||
|
||||
ctx = wcrypto_create_comp_ctx(queue, &comp_setup);
|
||||
@@ -636,8 +640,8 @@ static void *zip_wd_stm_lz77_sync_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
|
||||
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.win_size = pdata->win_size;
|
||||
comp_setup.stream_mode = WCRYPTO_COMP_STATEFUL;
|
||||
|
||||
ctx = wcrypto_create_comp_ctx(queue, &comp_setup);
|
||||
@@ -745,8 +749,8 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
|
||||
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.win_size = pdata->win_size;
|
||||
comp_setup.stream_mode = WCRYPTO_COMP_STATELESS;
|
||||
comp_setup.cb = zip_lz77_async_cb;
|
||||
|
||||
@@ -866,8 +870,8 @@ static void *zip_wd_blk_sync_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
|
||||
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.win_size = pdata->win_size;
|
||||
comp_setup.stream_mode = WCRYPTO_COMP_STATELESS;
|
||||
|
||||
ctx = wcrypto_create_comp_ctx(queue, &comp_setup);
|
||||
@@ -939,8 +943,8 @@ static void *zip_wd_stm_sync_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
|
||||
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.win_size = pdata->win_size;
|
||||
comp_setup.stream_mode = WCRYPTO_COMP_STATEFUL;
|
||||
|
||||
ctx = wcrypto_create_comp_ctx(queue, &comp_setup);
|
||||
@@ -1018,8 +1022,8 @@ static void *zip_wd_blk_async_run(void *arg)
|
||||
|
||||
comp_setup.alg_type = pdata->alg;
|
||||
comp_setup.op_type = pdata->optype;
|
||||
- comp_setup.comp_lv = WCRYPTO_COMP_L8;
|
||||
- comp_setup.win_size = WCRYPTO_COMP_WS_8K;
|
||||
+ comp_setup.comp_lv = pdata->comp_lv;
|
||||
+ comp_setup.win_size = pdata->win_size;
|
||||
comp_setup.stream_mode = WCRYPTO_COMP_STATELESS;
|
||||
comp_setup.cb = zip_async_cb;
|
||||
|
||||
@@ -1123,6 +1127,8 @@ static int zip_wd_sync_threads(struct acc_option *options)
|
||||
threads_args[i].alg = threads_option.alg;
|
||||
threads_args[i].mode = threads_option.mode;
|
||||
threads_args[i].optype = threads_option.optype;
|
||||
+ threads_args[i].comp_lv = threads_option.comp_lv;
|
||||
+ threads_args[i].win_size = threads_option.win_size;
|
||||
threads_args[i].td_id = i;
|
||||
ret = pthread_create(&tdid[i], NULL, wd_zip_sync_run, &threads_args[i]);
|
||||
if (ret) {
|
||||
@@ -1183,6 +1189,8 @@ static int zip_wd_async_threads(struct acc_option *options)
|
||||
threads_args[i].alg = threads_option.alg;
|
||||
threads_args[i].mode = threads_option.mode;
|
||||
threads_args[i].optype = threads_option.optype;
|
||||
+ threads_args[i].comp_lv = threads_option.comp_lv;
|
||||
+ threads_args[i].win_size = threads_option.win_size;
|
||||
threads_args[i].td_id = i;
|
||||
ret = pthread_create(&tdid[i], NULL, wd_zip_async_run, &threads_args[i]);
|
||||
if (ret) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
317
0057-uadk_tool-v1-support-aead-algorithm-decrypto-perf-te.patch
Normal file
317
0057-uadk_tool-v1-support-aead-algorithm-decrypto-perf-te.patch
Normal file
@ -0,0 +1,317 @@
|
||||
From 7701b69c844f49cfeeb68446d599da9699ca8b6d Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:26 +0800
|
||||
Subject: [PATCH 57/85] uadk_tool/v1 - support aead algorithm decrypto perf
|
||||
testing
|
||||
|
||||
The structure of the nosva aead input and output are as follows :
|
||||
AEAD encryption input: assoc data || plaintext
|
||||
AEAD encryption output: assoc data || ciphertext || auth tag
|
||||
AEAD decryption input: assoc data || ciphertext || auth tag
|
||||
AEAD decryption output: assoc data || plaintext
|
||||
|
||||
First, we store the encrypted result in a file,
|
||||
and then use the encrypted result as input for decryption.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_wd_benchmark.c | 165 +++++++++++++++++++++++--
|
||||
1 file changed, 157 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
index 739c49e..95222c5 100644
|
||||
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
@@ -14,6 +14,10 @@
|
||||
#define MAX_IVK_LENTH 64
|
||||
#define DEF_IVK_DATA 0xAA
|
||||
#define SQE_SIZE 128
|
||||
+#define SEC_AAD_LEN 16
|
||||
+#define SEC_PERF_KEY_LEN 16
|
||||
+#define SEC_SAVE_FILE_LEN 64
|
||||
+#define SEC_MAC_LEN 16
|
||||
|
||||
typedef struct wd_thread_res {
|
||||
u32 subtype;
|
||||
@@ -46,10 +50,134 @@ struct wcrypto_async_tag {
|
||||
int cnt;
|
||||
};
|
||||
|
||||
+struct aead_alg_info {
|
||||
+ int index;
|
||||
+ char *name;
|
||||
+ unsigned int mac_len;
|
||||
+};
|
||||
+
|
||||
static struct thread_queue_res g_thread_queue;
|
||||
static unsigned int g_thread_num;
|
||||
static unsigned int g_pktlen;
|
||||
|
||||
+static unsigned int g_alg;
|
||||
+static unsigned int g_algtype;
|
||||
+static unsigned int g_optype;
|
||||
+
|
||||
+static char wd_aead_key[] = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
|
||||
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf";
|
||||
+
|
||||
+static char wd_aead_aad[] = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
|
||||
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf";
|
||||
+
|
||||
+static struct aead_alg_info wd_aead_info[] = {
|
||||
+ {
|
||||
+ .index = AES_128_CCM,
|
||||
+ .name = "AES_128_CCM",
|
||||
+ .mac_len = 16,
|
||||
+ }, {
|
||||
+ .index = AES_128_GCM,
|
||||
+ .name = "AES_128_GCM",
|
||||
+ .mac_len = 16,
|
||||
+ }, {
|
||||
+ .index = AES_128_CBC_SHA256_HMAC,
|
||||
+ .name = "AES_128_CBC_SHA256_HMAC",
|
||||
+ .mac_len = 32,
|
||||
+ }, {
|
||||
+ .index = SM4_128_GCM,
|
||||
+ .name = "SM4_128_GCM",
|
||||
+ .mac_len = 16,
|
||||
+ }, {
|
||||
+ .index = SM4_128_CCM,
|
||||
+ .name = "SM4_128_CCM",
|
||||
+ .mac_len = 16,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static char *get_aead_alg_name(int algtype)
|
||||
+{
|
||||
+ int table_size = ARRAY_SIZE(wd_aead_info);
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < table_size; i++) {
|
||||
+ if (algtype == wd_aead_info[i].index)
|
||||
+ return wd_aead_info[i].name;
|
||||
+ }
|
||||
+
|
||||
+ SEC_TST_PRT("failed to get the aead alg name\n");
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void init_aead_enc_input(u8 *addr, u32 size)
|
||||
+{
|
||||
+ memset(addr, 0, size);
|
||||
+ memcpy(addr, wd_aead_aad, SEC_AAD_LEN);
|
||||
+}
|
||||
+
|
||||
+static void save_aead_enc_output(u8 *addr, u32 size)
|
||||
+{
|
||||
+ char file_name[SEC_SAVE_FILE_LEN] = {0};
|
||||
+ char *alg_name;
|
||||
+ FILE *fp;
|
||||
+
|
||||
+ alg_name = get_aead_alg_name(g_algtype);
|
||||
+ if (!alg_name) {
|
||||
+ SEC_TST_PRT("failed to get the aead alg name!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(file_name, SEC_SAVE_FILE_LEN, "ctext_%s_%u_WD", alg_name, g_pktlen);
|
||||
+
|
||||
+ fp = fopen(file_name, "w");
|
||||
+ if (!fp) {
|
||||
+ SEC_TST_PRT("failed to open the ctext file!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < size; i++)
|
||||
+ fputc((char)addr[i], fp);
|
||||
+
|
||||
+ fclose(fp);
|
||||
+}
|
||||
+
|
||||
+static void init_aead_dec_input(u8 *addr, u32 size)
|
||||
+{
|
||||
+ char file_name[SEC_SAVE_FILE_LEN] = {0};
|
||||
+ char *alg_name;
|
||||
+ FILE *fp;
|
||||
+ int read_size;
|
||||
+
|
||||
+ alg_name = get_aead_alg_name(g_algtype);
|
||||
+ if (!alg_name) {
|
||||
+ SEC_TST_PRT("failed to get the aead alg name!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(file_name, SEC_SAVE_FILE_LEN, "ctext_%s_%u_WD", alg_name, g_pktlen);
|
||||
+
|
||||
+ fp = fopen(file_name, "r");
|
||||
+ if (!fp) {
|
||||
+ SEC_TST_PRT("failed to open the ctext file!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ fseek(fp, 0, SEEK_END);
|
||||
+ size = ftell(fp);
|
||||
+
|
||||
+ rewind(fp);
|
||||
+ read_size = fread(addr, 1, size, fp);
|
||||
+ if (read_size != size) {
|
||||
+ SEC_TST_PRT("failed to read enough data from ctext!\n");
|
||||
+ fclose(fp);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ addr[size] = '\0';
|
||||
+
|
||||
+ fclose(fp);
|
||||
+}
|
||||
+
|
||||
static void *cipher_async_cb(void *message, void *cipher_tag)
|
||||
{
|
||||
return NULL;
|
||||
@@ -434,6 +562,15 @@ static int init_wd_queue(struct acc_option *options)
|
||||
ret = -ENOMEM;
|
||||
goto in_err;
|
||||
}
|
||||
+ if (g_alg == AEAD_TYPE) {
|
||||
+ if (!g_optype) {
|
||||
+ init_aead_enc_input(g_thread_queue.bd_res[m].in[idx],
|
||||
+ g_pktlen + SEC_AAD_LEN);
|
||||
+ } else {
|
||||
+ init_aead_dec_input(g_thread_queue.bd_res[m].in[idx],
|
||||
+ g_pktlen + SEC_AAD_LEN + SEC_MAC_LEN);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,6 +646,11 @@ static void uninit_wd_queue(void)
|
||||
{
|
||||
int i, j, idx;
|
||||
|
||||
+ // save aad + ciphertxt + mac to file.
|
||||
+ if (g_alg == AEAD_TYPE && !g_optype)
|
||||
+ save_aead_enc_output(g_thread_queue.bd_res[0].out[0],
|
||||
+ g_pktlen + SEC_AAD_LEN + SEC_MAC_LEN);
|
||||
+
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
for (idx = 0; idx < MAX_POOL_LENTH; idx++) {
|
||||
wd_free_blk(g_thread_queue.bd_res[i].pool, g_thread_queue.bd_res[i].iv[idx]);
|
||||
@@ -642,7 +784,7 @@ static void *sec_wd_cipher_async(void *arg)
|
||||
goto tag_err;
|
||||
}
|
||||
|
||||
- if (queue->capa.priv.direction == 0)
|
||||
+ if (!g_optype)
|
||||
copdata.op_type = WCRYPTO_CIPHER_ENCRYPTION;
|
||||
else
|
||||
copdata.op_type = WCRYPTO_CIPHER_DECRYPTION;
|
||||
@@ -728,7 +870,7 @@ static void *sec_wd_aead_async(void *arg)
|
||||
res_iv = bd_res->iv;
|
||||
|
||||
memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH);
|
||||
- memset(priv_hash, DEF_IVK_DATA, MAX_IVK_LENTH);
|
||||
+ memcpy(priv_hash, wd_aead_key, SEC_PERF_KEY_LEN);
|
||||
tag = malloc(sizeof(struct wcrypto_async_tag)); // set the user tag
|
||||
if (!tag) {
|
||||
SEC_TST_PRT("wcrypto async alloc tag fail!\n");
|
||||
@@ -781,7 +923,7 @@ static void *sec_wd_aead_async(void *arg)
|
||||
goto tag_err;
|
||||
}
|
||||
|
||||
- if (queue->capa.priv.direction == 0) {
|
||||
+ if (!g_optype) {
|
||||
aopdata.op_type = WCRYPTO_CIPHER_ENCRYPTION_DIGEST;
|
||||
aopdata.out_bytes = g_pktlen + 32; // aad + plen + authsize;
|
||||
} else {
|
||||
@@ -791,7 +933,6 @@ static void *sec_wd_aead_async(void *arg)
|
||||
|
||||
aopdata.assoc_size = 16;
|
||||
aopdata.in_bytes = g_pktlen;
|
||||
- aopdata.out_bytes = g_pktlen;
|
||||
aopdata.iv_bytes = pdata->ivsize;
|
||||
aopdata.priv = NULL;
|
||||
aopdata.out_buf_bytes = g_pktlen * 2;
|
||||
@@ -800,6 +941,7 @@ static void *sec_wd_aead_async(void *arg)
|
||||
aopdata.in = res_in[0];
|
||||
aopdata.out = res_out[0];
|
||||
aopdata.iv = res_iv[0];
|
||||
+ memset(aopdata.iv, DEF_IVK_DATA, MAX_IVK_LENTH);
|
||||
usleep(SEND_USLEEP);
|
||||
while(1) {
|
||||
if (get_run_state() == 0)
|
||||
@@ -1002,7 +1144,7 @@ static void *sec_wd_cipher_sync(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- if (queue->capa.priv.direction == 0)
|
||||
+ if (!g_optype)
|
||||
copdata.op_type = WCRYPTO_CIPHER_ENCRYPTION;
|
||||
else
|
||||
copdata.op_type = WCRYPTO_CIPHER_DECRYPTION;
|
||||
@@ -1077,7 +1219,7 @@ static void *sec_wd_aead_sync(void *arg)
|
||||
res_iv = bd_res->iv;
|
||||
|
||||
memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH);
|
||||
- memset(priv_hash, DEF_IVK_DATA, MAX_IVK_LENTH);
|
||||
+ memcpy(priv_hash, wd_aead_key, SEC_PERF_KEY_LEN);
|
||||
|
||||
aead_setup.calg = pdata->alg;
|
||||
aead_setup.cmode = pdata->mode;
|
||||
@@ -1122,7 +1264,7 @@ static void *sec_wd_aead_sync(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- if (queue->capa.priv.direction == 0) {
|
||||
+ if (!g_optype) {
|
||||
aopdata.op_type = WCRYPTO_CIPHER_ENCRYPTION_DIGEST;
|
||||
aopdata.out_bytes = g_pktlen + 32; // aad + plen + authsize;
|
||||
} else {
|
||||
@@ -1132,7 +1274,6 @@ static void *sec_wd_aead_sync(void *arg)
|
||||
|
||||
aopdata.assoc_size = 16;
|
||||
aopdata.in_bytes = g_pktlen;
|
||||
- aopdata.out_bytes = g_pktlen;
|
||||
aopdata.iv_bytes = pdata->ivsize;
|
||||
aopdata.priv = NULL;
|
||||
aopdata.out_buf_bytes = g_pktlen * 2;
|
||||
@@ -1140,6 +1281,7 @@ static void *sec_wd_aead_sync(void *arg)
|
||||
aopdata.in = res_in[0];
|
||||
aopdata.out = res_out[0];
|
||||
aopdata.iv = res_iv[0];
|
||||
+ memset(aopdata.iv, DEF_IVK_DATA, MAX_IVK_LENTH);
|
||||
usleep(SEND_USLEEP);
|
||||
while(1) {
|
||||
if (get_run_state() == 0)
|
||||
@@ -1290,7 +1432,9 @@ int sec_wd_sync_threads(struct acc_option *options)
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
threads_args[i].subtype = threads_option.subtype;
|
||||
threads_args[i].alg = threads_option.alg;
|
||||
+ threads_args[i].dalg = threads_option.dalg;
|
||||
threads_args[i].mode = threads_option.mode;
|
||||
+ threads_args[i].is_union = threads_option.is_union;
|
||||
threads_args[i].keysize = threads_option.keysize;
|
||||
threads_args[i].ivsize = threads_option.ivsize;
|
||||
threads_args[i].optype = threads_option.optype;
|
||||
@@ -1357,7 +1501,9 @@ int sec_wd_async_threads(struct acc_option *options)
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
threads_args[i].subtype = threads_option.subtype;
|
||||
threads_args[i].alg = threads_option.alg;
|
||||
+ threads_args[i].dalg = threads_option.dalg;
|
||||
threads_args[i].mode = threads_option.mode;
|
||||
+ threads_args[i].is_union = threads_option.is_union;
|
||||
threads_args[i].keysize = threads_option.keysize;
|
||||
threads_args[i].ivsize = threads_option.ivsize;
|
||||
threads_args[i].optype = threads_option.optype;
|
||||
@@ -1395,6 +1541,9 @@ int sec_wd_benchmark(struct acc_option *options)
|
||||
u32 ptime;
|
||||
int ret;
|
||||
|
||||
+ g_alg = options->subtype;
|
||||
+ g_algtype = options->algtype;
|
||||
+ g_optype = options->optype;
|
||||
g_thread_num = options->threads;
|
||||
g_pktlen = options->pktlen;
|
||||
if (options->optype > WCRYPTO_CIPHER_DECRYPTION) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
106
0058-uadk_tool-v1-fix-sec-benchmark-problem.patch
Normal file
106
0058-uadk_tool-v1-fix-sec-benchmark-problem.patch
Normal file
@ -0,0 +1,106 @@
|
||||
From dada1bc4138629d622c18bbd5d04924af16db5a6 Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:27 +0800
|
||||
Subject: [PATCH 58/85] uadk_tool/v1: fix sec benchmark problem
|
||||
|
||||
1.do not free ctxs until tasks are complete.
|
||||
2.wait for aead tasks, it need to free aiv in callback function.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_wd_benchmark.c | 43 +++++++++++++-------------
|
||||
1 file changed, 22 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
index 95222c5..3791792 100644
|
||||
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
@@ -94,6 +94,20 @@ static struct aead_alg_info wd_aead_info[] = {
|
||||
},
|
||||
};
|
||||
|
||||
+static void wait_recv_complete(void)
|
||||
+{
|
||||
+ int i = 0;
|
||||
+
|
||||
+ while (get_recv_time() != g_thread_num) {
|
||||
+ if (i++ >= MAX_TRY_CNT) {
|
||||
+ SEC_TST_PRT("failed to wait poll thread finish!\n");
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ usleep(SEND_USLEEP);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static char *get_aead_alg_name(int algtype)
|
||||
{
|
||||
int table_size = ARRAY_SIZE(wd_aead_info);
|
||||
@@ -705,17 +719,19 @@ void *sec_wd_poll(void *data)
|
||||
recv = wd_poll_ctx(g_thread_queue.bd_res[id].queue, expt);
|
||||
/*
|
||||
* warpdrive async mode poll easy to 100% with small package.
|
||||
- * SEC_TST_PRT("warpdrive poll %d recv: %u!\n", i, recv);
|
||||
+ * SEC_TST_PRT("warpdrive poll %d recv: %d!\n", i, recv);
|
||||
*/
|
||||
if (unlikely(recv < 0)) {
|
||||
- SEC_TST_PRT("poll ret: %u!\n", recv);
|
||||
+ SEC_TST_PRT("poll ret: %d!\n", recv);
|
||||
goto recv_error;
|
||||
}
|
||||
count += recv;
|
||||
recv = 0;
|
||||
|
||||
- if (get_run_state() == 0)
|
||||
+ if (get_run_state() == 0) {
|
||||
last_time--;
|
||||
+ usleep(SEND_USLEEP);
|
||||
+ }
|
||||
}
|
||||
|
||||
recv_error:
|
||||
@@ -824,12 +840,7 @@ static void *sec_wd_cipher_async(void *arg)
|
||||
}
|
||||
|
||||
add_send_complete();
|
||||
-
|
||||
- while (1) {
|
||||
- if (get_recv_time() > 0) // wait Async mode finish recv
|
||||
- break;
|
||||
- usleep(SEND_USLEEP);
|
||||
- }
|
||||
+ wait_recv_complete();
|
||||
|
||||
wcrypto_del_cipher_ctx(ctx);
|
||||
|
||||
@@ -968,12 +979,7 @@ static void *sec_wd_aead_async(void *arg)
|
||||
}
|
||||
|
||||
add_send_complete();
|
||||
-
|
||||
- while (1) {
|
||||
- if (get_recv_time() > 0) // wait Async mode finish recv
|
||||
- break;
|
||||
- usleep(SEND_USLEEP);
|
||||
- }
|
||||
+ wait_recv_complete();
|
||||
|
||||
wcrypto_del_aead_ctx(ctx);
|
||||
|
||||
@@ -1077,12 +1083,7 @@ static void *sec_wd_digest_async(void *arg)
|
||||
}
|
||||
|
||||
add_send_complete();
|
||||
-
|
||||
- while (1) {
|
||||
- if (get_recv_time() > 0) // wait async mode finish recv
|
||||
- break;
|
||||
- usleep(SEND_USLEEP);
|
||||
- }
|
||||
+ wait_recv_complete();
|
||||
|
||||
wcrypto_del_digest_ctx(ctx);
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
591
0059-uadk-tools-misc-fixes-for-uadk-compress-performance.patch
Normal file
591
0059-uadk-tools-misc-fixes-for-uadk-compress-performance.patch
Normal file
@ -0,0 +1,591 @@
|
||||
From a5e9a9cfaadfe594358efde05e14f8c8d095bf16 Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:28 +0800
|
||||
Subject: [PATCH 59/85] uadk/tools - misc fixes for uadk compress performance
|
||||
|
||||
1.The decompression performance is depends on the compression ratio,
|
||||
usually based on 50%. So adjust the compression source data to make
|
||||
the compression ratio near 50%.
|
||||
2.The per-thread data pool depth determines the size of memory. 4096
|
||||
is too big for EVB environment. So limit to 512 for compression.
|
||||
3.The req.src_len will be override after do compression. So need to
|
||||
use 'g_pktlen' to calculate length.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/uadk_benchmark.c | 2 +-
|
||||
uadk_tool/benchmark/zip_uadk_benchmark.c | 75 +++++++++++------------
|
||||
uadk_tool/benchmark/zip_wd_benchmark.c | 76 +++++++++++-------------
|
||||
3 files changed, 71 insertions(+), 82 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
index d869688..aa884bc 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
@@ -429,7 +429,7 @@ void cal_perfermance_data(struct acc_option *option, u32 sttime)
|
||||
ops = perfops / option->times;
|
||||
cpu_rate = (double)ptime / option->times;
|
||||
ACC_TST_PRT("algname: length: perf: iops: CPU_rate:\n"
|
||||
- "%s %-2uBytes %.1fKB/s %.1fKops %.2f%%\n",
|
||||
+ "%s %-2uBytes %.1fKB/s %.1fKops %.2f%%\n",
|
||||
palgname, option->pktlen, perfermance, ops, cpu_rate);
|
||||
}
|
||||
|
||||
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
index 747172a..44746f6 100644
|
||||
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
@@ -13,6 +13,8 @@
|
||||
#define ZIP_FILE "./zip"
|
||||
#define COMP_LEN_RATE 2
|
||||
#define DECOMP_LEN_RATE 2
|
||||
+#define MAX_POOL_LENTH_COMP 512
|
||||
+#define COMPRESSION_RATIO_FACTOR 0.7
|
||||
|
||||
struct uadk_bd {
|
||||
u8 *src;
|
||||
@@ -54,7 +56,7 @@ typedef struct uadk_thread_res {
|
||||
struct zip_file_head {
|
||||
u32 file_size;
|
||||
u32 block_num;
|
||||
- u32 blk_sz[MAX_POOL_LENTH];
|
||||
+ u32 blk_sz[MAX_POOL_LENTH_COMP];
|
||||
};
|
||||
|
||||
static struct wd_ctx_config g_ctx_cfg;
|
||||
@@ -115,11 +117,11 @@ static int save_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
}
|
||||
|
||||
// init file head informations
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
fhead->blk_sz[j] = g_zip_pool.pool[0].bds[j].dst_len;
|
||||
total_file_size += fhead->blk_sz[j];
|
||||
}
|
||||
- fhead->block_num = MAX_POOL_LENTH;
|
||||
+ fhead->block_num = MAX_POOL_LENTH_COMP;
|
||||
fhead->file_size = total_file_size;
|
||||
size = write(fd, fhead, sizeof(*fhead));
|
||||
if (size < 0) {
|
||||
@@ -129,7 +131,7 @@ static int save_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
}
|
||||
|
||||
// write data for one buffer one buffer to file line.
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
size = write(fd, g_zip_pool.pool[0].bds[j].dst,
|
||||
fhead->blk_sz[j]);
|
||||
if (size < 0) {
|
||||
@@ -144,7 +146,7 @@ write_error:
|
||||
fd_error:
|
||||
close(fd);
|
||||
|
||||
- full_size = g_pktlen * MAX_POOL_LENTH;
|
||||
+ full_size = g_pktlen * MAX_POOL_LENTH_COMP;
|
||||
comp_rate = (double) total_file_size / full_size;
|
||||
ZIP_TST_PRT("compress data rate: %.1f%%!\n", comp_rate * 100);
|
||||
|
||||
@@ -187,14 +189,14 @@ static int load_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
goto fd_err;
|
||||
}
|
||||
size = read(fd, fhead, sizeof(*fhead));
|
||||
- if (size < 0 || fhead->block_num != MAX_POOL_LENTH) {
|
||||
+ if (size < 0 || fhead->block_num != MAX_POOL_LENTH_COMP) {
|
||||
ZIP_TST_PRT("failed to read file head\n");
|
||||
ret = -EINVAL;
|
||||
goto read_err;
|
||||
}
|
||||
|
||||
// read data for one buffer one buffer from file line
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
memset(g_zip_pool.pool[0].bds[j].src, 0x0,
|
||||
g_zip_pool.pool[0].bds[j].src_len);
|
||||
if (size != 0) { // zero size buffer no need to read;
|
||||
@@ -212,7 +214,7 @@ static int load_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
}
|
||||
|
||||
for (i = 1; i < g_thread_num; i++) {
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
if (g_zip_pool.pool[0].bds[j].src_len)
|
||||
memcpy(g_zip_pool.pool[i].bds[j].src,
|
||||
g_zip_pool.pool[0].bds[j].src,
|
||||
@@ -383,14 +385,14 @@ static int init_uadk_bd_pool(u32 optype)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
- g_zip_pool.pool[i].bds = malloc(MAX_POOL_LENTH *
|
||||
+ g_zip_pool.pool[i].bds = malloc(MAX_POOL_LENTH_COMP *
|
||||
sizeof(struct uadk_bd));
|
||||
if (!g_zip_pool.pool[i].bds) {
|
||||
ZIP_TST_PRT("init uadk bds alloc failed!\n");
|
||||
goto malloc_error1;
|
||||
}
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
- g_zip_pool.pool[i].bds[j].src = malloc(insize);
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
+ g_zip_pool.pool[i].bds[j].src = calloc(1, insize);
|
||||
if (!g_zip_pool.pool[i].bds[j].src)
|
||||
goto malloc_error2;
|
||||
g_zip_pool.pool[i].bds[j].src_len = insize;
|
||||
@@ -400,7 +402,7 @@ static int init_uadk_bd_pool(u32 optype)
|
||||
goto malloc_error3;
|
||||
g_zip_pool.pool[i].bds[j].dst_len = outsize;
|
||||
|
||||
- get_rand_data(g_zip_pool.pool[i].bds[j].src, insize);
|
||||
+ get_rand_data(g_zip_pool.pool[i].bds[j].src, insize * COMPRESSION_RATIO_FACTOR);
|
||||
if (g_prefetch)
|
||||
get_rand_data(g_zip_pool.pool[i].bds[j].dst, outsize);
|
||||
}
|
||||
@@ -418,7 +420,7 @@ malloc_error2:
|
||||
}
|
||||
malloc_error1:
|
||||
for (i--; i >= 0; i--) {
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
free(g_zip_pool.pool[i].bds[j].src);
|
||||
free(g_zip_pool.pool[i].bds[j].dst);
|
||||
}
|
||||
@@ -438,7 +440,7 @@ static void free_uadk_bd_pool(void)
|
||||
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
if (g_zip_pool.pool[i].bds) {
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
free(g_zip_pool.pool[i].bds[j].src);
|
||||
free(g_zip_pool.pool[i].bds[j].dst);
|
||||
}
|
||||
@@ -565,17 +567,17 @@ static void *zip_uadk_blk_lz77_sync_run(void *arg)
|
||||
creq.data_fmt = 0;
|
||||
creq.status = 0;
|
||||
|
||||
- ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH);
|
||||
+ ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH_COMP);
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH);
|
||||
+ hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
if (!hw_buff_out)
|
||||
goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH);
|
||||
+ memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
|
||||
while(1) {
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
creq.src = uadk_pool->bds[i].src;
|
||||
creq.dst = &hw_buff_out[i]; //temp out
|
||||
creq.src_len = uadk_pool->bds[i].src_len;
|
||||
@@ -610,7 +612,7 @@ fse_err:
|
||||
|
||||
cal_avg_latency(count);
|
||||
if (pdata->optype == WD_DIR_COMPRESS)
|
||||
- add_recv_data(count, creq.src_len);
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
else
|
||||
add_recv_data(count, first_len);
|
||||
|
||||
@@ -659,17 +661,17 @@ static void *zip_uadk_stm_lz77_sync_run(void *arg)
|
||||
creq.data_fmt = 0;
|
||||
creq.status = 0;
|
||||
|
||||
- ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH);
|
||||
+ ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH_COMP);
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH);
|
||||
+ hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
if (!hw_buff_out)
|
||||
goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH);
|
||||
+ memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
|
||||
while(1) {
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
creq.src = uadk_pool->bds[i].src;
|
||||
creq.dst = &hw_buff_out[i]; //temp out
|
||||
creq.src_len = uadk_pool->bds[i].src_len;
|
||||
@@ -707,7 +709,7 @@ fse_err:
|
||||
|
||||
cal_avg_latency(count);
|
||||
if (pdata->optype == WD_DIR_COMPRESS)
|
||||
- add_recv_data(count, creq.src_len);
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
else
|
||||
add_recv_data(count, first_len);
|
||||
|
||||
@@ -754,16 +756,16 @@ static void *zip_uadk_blk_lz77_async_run(void *arg)
|
||||
creq.data_fmt = 0;
|
||||
creq.status = 0;
|
||||
|
||||
- ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH);
|
||||
+ ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH_COMP);
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH);
|
||||
+ hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
if (!hw_buff_out)
|
||||
goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH);
|
||||
+ memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
|
||||
- tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
+ tag = malloc(sizeof(*tag) * MAX_POOL_LENTH_COMP);
|
||||
if (!tag) {
|
||||
ZIP_TST_PRT("failed to malloc zip tag!\n");
|
||||
goto tag_err;
|
||||
@@ -774,7 +776,7 @@ static void *zip_uadk_blk_lz77_async_run(void *arg)
|
||||
break;
|
||||
|
||||
try_cnt = 0;
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
creq.src = uadk_pool->bds[i].src;
|
||||
creq.dst = &hw_buff_out[i]; //temp out
|
||||
creq.src_len = uadk_pool->bds[i].src_len;
|
||||
@@ -815,10 +817,6 @@ hw_buff_err:
|
||||
fse_err:
|
||||
free(ftuple);
|
||||
wd_comp_free_sess(h_sess);
|
||||
-
|
||||
- // ZIP_TST_PRT("LZ77 valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, creq.dst_len);
|
||||
-
|
||||
add_send_complete();
|
||||
|
||||
return NULL;
|
||||
@@ -861,7 +859,7 @@ static void *zip_uadk_blk_sync_run(void *arg)
|
||||
creq.status = 0;
|
||||
|
||||
while(1) {
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
creq.src = uadk_pool->bds[i].src;
|
||||
creq.dst = uadk_pool->bds[i].dst;
|
||||
creq.src_len = uadk_pool->bds[i].src_len;
|
||||
@@ -921,7 +919,7 @@ static void *zip_uadk_stm_sync_run(void *arg)
|
||||
creq.status = 0;
|
||||
|
||||
while(1) {
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
creq.src = uadk_pool->bds[i].src;
|
||||
creq.dst = uadk_pool->bds[i].dst;
|
||||
creq.src_len = uadk_pool->bds[i].src_len;
|
||||
@@ -986,7 +984,7 @@ static void *zip_uadk_blk_async_run(void *arg)
|
||||
creq.priv = 0;
|
||||
creq.status = 0;
|
||||
|
||||
- tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
+ tag = malloc(sizeof(*tag) * MAX_POOL_LENTH_COMP);
|
||||
if (!tag) {
|
||||
ZIP_TST_PRT("failed to malloc zip tag!\n");
|
||||
wd_comp_free_sess(h_sess);
|
||||
@@ -998,7 +996,7 @@ static void *zip_uadk_blk_async_run(void *arg)
|
||||
break;
|
||||
|
||||
try_cnt = 0;
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
creq.src = uadk_pool->bds[i].src;
|
||||
creq.dst = uadk_pool->bds[i].dst;
|
||||
creq.src_len = uadk_pool->bds[i].src_len;
|
||||
@@ -1032,9 +1030,6 @@ static void *zip_uadk_blk_async_run(void *arg)
|
||||
free(tag);
|
||||
wd_comp_free_sess(h_sess);
|
||||
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, creq.dst_len);
|
||||
-
|
||||
add_send_complete();
|
||||
|
||||
return NULL;
|
||||
diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
index dc00631..61f6c69 100644
|
||||
--- a/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#define COMP_LEN_RATE 2
|
||||
#define DECOMP_LEN_RATE 2
|
||||
+#define COMPRESSION_RATIO_FACTOR 0.7
|
||||
+#define MAX_POOL_LENTH_COMP 512
|
||||
|
||||
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
|
||||
#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
|
||||
@@ -67,7 +69,7 @@ typedef struct uadk_thread_res {
|
||||
struct zip_file_head {
|
||||
u32 file_size;
|
||||
u32 block_num;
|
||||
- u32 blk_sz[MAX_POOL_LENTH];
|
||||
+ u32 blk_sz[MAX_POOL_LENTH_COMP];
|
||||
};
|
||||
|
||||
static unsigned int g_thread_num;
|
||||
@@ -124,11 +126,11 @@ static int save_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
}
|
||||
|
||||
// init file head informations
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
fhead->blk_sz[j] = g_thread_queue.bd_res[0].bds[j].dst_len;
|
||||
total_file_size += fhead->blk_sz[j];
|
||||
}
|
||||
- fhead->block_num = MAX_POOL_LENTH;
|
||||
+ fhead->block_num = MAX_POOL_LENTH_COMP;
|
||||
fhead->file_size = total_file_size;
|
||||
size = write(fd, fhead, sizeof(*fhead));
|
||||
if (size < 0) {
|
||||
@@ -138,7 +140,7 @@ static int save_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
}
|
||||
|
||||
// write data for one buffer one buffer to file line.
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
size = write(fd, g_thread_queue.bd_res[0].bds[j].dst,
|
||||
fhead->blk_sz[j]);
|
||||
if (size < 0) {
|
||||
@@ -153,7 +155,7 @@ write_error:
|
||||
fd_error:
|
||||
close(fd);
|
||||
|
||||
- full_size = g_pktlen * MAX_POOL_LENTH;
|
||||
+ full_size = g_pktlen * MAX_POOL_LENTH_COMP;
|
||||
comp_rate = (double) total_file_size / full_size;
|
||||
ZIP_TST_PRT("compress data rate: %.1f%%!\n", comp_rate * 100);
|
||||
|
||||
@@ -196,14 +198,14 @@ static int load_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
goto fd_err;
|
||||
}
|
||||
size = read(fd, fhead, sizeof(*fhead));
|
||||
- if (size < 0 || fhead->block_num != MAX_POOL_LENTH) {
|
||||
+ if (size < 0 || fhead->block_num != MAX_POOL_LENTH_COMP) {
|
||||
ZIP_TST_PRT("failed to read file head\n");
|
||||
ret = -EINVAL;
|
||||
goto read_err;
|
||||
}
|
||||
|
||||
// read data for one buffer one buffer from file line
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
memset(g_thread_queue.bd_res[0].bds[j].src, 0x0,
|
||||
g_thread_queue.bd_res[0].bds[j].src_len);
|
||||
if (size != 0) { // zero size buffer no need to read;
|
||||
@@ -221,7 +223,7 @@ static int load_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
}
|
||||
|
||||
for (i = 1; i < g_thread_num; i++) {
|
||||
- for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
+ for (j = 0; j < MAX_POOL_LENTH_COMP; j++) {
|
||||
if (g_thread_queue.bd_res[0].bds[j].src_len)
|
||||
memcpy(g_thread_queue.bd_res[i].bds[j].src,
|
||||
g_thread_queue.bd_res[0].bds[j].src,
|
||||
@@ -328,7 +330,7 @@ static int init_zip_wd_queue(struct acc_option *options)
|
||||
}
|
||||
}
|
||||
|
||||
- // use no-sva pbuffer, MAX_BLOCK_NM at least 4 times of MAX_POOL_LENTH
|
||||
+ // use no-sva pbuffer, MAX_BLOCK_NM at least 4 times of MAX_POOL_LENTH_COMP
|
||||
memset(&blksetup, 0, sizeof(blksetup));
|
||||
outsize = ALIGN(outsize, ALIGN_SIZE);
|
||||
blksetup.block_size = outsize;
|
||||
@@ -345,12 +347,12 @@ static int init_zip_wd_queue(struct acc_option *options)
|
||||
}
|
||||
pool = g_thread_queue.bd_res[j].pool;
|
||||
|
||||
- g_thread_queue.bd_res[j].bds = malloc(sizeof(struct wd_bd) * MAX_POOL_LENTH);
|
||||
+ g_thread_queue.bd_res[j].bds = malloc(sizeof(struct wd_bd) * MAX_POOL_LENTH_COMP);
|
||||
if (!g_thread_queue.bd_res[j].bds)
|
||||
goto bds_error;
|
||||
bds = g_thread_queue.bd_res[j].bds;
|
||||
|
||||
- for (i = 0; i < MAX_POOL_LENTH; i++) {
|
||||
+ for (i = 0; i < MAX_POOL_LENTH_COMP; i++) {
|
||||
bds[i].src = wd_alloc_blk(pool);
|
||||
if (!bds[i].src) {
|
||||
ret = -ENOMEM;
|
||||
@@ -365,7 +367,7 @@ static int init_zip_wd_queue(struct acc_option *options)
|
||||
}
|
||||
bds[i].dst_len = outsize;
|
||||
|
||||
- get_rand_data(bds[i].src, insize);
|
||||
+ get_rand_data(bds[i].src, insize * COMPRESSION_RATIO_FACTOR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -385,7 +387,7 @@ pool_err:
|
||||
for (j--; j >= 0; j--) {
|
||||
pool = g_thread_queue.bd_res[j].pool;
|
||||
bds = g_thread_queue.bd_res[j].bds;
|
||||
- for (i = 0; i < MAX_POOL_LENTH; i++) {
|
||||
+ for (i = 0; i < MAX_POOL_LENTH_COMP; i++) {
|
||||
wd_free_blk(pool, bds[i].src);
|
||||
wd_free_blk(pool, bds[i].dst);
|
||||
}
|
||||
@@ -410,7 +412,7 @@ static void uninit_zip_wd_queue(void)
|
||||
for (j = 0; j < g_thread_num; j++) {
|
||||
pool = g_thread_queue.bd_res[j].pool;
|
||||
bds = g_thread_queue.bd_res[j].bds;
|
||||
- for (i = 0; i < MAX_POOL_LENTH; i++) {
|
||||
+ for (i = 0; i < MAX_POOL_LENTH_COMP; i++) {
|
||||
wd_free_blk(pool, bds[i].src);
|
||||
wd_free_blk(pool, bds[i].dst);
|
||||
}
|
||||
@@ -551,17 +553,17 @@ static void *zip_wd_blk_lz77_sync_run(void *arg)
|
||||
|
||||
out_len = bd_pool[0].dst_len;
|
||||
|
||||
- ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH);
|
||||
+ ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH_COMP);
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH);
|
||||
+ hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
if (!hw_buff_out)
|
||||
goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH);
|
||||
+ memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
|
||||
while(1) {
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
opdata.in = bd_pool[i].src;
|
||||
opdata.out = &hw_buff_out[i]; //temp out
|
||||
opdata.in_len = bd_pool[i].src_len;
|
||||
@@ -597,7 +599,7 @@ fse_err:
|
||||
|
||||
cal_avg_latency(count);
|
||||
if (pdata->optype == WCRYPTO_DEFLATE)
|
||||
- add_recv_data(count, opdata.in_len);
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
else
|
||||
add_recv_data(count, first_len);
|
||||
|
||||
@@ -659,17 +661,17 @@ static void *zip_wd_stm_lz77_sync_run(void *arg)
|
||||
|
||||
out_len = bd_pool[0].dst_len;
|
||||
|
||||
- ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH);
|
||||
+ ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH_COMP);
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH);
|
||||
+ hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
if (!hw_buff_out)
|
||||
goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH);
|
||||
+ memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
|
||||
while(1) {
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
opdata.in = bd_pool[i].src;
|
||||
opdata.out = &hw_buff_out[i]; //temp out
|
||||
opdata.in_len = bd_pool[i].src_len;
|
||||
@@ -708,7 +710,7 @@ fse_err:
|
||||
|
||||
cal_avg_latency(count);
|
||||
if (pdata->optype == WCRYPTO_DEFLATE)
|
||||
- add_recv_data(count, opdata.in_len);
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
else
|
||||
add_recv_data(count, first_len);
|
||||
|
||||
@@ -769,16 +771,16 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
|
||||
out_len = bd_pool[0].dst_len;
|
||||
|
||||
- ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH);
|
||||
+ ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH_COMP);
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH);
|
||||
+ hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
if (!hw_buff_out)
|
||||
goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH);
|
||||
+ memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
|
||||
- tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
+ tag = malloc(sizeof(*tag) * MAX_POOL_LENTH_COMP);
|
||||
if (!tag) {
|
||||
ZIP_TST_PRT("failed to malloc zip tag!\n");
|
||||
goto tag_err;
|
||||
@@ -789,7 +791,7 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
break;
|
||||
|
||||
try_cnt = 0;
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
opdata.in = bd_pool[i].src;
|
||||
opdata.out = &hw_buff_out[i]; //temp out
|
||||
opdata.in_len = bd_pool[i].src_len;
|
||||
@@ -832,10 +834,6 @@ hw_buff_err:
|
||||
fse_err:
|
||||
free(ftuple);
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
-
|
||||
- // ZIP_TST_PRT("LZ77 valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, opdata.produced);
|
||||
-
|
||||
add_send_complete();
|
||||
|
||||
return NULL;
|
||||
@@ -890,7 +888,7 @@ static void *zip_wd_blk_sync_run(void *arg)
|
||||
out_len = bd_pool[0].dst_len;
|
||||
|
||||
while(1) {
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
opdata.in = bd_pool[i].src;
|
||||
opdata.out = bd_pool[i].dst;
|
||||
opdata.in_len = bd_pool[i].src_len;
|
||||
@@ -963,7 +961,7 @@ static void *zip_wd_stm_sync_run(void *arg)
|
||||
out_len = bd_pool[0].dst_len;
|
||||
|
||||
while(1) {
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
opdata.in = bd_pool[i].src;
|
||||
opdata.out = bd_pool[i].dst;
|
||||
opdata.in_len = bd_pool[i].src_len;
|
||||
@@ -1041,7 +1039,7 @@ static void *zip_wd_blk_async_run(void *arg)
|
||||
opdata.flush = WCRYPTO_FINISH;
|
||||
|
||||
out_len = bd_pool[0].dst_len;
|
||||
- tag = malloc(sizeof(*tag) * MAX_POOL_LENTH);
|
||||
+ tag = malloc(sizeof(*tag) * MAX_POOL_LENTH_COMP);
|
||||
if (!tag) {
|
||||
ZIP_TST_PRT("failed to malloc zip tag!\n");
|
||||
goto tag_release;
|
||||
@@ -1051,7 +1049,7 @@ static void *zip_wd_blk_async_run(void *arg)
|
||||
if (get_run_state() == 0)
|
||||
break;
|
||||
|
||||
- i = count % MAX_POOL_LENTH;
|
||||
+ i = count % MAX_POOL_LENTH_COMP;
|
||||
opdata.in = bd_pool[i].src;
|
||||
opdata.out = bd_pool[i].dst;
|
||||
opdata.in_len = bd_pool[i].src_len;
|
||||
@@ -1088,10 +1086,6 @@ static void *zip_wd_blk_async_run(void *arg)
|
||||
tag_release:
|
||||
free(tag);
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
-
|
||||
- // ZIP_TST_PRT("valid pool len: %u, send count BD: %u, output len: %u!\n",
|
||||
- // MAX_POOL_LENTH, count, opdata.produced);
|
||||
-
|
||||
add_send_complete();
|
||||
|
||||
return NULL;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
456
0060-uadk-tools-fix-lz77_zstd-performance-test-for-nosva-.patch
Normal file
456
0060-uadk-tools-fix-lz77_zstd-performance-test-for-nosva-.patch
Normal file
@ -0,0 +1,456 @@
|
||||
From 2b8826c6582ddaa48a1f6be3487d5de7e9bd42be Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:29 +0800
|
||||
Subject: [PATCH 60/85] uadk/tools - fix lz77_zstd performance test for nosva
|
||||
mode
|
||||
|
||||
1.lz77_zstd need a large buffer to output literals and sequences.
|
||||
2.For nosva mode, the output buffer need to be alloced by wd_alloc_blk
|
||||
from block memory pool.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/zip_uadk_benchmark.c | 67 ++++------
|
||||
uadk_tool/benchmark/zip_wd_benchmark.c | 160 ++++++-----------------
|
||||
2 files changed, 66 insertions(+), 161 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
index 44746f6..7c96edf 100644
|
||||
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
@@ -15,7 +15,7 @@
|
||||
#define DECOMP_LEN_RATE 2
|
||||
#define MAX_POOL_LENTH_COMP 512
|
||||
#define COMPRESSION_RATIO_FACTOR 0.7
|
||||
-
|
||||
+#define CHUNK_SIZE (128 * 1024)
|
||||
struct uadk_bd {
|
||||
u8 *src;
|
||||
u8 *dst;
|
||||
@@ -623,16 +623,12 @@ static void *zip_uadk_stm_lz77_sync_run(void *arg)
|
||||
{
|
||||
thread_data *pdata = (thread_data *)arg;
|
||||
struct wd_comp_sess_setup comp_setup = {0};
|
||||
- ZSTD_CCtx *cctx = zstd_soft_fse_init(15);
|
||||
- ZSTD_inBuffer zstd_input = {0};
|
||||
- ZSTD_outBuffer zstd_output = {0};
|
||||
COMP_TUPLE_TAG *ftuple = NULL;
|
||||
struct bd_pool *uadk_pool;
|
||||
struct wd_comp_req creq;
|
||||
- char *hw_buff_out = NULL;
|
||||
- size_t fse_size;
|
||||
handle_t h_sess;
|
||||
- u32 first_len = 0;
|
||||
+ void *src, *dst;
|
||||
+ u32 in_len = 0;
|
||||
u32 out_len = 0;
|
||||
u32 count = 0;
|
||||
int ret, i;
|
||||
@@ -654,7 +650,6 @@ static void *zip_uadk_stm_lz77_sync_run(void *arg)
|
||||
return NULL;
|
||||
|
||||
creq.op_type = pdata->optype;
|
||||
- creq.src_len = g_pktlen;
|
||||
out_len = uadk_pool->bds[0].dst_len;
|
||||
|
||||
creq.cb = NULL;
|
||||
@@ -665,53 +660,45 @@ static void *zip_uadk_stm_lz77_sync_run(void *arg)
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
- if (!hw_buff_out)
|
||||
- goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
-
|
||||
while(1) {
|
||||
i = count % MAX_POOL_LENTH_COMP;
|
||||
- creq.src = uadk_pool->bds[i].src;
|
||||
- creq.dst = &hw_buff_out[i]; //temp out
|
||||
- creq.src_len = uadk_pool->bds[i].src_len;
|
||||
- creq.dst_len = out_len;
|
||||
- creq.priv = &ftuple[i];
|
||||
+ src = uadk_pool->bds[i].src;
|
||||
+ dst = uadk_pool->bds[i].dst;
|
||||
+ in_len = uadk_pool->bds[0].src_len;
|
||||
+ out_len = uadk_pool->bds[0].dst_len;
|
||||
+
|
||||
+ while (in_len > 0) {
|
||||
+ creq.src_len = in_len > CHUNK_SIZE ? CHUNK_SIZE : in_len;
|
||||
+ creq.dst_len = out_len > 2 * CHUNK_SIZE ? 2 * CHUNK_SIZE : out_len;
|
||||
+ creq.src = src;
|
||||
+ creq.dst = dst;
|
||||
+ creq.priv = &ftuple[i];
|
||||
+
|
||||
+ ret = wd_do_comp_strm(h_sess, &creq);
|
||||
+ if (ret < 0 || creq.status == WD_IN_EPARA) {
|
||||
+ ZIP_TST_PRT("wd comp, invalid or incomplete data! "
|
||||
+ "ret(%d), req.status(%u)\n", ret, creq.status);
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
- ret = wd_do_comp_strm(h_sess, &creq);
|
||||
- if (ret < 0 || creq.status == WD_IN_EPARA) {
|
||||
- ZIP_TST_PRT("wd comp, invalid or incomplete data! "
|
||||
- "ret(%d), req.status(%u)\n", ret, creq.status);
|
||||
- break;
|
||||
+ src += CHUNK_SIZE;
|
||||
+ in_len -= CHUNK_SIZE;
|
||||
+ dst += 2 * CHUNK_SIZE;
|
||||
+ out_len -= 2 * CHUNK_SIZE;
|
||||
}
|
||||
|
||||
count++;
|
||||
- zstd_input.src = creq.src;
|
||||
- zstd_input.size = creq.src_len;
|
||||
- zstd_input.pos = 0;
|
||||
- zstd_output.dst = uadk_pool->bds[i].dst;
|
||||
- zstd_output.size = out_len;
|
||||
- zstd_output.pos = 0;
|
||||
- fse_size = zstd_soft_fse(creq.priv, &zstd_input, &zstd_output, cctx, ZSTD_e_end);
|
||||
|
||||
- uadk_pool->bds[i].dst_len = fse_size;
|
||||
- if (unlikely(i == 0))
|
||||
- first_len = fse_size;
|
||||
if (get_run_state() == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
-hw_buff_err:
|
||||
- free(hw_buff_out);
|
||||
-fse_err:
|
||||
free(ftuple);
|
||||
+fse_err:
|
||||
wd_comp_free_sess(h_sess);
|
||||
|
||||
cal_avg_latency(count);
|
||||
- if (pdata->optype == WD_DIR_COMPRESS)
|
||||
- add_recv_data(count, g_pktlen);
|
||||
- else
|
||||
- add_recv_data(count, first_len);
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
index 61f6c69..b25f1fb 100644
|
||||
--- a/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
@@ -20,6 +20,7 @@
|
||||
#define DECOMP_LEN_RATE 2
|
||||
#define COMPRESSION_RATIO_FACTOR 0.7
|
||||
#define MAX_POOL_LENTH_COMP 512
|
||||
+#define CHUNK_SIZE (128 * 1024)
|
||||
|
||||
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
|
||||
#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
|
||||
@@ -75,18 +76,6 @@ struct zip_file_head {
|
||||
static unsigned int g_thread_num;
|
||||
static unsigned int g_pktlen;
|
||||
|
||||
-#ifndef ZLIB_FSE
|
||||
-static ZSTD_CCtx* zstd_soft_fse_init(unsigned int level)
|
||||
-{
|
||||
- return NULL;
|
||||
-}
|
||||
-
|
||||
-static int zstd_soft_fse(void *Ftuple, ZSTD_inBuffer *input, ZSTD_outBuffer *output, ZSTD_CCtx * cctx, ZSTD_EndDirective cmode)
|
||||
-{
|
||||
- return input->size;
|
||||
-}
|
||||
-#endif
|
||||
-
|
||||
static int save_file_data(const char *alg, u32 pkg_len, u32 optype)
|
||||
{
|
||||
struct zip_file_head *fhead = NULL;
|
||||
@@ -430,26 +419,12 @@ static void zip_lz77_async_cb(const void *message, void *data)
|
||||
{
|
||||
const struct wcrypto_comp_msg *cbmsg = message;
|
||||
struct zip_async_tag *tag = data;
|
||||
- ZSTD_CCtx *cctx = tag->cctx;
|
||||
- ZSTD_inBuffer zstd_input;
|
||||
- ZSTD_outBuffer zstd_output;
|
||||
- struct wd_bd *bd_pool;
|
||||
int td_id = tag->td_id;
|
||||
+ struct wd_bd *bd_pool;
|
||||
int idx = tag->bd_idx;
|
||||
- size_t fse_size;
|
||||
|
||||
bd_pool = g_thread_queue.bd_res[td_id].bds;
|
||||
bd_pool[idx].dst_len = cbmsg->produced;
|
||||
-
|
||||
- zstd_input.src = cbmsg->src;
|
||||
- zstd_input.size = cbmsg->in_size;
|
||||
- zstd_input.pos = 0;
|
||||
- zstd_output.dst = bd_pool[idx].dst;
|
||||
- zstd_output.size = tag->cm_len;
|
||||
- zstd_output.pos = 0;
|
||||
- fse_size = zstd_soft_fse(tag->priv, &zstd_input, &zstd_output, cctx, ZSTD_e_end);
|
||||
-
|
||||
- bd_pool[idx].dst_len = fse_size;
|
||||
}
|
||||
|
||||
static void zip_async_cb(const void *message, void *data)
|
||||
@@ -501,18 +476,12 @@ recv_error:
|
||||
static void *zip_wd_blk_lz77_sync_run(void *arg)
|
||||
{
|
||||
thread_data *pdata = (thread_data *)arg;
|
||||
- ZSTD_CCtx *cctx = zstd_soft_fse_init(15);
|
||||
- ZSTD_inBuffer zstd_input = {0};
|
||||
- ZSTD_outBuffer zstd_output = {0};
|
||||
COMP_TUPLE_TAG *ftuple = NULL;
|
||||
struct wcrypto_comp_ctx_setup comp_setup;
|
||||
struct wcrypto_comp_op_data opdata;
|
||||
struct wcrypto_comp_ctx *ctx;
|
||||
struct wd_queue *queue;
|
||||
struct wd_bd *bd_pool;
|
||||
- u8 *hw_buff_out = NULL;
|
||||
- size_t fse_size;
|
||||
- u32 first_len = 0;
|
||||
u32 out_len = 0;
|
||||
u32 count = 0;
|
||||
int ret, i;
|
||||
@@ -557,15 +526,10 @@ static void *zip_wd_blk_lz77_sync_run(void *arg)
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
- if (!hw_buff_out)
|
||||
- goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
-
|
||||
while(1) {
|
||||
i = count % MAX_POOL_LENTH_COMP;
|
||||
opdata.in = bd_pool[i].src;
|
||||
- opdata.out = &hw_buff_out[i]; //temp out
|
||||
+ opdata.out = bd_pool[i].dst;
|
||||
opdata.in_len = bd_pool[i].src_len;
|
||||
opdata.avail_out = out_len;
|
||||
opdata.priv = &ftuple[i];
|
||||
@@ -576,32 +540,17 @@ static void *zip_wd_blk_lz77_sync_run(void *arg)
|
||||
break;
|
||||
|
||||
count++;
|
||||
- zstd_input.src = opdata.in;
|
||||
- zstd_input.size = opdata.in_len;
|
||||
- zstd_input.pos = 0;
|
||||
- zstd_output.dst = bd_pool[i].dst;
|
||||
- zstd_output.size = out_len;
|
||||
- zstd_output.pos = 0;
|
||||
- fse_size = zstd_soft_fse(opdata.priv, &zstd_input, &zstd_output, cctx, ZSTD_e_end);
|
||||
-
|
||||
- bd_pool[i].dst_len = fse_size;
|
||||
- if (unlikely(i == 0))
|
||||
- first_len = fse_size;
|
||||
+
|
||||
if (get_run_state() == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
-hw_buff_err:
|
||||
- free(hw_buff_out);
|
||||
-fse_err:
|
||||
free(ftuple);
|
||||
+fse_err:
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
|
||||
cal_avg_latency(count);
|
||||
- if (pdata->optype == WCRYPTO_DEFLATE)
|
||||
- add_recv_data(count, g_pktlen);
|
||||
- else
|
||||
- add_recv_data(count, first_len);
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -609,18 +558,14 @@ fse_err:
|
||||
static void *zip_wd_stm_lz77_sync_run(void *arg)
|
||||
{
|
||||
thread_data *pdata = (thread_data *)arg;
|
||||
- ZSTD_CCtx *cctx = zstd_soft_fse_init(15);
|
||||
- ZSTD_inBuffer zstd_input = {0};
|
||||
- ZSTD_outBuffer zstd_output = {0};
|
||||
COMP_TUPLE_TAG *ftuple = NULL;
|
||||
struct wcrypto_comp_ctx_setup comp_setup;
|
||||
struct wcrypto_comp_op_data opdata;
|
||||
struct wcrypto_comp_ctx *ctx;
|
||||
struct wd_queue *queue;
|
||||
struct wd_bd *bd_pool;
|
||||
- u8 *hw_buff_out = NULL;
|
||||
- size_t fse_size;
|
||||
- u32 first_len = 0;
|
||||
+ void *src, *dst;
|
||||
+ u32 in_len = 0;
|
||||
u32 out_len = 0;
|
||||
u32 count = 0;
|
||||
int ret, i;
|
||||
@@ -659,60 +604,48 @@ static void *zip_wd_stm_lz77_sync_run(void *arg)
|
||||
else
|
||||
opdata.flush = WCRYPTO_FINISH;
|
||||
|
||||
- out_len = bd_pool[0].dst_len;
|
||||
-
|
||||
ftuple = malloc(sizeof(COMP_TUPLE_TAG) * MAX_POOL_LENTH_COMP);
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
- if (!hw_buff_out)
|
||||
- goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
-
|
||||
while(1) {
|
||||
i = count % MAX_POOL_LENTH_COMP;
|
||||
- opdata.in = bd_pool[i].src;
|
||||
- opdata.out = &hw_buff_out[i]; //temp out
|
||||
- opdata.in_len = bd_pool[i].src_len;
|
||||
- opdata.avail_out = out_len;
|
||||
- opdata.priv = &ftuple[i];
|
||||
-
|
||||
- ret = wcrypto_do_comp(ctx, &opdata, NULL);
|
||||
- if (ret || opdata.status == WCRYPTO_DECOMP_END_NOSPACE ||
|
||||
- opdata.status == WD_IN_EPARA || opdata.status == WD_VERIFY_ERR) {
|
||||
- ZIP_TST_PRT("wd comp, invalid or incomplete data! "
|
||||
- "ret(%d), req.status(%u)\n", ret, opdata.status);
|
||||
- break;
|
||||
+ src = bd_pool[i].src;
|
||||
+ dst = bd_pool[i].dst;
|
||||
+ in_len = bd_pool[i].src_len;
|
||||
+ out_len = bd_pool[i].dst_len;
|
||||
+
|
||||
+ while (in_len > 0) {
|
||||
+ opdata.in_len = in_len > CHUNK_SIZE ? CHUNK_SIZE : in_len;
|
||||
+ opdata.avail_out = out_len > 2 * CHUNK_SIZE ? 2 * CHUNK_SIZE : out_len;
|
||||
+ opdata.in = src;
|
||||
+ opdata.out = dst;
|
||||
+ opdata.priv = &ftuple[i];
|
||||
+
|
||||
+ ret = wcrypto_do_comp(ctx, &opdata, NULL);
|
||||
+ if (ret || opdata.status == WCRYPTO_DECOMP_END_NOSPACE ||
|
||||
+ opdata.status == WD_IN_EPARA || opdata.status == WD_VERIFY_ERR) {
|
||||
+ ZIP_TST_PRT("wd comp, invalid or incomplete data! "
|
||||
+ "ret(%d), req.status(%u)\n", ret, opdata.status);
|
||||
+ break;
|
||||
+ }
|
||||
+ src += CHUNK_SIZE;
|
||||
+ in_len -= CHUNK_SIZE;
|
||||
+ dst += 2 * CHUNK_SIZE;
|
||||
+ out_len -= 2 * CHUNK_SIZE;
|
||||
}
|
||||
-
|
||||
count++;
|
||||
- zstd_input.src = opdata.in;
|
||||
- zstd_input.size = opdata.in_len;
|
||||
- zstd_input.pos = 0;
|
||||
- zstd_output.dst = opdata.out;
|
||||
- zstd_output.size = out_len;
|
||||
- zstd_output.pos = 0;
|
||||
- fse_size = zstd_soft_fse(opdata.priv, &zstd_input, &zstd_output, cctx, ZSTD_e_end);
|
||||
-
|
||||
- bd_pool[i].dst_len = fse_size;
|
||||
- if (unlikely(i == 0))
|
||||
- first_len = fse_size;
|
||||
+
|
||||
if (get_run_state() == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
-hw_buff_err:
|
||||
- free(hw_buff_out);
|
||||
-fse_err:
|
||||
free(ftuple);
|
||||
+fse_err:
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
|
||||
cal_avg_latency(count);
|
||||
- if (pdata->optype == WCRYPTO_DEFLATE)
|
||||
- add_recv_data(count, g_pktlen);
|
||||
- else
|
||||
- add_recv_data(count, first_len);
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -720,18 +653,16 @@ fse_err:
|
||||
static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
{
|
||||
thread_data *pdata = (thread_data *)arg;
|
||||
- ZSTD_CCtx *cctx = zstd_soft_fse_init(15);
|
||||
- COMP_TUPLE_TAG *ftuple = NULL;
|
||||
struct wcrypto_comp_ctx_setup comp_setup;
|
||||
struct wcrypto_comp_op_data opdata;
|
||||
+ COMP_TUPLE_TAG *ftuple = NULL;
|
||||
struct wcrypto_comp_ctx *ctx;
|
||||
struct zip_async_tag *tag;
|
||||
- u8 *hw_buff_out = NULL;
|
||||
struct wd_queue *queue;
|
||||
struct wd_bd *bd_pool;
|
||||
u32 out_len = 0;
|
||||
- u32 count = 0;
|
||||
u32 try_cnt = 0;
|
||||
+ u32 count = 0;
|
||||
int ret, i;
|
||||
|
||||
if (pdata->td_id > g_thread_num)
|
||||
@@ -760,14 +691,9 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
- opdata.stream_pos = WCRYPTO_COMP_STREAM_NEW;
|
||||
opdata.alg_type = pdata->alg;
|
||||
opdata.priv = NULL;
|
||||
opdata.status = 0;
|
||||
- if (pdata->optype == WCRYPTO_INFLATE)
|
||||
- opdata.flush = WCRYPTO_SYNC_FLUSH;
|
||||
- else
|
||||
- opdata.flush = WCRYPTO_FINISH;
|
||||
|
||||
out_len = bd_pool[0].dst_len;
|
||||
|
||||
@@ -775,11 +701,6 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
if (!ftuple)
|
||||
goto fse_err;
|
||||
|
||||
- hw_buff_out = malloc(out_len * MAX_POOL_LENTH_COMP);
|
||||
- if (!hw_buff_out)
|
||||
- goto hw_buff_err;
|
||||
- memset(hw_buff_out, 0x0, out_len * MAX_POOL_LENTH_COMP);
|
||||
-
|
||||
tag = malloc(sizeof(*tag) * MAX_POOL_LENTH_COMP);
|
||||
if (!tag) {
|
||||
ZIP_TST_PRT("failed to malloc zip tag!\n");
|
||||
@@ -793,7 +714,7 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
try_cnt = 0;
|
||||
i = count % MAX_POOL_LENTH_COMP;
|
||||
opdata.in = bd_pool[i].src;
|
||||
- opdata.out = &hw_buff_out[i]; //temp out
|
||||
+ opdata.out = bd_pool[i].dst; //temp out
|
||||
opdata.in_len = bd_pool[i].src_len;
|
||||
opdata.avail_out = out_len;
|
||||
opdata.priv = &ftuple[i];
|
||||
@@ -802,7 +723,6 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
tag[i].ctx = ctx;
|
||||
tag[i].td_id = pdata->td_id;
|
||||
tag[i].cm_len = out_len;
|
||||
- tag[i].cctx = cctx;
|
||||
tag[i].priv = opdata.priv;
|
||||
|
||||
ret = wcrypto_do_comp(ctx, &opdata, &tag[i]);
|
||||
@@ -827,12 +747,10 @@ static void *zip_wd_blk_lz77_async_run(void *arg)
|
||||
usleep(SEND_USLEEP);
|
||||
}
|
||||
|
||||
-tag_err:
|
||||
free(tag);
|
||||
-hw_buff_err:
|
||||
- free(hw_buff_out);
|
||||
-fse_err:
|
||||
+tag_err:
|
||||
free(ftuple);
|
||||
+fse_err:
|
||||
wcrypto_del_comp_ctx(ctx);
|
||||
add_send_complete();
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
138
0061-uadk-tools-fix-for-uadk-compression-stream-performan.patch
Normal file
138
0061-uadk-tools-fix-for-uadk-compression-stream-performan.patch
Normal file
@ -0,0 +1,138 @@
|
||||
From 9c3a48205372045097d4bf835d772aeffd4e5f8d Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:30 +0800
|
||||
Subject: [PATCH 61/85] uadk/tools - fix for uadk compression stream
|
||||
performance
|
||||
|
||||
The compression stream mode test case should devide the input package
|
||||
into 128KiB block.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/zip_uadk_benchmark.c | 4 +-
|
||||
uadk_tool/benchmark/zip_wd_benchmark.c | 57 ++++++++++++++----------
|
||||
2 files changed, 36 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
index 7c96edf..6bf1749 100644
|
||||
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
@@ -13,7 +13,7 @@
|
||||
#define ZIP_FILE "./zip"
|
||||
#define COMP_LEN_RATE 2
|
||||
#define DECOMP_LEN_RATE 2
|
||||
-#define MAX_POOL_LENTH_COMP 512
|
||||
+#define MAX_POOL_LENTH_COMP 1
|
||||
#define COMPRESSION_RATIO_FACTOR 0.7
|
||||
#define CHUNK_SIZE (128 * 1024)
|
||||
struct uadk_bd {
|
||||
@@ -912,7 +912,7 @@ static void *zip_uadk_stm_sync_run(void *arg)
|
||||
creq.src_len = uadk_pool->bds[i].src_len;
|
||||
creq.dst_len = out_len;
|
||||
|
||||
- ret = wd_do_comp_strm(h_sess, &creq);
|
||||
+ ret = wd_do_comp_sync2(h_sess, &creq);
|
||||
if (ret < 0 || creq.status == WD_IN_EPARA) {
|
||||
ZIP_TST_PRT("wd comp, invalid or incomplete data! "
|
||||
"ret(%d), req.status(%u)\n", ret, creq.status);
|
||||
diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
index b25f1fb..d2340e0 100644
|
||||
--- a/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_wd_benchmark.c
|
||||
@@ -323,9 +323,8 @@ static int init_zip_wd_queue(struct acc_option *options)
|
||||
memset(&blksetup, 0, sizeof(blksetup));
|
||||
outsize = ALIGN(outsize, ALIGN_SIZE);
|
||||
blksetup.block_size = outsize;
|
||||
- blksetup.block_num = MAX_BLOCK_NM;
|
||||
+ blksetup.block_num = MAX_POOL_LENTH_COMP * 3;
|
||||
blksetup.align_size = ALIGN_SIZE;
|
||||
- // ZIP_TST_PRT("create pool memory: %d KB\n", (MAX_BLOCK_NM * blksetup.block_size) >> 10);
|
||||
|
||||
for (j = 0; j < g_thread_num; j++) {
|
||||
g_thread_queue.bd_res[j].pool = wd_blkpool_create(g_thread_queue.bd_res[j].queue, &blksetup);
|
||||
@@ -832,14 +831,14 @@ static void *zip_wd_blk_sync_run(void *arg)
|
||||
|
||||
static void *zip_wd_stm_sync_run(void *arg)
|
||||
{
|
||||
+ u32 in_len, out_len, total_out, count = 0;
|
||||
thread_data *pdata = (thread_data *)arg;
|
||||
struct wcrypto_comp_ctx_setup comp_setup;
|
||||
struct wcrypto_comp_op_data opdata;
|
||||
struct wcrypto_comp_ctx *ctx;
|
||||
struct wd_queue *queue;
|
||||
struct wd_bd *bd_pool;
|
||||
- u32 out_len = 0;
|
||||
- u32 count = 0;
|
||||
+ void *src, *dst;
|
||||
int ret, i;
|
||||
|
||||
if (pdata->td_id > g_thread_num)
|
||||
@@ -867,34 +866,46 @@ static void *zip_wd_stm_sync_run(void *arg)
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
- opdata.stream_pos = WCRYPTO_COMP_STREAM_NEW;
|
||||
opdata.alg_type = pdata->alg;
|
||||
opdata.priv = NULL;
|
||||
opdata.status = 0;
|
||||
- if (pdata->optype == WCRYPTO_INFLATE)
|
||||
- opdata.flush = WCRYPTO_SYNC_FLUSH;
|
||||
- else
|
||||
- opdata.flush = WCRYPTO_FINISH;
|
||||
-
|
||||
- out_len = bd_pool[0].dst_len;
|
||||
|
||||
while(1) {
|
||||
i = count % MAX_POOL_LENTH_COMP;
|
||||
- opdata.in = bd_pool[i].src;
|
||||
- opdata.out = bd_pool[i].dst;
|
||||
- opdata.in_len = bd_pool[i].src_len;
|
||||
- opdata.avail_out = out_len;
|
||||
+ src = bd_pool[i].src;
|
||||
+ dst = bd_pool[i].dst;
|
||||
+ in_len = bd_pool[i].src_len;
|
||||
+ out_len = g_pktlen * DECOMP_LEN_RATE;
|
||||
+ total_out = 0;
|
||||
+ opdata.stream_pos = WCRYPTO_COMP_STREAM_NEW;
|
||||
|
||||
- ret = wcrypto_do_comp(ctx, &opdata, NULL);
|
||||
- if (ret || opdata.status == WCRYPTO_DECOMP_END_NOSPACE ||
|
||||
- opdata.status == WD_IN_EPARA || opdata.status == WD_VERIFY_ERR) {
|
||||
- ZIP_TST_PRT("wd comp, invalid or incomplete data! "
|
||||
- "ret(%d), req.status(%u)\n", ret, opdata.status);
|
||||
- break;
|
||||
- }
|
||||
+ do {
|
||||
+ opdata.in_len = in_len > CHUNK_SIZE ? CHUNK_SIZE : in_len;
|
||||
+ opdata.avail_out = out_len > 2 * CHUNK_SIZE ? 2 * CHUNK_SIZE : out_len;
|
||||
+ opdata.in = src;
|
||||
+ opdata.out = dst;
|
||||
+ opdata.flush = in_len ? WCRYPTO_SYNC_FLUSH : WCRYPTO_FINISH;
|
||||
+
|
||||
+ ret = wcrypto_do_comp(ctx, &opdata, NULL);
|
||||
+ if (ret || opdata.status == WCRYPTO_DECOMP_END_NOSPACE ||
|
||||
+ opdata.status == WD_IN_EPARA || opdata.status == WD_VERIFY_ERR) {
|
||||
+ ZIP_TST_PRT("wd comp, invalid or incomplete data! "
|
||||
+ "ret(%d), req.status(%u)\n", ret, opdata.status);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ opdata.stream_pos = WCRYPTO_COMP_STREAM_OLD;
|
||||
+
|
||||
+ src += opdata.consumed;
|
||||
+ in_len -= opdata.consumed;
|
||||
+ dst += opdata.produced;
|
||||
+ out_len -= opdata.produced;
|
||||
+ total_out += opdata.produced;
|
||||
+ } while (in_len > 0);
|
||||
|
||||
count++;
|
||||
- bd_pool[i].dst_len = opdata.produced;
|
||||
+ bd_pool[i].dst_len = total_out;
|
||||
+
|
||||
if (get_run_state() == 0)
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
185
0062-uadk-tools-fix-for-uadk-tool-sec-aead-async-mode.patch
Normal file
185
0062-uadk-tools-fix-for-uadk-tool-sec-aead-async-mode.patch
Normal file
@ -0,0 +1,185 @@
|
||||
From f4adc9ff84c39def8c82a6976e7c62d2c79c5363 Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:31 +0800
|
||||
Subject: [PATCH 62/85] uadk/tools: fix for uadk tool sec aead async mode
|
||||
|
||||
In asynchronous mode, each BD of each thread requires an
|
||||
independent MAC address. Otherwise, hardware write-back
|
||||
overwrites each other.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 43 +++++++-----------------
|
||||
1 file changed, 13 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index aed1b26..d0bf871 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -28,6 +28,7 @@ char g_save_mac[SEC_MAX_MAC_LEN];
|
||||
struct uadk_bd {
|
||||
u8 *src;
|
||||
u8 *dst;
|
||||
+ u8 mac[SEC_MAX_MAC_LEN];
|
||||
};
|
||||
|
||||
struct bd_pool {
|
||||
@@ -38,7 +39,6 @@ struct thread_pool {
|
||||
struct bd_pool *pool;
|
||||
u8 **iv;
|
||||
u8 **key;
|
||||
- u8 **mac;
|
||||
u8 **hash;
|
||||
} g_uadk_pool;
|
||||
|
||||
@@ -602,7 +602,7 @@ static void save_aead_dst_data(u8 *addr, u32 size)
|
||||
return;
|
||||
}
|
||||
|
||||
- memcpy(addr + size, g_uadk_pool.mac[0], SEC_PERF_AUTH_SIZE);
|
||||
+ memcpy(addr + size, g_uadk_pool.pool[0].bds[0].mac, SEC_PERF_AUTH_SIZE);
|
||||
|
||||
for (int i = 0; i < size + SEC_PERF_AUTH_SIZE; i++)
|
||||
fputc((char)addr[i], fp);
|
||||
@@ -645,7 +645,7 @@ static void read_aead_dst_data(u8 *addr, u32 len)
|
||||
|
||||
static int init_ivkey_source(void)
|
||||
{
|
||||
- int i, j, k, m, idx;
|
||||
+ int i, j, m, idx;
|
||||
|
||||
g_uadk_pool.iv = malloc(sizeof(char *) * g_thread_num);
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
@@ -663,13 +663,6 @@ static int init_ivkey_source(void)
|
||||
memcpy(g_uadk_pool.key[j], aead_key, SEC_PERF_KEY_LEN);
|
||||
}
|
||||
|
||||
- g_uadk_pool.mac = malloc(sizeof(char *) * g_thread_num);
|
||||
- for (k = 0; k < g_thread_num; k++) {
|
||||
- g_uadk_pool.mac[k] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
- if (!g_uadk_pool.mac[k])
|
||||
- goto free_mac;
|
||||
- }
|
||||
-
|
||||
g_uadk_pool.hash = malloc(sizeof(char *) * g_thread_num);
|
||||
for (m = 0; m < g_thread_num; m++) {
|
||||
g_uadk_pool.hash[m] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
@@ -686,12 +679,6 @@ free_hash:
|
||||
free(g_uadk_pool.hash[idx]);
|
||||
free(g_uadk_pool.hash);
|
||||
|
||||
-free_mac:
|
||||
- for (idx = k - 1; idx >= 0; idx--)
|
||||
- free(g_uadk_pool.mac[idx]);
|
||||
-
|
||||
- free(g_uadk_pool.mac);
|
||||
-
|
||||
free_key:
|
||||
for (idx = j - 1; idx >= 0; idx--)
|
||||
free(g_uadk_pool.key[idx]);
|
||||
@@ -712,13 +699,11 @@ static void free_ivkey_source(void)
|
||||
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
free(g_uadk_pool.hash[i]);
|
||||
- free(g_uadk_pool.mac[i]);
|
||||
free(g_uadk_pool.key[i]);
|
||||
free(g_uadk_pool.iv[i]);
|
||||
}
|
||||
|
||||
free(g_uadk_pool.hash);
|
||||
- free(g_uadk_pool.mac);
|
||||
free(g_uadk_pool.key);
|
||||
free(g_uadk_pool.iv);
|
||||
}
|
||||
@@ -767,14 +752,13 @@ static int init_uadk_bd_pool(void)
|
||||
if (!g_optype)
|
||||
get_aead_data(g_uadk_pool.pool[i].bds[j].src,
|
||||
g_pktlen + SEC_AEAD_LEN);
|
||||
- else
|
||||
+ else {
|
||||
read_aead_dst_data(g_uadk_pool.pool[i].bds[j].src,
|
||||
g_pktlen + SEC_AEAD_LEN);
|
||||
+ memcpy(g_uadk_pool.pool[i].bds[j].mac, g_save_mac, SEC_MAX_MAC_LEN);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
-
|
||||
- if (g_alg == AEAD_TYPE && g_optype)
|
||||
- memcpy(g_uadk_pool.mac[i], g_save_mac, SEC_MAX_MAC_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,7 +941,7 @@ 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;
|
||||
+ u8 *priv_iv, *priv_key, *priv_hash;
|
||||
u32 auth_size = SEC_PERF_AUTH_SIZE;
|
||||
struct wd_aead_req areq;
|
||||
struct bd_pool *uadk_pool;
|
||||
@@ -972,7 +956,6 @@ static void *sec_uadk_aead_async(void *arg)
|
||||
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_hash = g_uadk_pool.hash[pdata->td_id];
|
||||
|
||||
memset(priv_iv, DEF_IVK_DATA, MAX_IVK_LENTH);
|
||||
@@ -1010,7 +993,7 @@ static void *sec_uadk_aead_async(void *arg)
|
||||
|
||||
areq.op_type = pdata->optype;
|
||||
areq.iv = priv_iv; // aead IV need update with param
|
||||
- areq.mac = priv_mac;
|
||||
+ areq.mac = uadk_pool->bds[0].mac;
|
||||
areq.iv_bytes = pdata->ivsize;
|
||||
areq.mac_bytes = auth_size;
|
||||
areq.assoc_bytes = SEC_AEAD_LEN;
|
||||
@@ -1033,6 +1016,7 @@ static void *sec_uadk_aead_async(void *arg)
|
||||
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) {
|
||||
@@ -1188,7 +1172,7 @@ 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_mac, *priv_hash;
|
||||
+ u8 *priv_iv, *priv_key, *priv_hash;
|
||||
u32 auth_size = SEC_PERF_AUTH_SIZE;
|
||||
struct wd_aead_req areq;
|
||||
struct bd_pool *uadk_pool;
|
||||
@@ -1203,7 +1187,6 @@ static void *sec_uadk_aead_sync(void *arg)
|
||||
|
||||
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_hash = g_uadk_pool.hash[pdata->td_id];
|
||||
|
||||
memset(priv_iv, DEF_IVK_DATA, MAX_IVK_LENTH);
|
||||
@@ -1212,8 +1195,8 @@ static void *sec_uadk_aead_sync(void *arg)
|
||||
aead_setup.calg = pdata->alg;
|
||||
aead_setup.cmode = pdata->mode;
|
||||
if (pdata->is_union) {
|
||||
- aead_setup.dalg = WD_DIGEST_SHA256;
|
||||
- aead_setup.dmode = WD_DIGEST_HMAC;
|
||||
+ aead_setup.dalg = pdata->dalg;
|
||||
+ aead_setup.dmode = pdata->dmode;
|
||||
}
|
||||
h_sess = wd_aead_alloc_sess(&aead_setup);
|
||||
if (!h_sess)
|
||||
@@ -1241,7 +1224,7 @@ static void *sec_uadk_aead_sync(void *arg)
|
||||
|
||||
areq.op_type = pdata->optype;
|
||||
areq.iv = priv_iv; // aead IV need update with param
|
||||
- areq.mac = priv_mac;
|
||||
+ areq.mac = uadk_pool->bds[0].mac;
|
||||
areq.iv_bytes = pdata->ivsize;
|
||||
areq.assoc_bytes = SEC_AEAD_LEN;
|
||||
areq.in_bytes = g_pktlen;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
217
0063-uadk-tools-Update-test-function-for-init2.patch
Normal file
217
0063-uadk-tools-Update-test-function-for-init2.patch
Normal file
@ -0,0 +1,217 @@
|
||||
From ab37cec169fc17a7aa2e661db55ea9892e8ec78d Mon Sep 17 00:00:00 2001
|
||||
From: Longfang Liu <liulongfang@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:32 +0800
|
||||
Subject: [PATCH 63/85] uadk/tools: Update test function for init2
|
||||
|
||||
Added support for init2 performance test function for uadk_tools
|
||||
|
||||
Signed-off-by: Longfang Liu <liulongfang@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/uadk_benchmark.c | 108 +++++++++++++++++++++++++++
|
||||
uadk_tool/benchmark/uadk_benchmark.h | 8 ++
|
||||
2 files changed, 116 insertions(+)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
index aa884bc..26b381e 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
@@ -137,6 +137,86 @@ static struct acc_alg_item alg_options[] = {
|
||||
{"", ALG_MAX}
|
||||
};
|
||||
|
||||
+static struct acc_alg_item alg_name_options[] = {
|
||||
+ {"zlib", ZLIB},
|
||||
+ {"gzip", GZIP},
|
||||
+ {"deflate", DEFLATE},
|
||||
+ {"lz77_zstd", LZ77_ZSTD},
|
||||
+ {"rsa", RSA_1024},
|
||||
+ {"rsa", RSA_2048},
|
||||
+ {"rsa", RSA_3072},
|
||||
+ {"rsa", RSA_4096},
|
||||
+ {"rsa", RSA_1024_CRT},
|
||||
+ {"rsa", RSA_2048_CRT},
|
||||
+ {"rsa", RSA_3072_CRT},
|
||||
+ {"rsa", RSA_4096_CRT},
|
||||
+ {"dh", DH_768},
|
||||
+ {"dh", DH_1024},
|
||||
+ {"dh", DH_1536},
|
||||
+ {"dh", DH_2048},
|
||||
+ {"dh", DH_3072},
|
||||
+ {"dh", DH_4096},
|
||||
+ {"ecdh", ECDH_256},
|
||||
+ {"ecdh", ECDH_384},
|
||||
+ {"ecdh", ECDH_521},
|
||||
+ {"ecdsa", ECDSA_256},
|
||||
+ {"ecdsa", ECDSA_384},
|
||||
+ {"ecdsa", ECDSA_521},
|
||||
+ {"sm2", SM2_ALG},
|
||||
+ {"x25519", X25519_ALG},
|
||||
+ {"x448", X448_ALG},
|
||||
+ {"ecb(aes)", AES_128_ECB},
|
||||
+ {"ecb(aes)", AES_192_ECB},
|
||||
+ {"ecb(aes)", AES_256_ECB},
|
||||
+ {"cbc(aes)", AES_128_CBC},
|
||||
+ {"cbc(aes)", AES_192_CBC},
|
||||
+ {"cbc(aes)", AES_256_CBC},
|
||||
+ {"ctr(aes)", AES_128_CTR},
|
||||
+ {"ctr(aes)", AES_192_CTR},
|
||||
+ {"ctr(aes)", AES_256_CTR},
|
||||
+ {"ofb(aes)", AES_128_OFB},
|
||||
+ {"ofb(aes)", AES_192_OFB},
|
||||
+ {"ofb(aes)", AES_256_OFB},
|
||||
+ {"cfb(aes)", AES_128_CFB},
|
||||
+ {"cfb(aes)", AES_192_CFB},
|
||||
+ {"cfb(aes)", AES_256_CFB},
|
||||
+ {"xts(aes)", AES_256_XTS},
|
||||
+ {"xts(aes)", AES_512_XTS},
|
||||
+ {"ecb(des3_ede)", DES3_128_ECB},
|
||||
+ {"ecb(des3_ede)", DES3_192_ECB},
|
||||
+ {"cbc(des3_ede)", DES3_128_CBC},
|
||||
+ {"cbc(des3_ede)", DES3_192_CBC},
|
||||
+ {"ecb(sm4)", SM4_128_ECB},
|
||||
+ {"cbc(sm4)", SM4_128_CBC},
|
||||
+ {"ctr(sm4)", SM4_128_CTR},
|
||||
+ {"ofb(sm4)", SM4_128_OFB},
|
||||
+ {"cfb(sm4)", SM4_128_CFB},
|
||||
+ {"xts(sm4)", SM4_128_XTS},
|
||||
+ {"ccm(aes)", AES_128_CCM},
|
||||
+ {"ccm(aes)", AES_192_CCM},
|
||||
+ {"ccm(aes)", AES_256_CCM},
|
||||
+ {"gcm(aes)", AES_128_GCM},
|
||||
+ {"gcm(aes)", AES_192_GCM},
|
||||
+ {"gcm(aes)", AES_256_GCM},
|
||||
+ {"authenc(hmac(sha256),cbc(aes))", AES_128_CBC_SHA256_HMAC},
|
||||
+ {"authenc(hmac(sha256),cbc(aes))", AES_192_CBC_SHA256_HMAC},
|
||||
+ {"authenc(hmac(sha256),cbc(aes))", AES_256_CBC_SHA256_HMAC},
|
||||
+ {"ccm(sm4)", SM4_128_CCM},
|
||||
+ {"gcm(sm4)", SM4_128_GCM},
|
||||
+ {"sm3", SM3_ALG},
|
||||
+ {"md5", MD5_ALG},
|
||||
+ {"sha1", SHA1_ALG},
|
||||
+ {"sha256", SHA256_ALG},
|
||||
+ {"sha224", SHA224_ALG},
|
||||
+ {"sha384", SHA384_ALG},
|
||||
+ {"sha512", SHA512_ALG},
|
||||
+ {"sha512-224", SHA512_224},
|
||||
+ {"sha512-256", SHA512_256},
|
||||
+ {"trng", TRNG},
|
||||
+ {"", ALG_MAX}
|
||||
+};
|
||||
+
|
||||
+
|
||||
/*-------------------------------------tool code------------------------------------------------------*/
|
||||
void add_send_complete(void)
|
||||
{
|
||||
@@ -194,6 +274,20 @@ static int get_alg_type(const char *alg_name)
|
||||
return alg;
|
||||
}
|
||||
|
||||
+int get_alg_name(int alg, char *alg_name)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ALG_MAX; i++) {
|
||||
+ if (alg == alg_name_options[i].alg) {
|
||||
+ strcpy(alg_name, alg_name_options[i].name);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return -EINVAL;
|
||||
+}
|
||||
+
|
||||
static int get_mode_type(const char *mode_name)
|
||||
{
|
||||
u32 modetype = INVALID_MODE;
|
||||
@@ -491,6 +585,8 @@ static void dump_param(struct acc_option *option)
|
||||
ACC_TST_PRT(" [--acctype]: %u\n", option->acctype);
|
||||
ACC_TST_PRT(" [--prefetch]:%u\n", option->prefetch);
|
||||
ACC_TST_PRT(" [--engine]: %s\n", option->engine);
|
||||
+ ACC_TST_PRT(" [--latency]: %u\n", option->latency);
|
||||
+ ACC_TST_PRT(" [--init2]: %u\n", option->inittype);
|
||||
}
|
||||
|
||||
int acc_benchmark_run(struct acc_option *option)
|
||||
@@ -571,6 +667,7 @@ int acc_default_case(struct acc_option *option)
|
||||
option->threads = 1;
|
||||
option->multis = 1;
|
||||
option->ctxnums = 2;
|
||||
+ option->inittype = INIT_TYPE;
|
||||
|
||||
return acc_benchmark_run(option);
|
||||
}
|
||||
@@ -611,6 +708,8 @@ static void print_help(void)
|
||||
ACC_TST_PRT(" list the all support alg\n");
|
||||
ACC_TST_PRT(" [--latency]:\n");
|
||||
ACC_TST_PRT(" test the running time of packets\n");
|
||||
+ ACC_TST_PRT(" [--init2]:\n");
|
||||
+ ACC_TST_PRT(" select init2 mode in the init interface of UADK SVA\n");
|
||||
ACC_TST_PRT(" [--help] = usage\n");
|
||||
ACC_TST_PRT("Example\n");
|
||||
ACC_TST_PRT(" ./uadk_tool benchmark --alg aes-128-cbc --mode sva --opt 0 --sync\n");
|
||||
@@ -651,6 +750,7 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
||||
{"latency", no_argument, 0, 14},
|
||||
{"winsize", required_argument, 0, 15},
|
||||
{"complevel", required_argument, 0, 16},
|
||||
+ {"init2", no_argument, 0, 17},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -712,6 +812,9 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
||||
case 16:
|
||||
option->complevel = strtol(optarg, NULL, 0);
|
||||
break;
|
||||
+ case 17:
|
||||
+ option->inittype = INIT2_TYPE;
|
||||
+ break;
|
||||
default:
|
||||
ACC_TST_PRT("bad input test parameter!\n");
|
||||
print_help();
|
||||
@@ -783,6 +886,11 @@ int acc_option_convert(struct acc_option *option)
|
||||
goto param_err;
|
||||
}
|
||||
|
||||
+ if (option->inittype == INIT2_TYPE && option->modetype != SVA_MODE) {
|
||||
+ ACC_TST_PRT("uadk benchmark No-SVA mode can't use init2\n");
|
||||
+ goto param_err;
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
|
||||
param_err:
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
index 71fe2dc..3a33fd8 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.h
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
@@ -73,6 +73,7 @@ struct acc_option {
|
||||
u32 prefetch;
|
||||
u32 winsize;
|
||||
u32 complevel;
|
||||
+ u32 inittype;
|
||||
bool latency;
|
||||
};
|
||||
|
||||
@@ -83,6 +84,12 @@ enum acc_type {
|
||||
TRNG_TYPE,
|
||||
};
|
||||
|
||||
+enum acc_init_type {
|
||||
+ INIT_TYPE = 0,
|
||||
+ INIT2_TYPE,
|
||||
+ MAX_TYPE,
|
||||
+};
|
||||
+
|
||||
enum alg_type {
|
||||
DEFAULT_TYPE,
|
||||
CIPHER_TYPE,
|
||||
@@ -192,6 +199,7 @@ extern void add_recv_data(u32 cnt, u32 pkglen);
|
||||
extern void add_send_complete(void);
|
||||
extern u32 get_recv_time(void);
|
||||
extern void cal_avg_latency(u32 count);
|
||||
+extern int get_alg_name(int alg, char *alg_name);
|
||||
|
||||
int acc_cmd_parse(int argc, char *argv[], struct acc_option *option);
|
||||
int acc_default_case(struct acc_option *option);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
531
0064-uadk-support-some-uadk-dfx-stronger-feature.patch
Normal file
531
0064-uadk-support-some-uadk-dfx-stronger-feature.patch
Normal file
@ -0,0 +1,531 @@
|
||||
From d06338f09aa0e36078c789b6203d2a1801fddbd5 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:33 +0800
|
||||
Subject: [PATCH 64/85] uadk: support some uadk dfx stronger feature
|
||||
|
||||
add some dfx dumping interface as task error.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
Signed-off-by: Longfang Liu <liulongfang@huawei.com>
|
||||
---
|
||||
uadk_tool/test/test_sec.c | 140 +++++++++++++++++---------------------
|
||||
1 file changed, 64 insertions(+), 76 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/test/test_sec.c b/uadk_tool/test/test_sec.c
|
||||
index 9594e61..c8bfdf4 100644
|
||||
--- a/uadk_tool/test/test_sec.c
|
||||
+++ b/uadk_tool/test/test_sec.c
|
||||
@@ -126,8 +126,8 @@ struct sva_bd_pool {
|
||||
};
|
||||
|
||||
typedef struct _thread_data_t {
|
||||
- int tid;
|
||||
- int flag;
|
||||
+ int tid;
|
||||
+ int flag;
|
||||
int mode;
|
||||
int cpu_id;
|
||||
struct sva_bd_pool *bd_pool;
|
||||
@@ -172,7 +172,6 @@ struct test_sec_option {
|
||||
__u32 init;
|
||||
};
|
||||
|
||||
-//static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
||||
static pthread_mutex_t test_sec_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_t system_test_thrds[THREADS_NUM];
|
||||
static thread_data_t thr_data[THREADS_NUM];
|
||||
@@ -304,7 +303,7 @@ static inline void copy_mem(int dst_sgl, void *dst, int src_sgl, void *src,
|
||||
SEC_TST_PRT("Not supported memory type for copy.\n");
|
||||
}
|
||||
|
||||
-static void dump_mem(int sgl, unsigned char *buf, size_t len)
|
||||
+static void dump_mem(const char *str, int sgl, unsigned char *buf, size_t len)
|
||||
{
|
||||
struct wd_datalist *p;
|
||||
size_t i, tmp;
|
||||
@@ -314,6 +313,8 @@ static void dump_mem(int sgl, unsigned char *buf, size_t len)
|
||||
return;
|
||||
}
|
||||
|
||||
+ SEC_TST_PRT("%s\n", str);
|
||||
+
|
||||
if (sgl == WD_FLAT_BUF) {
|
||||
for (i = 0; i < len; i++) {
|
||||
SEC_TST_PRT("\\0x%02x", buf[i]);
|
||||
@@ -693,7 +694,7 @@ static int test_sec_cipher_sync_once(void)
|
||||
float speed, time_used;
|
||||
int pid = getpid();
|
||||
int cnt = g_times;
|
||||
- size_t unit_sz;
|
||||
+ size_t unit_sz, len;
|
||||
int ret;
|
||||
|
||||
/* config setup */
|
||||
@@ -713,9 +714,10 @@ static int test_sec_cipher_sync_once(void)
|
||||
req.op_type = WD_CIPHER_DECRYPTION;
|
||||
|
||||
/* get resource */
|
||||
- ret = get_cipher_resource(&tv, (int *)&setup.alg, (int *)&setup.mode);
|
||||
+ (void)get_cipher_resource(&tv, (int *)&setup.alg, (int *)&setup.mode);
|
||||
|
||||
- req.in_bytes = tv->len;
|
||||
+ len = g_pktlen < tv->len ? g_pktlen : tv->len;
|
||||
+ req.in_bytes = len;
|
||||
unit_sz = cal_unit_sz(req.in_bytes, g_sgl_num);
|
||||
req.src = create_buf(g_data_fmt, req.in_bytes, unit_sz);
|
||||
if (!req.src) {
|
||||
@@ -723,17 +725,18 @@ static int test_sec_cipher_sync_once(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- SEC_TST_PRT("req src--------->:\n");
|
||||
if (g_direction == 0)
|
||||
copy_mem(g_data_fmt, req.src, WD_FLAT_BUF,
|
||||
(void *)tv->ptext, (size_t)tv->len);
|
||||
else
|
||||
copy_mem(g_data_fmt, req.src, WD_FLAT_BUF,
|
||||
(void *)tv->ctext, (size_t)tv->len);
|
||||
- dump_mem(g_data_fmt, req.src, req.in_bytes);
|
||||
|
||||
- req.out_bytes = tv->len;
|
||||
- req.out_buf_bytes = g_pktlen;
|
||||
+ dump_mem("req src--->:", g_data_fmt, req.src, req.in_bytes);
|
||||
+ SEC_TST_PRT("input_len: %u, ready to dump sgl ? fmt:%d\n", req.in_bytes, g_data_fmt);
|
||||
+
|
||||
+ req.out_bytes = len;
|
||||
+ req.out_buf_bytes = len;
|
||||
req.data_fmt = g_data_fmt;
|
||||
req.dst = create_buf(g_data_fmt, req.out_buf_bytes, unit_sz);
|
||||
if (!req.dst) {
|
||||
@@ -753,8 +756,7 @@ static int test_sec_cipher_sync_once(void)
|
||||
memset(req.iv, 0, req.iv_bytes);
|
||||
if (tv->iv)
|
||||
memcpy(req.iv, tv->iv, strlen(tv->iv));
|
||||
- SEC_TST_PRT("cipher req iv--------->:\n");
|
||||
- dump_mem(WD_FLAT_BUF, req.iv, req.iv_bytes);
|
||||
+ dump_mem("cipher req iv--->:", WD_FLAT_BUF, req.iv, req.iv_bytes);
|
||||
}
|
||||
|
||||
h_sess = wd_cipher_alloc_sess(&setup);
|
||||
@@ -768,7 +770,6 @@ static int test_sec_cipher_sync_once(void)
|
||||
SEC_TST_PRT("req set key failed!\n");
|
||||
goto out_key;
|
||||
}
|
||||
- SEC_TST_PRT("cipher req key--------->:\n");
|
||||
|
||||
gettimeofday(&bg_tval, NULL);
|
||||
while (cnt) {
|
||||
@@ -784,8 +785,7 @@ static int test_sec_cipher_sync_once(void)
|
||||
SEC_TST_PRT("Pro-%d, thread_id-%d, speed:%0.3f ops, Perf: %ld KB/s\n", pid,
|
||||
thread_id, speed, Perf);
|
||||
|
||||
- SEC_TST_PRT("Test cipher sync function: output dst-->\n");
|
||||
- dump_mem(g_data_fmt, req.dst, req.out_bytes);
|
||||
+ dump_mem("Test cipher sync function: output dst-->", g_data_fmt, req.dst, req.out_bytes);
|
||||
|
||||
out_key:
|
||||
wd_cipher_free_sess(h_sess);
|
||||
@@ -849,7 +849,7 @@ static int test_sec_cipher_async_once(void)
|
||||
}
|
||||
|
||||
/* get resource */
|
||||
- ret = get_cipher_resource(&tv, (int *)&setup.alg, (int *)&setup.mode);
|
||||
+ (void)get_cipher_resource(&tv, (int *)&setup.alg, (int *)&setup.mode);
|
||||
|
||||
req.data_fmt = g_data_fmt;
|
||||
req.in_bytes = g_pktlen;
|
||||
@@ -860,14 +860,13 @@ static int test_sec_cipher_async_once(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- SEC_TST_PRT("req src--------->:\n");
|
||||
if (g_direction == 0)
|
||||
copy_mem(g_data_fmt, req.src, WD_FLAT_BUF,
|
||||
(void *)tv->ptext, (size_t)tv->len);
|
||||
else
|
||||
copy_mem(g_data_fmt, req.src, WD_FLAT_BUF,
|
||||
(void *)tv->ctext, (size_t)tv->len);
|
||||
- dump_mem(g_data_fmt, req.src, req.in_bytes);
|
||||
+ dump_mem("req src--->:", g_data_fmt, req.src, req.in_bytes);
|
||||
|
||||
req.out_bytes = tv->len;
|
||||
req.out_buf_bytes = BUFF_SIZE;
|
||||
@@ -877,6 +876,7 @@ static int test_sec_cipher_async_once(void)
|
||||
goto out_dst;
|
||||
}
|
||||
|
||||
+
|
||||
req.iv = malloc(IV_SIZE);
|
||||
if (!req.iv) {
|
||||
ret = -ENOMEM;
|
||||
@@ -889,8 +889,7 @@ static int test_sec_cipher_async_once(void)
|
||||
memset(req.iv, 0, req.iv_bytes);
|
||||
if (tv->iv)
|
||||
memcpy(req.iv, tv->iv, strlen(tv->iv));
|
||||
- SEC_TST_PRT("cipher req iv--------->:\n");
|
||||
- dump_mem(WD_FLAT_BUF, req.iv, req.iv_bytes);
|
||||
+ dump_mem("cipher req iv--->:", WD_FLAT_BUF, req.iv, req.iv_bytes);
|
||||
}
|
||||
h_sess = wd_cipher_alloc_sess(&setup);
|
||||
if (!h_sess) {
|
||||
@@ -903,7 +902,7 @@ static int test_sec_cipher_async_once(void)
|
||||
SEC_TST_PRT("req set key failed!\n");
|
||||
goto out_key;
|
||||
}
|
||||
- SEC_TST_PRT("cipher req key--------->:\n");
|
||||
+
|
||||
gettimeofday(&bg_tval, NULL);
|
||||
while (cnt) {
|
||||
req.cb = async_cb;
|
||||
@@ -971,7 +970,7 @@ static int test_sec_cipher_sync(void *arg)
|
||||
int ret;
|
||||
|
||||
/* get resource */
|
||||
- ret = get_cipher_resource(&tv, (int *)&setup->alg, (int *)&setup->mode);
|
||||
+ (void)get_cipher_resource(&tv, (int *)&setup->alg, (int *)&setup->mode);
|
||||
|
||||
h_sess = wd_cipher_alloc_sess(setup);
|
||||
if (!h_sess) {
|
||||
@@ -980,11 +979,10 @@ static int test_sec_cipher_sync(void *arg)
|
||||
}
|
||||
|
||||
pktlen = req->in_bytes;
|
||||
- SEC_TST_PRT("cipher req src--------->:\n");
|
||||
- dump_mem(g_data_fmt, req->src, req->in_bytes);
|
||||
+ dump_mem("cipher req src--->:", g_data_fmt, req->src, req->in_bytes);
|
||||
|
||||
- SEC_TST_PRT("ivlen = %d, cipher req iv--------->:\n", req->iv_bytes);
|
||||
- dump_mem(WD_FLAT_BUF, req->iv, req->iv_bytes);
|
||||
+ SEC_TST_PRT("ivlen = %d\n", req->iv_bytes);
|
||||
+ dump_mem("cipher req iv--->:", WD_FLAT_BUF, req->iv, req->iv_bytes);
|
||||
|
||||
ret = wd_cipher_set_key(h_sess, (const __u8*)tv->key, tv->klen);
|
||||
if (ret) {
|
||||
@@ -992,8 +990,6 @@ static int test_sec_cipher_sync(void *arg)
|
||||
goto out;;
|
||||
}
|
||||
|
||||
- SEC_TST_PRT("cipher req key--------->:\n");
|
||||
-
|
||||
pthread_mutex_lock(&test_sec_mutex);
|
||||
/* run task */
|
||||
while (cnt) {
|
||||
@@ -1080,7 +1076,7 @@ static int sec_cipher_sync_test(void)
|
||||
memset(setup, 0, sizeof(struct wd_cipher_sess_setup) * THREADS_NUM);
|
||||
|
||||
/* get resource */
|
||||
- ret = get_cipher_resource(&tv, &test_alg, &test_mode);
|
||||
+ (void)get_cipher_resource(&tv, &test_alg, &test_mode);
|
||||
|
||||
iv = calloc(1, IV_SIZE * THREADS_NUM);
|
||||
if (!iv) {
|
||||
@@ -1088,7 +1084,6 @@ static int sec_cipher_sync_test(void)
|
||||
goto out_iv;
|
||||
}
|
||||
|
||||
-
|
||||
len = g_pktlen < tv->len ? g_pktlen : tv->len;
|
||||
unit_sz = cal_unit_sz(len, g_sgl_num);
|
||||
for (i = 0; i < parallel; i++) {
|
||||
@@ -1131,7 +1126,7 @@ static int sec_cipher_sync_test(void)
|
||||
|
||||
ret = init_ctx_config(CTX_TYPE_ENCRYPT, CTX_MODE_SYNC);
|
||||
if (ret) {
|
||||
- SEC_TST_PRT("fail to init sigle ctx config!\n");
|
||||
+ SEC_TST_PRT("failed to init sigle ctx config!\n");
|
||||
goto out_cfg;
|
||||
}
|
||||
|
||||
@@ -1172,7 +1167,7 @@ static int test_sec_cipher_async(void *arg)
|
||||
int ret;
|
||||
|
||||
/* get resource */
|
||||
- ret = get_cipher_resource(&tv, (int *)&setup->alg, (int *)&setup->mode);
|
||||
+ (void)get_cipher_resource(&tv, (int *)&setup->alg, (int *)&setup->mode);
|
||||
|
||||
h_sess = wd_cipher_alloc_sess(setup);
|
||||
if (!h_sess) {
|
||||
@@ -1187,7 +1182,6 @@ static int test_sec_cipher_async(void *arg)
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&test_sec_mutex);
|
||||
- // pthread_cond_wait(&cond, &test_sec_mutex);
|
||||
/* run task */
|
||||
do {
|
||||
try_do_again:
|
||||
@@ -1469,8 +1463,8 @@ out:
|
||||
|
||||
static int digest_init2(int type, int mode)
|
||||
{
|
||||
- struct wd_ctx_params cparams = {0};
|
||||
struct wd_ctx_nums *ctx_set_num;
|
||||
+ struct wd_ctx_params cparams;
|
||||
int ret;
|
||||
|
||||
if (g_testalg >= MAX_ALGO_PER_TYPE)
|
||||
@@ -1847,10 +1841,9 @@ static int sec_digest_sync_once(void)
|
||||
|
||||
req.in_bytes = tv->psize;
|
||||
|
||||
- SEC_TST_PRT("req src in--------->:\n");
|
||||
copy_mem(g_data_fmt, req.in, WD_FLAT_BUF,
|
||||
(void *)tv->plaintext, tv->psize);
|
||||
- dump_mem(g_data_fmt, req.in, req.in_bytes);
|
||||
+ dump_mem("req src in--->:", g_data_fmt, req.in, req.in_bytes);
|
||||
|
||||
req.out = create_buf(WD_FLAT_BUF, BUFF_SIZE, unit_sz);
|
||||
if (!req.out) {
|
||||
@@ -1905,7 +1898,7 @@ static int sec_digest_sync_once(void)
|
||||
SEC_TST_PRT("time_used:%0.0f us, send task num:%lld\n", time_used, g_times);
|
||||
SEC_TST_PRT("Pro-%d, thread_id-%d, speed:%0.3f ops, Perf: %ld KB/s\n", getpid(),
|
||||
(int)syscall(__NR_gettid), speed, Perf);
|
||||
- dump_mem(WD_FLAT_BUF, req.out, req.out_bytes);
|
||||
+ dump_mem("req's out--->", WD_FLAT_BUF, req.out, req.out_bytes);
|
||||
|
||||
out_key:
|
||||
wd_digest_free_sess(h_sess);
|
||||
@@ -1981,8 +1974,8 @@ static int sec_digest_sync_stream_cmp(void)
|
||||
cnt--;
|
||||
}
|
||||
|
||||
- SEC_TST_PRT("one hash BD dump the out memory, cmp the stream mode:\n");
|
||||
- dump_mem(WD_FLAT_BUF, req.out, 16);
|
||||
+ char digest_str[] = "one hash BD dump the out memory, cmp the stream mode:";
|
||||
+ dump_mem(digest_str, WD_FLAT_BUF, req.out, 16);
|
||||
|
||||
out_key:
|
||||
wd_digest_free_sess(h_sess);
|
||||
@@ -2080,8 +2073,8 @@ static int sec_digest_sync_stream_mode(void)
|
||||
memcpy(req.in, tv->plaintext, tv->psize);
|
||||
cnt--;
|
||||
}
|
||||
- SEC_TST_PRT("long hash BD dump the out memory:--------->:\n");
|
||||
- dump_mem(g_data_fmt, req.out, 16);
|
||||
+ char digest_str[] = "long hash BD dump the out memory:--->:";
|
||||
+ dump_mem(digest_str, g_data_fmt, req.out, 16);
|
||||
|
||||
out:
|
||||
free(req.out);
|
||||
@@ -2174,8 +2167,8 @@ void *digest_sync_stream_mode_send_td(void *data)
|
||||
memcpy(req.in, tv->plaintext, tv->psize);
|
||||
cnt--;
|
||||
}
|
||||
- SEC_TST_PRT("Pid - %d, thread-id - %d, long hash BD dump the out memory:\n", getpid(), thread_id);
|
||||
- dump_mem(g_data_fmt, req.out, 16);
|
||||
+ SEC_TST_PRT("Pid - %d, thread-id - %d\n", getpid(), thread_id);
|
||||
+ dump_mem("long hash BD dump the out memory:", g_data_fmt, req.out, 16);
|
||||
out_key:
|
||||
wd_digest_free_sess(h_sess);
|
||||
out:
|
||||
@@ -2370,10 +2363,9 @@ static int sec_digest_async_once(void)
|
||||
|
||||
req.in_bytes = tv->psize;
|
||||
|
||||
- SEC_TST_PRT("req src in--------->:\n");
|
||||
copy_mem(g_data_fmt, req.in, WD_FLAT_BUF,
|
||||
(void *)tv->plaintext, (size_t)tv->psize);
|
||||
- dump_mem(g_data_fmt, req.in, req.in_bytes);
|
||||
+ dump_mem("req src in--->:", g_data_fmt, req.in, req.in_bytes);
|
||||
|
||||
req.out = create_buf(WD_FLAT_BUF, BUFF_SIZE, unit_sz);
|
||||
if (!req.out) {
|
||||
@@ -2430,7 +2422,7 @@ static int sec_digest_async_once(void)
|
||||
SEC_TST_PRT("pthread_join fail at %s", __func__);
|
||||
goto out_thr;
|
||||
}
|
||||
- dump_mem(WD_FLAT_BUF, req.out, req.out_bytes);
|
||||
+ dump_mem("req src out--->:", WD_FLAT_BUF, req.out, req.out_bytes);
|
||||
|
||||
out_thr:
|
||||
out_key:
|
||||
@@ -2477,8 +2469,7 @@ static int sec_digest_sync_multi(void)
|
||||
memcpy(req.in, tv->plaintext, tv->psize);
|
||||
req.in_bytes = tv->psize;
|
||||
|
||||
- SEC_TST_PRT("req src in--------->:\n");
|
||||
- dump_mem(g_data_fmt, req.in, req.in_bytes);
|
||||
+ dump_mem("req src in--->:", g_data_fmt, req.in, req.in_bytes);
|
||||
|
||||
req.out = create_buf(g_data_fmt, BUFF_SIZE, unit_sz);
|
||||
if (!req.out) {
|
||||
@@ -2532,7 +2523,7 @@ static int sec_digest_sync_multi(void)
|
||||
g_thread_num, td_data.sum_perf,
|
||||
(td_data.sum_perf >> 10) * req.in_bytes);
|
||||
|
||||
- dump_mem(g_data_fmt, req.out, req.out_bytes);
|
||||
+ dump_mem("req src out--->:", g_data_fmt, req.out, req.out_bytes);
|
||||
out_thr:
|
||||
out_key:
|
||||
wd_digest_free_sess(h_sess);
|
||||
@@ -2580,8 +2571,7 @@ static int sec_digest_async_multi(void)
|
||||
}
|
||||
memcpy(req.in, tv->plaintext, tv->psize);
|
||||
req.in_bytes = tv->psize;
|
||||
- SEC_TST_PRT("req src in--------->:\n");
|
||||
- dump_mem(WD_FLAT_BUF, req.in, tv->psize);
|
||||
+ dump_mem("req src in--->:", WD_FLAT_BUF, req.in, tv->psize);
|
||||
req.out = malloc(BUFF_SIZE);
|
||||
if (!req.out) {
|
||||
SEC_TST_PRT("req dst out mem malloc failed!\n");
|
||||
@@ -2644,7 +2634,7 @@ static int sec_digest_async_multi(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
- dump_mem(WD_FLAT_BUF, req.out, req.out_bytes);
|
||||
+ dump_mem("req src out--->:", WD_FLAT_BUF, req.out, req.out_bytes);
|
||||
out:
|
||||
if (req.in)
|
||||
free(req.in);
|
||||
@@ -2721,8 +2711,8 @@ out:
|
||||
|
||||
static int aead_init2(int type, int mode)
|
||||
{
|
||||
- struct wd_ctx_params cparams = {0};
|
||||
struct wd_ctx_nums *ctx_set_num;
|
||||
+ struct wd_ctx_params cparams;
|
||||
int ret;
|
||||
|
||||
if (g_testalg >= MAX_ALGO_PER_TYPE)
|
||||
@@ -2931,7 +2921,7 @@ static int sec_aead_sync_once(void)
|
||||
}
|
||||
|
||||
/* should set key */
|
||||
- dump_mem(WD_FLAT_BUF, (void *)tv->key, tv->klen);
|
||||
+ dump_mem("req src key--->:", WD_FLAT_BUF, (void *)tv->key, tv->klen);
|
||||
if (setup.cmode == WD_CIPHER_CCM || setup.cmode == WD_CIPHER_GCM) {
|
||||
ret = wd_aead_set_ckey(h_sess, (const __u8*)tv->key, tv->klen);
|
||||
if (ret) {
|
||||
@@ -3023,8 +3013,7 @@ static int sec_aead_sync_once(void)
|
||||
memcpy(req.mac, tv->ctext + tv->clen - auth_size, auth_size);
|
||||
}
|
||||
|
||||
- SEC_TST_PRT("mac addr src is:\n");
|
||||
- dump_mem(0, req.mac, auth_size);
|
||||
+ dump_mem("mac addr src is:", 0, req.mac, auth_size);
|
||||
|
||||
req.src = create_buf(g_data_fmt, in_size, unit_sz);
|
||||
if (!req.src) {
|
||||
@@ -3034,8 +3023,8 @@ static int sec_aead_sync_once(void)
|
||||
copy_mem(g_data_fmt, req.src, WD_FLAT_BUF, src,
|
||||
(size_t)(req.in_bytes + tv->alen));
|
||||
free(src);
|
||||
- SEC_TST_PRT("aead req src in--------->: %u\n", tv->alen + req.in_bytes);
|
||||
- dump_mem(g_data_fmt, req.src, tv->alen + req.in_bytes);
|
||||
+ SEC_TST_PRT("aead req src len: %u\n", tv->alen + req.in_bytes);
|
||||
+ dump_mem("aead req src in--->", g_data_fmt, req.src, tv->alen + req.in_bytes);
|
||||
|
||||
if (g_direction == 0) {
|
||||
req.out_bytes = req.assoc_bytes + tv->clen - auth_size;
|
||||
@@ -3081,10 +3070,8 @@ static int sec_aead_sync_once(void)
|
||||
SEC_TST_PRT("Pro-%d, thread_id-%d, speed:%0.3f ops, Perf: %ld KB/s\n", getpid(),
|
||||
(int)syscall(__NR_gettid), speed, Perf);
|
||||
|
||||
- SEC_TST_PRT("aead dump out addr is:\n");
|
||||
- dump_mem(g_data_fmt, req.dst, req.out_bytes);
|
||||
- SEC_TST_PRT("aead dump mac addr is:\n");
|
||||
- dump_mem(0, req.mac, auth_size);
|
||||
+ dump_mem("aead dump out addr is:", g_data_fmt, req.dst, req.out_bytes);
|
||||
+ dump_mem("aead dump mac addr is:", 0, req.mac, auth_size);
|
||||
|
||||
free(req.iv);
|
||||
out_iv:
|
||||
@@ -3169,7 +3156,7 @@ void *aead_poll_thread(void *data)
|
||||
time_used = (float)((cur_tval.tv_sec - td_data->start_tval.tv_sec) * 1000000 +
|
||||
cur_tval.tv_usec - td_data->start_tval.tv_usec);
|
||||
speed = cnt / time_used * 1000000;
|
||||
- Perf = speed * req->in_bytes / 1024; //B->KB
|
||||
+ Perf = speed * req->in_bytes / 1024;
|
||||
pthread_mutex_unlock(&test_sec_mutex);
|
||||
SEC_TST_PRT("time_used:%0.0f us, send task num:%ld\n", time_used, cnt);
|
||||
SEC_TST_PRT("Pro-%d, thread_id-%d, speed:%0.3f ops, Perf: %ld KB/s\n", getpid(),
|
||||
@@ -3255,7 +3242,7 @@ static int sec_aead_async_once(void)
|
||||
}
|
||||
|
||||
/* should set key */
|
||||
- dump_mem(WD_FLAT_BUF, (void *)tv->key, tv->klen);
|
||||
+ dump_mem("aead dump aead key is:", WD_FLAT_BUF, (void *)tv->key, tv->klen);
|
||||
if (setup.cmode == WD_CIPHER_CCM || setup.cmode == WD_CIPHER_GCM) {
|
||||
ret = wd_aead_set_ckey(h_sess, (const __u8*)tv->key, tv->klen);
|
||||
if (ret) {
|
||||
@@ -3349,8 +3336,8 @@ static int sec_aead_async_once(void)
|
||||
copy_mem(g_data_fmt, req.src, WD_FLAT_BUF, src,
|
||||
(size_t)(req.in_bytes + tv->alen));
|
||||
free(src);
|
||||
- SEC_TST_PRT("aead req alen---->: %u. in_bytes--->:%u\n", tv->alen, req.in_bytes);
|
||||
- dump_mem(g_data_fmt, req.src, tv->alen + req.in_bytes);
|
||||
+ SEC_TST_PRT("aead req alen--->: %u. in_bytes--->:%u\n", tv->alen, req.in_bytes);
|
||||
+ dump_mem("aead dump req in is:", g_data_fmt, req.src, tv->alen + req.in_bytes);
|
||||
|
||||
// alloc out buffer memory
|
||||
req.dst = create_buf(g_data_fmt, BUFF_SIZE, unit_sz);
|
||||
@@ -3411,7 +3398,8 @@ static int sec_aead_async_once(void)
|
||||
goto out_thr;
|
||||
}
|
||||
|
||||
- dump_mem(g_data_fmt, req.dst, req.out_bytes);
|
||||
+ dump_mem("dump aead dst data", g_data_fmt, req.dst, req.out_bytes);
|
||||
+ dump_mem("dump aead dst mac", g_data_fmt, req.mac, 8);
|
||||
out_thr:
|
||||
free(req.iv);
|
||||
out_iv:
|
||||
@@ -3467,7 +3455,7 @@ static int sec_aead_sync_multi(void)
|
||||
}
|
||||
|
||||
/* should set key */
|
||||
- dump_mem(WD_FLAT_BUF, (void *)tv->key, tv->klen);
|
||||
+ dump_mem("dump aead key", WD_FLAT_BUF, (void *)tv->key, tv->klen);
|
||||
if (setup.cmode == WD_CIPHER_CCM || setup.cmode == WD_CIPHER_GCM) {
|
||||
ret = wd_aead_set_ckey(h_sess, (const __u8*)tv->key, tv->klen);
|
||||
if (ret) {
|
||||
@@ -3562,8 +3550,8 @@ static int sec_aead_sync_multi(void)
|
||||
(size_t)(req.in_bytes + tv->alen));
|
||||
free(src);
|
||||
|
||||
- SEC_TST_PRT("aead req src in>: alen:%u, input len:%d\n", tv->alen, req.in_bytes);
|
||||
- dump_mem(g_data_fmt, req.src, tv->alen + req.in_bytes);
|
||||
+ SEC_TST_PRT(" alen:%u, input len:%d\n", tv->alen, req.in_bytes);
|
||||
+ dump_mem("aead req src in--->:", g_data_fmt, req.src, tv->alen + req.in_bytes);
|
||||
|
||||
// alloc out buffer memory
|
||||
req.dst = create_buf(g_data_fmt, BUFF_SIZE, unit_sz);
|
||||
@@ -3617,7 +3605,7 @@ static int sec_aead_sync_multi(void)
|
||||
}
|
||||
}
|
||||
|
||||
- dump_mem(g_data_fmt, req.dst, req.out_bytes);
|
||||
+ dump_mem("aead req src out--->:", g_data_fmt, req.dst, req.out_bytes);
|
||||
out_thr:
|
||||
free(req.iv);
|
||||
out_iv:
|
||||
@@ -3674,7 +3662,7 @@ static int sec_aead_async_multi(void)
|
||||
}
|
||||
|
||||
/* should set key */
|
||||
- dump_mem(WD_FLAT_BUF, (void *)tv->key, tv->klen);
|
||||
+ dump_mem("aead set key--->:", WD_FLAT_BUF, (void *)tv->key, tv->klen);
|
||||
if (setup.cmode == WD_CIPHER_CCM || setup.cmode == WD_CIPHER_GCM) {
|
||||
ret = wd_aead_set_ckey(h_sess, (const __u8*)tv->key, tv->klen);
|
||||
if (ret) {
|
||||
@@ -3766,8 +3754,8 @@ static int sec_aead_async_multi(void)
|
||||
copy_mem(g_data_fmt, req.src, WD_FLAT_BUF, src,
|
||||
(size_t)(req.in_bytes + tv->alen));
|
||||
free(src);
|
||||
- SEC_TST_PRT("aead req src in--------->: %u\n", tv->alen + req.in_bytes);
|
||||
- dump_mem(g_data_fmt, req.src, tv->alen + req.in_bytes);
|
||||
+ SEC_TST_PRT("src len: %u\n", tv->alen + req.in_bytes);
|
||||
+ dump_mem("aead req src in--->", g_data_fmt, req.src, tv->alen + req.in_bytes);
|
||||
|
||||
// alloc out buffer memory
|
||||
req.dst = create_buf(g_data_fmt, BUFF_SIZE, unit_sz);
|
||||
@@ -3831,7 +3819,7 @@ static int sec_aead_async_multi(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- dump_mem(g_data_fmt, req.dst, req.out_bytes);
|
||||
+ dump_mem("aead req src out--->", g_data_fmt, req.dst, req.out_bytes);
|
||||
out:
|
||||
if (req.mac)
|
||||
free(req.mac);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
191
0065-uadk-sec-added-init2-performance-test.patch
Normal file
191
0065-uadk-sec-added-init2-performance-test.patch
Normal file
@ -0,0 +1,191 @@
|
||||
From 73307d9181922b4291025d757617a027cfdce94c Mon Sep 17 00:00:00 2001
|
||||
From: Longfang Liu <liulongfang@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:34 +0800
|
||||
Subject: [PATCH 65/85] uadk/sec: added init2 performance test
|
||||
|
||||
Added init2 performance test function for uadk_tools of
|
||||
SEC module.
|
||||
|
||||
Signed-off-by: Longfang Liu <liulongfang@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 119 ++++++++++++++++++++++-
|
||||
1 file changed, 114 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index d0bf871..9f1f903 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -454,10 +454,13 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
+static int init_ctx_config(struct acc_option *options)
|
||||
{
|
||||
struct sched_params param;
|
||||
struct uacce_dev *dev = NULL;
|
||||
+ char *alg = options->algclass;
|
||||
+ int subtype = options->subtype;
|
||||
+ int mode = options->syncmode;
|
||||
int ret, max_node, i;
|
||||
|
||||
max_node = numa_max_node() + 1;
|
||||
@@ -576,6 +579,57 @@ static void uninit_ctx_config(int subtype)
|
||||
wd_sched_rr_release(g_sched);
|
||||
}
|
||||
|
||||
+static void uninit_ctx_config2(int subtype)
|
||||
+{
|
||||
+ /* uninit2 */
|
||||
+ switch(subtype) {
|
||||
+ case CIPHER_TYPE:
|
||||
+ wd_cipher_uninit2();
|
||||
+ break;
|
||||
+ case AEAD_TYPE:
|
||||
+ wd_aead_uninit2();
|
||||
+ break;
|
||||
+ case DIGEST_TYPE:
|
||||
+ wd_digest_uninit2();
|
||||
+ break;
|
||||
+ default:
|
||||
+ SEC_TST_PRT("failed to parse alg subtype on uninit2!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int init_ctx_config2(struct acc_option *options)
|
||||
+{
|
||||
+ char alg_name[64];
|
||||
+ int subtype = options->subtype;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = get_alg_name(options->algtype, alg_name);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("failed to get valid alg name!\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ /* init */
|
||||
+ switch(subtype) {
|
||||
+ case CIPHER_TYPE:
|
||||
+ ret = wd_cipher_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
|
||||
+ break;
|
||||
+ case AEAD_TYPE:
|
||||
+ ret = wd_aead_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
|
||||
+ break;
|
||||
+ case DIGEST_TYPE:
|
||||
+ ret = wd_digest_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
|
||||
+ break;
|
||||
+ }
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("failed to do cipher init2!\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void get_aead_data(u8 *addr, u32 size)
|
||||
{
|
||||
memset(addr, 0, size);
|
||||
@@ -852,7 +906,52 @@ static void *sec_uadk_poll(void *data)
|
||||
count += recv;
|
||||
recv = 0;
|
||||
if (unlikely(ret != -WD_EAGAIN && ret < 0)) {
|
||||
- SEC_TST_PRT("poll ret: %u!\n", ret);
|
||||
+ SEC_TST_PRT("poll ret: %d!\n", ret);
|
||||
+ goto recv_error;
|
||||
+ }
|
||||
+
|
||||
+ if (get_run_state() == 0)
|
||||
+ last_time--;
|
||||
+ }
|
||||
+
|
||||
+recv_error:
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void *sec_uadk_poll2(void *data)
|
||||
+{
|
||||
+ typedef int (*poll_ctx)(__u32 expt, __u32 *count);
|
||||
+ poll_ctx uadk_poll_policy = NULL;
|
||||
+ thread_data *pdata = (thread_data *)data;
|
||||
+ u32 expt = ACC_QUEUE_SIZE * g_thread_num;
|
||||
+ u32 last_time = 2; // poll need one more recv time
|
||||
+ u32 count = 0;
|
||||
+ u32 recv = 0;
|
||||
+ int ret;
|
||||
+
|
||||
+ switch(pdata->subtype) {
|
||||
+ 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;
|
||||
+ default:
|
||||
+ SEC_TST_PRT("<<<<<<async poll interface is NULL!\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ while (last_time) {
|
||||
+ ret = uadk_poll_policy(expt, &recv);
|
||||
+ count += recv;
|
||||
+ recv = 0;
|
||||
+ if (unlikely(ret != -WD_EAGAIN && ret < 0)) {
|
||||
+ SEC_TST_PRT("poll ret: %d!\n", ret);
|
||||
goto recv_error;
|
||||
}
|
||||
|
||||
@@ -866,6 +965,7 @@ recv_error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+
|
||||
static void *sec_uadk_cipher_async(void *arg)
|
||||
{
|
||||
thread_data *pdata = (thread_data *)arg;
|
||||
@@ -1404,7 +1504,10 @@ int sec_uadk_async_threads(struct acc_option *options)
|
||||
threads_args[i].subtype = threads_option.subtype;
|
||||
threads_args[i].td_id = i;
|
||||
/* poll thread */
|
||||
- ret = pthread_create(&pollid[i], NULL, sec_uadk_poll, &threads_args[i]);
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ ret = pthread_create(&pollid[i], NULL, sec_uadk_poll2, &threads_args[i]);
|
||||
+ else
|
||||
+ ret = pthread_create(&pollid[i], NULL, sec_uadk_poll, &threads_args[i]);
|
||||
if (ret) {
|
||||
SEC_TST_PRT("Create poll thread fail!\n");
|
||||
goto async_error;
|
||||
@@ -1475,7 +1578,10 @@ int sec_uadk_benchmark(struct acc_option *options)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- ret = init_ctx_config(options->algclass, options->subtype, options->syncmode);
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ ret = init_ctx_config2(options);
|
||||
+ else
|
||||
+ ret = init_ctx_config(options);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -1494,7 +1600,10 @@ int sec_uadk_benchmark(struct acc_option *options)
|
||||
return ret;
|
||||
|
||||
free_uadk_bd_pool();
|
||||
- uninit_ctx_config(options->subtype);
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ uninit_ctx_config2(options->subtype);
|
||||
+ else
|
||||
+ uninit_ctx_config(options->subtype);
|
||||
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
134
0066-uadk-comp-added-init2-test-function-for-comp.patch
Normal file
134
0066-uadk-comp-added-init2-test-function-for-comp.patch
Normal file
@ -0,0 +1,134 @@
|
||||
From c650bdadb5c4dd767268411349f7109be33fefe4 Mon Sep 17 00:00:00 2001
|
||||
From: Longfang Liu <liulongfang@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:35 +0800
|
||||
Subject: [PATCH 66/85] uadk/comp: added init2 test function for comp
|
||||
|
||||
Added support for init2 performance test function for uadk_tools
|
||||
of comp module.
|
||||
|
||||
Signed-off-by: Longfang Liu <liulongfang@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/zip_uadk_benchmark.c | 76 ++++++++++++++++++++++--
|
||||
1 file changed, 71 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
index 6bf1749..7b02df8 100644
|
||||
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
@@ -278,10 +278,40 @@ static int zip_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void uninit_ctx_config2(void)
|
||||
+{
|
||||
+ /* uninit2 */
|
||||
+ wd_comp_uninit2();
|
||||
+}
|
||||
+
|
||||
+static int init_ctx_config2(struct acc_option *options)
|
||||
+{
|
||||
+ char alg_name[64];
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ ret = get_alg_name(options->algtype, alg_name);
|
||||
+ if (ret) {
|
||||
+ ZIP_TST_PRT("failed to get valid alg name!\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ /* init */
|
||||
+ ret = wd_comp_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
|
||||
+ if (ret) {
|
||||
+ ZIP_TST_PRT("Fail to do comp init2!\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static struct sched_params param;
|
||||
-static int init_ctx_config(char *alg, int mode, int optype)
|
||||
+static int init_ctx_config(struct acc_option *options)
|
||||
{
|
||||
struct uacce_dev_list *list;
|
||||
+ char *alg = options->algclass;
|
||||
+ int optype = options->optype;
|
||||
+ int mode = options->syncmode;
|
||||
int i, max_node;
|
||||
int ret = 0;
|
||||
|
||||
@@ -511,7 +541,34 @@ static void *zip_uadk_poll(void *data)
|
||||
count += recv;
|
||||
recv = 0;
|
||||
if (unlikely(ret != -WD_EAGAIN && ret < 0)) {
|
||||
- ZIP_TST_PRT("poll ret: %u!\n", ret);
|
||||
+ ZIP_TST_PRT("poll ret: %d!\n", ret);
|
||||
+ goto recv_error;
|
||||
+ }
|
||||
+
|
||||
+ if (get_run_state() == 0)
|
||||
+ last_time--;
|
||||
+ }
|
||||
+
|
||||
+recv_error:
|
||||
+ add_recv_data(count, g_pktlen);
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void *zip_uadk_poll2(void *data)
|
||||
+{
|
||||
+ u32 expt = ACC_QUEUE_SIZE * g_thread_num;
|
||||
+ u32 last_time = 2; // poll need one more recv time
|
||||
+ u32 count = 0;
|
||||
+ u32 recv = 0;
|
||||
+ int ret;
|
||||
+
|
||||
+ while (last_time) {
|
||||
+ ret = wd_comp_poll(expt, &recv);
|
||||
+ count += recv;
|
||||
+ recv = 0;
|
||||
+ if (unlikely(ret != -WD_EAGAIN && ret < 0)) {
|
||||
+ ZIP_TST_PRT("poll ret: %d!\n", ret);
|
||||
goto recv_error;
|
||||
}
|
||||
|
||||
@@ -1103,7 +1160,10 @@ static int zip_uadk_async_threads(struct acc_option *options)
|
||||
for (i = 0; i < g_ctxnum; i++) {
|
||||
threads_args[i].td_id = i;
|
||||
/* poll thread */
|
||||
- ret = pthread_create(&pollid[i], NULL, zip_uadk_poll, &threads_args[i]);
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ ret = pthread_create(&pollid[i], NULL, zip_uadk_poll2, &threads_args[i]);
|
||||
+ else
|
||||
+ ret = pthread_create(&pollid[i], NULL, zip_uadk_poll, &threads_args[i]);
|
||||
if (ret) {
|
||||
ZIP_TST_PRT("Create poll thread fail!\n");
|
||||
goto async_error;
|
||||
@@ -1160,7 +1220,10 @@ int zip_uadk_benchmark(struct acc_option *options)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- ret = init_ctx_config(options->algclass, options->syncmode, options->optype);
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ ret = init_ctx_config2(options);
|
||||
+ else
|
||||
+ ret = init_ctx_config(options);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -1187,7 +1250,10 @@ int zip_uadk_benchmark(struct acc_option *options)
|
||||
return ret;
|
||||
|
||||
free_uadk_bd_pool();
|
||||
- uninit_ctx_config();
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ uninit_ctx_config2();
|
||||
+ else
|
||||
+ uninit_ctx_config();
|
||||
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
230
0067-uadk_tool-added-init2-test-function-for-hpre.patch
Normal file
230
0067-uadk_tool-added-init2-test-function-for-hpre.patch
Normal file
@ -0,0 +1,230 @@
|
||||
From 782a3a9954b9a7ae4243fc3cc6c25c296c36b34b Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:36 +0800
|
||||
Subject: [PATCH 67/85] uadk_tool: added init2 test function for hpre
|
||||
|
||||
Added support for init2 performance test function for uadk_tools
|
||||
of hpre module.
|
||||
And fix some code style issues.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/hpre_uadk_benchmark.c | 137 ++++++++++++++++++++--
|
||||
1 file changed, 125 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
index ffa1a85..028e102 100644
|
||||
--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
||||
@@ -344,8 +344,11 @@ static int hpre_uadk_param_parse(thread_data *tddata, struct acc_option *options
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int init_hpre_ctx_config(char *alg, int subtype, int mode)
|
||||
+static int init_hpre_ctx_config(struct acc_option *options)
|
||||
{
|
||||
+ int subtype = options->subtype;
|
||||
+ char *alg = options->algclass;
|
||||
+ int mode = options->syncmode;
|
||||
struct sched_params param;
|
||||
struct uacce_dev *dev;
|
||||
int max_node;
|
||||
@@ -398,7 +401,7 @@ static int init_hpre_ctx_config(char *alg, int subtype, int mode)
|
||||
break;
|
||||
default:
|
||||
HPRE_TST_PRT("failed to parse alg subtype!\n");
|
||||
- g_sched = NULL;
|
||||
+ return -EINVAL;
|
||||
}
|
||||
if (!g_sched) {
|
||||
HPRE_TST_PRT("failed to alloc sched!\n");
|
||||
@@ -432,8 +435,6 @@ static int init_hpre_ctx_config(char *alg, int subtype, int mode)
|
||||
case X448_TYPE:
|
||||
ret = wd_ecc_init(&g_ctx_cfg, g_sched);
|
||||
break;
|
||||
- default:
|
||||
- ret = -EINVAL;
|
||||
}
|
||||
if (ret) {
|
||||
HPRE_TST_PRT("failed to get hpre ctx!\n");
|
||||
@@ -456,7 +457,7 @@ static void uninit_hpre_ctx_config(int subtype)
|
||||
int i;
|
||||
|
||||
/* uninit */
|
||||
- switch(subtype) {
|
||||
+ switch (subtype) {
|
||||
case RSA_TYPE:
|
||||
wd_rsa_uninit();
|
||||
break;
|
||||
@@ -481,6 +482,59 @@ static void uninit_hpre_ctx_config(int subtype)
|
||||
wd_sched_rr_release(g_sched);
|
||||
}
|
||||
|
||||
+static void uninit_hpre_ctx_config2(int subtype)
|
||||
+{
|
||||
+ /* uninit2 */
|
||||
+ switch (subtype) {
|
||||
+ case RSA_TYPE:
|
||||
+ wd_rsa_uninit2();
|
||||
+ break;
|
||||
+ case DH_TYPE:
|
||||
+ wd_dh_uninit2();
|
||||
+ break;
|
||||
+ case ECDH_TYPE:
|
||||
+ case ECDSA_TYPE:
|
||||
+ case SM2_TYPE:
|
||||
+ case X25519_TYPE:
|
||||
+ case X448_TYPE:
|
||||
+ wd_ecc_uninit2();
|
||||
+ break;
|
||||
+ default:
|
||||
+ HPRE_TST_PRT("failed to parse alg subtype on uninit2!\n");
|
||||
+ return;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int init_hpre_ctx_config2(struct acc_option *options)
|
||||
+{
|
||||
+ int subtype = options->subtype;
|
||||
+ char alg_name[MAX_ALG_NAME];
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = get_alg_name(options->algtype, alg_name);
|
||||
+ if (ret) {
|
||||
+ HPRE_TST_PRT("failed to get valid alg name!\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ /* init2 */
|
||||
+ switch (subtype) {
|
||||
+ case RSA_TYPE:
|
||||
+ return wd_rsa_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
|
||||
+ case DH_TYPE:
|
||||
+ return wd_dh_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
|
||||
+ case ECDH_TYPE:
|
||||
+ case ECDSA_TYPE:
|
||||
+ case SM2_TYPE:
|
||||
+ case X25519_TYPE:
|
||||
+ case X448_TYPE:
|
||||
+ return wd_ecc_init2(alg_name, SCHED_POLICY_RR, TASK_HW);
|
||||
+ default:
|
||||
+ HPRE_TST_PRT("failed to parse alg subtype on uninit2!\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/*-------------------------------uadk benchmark main code-------------------------------------*/
|
||||
|
||||
void *hpre_uadk_poll(void *data)
|
||||
@@ -498,7 +552,7 @@ void *hpre_uadk_poll(void *data)
|
||||
if (id > g_ctxnum)
|
||||
return NULL;
|
||||
|
||||
- switch(pdata->subtype) {
|
||||
+ switch (pdata->subtype) {
|
||||
case RSA_TYPE:
|
||||
uadk_poll_ctx = wd_rsa_poll_ctx;
|
||||
break;
|
||||
@@ -522,7 +576,56 @@ void *hpre_uadk_poll(void *data)
|
||||
count += recv;
|
||||
recv = 0;
|
||||
if (unlikely(ret != -WD_EAGAIN && ret < 0)) {
|
||||
- HPRE_TST_PRT("poll ret: %u!\n", ret);
|
||||
+ HPRE_TST_PRT("poll ret: %d!\n", ret);
|
||||
+ goto recv_error;
|
||||
+ }
|
||||
+
|
||||
+ if (get_run_state() == 0)
|
||||
+ last_time--;
|
||||
+ }
|
||||
+
|
||||
+recv_error:
|
||||
+ add_recv_data(count, pdata->keybits >> 3);
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+void *hpre_uadk_poll2(void *data)
|
||||
+{
|
||||
+ typedef int (*poll_ctx)(__u32 expt, __u32 *count);
|
||||
+ thread_data *pdata = (thread_data *)data;
|
||||
+ u32 expt = ACC_QUEUE_SIZE * g_thread_num;
|
||||
+ poll_ctx uadk_poll = NULL;
|
||||
+ u32 last_time = 2; // poll need one more recv time
|
||||
+ u32 count = 0;
|
||||
+ u32 recv = 0;
|
||||
+ int ret;
|
||||
+
|
||||
+ switch (pdata->subtype) {
|
||||
+ case RSA_TYPE:
|
||||
+ uadk_poll = wd_rsa_poll;
|
||||
+ break;
|
||||
+ case DH_TYPE:
|
||||
+ uadk_poll = wd_dh_poll;
|
||||
+ break;
|
||||
+ case ECDH_TYPE:
|
||||
+ case ECDSA_TYPE:
|
||||
+ case SM2_TYPE:
|
||||
+ case X25519_TYPE:
|
||||
+ case X448_TYPE:
|
||||
+ uadk_poll = wd_ecc_poll;
|
||||
+ break;
|
||||
+ default:
|
||||
+ HPRE_TST_PRT("<<<<<<async poll interface is NULL!\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ while (last_time) {
|
||||
+ ret = uadk_poll(expt, &recv);
|
||||
+ count += recv;
|
||||
+ recv = 0;
|
||||
+ if (unlikely(ret != -WD_EAGAIN && ret < 0)) {
|
||||
+ HPRE_TST_PRT("poll ret: %d!\n", ret);
|
||||
goto recv_error;
|
||||
}
|
||||
|
||||
@@ -2451,7 +2554,10 @@ static int hpre_uadk_async_threads(struct acc_option *options)
|
||||
threads_args[i].subtype = threads_option.subtype;
|
||||
threads_args[i].td_id = i;
|
||||
/* poll thread */
|
||||
- ret = pthread_create(&pollid[i], NULL, hpre_uadk_poll, &threads_args[i]);
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ ret = pthread_create(&pollid[i], NULL, hpre_uadk_poll2, &threads_args[i]);
|
||||
+ else
|
||||
+ ret = pthread_create(&pollid[i], NULL, hpre_uadk_poll, &threads_args[i]);
|
||||
if (ret) {
|
||||
HPRE_TST_PRT("Create poll thread fail!\n");
|
||||
goto async_error;
|
||||
@@ -2505,10 +2611,14 @@ int hpre_uadk_benchmark(struct acc_option *options)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- ret = init_hpre_ctx_config(options->algclass, options->subtype,
|
||||
- options->syncmode);
|
||||
- if (ret)
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ ret = init_hpre_ctx_config2(options);
|
||||
+ else
|
||||
+ ret = init_hpre_ctx_config(options);
|
||||
+ if (ret) {
|
||||
+ HPRE_TST_PRT("failed to init %s ctx, ret = %d!\n", options->algclass, ret);
|
||||
return ret;
|
||||
+ }
|
||||
|
||||
get_pid_cpu_time(&ptime);
|
||||
time_start(options->times);
|
||||
@@ -2520,7 +2630,10 @@ int hpre_uadk_benchmark(struct acc_option *options)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- uninit_hpre_ctx_config(options->subtype);
|
||||
+ if (options->inittype == INIT2_TYPE)
|
||||
+ uninit_hpre_ctx_config2(options->subtype);
|
||||
+ else
|
||||
+ uninit_hpre_ctx_config(options->subtype);
|
||||
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
43
0068-uadk_tool-use-marco-to-replace-numbers.patch
Normal file
43
0068-uadk_tool-use-marco-to-replace-numbers.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From 3fb56fddd367e6bcace4cc56a732002385c4be41 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:37 +0800
|
||||
Subject: [PATCH 68/85] uadk_tool: use marco to replace numbers
|
||||
|
||||
Use marco to replace incomprehensible numbers.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 2 +-
|
||||
uadk_tool/benchmark/zip_uadk_benchmark.c | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index 9f1f903..88806ca 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -600,8 +600,8 @@ static void uninit_ctx_config2(int subtype)
|
||||
|
||||
static int init_ctx_config2(struct acc_option *options)
|
||||
{
|
||||
- char alg_name[64];
|
||||
int subtype = options->subtype;
|
||||
+ char alg_name[MAX_ALG_NAME];
|
||||
int ret;
|
||||
|
||||
ret = get_alg_name(options->algtype, alg_name);
|
||||
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
index 7b02df8..435c0b4 100644
|
||||
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
||||
@@ -286,7 +286,7 @@ static void uninit_ctx_config2(void)
|
||||
|
||||
static int init_ctx_config2(struct acc_option *options)
|
||||
{
|
||||
- char alg_name[64];
|
||||
+ char alg_name[MAX_ALG_NAME];
|
||||
int ret = 0;
|
||||
|
||||
ret = get_alg_name(options->algtype, alg_name);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
211
0069-uadk_tool-support-test-case-for-aes-cbc-cts-mode.patch
Normal file
211
0069-uadk_tool-support-test-case-for-aes-cbc-cts-mode.patch
Normal file
@ -0,0 +1,211 @@
|
||||
From 3881092b8832687b78498ecc8d509edd96c9d568 Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:38 +0800
|
||||
Subject: [PATCH 69/85] uadk_tool: support test case for aes cbc cts mode
|
||||
|
||||
Add test case for AES-CBC CTS mode, CS1/2/3, for both
|
||||
uadk v1 and uadk v2 in uadk_tool benchmark tool.
|
||||
|
||||
Use param such as '--alg aes-128-cbc-cs1' to enable
|
||||
cs1 mode test.
|
||||
|
||||
Use 'uadk_tool benchmark --alglist' to find the name
|
||||
of other modes.
|
||||
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 54 ++++++++++++++++++++++++
|
||||
uadk_tool/benchmark/sec_wd_benchmark.c | 54 ++++++++++++++++++++++++
|
||||
uadk_tool/benchmark/uadk_benchmark.c | 18 ++++++++
|
||||
uadk_tool/benchmark/uadk_benchmark.h | 9 ++++
|
||||
4 files changed, 135 insertions(+)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index 88806ca..1994ad0 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -190,6 +190,60 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
mode = WD_CIPHER_CBC;
|
||||
alg = WD_CIPHER_AES;
|
||||
break;
|
||||
+ case AES_128_CBC_CS1:
|
||||
+ keysize = 16;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS1;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_128_CBC_CS2:
|
||||
+ keysize = 16;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS2;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_128_CBC_CS3:
|
||||
+ keysize = 16;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS3;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_192_CBC_CS1:
|
||||
+ keysize = 24;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS1;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_192_CBC_CS2:
|
||||
+ keysize = 24;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS2;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_192_CBC_CS3:
|
||||
+ keysize = 24;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS3;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_256_CBC_CS1:
|
||||
+ keysize = 32;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS1;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_256_CBC_CS2:
|
||||
+ keysize = 32;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS2;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_256_CBC_CS3:
|
||||
+ keysize = 32;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_CBC_CS3;
|
||||
+ alg = WD_CIPHER_AES;
|
||||
+ break;
|
||||
case AES_128_CTR:
|
||||
keysize = 16;
|
||||
ivsize = 16;
|
||||
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
index 3791792..aa36c22 100644
|
||||
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
@@ -256,6 +256,60 @@ static int sec_wd_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
mode = WCRYPTO_CIPHER_CBC;
|
||||
alg = WCRYPTO_CIPHER_AES;
|
||||
break;
|
||||
+ case AES_128_CBC_CS1:
|
||||
+ keysize = 16;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS1;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_128_CBC_CS2:
|
||||
+ keysize = 16;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS2;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_128_CBC_CS3:
|
||||
+ keysize = 16;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS3;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_192_CBC_CS1:
|
||||
+ keysize = 24;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS1;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_192_CBC_CS2:
|
||||
+ keysize = 24;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS2;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_192_CBC_CS3:
|
||||
+ keysize = 24;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS3;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_256_CBC_CS1:
|
||||
+ keysize = 32;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS1;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_256_CBC_CS2:
|
||||
+ keysize = 32;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS2;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
+ case AES_256_CBC_CS3:
|
||||
+ keysize = 32;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_CBC_CS3;
|
||||
+ alg = WCRYPTO_CIPHER_AES;
|
||||
+ break;
|
||||
case AES_128_CTR:
|
||||
keysize = 16;
|
||||
ivsize = 16;
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
index 26b381e..ff95bea 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
@@ -92,6 +92,15 @@ static struct acc_alg_item alg_options[] = {
|
||||
{"aes-128-cbc", AES_128_CBC},
|
||||
{"aes-192-cbc", AES_192_CBC},
|
||||
{"aes-256-cbc", AES_256_CBC},
|
||||
+ {"aes-128-cbc-cs1", AES_128_CBC_CS1},
|
||||
+ {"aes-128-cbc-cs2", AES_128_CBC_CS2},
|
||||
+ {"aes-128-cbc-cs3", AES_128_CBC_CS3},
|
||||
+ {"aes-192-cbc-cs1", AES_192_CBC_CS1},
|
||||
+ {"aes-192-cbc-cs2", AES_192_CBC_CS2},
|
||||
+ {"aes-192-cbc-cs3", AES_192_CBC_CS3},
|
||||
+ {"aes-256-cbc-cs1", AES_256_CBC_CS1},
|
||||
+ {"aes-256-cbc-cs2", AES_256_CBC_CS2},
|
||||
+ {"aes-256-cbc-cs3", AES_256_CBC_CS3},
|
||||
{"aes-128-ctr", AES_128_CTR},
|
||||
{"aes-192-ctr", AES_192_CTR},
|
||||
{"aes-256-ctr", AES_256_CTR},
|
||||
@@ -171,6 +180,15 @@ static struct acc_alg_item alg_name_options[] = {
|
||||
{"cbc(aes)", AES_128_CBC},
|
||||
{"cbc(aes)", AES_192_CBC},
|
||||
{"cbc(aes)", AES_256_CBC},
|
||||
+ {"cbc-cs1(aes)", AES_128_CBC_CS1},
|
||||
+ {"cbc-cs2(aes)", AES_128_CBC_CS2},
|
||||
+ {"cbc-cs3(aes)", AES_128_CBC_CS3},
|
||||
+ {"cbc-cs1(aes)", AES_192_CBC_CS1},
|
||||
+ {"cbc-cs2(aes)", AES_192_CBC_CS2},
|
||||
+ {"cbc-cs3(aes)", AES_192_CBC_CS3},
|
||||
+ {"cbc-cs1(aes)", AES_256_CBC_CS1},
|
||||
+ {"cbc-cs2(aes)", AES_256_CBC_CS2},
|
||||
+ {"cbc-cs3(aes)", AES_256_CBC_CS3},
|
||||
{"ctr(aes)", AES_128_CTR},
|
||||
{"ctr(aes)", AES_192_CTR},
|
||||
{"ctr(aes)", AES_256_CTR},
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
index 3a33fd8..c2ba9bc 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.h
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
@@ -143,6 +143,15 @@ enum test_alg {
|
||||
AES_128_CBC,
|
||||
AES_192_CBC,
|
||||
AES_256_CBC,
|
||||
+ AES_128_CBC_CS1,
|
||||
+ AES_128_CBC_CS2,
|
||||
+ AES_128_CBC_CS3,
|
||||
+ AES_192_CBC_CS1,
|
||||
+ AES_192_CBC_CS2,
|
||||
+ AES_192_CBC_CS3,
|
||||
+ AES_256_CBC_CS1,
|
||||
+ AES_256_CBC_CS2,
|
||||
+ AES_256_CBC_CS3,
|
||||
AES_128_CTR,
|
||||
AES_192_CTR,
|
||||
AES_256_CTR,
|
||||
--
|
||||
2.25.1
|
||||
|
||||
39
0070-uadk-tool-initialize-cparams-to-zero.patch
Normal file
39
0070-uadk-tool-initialize-cparams-to-zero.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From 7ee9dd2c72a1402b967c9be23d5773dbc3054071 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:39 +0800
|
||||
Subject: [PATCH 70/85] uadk/tool: initialize cparams to zero
|
||||
|
||||
Initialize cparams to zero.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/test/test_sec.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/test/test_sec.c b/uadk_tool/test/test_sec.c
|
||||
index c8bfdf4..b00a933 100644
|
||||
--- a/uadk_tool/test/test_sec.c
|
||||
+++ b/uadk_tool/test/test_sec.c
|
||||
@@ -1463,8 +1463,8 @@ out:
|
||||
|
||||
static int digest_init2(int type, int mode)
|
||||
{
|
||||
+ struct wd_ctx_params cparams = {0};
|
||||
struct wd_ctx_nums *ctx_set_num;
|
||||
- struct wd_ctx_params cparams;
|
||||
int ret;
|
||||
|
||||
if (g_testalg >= MAX_ALGO_PER_TYPE)
|
||||
@@ -2711,8 +2711,8 @@ out:
|
||||
|
||||
static int aead_init2(int type, int mode)
|
||||
{
|
||||
+ struct wd_ctx_params cparams = {0};
|
||||
struct wd_ctx_nums *ctx_set_num;
|
||||
- struct wd_ctx_params cparams;
|
||||
int ret;
|
||||
|
||||
if (g_testalg >= MAX_ALGO_PER_TYPE)
|
||||
--
|
||||
2.25.1
|
||||
|
||||
28
0071-uadk_tool-fix-the-memory-leak-problem.patch
Normal file
28
0071-uadk_tool-fix-the-memory-leak-problem.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From 70d792b664ce9e5374f803335056643826985f47 Mon Sep 17 00:00:00 2001
|
||||
From: Qi Tao <taoqi10@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:40 +0800
|
||||
Subject: [PATCH 71/85] uadk_tool: fix the memory leak problem
|
||||
|
||||
After calling the wd_release_queue (*q),
|
||||
call free(*q) to release the memory pointed to by q.
|
||||
|
||||
Signed-off-by: Qi Tao <taoqi10@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_wd_benchmark.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
index aa36c22..f34051e 100644
|
||||
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
@@ -733,6 +733,7 @@ static void uninit_wd_queue(void)
|
||||
for (j = 0; j < g_thread_num; j++) {
|
||||
wd_blkpool_destroy(g_thread_queue.bd_res[j].pool);
|
||||
wd_release_queue(g_thread_queue.bd_res[j].queue);
|
||||
+ free(g_thread_queue.bd_res[j].queue);
|
||||
}
|
||||
|
||||
free(g_thread_queue.bd_res);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
104
0072-uadk_tool-fix-error-writing-data-to-uninitialized-me.patch
Normal file
104
0072-uadk_tool-fix-error-writing-data-to-uninitialized-me.patch
Normal file
@ -0,0 +1,104 @@
|
||||
From baa660f648148440bc95a4c563d0f83e31afd380 Mon Sep 17 00:00:00 2001
|
||||
From: Qi Tao <taoqi10@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:41 +0800
|
||||
Subject: [PATCH 72/85] uadk_tool: fix error writing data to uninitialized
|
||||
memory
|
||||
|
||||
After the memory is applied for, the memory
|
||||
must be initialized before being written.
|
||||
|
||||
Signed-off-by: Qi Tao <taoqi10@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 14 ++++++++++----
|
||||
uadk_tool/benchmark/sec_wd_benchmark.c | 1 +
|
||||
2 files changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index 1994ad0..7ccdb7e 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -756,6 +756,7 @@ static int init_ivkey_source(void)
|
||||
int i, j, m, idx;
|
||||
|
||||
g_uadk_pool.iv = malloc(sizeof(char *) * g_thread_num);
|
||||
+ memset(g_uadk_pool.iv, 0, sizeof(char *) * g_thread_num);
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
g_uadk_pool.iv[i] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
if (!g_uadk_pool.iv[i])
|
||||
@@ -763,6 +764,7 @@ static int init_ivkey_source(void)
|
||||
}
|
||||
|
||||
g_uadk_pool.key = malloc(sizeof(char *) * g_thread_num);
|
||||
+ memset(g_uadk_pool.key, 0, sizeof(char *) * g_thread_num);
|
||||
for (j = 0; j < g_thread_num; j++) {
|
||||
g_uadk_pool.key[j] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
if (!g_uadk_pool.key[j])
|
||||
@@ -772,6 +774,7 @@ static int init_ivkey_source(void)
|
||||
}
|
||||
|
||||
g_uadk_pool.hash = malloc(sizeof(char *) * g_thread_num);
|
||||
+ memset(g_uadk_pool.hash, 0, sizeof(char *) * g_thread_num);
|
||||
for (m = 0; m < g_thread_num; m++) {
|
||||
g_uadk_pool.hash[m] = calloc(MAX_IVK_LENTH, sizeof(char));
|
||||
if (!g_uadk_pool.hash[m])
|
||||
@@ -832,22 +835,25 @@ static int init_uadk_bd_pool(void)
|
||||
}
|
||||
|
||||
g_uadk_pool.pool = malloc(g_thread_num * sizeof(struct bd_pool));
|
||||
+ memset(g_uadk_pool.pool, 0, g_thread_num * sizeof(struct bd_pool));
|
||||
if (!g_uadk_pool.pool) {
|
||||
SEC_TST_PRT("init uadk pool alloc thread failed!\n");
|
||||
goto free_ivkey;
|
||||
} else {
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
- g_uadk_pool.pool[i].bds = malloc(MAX_POOL_LENTH *
|
||||
- sizeof(struct uadk_bd));
|
||||
+ g_uadk_pool.pool[i].bds = malloc(MAX_POOL_LENTH *sizeof(struct uadk_bd));
|
||||
+ memset(g_uadk_pool.pool[i].bds, 0, MAX_POOL_LENTH *sizeof(struct uadk_bd));
|
||||
if (!g_uadk_pool.pool[i].bds) {
|
||||
SEC_TST_PRT("init uadk bds alloc failed!\n");
|
||||
goto malloc_error1;
|
||||
}
|
||||
for (j = 0; j < MAX_POOL_LENTH; j++) {
|
||||
g_uadk_pool.pool[i].bds[j].src = malloc(step);
|
||||
+ memset(g_uadk_pool.pool[i].bds[j].src, 0, step);
|
||||
if (!g_uadk_pool.pool[i].bds[j].src)
|
||||
goto malloc_error2;
|
||||
g_uadk_pool.pool[i].bds[j].dst = malloc(step);
|
||||
+ memset(g_uadk_pool.pool[i].bds[j].dst, 0, step);
|
||||
if (!g_uadk_pool.pool[i].bds[j].dst)
|
||||
goto malloc_error3;
|
||||
|
||||
@@ -1097,7 +1103,7 @@ static void *sec_uadk_aead_async(void *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;
|
||||
+ struct wd_aead_req areq = {0};
|
||||
struct bd_pool *uadk_pool;
|
||||
int try_cnt = 0;
|
||||
handle_t h_sess;
|
||||
@@ -1328,7 +1334,7 @@ static void *sec_uadk_aead_sync(void *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;
|
||||
+ struct wd_aead_req areq = {0};
|
||||
struct bd_pool *uadk_pool;
|
||||
handle_t h_sess;
|
||||
u32 count = 0;
|
||||
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
index f34051e..e620c3c 100644
|
||||
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
@@ -587,6 +587,7 @@ static int init_wd_queue(struct acc_option *options)
|
||||
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
g_thread_queue.bd_res[i].queue = malloc(sizeof(struct wd_queue));
|
||||
+ memset(g_thread_queue.bd_res[i].queue, 0, sizeof(struct wd_queue));
|
||||
g_thread_queue.bd_res[i].queue->capa.alg = options->algclass;
|
||||
// 0 is ENC, 1 is DEC
|
||||
g_thread_queue.bd_res[i].queue->capa.priv.direction = options->optype;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
93
0073-uadk_tool-added-sm4-xts-GB-test.patch
Normal file
93
0073-uadk_tool-added-sm4-xts-GB-test.patch
Normal file
@ -0,0 +1,93 @@
|
||||
From 12c7632bc6dbf9043c8c1e24177bd3b36aed8b57 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:42 +0800
|
||||
Subject: [PATCH 73/85] uadk_tool: added sm4-xts GB test
|
||||
|
||||
Add testcase cmd sm4-128-xts-gb for sm4-xts GB.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 6 ++++++
|
||||
uadk_tool/benchmark/sec_wd_benchmark.c | 6 ++++++
|
||||
uadk_tool/benchmark/uadk_benchmark.c | 4 +++-
|
||||
uadk_tool/benchmark/uadk_benchmark.h | 1 +
|
||||
4 files changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index 7ccdb7e..d6effe5 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -370,6 +370,12 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
mode = WD_CIPHER_XTS;
|
||||
alg = WD_CIPHER_SM4;
|
||||
break;
|
||||
+ case SM4_128_XTS_GB:
|
||||
+ keysize = 32;
|
||||
+ ivsize = 16;
|
||||
+ mode = WD_CIPHER_XTS_GB;
|
||||
+ alg = WD_CIPHER_SM4;
|
||||
+ break;
|
||||
case AES_128_CCM:
|
||||
keysize = 16;
|
||||
ivsize = 16;
|
||||
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
index e620c3c..6e5c8a0 100644
|
||||
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
||||
@@ -436,6 +436,12 @@ static int sec_wd_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
mode = WCRYPTO_CIPHER_XTS;
|
||||
alg = WCRYPTO_CIPHER_SM4;
|
||||
break;
|
||||
+ case SM4_128_XTS_GB:
|
||||
+ keysize = 32;
|
||||
+ ivsize = 16;
|
||||
+ mode = WCRYPTO_CIPHER_XTS_GB;
|
||||
+ alg = WCRYPTO_CIPHER_SM4;
|
||||
+ break;
|
||||
case AES_128_CCM:
|
||||
keysize = 16;
|
||||
ivsize = 16;
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
index ff95bea..6d5d009 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
||||
@@ -122,6 +122,7 @@ static struct acc_alg_item alg_options[] = {
|
||||
{"sm4-128-ofb", SM4_128_OFB},
|
||||
{"sm4-128-cfb", SM4_128_CFB},
|
||||
{"sm4-128-xts", SM4_128_XTS},
|
||||
+ {"sm4-128-xts-gb", SM4_128_XTS_GB},
|
||||
{"aes-128-ccm", AES_128_CCM},
|
||||
{"aes-192-ccm", AES_192_CCM},
|
||||
{"aes-256-ccm", AES_256_CCM},
|
||||
@@ -210,6 +211,7 @@ static struct acc_alg_item alg_name_options[] = {
|
||||
{"ofb(sm4)", SM4_128_OFB},
|
||||
{"cfb(sm4)", SM4_128_CFB},
|
||||
{"xts(sm4)", SM4_128_XTS},
|
||||
+ {"xts(sm4)", SM4_128_XTS_GB},
|
||||
{"ccm(aes)", AES_128_CCM},
|
||||
{"ccm(aes)", AES_192_CCM},
|
||||
{"ccm(aes)", AES_256_CCM},
|
||||
@@ -482,7 +484,7 @@ static void parse_alg_param(struct acc_option *option)
|
||||
snprintf(option->algclass, MAX_ALG_NAME, "%s", "ecdsa");
|
||||
option->acctype = HPRE_TYPE;
|
||||
option->subtype = ECDSA_TYPE;
|
||||
- } else if (option->algtype <= SM4_128_XTS) {
|
||||
+ } else if (option->algtype <= SM4_128_XTS_GB) {
|
||||
snprintf(option->algclass, MAX_ALG_NAME, "%s", "cipher");
|
||||
option->acctype = SEC_TYPE;
|
||||
option->subtype = CIPHER_TYPE;
|
||||
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
index c2ba9bc..1cce63d 100644
|
||||
--- a/uadk_tool/benchmark/uadk_benchmark.h
|
||||
+++ b/uadk_tool/benchmark/uadk_benchmark.h
|
||||
@@ -173,6 +173,7 @@ enum test_alg {
|
||||
SM4_128_OFB,
|
||||
SM4_128_CFB,
|
||||
SM4_128_XTS,
|
||||
+ SM4_128_XTS_GB,
|
||||
AES_128_CCM, // aead
|
||||
AES_192_CCM,
|
||||
AES_256_CCM,
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
From 1628e0964d25ff490bb98d5de31338603420ce56 Mon Sep 17 00:00:00 2001
|
||||
From: Qi Tao <taoqi10@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:43 +0800
|
||||
Subject: [PATCH 74/85] uadk_tool: initialize the return value 'ret' of the
|
||||
function
|
||||
|
||||
'ret' was used uninitialized in function init_ctx_config().
|
||||
|
||||
Signed-off-by: Qi Tao <taoqi10@huawei.com>
|
||||
---
|
||||
uadk_tool/benchmark/sec_uadk_benchmark.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
index d6effe5..f1ae18b 100644
|
||||
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
||||
@@ -516,12 +516,14 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
|
||||
static int init_ctx_config(struct acc_option *options)
|
||||
{
|
||||
- struct sched_params param;
|
||||
+ struct sched_params param = {0};
|
||||
struct uacce_dev *dev = NULL;
|
||||
char *alg = options->algclass;
|
||||
int subtype = options->subtype;
|
||||
int mode = options->syncmode;
|
||||
- int ret, max_node, i;
|
||||
+ int max_node = 0;
|
||||
+ int ret = 0;
|
||||
+ int i = 0;
|
||||
|
||||
max_node = numa_max_node() + 1;
|
||||
if (max_node <= 0)
|
||||
@@ -533,7 +535,6 @@ static int init_ctx_config(struct acc_option *options)
|
||||
if (!g_ctx_cfg.ctxs)
|
||||
return -ENOMEM;
|
||||
|
||||
- i = 0;
|
||||
while (i < g_ctxnum) {
|
||||
dev = wd_get_accel_dev(alg);
|
||||
if (!dev) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
43
0075-add-secure-compilation-option.patch
Normal file
43
0075-add-secure-compilation-option.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From 6ad3084be58e00c97d56e1dcf2507bd6519599fd Mon Sep 17 00:00:00 2001
|
||||
From: Qi Tao <taoqi10@huawei.com>
|
||||
Date: Fri, 10 Nov 2023 11:52:44 +0800
|
||||
Subject: [PATCH 75/85] add secure compilation option
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Add PIE、PIC、BIND_NOW、SP、NO Rpath/RunPath、FS、Ftrapv and Strip
|
||||
to UADK compilation.
|
||||
|
||||
Signed-off-by: Qi Tao <taoqi10@huawei.com>
|
||||
---
|
||||
uadk_tool/Makefile.am | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/Makefile.am b/uadk_tool/Makefile.am
|
||||
index 6b787f9..7f00087 100644
|
||||
--- a/uadk_tool/Makefile.am
|
||||
+++ b/uadk_tool/Makefile.am
|
||||
@@ -1,7 +1,9 @@
|
||||
ACLOCAL_AMFLAGS = -I m4 -I./include
|
||||
AUTOMAKE_OPTIONS = foreign subdir-objects
|
||||
-AM_CFLAGS=-Wall -fno-strict-aliasing -I$(top_srcdir) -I$(top_srcdir)/benchmark/include \
|
||||
+AM_CFLAGS=-Wall -Werror -fno-strict-aliasing -I$(top_srcdir) -I$(top_srcdir)/benchmark/include \
|
||||
-pthread
|
||||
+AM_CFLAGS += -fPIC -fPIE -pie -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
|
||||
+-O2 -ftrapv -Wl,-z,now -Wl,-s
|
||||
|
||||
#AUTOMAKE_OPTIONS = subdir-objects
|
||||
|
||||
@@ -33,8 +35,6 @@ uadk_tool_LDADD=-L../.libs -l:libwd.so.2 -l:libwd_crypto.so.2 \
|
||||
-l:libwd_comp.so.2 -lnuma
|
||||
endif
|
||||
|
||||
-uadk_tool_LDFLAGS=-Wl,-rpath,'/usr/local/lib',--enable-new-dtags
|
||||
-
|
||||
if WITH_ZLIB_FSE_DIR
|
||||
AM_CFLAGS += -DZLIB_FSE
|
||||
uadk_tool_LDADD+= $(with_zlib_fse_dir)/libfse.a
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
From 35d1a4ff23a7ed21d48e98e2264af61281323532 Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:21:52 +0800
|
||||
Subject: [PATCH 76/85] uadk/v1/drv: hisi_zip_udrv - fix unmap buffer for
|
||||
lz77_zstd stream mode
|
||||
|
||||
In uadk v1, the library will alloc a ctx_buffer used for storing
|
||||
stream information. On hisilicon platform, the hardware will output
|
||||
some data to this buffer. So the ctx_buffer should be map to PA/IOVA.
|
||||
But here the lz77_zstd forgot to unmap this buffer on error branch.
|
||||
|
||||
What's more, if the user use the wd_bmm ops, the unmap is a void
|
||||
function.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
v1/drv/hisi_zip_udrv.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/v1/drv/hisi_zip_udrv.c b/v1/drv/hisi_zip_udrv.c
|
||||
index f820b7f..470acb9 100644
|
||||
--- a/v1/drv/hisi_zip_udrv.c
|
||||
+++ b/v1/drv/hisi_zip_udrv.c
|
||||
@@ -512,6 +512,9 @@ static int fill_zip_addr_lz77_zstd(void *ssqe,
|
||||
unmap_phy_seq:
|
||||
drv_iova_unmap(q, zstd_out->literal, (void *)phy_lit, zstd_out->lit_sz);
|
||||
unmap_phy_lit:
|
||||
+ if (msg->stream_mode == WCRYPTO_COMP_STATEFUL)
|
||||
+ drv_iova_unmap(q, msg->ctx_buf, (void *)addr.ctxbuf_addr - CTX_BUFFER_OFFSET,
|
||||
+ MAX_CTX_RSV_SIZE);
|
||||
drv_iova_unmap(q, msg->src, (void *)addr.source_addr, msg->in_size);
|
||||
return -WD_ENOMEM;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
From 51d9d531c5944e66d62f28f738f2f1b5aaf8373b Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:21:53 +0800
|
||||
Subject: [PATCH 77/85] uadk/v1/drv: hisi_zip_udrv - fix the wrong unmapped
|
||||
address
|
||||
|
||||
Some region is reserved for driver data in ctx_buf. So there is
|
||||
a offset between the hardware ctx_buf and the original ctx_buf.
|
||||
The unmapped address should be the original ctx_buf rather than
|
||||
hardware ctx_buf.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
v1/drv/hisi_zip_udrv.c | 9 +++++----
|
||||
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/v1/drv/hisi_zip_udrv.c b/v1/drv/hisi_zip_udrv.c
|
||||
index 470acb9..dfd1fb3 100644
|
||||
--- a/v1/drv/hisi_zip_udrv.c
|
||||
+++ b/v1/drv/hisi_zip_udrv.c
|
||||
@@ -126,6 +126,7 @@ static int qm_fill_zip_sqe_get_phy_addr(struct hisi_zip_sqe_addr *addr,
|
||||
WD_ERR("Get zip in buf dma address fail!\n");
|
||||
return -WD_ENOMEM;
|
||||
}
|
||||
+
|
||||
if (!(is_lz77 && msg->data_fmt == WD_SGL_BUF)) {
|
||||
phy_out = (uintptr_t)drv_iova_map(q, msg->dst, msg->avail_out);
|
||||
if (!phy_out) {
|
||||
@@ -296,8 +297,8 @@ int qm_parse_zip_sqe(void *hw_msg, const struct qm_queue_info *info,
|
||||
phy_out = DMA_ADDR(sqe->dest_addr_h, sqe->dest_addr_l);
|
||||
drv_iova_unmap(q, recv_msg->dst, (void *)phy_out, recv_msg->avail_out);
|
||||
if (recv_msg->ctx_buf) {
|
||||
- phy_ctxbuf = DMA_ADDR(sqe->stream_ctx_addr_h,
|
||||
- sqe->stream_ctx_addr_l);
|
||||
+ phy_ctxbuf = DMA_ADDR(sqe->stream_ctx_addr_h, sqe->stream_ctx_addr_l) -
|
||||
+ CTX_BUFFER_OFFSET;
|
||||
drv_iova_unmap(q, recv_msg->ctx_buf, (void *)phy_ctxbuf,
|
||||
MAX_CTX_RSV_SIZE);
|
||||
}
|
||||
@@ -727,8 +728,8 @@ int qm_parse_zip_sqe_v3(void *hw_msg, const struct qm_queue_info *info,
|
||||
phy_out = DMA_ADDR(sqe->dest_addr_h, sqe->dest_addr_l);
|
||||
drv_iova_unmap(q, recv_msg->dst, (void *)phy_out, recv_msg->avail_out);
|
||||
if (recv_msg->ctx_buf) {
|
||||
- phy_ctxbuf = DMA_ADDR(sqe->stream_ctx_addr_h,
|
||||
- sqe->stream_ctx_addr_l);
|
||||
+ phy_ctxbuf = DMA_ADDR(sqe->stream_ctx_addr_h, sqe->stream_ctx_addr_l) -
|
||||
+ CTX_BUFFER_OFFSET;
|
||||
drv_iova_unmap(q, recv_msg->ctx_buf, (void *)phy_ctxbuf,
|
||||
MAX_CTX_RSV_SIZE);
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From 22869c48d92b607d6c4f13a282af3800244f975c Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:21:54 +0800
|
||||
Subject: [PATCH 78/85] uadk/v1: wd_comp - fix unlocked queue resource change
|
||||
|
||||
Move the resource release into lock.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
v1/wd_comp.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/v1/wd_comp.c b/v1/wd_comp.c
|
||||
index f898c1d..fb9e413 100644
|
||||
--- a/v1/wd_comp.c
|
||||
+++ b/v1/wd_comp.c
|
||||
@@ -192,8 +192,8 @@ free_ctx_buf:
|
||||
free(ctx);
|
||||
free_ctx_id:
|
||||
wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, ctx_id, WD_MAX_CTX_NUM);
|
||||
- wd_spinlock(&qinfo->qlock);
|
||||
qinfo->ctx_num--;
|
||||
+ wd_spinlock(&qinfo->qlock);
|
||||
unlock:
|
||||
wd_unspinlock(&qinfo->qlock);
|
||||
return NULL;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
From f84772417e6f7ec71539bf3ef8512055d9a659be Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:21:55 +0800
|
||||
Subject: [PATCH 79/85] uadk/wd_alg - add registering driver parameters check
|
||||
|
||||
Add checks for some necessary parameters of dynamically registered
|
||||
drivers.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
wd_alg.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/wd_alg.c b/wd_alg.c
|
||||
index 8d88316..3b111c8 100644
|
||||
--- a/wd_alg.c
|
||||
+++ b/wd_alg.c
|
||||
@@ -139,6 +139,11 @@ int wd_alg_driver_register(struct wd_alg_driver *drv)
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
|
||||
+ if (!drv->init || !drv->exit || !drv->send || !drv->recv) {
|
||||
+ WD_ERR("invalid: driver's parameter is NULL!\n");
|
||||
+ return -WD_EINVAL;
|
||||
+ }
|
||||
+
|
||||
new_alg = calloc(1, sizeof(struct wd_alg_list));
|
||||
if (!new_alg) {
|
||||
WD_ERR("failed to alloc alg driver memory!\n");
|
||||
--
|
||||
2.25.1
|
||||
|
||||
75
0080-uadk-wd_comp-fix-some-comments.patch
Normal file
75
0080-uadk-wd_comp-fix-some-comments.patch
Normal file
@ -0,0 +1,75 @@
|
||||
From 1dee88d833b6b6186cc63680efe452fd6621de9c Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:21:56 +0800
|
||||
Subject: [PATCH 80/85] uadk: wd_comp - fix some comments
|
||||
|
||||
Update some comments.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
include/wd_comp.h | 20 ++++++++++----------
|
||||
wd_comp.c | 3 +--
|
||||
2 files changed, 11 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/include/wd_comp.h b/include/wd_comp.h
|
||||
index 45b0d0b..45994ff 100644
|
||||
--- a/include/wd_comp.h
|
||||
+++ b/include/wd_comp.h
|
||||
@@ -39,12 +39,12 @@ enum wd_comp_level {
|
||||
WD_COMP_L7, /* Compression level 7 */
|
||||
WD_COMP_L8, /* Compression level 8 */
|
||||
WD_COMP_L9, /* Compression level 9 */
|
||||
- WD_COMP_L10, /* Compression level 10 */
|
||||
- WD_COMP_L11, /* Compression level 11 */
|
||||
- WD_COMP_L12, /* Compression level 12 */
|
||||
- WD_COMP_L13, /* Compression level 13 */
|
||||
- WD_COMP_L14, /* Compression level 14 */
|
||||
- WD_COMP_L15, /* Compression level 15 */
|
||||
+ WD_COMP_L10, /* Compression level 10 */
|
||||
+ WD_COMP_L11, /* Compression level 11 */
|
||||
+ WD_COMP_L12, /* Compression level 12 */
|
||||
+ WD_COMP_L13, /* Compression level 13 */
|
||||
+ WD_COMP_L14, /* Compression level 14 */
|
||||
+ WD_COMP_L15, /* Compression level 15 */
|
||||
};
|
||||
|
||||
enum wd_comp_winsz_type {
|
||||
@@ -72,10 +72,10 @@ struct wd_comp_req {
|
||||
__u32 dst_len;
|
||||
wd_alg_comp_cb_t *cb;
|
||||
void *cb_param;
|
||||
- enum wd_comp_op_type op_type; /* Denoted by wd_comp_op_type */
|
||||
- enum wd_buff_type data_fmt; /* Denoted by wd_buff_type */
|
||||
- __u32 last;
|
||||
- __u32 status;
|
||||
+ enum wd_comp_op_type op_type; /* denoted by wd_comp_op_type */
|
||||
+ enum wd_buff_type data_fmt; /* denoted by wd_buff_type */
|
||||
+ __u32 last; /* flag of last block for stream mode */
|
||||
+ __u32 status; /* request error code */
|
||||
void *priv;
|
||||
};
|
||||
|
||||
diff --git a/wd_comp.c b/wd_comp.c
|
||||
index 21c9928..6e71d35 100644
|
||||
--- a/wd_comp.c
|
||||
+++ b/wd_comp.c
|
||||
@@ -494,7 +494,6 @@ static void fill_comp_msg(struct wd_comp_sess *sess, struct wd_comp_msg *msg,
|
||||
msg->win_sz = sess->win_sz;
|
||||
msg->avail_out = req->dst_len;
|
||||
|
||||
- /* if is last 1: flush end; other: sync flush */
|
||||
msg->req.last = 1;
|
||||
}
|
||||
|
||||
@@ -722,7 +721,7 @@ static int append_store_block(struct wd_comp_sess *sess,
|
||||
memcpy(req->dst, store_block, blocksize);
|
||||
req->dst_len = blocksize;
|
||||
checksum = (__u32) cpu_to_be32(checksum);
|
||||
- /* if zlib, ADLER32 */
|
||||
+ /* if zlib, ADLER32 */
|
||||
memcpy(req->dst + blocksize, &checksum, sizeof(checksum));
|
||||
req->dst_len += sizeof(checksum);
|
||||
} else if (sess->alg_type == WD_GZIP) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
52
0081-uadk-fix-the-process-when-ctx-request-fails.patch
Normal file
52
0081-uadk-fix-the-process-when-ctx-request-fails.patch
Normal file
@ -0,0 +1,52 @@
|
||||
From c1c93a8bf7694a5e73933e6434bcd2c6924f8a00 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:21:57 +0800
|
||||
Subject: [PATCH 81/85] uadk: fix the process when ctx request fails
|
||||
|
||||
When request ctx busy, the ctx needs to be applied again instead of
|
||||
performing subsequent operations. In addition, add ctx checks,
|
||||
if ctx is 0, return -WD_ENOMEM.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
wd_util.c | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index a9640c3..8af0261 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -2418,6 +2418,7 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l
|
||||
struct wd_ctx_nums ctx_nums = attrs->ctx_params->ctx_set_num[op_type];
|
||||
__u32 ctx_set_num = ctx_nums.sync_ctx_num + ctx_nums.async_ctx_num;
|
||||
struct wd_ctx_config *ctx_config = attrs->ctx_config;
|
||||
+ __u32 count = idx + ctx_set_num;
|
||||
struct uacce_dev *dev;
|
||||
__u32 i;
|
||||
|
||||
@@ -2429,13 +2430,21 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l
|
||||
if (WD_IS_ERR(dev))
|
||||
return WD_PTR_ERR(dev);
|
||||
|
||||
- for (i = idx; i < idx + ctx_set_num; i++) {
|
||||
+ for (i = idx; i < count; i++) {
|
||||
ctx_config->ctxs[i].ctx = wd_request_ctx(dev);
|
||||
if (errno == WD_EBUSY) {
|
||||
dev = wd_find_dev_by_numa(list, numa_id);
|
||||
if (WD_IS_ERR(dev))
|
||||
return WD_PTR_ERR(dev);
|
||||
+
|
||||
i--;
|
||||
+ continue;
|
||||
+ } else if (!ctx_config->ctxs[i].ctx) {
|
||||
+ /*
|
||||
+ * wd_release_ctx_set will release ctx in
|
||||
+ * caller wd_init_ctx_and_sched.
|
||||
+ */
|
||||
+ return -WD_ENOMEM;
|
||||
}
|
||||
ctx_config->ctxs[i].op_type = op_type;
|
||||
ctx_config->ctxs[i].ctx_mode =
|
||||
--
|
||||
2.25.1
|
||||
|
||||
47
0082-uadk-wd_util-fix-a-theoretically-infinite-loop.patch
Normal file
47
0082-uadk-wd_util-fix-a-theoretically-infinite-loop.patch
Normal file
@ -0,0 +1,47 @@
|
||||
From 29ee35cd6e2fd592730ce4374acce84f9c4b5c3f Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:21:58 +0800
|
||||
Subject: [PATCH 82/85] uadk: wd_util - fix a theoretically infinite loop
|
||||
|
||||
In wd_init_ctx_set, it will try to get the ctx from the most
|
||||
idle device. But requesting ctx from devices is an exclusive
|
||||
behavior. And there is no lock to protect against multi-process
|
||||
contention. In the worst situation, a process will always get
|
||||
'EBUSY' from wd_request_ctx.
|
||||
|
||||
So here add a retry count to avoid a infinite loop.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
wd_util.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index 8af0261..bfa3af0 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -2420,7 +2420,7 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l
|
||||
struct wd_ctx_config *ctx_config = attrs->ctx_config;
|
||||
__u32 count = idx + ctx_set_num;
|
||||
struct uacce_dev *dev;
|
||||
- __u32 i;
|
||||
+ __u32 i, cnt = 0;
|
||||
|
||||
/* If the ctx set number is 0, the initialization is skipped. */
|
||||
if (!ctx_set_num)
|
||||
@@ -2437,6 +2437,12 @@ static int wd_init_ctx_set(struct wd_init_attrs *attrs, struct uacce_dev_list *l
|
||||
if (WD_IS_ERR(dev))
|
||||
return WD_PTR_ERR(dev);
|
||||
|
||||
+ if (cnt++ > WD_INIT_RETRY_TIMES) {
|
||||
+ WD_ERR("failed to request enough ctx due to timeout!\n");
|
||||
+ return -WD_ETIMEDOUT;
|
||||
+ }
|
||||
+
|
||||
+ /* self-decrease i to eliminate self-increase on next loop */
|
||||
i--;
|
||||
continue;
|
||||
} else if (!ctx_config->ctxs[i].ctx) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
37
0083-uadk-wd-fix-fscanf-infinite-loop.patch
Normal file
37
0083-uadk-wd-fix-fscanf-infinite-loop.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From 99bc5eb28297945c496e8fb0d282e108978c22e7 Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:21:59 +0800
|
||||
Subject: [PATCH 83/85] uadk: wd - fix fscanf infinite loop
|
||||
|
||||
UADK supports registration of log to the rsyslog service.
|
||||
So it will read the rsyslog.conf to user's log level.
|
||||
Here use '%[^\n ] ' to divided the lines in file into
|
||||
words to analysis.
|
||||
|
||||
But there is a problem if the first line in the file is
|
||||
'\n'. The fscanf will return 0 and always read the first
|
||||
line, which makes a infinite loop.
|
||||
|
||||
Add a whitespace before '%[^\n ] ' to filter the unintended '\n'.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
wd.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wd.c b/wd.c
|
||||
index ddde38d..e88c993 100644
|
||||
--- a/wd.c
|
||||
+++ b/wd.c
|
||||
@@ -79,7 +79,7 @@ static void wd_parse_log_level(void)
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
- while (fscanf(in_file, "%[^\n ] ", file_contents) != EOF) {
|
||||
+ while (fscanf(in_file, " %[^\n ] ", file_contents) != EOF) {
|
||||
if (!strcmp("local5.debug", file_contents))
|
||||
log_debug = true;
|
||||
else if (!strcmp("local5.info", file_contents))
|
||||
--
|
||||
2.25.1
|
||||
|
||||
30
0084-uadk-zlibwrapper-fix-wrong-request-check.patch
Normal file
30
0084-uadk-zlibwrapper-fix-wrong-request-check.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From 28af7936c6eebb6b18492cc128b905158fec56d9 Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:22:00 +0800
|
||||
Subject: [PATCH 84/85] uadk: zlibwrapper - fix wrong request check
|
||||
|
||||
Add the check on req.status to show users invalid requests.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
wd_zlibwrapper.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c
|
||||
index 7189b7f..afa8ee7 100644
|
||||
--- a/wd_zlibwrapper.c
|
||||
+++ b/wd_zlibwrapper.c
|
||||
@@ -236,8 +236,8 @@ static int wd_zlib_do_request(z_streamp strm, int flush, enum wd_comp_op_type ty
|
||||
req.last = (flush == Z_FINISH) ? 1 : 0;
|
||||
|
||||
ret = wd_do_comp_strm(h_sess, &req);
|
||||
- if (unlikely(ret)) {
|
||||
- WD_ERR("failed to do compress(%d)!\n", ret);
|
||||
+ if (unlikely(ret || req.status == WD_IN_EPARA)) {
|
||||
+ WD_ERR("failed to do compress, ret = %d, req.status = %u!\n", ret, req.status);
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
51
0085-uadk-drv-hisi-fix-sgl-copy-offset-error.patch
Normal file
51
0085-uadk-drv-hisi-fix-sgl-copy-offset-error.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From dafb286fe6ca5ba2a4ddf2381db1750b87dd3e1b Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Mon, 20 Nov 2023 15:22:01 +0800
|
||||
Subject: [PATCH 85/85] uadk: drv/hisi - fix sgl copy offset error
|
||||
|
||||
The HiSilicon drivers support copy data between the pbuffer and sgl.
|
||||
And it supports copying data from the specified domain of sgl.
|
||||
|
||||
There is a bug when the driver calculate the sgl address. It adds the
|
||||
next sgl node length rather than the origin one. So if the sgl lengths
|
||||
are not equal, the target node will be wrong.
|
||||
|
||||
Therefore, the driver should add the origin sgl length and then fetch
|
||||
the next node.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
drv/hisi_qm_udrv.c | 7 +++----
|
||||
1 file changed, 3 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
|
||||
index d86a692..13db3f0 100644
|
||||
--- a/drv/hisi_qm_udrv.c
|
||||
+++ b/drv/hisi_qm_udrv.c
|
||||
@@ -972,20 +972,19 @@ void hisi_qm_sgl_copy(void *pbuff, void *hw_sgl, __u32 offset, __u32 size,
|
||||
__u8 direct)
|
||||
{
|
||||
struct hisi_sgl *tmp = hw_sgl;
|
||||
+ int begin_sge = 0, i;
|
||||
__u32 sge_offset = 0;
|
||||
__u32 len = 0;
|
||||
- int begin_sge = 0;
|
||||
- int i;
|
||||
|
||||
if (!pbuff || !size || !tmp)
|
||||
return;
|
||||
|
||||
while (len + tmp->entry_size_in_sgl <= offset) {
|
||||
+ len += tmp->entry_size_in_sgl;
|
||||
+
|
||||
tmp = (struct hisi_sgl *)tmp->next_dma;
|
||||
if (!tmp)
|
||||
return;
|
||||
-
|
||||
- len += tmp->entry_size_in_sgl;
|
||||
}
|
||||
|
||||
/* find the start sge position and start offset */
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Name: libwd
|
||||
Summary: User Space Accelerator Development Kit
|
||||
Version: 2.5.0
|
||||
Release: 5
|
||||
Release: 6
|
||||
License: Apache-2.0
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
Vendor: Huawei Corporation
|
||||
@ -57,6 +57,49 @@ Patch0039: 0039-uadk-cipher-support-sm4-xts-GB-standard.patch
|
||||
Patch0040: 0040-uadk-v1-cipher-support-sm4-xts-GB-standard.patch
|
||||
Patch0041: 0041-uadk-v1-digest-support-new-AES-mode-algs.patch
|
||||
Patch0042: 0042-uadk-v1-fix-long-hash-state-issue.patch
|
||||
Patch0043: 0043-uadk_tool-delete-redundant-memset-zero.patch
|
||||
Patch0044: 0044-uadk_tool-fix-possible-memory-leak-in-alg-_uadk_asyn.patch
|
||||
Patch0045: 0045-uadk_tool-fix-the-called-function-interface.patch
|
||||
Patch0046: 0046-uadk_tool-release-memory-after-all-tasks-are-complet.patch
|
||||
Patch0047: 0047-uadk_tool-Optimize-sec-s-sva-benchmark-code.patch
|
||||
Patch0048: 0048-uadk_tool-Optimize-sec-s-no-sva-benchmark-code.patch
|
||||
Patch0049: 0049-uadk_tool-Optimize-sec-s-software-benchmark-code.patch
|
||||
Patch0050: 0050-uadk_tool-add-latency-test-function-for-uadk_tools.patch
|
||||
Patch0051: 0051-uadk_tool-modify-the-clean-code-issue.patch
|
||||
Patch0052: 0052-uadk_tool-support-aead-algorithm-decrypto-perf-testi.patch
|
||||
Patch0053: 0053-uadk_tool-fix-hpre-test-code-issues.patch
|
||||
Patch0054: 0054-uadk_tool-support-dual-sec-engine-device-testing.patch
|
||||
Patch0055: 0055-uadk_tool-Support-performance-test-for-TRNG.patch
|
||||
Patch0056: 0056-uadk-tools-support-new-parameters-for-compression.patch
|
||||
Patch0057: 0057-uadk_tool-v1-support-aead-algorithm-decrypto-perf-te.patch
|
||||
Patch0058: 0058-uadk_tool-v1-fix-sec-benchmark-problem.patch
|
||||
Patch0059: 0059-uadk-tools-misc-fixes-for-uadk-compress-performance.patch
|
||||
Patch0060: 0060-uadk-tools-fix-lz77_zstd-performance-test-for-nosva-.patch
|
||||
Patch0061: 0061-uadk-tools-fix-for-uadk-compression-stream-performan.patch
|
||||
Patch0062: 0062-uadk-tools-fix-for-uadk-tool-sec-aead-async-mode.patch
|
||||
Patch0063: 0063-uadk-tools-Update-test-function-for-init2.patch
|
||||
Patch0064: 0064-uadk-support-some-uadk-dfx-stronger-feature.patch
|
||||
Patch0065: 0065-uadk-sec-added-init2-performance-test.patch
|
||||
Patch0066: 0066-uadk-comp-added-init2-test-function-for-comp.patch
|
||||
Patch0067: 0067-uadk_tool-added-init2-test-function-for-hpre.patch
|
||||
Patch0068: 0068-uadk_tool-use-marco-to-replace-numbers.patch
|
||||
Patch0069: 0069-uadk_tool-support-test-case-for-aes-cbc-cts-mode.patch
|
||||
Patch0070: 0070-uadk-tool-initialize-cparams-to-zero.patch
|
||||
Patch0071: 0071-uadk_tool-fix-the-memory-leak-problem.patch
|
||||
Patch0072: 0072-uadk_tool-fix-error-writing-data-to-uninitialized-me.patch
|
||||
Patch0073: 0073-uadk_tool-added-sm4-xts-GB-test.patch
|
||||
Patch0074: 0074-uadk_tool-initialize-the-return-value-ret-of-the-fun.patch
|
||||
Patch0075: 0075-add-secure-compilation-option.patch
|
||||
Patch0076: 0076-uadk-v1-drv-hisi_zip_udrv-fix-unmap-buffer-for-lz77_.patch
|
||||
Patch0077: 0077-uadk-v1-drv-hisi_zip_udrv-fix-the-wrong-unmapped-add.patch
|
||||
Patch0078: 0078-uadk-v1-wd_comp-fix-unlocked-queue-resource-change.patch
|
||||
Patch0079: 0079-uadk-wd_alg-add-registering-driver-parameters-check.patch
|
||||
Patch0080: 0080-uadk-wd_comp-fix-some-comments.patch
|
||||
Patch0081: 0081-uadk-fix-the-process-when-ctx-request-fails.patch
|
||||
Patch0082: 0082-uadk-wd_util-fix-a-theoretically-infinite-loop.patch
|
||||
Patch0083: 0083-uadk-wd-fix-fscanf-infinite-loop.patch
|
||||
Patch0084: 0084-uadk-zlibwrapper-fix-wrong-request-check.patch
|
||||
Patch0085: 0085-uadk-drv-hisi-fix-sgl-copy-offset-error.patch
|
||||
|
||||
%description
|
||||
This package contains the User Space Accelerator Library
|
||||
@ -229,6 +272,9 @@ fi
|
||||
/sbin/ldconfig
|
||||
|
||||
%changelog
|
||||
* Thu Nov 23 2023 JiangShui Yang <yangjiangshui@h-partners.com> 2.5.0-6
|
||||
- libwd: update the source code
|
||||
|
||||
* Tue Oct 31 2023 JiangShui Yang <yangjiangshui@h-partners.com> 2.5.0-5
|
||||
- libwd: update the source code
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user