libwd: backport for uadk from 2.3.27 to 2.3.28
Update some patch for uadk from mainline. To get more infomation, please visit the homepage: https://github.com/Linaro/uadk Signed-off-by: Yang Shen <shenyang39@huawei.com> (cherry picked from commit 12a3158ac70bbfa3d0c532b0c98cdeed60f7e375)
This commit is contained in:
parent
ad409cdb11
commit
ac54d6a1a7
43
0061-uadk-comp-optimize-for-spin-lock.patch
Normal file
43
0061-uadk-comp-optimize-for-spin-lock.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From 12afca7c245a7003c7d9e8e4445426794346940e Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Mon, 21 Feb 2022 20:09:51 +0800
|
||||
Subject: [PATCH 67/76] uadk: comp: optimize for spin lock
|
||||
|
||||
Printf should be outside of the lock region.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_comp.c | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/wd_comp.c b/wd_comp.c
|
||||
index 7868551..4a97f06 100644
|
||||
--- a/wd_comp.c
|
||||
+++ b/wd_comp.c
|
||||
@@ -718,15 +718,21 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||
|
||||
ret = wd_comp_setting.driver->comp_send(ctx->ctx, msg, priv);
|
||||
if (ret < 0) {
|
||||
+ pthread_spin_unlock(&ctx->lock);
|
||||
WD_ERR("wd comp send err(%d)!\n", ret);
|
||||
- wd_put_msg_to_pool(&wd_comp_setting.pool, idx, msg->tag);
|
||||
+ goto fail_with_msg;
|
||||
}
|
||||
|
||||
pthread_spin_unlock(&ctx->lock);
|
||||
|
||||
ret = wd_add_task_to_async_queue(&wd_comp_env_config, idx);
|
||||
if (ret)
|
||||
- wd_put_msg_to_pool(&wd_comp_setting.pool, idx, msg->tag);
|
||||
+ goto fail_with_msg;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+fail_with_msg:
|
||||
+ wd_put_msg_to_pool(&wd_comp_setting.pool, idx, msg->tag);
|
||||
|
||||
return ret;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
239
0062-hisi-comp-cleanup-for-duplication-code.patch
Normal file
239
0062-hisi-comp-cleanup-for-duplication-code.patch
Normal file
@ -0,0 +1,239 @@
|
||||
From e4758e80e2dc38ff018cd561636860121603b93f Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Wed, 16 Feb 2022 15:05:11 +0800
|
||||
Subject: [PATCH 68/76] hisi-comp: cleanup for duplication code
|
||||
|
||||
The algorithms zlib/gzip/deflate have same process. The only difference is
|
||||
the protocol. So move the generic logic into a function and the difference
|
||||
into the parameters.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
drv/hisi_comp.c | 161 ++++++++++++++----------------------------------
|
||||
1 file changed, 45 insertions(+), 116 deletions(-)
|
||||
|
||||
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
|
||||
index 5ea5dc3..0760908 100644
|
||||
--- a/drv/hisi_comp.c
|
||||
+++ b/drv/hisi_comp.c
|
||||
@@ -223,33 +223,9 @@ static void fill_buf_addr_deflate(struct hisi_zip_sqe *sqe, void *src,
|
||||
sqe->stream_ctx_addr_h = upper_32_bits(ctx_buf);
|
||||
}
|
||||
|
||||
-static int fill_buf_deflate(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
- struct wd_comp_msg *msg)
|
||||
-{
|
||||
- struct wd_comp_req *req = &msg->req;
|
||||
- __u32 out_size = msg->avail_out;
|
||||
- __u32 in_size = req->src_len;
|
||||
- void *ctx_buf;
|
||||
- int ret;
|
||||
-
|
||||
- ret = buf_size_check_deflate(&in_size, &out_size);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
-
|
||||
- fill_buf_size_deflate(sqe, in_size, out_size);
|
||||
-
|
||||
- if (msg->ctx_buf)
|
||||
- ctx_buf = msg->ctx_buf + RSV_OFFSET;
|
||||
- else
|
||||
- ctx_buf = NULL;
|
||||
-
|
||||
- fill_buf_addr_deflate(sqe, req->src, req->dst, ctx_buf);
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-static int fill_buf_zlib(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
- struct wd_comp_msg *msg)
|
||||
+static int fill_buf_deflate_generic(struct hisi_zip_sqe *sqe,
|
||||
+ struct wd_comp_msg *msg,
|
||||
+ const char *head, int head_size)
|
||||
{
|
||||
__u32 in_size = msg->req.src_len;
|
||||
__u32 out_size = msg->avail_out;
|
||||
@@ -258,14 +234,14 @@ static int fill_buf_zlib(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
void *ctx_buf = NULL;
|
||||
int ret;
|
||||
|
||||
- if (msg->stream_pos == WD_COMP_STREAM_NEW) {
|
||||
+ if (msg->stream_pos == WD_COMP_STREAM_NEW && head != NULL) {
|
||||
if (msg->req.op_type == WD_DIR_COMPRESS) {
|
||||
- memcpy(dst, ZLIB_HEADER, ZLIB_HEADER_SZ);
|
||||
- dst += ZLIB_HEADER_SZ;
|
||||
- out_size -= ZLIB_HEADER_SZ;
|
||||
+ memcpy(dst, head, head_size);
|
||||
+ dst += head_size;
|
||||
+ out_size -= head_size;
|
||||
} else {
|
||||
- src += ZLIB_HEADER_SZ;
|
||||
- in_size -= ZLIB_HEADER_SZ;
|
||||
+ src += head_size;
|
||||
+ in_size -= head_size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,39 +259,22 @@ static int fill_buf_zlib(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int fill_buf_gzip(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
- struct wd_comp_msg *msg)
|
||||
+static int fill_buf_deflate(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
+ struct wd_comp_msg *msg)
|
||||
{
|
||||
- __u32 in_size = msg->req.src_len;
|
||||
- __u32 out_size = msg->avail_out;
|
||||
- void *src = msg->req.src;
|
||||
- void *dst = msg->req.dst;
|
||||
- void *ctx_buf = NULL;
|
||||
- int ret;
|
||||
-
|
||||
- if (msg->stream_pos == WD_COMP_STREAM_NEW) {
|
||||
- if (msg->req.op_type == WD_DIR_COMPRESS) {
|
||||
- memcpy(dst, GZIP_HEADER, GZIP_HEADER_SZ);
|
||||
- dst += GZIP_HEADER_SZ;
|
||||
- out_size -= GZIP_HEADER_SZ;
|
||||
- } else {
|
||||
- src += GZIP_HEADER_SZ;
|
||||
- in_size -= GZIP_HEADER_SZ;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- ret = buf_size_check_deflate(&in_size, &out_size);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
-
|
||||
- fill_buf_size_deflate(sqe, in_size, out_size);
|
||||
-
|
||||
- if (msg->ctx_buf)
|
||||
- ctx_buf = msg->ctx_buf + RSV_OFFSET;
|
||||
+ return fill_buf_deflate_generic(sqe, msg, NULL, 0);
|
||||
+}
|
||||
|
||||
- fill_buf_addr_deflate(sqe, src, dst, ctx_buf);
|
||||
+static int fill_buf_zlib(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
+ struct wd_comp_msg *msg)
|
||||
+{
|
||||
+ return fill_buf_deflate_generic(sqe, msg, ZLIB_HEADER, ZLIB_HEADER_SZ);
|
||||
+}
|
||||
|
||||
- return 0;
|
||||
+static int fill_buf_gzip(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
+ struct wd_comp_msg *msg)
|
||||
+{
|
||||
+ return fill_buf_deflate_generic(sqe, msg, GZIP_HEADER, GZIP_HEADER_SZ);
|
||||
}
|
||||
|
||||
static void fill_buf_type_sgl(struct hisi_zip_sqe *sqe)
|
||||
@@ -358,23 +317,6 @@ static int fill_buf_addr_deflate_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int fill_buf_deflate_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
- struct wd_comp_msg *msg)
|
||||
-{
|
||||
- struct wd_comp_req *req = &msg->req;
|
||||
- int ret;
|
||||
-
|
||||
- fill_buf_type_sgl(sqe);
|
||||
-
|
||||
- ret = fill_buf_addr_deflate_sgl(h_qp, sqe, msg);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
-
|
||||
- fill_buf_size_deflate(sqe, req->src_len, msg->avail_out);
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
static void fill_buf_sgl_skip(struct hisi_zip_sqe *sqe, __u32 src_skip,
|
||||
__u32 dst_skip)
|
||||
{
|
||||
@@ -389,8 +331,9 @@ static void fill_buf_sgl_skip(struct hisi_zip_sqe *sqe, __u32 src_skip,
|
||||
sqe->dw8 = val;
|
||||
}
|
||||
|
||||
-static int fill_buf_zlib_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
- struct wd_comp_msg *msg)
|
||||
+static int fill_buf_deflate_slg_generic(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
+ struct wd_comp_msg *msg, const char *head,
|
||||
+ int head_size)
|
||||
{
|
||||
struct wd_comp_req *req = &msg->req;
|
||||
__u32 out_size = msg->avail_out;
|
||||
@@ -405,13 +348,13 @@ static int fill_buf_zlib_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- if (msg->req.op_type == WD_DIR_COMPRESS) {
|
||||
- memcpy(req->list_dst->data, ZLIB_HEADER, ZLIB_HEADER_SZ);
|
||||
- dst_skip = ZLIB_HEADER_SZ;
|
||||
- out_size -= ZLIB_HEADER_SZ;
|
||||
- } else {
|
||||
- src_skip = ZLIB_HEADER_SZ;
|
||||
- in_size -= ZLIB_HEADER_SZ;
|
||||
+ if (head != NULL && msg->req.op_type == WD_DIR_COMPRESS) {
|
||||
+ memcpy(req->list_dst->data, head, head_size);
|
||||
+ dst_skip = head_size;
|
||||
+ out_size -= head_size;
|
||||
+ } else if (head != NULL && msg->req.op_type == WD_DIR_DECOMPRESS) {
|
||||
+ src_skip = head_size;
|
||||
+ in_size -= head_size;
|
||||
}
|
||||
|
||||
fill_buf_sgl_skip(sqe, src_skip, dst_skip);
|
||||
@@ -421,36 +364,22 @@ static int fill_buf_zlib_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int fill_buf_gzip_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
- struct wd_comp_msg *msg)
|
||||
+static int fill_buf_deflate_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
+ struct wd_comp_msg *msg)
|
||||
{
|
||||
- struct wd_comp_req *req = &msg->req;
|
||||
- __u32 out_size = msg->avail_out;
|
||||
- __u32 in_size = req->src_len;
|
||||
- __u32 src_skip = 0;
|
||||
- __u32 dst_skip = 0;
|
||||
- int ret;
|
||||
-
|
||||
- fill_buf_type_sgl(sqe);
|
||||
-
|
||||
- ret = fill_buf_addr_deflate_sgl(h_qp, sqe, msg);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
-
|
||||
- if (msg->req.op_type == WD_DIR_COMPRESS) {
|
||||
- memcpy(req->list_dst->data, GZIP_HEADER, GZIP_HEADER_SZ);
|
||||
- dst_skip = GZIP_HEADER_SZ;
|
||||
- out_size -= GZIP_HEADER_SZ;
|
||||
- } else {
|
||||
- src_skip = GZIP_HEADER_SZ;
|
||||
- in_size -= GZIP_HEADER_SZ;
|
||||
- }
|
||||
-
|
||||
- fill_buf_sgl_skip(sqe, src_skip, dst_skip);
|
||||
+ return fill_buf_deflate_slg_generic(h_qp, sqe, msg, NULL, 0);
|
||||
+}
|
||||
|
||||
- fill_buf_size_deflate(sqe, in_size, out_size);
|
||||
+static int fill_buf_zlib_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
+ struct wd_comp_msg *msg)
|
||||
+{
|
||||
+ return fill_buf_deflate_slg_generic(h_qp, sqe, msg, ZLIB_HEADER, ZLIB_HEADER_SZ);
|
||||
+}
|
||||
|
||||
- return 0;
|
||||
+static int fill_buf_gzip_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||
+ struct wd_comp_msg *msg)
|
||||
+{
|
||||
+ return fill_buf_deflate_slg_generic(h_qp, sqe, msg, GZIP_HEADER, GZIP_HEADER_SZ);
|
||||
}
|
||||
|
||||
static void fill_buf_size_lz77_zstd(struct hisi_zip_sqe *sqe, __u32 in_size,
|
||||
--
|
||||
2.25.1
|
||||
|
||||
80
0063-wd_comp-remove-some-useless-printf.patch
Normal file
80
0063-wd_comp-remove-some-useless-printf.patch
Normal file
@ -0,0 +1,80 @@
|
||||
From fb0abcd7e3d0afdad015193e7e220b6597e0c606 Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Wed, 16 Feb 2022 15:05:12 +0800
|
||||
Subject: [PATCH 69/76] wd_comp: remove some useless printf
|
||||
|
||||
Due to the called function has print the error reason, the call function
|
||||
has no need to add printf.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
wd_comp.c | 20 +++++---------------
|
||||
1 file changed, 5 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/wd_comp.c b/wd_comp.c
|
||||
index 4a97f06..722666d 100644
|
||||
--- a/wd_comp.c
|
||||
+++ b/wd_comp.c
|
||||
@@ -459,10 +459,8 @@ int wd_do_comp_sync(handle_t h_sess, struct wd_comp_req *req)
|
||||
int ret;
|
||||
|
||||
ret = wd_comp_check_params(sess, req, CTX_MODE_SYNC);
|
||||
- if (ret) {
|
||||
- WD_ERR("fail to check params!\n");
|
||||
+ if (ret)
|
||||
return ret;
|
||||
- }
|
||||
|
||||
if (!req->src_len) {
|
||||
WD_ERR("invalid: req src_len is 0!\n");
|
||||
@@ -477,10 +475,8 @@ int wd_do_comp_sync(handle_t h_sess, struct wd_comp_req *req)
|
||||
msg.stream_mode = WD_COMP_STATELESS;
|
||||
|
||||
ret = wd_comp_sync_job(sess, req, &msg);
|
||||
- if (ret) {
|
||||
- WD_ERR("fail to check params!\n");
|
||||
+ if (ret)
|
||||
return ret;
|
||||
- }
|
||||
|
||||
req->src_len = msg.in_cons;
|
||||
req->dst_len = msg.produced;
|
||||
@@ -499,10 +495,8 @@ int wd_do_comp_sync2(handle_t h_sess, struct wd_comp_req *req)
|
||||
int ret;
|
||||
|
||||
ret = wd_comp_check_params(sess, req, CTX_MODE_SYNC);
|
||||
- if (ret) {
|
||||
- WD_ERR("fail to check params!\n");
|
||||
+ if (ret)
|
||||
return ret;
|
||||
- }
|
||||
|
||||
if (!req->src_len) {
|
||||
WD_ERR("invalid: req src_len is 0!\n");
|
||||
@@ -655,10 +649,8 @@ int wd_do_comp_strm(handle_t h_sess, struct wd_comp_req *req)
|
||||
src_len = req->src_len;
|
||||
|
||||
ret = wd_comp_sync_job(sess, req, &msg);
|
||||
- if (ret) {
|
||||
- WD_ERR("fail to check params!\n");
|
||||
+ if (ret)
|
||||
return ret;
|
||||
- }
|
||||
|
||||
req->src_len = msg.in_cons;
|
||||
req->dst_len = msg.produced;
|
||||
@@ -685,10 +677,8 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||
__u32 idx;
|
||||
|
||||
ret = wd_comp_check_params(sess, req, CTX_MODE_ASYNC);
|
||||
- if (ret) {
|
||||
- WD_ERR("fail to check params!\n");
|
||||
+ if (ret)
|
||||
return ret;
|
||||
- }
|
||||
|
||||
if (!req->src_len) {
|
||||
WD_ERR("invalid: req src_len is 0!\n");
|
||||
--
|
||||
2.25.1
|
||||
|
||||
639
0064-sample-add-a-demo-for-comp.patch
Normal file
639
0064-sample-add-a-demo-for-comp.patch
Normal file
@ -0,0 +1,639 @@
|
||||
From 471df047de19c8ec5a111e8c39a17f4240f6dead Mon Sep 17 00:00:00 2001
|
||||
From: Yang Shen <shenyang39@huawei.com>
|
||||
Date: Wed, 16 Feb 2022 15:05:13 +0800
|
||||
Subject: [PATCH 70/76] sample: add a demo for comp
|
||||
|
||||
Add the sample for uadk comp which is aimed to support test of
|
||||
compression/decompression and provide users with API reference.
|
||||
|
||||
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||
---
|
||||
sample/Makefile.am | 10 +-
|
||||
sample/uadk_comp.c | 505 +++++++++++++++++++++++++++++++++++++++++++
|
||||
sample/uadk_sample.c | 76 -------
|
||||
3 files changed, 510 insertions(+), 81 deletions(-)
|
||||
create mode 100644 sample/uadk_comp.c
|
||||
delete mode 100644 sample/uadk_sample.c
|
||||
|
||||
diff --git a/sample/Makefile.am b/sample/Makefile.am
|
||||
index 62ab902..eb8d71b 100644
|
||||
--- a/sample/Makefile.am
|
||||
+++ b/sample/Makefile.am
|
||||
@@ -1,16 +1,16 @@
|
||||
ACLOCAL_AMFLAGS = -I m4 -I./include
|
||||
AM_CFLAGS=-Wall -fno-strict-aliasing -I$(top_srcdir) -I$(top_srcdir)/include
|
||||
|
||||
-bin_PROGRAMS=uadk_sample
|
||||
+bin_PROGRAMS=uadk_comp
|
||||
|
||||
-uadk_sample_SOURCES=uadk_sample.c
|
||||
+uadk_comp_SOURCES=uadk_comp.c
|
||||
|
||||
if WD_STATIC_DRV
|
||||
AM_CFLAGS+=-Bstatic
|
||||
-uadk_sample_LDADD=../.libs/libwd.a \
|
||||
+uadk_comp_LDADD=../.libs/libwd.a \
|
||||
../.libs/libwd_comp.a \
|
||||
../.libs/libhisi_zip.a -lpthread -lnuma
|
||||
else
|
||||
-uadk_sample_LDADD=-L../.libs -l:libwd.so.2 -l:libwd_comp.so.2 -lpthread -lnuma
|
||||
+uadk_comp_LDADD=-L../.libs -l:libwd.so.2 -l:libwd_comp.so.2 -lpthread -lnuma
|
||||
endif
|
||||
-uadk_sample_LDFLAGS=-Wl,-rpath,'/usr/local/lib'
|
||||
+uadk_comp_LDFLAGS=-Wl,-rpath,'/usr/local/lib'
|
||||
diff --git a/sample/uadk_comp.c b/sample/uadk_comp.c
|
||||
new file mode 100644
|
||||
index 0000000..908c7bc
|
||||
--- /dev/null
|
||||
+++ b/sample/uadk_comp.c
|
||||
@@ -0,0 +1,505 @@
|
||||
+#include <stdlib.h>
|
||||
+#include <stdio.h>
|
||||
+#include <getopt.h>
|
||||
+#include <math.h>
|
||||
+#include <sys/stat.h>
|
||||
+
|
||||
+#include "wd_alg_common.h"
|
||||
+#include "wd_comp.h"
|
||||
+#include "wd_sched.h"
|
||||
+
|
||||
+#define SCHED_RR_NAME "sched_rr"
|
||||
+
|
||||
+#define CTX_SET_NUM 1
|
||||
+#define CTX_SET_SIZE 4
|
||||
+#define MAX_ALG_LEN 32
|
||||
+#define MAX_THREAD 1024
|
||||
+
|
||||
+#define no_argument 0
|
||||
+#define required_argument 1
|
||||
+#define optional_argument 2
|
||||
+
|
||||
+struct request_config {
|
||||
+ char algname[MAX_ALG_LEN];
|
||||
+ enum wd_comp_alg_type alg;
|
||||
+ enum wd_comp_level complv;
|
||||
+ enum wd_comp_op_type optype;
|
||||
+ enum wd_comp_winsz_type winsize;
|
||||
+ enum wd_ctx_mode request_mode;
|
||||
+ enum wd_buff_type buftype;
|
||||
+ struct wd_ctx_config ctx;
|
||||
+ struct wd_sched *sched;
|
||||
+ struct uacce_dev_list *list;
|
||||
+};
|
||||
+
|
||||
+struct request_data {
|
||||
+ handle_t h_sess;
|
||||
+ struct wd_comp_req req;
|
||||
+};
|
||||
+
|
||||
+struct acc_alg_item {
|
||||
+ char *name;
|
||||
+ int alg;
|
||||
+};
|
||||
+
|
||||
+static struct request_config config = {
|
||||
+ .complv = WD_COMP_L8,
|
||||
+ .optype = WD_DIR_COMPRESS,
|
||||
+ .winsize = WD_COMP_WS_8K,
|
||||
+ .request_mode = CTX_MODE_SYNC,
|
||||
+ .buftype = WD_FLAT_BUF,
|
||||
+};
|
||||
+
|
||||
+static struct request_data data;
|
||||
+
|
||||
+static struct acc_alg_item alg_options[] = {
|
||||
+ {"zlib", WD_ZLIB},
|
||||
+ {"gzip", WD_GZIP},
|
||||
+ {"deflate", WD_DEFLATE},
|
||||
+ {"lz77_zstd", WD_LZ77_ZSTD},
|
||||
+ {"", WD_COMP_ALG_MAX}
|
||||
+};
|
||||
+
|
||||
+static void cowfail(char *s)
|
||||
+{
|
||||
+ fprintf(stderr, ""
|
||||
+ "__________________________________\n\n"
|
||||
+ "%s"
|
||||
+ "\n----------------------------------\n"
|
||||
+ "\t \\ ^__^\n"
|
||||
+ "\t \\ (oo)\\_______\n"
|
||||
+ "\t (__)\\ )\\\\\n"
|
||||
+ "\t ||----w |\n"
|
||||
+ "\t || ||\n"
|
||||
+ "\n", s);
|
||||
+}
|
||||
+
|
||||
+static struct uacce_dev_list* get_dev_list(char *alg_name)
|
||||
+{
|
||||
+ struct uacce_dev_list *list, *p, *head = NULL, *prev = NULL;
|
||||
+ int ctx_set_num = CTX_SET_NUM;
|
||||
+ int max_ctx_num;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(alg_options); i++)
|
||||
+ if (!strcmp(alg_name, alg_options[i].name))
|
||||
+ config.alg = alg_options[i].alg;
|
||||
+
|
||||
+ list = wd_get_accel_list(alg_name);
|
||||
+ if (!list)
|
||||
+ return NULL;
|
||||
+
|
||||
+ p = list;
|
||||
+ /* Find one device matching the requested contexts. */
|
||||
+ while (p) {
|
||||
+ max_ctx_num = wd_get_avail_ctx(p->dev);
|
||||
+ /*
|
||||
+ * Check whether there's enough contexts.
|
||||
+ * There may be multiple taskes running together.
|
||||
+ * The number of multiple taskes is specified in children.
|
||||
+ */
|
||||
+ if (max_ctx_num < ctx_set_num * CTX_SET_SIZE) {
|
||||
+ if (!head)
|
||||
+ head = p;
|
||||
+ prev = p;
|
||||
+ p = p->next;
|
||||
+ } else
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (!p) {
|
||||
+ fprintf(stderr, "%s request too much contexts: %d.\n",
|
||||
+ __func__, ctx_set_num);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ /* Adjust p to the head of list if p is in the middle. */
|
||||
+ if (p && (p != list)) {
|
||||
+ prev->next = p->next;
|
||||
+ p->next = head;
|
||||
+ return p;
|
||||
+ }
|
||||
+
|
||||
+ return list;
|
||||
+
|
||||
+out:
|
||||
+ wd_free_list_accels(list);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static int lib_poll_func(__u32 pos, __u32 expect, __u32 *count)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = wd_comp_poll_ctx(pos, expect, count);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct wd_sched *uadk_comp_sched_init(void)
|
||||
+{
|
||||
+ int ctx_set_num = CTX_SET_NUM;
|
||||
+ struct sched_params param;
|
||||
+ struct wd_sched *sched;
|
||||
+ int i, j, ret;
|
||||
+
|
||||
+ sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 2, 2, lib_poll_func);
|
||||
+ if (!sched) {
|
||||
+ printf("%s fail to alloc sched.\n", __func__);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ sched->name = SCHED_RR_NAME;
|
||||
+
|
||||
+ /*
|
||||
+ * All contexts for 2 modes & 2 types.
|
||||
+ * The test only uses one kind of contexts at the same time.
|
||||
+ */
|
||||
+ for (i = 0; i < CTX_SET_SIZE; i++) {
|
||||
+ for (j = ctx_set_num * i; j < ctx_set_num * (i + 1); j++) {
|
||||
+ param.mode = i / 2;
|
||||
+ param.type = i % 2;
|
||||
+ param.numa_id = 0;
|
||||
+ param.begin = ctx_set_num * i;
|
||||
+ param.end = ctx_set_num * (i + 1) - 1;
|
||||
+ ret = wd_sched_rr_instance(sched, ¶m);
|
||||
+ if (ret < 0) {
|
||||
+ fprintf(stderr, "%s fail to fill sched region.\n",
|
||||
+ __func__);
|
||||
+ goto out_free_sched;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return sched;
|
||||
+
|
||||
+out_free_sched:
|
||||
+ wd_sched_rr_release(sched);
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static int uadk_comp_ctx_init(void)
|
||||
+{
|
||||
+ struct wd_ctx_config *ctx = &config.ctx;
|
||||
+ int ctx_set_num = CTX_SET_NUM;
|
||||
+ struct wd_sched *sched;
|
||||
+ int i, j, ret;
|
||||
+
|
||||
+ memset(ctx, 0, sizeof(struct wd_ctx_config));
|
||||
+ ctx->ctx_num = ctx_set_num * CTX_SET_SIZE;
|
||||
+ ctx->ctxs = calloc(ctx_set_num * CTX_SET_SIZE, sizeof(struct wd_ctx));
|
||||
+ if (!ctx->ctxs) {
|
||||
+ fprintf(stderr, "%s fail to allocate contexts.\n", __func__);
|
||||
+ return -WD_ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < CTX_SET_SIZE; i++) {
|
||||
+ for (j = ctx_set_num * i; j < ctx_set_num * (i + 1); j++) {
|
||||
+ ctx->ctxs[j].ctx = wd_request_ctx(config.list->dev);
|
||||
+ if (!ctx->ctxs[j].ctx) {
|
||||
+ fprintf(stderr, "%s fail to request context #%d.\n",
|
||||
+ __func__, i);
|
||||
+ ret = -WD_EINVAL;
|
||||
+ goto out_free_ctx;
|
||||
+ }
|
||||
+ ctx->ctxs[j].ctx_mode = i / 2;
|
||||
+ ctx->ctxs[j].op_type = i % 2;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ sched = uadk_comp_sched_init();
|
||||
+ if (!sched) {
|
||||
+ ret = -WD_EINVAL;
|
||||
+ goto out_free_ctx;
|
||||
+ }
|
||||
+
|
||||
+ config.sched = sched;
|
||||
+
|
||||
+ ret = wd_comp_init(ctx, sched);
|
||||
+ if (ret) {
|
||||
+ fprintf(stderr, "%s fail to init comp.\n", __func__);
|
||||
+ goto out_free_sched;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+out_free_sched:
|
||||
+ wd_sched_rr_release(sched);
|
||||
+
|
||||
+out_free_ctx:
|
||||
+ for (i = 0; i < ctx->ctx_num; i++)
|
||||
+ if (ctx->ctxs[i].ctx)
|
||||
+ wd_release_ctx(ctx->ctxs[i].ctx);
|
||||
+ free(ctx->ctxs);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void uadk_comp_ctx_uninit(void)
|
||||
+{
|
||||
+ struct wd_ctx_config *ctx = &config.ctx;
|
||||
+ int i;
|
||||
+
|
||||
+ wd_comp_uninit();
|
||||
+
|
||||
+ for (i = 0; i < ctx->ctx_num; i++)
|
||||
+ wd_release_ctx(ctx->ctxs[i].ctx);
|
||||
+
|
||||
+ wd_free_list_accels(config.list);
|
||||
+ wd_sched_rr_release(config.sched);
|
||||
+}
|
||||
+
|
||||
+static int uadk_comp_sess_init(void)
|
||||
+{
|
||||
+ struct wd_comp_sess_setup setup = {0};
|
||||
+ struct sched_params param = {0};
|
||||
+ handle_t h_sess;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ setup.alg_type = config.alg;
|
||||
+ setup.op_type = config.optype;
|
||||
+ setup.comp_lv = config.complv;
|
||||
+ setup.win_sz = config.winsize;
|
||||
+ param.type = config.optype;
|
||||
+ setup.sched_param = ¶m;
|
||||
+
|
||||
+ h_sess = wd_comp_alloc_sess(&setup);
|
||||
+ if (!h_sess) {
|
||||
+ fprintf(stderr, "%s fail to alloc comp sess.\n", __func__);
|
||||
+ ret = -WD_EINVAL;
|
||||
+ goto out_free_sess;
|
||||
+ }
|
||||
+ data.h_sess = h_sess;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+out_free_sess:
|
||||
+ wd_comp_free_sess(data.h_sess);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void uadk_comp_sess_uninit(void)
|
||||
+{
|
||||
+ wd_comp_free_sess(data.h_sess);
|
||||
+}
|
||||
+
|
||||
+static int uadk_req_buf_init(struct wd_comp_req *req, FILE *source)
|
||||
+{
|
||||
+ int src_len = req->src_len;
|
||||
+ int dst_len = req->dst_len;
|
||||
+ void *src, *dst;
|
||||
+ int ret;
|
||||
+
|
||||
+ src = malloc(src_len);
|
||||
+ if (!src) {
|
||||
+ fprintf(stderr, "%s fail to alloc src.\n", __func__);
|
||||
+ return -WD_ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ dst = malloc(dst_len);
|
||||
+ if (!dst) {
|
||||
+ fprintf(stderr, "%s fail to alloc dst.\n", __func__);
|
||||
+ ret = -WD_ENOMEM;
|
||||
+ goto out_free_src;
|
||||
+ }
|
||||
+
|
||||
+ ret = fread(src, 1, src_len, source);
|
||||
+ if (ret != src_len) {
|
||||
+ fprintf(stderr, "%s fail to read stdin.\n", __func__);
|
||||
+ ret = -WD_ENOMEM;
|
||||
+ goto out_free_dst;
|
||||
+ }
|
||||
+
|
||||
+ req->src = src;
|
||||
+ req->dst = dst;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+out_free_dst:
|
||||
+ free(dst);
|
||||
+
|
||||
+out_free_src:
|
||||
+ free(src);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void uadk_req_buf_uninit(void)
|
||||
+{
|
||||
+ free(data.req.src);
|
||||
+ free(data.req.dst);
|
||||
+}
|
||||
+
|
||||
+static int uadk_comp_request_init(FILE *source)
|
||||
+{
|
||||
+ struct wd_comp_req *req;
|
||||
+ struct stat fs;
|
||||
+ int fd, ret;
|
||||
+
|
||||
+ fd = fileno(source);
|
||||
+ ret = fstat(fd, &fs);
|
||||
+ if (ret < 0) {
|
||||
+ fprintf(stderr, "%s fstat error.\n", __func__);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ req = &data.req;
|
||||
+ req->op_type = config.optype;
|
||||
+ req->data_fmt = WD_FLAT_BUF;
|
||||
+ req->src_len = fs.st_size;
|
||||
+ req->dst_len = fs.st_size * 4;
|
||||
+
|
||||
+ return uadk_req_buf_init(req, source);
|
||||
+}
|
||||
+
|
||||
+static void uadk_comp_request_uninit(void)
|
||||
+{
|
||||
+ uadk_req_buf_uninit();
|
||||
+}
|
||||
+
|
||||
+static int uadk_do_comp(void)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = wd_do_comp_sync2(data.h_sess, &data.req);
|
||||
+ if (ret < 0)
|
||||
+ fprintf(stderr, "%s fail to do comp sync(ret = %d).\n", __func__, ret);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int uadk_comp_write_file(FILE *dest)
|
||||
+{
|
||||
+ int size;
|
||||
+
|
||||
+ size = fwrite(data.req.dst, 1, data.req.dst_len, dest);
|
||||
+ if (size < 0)
|
||||
+ return size;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int operation(FILE *source, FILE *dest)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = uadk_comp_ctx_init();
|
||||
+ if (ret) {
|
||||
+ fprintf(stderr, "%s fail to init ctx!\n", __func__);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = uadk_comp_sess_init();
|
||||
+ if (ret) {
|
||||
+ fprintf(stderr, "%s fail to init sess!\n", __func__);
|
||||
+ goto out_ctx_uninit;
|
||||
+ }
|
||||
+
|
||||
+ ret = uadk_comp_request_init(source);
|
||||
+ if (ret) {
|
||||
+ fprintf(stderr, "%s fail to init request!\n", __func__);
|
||||
+ goto out_sess_uninit;
|
||||
+ }
|
||||
+
|
||||
+ ret = uadk_do_comp();
|
||||
+ if (ret) {
|
||||
+ fprintf(stderr, "%s fail to do request!\n", __func__);
|
||||
+ goto out_sess_uninit;
|
||||
+ }
|
||||
+
|
||||
+ ret = uadk_comp_write_file(dest);
|
||||
+ if (ret)
|
||||
+ fprintf(stderr, "%s fail to write result!\n", __func__);
|
||||
+
|
||||
+ uadk_comp_request_uninit();
|
||||
+
|
||||
+out_sess_uninit:
|
||||
+ uadk_comp_sess_uninit();
|
||||
+
|
||||
+out_ctx_uninit:
|
||||
+ uadk_comp_ctx_uninit();
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void print_help(void)
|
||||
+{
|
||||
+ fprintf(stderr, ""
|
||||
+ "uadk_comp - a tool used to do compress/decompress\n\n"
|
||||
+ "Arguments:\n"
|
||||
+ "\t[--alg]: "
|
||||
+ "The name of the algorithm (can find under .../uacce/<dev>/algorithms)\n"
|
||||
+ "\t[--optype]: "
|
||||
+ "Use 0/1 stand for compression/decompression.\n"
|
||||
+ "\t[--winsize]: "
|
||||
+ "The window size for compression(8K as default).\n"
|
||||
+ "\t[--complv]: "
|
||||
+ "The compression level(8 as default).\n"
|
||||
+ "\t[--help] "
|
||||
+ "Print Help (this message) and exit\n"
|
||||
+ "");
|
||||
+}
|
||||
+
|
||||
+int main(int argc, char *argv[])
|
||||
+{
|
||||
+ int option_index = 0;
|
||||
+ int help = 0;
|
||||
+ int ret, c;
|
||||
+
|
||||
+ static struct option long_options[] = {
|
||||
+ {"help", no_argument, 0, 0},
|
||||
+ {"alg", required_argument, 0, 1},
|
||||
+ {"complv", required_argument, 0, 2},
|
||||
+ {"optype", required_argument, 0, 3},
|
||||
+ {"winsize", required_argument, 0, 4},
|
||||
+ {0, 0, 0, 0}
|
||||
+ };
|
||||
+
|
||||
+ while (!help) {
|
||||
+ c = getopt_long(argc, argv, "", long_options, &option_index);
|
||||
+ if (c == -1)
|
||||
+ break;
|
||||
+
|
||||
+ switch (c) {
|
||||
+ case 0:
|
||||
+ help = 1;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ config.list = get_dev_list(optarg);
|
||||
+ if (!config.list) {
|
||||
+ cowfail("Can't find your algorithm!\n");
|
||||
+ help = 1;
|
||||
+ } else {
|
||||
+ strcpy(config.algname, optarg);
|
||||
+ }
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ config.complv = strtol(optarg, NULL, 0);
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ config.optype = strtol(optarg, NULL, 0);
|
||||
+ break;
|
||||
+ case 4:
|
||||
+ config.winsize = strtol(optarg, NULL, 0);
|
||||
+ break;
|
||||
+ default:
|
||||
+ help = 1;
|
||||
+ cowfail("bad input test parameter!\n");
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (help) {
|
||||
+ print_help();
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+
|
||||
+ ret = operation(stdin, stdout);
|
||||
+ if (ret)
|
||||
+ cowfail("So sad for we do something wrong!\n");
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/sample/uadk_sample.c b/sample/uadk_sample.c
|
||||
deleted file mode 100644
|
||||
index 3ec2c47..0000000
|
||||
--- a/sample/uadk_sample.c
|
||||
+++ /dev/null
|
||||
@@ -1,76 +0,0 @@
|
||||
-#include "wd_comp.h"
|
||||
-
|
||||
-#define TEST_WORD_LEN 64
|
||||
-
|
||||
-int operation(int op_type, void *src, int src_sz, void *dst, int *dst_sz)
|
||||
-{
|
||||
- struct wd_comp_sess_setup setup = {0};
|
||||
- struct wd_comp_req req = {0};
|
||||
- handle_t h_dfl;
|
||||
- int ret;
|
||||
-
|
||||
- if (!src || !dst || !dst_sz || (*dst_sz <= 0))
|
||||
- return -EINVAL;
|
||||
- ret = wd_comp_env_init(NULL);
|
||||
- if (ret < 0)
|
||||
- goto out;
|
||||
-
|
||||
- setup.alg_type = WD_ZLIB;
|
||||
- setup.win_sz = WD_COMP_WS_32K;
|
||||
- setup.comp_lv = WD_COMP_L8;
|
||||
- setup.op_type = op_type;
|
||||
- h_dfl = wd_comp_alloc_sess(&setup);
|
||||
- if (!h_dfl) {
|
||||
- ret = -EINVAL;
|
||||
- goto out_sess;
|
||||
- }
|
||||
- req.src = src;
|
||||
- req.src_len = src_sz;
|
||||
- req.dst = dst;
|
||||
- req.dst_len = *dst_sz;
|
||||
- req.op_type = op_type;
|
||||
- req.data_fmt = WD_FLAT_BUF;
|
||||
- do {
|
||||
- ret = wd_do_comp_sync(h_dfl, &req);
|
||||
- } while (ret == -WD_EBUSY);
|
||||
- if (ret)
|
||||
- goto out_comp;
|
||||
- *dst_sz = req.dst_len;
|
||||
- wd_comp_free_sess(h_dfl);
|
||||
- wd_comp_env_uninit();
|
||||
- return 0;
|
||||
-out_comp:
|
||||
- wd_comp_free_sess(h_dfl);
|
||||
-out_sess:
|
||||
- wd_comp_env_uninit();
|
||||
-out:
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-int main(void)
|
||||
-{
|
||||
- char src[TEST_WORD_LEN] = {0}, dst[TEST_WORD_LEN] = {0};
|
||||
- char tmp[TEST_WORD_LEN] = {0};
|
||||
- int ret, src_sz, dst_sz, tmp_sz;
|
||||
-
|
||||
- strcpy(src, "go to test.");
|
||||
- src_sz = strlen(src);
|
||||
- dst_sz = tmp_sz = TEST_WORD_LEN;
|
||||
- ret = operation(WD_DIR_COMPRESS, src, src_sz, tmp, &tmp_sz);
|
||||
- if (ret < 0)
|
||||
- goto out;
|
||||
- ret = operation(WD_DIR_DECOMPRESS, tmp, tmp_sz, dst, &dst_sz);
|
||||
- if (ret < 0)
|
||||
- goto out;
|
||||
- if ((src_sz == dst_sz) && !strcmp(src, dst))
|
||||
- printf("Compression verified!\n");
|
||||
- else {
|
||||
- printf("Fail to verify the compression!\n");
|
||||
- ret = -EFAULT;
|
||||
- goto out;
|
||||
- }
|
||||
- return 0;
|
||||
-out:
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
--
|
||||
2.25.1
|
||||
|
||||
291
0065-uadk-tool-modify-uadk_benchmark-toos-code.patch
Normal file
291
0065-uadk-tool-modify-uadk_benchmark-toos-code.patch
Normal file
@ -0,0 +1,291 @@
|
||||
From 47705e97580314d97c6ad781b0252a80d8024fc1 Mon Sep 17 00:00:00 2001
|
||||
From: Liulongfang <liulongfang@foxmail.com>
|
||||
Date: Tue, 22 Feb 2022 11:47:02 +0800
|
||||
Subject: [PATCH 71/76] uadk/tool: modify uadk_benchmark toos code
|
||||
|
||||
1.bugfix some alg parameter
|
||||
2.add multi thread for async mode to poll BD
|
||||
|
||||
Signed-off-by: Liulongfang <liulongfang@foxmail.com>
|
||||
---
|
||||
uadk_tool/sec_uadk_benchmark.c | 55 +++++++++++++++++--------------
|
||||
uadk_tool/sec_wd_benchmark.c | 59 +++++++++++++++++++---------------
|
||||
uadk_tool/uadk_benchmark.c | 4 +--
|
||||
3 files changed, 66 insertions(+), 52 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/sec_uadk_benchmark.c b/uadk_tool/sec_uadk_benchmark.c
|
||||
index d68ac25..467e621 100644
|
||||
--- a/uadk_tool/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/sec_uadk_benchmark.c
|
||||
@@ -180,13 +180,13 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
break;
|
||||
case DES3_128_ECB:
|
||||
keysize = 16;
|
||||
- ivsize = 8;
|
||||
+ ivsize = 0;
|
||||
mode = WD_CIPHER_ECB;
|
||||
alg = WD_CIPHER_3DES;
|
||||
break;
|
||||
case DES3_192_ECB:
|
||||
keysize = 24;
|
||||
- ivsize = 8;
|
||||
+ ivsize = 0;
|
||||
mode = WD_CIPHER_ECB;
|
||||
alg = WD_CIPHER_3DES;
|
||||
break;
|
||||
@@ -204,7 +204,7 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
break;
|
||||
case SM4_128_ECB:
|
||||
keysize = 16;
|
||||
- ivsize = 16;
|
||||
+ ivsize = 0;
|
||||
mode = WD_CIPHER_ECB;
|
||||
alg = WD_CIPHER_SM4;
|
||||
break;
|
||||
@@ -233,7 +233,7 @@ static int sec_uadk_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
alg = WD_CIPHER_SM4;
|
||||
break;
|
||||
case SM4_128_XTS:
|
||||
- keysize = 16;
|
||||
+ keysize = 32;
|
||||
ivsize = 16;
|
||||
mode = WD_CIPHER_XTS;
|
||||
alg = WD_CIPHER_SM4;
|
||||
@@ -560,11 +560,14 @@ void *sec_uadk_poll(void *data)
|
||||
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 count = 0;
|
||||
u32 recv = 0;
|
||||
- u32 i = 0;
|
||||
- int ret;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (id > g_ctxnum)
|
||||
+ return NULL;
|
||||
|
||||
switch(pdata->subtype) {
|
||||
case CIPHER_TYPE:
|
||||
@@ -582,15 +585,13 @@ void *sec_uadk_poll(void *data)
|
||||
}
|
||||
|
||||
while (last_time) {
|
||||
- for (i = 0; i < g_ctx_cfg.ctx_num; i++) {
|
||||
- ret = uadk_poll_ctx(i, 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)) {
|
||||
- SEC_TST_PRT("poll ret: %u!\n", ret);
|
||||
- goto recv_error;
|
||||
- }
|
||||
+ 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)) {
|
||||
+ SEC_TST_PRT("poll ret: %u!\n", ret);
|
||||
+ goto recv_error;
|
||||
}
|
||||
|
||||
if (get_run_state() == 0)
|
||||
@@ -989,7 +990,7 @@ int sec_uadk_async_threads(struct acc_option *options)
|
||||
thread_data threads_args[THREADS_NUM];
|
||||
thread_data threads_option;
|
||||
pthread_t tdid[THREADS_NUM];
|
||||
- pthread_t pollid;
|
||||
+ pthread_t pollid[THREADS_NUM];
|
||||
int i, ret;
|
||||
|
||||
/* alg param parse and set to thread data */
|
||||
@@ -998,10 +999,14 @@ int sec_uadk_async_threads(struct acc_option *options)
|
||||
return ret;
|
||||
|
||||
/* poll thread */
|
||||
- ret = pthread_create(&pollid, NULL, sec_uadk_poll, &threads_option);
|
||||
- if (ret) {
|
||||
- SEC_TST_PRT("Create poll thread fail!\n");
|
||||
- goto async_error;
|
||||
+ for (i = 0; i < g_ctxnum; i++) {
|
||||
+ threads_args[i].subtype = threads_option.subtype;
|
||||
+ threads_args[i].td_id = i;
|
||||
+ ret = pthread_create(&pollid, NULL, sec_uadk_poll, &threads_args[i]);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Create poll thread fail!\n");
|
||||
+ goto async_error;
|
||||
+ }
|
||||
}
|
||||
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
@@ -1028,10 +1033,12 @@ int sec_uadk_async_threads(struct acc_option *options)
|
||||
}
|
||||
}
|
||||
|
||||
- ret = pthread_join(pollid, NULL);
|
||||
- if (ret) {
|
||||
- SEC_TST_PRT("Join poll thread fail!\n");
|
||||
- goto async_error;
|
||||
+ for (i = 0; i < g_ctxnum; i++) {
|
||||
+ ret = pthread_join(pollid[i], NULL);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Join poll thread fail!\n");
|
||||
+ goto async_error;
|
||||
+ }
|
||||
}
|
||||
|
||||
async_error:
|
||||
diff --git a/uadk_tool/sec_wd_benchmark.c b/uadk_tool/sec_wd_benchmark.c
|
||||
index dffd3a7..74b106e 100644
|
||||
--- a/uadk_tool/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/sec_wd_benchmark.c
|
||||
@@ -200,13 +200,13 @@ static int sec_wd_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
break;
|
||||
case DES3_128_ECB:
|
||||
keysize = 16;
|
||||
- ivsize = 8;
|
||||
+ ivsize = 0;
|
||||
mode = WCRYPTO_CIPHER_ECB;
|
||||
alg = WCRYPTO_CIPHER_3DES;
|
||||
break;
|
||||
case DES3_192_ECB:
|
||||
keysize = 24;
|
||||
- ivsize = 8;
|
||||
+ ivsize = 0;
|
||||
mode = WCRYPTO_CIPHER_ECB;
|
||||
alg = WCRYPTO_CIPHER_3DES;
|
||||
break;
|
||||
@@ -224,7 +224,7 @@ static int sec_wd_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
break;
|
||||
case SM4_128_ECB:
|
||||
keysize = 16;
|
||||
- ivsize = 16;
|
||||
+ ivsize = 0;
|
||||
mode = WCRYPTO_CIPHER_ECB;
|
||||
alg = WCRYPTO_CIPHER_SM4;
|
||||
break;
|
||||
@@ -253,7 +253,7 @@ static int sec_wd_param_parse(thread_data *tddata, struct acc_option *options)
|
||||
alg = WCRYPTO_CIPHER_SM4;
|
||||
break;
|
||||
case SM4_128_XTS:
|
||||
- keysize = 16;
|
||||
+ keysize = 32;
|
||||
ivsize = 16;
|
||||
mode = WCRYPTO_CIPHER_XTS;
|
||||
alg = WCRYPTO_CIPHER_SM4;
|
||||
@@ -525,9 +525,9 @@ void *sec_wd_poll(void *data)
|
||||
poll_ctx uadk_poll_ctx = NULL;
|
||||
u32 expt = ACC_QUEUE_SIZE * g_thread_num;
|
||||
u32 last_time = 2; /* poll need one more recv time */
|
||||
+ u32 id = pdata->td_id;
|
||||
u32 count = 0;
|
||||
u32 recv = 0;
|
||||
- u32 i = 0;
|
||||
|
||||
switch(pdata->subtype) {
|
||||
case CIPHER_TYPE:
|
||||
@@ -544,20 +544,21 @@ void *sec_wd_poll(void *data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ if (id > g_thread_num)
|
||||
+ return NULL;
|
||||
+
|
||||
while (last_time) {
|
||||
- for (i = 0; i < g_thread_num; i++) {
|
||||
- recv = uadk_poll_ctx(g_thread_queue.bd_res[i].queue, expt);
|
||||
- /*
|
||||
- * warpdrive async mode poll easy to 100% with small package.
|
||||
- * SEC_TST_PRT("warpdrive poll %d recv: %u!\n", i, recv);
|
||||
- */
|
||||
- if (unlikely(recv < 0)) {
|
||||
- SEC_TST_PRT("poll ret: %u!\n", recv);
|
||||
- goto recv_error;
|
||||
- }
|
||||
- count += recv;
|
||||
- recv = 0;
|
||||
+ recv = uadk_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);
|
||||
+ */
|
||||
+ if (unlikely(recv < 0)) {
|
||||
+ SEC_TST_PRT("poll ret: %u!\n", recv);
|
||||
+ goto recv_error;
|
||||
}
|
||||
+ count += recv;
|
||||
+ recv = 0;
|
||||
|
||||
if (get_run_state() == 0)
|
||||
last_time--;
|
||||
@@ -1186,7 +1187,7 @@ int sec_wd_async_threads(struct acc_option *options)
|
||||
thread_data threads_args[THREADS_NUM];
|
||||
thread_data threads_option;
|
||||
pthread_t tdid[THREADS_NUM];
|
||||
- pthread_t pollid;
|
||||
+ pthread_t pollid[THREADS_NUM];
|
||||
int i, ret;
|
||||
|
||||
/* alg param parse and set to thread data */
|
||||
@@ -1195,10 +1196,14 @@ int sec_wd_async_threads(struct acc_option *options)
|
||||
return ret;
|
||||
|
||||
/* poll thread */
|
||||
- ret = pthread_create(&pollid, NULL, sec_wd_poll, &threads_option);
|
||||
- if (ret) {
|
||||
- SEC_TST_PRT("Create poll thread fail!\n");
|
||||
- goto async_error;
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ threads_args[i].subtype = threads_option.subtype;
|
||||
+ threads_args[i].td_id = i;
|
||||
+ ret = pthread_create(&pollid[i], NULL, sec_wd_poll, &threads_args[i]);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Create poll thread fail!\n");
|
||||
+ goto async_error;
|
||||
+ }
|
||||
}
|
||||
|
||||
for (i = 0; i < g_thread_num; i++) {
|
||||
@@ -1225,10 +1230,12 @@ int sec_wd_async_threads(struct acc_option *options)
|
||||
}
|
||||
}
|
||||
|
||||
- ret = pthread_join(pollid, NULL);
|
||||
- if (ret) {
|
||||
- SEC_TST_PRT("Join poll thread fail!\n");
|
||||
- goto async_error;
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ ret = pthread_join(pollid[i], NULL);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Join poll thread fail!\n");
|
||||
+ goto async_error;
|
||||
+ }
|
||||
}
|
||||
|
||||
async_error:
|
||||
diff --git a/uadk_tool/uadk_benchmark.c b/uadk_tool/uadk_benchmark.c
|
||||
index 0d7fc71..8c3c96f 100644
|
||||
--- a/uadk_tool/uadk_benchmark.c
|
||||
+++ b/uadk_tool/uadk_benchmark.c
|
||||
@@ -271,7 +271,7 @@ int get_rand_int(int range)
|
||||
ACC_TST_PRT("rand range error!\n");
|
||||
return 1;
|
||||
}
|
||||
- srand((unsigned) time(NULL) * getpid());
|
||||
+ srand((unsigned)time(NULL) * getpid());
|
||||
randnum = rand() % range;
|
||||
|
||||
return randnum;
|
||||
@@ -281,7 +281,7 @@ void get_rand_data(u8 *addr, int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
- srand((unsigned) time(NULL) * getpid());
|
||||
+ srand((unsigned)time(NULL) * getpid());
|
||||
for (i = 0; i < size; i++) {
|
||||
addr[i] = rand() % 0xFF;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
28
0066-uadk-tools-modify-uadk-benchmark-clean-code.patch
Normal file
28
0066-uadk-tools-modify-uadk-benchmark-clean-code.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From a1f58e62ddb6419f50bfb3ae743d6db39533a42c Mon Sep 17 00:00:00 2001
|
||||
From: Liulongfang <liulongfang@foxmail.com>
|
||||
Date: Wed, 23 Feb 2022 10:36:09 +0800
|
||||
Subject: [PATCH 72/76] uadk/tools: modify uadk benchmark clean code
|
||||
|
||||
modify uadk benchmark thread create warning
|
||||
|
||||
Signed-off-by: Liulongfang <liulongfang@foxmail.com>
|
||||
---
|
||||
uadk_tool/sec_uadk_benchmark.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/uadk_tool/sec_uadk_benchmark.c b/uadk_tool/sec_uadk_benchmark.c
|
||||
index 467e621..6eeee12 100644
|
||||
--- a/uadk_tool/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/sec_uadk_benchmark.c
|
||||
@@ -1002,7 +1002,7 @@ int sec_uadk_async_threads(struct acc_option *options)
|
||||
for (i = 0; i < g_ctxnum; i++) {
|
||||
threads_args[i].subtype = threads_option.subtype;
|
||||
threads_args[i].td_id = i;
|
||||
- ret = pthread_create(&pollid, NULL, sec_uadk_poll, &threads_args[i]);
|
||||
+ 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;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
55
0067-uadk-v1-fix-for-cookie-initialization.patch
Normal file
55
0067-uadk-v1-fix-for-cookie-initialization.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From 4b10036f1504396fd61fac2ada45c8bc84cfd77e Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 24 Feb 2022 11:22:26 +0800
|
||||
Subject: [PATCH 73/76] uadk: v1: fix for cookie initialization
|
||||
|
||||
If ctx message number is too big, it takes a lot of time
|
||||
to initialize each cookies and drag performance, so this
|
||||
patch reduce it from 1024 to 64.
|
||||
We also found calloc in wd_init_cookie_pool use to much cpu
|
||||
when it does memset zero, which is not unnecessary, so
|
||||
replace it with malloc is better.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
v1/wd_util.c | 7 ++++---
|
||||
v1/wd_util.h | 2 +-
|
||||
2 files changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/v1/wd_util.c b/v1/wd_util.c
|
||||
index 616bf69..715804c 100644
|
||||
--- a/v1/wd_util.c
|
||||
+++ b/v1/wd_util.c
|
||||
@@ -85,12 +85,13 @@ void wd_free_id(__u8 *buf, __u32 size, __u32 id, __u32 id_max)
|
||||
int wd_init_cookie_pool(struct wd_cookie_pool *pool,
|
||||
__u32 cookies_size, __u32 cookies_num)
|
||||
{
|
||||
- pool->cookies = calloc(1, cookies_size * cookies_num + cookies_num);
|
||||
+ __u64 total_size = cookies_size * cookies_num;
|
||||
+
|
||||
+ pool->cookies = malloc(total_size + cookies_num);
|
||||
if (!pool->cookies)
|
||||
return -WD_ENOMEM;
|
||||
|
||||
- pool->cstatus = (void *)((uintptr_t)pool->cookies +
|
||||
- cookies_num * cookies_size);
|
||||
+ pool->cstatus = (void *)((uintptr_t)pool->cookies + total_size);
|
||||
pool->cookies_num = cookies_num;
|
||||
pool->cookies_size = cookies_size;
|
||||
pool->cid = 0;
|
||||
diff --git a/v1/wd_util.h b/v1/wd_util.h
|
||||
index 1ac157e..78b91ee 100644
|
||||
--- a/v1/wd_util.h
|
||||
+++ b/v1/wd_util.h
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "v1/wd_ecc.h"
|
||||
#include "v1/wd_adapter.h"
|
||||
|
||||
-#define WD_CTX_MSG_NUM 1024
|
||||
+#define WD_CTX_MSG_NUM 64
|
||||
#define WD_HPRE_CTX_MSG_NUM 64
|
||||
#define WD_RNG_CTX_MSG_NUM 256
|
||||
#define WD_MAX_CTX_NUM 256
|
||||
--
|
||||
2.25.1
|
||||
|
||||
19
0068-uadk-update-file-permission-on-cleanup.patch
Normal file
19
0068-uadk-update-file-permission-on-cleanup.patch
Normal file
@ -0,0 +1,19 @@
|
||||
From f9f3fc6a1de8e20680ef4c5c0efd98c7d503b87b Mon Sep 17 00:00:00 2001
|
||||
From: Haojian Zhuang <haojian.zhuang@linaro.org>
|
||||
Date: Wed, 23 Feb 2022 15:36:10 +0800
|
||||
Subject: [PATCH 74/76] uadk: update file permission on cleanup
|
||||
|
||||
Set execution permission on cleanup.sh.
|
||||
|
||||
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
|
||||
---
|
||||
cleanup.sh | 0
|
||||
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||
mode change 100644 => 100755 cleanup.sh
|
||||
|
||||
diff --git a/cleanup.sh b/cleanup.sh
|
||||
old mode 100644
|
||||
new mode 100755
|
||||
--
|
||||
2.25.1
|
||||
|
||||
58
0069-uadk_tool-fix-build-warning-of-sec_wd_benchmark.patch
Normal file
58
0069-uadk_tool-fix-build-warning-of-sec_wd_benchmark.patch
Normal file
@ -0,0 +1,58 @@
|
||||
From 42a496b15f685a8b3d763fe779cea17346e2116d Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Wed, 23 Feb 2022 06:39:14 +0000
|
||||
Subject: [PATCH 75/76] uadk_tool: fix build warning of sec_wd_benchmark
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Fix build warning:
|
||||
In file included from sec_wd_benchmark.c:3:
|
||||
uadk_benchmark.h:168:31: note: expected ‘u8 *’ {aka ‘unsigned char *’} but argument is of type ‘char *’
|
||||
168 | extern void get_rand_data(u8 *addr, int size);
|
||||
| ~~~~^~~~
|
||||
|
||||
sec_wd_benchmark.c: In function ‘sec_wd_async_run’:
|
||||
sec_wd_benchmark.c:613:16: warning: pointer targets in passing argument 1 of ‘get_rand_data’ differ in signedness [-Wpointer-sign]
|
||||
613 | get_rand_data(src_data_buf, g_pktlen);
|
||||
| ^~~~~~~~~~~~
|
||||
| |
|
||||
| char *
|
||||
|
||||
sec_wd_benchmark.c: In function ‘sec_wd_sync_run’:
|
||||
sec_wd_benchmark.c:913:16: warning: pointer targets in passing argument 1 of ‘get_rand_data’ differ in signedness [-Wpointer-sign]
|
||||
913 | get_rand_data(src_data_buf, g_pktlen);
|
||||
| ^~~~~~~~~~~~
|
||||
| |
|
||||
| char *
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
uadk_tool/sec_wd_benchmark.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/uadk_tool/sec_wd_benchmark.c b/uadk_tool/sec_wd_benchmark.c
|
||||
index 74b106e..2e9c55d 100644
|
||||
--- a/uadk_tool/sec_wd_benchmark.c
|
||||
+++ b/uadk_tool/sec_wd_benchmark.c
|
||||
@@ -610,7 +610,7 @@ static void *sec_wd_async_run(void *arg)
|
||||
if (!src_data_buf)
|
||||
return NULL;
|
||||
|
||||
- get_rand_data(src_data_buf, g_pktlen);
|
||||
+ 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);
|
||||
@@ -910,7 +910,7 @@ static void *sec_wd_sync_run(void *arg)
|
||||
if (!src_data_buf)
|
||||
return NULL;
|
||||
|
||||
- get_rand_data(src_data_buf, g_pktlen);
|
||||
+ 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);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Name: libwd
|
||||
Summary: User Space Accelerator Development Kit
|
||||
Version: 2.3.21
|
||||
Release: 3
|
||||
Release: 4
|
||||
License: Apache-2.0
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
Vendor: Huawei Corporation
|
||||
@ -74,6 +74,15 @@ Patch0057: 0057-uadk-optimize-wd_sched_rr_instance.patch
|
||||
Patch0058: 0058-uadk-optimize-wd_get_accel_list.patch
|
||||
Patch0059: 0059-uadk-fix-staic-check-warning.patch
|
||||
Patch0060: 0060-uadk-v1-fix-the-waiting-time-for-receiving-task.patch
|
||||
Patch0061: 0061-uadk-comp-optimize-for-spin-lock.patch
|
||||
Patch0062: 0062-hisi-comp-cleanup-for-duplication-code.patch
|
||||
Patch0063: 0063-wd_comp-remove-some-useless-printf.patch
|
||||
Patch0064: 0064-sample-add-a-demo-for-comp.patch
|
||||
Patch0065: 0065-uadk-tool-modify-uadk_benchmark-toos-code.patch
|
||||
Patch0066: 0066-uadk-tools-modify-uadk-benchmark-clean-code.patch
|
||||
Patch0067: 0067-uadk-v1-fix-for-cookie-initialization.patch
|
||||
Patch0068: 0068-uadk-update-file-permission-on-cleanup.patch
|
||||
Patch0069: 0069-uadk_tool-fix-build-warning-of-sec_wd_benchmark.patch
|
||||
|
||||
%description
|
||||
This package contains the User Space Accelerator Library
|
||||
@ -231,6 +240,9 @@ fi
|
||||
/sbin/ldconfig
|
||||
|
||||
%changelog
|
||||
* Tue Mar 1 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-4
|
||||
- libwd: backport the patch of uadk from 2.3.27 to 2.3.28
|
||||
|
||||
* Mon Feb 21 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-3
|
||||
- libwd: backport the patch of uadk from 2.3.24 to 2.3.27
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user