Update some patch for uadk from mainline. To get more information, please visit the homepage: https://github.comp/Linaro/uadk Signed-off-by: Yang Shen <shenyang39@huawei.com>
1247 lines
36 KiB
Diff
1247 lines
36 KiB
Diff
From e1f90f375fc35862d2c775f97a3119b95f19c8a2 Mon Sep 17 00:00:00 2001
|
|
From: Longfang Liu <liulongfang@huawei.com>
|
|
Date: Mon, 18 Jul 2022 17:16:31 +0800
|
|
Subject: [PATCH 147/183] uadk_tool: Update some new test features
|
|
|
|
1. Modify part of the repeated code macro.
|
|
2. Add new random number generation method.
|
|
3. Add new test parameters, support test algorithm
|
|
query and address pre-step function.
|
|
|
|
Signed-off-by: Longfang Liu <liulongfang@huawei.com>
|
|
---
|
|
uadk_tool/benchmark/sec_soft_benchmark.c | 7 +-
|
|
uadk_tool/benchmark/sec_soft_benchmark.h | 1 -
|
|
uadk_tool/benchmark/sec_uadk_benchmark.c | 65 ++++----
|
|
uadk_tool/benchmark/sec_wd_benchmark.c | 191 ++++++-----------------
|
|
uadk_tool/benchmark/uadk_benchmark.c | 115 ++++++++------
|
|
uadk_tool/benchmark/uadk_benchmark.h | 20 ++-
|
|
6 files changed, 166 insertions(+), 233 deletions(-)
|
|
|
|
diff --git a/uadk_tool/benchmark/sec_soft_benchmark.c b/uadk_tool/benchmark/sec_soft_benchmark.c
|
|
index 2f6bccb..a622329 100644
|
|
--- a/uadk_tool/benchmark/sec_soft_benchmark.c
|
|
+++ b/uadk_tool/benchmark/sec_soft_benchmark.c
|
|
@@ -56,11 +56,8 @@ typedef struct soft_jobs_res {
|
|
u32 use_engine;
|
|
} jobs_data;
|
|
|
|
-#define MAX_POOL_LENTH 4096
|
|
#define MAX_IVK_LENTH 64
|
|
#define DEF_IVK_DATA 0xAA
|
|
-#define MAX_TRY_CNT 5000
|
|
-#define SEND_USLEEP 100
|
|
|
|
static unsigned int g_thread_num;
|
|
static unsigned int g_ctxnum;
|
|
@@ -613,7 +610,7 @@ static void *sec_soft_async_run(void *arg)
|
|
exit_pause:
|
|
ASYNC_WAIT_CTX_free(waitctx);
|
|
|
|
- add_recv_data(count);
|
|
+ add_recv_data(count, g_pktlen);
|
|
|
|
return NULL;
|
|
}
|
|
@@ -802,7 +799,7 @@ static void *sec_soft_sync_run(void *arg)
|
|
break;
|
|
}
|
|
|
|
- add_recv_data(count);
|
|
+ add_recv_data(count, g_pktlen);
|
|
|
|
return NULL;
|
|
}
|
|
diff --git a/uadk_tool/benchmark/sec_soft_benchmark.h b/uadk_tool/benchmark/sec_soft_benchmark.h
|
|
index 8331eb5..c1374d6 100644
|
|
--- a/uadk_tool/benchmark/sec_soft_benchmark.h
|
|
+++ b/uadk_tool/benchmark/sec_soft_benchmark.h
|
|
@@ -4,6 +4,5 @@
|
|
|
|
#include "uadk_benchmark.h"
|
|
|
|
-
|
|
extern int sec_soft_benchmark(struct acc_option *options);
|
|
#endif /* SEC_SOFT_BENCHMARK_H */
|
|
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
|
index 6eeee12..09cd8f4 100644
|
|
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
|
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
|
@@ -10,6 +10,8 @@
|
|
#include "include/wd_sched.h"
|
|
|
|
#define SEC_TST_PRT printf
|
|
+#define MAX_IVK_LENTH 64
|
|
+#define DEF_IVK_DATA 0xAA
|
|
|
|
struct uadk_bd {
|
|
u8 *src;
|
|
@@ -37,18 +39,12 @@ typedef struct uadk_thread_res {
|
|
u32 td_id;
|
|
} thread_data;
|
|
|
|
-#define MAX_POOL_LENTH 4096
|
|
-#define MAX_IVK_LENTH 64
|
|
-#define DEF_IVK_DATA 0xAA
|
|
-#define MAX_TRY_CNT 5000
|
|
-#define SEND_USLEEP 100
|
|
-
|
|
static struct wd_ctx_config g_ctx_cfg;
|
|
static struct wd_sched *g_sched;
|
|
static unsigned int g_thread_num;
|
|
static unsigned int g_ctxnum;
|
|
+static unsigned int g_prefetch;
|
|
static unsigned int g_pktlen;
|
|
-static struct sched_params g_param;
|
|
|
|
static void *cipher_async_cb(struct wd_cipher_req *req, void *data)
|
|
{
|
|
@@ -349,6 +345,7 @@ 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;
|
|
|
|
@@ -385,7 +382,7 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
|
break;
|
|
default:
|
|
SEC_TST_PRT("Fail to parse alg subtype!\n");
|
|
- return -EINVAL;
|
|
+ goto out;
|
|
}
|
|
if (!g_sched) {
|
|
SEC_TST_PRT("Fail to alloc sched!\n");
|
|
@@ -397,12 +394,12 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
|
list->dev->numa_id = 0;
|
|
|
|
g_sched->name = SCHED_SINGLE;
|
|
- g_param.numa_id = list->dev->numa_id;
|
|
- g_param.type = 0;
|
|
- g_param.mode = mode;
|
|
- g_param.begin = 0;
|
|
- g_param.end = g_ctxnum - 1;
|
|
- ret = wd_sched_rr_instance(g_sched, &g_param);
|
|
+ param.numa_id = list->dev->numa_id;
|
|
+ param.type = 0;
|
|
+ param.mode = mode;
|
|
+ param.begin = 0;
|
|
+ param.end = g_ctxnum - 1;
|
|
+ ret = wd_sched_rr_instance(g_sched, ¶m);
|
|
if (ret) {
|
|
SEC_TST_PRT("Fail to fill sched data!\n");
|
|
goto out;
|
|
@@ -419,6 +416,8 @@ 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");
|
|
@@ -461,18 +460,13 @@ static void uninit_ctx_config(int subtype)
|
|
wd_sched_rr_release(g_sched);
|
|
}
|
|
|
|
-int init_uadk_bd_pool(void)
|
|
+static int init_uadk_bd_pool(void)
|
|
{
|
|
unsigned long step;
|
|
- int fill_size;
|
|
int i, j;
|
|
|
|
// make the block not align to 4K
|
|
step = sizeof(char) * g_pktlen * 2;
|
|
- if (g_pktlen > MAX_IVK_LENTH)
|
|
- fill_size = MAX_IVK_LENTH;
|
|
- else
|
|
- fill_size = g_pktlen;
|
|
|
|
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));
|
|
@@ -498,7 +492,9 @@ 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, fill_size);
|
|
+ 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);
|
|
}
|
|
}
|
|
}
|
|
@@ -526,12 +522,13 @@ malloc_error1:
|
|
|
|
free(g_uadk_pool.iv);
|
|
free(g_uadk_pool.key);
|
|
+ free(g_uadk_pool.mac);
|
|
|
|
SEC_TST_PRT("init uadk bd pool alloc failed!\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
-void free_uadk_bd_pool(void)
|
|
+static void free_uadk_bd_pool(void)
|
|
{
|
|
int i, j;
|
|
|
|
@@ -550,21 +547,22 @@ void free_uadk_bd_pool(void)
|
|
|
|
free(g_uadk_pool.iv);
|
|
free(g_uadk_pool.key);
|
|
+ free(g_uadk_pool.mac);
|
|
}
|
|
|
|
/*-------------------------------uadk benchmark main code-------------------------------------*/
|
|
|
|
-void *sec_uadk_poll(void *data)
|
|
+static void *sec_uadk_poll(void *data)
|
|
{
|
|
typedef int (*poll_ctx)(__u32 idx, __u32 expt, __u32 *count);
|
|
poll_ctx uadk_poll_ctx = NULL;
|
|
thread_data *pdata = (thread_data *)data;
|
|
u32 expt = ACC_QUEUE_SIZE * g_thread_num;
|
|
u32 id = pdata->td_id;
|
|
- u32 last_time = 2; /* poll need one more recv time */
|
|
+ u32 last_time = 2; // poll need one more recv time
|
|
u32 count = 0;
|
|
u32 recv = 0;
|
|
- int ret;
|
|
+ int ret;
|
|
|
|
if (id > g_ctxnum)
|
|
return NULL;
|
|
@@ -586,7 +584,6 @@ void *sec_uadk_poll(void *data)
|
|
|
|
while (last_time) {
|
|
ret = uadk_poll_ctx(id, expt, &recv);
|
|
- // SEC_TST_PRT("expt %u, poll %d recv: %u!\n", expt, i, recv);
|
|
count += recv;
|
|
recv = 0;
|
|
if (unlikely(ret != -WD_EAGAIN && ret < 0)) {
|
|
@@ -599,7 +596,7 @@ void *sec_uadk_poll(void *data)
|
|
}
|
|
|
|
recv_error:
|
|
- add_recv_data(count);
|
|
+ add_recv_data(count, g_pktlen);
|
|
|
|
return NULL;
|
|
}
|
|
@@ -636,7 +633,6 @@ static void *sec_uadk_async_run(void *arg)
|
|
case CIPHER_TYPE:
|
|
cipher_setup.alg = pdata->alg;
|
|
cipher_setup.mode = pdata->mode;
|
|
- cipher_setup.sched_param = (void *)&g_param;
|
|
h_sess = wd_cipher_alloc_sess(&cipher_setup);
|
|
if (!h_sess)
|
|
return NULL;
|
|
@@ -682,7 +678,6 @@ static void *sec_uadk_async_run(void *arg)
|
|
case AEAD_TYPE: // just ccm and gcm
|
|
aead_setup.calg = pdata->alg;
|
|
aead_setup.cmode = pdata->mode;
|
|
- aead_setup.sched_param = (void *)&g_param;
|
|
h_sess = wd_aead_alloc_sess(&aead_setup);
|
|
if (!h_sess)
|
|
return NULL;
|
|
@@ -740,7 +735,6 @@ static void *sec_uadk_async_run(void *arg)
|
|
case DIGEST_TYPE:
|
|
digest_setup.alg = pdata->alg;
|
|
digest_setup.mode = pdata->mode; // digest mode is optype
|
|
- digest_setup.sched_param = (void *)&g_param;
|
|
h_sess = wd_digest_alloc_sess(&digest_setup);
|
|
if (!h_sess)
|
|
return NULL;
|
|
@@ -820,7 +814,6 @@ static void *sec_uadk_sync_run(void *arg)
|
|
case CIPHER_TYPE:
|
|
cipher_setup.alg = pdata->alg;
|
|
cipher_setup.mode = pdata->mode;
|
|
- cipher_setup.sched_param = (void *)&g_param;
|
|
h_sess = wd_cipher_alloc_sess(&cipher_setup);
|
|
if (!h_sess)
|
|
return NULL;
|
|
@@ -845,7 +838,7 @@ static void *sec_uadk_sync_run(void *arg)
|
|
creq.src = uadk_pool->bds[i].src;
|
|
creq.dst = uadk_pool->bds[i].dst;
|
|
ret = wd_do_cipher_sync(h_sess, &creq);
|
|
- if (ret || creq.state)
|
|
+ if ((ret < 0 && ret != -WD_EBUSY) || creq.state)
|
|
break;
|
|
count++;
|
|
if (get_run_state() == 0)
|
|
@@ -856,7 +849,6 @@ static void *sec_uadk_sync_run(void *arg)
|
|
case AEAD_TYPE: // just ccm and gcm
|
|
aead_setup.calg = pdata->alg;
|
|
aead_setup.cmode = pdata->mode;
|
|
- aead_setup.sched_param = (void *)&g_param;
|
|
h_sess = wd_aead_alloc_sess(&aead_setup);
|
|
if (!h_sess)
|
|
return NULL;
|
|
@@ -905,7 +897,6 @@ static void *sec_uadk_sync_run(void *arg)
|
|
case DIGEST_TYPE:
|
|
digest_setup.alg = pdata->alg;
|
|
digest_setup.mode = pdata->mode; // digest mode is optype
|
|
- digest_setup.sched_param = (void *)&g_param;
|
|
h_sess = wd_digest_alloc_sess(&digest_setup);
|
|
if (!h_sess)
|
|
return NULL;
|
|
@@ -939,7 +930,7 @@ static void *sec_uadk_sync_run(void *arg)
|
|
break;
|
|
}
|
|
|
|
- add_recv_data(count);
|
|
+ add_recv_data(count, g_pktlen);
|
|
|
|
return NULL;
|
|
}
|
|
@@ -982,7 +973,6 @@ int sec_uadk_sync_threads(struct acc_option *options)
|
|
|
|
sync_error:
|
|
return ret;
|
|
-
|
|
}
|
|
|
|
int sec_uadk_async_threads(struct acc_option *options)
|
|
@@ -998,10 +988,10 @@ int sec_uadk_async_threads(struct acc_option *options)
|
|
if (ret)
|
|
return ret;
|
|
|
|
- /* poll thread */
|
|
for (i = 0; i < g_ctxnum; i++) {
|
|
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 (ret) {
|
|
SEC_TST_PRT("Create poll thread fail!\n");
|
|
@@ -1053,6 +1043,7 @@ int sec_uadk_benchmark(struct acc_option *options)
|
|
g_thread_num = options->threads;
|
|
g_pktlen = options->pktlen;
|
|
g_ctxnum = options->ctxnums;
|
|
+ g_prefetch = options->prefetch;
|
|
if (options->optype > WD_CIPHER_DECRYPTION) {
|
|
SEC_TST_PRT("SEC optype error: %u\n", options->optype);
|
|
return -EINVAL;
|
|
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
|
index 2e9c55d..3017fb8 100644
|
|
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
|
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
|
@@ -11,6 +11,9 @@
|
|
#include "v1/wd_util.h"
|
|
|
|
#define SEC_TST_PRT printf
|
|
+#define MAX_IVK_LENTH 64
|
|
+#define DEF_IVK_DATA 0xAA
|
|
+#define SQE_SIZE 128
|
|
|
|
typedef struct wd_thread_res {
|
|
u32 subtype;
|
|
@@ -32,57 +35,31 @@ struct thread_bd_res {
|
|
|
|
struct thread_queue_res {
|
|
struct thread_bd_res *bd_res;
|
|
-} g_thread_queue;
|
|
+};
|
|
|
|
struct wcrypto_async_tag {
|
|
void *ctx;
|
|
- char *out_buf;
|
|
int thread_id;
|
|
int cnt;
|
|
};
|
|
|
|
-#define MAX_IVK_LENTH 64
|
|
-#define DEF_IVK_DATA 0xAA
|
|
-#define MAX_TRY_CNT 5000
|
|
-#define SEND_USLEEP 100
|
|
-#define TEST_MAX_THRD 128
|
|
-#define SQE_SIZE 128
|
|
-#define MAX_BLOCK_NM 4096
|
|
-
|
|
+static struct thread_queue_res g_thread_queue;
|
|
static unsigned int g_thread_num;
|
|
-static unsigned int g_ctxnum;
|
|
static unsigned int g_pktlen;
|
|
|
|
static void *cipher_async_cb(void *message, void *cipher_tag)
|
|
{
|
|
- struct wcrypto_async_tag *async_tag = (struct wcrypto_async_tag *)cipher_tag;
|
|
- struct wcrypto_cipher_msg *req = (struct wcrypto_cipher_msg *)message;
|
|
-
|
|
- // no-sva data copy from uadk to user
|
|
- memcpy(async_tag->out_buf, req->out, g_pktlen);
|
|
-
|
|
return NULL;
|
|
}
|
|
|
|
-static void *aead_async_cb(void *message, void *aead_tag)
|
|
+static void *aead_async_cb(void *message, void *cipher_tag)
|
|
{
|
|
- struct wcrypto_async_tag *async_tag = (struct wcrypto_async_tag *)aead_tag;
|
|
- struct wcrypto_aead_msg *req = (struct wcrypto_aead_msg *)message;
|
|
-
|
|
- // no-sva data copy from uadk to user
|
|
- memcpy(async_tag->out_buf, req->out, g_pktlen);
|
|
-
|
|
return NULL;
|
|
}
|
|
|
|
static void *digest_async_cb(void *message, void *digest_tag)
|
|
{
|
|
- struct wcrypto_async_tag *async_tag = (struct wcrypto_async_tag *)digest_tag;
|
|
- struct wcrypto_digest_msg *req = (struct wcrypto_digest_msg *)message;
|
|
-
|
|
- // no-sva data copy from uadk to user
|
|
- memcpy(async_tag->out_buf, req->out, 16);
|
|
-
|
|
+ // struct WCRYPTO_req *req = (struct WCRYPTO_req *)data;
|
|
return NULL;
|
|
}
|
|
|
|
@@ -396,9 +373,9 @@ static int init_wd_queue(struct acc_option *options)
|
|
// use no-sva pbuffer
|
|
memset(&blksetup, 0, sizeof(blksetup));
|
|
blksetup.block_size = g_pktlen + SQE_SIZE; //aead need mac and aad out
|
|
- blksetup.block_num = MAX_BLOCK_NM * 4; //set pool inv + key + in + out
|
|
+ blksetup.block_num = MAX_BLOCK_NM; //set pool inv + key + in + out
|
|
blksetup.align_size = SQE_SIZE;
|
|
- SEC_TST_PRT("create pool memory: %d KB\n", (MAX_BLOCK_NM * blksetup.block_size) >> 10);
|
|
+ // SEC_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);
|
|
@@ -411,8 +388,8 @@ static int init_wd_queue(struct acc_option *options)
|
|
|
|
// alloc in pbuffer res
|
|
for (m = 0; m < g_thread_num; m++) {
|
|
- g_thread_queue.bd_res[m].in = malloc(MAX_BLOCK_NM * sizeof(void *));
|
|
- for (idx = 0; idx < MAX_BLOCK_NM; idx++) {
|
|
+ g_thread_queue.bd_res[m].in = malloc(MAX_POOL_LENTH * sizeof(void *));
|
|
+ for (idx = 0; idx < MAX_POOL_LENTH; idx++) {
|
|
g_thread_queue.bd_res[m].in[idx] = wd_alloc_blk(g_thread_queue.bd_res[m].pool);
|
|
if (!g_thread_queue.bd_res[m].in[idx]) {
|
|
SEC_TST_PRT("create pool %dth in memory fail!\n", m);
|
|
@@ -427,8 +404,8 @@ static int init_wd_queue(struct acc_option *options)
|
|
|
|
// alloc out pbuffer res
|
|
for (n = 0; n < g_thread_num; n++) {
|
|
- g_thread_queue.bd_res[n].out = malloc(MAX_BLOCK_NM * sizeof(void *));
|
|
- for (idx = 0; idx < MAX_BLOCK_NM; idx++) {
|
|
+ g_thread_queue.bd_res[n].out = malloc(MAX_POOL_LENTH * sizeof(void *));
|
|
+ for (idx = 0; idx < MAX_POOL_LENTH; idx++) {
|
|
g_thread_queue.bd_res[n].out[idx] = wd_alloc_blk(g_thread_queue.bd_res[n].pool);
|
|
if (!g_thread_queue.bd_res[n].out[idx]) {
|
|
SEC_TST_PRT("create pool %dth out memory fail!\n", n);
|
|
@@ -443,8 +420,8 @@ static int init_wd_queue(struct acc_option *options)
|
|
|
|
// alloc iv pbuffer res
|
|
for (k = 0; k < g_thread_num; k++) {
|
|
- g_thread_queue.bd_res[k].iv = malloc(MAX_BLOCK_NM * sizeof(void *));
|
|
- for (idx = 0; idx < MAX_BLOCK_NM; idx++) {
|
|
+ g_thread_queue.bd_res[k].iv = malloc(MAX_POOL_LENTH * sizeof(void *));
|
|
+ for (idx = 0; idx < MAX_POOL_LENTH; idx++) {
|
|
g_thread_queue.bd_res[k].iv[idx] = wd_alloc_blk(g_thread_queue.bd_res[k].pool);
|
|
if (!g_thread_queue.bd_res[k].iv[idx]) {
|
|
SEC_TST_PRT("create pool %dth iv memory fail!\n", k);
|
|
@@ -462,21 +439,21 @@ static int init_wd_queue(struct acc_option *options)
|
|
|
|
iv_err:
|
|
for (k--; k >= 0; k--) {
|
|
- for (idx = 0; idx < MAX_BLOCK_NM; idx++)
|
|
+ for (idx = 0; idx < MAX_POOL_LENTH; idx++)
|
|
wd_free_blk(g_thread_queue.bd_res[k].pool,
|
|
g_thread_queue.bd_res[k].iv[idx]);
|
|
free(g_thread_queue.bd_res[k].iv);
|
|
}
|
|
out_err:
|
|
for (n--; n >= 0; n--) {
|
|
- for (idx = 0; idx < MAX_BLOCK_NM; idx++)
|
|
+ for (idx = 0; idx < MAX_POOL_LENTH; idx++)
|
|
wd_free_blk(g_thread_queue.bd_res[n].pool,
|
|
g_thread_queue.bd_res[n].out[idx]);
|
|
free(g_thread_queue.bd_res[n].out);
|
|
}
|
|
in_err:
|
|
for (m--; m >= 0; m--) {
|
|
- for (idx = 0; idx < MAX_BLOCK_NM; idx++)
|
|
+ for (idx = 0; idx < MAX_POOL_LENTH; idx++)
|
|
wd_free_blk(g_thread_queue.bd_res[m].pool,
|
|
g_thread_queue.bd_res[m].in[idx]);
|
|
free(g_thread_queue.bd_res[m].in);
|
|
@@ -498,7 +475,7 @@ static void uninit_wd_queue(void)
|
|
int i, j, idx;
|
|
|
|
for (i = 0; i < g_thread_num; i++) {
|
|
- for (idx = 0; idx < MAX_BLOCK_NM; idx++) {
|
|
+ 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]);
|
|
wd_free_blk(g_thread_queue.bd_res[i].pool, g_thread_queue.bd_res[i].in[idx]);
|
|
wd_free_blk(g_thread_queue.bd_res[i].pool, g_thread_queue.bd_res[i].out[idx]);
|
|
@@ -522,22 +499,22 @@ void *sec_wd_poll(void *data)
|
|
{
|
|
typedef int (*poll_ctx)(struct wd_queue *q, unsigned int num);
|
|
thread_data *pdata = (thread_data *)data;
|
|
- poll_ctx uadk_poll_ctx = NULL;
|
|
+ poll_ctx wd_poll_ctx = NULL;
|
|
u32 expt = ACC_QUEUE_SIZE * g_thread_num;
|
|
- u32 last_time = 2; /* poll need one more recv time */
|
|
+ u32 last_time = 2; // poll need one more recv time
|
|
u32 id = pdata->td_id;
|
|
u32 count = 0;
|
|
- u32 recv = 0;
|
|
+ int recv = 0;
|
|
|
|
switch(pdata->subtype) {
|
|
case CIPHER_TYPE:
|
|
- uadk_poll_ctx = wcrypto_cipher_poll;
|
|
+ wd_poll_ctx = wcrypto_cipher_poll;
|
|
break;
|
|
case AEAD_TYPE:
|
|
- uadk_poll_ctx = wcrypto_aead_poll;
|
|
+ wd_poll_ctx = wcrypto_aead_poll;
|
|
break;
|
|
case DIGEST_TYPE:
|
|
- uadk_poll_ctx = wcrypto_digest_poll;
|
|
+ wd_poll_ctx = wcrypto_digest_poll;
|
|
break;
|
|
default:
|
|
SEC_TST_PRT("<<<<<<async poll interface is NULL!\n");
|
|
@@ -548,7 +525,7 @@ void *sec_wd_poll(void *data)
|
|
return NULL;
|
|
|
|
while (last_time) {
|
|
- recv = uadk_poll_ctx(g_thread_queue.bd_res[id].queue, expt);
|
|
+ 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);
|
|
@@ -565,7 +542,7 @@ void *sec_wd_poll(void *data)
|
|
}
|
|
|
|
recv_error:
|
|
- add_recv_data(count);
|
|
+ add_recv_data(count, g_pktlen);
|
|
|
|
return NULL;
|
|
}
|
|
@@ -582,8 +559,6 @@ static void *sec_wd_async_run(void *arg)
|
|
struct wcrypto_async_tag *tag = NULL;
|
|
char priv_key[MAX_IVK_LENTH];
|
|
struct thread_bd_res *bd_res;
|
|
- char *src_data_buf = NULL;
|
|
- char *out_data_buf = NULL;
|
|
struct wd_queue *queue;
|
|
void *ctx = NULL;
|
|
void **res_in;
|
|
@@ -605,27 +580,13 @@ static void *sec_wd_async_run(void *arg)
|
|
res_out = bd_res->out;
|
|
res_iv = bd_res->iv;
|
|
|
|
- /* create user data buffer */
|
|
- src_data_buf = malloc(g_pktlen * sizeof(char));
|
|
- if (!src_data_buf)
|
|
- return NULL;
|
|
-
|
|
- get_rand_data((u8 *)src_data_buf, g_pktlen);
|
|
- out_data_buf = malloc(g_pktlen * sizeof(char));
|
|
- if (!out_data_buf) {
|
|
- free(src_data_buf);
|
|
- return NULL;
|
|
- }
|
|
-
|
|
memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH);
|
|
tag = malloc(sizeof(struct wcrypto_async_tag)); // set the user tag
|
|
if (!tag) {
|
|
SEC_TST_PRT("wcrypto async alloc tag fail!\n");
|
|
- free(src_data_buf);
|
|
- free(out_data_buf);
|
|
return NULL;
|
|
}
|
|
- tag->out_buf = out_data_buf;
|
|
+ tag->thread_id = pdata->td_id;
|
|
|
|
switch(pdata->subtype) {
|
|
case CIPHER_TYPE:
|
|
@@ -642,7 +603,7 @@ static void *sec_wd_async_run(void *arg)
|
|
ctx = wcrypto_create_cipher_ctx(queue, &cipher_setup);
|
|
if (!ctx) {
|
|
SEC_TST_PRT("wd create cipher ctx fail!\n");
|
|
- goto async_err;
|
|
+ return NULL;
|
|
}
|
|
tag->ctx = ctx;
|
|
|
|
@@ -650,7 +611,7 @@ static void *sec_wd_async_run(void *arg)
|
|
if (ret) {
|
|
SEC_TST_PRT("wd cipher set key fail!\n");
|
|
wcrypto_del_cipher_ctx(ctx);
|
|
- goto async_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
if (queue->capa.priv.direction == 0)
|
|
@@ -672,9 +633,6 @@ static void *sec_wd_async_run(void *arg)
|
|
if (get_run_state() == 0)
|
|
break;
|
|
|
|
- // no-sva data copy to uadk
|
|
- memcpy(copdata.in, src_data_buf, g_pktlen);
|
|
-
|
|
ret = wcrypto_do_cipher(ctx, &copdata, (void *)tag);
|
|
if (ret == -WD_EBUSY) {
|
|
usleep(SEND_USLEEP * try_cnt);
|
|
@@ -687,7 +645,7 @@ static void *sec_wd_async_run(void *arg)
|
|
}
|
|
|
|
count++;
|
|
- i = count % MAX_BLOCK_NM;
|
|
+ i = count % MAX_POOL_LENTH;
|
|
tag->cnt = i;
|
|
try_cnt = 0;
|
|
copdata.in = res_in[i];
|
|
@@ -710,7 +668,7 @@ static void *sec_wd_async_run(void *arg)
|
|
ctx = wcrypto_create_aead_ctx(queue, &aead_setup);
|
|
if (!ctx) {
|
|
SEC_TST_PRT("wd create aead ctx fail!\n");
|
|
- goto async_err;
|
|
+ return NULL;
|
|
}
|
|
tag->ctx = ctx;
|
|
|
|
@@ -718,7 +676,7 @@ static void *sec_wd_async_run(void *arg)
|
|
if (ret) {
|
|
SEC_TST_PRT("wd aead set key fail!\n");
|
|
wcrypto_del_aead_ctx(ctx);
|
|
- goto async_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
authsize = 16; //set defaut size
|
|
@@ -726,7 +684,7 @@ static void *sec_wd_async_run(void *arg)
|
|
if (ret) {
|
|
SEC_TST_PRT("set authsize fail!\n");
|
|
wcrypto_del_aead_ctx(ctx);
|
|
- goto async_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
if (queue->capa.priv.direction == 0) {
|
|
@@ -753,9 +711,6 @@ static void *sec_wd_async_run(void *arg)
|
|
if (get_run_state() == 0)
|
|
break;
|
|
|
|
- // no-sva data copy to uadk
|
|
- memcpy(aopdata.in, src_data_buf, g_pktlen);
|
|
-
|
|
ret = wcrypto_do_aead(ctx, &aopdata, (void *)tag);
|
|
if (ret == -WD_EBUSY) {
|
|
usleep(SEND_USLEEP * try_cnt);
|
|
@@ -768,7 +723,7 @@ static void *sec_wd_async_run(void *arg)
|
|
}
|
|
|
|
count++;
|
|
- i = count % MAX_BLOCK_NM;
|
|
+ i = count % MAX_POOL_LENTH;
|
|
tag->cnt = i;
|
|
try_cnt = 0;
|
|
aopdata.in = res_in[i];
|
|
@@ -791,7 +746,7 @@ static void *sec_wd_async_run(void *arg)
|
|
ctx = wcrypto_create_digest_ctx(queue, &digest_setup);
|
|
if (!ctx) {
|
|
SEC_TST_PRT("wd create digest ctx fail!\n");
|
|
- goto async_err;
|
|
+ return NULL;
|
|
}
|
|
tag->ctx = ctx;
|
|
|
|
@@ -801,7 +756,7 @@ static void *sec_wd_async_run(void *arg)
|
|
if (ret) {
|
|
SEC_TST_PRT("wd digest set key fail!\n");
|
|
wcrypto_del_digest_ctx(ctx);
|
|
- goto async_err;
|
|
+ return NULL;
|
|
}
|
|
}
|
|
|
|
@@ -818,9 +773,6 @@ static void *sec_wd_async_run(void *arg)
|
|
if (get_run_state() == 0)
|
|
break;
|
|
|
|
- // no-sva data copy to uadk
|
|
- memcpy(dopdata.in, src_data_buf, g_pktlen);
|
|
-
|
|
ret = wcrypto_do_digest(ctx, &dopdata, (void *)tag);
|
|
if (ret == -WD_EBUSY) {
|
|
usleep(SEND_USLEEP * try_cnt);
|
|
@@ -833,7 +785,7 @@ static void *sec_wd_async_run(void *arg)
|
|
}
|
|
|
|
count++;
|
|
- i = count % MAX_BLOCK_NM;
|
|
+ i = count % MAX_POOL_LENTH;
|
|
tag->cnt = i;
|
|
try_cnt = 0;
|
|
dopdata.in = res_in[i];
|
|
@@ -846,7 +798,7 @@ static void *sec_wd_async_run(void *arg)
|
|
add_send_complete();
|
|
|
|
while (1) {
|
|
- if (get_recv_time() == g_thread_num) // wait Async mode finish recv
|
|
+ if (get_recv_time() > 0) // wait Async mode finish recv
|
|
break;
|
|
usleep(SEND_USLEEP);
|
|
}
|
|
@@ -863,10 +815,6 @@ static void *sec_wd_async_run(void *arg)
|
|
break;
|
|
}
|
|
|
|
-async_err:
|
|
- free(tag);
|
|
- free(src_data_buf);
|
|
- free(out_data_buf);
|
|
return NULL;
|
|
}
|
|
|
|
@@ -882,8 +830,6 @@ static void *sec_wd_sync_run(void *arg)
|
|
char priv_key[MAX_IVK_LENTH];
|
|
struct thread_bd_res *bd_res;
|
|
struct wd_queue *queue;
|
|
- char *src_data_buf = NULL;
|
|
- char *out_data_buf = NULL;
|
|
void *ctx = NULL;
|
|
void *tag = NULL;
|
|
void **res_in;
|
|
@@ -905,18 +851,6 @@ static void *sec_wd_sync_run(void *arg)
|
|
res_out = bd_res->out;
|
|
res_iv = bd_res->iv;
|
|
|
|
- /* create user data buffer */
|
|
- src_data_buf = malloc(g_pktlen * sizeof(char));
|
|
- if (!src_data_buf)
|
|
- return NULL;
|
|
-
|
|
- get_rand_data((u8 *)src_data_buf, g_pktlen);
|
|
- out_data_buf = malloc(g_pktlen * sizeof(char));
|
|
- if (!out_data_buf) {
|
|
- free(src_data_buf);
|
|
- return NULL;
|
|
- }
|
|
-
|
|
memset(priv_key, DEF_IVK_DATA, MAX_IVK_LENTH);
|
|
|
|
switch(pdata->subtype) {
|
|
@@ -933,14 +867,14 @@ static void *sec_wd_sync_run(void *arg)
|
|
ctx = wcrypto_create_cipher_ctx(queue, &cipher_setup);
|
|
if (!ctx) {
|
|
SEC_TST_PRT("wd create cipher ctx fail!\n");
|
|
- goto sync_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
ret = wcrypto_set_cipher_key(ctx, (__u8*)priv_key, (__u16)pdata->keysize);
|
|
if (ret) {
|
|
SEC_TST_PRT("wd cipher set key fail!\n");
|
|
wcrypto_del_cipher_ctx(ctx);
|
|
- goto sync_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
if (queue->capa.priv.direction == 0)
|
|
@@ -961,9 +895,6 @@ static void *sec_wd_sync_run(void *arg)
|
|
if (get_run_state() == 0)
|
|
break;
|
|
|
|
- // no-sva data copy to uadk
|
|
- memcpy(copdata.in, src_data_buf, g_pktlen);
|
|
-
|
|
ret = wcrypto_do_cipher(ctx, &copdata, tag);
|
|
if (ret == -WD_EBUSY) {
|
|
usleep(SEND_USLEEP * try_cnt);
|
|
@@ -977,13 +908,10 @@ static void *sec_wd_sync_run(void *arg)
|
|
|
|
count++;
|
|
try_cnt = 0;
|
|
- i = count % MAX_BLOCK_NM;
|
|
+ i = count % MAX_POOL_LENTH;
|
|
copdata.in = res_in[i];
|
|
copdata.out = res_out[i];
|
|
copdata.iv = res_iv[i];
|
|
-
|
|
- // no-sva data copy from uadk to user
|
|
- memcpy(out_data_buf, copdata.out, g_pktlen);
|
|
}
|
|
wcrypto_del_cipher_ctx(ctx);
|
|
|
|
@@ -1001,14 +929,14 @@ static void *sec_wd_sync_run(void *arg)
|
|
ctx = wcrypto_create_aead_ctx(queue, &aead_setup);
|
|
if (!ctx) {
|
|
SEC_TST_PRT("wd create aead ctx fail!\n");
|
|
- goto sync_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
ret = wcrypto_set_aead_ckey(ctx, (__u8*)priv_key, (__u16)pdata->keysize);
|
|
if (ret) {
|
|
SEC_TST_PRT("wd aead set key fail!\n");
|
|
wcrypto_del_aead_ctx(ctx);
|
|
- goto sync_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
authsize = 16; //set defaut size
|
|
@@ -1016,7 +944,7 @@ static void *sec_wd_sync_run(void *arg)
|
|
if (ret) {
|
|
SEC_TST_PRT("set authsize fail!\n");
|
|
wcrypto_del_aead_ctx(ctx);
|
|
- goto sync_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
if (queue->capa.priv.direction == 0) {
|
|
@@ -1042,9 +970,6 @@ static void *sec_wd_sync_run(void *arg)
|
|
if (get_run_state() == 0)
|
|
break;
|
|
|
|
- // no-sva data copy to uadk
|
|
- memcpy(aopdata.in, src_data_buf, g_pktlen);
|
|
-
|
|
ret = wcrypto_do_aead(ctx, &aopdata, tag);
|
|
if (ret == -WD_EBUSY) {
|
|
usleep(SEND_USLEEP * try_cnt);
|
|
@@ -1058,13 +983,10 @@ static void *sec_wd_sync_run(void *arg)
|
|
|
|
count++;
|
|
try_cnt = 0;
|
|
- i = count % MAX_BLOCK_NM;
|
|
+ i = count % MAX_POOL_LENTH;
|
|
aopdata.in = res_in[i];
|
|
aopdata.out = res_out[i];
|
|
aopdata.iv = res_iv[i];
|
|
-
|
|
- // no-sva data copy from uadk to user
|
|
- memcpy(out_data_buf, aopdata.out, g_pktlen);
|
|
}
|
|
wcrypto_del_aead_ctx(ctx);
|
|
|
|
@@ -1082,7 +1004,7 @@ static void *sec_wd_sync_run(void *arg)
|
|
ctx = wcrypto_create_digest_ctx(queue, &digest_setup);
|
|
if (!ctx) {
|
|
SEC_TST_PRT("wd create digest ctx fail!\n");
|
|
- goto sync_err;
|
|
+ return NULL;
|
|
}
|
|
|
|
if (digest_setup.mode == WCRYPTO_DIGEST_HMAC) {
|
|
@@ -1091,7 +1013,7 @@ static void *sec_wd_sync_run(void *arg)
|
|
if (ret) {
|
|
SEC_TST_PRT("wd digest set key fail!\n");
|
|
wcrypto_del_digest_ctx(ctx);
|
|
- goto sync_err;
|
|
+ return NULL;
|
|
}
|
|
}
|
|
|
|
@@ -1107,9 +1029,6 @@ static void *sec_wd_sync_run(void *arg)
|
|
if (get_run_state() == 0)
|
|
break;
|
|
|
|
- // no-sva data copy to uadk
|
|
- memcpy(dopdata.in, src_data_buf, g_pktlen);
|
|
-
|
|
ret = wcrypto_do_digest(ctx, &dopdata, (void *)tag);
|
|
if (ret == -WD_EBUSY) {
|
|
usleep(SEND_USLEEP * try_cnt);
|
|
@@ -1123,22 +1042,16 @@ static void *sec_wd_sync_run(void *arg)
|
|
|
|
count++;
|
|
try_cnt = 0;
|
|
- i = count % MAX_BLOCK_NM;
|
|
+ i = count % MAX_POOL_LENTH;
|
|
dopdata.in = res_in[i];
|
|
- dopdata.out = res_out[i];
|
|
-
|
|
- // no-sva data copy from uadk to user
|
|
- memcpy(out_data_buf, dopdata.out, 16);
|
|
+ dopdata.out = res_out[i];
|
|
}
|
|
wcrypto_del_digest_ctx(ctx);
|
|
break;
|
|
}
|
|
|
|
- add_recv_data(count);
|
|
+ add_recv_data(count, g_pktlen);
|
|
|
|
-sync_err:
|
|
- free(src_data_buf);
|
|
- free(out_data_buf);
|
|
return NULL;
|
|
}
|
|
|
|
@@ -1180,6 +1093,7 @@ int sec_wd_sync_threads(struct acc_option *options)
|
|
|
|
sync_error:
|
|
return ret;
|
|
+
|
|
}
|
|
|
|
int sec_wd_async_threads(struct acc_option *options)
|
|
@@ -1249,7 +1163,6 @@ int sec_wd_benchmark(struct acc_option *options)
|
|
|
|
g_thread_num = options->threads;
|
|
g_pktlen = options->pktlen;
|
|
- g_ctxnum = options->ctxnums;
|
|
if (options->optype > WCRYPTO_CIPHER_DECRYPTION) {
|
|
SEC_TST_PRT("SEC optype error: %u\n", options->optype);
|
|
return -EINVAL;
|
|
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
|
index 84941d5..2904cba 100644
|
|
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
|
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
|
@@ -10,19 +10,19 @@
|
|
|
|
#define BYTES_TO_KB 10
|
|
#define TABLE_SPACE_SIZE 8
|
|
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
/*----------------------------------------head struct--------------------------------------------------------*/
|
|
static unsigned int g_run_state = 1;
|
|
static pthread_mutex_t acc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
static struct _recv_data {
|
|
+ double pkg_len;
|
|
u64 send_cnt;
|
|
u64 recv_cnt;
|
|
u32 send_times;
|
|
u32 recv_times;
|
|
} g_recv_data;
|
|
|
|
-/* SVA mode and NOSVA mode change need re_insmode driver ko */
|
|
+/* SVA mode and NOSVA mode change need re_insmod driver ko */
|
|
enum test_type {
|
|
SVA_MODE = 0x1,
|
|
NOSVA_MODE = 0x2,
|
|
@@ -63,7 +63,7 @@ static struct acc_alg_item alg_options[] = {
|
|
{"rsa-2048-crt", RSA_2048_CRT},
|
|
{"rsa-3072-crt", RSA_3072_CRT},
|
|
{"rsa-4096-crt", RSA_4096_CRT},
|
|
- {"dh-768 ", DH_768},
|
|
+ {"dh-768", DH_768},
|
|
{"dh-1024", DH_1024},
|
|
{"dh-1536", DH_1536},
|
|
{"dh-2048", DH_2048},
|
|
@@ -131,10 +131,14 @@ void add_send_complete(void)
|
|
__atomic_add_fetch(&g_recv_data.send_times, 1, __ATOMIC_RELAXED);
|
|
}
|
|
|
|
-void add_recv_data(u32 cnt)
|
|
+void add_recv_data(u32 cnt, u32 pkglen)
|
|
{
|
|
pthread_mutex_lock(&acc_mutex);
|
|
g_recv_data.recv_cnt += cnt;
|
|
+ if (g_recv_data.pkg_len == 0)
|
|
+ g_recv_data.pkg_len = pkglen;
|
|
+ else
|
|
+ g_recv_data.pkg_len = ((double)pkglen + g_recv_data.pkg_len) / 2;
|
|
g_recv_data.recv_times++;
|
|
pthread_mutex_unlock(&acc_mutex);
|
|
}
|
|
@@ -148,6 +152,7 @@ void init_recv_data(void)
|
|
{
|
|
g_recv_data.send_cnt = 0;
|
|
g_recv_data.recv_cnt = 0;
|
|
+ g_recv_data.pkg_len = 0.0;
|
|
g_recv_data.send_times = 0;
|
|
g_recv_data.recv_times = 0;
|
|
}
|
|
@@ -263,28 +268,21 @@ void time_start(u32 seconds)
|
|
alarm(seconds);
|
|
}
|
|
|
|
-int get_rand_int(int range)
|
|
-{
|
|
- int randnum;
|
|
-
|
|
- if (range <= 0) {
|
|
- ACC_TST_PRT("rand range error!\n");
|
|
- return 1;
|
|
- }
|
|
- srand((unsigned)time(NULL) * getpid());
|
|
- randnum = rand() % range;
|
|
-
|
|
- return randnum;
|
|
-}
|
|
-
|
|
-void get_rand_data(u8 *addr, int size)
|
|
+void get_rand_data(u8 *addr, u32 size)
|
|
{
|
|
+ unsigned short rand_state[3] = {
|
|
+ (0xae >> 16) & 0xffff, 0xae & 0xffff, 0x330e};
|
|
int i;
|
|
|
|
- srand((unsigned)time(NULL) * getpid());
|
|
- for (i = 0; i < size; i++) {
|
|
- addr[i] = rand() % 0xFF;
|
|
- }
|
|
+#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
|
|
}
|
|
|
|
/*-------------------------------------main code------------------------------------------------------*/
|
|
@@ -320,7 +318,7 @@ static void parse_alg_param(struct acc_option *option)
|
|
case X25519_ALG:
|
|
snprintf(option->algclass, MAX_ALG_NAME, "%s", "x25519");
|
|
option->acctype = HPRE_TYPE;
|
|
- option->subtype = X22519_TYPE;
|
|
+ option->subtype = X25519_TYPE;
|
|
break;
|
|
case X448_ALG:
|
|
snprintf(option->algclass, MAX_ALG_NAME, "%s", "x448");
|
|
@@ -366,8 +364,8 @@ void cal_perfermance_data(struct acc_option *option, u32 sttime)
|
|
double perfermance;
|
|
double cpu_rate;
|
|
u32 ttime = 1000;
|
|
- u32 perfdata;
|
|
- u32 perfops;
|
|
+ double perfdata;
|
|
+ double perfops;
|
|
double ops;
|
|
u32 ptime;
|
|
int i, len;
|
|
@@ -397,13 +395,13 @@ void cal_perfermance_data(struct acc_option *option, u32 sttime)
|
|
palgname[i] = '\0';
|
|
|
|
ptime = ptime - sttime;
|
|
- perfdata = (g_recv_data.recv_cnt * option->pktlen) >> BYTES_TO_KB;
|
|
- perfops = (g_recv_data.recv_cnt) >> BYTES_TO_KB;
|
|
- perfermance = (double)perfdata / option->times;
|
|
- ops = (double)perfops / option->times;
|
|
+ perfdata = g_recv_data.pkg_len * g_recv_data.recv_cnt / 1024.0;
|
|
+ perfops = (double)(g_recv_data.recv_cnt) / 1000.0;
|
|
+ perfermance = perfdata / option->times;
|
|
+ ops = perfops / option->times;
|
|
cpu_rate = (double)ptime / option->times;
|
|
ACC_TST_PRT("algname: length: perf: iops: CPU_rate:\n"
|
|
- "%s %uBytes %.1fKB/s %.1fKops %.2f%%\n",
|
|
+ "%s %-2uBytes %.1fKB/s %.1fKops %.2f%%\n",
|
|
palgname, option->pktlen, perfermance, ops, cpu_rate);
|
|
}
|
|
|
|
@@ -419,11 +417,11 @@ static int benchmark_run(struct acc_option *option)
|
|
ret = sec_wd_benchmark(option);
|
|
}
|
|
usleep(20000);
|
|
- #ifdef WITH_OPENSSL_DIR
|
|
+#ifdef WITH_OPENSSL_DIR
|
|
if (option->modetype & SOFT_MODE) {
|
|
ret = sec_soft_benchmark(option);
|
|
}
|
|
- #endif
|
|
+#endif
|
|
break;
|
|
case HPRE_TYPE:
|
|
break;
|
|
@@ -447,6 +445,7 @@ static void dump_param(struct acc_option *option)
|
|
ACC_TST_PRT(" [--ctxnum]: %u\n", option->ctxnums);
|
|
ACC_TST_PRT(" [--algclass]:%s\n", option->algclass);
|
|
ACC_TST_PRT(" [--acctype]: %u\n", option->acctype);
|
|
+ ACC_TST_PRT(" [--prefetch]:%u\n", option->prefetch);
|
|
ACC_TST_PRT(" [--engine]: %s\n", option->engine);
|
|
}
|
|
|
|
@@ -457,6 +456,7 @@ 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);
|
|
|
|
@@ -558,13 +558,27 @@ static void print_help(void)
|
|
ACC_TST_PRT(" set the number of threads\n");
|
|
ACC_TST_PRT(" [--ctxnum]:\n");
|
|
ACC_TST_PRT(" the number of QP queues used by the entire test task\n");
|
|
+ ACC_TST_PRT(" [--prefetch]:\n");
|
|
+ ACC_TST_PRT(" in SVA mode, Enable prefetch can reduce page faults and improve performance\n");
|
|
ACC_TST_PRT(" [--engine]:\n");
|
|
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(" [--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:2021-7-28\n");
|
|
+ ACC_TST_PRT("UPDATE:2022-7-18\n");
|
|
+}
|
|
+
|
|
+static void print_support_alg(void)
|
|
+{
|
|
+ int i;
|
|
+
|
|
+ ACC_TST_PRT("UADK benchmark supported ALG:\n");
|
|
+ for (i = 0; i < ALG_MAX; i++) {
|
|
+ ACC_TST_PRT("%s\n", alg_options[i].name);
|
|
+ }
|
|
}
|
|
|
|
int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
|
@@ -583,8 +597,10 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
|
{"thread", required_argument, 0, 9},
|
|
{"multi", required_argument, 0, 10},
|
|
{"ctxnum", required_argument, 0, 11},
|
|
- {"engine", required_argument, 0, 12},
|
|
- {"help", no_argument, 0, 13},
|
|
+ {"prefetch", no_argument, 0, 12},
|
|
+ {"engine", required_argument, 0, 13},
|
|
+ {"alglist", no_argument, 0, 14},
|
|
+ {"help", no_argument, 0, 15},
|
|
{0, 0, 0, 0}
|
|
};
|
|
|
|
@@ -593,7 +609,6 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
|
if (c == -1)
|
|
break;
|
|
|
|
- // ACC_TST_PRT("index:%d , optarg name:%s\n", c, optarg);
|
|
switch (c) {
|
|
case 2:
|
|
option->algtype = get_alg_type(optarg);
|
|
@@ -627,26 +642,36 @@ int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
|
|
option->ctxnums = strtol(optarg, NULL, 0);
|
|
break;
|
|
case 12:
|
|
- strcpy(option->engine, optarg);
|
|
+ option->prefetch = 1;
|
|
break;
|
|
case 13:
|
|
- print_help();
|
|
+ strcpy(option->engine, optarg);
|
|
break;
|
|
+ case 14:
|
|
+ print_support_alg();
|
|
+ goto to_exit;
|
|
+ case 15:
|
|
+ print_help();
|
|
+ goto to_exit;
|
|
default:
|
|
ACC_TST_PRT("bad input test parameter!\n");
|
|
print_help();
|
|
- exit(-1);
|
|
+ goto to_exit;
|
|
}
|
|
}
|
|
+
|
|
return 0;
|
|
+
|
|
+to_exit:
|
|
+ return -EINVAL;
|
|
}
|
|
|
|
int acc_option_convert(struct acc_option *option)
|
|
{
|
|
- if (option->algtype >= ALG_MAX)
|
|
+ if (option->algtype >= ALG_MAX) {
|
|
+ ACC_TST_PRT("invalid: input algname is wrong!\n");
|
|
goto param_err;
|
|
- else if (option->algtype < 0)
|
|
- option->algtype = AES_128_CBC;
|
|
+ }
|
|
|
|
if (option->modetype >= INVALID_MODE)
|
|
goto param_err;
|
|
@@ -657,8 +682,8 @@ int acc_option_convert(struct acc_option *option)
|
|
/* Min test package size is 64Bytes */
|
|
if (option->pktlen > MAX_DATA_SIZE)
|
|
goto param_err;
|
|
- else if (option->pktlen < 64)
|
|
- option->pktlen = 64;
|
|
+ else if (option->pktlen < 16)
|
|
+ option->pktlen = 16;
|
|
|
|
if (option->times > MAX_TIME_SECONDS) {
|
|
ACC_TST_PRT("uadk benchmark max test times to 128 seconds\n");
|
|
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
|
|
index 2cb3dc0..a344fac 100644
|
|
--- a/uadk_tool/benchmark/uadk_benchmark.h
|
|
+++ b/uadk_tool/benchmark/uadk_benchmark.h
|
|
@@ -15,7 +15,6 @@
|
|
#include <signal.h>
|
|
#include <linux/random.h>
|
|
#include <sys/syscall.h>
|
|
-#include <sys/mman.h>
|
|
#include <sys/time.h>
|
|
|
|
#define ACC_TST_PRT printf
|
|
@@ -24,21 +23,30 @@
|
|
#define MAX_CTX_NUM 64
|
|
#define MAX_TIME_SECONDS 128
|
|
#define BYTES_TO_MB 20
|
|
-#define MAX_OPT_TYPE 5
|
|
+#define MAX_OPT_TYPE 6
|
|
#define MAX_DATA_SIZE (15 * 1024 * 1024)
|
|
#define MAX_ALG_NAME 64
|
|
#define ACC_QUEUE_SIZE 1024
|
|
|
|
+#define MAX_BLOCK_NM 16384 /* BLOCK_NUM must 4 times of POOL_LENTH */
|
|
+#define MAX_POOL_LENTH 4096
|
|
+#define MAX_TRY_CNT 5000
|
|
+#define SEND_USLEEP 100
|
|
+
|
|
typedef unsigned char u8;
|
|
typedef unsigned int u32;
|
|
typedef unsigned long long u64;
|
|
#define SCHED_SINGLE "sched_single"
|
|
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
/**
|
|
* struct acc_option - Define the test acc app option list.
|
|
* @algclass: 0:cipher 1:digest
|
|
* @acctype: The sub alg type, reference func get_cipher_resource.
|
|
* @syncmode: 0:sync mode 1:async mode
|
|
+ * @modetype: sva, no-sva, soft mode
|
|
+ * @optype: enc/dec, comp/decomp
|
|
+ * @prefetch: write allocated memory to prevent page faults
|
|
*/
|
|
struct acc_option {
|
|
char algname[64];
|
|
@@ -56,6 +64,7 @@ struct acc_option {
|
|
u32 subtype;
|
|
char engine[64];
|
|
u32 engine_flag;
|
|
+ u32 prefetch;
|
|
};
|
|
|
|
enum acc_type {
|
|
@@ -74,7 +83,7 @@ enum alg_type {
|
|
ECDH_TYPE,
|
|
ECDSA_TYPE,
|
|
SM2_TYPE,
|
|
- X22519_TYPE,
|
|
+ X25519_TYPE,
|
|
X448_TYPE,
|
|
};
|
|
|
|
@@ -164,9 +173,8 @@ extern void cal_perfermance_data(struct acc_option *option, u32 sttime);
|
|
extern void time_start(u32 seconds);
|
|
extern int get_run_state(void);
|
|
extern void set_run_state(int state);
|
|
-extern int get_rand_int(int range);
|
|
-extern void get_rand_data(u8 *addr, int size);
|
|
-extern void add_recv_data(u32 cnt);
|
|
+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);
|
|
|
|
--
|
|
2.27.0
|
|
|