libwd: backport for uadk from 2.3.21 to 2.3.24
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 bd84f97fbf6b05318e0f025ed8341a7f4815c405)
This commit is contained in:
parent
dfef3b26dd
commit
6bfcc709d5
213
0001-uadk-digest-add-stream-mode-for-digest-sync.patch
Normal file
213
0001-uadk-digest-add-stream-mode-for-digest-sync.patch
Normal file
@ -0,0 +1,213 @@
|
||||
From c1e75c6c27ea54dec9e31223af49e33aa0d38490 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Mon, 13 Dec 2021 18:55:32 +0800
|
||||
Subject: [PATCH 01/28] uadk/digest - add stream mode for digest sync
|
||||
|
||||
Support the sec digest steam mode. Using the session to store
|
||||
the stream BD state, using the iv_bytes to notify the BD state
|
||||
from message. So one session only supports one stream. User
|
||||
can use the has_next flag to indicate whether there is any
|
||||
packet to be input.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
drv/hisi_sec.c | 50 ++++++++++++++++++++-----------------
|
||||
include/drv/wd_digest_drv.h | 2 ++
|
||||
wd_digest.c | 20 ++++++++++++---
|
||||
3 files changed, 46 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
|
||||
index e43ded2..2fd23f3 100644
|
||||
--- a/drv/hisi_sec.c
|
||||
+++ b/drv/hisi_sec.c
|
||||
@@ -73,6 +73,8 @@
|
||||
/* The max BD data length is 16M-512B */
|
||||
#define MAX_INPUT_DATA_LEN 0xFFFE00
|
||||
#define MAX_CCM_AAD_LEN 65279
|
||||
+#define SHA1_ALIGN_SZ 64
|
||||
+#define SHA512_ALIGN_SZ 128
|
||||
|
||||
#define AUTHPAD_OFFSET 2
|
||||
#define AUTHTYPE_OFFSET 6
|
||||
@@ -1229,31 +1231,24 @@ static int fill_digest_bd2_alg(struct wd_digest_msg *msg,
|
||||
static void qm_fill_digest_long_bd(struct wd_digest_msg *msg,
|
||||
struct hisi_sec_sqe *sqe)
|
||||
{
|
||||
- struct wd_digest_tag *digest_tag = (void *)(uintptr_t)msg->usr_data;
|
||||
__u64 total_bits;
|
||||
|
||||
if (msg->has_next && (msg->iv_bytes == 0)) {
|
||||
/* LONG BD FIRST */
|
||||
sqe->ai_apd_cs = AI_GEN_INNER;
|
||||
sqe->ai_apd_cs |= AUTHPAD_NOPAD << AUTHPAD_OFFSET;
|
||||
- msg->iv_bytes = msg->out_bytes;
|
||||
} else if (msg->has_next && (msg->iv_bytes != 0)) {
|
||||
/* LONG BD MIDDLE */
|
||||
sqe->ai_apd_cs = AI_GEN_IVIN_ADDR;
|
||||
sqe->ai_apd_cs |= AUTHPAD_NOPAD << AUTHPAD_OFFSET;
|
||||
sqe->type2.a_ivin_addr = sqe->type2.mac_addr;
|
||||
- msg->iv_bytes = msg->out_bytes;
|
||||
} else if (!msg->has_next && (msg->iv_bytes != 0)) {
|
||||
/* LONG BD END */
|
||||
sqe->ai_apd_cs = AI_GEN_IVIN_ADDR;
|
||||
sqe->ai_apd_cs |= AUTHPAD_PAD << AUTHPAD_OFFSET;
|
||||
sqe->type2.a_ivin_addr = sqe->type2.mac_addr;
|
||||
- total_bits = digest_tag->long_data_len * BYTE_BITS;
|
||||
+ total_bits = msg->long_data_len * BYTE_BITS;
|
||||
sqe->type2.long_a_data_len = total_bits;
|
||||
- msg->iv_bytes = 0;
|
||||
- } else {
|
||||
- /* SHORT BD */
|
||||
- msg->iv_bytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1282,21 +1277,37 @@ static void parse_digest_bd2(struct hisi_sec_sqe *sqe, struct wd_digest_msg *rec
|
||||
#endif
|
||||
}
|
||||
|
||||
-static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type)
|
||||
+static int digest_long_bd_check(struct wd_digest_msg *msg)
|
||||
{
|
||||
- if (type == BD_TYPE2 && msg->in_bytes == 0) {
|
||||
- WD_ERR("digest bd2 not supports 0 packet!\n");
|
||||
+ if (msg->alg >= WD_DIGEST_SHA512 && msg->in_bytes % SHA512_ALIGN_SZ)
|
||||
+ return -WD_EINVAL;
|
||||
+ else if (msg->in_bytes % SHA1_ALIGN_SZ)
|
||||
+ return -WD_EINVAL;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ /* End BD not need to check the input zero bytes */
|
||||
+ if (unlikely(type == BD_TYPE2 && (!msg->has_next && msg->in_bytes == 0))) {
|
||||
+ WD_ERR("kunpeng 920, digest mode not support 0 size!\n");
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
|
||||
if (unlikely(msg->in_bytes > MAX_INPUT_DATA_LEN)) {
|
||||
- WD_ERR("failed to check digest input data length!\n");
|
||||
+ WD_ERR("input data length is too long, size:%u!\n", msg->in_bytes);
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
|
||||
- if (unlikely(msg->out_bytes & WORD_ALIGNMENT_MASK)) {
|
||||
- WD_ERR("failed to check digest out length!\n");
|
||||
- return -WD_EINVAL;
|
||||
+ if (msg->has_next) {
|
||||
+ ret = digest_long_bd_check(msg);
|
||||
+ if (ret) {
|
||||
+ WD_ERR("input data isn't aligned, size:%u!\n", msg->in_bytes);
|
||||
+ return -WD_EINVAL;
|
||||
+ }
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1435,31 +1446,24 @@ static int fill_digest_bd3_alg(struct wd_digest_msg *msg,
|
||||
static void qm_fill_digest_long_bd3(struct wd_digest_msg *msg,
|
||||
struct hisi_sec_sqe3 *sqe)
|
||||
{
|
||||
- struct wd_digest_tag *digest_tag = (void *)(uintptr_t)msg->usr_data;
|
||||
__u64 total_bits;
|
||||
|
||||
if (msg->has_next && (msg->iv_bytes == 0)) {
|
||||
/* LONG BD FIRST */
|
||||
sqe->auth_mac_key |= AI_GEN_INNER << SEC_AI_GEN_OFFSET_V3;
|
||||
sqe->stream_scene.stream_auth_pad = AUTHPAD_NOPAD;
|
||||
- msg->iv_bytes = msg->out_bytes;
|
||||
} else if (msg->has_next && (msg->iv_bytes != 0)) {
|
||||
/* LONG BD MIDDLE */
|
||||
sqe->auth_mac_key |= AI_GEN_IVIN_ADDR << SEC_AI_GEN_OFFSET_V3;
|
||||
sqe->stream_scene.stream_auth_pad = AUTHPAD_NOPAD;
|
||||
sqe->auth_ivin.a_ivin_addr = sqe->mac_addr;
|
||||
- msg->iv_bytes = msg->out_bytes;
|
||||
} else if (!msg->has_next && (msg->iv_bytes != 0)) {
|
||||
/* LONG BD END */
|
||||
sqe->auth_mac_key |= AI_GEN_IVIN_ADDR << SEC_AI_GEN_OFFSET_V3;
|
||||
sqe->stream_scene.stream_auth_pad = AUTHPAD_PAD;
|
||||
sqe->auth_ivin.a_ivin_addr = sqe->mac_addr;
|
||||
- total_bits = digest_tag->long_data_len * BYTE_BITS;
|
||||
+ total_bits = msg->long_data_len * BYTE_BITS;
|
||||
sqe->stream_scene.long_a_data_len = total_bits;
|
||||
- msg->iv_bytes = 0;
|
||||
- } else {
|
||||
- /* SHORT BD */
|
||||
- msg->iv_bytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/include/drv/wd_digest_drv.h b/include/drv/wd_digest_drv.h
|
||||
index 8ccf291..ac3b028 100644
|
||||
--- a/include/drv/wd_digest_drv.h
|
||||
+++ b/include/drv/wd_digest_drv.h
|
||||
@@ -45,6 +45,8 @@ struct wd_digest_msg {
|
||||
__u8 *in;
|
||||
/* output data pointer */
|
||||
__u8 *out;
|
||||
+ /* total of data for stream mode */
|
||||
+ __u64 long_data_len;
|
||||
};
|
||||
|
||||
struct wd_digest_driver {
|
||||
diff --git a/wd_digest.c b/wd_digest.c
|
||||
index 22aa98e..c110f7b 100644
|
||||
--- a/wd_digest.c
|
||||
+++ b/wd_digest.c
|
||||
@@ -46,6 +46,10 @@ struct wd_digest_sess {
|
||||
unsigned char key[MAX_HMAC_KEY_SIZE];
|
||||
__u32 key_bytes;
|
||||
void *sched_key;
|
||||
+ /* Notify the BD state */
|
||||
+ int state;
|
||||
+ /* Total of data for stream mode */
|
||||
+ __u64 long_data_len;
|
||||
};
|
||||
|
||||
struct wd_env_config wd_digest_env_config;
|
||||
@@ -286,11 +290,19 @@ static void fill_request_msg(struct wd_digest_msg *msg,
|
||||
msg->in_bytes = req->in_bytes;
|
||||
msg->out = req->out;
|
||||
msg->out_bytes = req->out_bytes;
|
||||
- msg->has_next = req->has_next;
|
||||
msg->data_fmt = req->data_fmt;
|
||||
+ msg->has_next = req->has_next;
|
||||
+ sess->long_data_len += req->in_bytes;
|
||||
+ msg->long_data_len = sess->long_data_len;
|
||||
+ /* To store the stream bd state */
|
||||
+ msg->iv_bytes = sess->state;
|
||||
+ if (req->has_next == 0) {
|
||||
+ sess->long_data_len = 0;
|
||||
+ sess->state = 0;
|
||||
+ }
|
||||
}
|
||||
|
||||
-static int send_recv_sync(struct wd_ctx_internal *ctx,
|
||||
+static int send_recv_sync(struct wd_ctx_internal *ctx, struct wd_digest_sess *dsess,
|
||||
struct wd_digest_msg *msg)
|
||||
{
|
||||
__u64 recv_cnt = 0;
|
||||
@@ -320,6 +332,8 @@ static int send_recv_sync(struct wd_ctx_internal *ctx,
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
+ if (msg->has_next)
|
||||
+ dsess->state = msg->out_bytes;
|
||||
} while (ret < 0);
|
||||
|
||||
out:
|
||||
@@ -353,7 +367,7 @@ int wd_do_digest_sync(handle_t h_sess, struct wd_digest_req *req)
|
||||
return ret;
|
||||
|
||||
ctx = config->ctxs + idx;
|
||||
- ret = send_recv_sync(ctx, &msg);
|
||||
+ ret = send_recv_sync(ctx, dsess, &msg);
|
||||
req->state = msg.result;
|
||||
|
||||
return ret;
|
||||
--
|
||||
2.31.1
|
||||
|
||||
508
0002-test-digest-support-the-digest-stream-mode.patch
Normal file
508
0002-test-digest-support-the-digest-stream-mode.patch
Normal file
@ -0,0 +1,508 @@
|
||||
From 08d633649d4a3c557bf042241e3953c3dd5cf586 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Thu, 9 Sep 2021 19:18:05 +0800
|
||||
Subject: [PATCH 02/28] test/digest: support the digest stream mode
|
||||
|
||||
Test the digest stream mode by compare to no stream mode.
|
||||
Tools supports the multiple thread testing.
|
||||
|
||||
For example:
|
||||
test_hisi_sec --digest 0 --sync --optype 3 --pktlen 1024 \
|
||||
--keylen 16 --times 1 --multi 2
|
||||
more details:
|
||||
test_hisi_sec --help
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
test/hisi_sec_test/test_hisi_sec.c | 370 ++++++++++++++++++++++++++++-
|
||||
test/hisi_sec_test/test_hisi_sec.h | 4 +-
|
||||
2 files changed, 360 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/test/hisi_sec_test/test_hisi_sec.c b/test/hisi_sec_test/test_hisi_sec.c
|
||||
index a2dba05..e1521f6 100644
|
||||
--- a/test/hisi_sec_test/test_hisi_sec.c
|
||||
+++ b/test/hisi_sec_test/test_hisi_sec.c
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
+#include <stdbool.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
#include <getopt.h>
|
||||
@@ -53,6 +54,8 @@ static unsigned int g_data_fmt = WD_FLAT_BUF;
|
||||
static unsigned int g_sgl_num = 0;
|
||||
static pthread_spinlock_t lock = 0;
|
||||
|
||||
+static struct hash_testvec g_long_hash_tv;
|
||||
+
|
||||
char *skcipher_names[MAX_ALGO_PER_TYPE] =
|
||||
{"ecb(aes)", "cbc(aes)", "xts(aes)", "ofb(aes)", "cfb(aes)", "ecb(des3_ede)",
|
||||
"cbc(des3_ede)", "cbc(sm4)", "xts(sm4)", "ofb(sm4)", "cfb(sm4)", "ecb(sm4)", NULL,};
|
||||
@@ -1509,7 +1512,7 @@ int get_digest_resource(struct hash_testvec **alg_tv, int* alg, int* mode)
|
||||
}
|
||||
if (g_ivlen == 1) {
|
||||
tmp_tv = tv;
|
||||
- tv = &long_hash_tv_template[0];
|
||||
+ tv = &g_long_hash_tv;
|
||||
tv->dsize = tmp_tv->dsize;
|
||||
} else if (g_ivlen == 2) {
|
||||
tmp_tv = tv;
|
||||
@@ -1587,7 +1590,7 @@ static int sec_digest_sync_once(void)
|
||||
|
||||
/* if mode is HMAC, should set key */
|
||||
if (setup.mode == WD_DIGEST_HMAC) {
|
||||
- ret = wd_digest_set_key(h_sess, (const __u8*)tv->key, tv->ksize);
|
||||
+ ret = wd_digest_set_key(h_sess, (const __u8 *)tv->key, tv->ksize);
|
||||
if (ret) {
|
||||
SEC_TST_PRT("sess set key failed!\n");
|
||||
goto out_key;
|
||||
@@ -1622,6 +1625,311 @@ out_src:
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static int sec_digest_sync_stream_cmp(void)
|
||||
+{
|
||||
+ struct wd_digest_sess_setup setup = {0};
|
||||
+ struct hash_testvec *tv = NULL;
|
||||
+ handle_t h_sess = 0;
|
||||
+ struct wd_digest_req req;
|
||||
+ unsigned long cnt = g_times;
|
||||
+ int ret;
|
||||
+ size_t unit_sz;
|
||||
+
|
||||
+ /* config setup */
|
||||
+ ret = init_digest_ctx_config(CTX_TYPE_ENCRYPT, CTX_MODE_SYNC);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Fail to init sigle ctx config!\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* config arg */
|
||||
+ memset(&req, 0, sizeof(struct wd_digest_req));
|
||||
+ get_digest_resource(&tv, (int *)&setup.alg, (int *)&setup.mode);
|
||||
+
|
||||
+ unit_sz = cal_unit_sz(BUFF_SIZE * 8, g_sgl_num);
|
||||
+ req.in = create_buf(g_data_fmt, BUFF_SIZE * 8, unit_sz);
|
||||
+ if (!req.in) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto out_src;
|
||||
+ }
|
||||
+
|
||||
+ req.in_bytes = tv->psize;
|
||||
+ copy_mem(g_data_fmt, req.in, WD_FLAT_BUF,
|
||||
+ (void *)tv->plaintext, tv->psize);
|
||||
+
|
||||
+ req.out = create_buf(WD_FLAT_BUF, BUFF_SIZE, unit_sz);
|
||||
+ if (!req.out) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto out_dst;
|
||||
+ }
|
||||
+
|
||||
+ req.out_buf_bytes = BUFF_SIZE;
|
||||
+ req.out_bytes = tv->dsize;
|
||||
+ req.data_fmt = g_data_fmt;
|
||||
+ req.has_next = 0;
|
||||
+
|
||||
+ h_sess = wd_digest_alloc_sess(&setup);
|
||||
+ if (!h_sess) {
|
||||
+ ret = -EINVAL;
|
||||
+ goto out_sess;
|
||||
+ }
|
||||
+
|
||||
+ /* if mode is HMAC, should set key */
|
||||
+ ret = wd_digest_set_key(h_sess, (const __u8 *)tv->key, tv->ksize);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("sess set key failed!\n");
|
||||
+ goto out_key;
|
||||
+ }
|
||||
+
|
||||
+ while (cnt) {
|
||||
+ ret = wd_do_digest_sync(h_sess, &req);
|
||||
+ cnt--;
|
||||
+ }
|
||||
+
|
||||
+ SEC_TST_PRT("one hash BD dump the out memory, cmp the stream mode:\n");
|
||||
+ dump_mem(WD_FLAT_BUF, req.out, 16);
|
||||
+
|
||||
+out_key:
|
||||
+ wd_digest_free_sess(h_sess);
|
||||
+out_sess:
|
||||
+ free_buf(WD_FLAT_BUF, req.out);
|
||||
+out_dst:
|
||||
+ free_buf(g_data_fmt, req.in);
|
||||
+out_src:
|
||||
+ digest_uninit_config();
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int sec_digest_sync_stream_mode(void)
|
||||
+{
|
||||
+ struct wd_digest_sess_setup setup;
|
||||
+ struct hash_testvec *tv = NULL;
|
||||
+ handle_t h_sess = 0;
|
||||
+ struct wd_digest_req req;
|
||||
+ unsigned long cnt = g_times;
|
||||
+ int ret, data_len;
|
||||
+ void *bak_in = NULL;
|
||||
+
|
||||
+ /* config setup */
|
||||
+ ret = init_digest_ctx_config(CTX_TYPE_ENCRYPT, CTX_MODE_SYNC);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Fail to init sigle ctx config!\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* config arg */
|
||||
+ memset(&req, 0, sizeof(struct wd_digest_req));
|
||||
+ get_digest_resource(&tv, (int *)&setup.alg, (int *)&setup.mode);
|
||||
+
|
||||
+ req.in = malloc(BUFF_SIZE * 8);
|
||||
+ if (!req.in) {
|
||||
+ SEC_TST_PRT("req src in mem malloc failed!\n");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ bak_in = req.in;
|
||||
+
|
||||
+ memcpy(req.in, tv->plaintext, tv->psize);
|
||||
+ req.in_bytes = tv->psize;
|
||||
+
|
||||
+ req.out = malloc(BUFF_SIZE);
|
||||
+ if (!req.out) {
|
||||
+ SEC_TST_PRT("req dst out mem malloc failed!\n");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ req.out_buf_bytes = BUFF_SIZE;
|
||||
+ req.out_bytes = tv->dsize;
|
||||
+ req.data_fmt = g_data_fmt;
|
||||
+ req.has_next = 0;
|
||||
+
|
||||
+ h_sess = wd_digest_alloc_sess(&setup);
|
||||
+ if (!h_sess) {
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ data_len = tv->psize;
|
||||
+
|
||||
+ /* if mode is HMAC, should set key */
|
||||
+ ret = wd_digest_set_key(h_sess, (const __u8 *)tv->key, tv->ksize);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("sess set key failed!\n");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ while (cnt) {
|
||||
+ do {
|
||||
+ if (data_len > 256) { // soft block size
|
||||
+ req.in_bytes = 256;
|
||||
+ data_len -= 256;
|
||||
+ req.has_next = 1;
|
||||
+ } else {
|
||||
+ req.has_next = 0;
|
||||
+ req.in_bytes = data_len;
|
||||
+ }
|
||||
+ ret = wd_do_digest_sync(h_sess, &req);
|
||||
+
|
||||
+ if (ret)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (req.has_next != 0)
|
||||
+ req.in += 256;
|
||||
+ else
|
||||
+ break;
|
||||
+ } while (true);
|
||||
+ data_len = tv->psize;
|
||||
+ req.has_next = 0;
|
||||
+ req.in = bak_in;
|
||||
+ 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);
|
||||
+
|
||||
+out:
|
||||
+ free(req.out);
|
||||
+ free(req.in);
|
||||
+ if (h_sess)
|
||||
+ wd_digest_free_sess(h_sess);
|
||||
+
|
||||
+ digest_uninit_config();
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+void *digest_sync_stream_mode_send_td(void *data)
|
||||
+{
|
||||
+ int thread_id = (int)syscall(__NR_gettid);
|
||||
+ struct wd_digest_sess_setup setup = {0};
|
||||
+ struct hash_testvec *tv = NULL;
|
||||
+ unsigned long cnt = g_times;
|
||||
+ struct wd_digest_req req;
|
||||
+ int ret, data_len;
|
||||
+ void *bak_in = NULL;
|
||||
+ handle_t h_sess = 0;
|
||||
+
|
||||
+ get_digest_resource(&tv, (int *)&setup.alg, (int *)&setup.mode);
|
||||
+
|
||||
+ h_sess = wd_digest_alloc_sess(&setup);
|
||||
+ if (!h_sess) {
|
||||
+ ret = -EINVAL;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ /* if mode is HMAC, should set key */
|
||||
+ ret = wd_digest_set_key(h_sess, (const __u8 *)tv->key, tv->ksize);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("sess set key failed!\n");
|
||||
+ goto out_key;
|
||||
+ }
|
||||
+
|
||||
+ /* config arg */
|
||||
+ memset(&req, 0, sizeof(struct wd_digest_req));
|
||||
+
|
||||
+ req.in = malloc(BUFF_SIZE * 8);
|
||||
+ if (!req.in) {
|
||||
+ SEC_TST_PRT("req src in mem malloc failed!\n");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ bak_in = req.in;
|
||||
+
|
||||
+ memcpy(req.in, tv->plaintext, tv->psize);
|
||||
+ req.in_bytes = tv->psize;
|
||||
+
|
||||
+ req.out = malloc(BUFF_SIZE);
|
||||
+ if (!req.out) {
|
||||
+ SEC_TST_PRT("req dst out mem malloc failed!\n");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ req.out_buf_bytes = BUFF_SIZE;
|
||||
+ req.out_bytes = tv->dsize;
|
||||
+ req.data_fmt = g_data_fmt;
|
||||
+ req.has_next = 0;
|
||||
+
|
||||
+ data_len = tv->psize;
|
||||
+
|
||||
+ while (cnt) {
|
||||
+ do {
|
||||
+ if (data_len > 256) { // soft block size
|
||||
+ req.in_bytes = 256;
|
||||
+ data_len -= 256;
|
||||
+ req.has_next = 1;
|
||||
+ } else {
|
||||
+ req.has_next = 0;
|
||||
+ req.in_bytes = data_len;
|
||||
+ }
|
||||
+ ret = wd_do_digest_sync(h_sess, &req);
|
||||
+
|
||||
+ if (ret)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (req.has_next != 0)
|
||||
+ req.in += 256;
|
||||
+ else
|
||||
+ break;
|
||||
+
|
||||
+ } while (true);
|
||||
+ data_len = tv->psize;
|
||||
+ req.has_next = 0;
|
||||
+ req.in = bak_in;
|
||||
+ 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);
|
||||
+out_key:
|
||||
+ wd_digest_free_sess(h_sess);
|
||||
+out:
|
||||
+ if (req.out)
|
||||
+ free(req.out);
|
||||
+ if (bak_in)
|
||||
+ free(bak_in);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static int sec_digest_sync_stream_mode_multi(void)
|
||||
+{
|
||||
+ static pthread_t sendtd[64];
|
||||
+ thread_data_d td_data;
|
||||
+ int i, ret;
|
||||
+
|
||||
+ /* config setup */
|
||||
+ ret = init_digest_ctx_config(CTX_TYPE_ENCRYPT, CTX_MODE_SYNC);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Fail to init sigle ctx config!\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* send thread */
|
||||
+ td_data.send_num = g_times;
|
||||
+ td_data.recv_num = g_times;
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ ret = pthread_create(&sendtd[i], NULL, digest_sync_stream_mode_send_td, &td_data);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Create send thread fail!\n");
|
||||
+ goto out_thr;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* join thread */
|
||||
+ for (i = 0; i < g_thread_num; i++) {
|
||||
+ ret = pthread_join(sendtd[i], NULL);
|
||||
+ if (ret) {
|
||||
+ SEC_TST_PRT("Join sendtd thread fail!\n");
|
||||
+ goto out_thr;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+out_thr:
|
||||
+ digest_uninit_config();
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
static void *digest_async_cb(void *data)
|
||||
{
|
||||
// struct wd_digest_req *req = (struct wd_digest_req *)data;
|
||||
@@ -1791,7 +2099,7 @@ static int sec_digest_async_once(void)
|
||||
|
||||
/* if mode is HMAC, should set key */
|
||||
if (setup.mode == WD_DIGEST_HMAC) {
|
||||
- ret = wd_digest_set_key(h_sess, (const __u8*)tv->key, tv->ksize);
|
||||
+ ret = wd_digest_set_key(h_sess, (const __u8 *)tv->key, tv->ksize);
|
||||
if (ret) {
|
||||
SEC_TST_PRT("sess set key failed!\n");
|
||||
goto out_key;
|
||||
@@ -1895,7 +2203,7 @@ static int sec_digest_sync_multi(void)
|
||||
|
||||
/* if mode is HMAC, should set key */
|
||||
if (setup.mode == WD_DIGEST_HMAC) {
|
||||
- ret = wd_digest_set_key(h_sess, (const __u8*)tv->key, tv->ksize);
|
||||
+ ret = wd_digest_set_key(h_sess, (const __u8 *)tv->key, tv->ksize);
|
||||
if (ret) {
|
||||
SEC_TST_PRT("sess set key failed!\n");
|
||||
goto out_key;
|
||||
@@ -1998,7 +2306,7 @@ static int sec_digest_async_multi(void)
|
||||
|
||||
/* if mode is HMAC, should set key */
|
||||
if (setup.mode == WD_DIGEST_HMAC) {
|
||||
- ret = wd_digest_set_key(h_sess, (const __u8*)tv->key, tv->ksize);
|
||||
+ ret = wd_digest_set_key(h_sess, (const __u8 *)tv->key, tv->ksize);
|
||||
if (ret) {
|
||||
SEC_TST_PRT("sess set key failed!\n");
|
||||
goto out;
|
||||
@@ -3471,7 +3779,7 @@ out_thr:
|
||||
static void print_help(void)
|
||||
{
|
||||
SEC_TST_PRT("NAME\n");
|
||||
- SEC_TST_PRT(" test_hisi_sec: test wd sec function,etc\n");
|
||||
+ SEC_TST_PRT(" test_hisi_sec: test wd sec function,etc\n");
|
||||
SEC_TST_PRT("USAGE\n");
|
||||
SEC_TST_PRT(" test_hisi_sec [--cipher] [--digest] [--aead] [--perf]\n");
|
||||
SEC_TST_PRT(" test_hisi_sec [--optype] [--pktlen] [--keylen] [--times]\n");
|
||||
@@ -3498,6 +3806,7 @@ static void print_help(void)
|
||||
SEC_TST_PRT(" [--optype]:\n");
|
||||
SEC_TST_PRT(" 0 : encryption operation or normal mode for hash\n");
|
||||
SEC_TST_PRT(" 1 : decryption operation or hmac mode for hash\n");
|
||||
+ SEC_TST_PRT(" 3 : hmac mode for stream hash mode\n");
|
||||
SEC_TST_PRT(" [--pktlen]:\n");
|
||||
SEC_TST_PRT(" set the length of BD message in bytes\n");
|
||||
SEC_TST_PRT(" [--keylen]:\n");
|
||||
@@ -3514,10 +3823,12 @@ static void print_help(void)
|
||||
SEC_TST_PRT(" the number of QP queues used by the entire test task\n");
|
||||
SEC_TST_PRT(" [--help] = usage\n");
|
||||
SEC_TST_PRT("Example\n");
|
||||
- SEC_TST_PRT(" ./test_hisi_sec --cipher 0 --sync --optype 0 \n");
|
||||
- SEC_TST_PRT(" --pktlen 16 --keylen 16 --times 1 --multi 1\n");
|
||||
- SEC_TST_PRT(" ./test_hisi_sec --perf --sync --pktlen 1024 --block 1024 \n");
|
||||
- SEC_TST_PRT(" --blknum 100000 --times 10000 --multi 1 --ctxnum 1\n");
|
||||
+ SEC_TST_PRT(" ./test_hisi_sec --cipher 0 --sync --optype 0\n");
|
||||
+ SEC_TST_PRT("--pktlen 16 --keylen 16 --times 1 --multi 1\n");
|
||||
+ SEC_TST_PRT(" ./test_hisi_sec --digest 0 --sync --optype 3\n");
|
||||
+ SEC_TST_PRT("--pktlen 16 --keylen 16 --times 1 --multi 2\n");
|
||||
+ SEC_TST_PRT(" ./test_hisi_sec --perf --sync --pktlen 1024 --block 1024\n");
|
||||
+ SEC_TST_PRT("--blknum 100000 --times 10000 --multi 1 --ctxnum 1\n");
|
||||
SEC_TST_PRT("UPDATE:2020-11-06\n");
|
||||
}
|
||||
|
||||
@@ -3684,6 +3995,28 @@ static int test_sec_default_case()
|
||||
return test_sec_cipher_sync_once();
|
||||
}
|
||||
|
||||
+static void long_hash_data_init(void)
|
||||
+{
|
||||
+ g_long_hash_tv.plaintext = malloc(g_pktlen);
|
||||
+ if (g_long_hash_tv.plaintext == NULL)
|
||||
+ return;
|
||||
+
|
||||
+ g_long_hash_tv.psize = g_pktlen;
|
||||
+
|
||||
+ g_long_hash_tv.key = malloc(16);
|
||||
+ if (g_long_hash_tv.key == NULL) {
|
||||
+ free(g_long_hash_tv.plaintext);
|
||||
+ return;
|
||||
+ }
|
||||
+ g_long_hash_tv.ksize = 16;
|
||||
+}
|
||||
+
|
||||
+static void long_hash_data_uninit(void)
|
||||
+{
|
||||
+ free(g_long_hash_tv.plaintext);
|
||||
+ free(g_long_hash_tv.key);
|
||||
+}
|
||||
+
|
||||
static int test_sec_run(__u32 sync_mode, __u32 alg_class)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -3698,13 +4031,26 @@ static int test_sec_run(__u32 sync_mode, __u32 alg_class)
|
||||
SEC_TST_PRT("currently cipher test is synchronize once, one thread!\n");
|
||||
}
|
||||
} else if (alg_class == DIGEST_CLASS) {
|
||||
- if (g_thread_num > 1) {
|
||||
- SEC_TST_PRT("currently digest test is synchronize multi -%d threads!\n", g_thread_num);
|
||||
+ SEC_TST_PRT("hisi_sec HMAC-digest mode.\n");
|
||||
+ long_hash_data_init();
|
||||
+ if (g_thread_num > 1 && g_direction != 3) {
|
||||
+ SEC_TST_PRT("currently digest test is synchronize psize:%u, multi -%d threads!\n", g_pktlen, g_thread_num);
|
||||
ret = sec_digest_sync_multi();
|
||||
+ } else if (g_thread_num > 1 && g_direction == 3) {
|
||||
+ ret = sec_digest_sync_stream_mode_multi();
|
||||
+ (void)sec_digest_sync_stream_cmp();
|
||||
+ SEC_TST_PRT("currently digest long hash mode, psize:%u, multi thread!\n", g_pktlen);
|
||||
+ } else if (g_thread_num == 1 && g_direction == 3) {
|
||||
+ if (g_ivlen == 1) {
|
||||
+ ret = sec_digest_sync_stream_mode();
|
||||
+ (void)sec_digest_sync_stream_cmp();
|
||||
+ SEC_TST_PRT("currently digest long hash mode, psize:%u, one thread!\n", g_pktlen);
|
||||
+ }
|
||||
} else {
|
||||
ret = sec_digest_sync_once();
|
||||
SEC_TST_PRT("currently digest test is synchronize once, one thread!\n");
|
||||
}
|
||||
+ long_hash_data_uninit();
|
||||
} else if (alg_class == AEAD_CLASS) {
|
||||
if (g_thread_num > 1) {
|
||||
SEC_TST_PRT("currently aead test is synchronize multi -%d threads!\n", g_thread_num);
|
||||
diff --git a/test/hisi_sec_test/test_hisi_sec.h b/test/hisi_sec_test/test_hisi_sec.h
|
||||
index f0d0812..defd3c4 100644
|
||||
--- a/test/hisi_sec_test/test_hisi_sec.h
|
||||
+++ b/test/hisi_sec_test/test_hisi_sec.h
|
||||
@@ -41,8 +41,8 @@ struct cipher_testvec {
|
||||
};
|
||||
|
||||
struct hash_testvec {
|
||||
- const char *key;
|
||||
- const char *plaintext;
|
||||
+ char *key;
|
||||
+ char *plaintext;
|
||||
const char *digest;
|
||||
unsigned int psize;
|
||||
unsigned short ksize;
|
||||
--
|
||||
2.31.1
|
||||
|
||||
82
0003-aead-cipher-digest-fix-some-code-issues.patch
Normal file
82
0003-aead-cipher-digest-fix-some-code-issues.patch
Normal file
@ -0,0 +1,82 @@
|
||||
From a119cf2838ee41078c452f93d5b48bea2561dfcc Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Tue, 14 Dec 2021 19:24:47 +0800
|
||||
Subject: [PATCH 03/28] aead/cipher/digest: fix some code issues
|
||||
|
||||
1. Due to the schedule already has the a checking for poll
|
||||
policy, so delete the checking for poll policy in poll.
|
||||
2. modify some comments.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
wd_aead.c | 9 ++-------
|
||||
wd_cipher.c | 5 -----
|
||||
wd_digest.c | 5 -----
|
||||
3 files changed, 2 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/wd_aead.c b/wd_aead.c
|
||||
index 54bd28d..f93f791 100644
|
||||
--- a/wd_aead.c
|
||||
+++ b/wd_aead.c
|
||||
@@ -367,12 +367,12 @@ static int aead_param_check(struct wd_aead_sess *sess,
|
||||
static int aead_init_check(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||
{
|
||||
if (!config || !sched) {
|
||||
- WD_ERR("failed to check aead init input param!\n");
|
||||
+ WD_ERR("wd aead config or sched is NULL!\n");
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
|
||||
if (!wd_is_sva(config->ctxs[0].ctx)) {
|
||||
- WD_ERR("failed to system is SVA mode!\n");
|
||||
+ WD_ERR("err, non sva, please check system!\n");
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
|
||||
@@ -660,11 +660,6 @@ int wd_aead_poll(__u32 expt, __u32 *count)
|
||||
handle_t h_ctx = wd_aead_setting.sched.h_sched_ctx;
|
||||
struct wd_sched *sched = &wd_aead_setting.sched;
|
||||
|
||||
- if (unlikely(!sched->poll_policy)) {
|
||||
- WD_ERR("failed to check aead poll_policy!\n");
|
||||
- return -WD_EINVAL;
|
||||
- }
|
||||
-
|
||||
return sched->poll_policy(h_ctx, expt, count);
|
||||
}
|
||||
|
||||
diff --git a/wd_cipher.c b/wd_cipher.c
|
||||
index f9d643d..9977765 100644
|
||||
--- a/wd_cipher.c
|
||||
+++ b/wd_cipher.c
|
||||
@@ -580,11 +580,6 @@ int wd_cipher_poll(__u32 expt, __u32 *count)
|
||||
handle_t h_ctx = wd_cipher_setting.sched.h_sched_ctx;
|
||||
struct wd_sched *sched = &wd_cipher_setting.sched;
|
||||
|
||||
- if (unlikely(!sched->poll_policy)) {
|
||||
- WD_ERR("failed to check cipher poll_policy!\n");
|
||||
- return -WD_EINVAL;
|
||||
- }
|
||||
-
|
||||
return sched->poll_policy(h_ctx, expt, count);
|
||||
}
|
||||
|
||||
diff --git a/wd_digest.c b/wd_digest.c
|
||||
index c110f7b..1962f09 100644
|
||||
--- a/wd_digest.c
|
||||
+++ b/wd_digest.c
|
||||
@@ -484,11 +484,6 @@ int wd_digest_poll(__u32 expt, __u32 *count)
|
||||
handle_t h_ctx = wd_digest_setting.sched.h_sched_ctx;
|
||||
struct wd_sched *sched = &wd_digest_setting.sched;
|
||||
|
||||
- if (unlikely(!sched->poll_policy)) {
|
||||
- WD_ERR("failed to check digest poll_policy!\n");
|
||||
- return -WD_EINVAL;
|
||||
- }
|
||||
-
|
||||
return sched->poll_policy(h_ctx, expt, count);
|
||||
}
|
||||
|
||||
--
|
||||
2.31.1
|
||||
|
||||
28
0004-digest-v1-fixed-hmac-key-0-length-checking.patch
Normal file
28
0004-digest-v1-fixed-hmac-key-0-length-checking.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From d27f5accc09bc63d81a6a972fd019e208cddc9a8 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Tue, 14 Dec 2021 19:24:48 +0800
|
||||
Subject: [PATCH 04/28] digest/v1: fixed hmac key 0 length checking
|
||||
|
||||
The length of keylen checking v1 and v2 should be the same.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
v1/wd_digest.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/v1/wd_digest.c b/v1/wd_digest.c
|
||||
index 6b22cdd..d684512 100644
|
||||
--- a/v1/wd_digest.c
|
||||
+++ b/v1/wd_digest.c
|
||||
@@ -243,7 +243,7 @@ int wcrypto_set_digest_key(void *ctx, __u8 *key, __u16 key_len)
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
|
||||
- if (key_len > MAX_HMAC_KEY_SIZE) {
|
||||
+ if (key_len == 0 || key_len > MAX_HMAC_KEY_SIZE) {
|
||||
WD_ERR("%s: input key length err!\n", __func__);
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
--
|
||||
2.31.1
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
From 6136bd700e5f5b23843a3e8aae9e3a925c37ca50 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Tue, 14 Dec 2021 19:24:49 +0800
|
||||
Subject: [PATCH 05/28] digest/v1: check the length of the key need to be
|
||||
changed.
|
||||
|
||||
The maximum length of the key is fixed by digest spec.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
v1/wd_digest.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/v1/wd_digest.c b/v1/wd_digest.c
|
||||
index d684512..aae4823 100644
|
||||
--- a/v1/wd_digest.c
|
||||
+++ b/v1/wd_digest.c
|
||||
@@ -243,7 +243,9 @@ int wcrypto_set_digest_key(void *ctx, __u8 *key, __u16 key_len)
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
|
||||
- if (key_len == 0 || key_len > MAX_HMAC_KEY_SIZE) {
|
||||
+ if ((ctxt->setup.alg <= WCRYPTO_SHA224 && key_len >
|
||||
+ MAX_HMAC_KEY_SIZE >> 1) || key_len == 0 ||
|
||||
+ key_len > MAX_HMAC_KEY_SIZE) {
|
||||
WD_ERR("%s: input key length err!\n", __func__);
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
--
|
||||
2.31.1
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
From 1903e366f228ac6ee9dfb826b75b9d698bb180d8 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Wed, 22 Dec 2021 14:38:03 +0800
|
||||
Subject: [PATCH 07/28] qm/v1: fixup the incorrect configuration of the type
|
||||
|
||||
1. SEC should setting the sqc type is 0. it doesn't depend on
|
||||
encryption or decryption direction.
|
||||
2. Modify the HPRE sqc type configuration.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
v1/drv/hisi_qm_udrv.c | 5 +++++
|
||||
v1/wd.h | 5 ++++-
|
||||
2 files changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/v1/drv/hisi_qm_udrv.c b/v1/drv/hisi_qm_udrv.c
|
||||
index 7fb6599..02aaf81 100644
|
||||
--- a/v1/drv/hisi_qm_udrv.c
|
||||
+++ b/v1/drv/hisi_qm_udrv.c
|
||||
@@ -277,16 +277,19 @@ static bool hpre_alg_info_init(struct wd_queue *q, const char *alg)
|
||||
struct qm_queue_info *info = qinfo->priv;
|
||||
bool is_found = true;
|
||||
|
||||
+ /* DH/RSA: qm sqc_type = 0, ECC: qm sqc_type = 1 */
|
||||
if (!strcmp(alg, "rsa")) {
|
||||
qinfo->atype = WCRYPTO_RSA;
|
||||
info->sqe_size = QM_HPRE_BD_SIZE;
|
||||
info->sqe_fill[WCRYPTO_RSA] = qm_fill_rsa_sqe;
|
||||
info->sqe_parse[WCRYPTO_RSA] = qm_parse_rsa_sqe;
|
||||
+ priv->direction = 0;
|
||||
} else if (!strcmp(alg, "dh")) {
|
||||
qinfo->atype = WCRYPTO_DH;
|
||||
info->sqe_size = QM_HPRE_BD_SIZE;
|
||||
info->sqe_fill[WCRYPTO_DH] = qm_fill_dh_sqe;
|
||||
info->sqe_parse[WCRYPTO_DH] = qm_parse_dh_sqe;
|
||||
+ priv->direction = 0;
|
||||
} else if (!strcmp(alg, "ecdh")) {
|
||||
qinfo->atype = WCRYPTO_ECDH;
|
||||
info->sqe_size = QM_HPRE_BD_SIZE;
|
||||
@@ -414,6 +417,8 @@ static int qm_set_queue_alg_info(struct wd_queue *q)
|
||||
} else if (zip_alg_info_init(qinfo, alg)) {
|
||||
ret = WD_SUCCESS;
|
||||
} else if (sec_alg_info_init(qinfo, alg)) {
|
||||
+ /* setting the type is 0 for sqc_type */
|
||||
+ priv->direction = 0;
|
||||
ret = WD_SUCCESS;
|
||||
} else if (!strcmp(alg, "xts(aes)") ||
|
||||
!strcmp(alg, "xts(sm4)")) {
|
||||
diff --git a/v1/wd.h b/v1/wd.h
|
||||
index 30fbf89..3dd69eb 100644
|
||||
--- a/v1/wd.h
|
||||
+++ b/v1/wd.h
|
||||
@@ -73,7 +73,10 @@ struct wcrypto_cb_tag {
|
||||
};
|
||||
|
||||
struct wcrypto_paras {
|
||||
- /* 0--encipher/compress .etc, 1 ---decipher/decomp .etc */
|
||||
+ /*
|
||||
+ * 0--encipher/compress .etc, 1 ---decipher/decomp .etc
|
||||
+ * it not been used for HiSilicon SEC currently.
|
||||
+ */
|
||||
__u8 direction;
|
||||
__u8 is_poll;
|
||||
|
||||
--
|
||||
2.31.1
|
||||
|
||||
30
0007-qm-fixup-the-incorrect-configuration-of-the-type.patch
Normal file
30
0007-qm-fixup-the-incorrect-configuration-of-the-type.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From c602a3e77fbd95286e233c7ed257762687d8ebac Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Wed, 22 Dec 2021 14:38:04 +0800
|
||||
Subject: [PATCH 08/28] qm: fixup the incorrect configuration of the type
|
||||
|
||||
SEC should setting the sqc type is 0. it doesn't depend on
|
||||
global configuration.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
drv/hisi_sec.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
|
||||
index 2fd23f3..603bdda 100644
|
||||
--- a/drv/hisi_sec.c
|
||||
+++ b/drv/hisi_sec.c
|
||||
@@ -2306,7 +2306,8 @@ int hisi_sec_init(struct wd_ctx_config_internal *config, void *priv)
|
||||
/* allocate qp for each context */
|
||||
for (i = 0; i < config->ctx_num; i++) {
|
||||
h_ctx = config->ctxs[i].ctx;
|
||||
- qm_priv.op_type = config->ctxs[i].op_type;
|
||||
+ /* setting the type is 0 for sqc_type */
|
||||
+ qm_priv.op_type = 0;
|
||||
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
|
||||
qm_priv.idx = i;
|
||||
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
|
||||
--
|
||||
2.31.1
|
||||
|
||||
1125
0008-uadk_benchmark-use-the-uadk_tool-instead-of-uadk_ben.patch
Normal file
1125
0008-uadk_benchmark-use-the-uadk_tool-instead-of-uadk_ben.patch
Normal file
File diff suppressed because it is too large
Load Diff
63
0009-digest-some-optimizations-for-digest-stream-mode.patch
Normal file
63
0009-digest-some-optimizations-for-digest-stream-mode.patch
Normal file
@ -0,0 +1,63 @@
|
||||
From 0d65963667c4795a28701e5a212422ebcff27c74 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Thu, 23 Dec 2021 15:40:15 +0800
|
||||
Subject: [PATCH 10/28] digest: some optimizations for digest stream mode
|
||||
|
||||
1. add some comments for session state.
|
||||
2. The stream status is set only when the last msg message is
|
||||
successfully received.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
wd_digest.c | 14 +++++++++-----
|
||||
1 file changed, 9 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/wd_digest.c b/wd_digest.c
|
||||
index 1962f09..bbb258f 100644
|
||||
--- a/wd_digest.c
|
||||
+++ b/wd_digest.c
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#define POLL_SIZE 100000
|
||||
#define POLL_TIME 1000
|
||||
+#define STREAM_MODE_STATE 1
|
||||
|
||||
static int g_digest_mac_len[WD_DIGEST_TYPE_MAX] = {
|
||||
WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN,
|
||||
@@ -46,8 +47,11 @@ struct wd_digest_sess {
|
||||
unsigned char key[MAX_HMAC_KEY_SIZE];
|
||||
__u32 key_bytes;
|
||||
void *sched_key;
|
||||
- /* Notify the BD state */
|
||||
- int state;
|
||||
+ /*
|
||||
+ * Notify the BD state, 1 is final BD or middle BD,
|
||||
+ * 0 is normal mode or first BD, one session only supports one stream.
|
||||
+ */
|
||||
+ int state;
|
||||
/* Total of data for stream mode */
|
||||
__u64 long_data_len;
|
||||
};
|
||||
@@ -294,7 +298,7 @@ static void fill_request_msg(struct wd_digest_msg *msg,
|
||||
msg->has_next = req->has_next;
|
||||
sess->long_data_len += req->in_bytes;
|
||||
msg->long_data_len = sess->long_data_len;
|
||||
- /* To store the stream bd state */
|
||||
+ /* To store the stream bd state, iv_bytes also means bd state */
|
||||
msg->iv_bytes = sess->state;
|
||||
if (req->has_next == 0) {
|
||||
sess->long_data_len = 0;
|
||||
@@ -332,8 +336,8 @@ static int send_recv_sync(struct wd_ctx_internal *ctx, struct wd_digest_sess *ds
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
- if (msg->has_next)
|
||||
- dsess->state = msg->out_bytes;
|
||||
+ if (msg->has_next && msg->result == WD_SUCCESS)
|
||||
+ dsess->state = STREAM_MODE_STATE;
|
||||
} while (ret < 0);
|
||||
|
||||
out:
|
||||
--
|
||||
2.31.1
|
||||
|
||||
44
0010-uadk-fix-error-of-wd_get_avail_ctx-return-value.patch
Normal file
44
0010-uadk-fix-error-of-wd_get_avail_ctx-return-value.patch
Normal file
@ -0,0 +1,44 @@
|
||||
From 17bc4f46411541e725d30ec76693982765a96114 Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Mon, 27 Dec 2021 09:52:00 +0800
|
||||
Subject: [PATCH 12/28] uadk: fix error of wd_get_avail_ctx return value
|
||||
|
||||
When wd_get_avail_ctx return negative value,
|
||||
wd should not use this device.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd.c | 3 ++-
|
||||
wd_util.c | 2 +-
|
||||
2 files changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/wd.c b/wd.c
|
||||
index 838efa7..2bb2fdd 100644
|
||||
--- a/wd.c
|
||||
+++ b/wd.c
|
||||
@@ -675,7 +675,8 @@ struct uacce_dev *wd_get_accel_dev(const char *alg_name)
|
||||
while (list) {
|
||||
tmp = numa_distance(node, list->dev->numa_id);
|
||||
ctx_num = wd_get_avail_ctx(list->dev);
|
||||
- if ((dis > tmp && ctx_num) || (dis == tmp && ctx_num > max)) {
|
||||
+ if ((dis > tmp && ctx_num > 0) ||
|
||||
+ (dis == tmp && ctx_num > max)) {
|
||||
dev = list->dev;
|
||||
dis = tmp;
|
||||
max = ctx_num;
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index c973eff..3c1fd26 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -846,7 +846,7 @@ static handle_t request_ctx_on_numa(struct wd_env_config_per_numa *config)
|
||||
for (i = 0; i < config->dev_num; i++) {
|
||||
dev = config->dev + i;
|
||||
ctx_num = wd_get_avail_ctx(dev);
|
||||
- if (!ctx_num)
|
||||
+ if (ctx_num <= 0)
|
||||
continue;
|
||||
|
||||
h_ctx = wd_request_ctx(dev);
|
||||
--
|
||||
2.31.1
|
||||
|
||||
85
0011-uadk-fix-comment-content.patch
Normal file
85
0011-uadk-fix-comment-content.patch
Normal file
@ -0,0 +1,85 @@
|
||||
From 6a83adca797b8917907d56097f72b3755acf74fa Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Mon, 27 Dec 2021 09:51:59 +0800
|
||||
Subject: [PATCH 13/28] uadk: fix comment content
|
||||
|
||||
There must be 1 space between the block comment character
|
||||
and the comment content.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
v1/drv/hisi_qm_udrv.c | 2 +-
|
||||
v1/wd_cipher.h | 2 +-
|
||||
v1/wd_dh.h | 2 +-
|
||||
wd_comp.c | 2 +-
|
||||
wd_util.c | 2 +-
|
||||
5 files changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/v1/drv/hisi_qm_udrv.c b/v1/drv/hisi_qm_udrv.c
|
||||
index 02aaf81..63f346b 100644
|
||||
--- a/v1/drv/hisi_qm_udrv.c
|
||||
+++ b/v1/drv/hisi_qm_udrv.c
|
||||
@@ -77,7 +77,7 @@ static int qm_hw_sgl_sge_init(struct wd_sgl *sgl, struct hisi_sgl *hisi_sgl,
|
||||
return WD_SUCCESS;
|
||||
}
|
||||
|
||||
-/* 'num' starts from 1*/
|
||||
+/* 'num' starts from 1 */
|
||||
void qm_hw_sgl_sge_uninit(struct wd_sgl *sgl, struct hisi_sgl *hisi_sgl,
|
||||
int num, struct wd_mm_br *br, __u32 buf_sz)
|
||||
{
|
||||
diff --git a/v1/wd_cipher.h b/v1/wd_cipher.h
|
||||
index 2ab0e1d..7059f53 100644
|
||||
--- a/v1/wd_cipher.h
|
||||
+++ b/v1/wd_cipher.h
|
||||
@@ -92,7 +92,7 @@ struct wcrypto_cipher_op_data {
|
||||
/* Cipher message format of Warpdrive */
|
||||
struct wcrypto_cipher_msg {
|
||||
__u8 alg_type:4; /* Denoted by enum wcrypto_type */
|
||||
- __u8 alg:4; /* Denoted by enum wcrypto_cipher_alg*/
|
||||
+ __u8 alg:4; /* Denoted by enum wcrypto_cipher_alg */
|
||||
__u8 op_type:4; /* Denoted by enum wcrypto_cipher_op_type */
|
||||
__u8 mode:4; /* Denoted by enum wcrypto_cipher_mode */
|
||||
__u8 data_fmt; /* Data format, denoted by enum wcrypto_buff_type */
|
||||
diff --git a/v1/wd_dh.h b/v1/wd_dh.h
|
||||
index 6364966..e411830 100644
|
||||
--- a/v1/wd_dh.h
|
||||
+++ b/v1/wd_dh.h
|
||||
@@ -64,7 +64,7 @@ struct wcrypto_dh_msg {
|
||||
__u8 result; /* Data format, denoted by WD error code */
|
||||
__u16 key_bytes; /* Key size */
|
||||
__u8 *x_p; /* This is Xa and p data in order. Should be DMA buffer */
|
||||
- __u8 *g; /* This is PV also at phase 2. Should be DMA buffer*/
|
||||
+ __u8 *g; /* This is PV also at phase 2. Should be DMA buffer */
|
||||
__u8 *out; /* Result address, should be DMA buffer */
|
||||
__u16 xbytes; /* parameter Xa size */
|
||||
__u16 pbytes; /* parameter p size */
|
||||
diff --git a/wd_comp.c b/wd_comp.c
|
||||
index 6f0cf9d..e34d590 100644
|
||||
--- a/wd_comp.c
|
||||
+++ b/wd_comp.c
|
||||
@@ -584,7 +584,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) {
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index 3c1fd26..3170f3c 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -34,7 +34,7 @@ static const char *comp_ctx_type[2][2] = {
|
||||
{"async-comp:", "async-decomp:"}
|
||||
};
|
||||
|
||||
-/* define two ctx mode here for cipher and other alg*/
|
||||
+/* define two ctx mode here for cipher and other alg */
|
||||
static const char *ctx_type[2][1] = { {"sync:"}, {"async:"} };
|
||||
|
||||
struct async_task {
|
||||
--
|
||||
2.31.1
|
||||
|
||||
424
0012-uadk-max-numa-number-should-not-be-fixed.patch
Normal file
424
0012-uadk-max-numa-number-should-not-be-fixed.patch
Normal file
@ -0,0 +1,424 @@
|
||||
From ca3131392a8cb3209599dc6ca4c377460346b36a Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Mon, 27 Dec 2021 09:52:01 +0800
|
||||
Subject: [PATCH 14/28] uadk: max numa number should not be fixed
|
||||
|
||||
numa_num_configured_nodes() returns the number
|
||||
of memory nodes in the system, so use it as max
|
||||
numa number is good.
|
||||
when function is called in io path, use static array
|
||||
as much as possible, so use a numa number macro.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
include/wd_sched.h | 5 +-
|
||||
include/wd_util.h | 6 +-
|
||||
test/hisi_sec_test/test_hisi_sec.c | 5 +-
|
||||
uadk_tool/sec_uadk_benchmark.c | 13 ++--
|
||||
wd_sched.c | 39 +++++++----
|
||||
wd_util.c | 106 ++++++++++++++++++-----------
|
||||
6 files changed, 109 insertions(+), 65 deletions(-)
|
||||
|
||||
diff --git a/include/wd_sched.h b/include/wd_sched.h
|
||||
index a008d57..78125f4 100644
|
||||
--- a/include/wd_sched.h
|
||||
+++ b/include/wd_sched.h
|
||||
@@ -8,7 +8,6 @@
|
||||
#define SCHED_SAMPLE_h
|
||||
#include "wd_alg_common.h"
|
||||
|
||||
-#define MAX_NUMA_NUM 4
|
||||
#define INVALID_POS 0xFFFFFFFF
|
||||
|
||||
/* The global policy type */
|
||||
@@ -48,8 +47,8 @@ int wd_sched_rr_instance(const struct wd_sched *sched,
|
||||
* @func: The ctx poll function of user underlying operating.
|
||||
*
|
||||
*/
|
||||
-struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num, __u8 numa_num,
|
||||
- user_poll_func func);
|
||||
+struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
|
||||
+ __u16 numa_num, user_poll_func func);
|
||||
|
||||
/**
|
||||
* wd_sched_rr_release - Release schedule memory.
|
||||
diff --git a/include/wd_util.h b/include/wd_util.h
|
||||
index 643309c..81f4ba8 100644
|
||||
--- a/include/wd_util.h
|
||||
+++ b/include/wd_util.h
|
||||
@@ -59,12 +59,9 @@ struct wd_env_config_per_numa {
|
||||
};
|
||||
|
||||
struct wd_env_config {
|
||||
- unsigned long numa_num;
|
||||
struct wd_env_config_per_numa *config_per_numa;
|
||||
/* Let's make it as a gobal config, not per numa */
|
||||
bool enable_internal_poll;
|
||||
- __u8 disable_env;
|
||||
- __u8 op_type_num;
|
||||
int (*alg_poll_ctx)(__u32, __u32, __u32 *);
|
||||
void (*alg_uninit)(void);
|
||||
|
||||
@@ -74,6 +71,9 @@ struct wd_env_config {
|
||||
struct wd_ctx_config *ctx_config;
|
||||
const struct wd_config_variable *table;
|
||||
__u32 table_size;
|
||||
+ __u16 numa_num;
|
||||
+ __u8 disable_env;
|
||||
+ __u8 op_type_num;
|
||||
};
|
||||
|
||||
struct wd_config_variable {
|
||||
diff --git a/test/hisi_sec_test/test_hisi_sec.c b/test/hisi_sec_test/test_hisi_sec.c
|
||||
index e1521f6..dda291d 100644
|
||||
--- a/test/hisi_sec_test/test_hisi_sec.c
|
||||
+++ b/test/hisi_sec_test/test_hisi_sec.c
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
#include <getopt.h>
|
||||
+#include <numa.h>
|
||||
|
||||
#include "test_hisi_sec.h"
|
||||
#include "wd_cipher.h"
|
||||
@@ -493,7 +494,9 @@ static int init_ctx_config(int type, int mode)
|
||||
if (list->dev->numa_id < 0)
|
||||
list->dev->numa_id = 0;
|
||||
|
||||
- g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, MAX_NUMA_NUM, wd_cipher_poll_ctx);
|
||||
+ g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1,
|
||||
+ numa_max_node() + 1,
|
||||
+ wd_cipher_poll_ctx);
|
||||
if (!g_sched) {
|
||||
printf("Fail to alloc sched!\n");
|
||||
goto out;
|
||||
diff --git a/uadk_tool/sec_uadk_benchmark.c b/uadk_tool/sec_uadk_benchmark.c
|
||||
index 21738ed..40ba227 100644
|
||||
--- a/uadk_tool/sec_uadk_benchmark.c
|
||||
+++ b/uadk_tool/sec_uadk_benchmark.c
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
+#include <numa.h>
|
||||
#include "uadk_benchmark.h"
|
||||
|
||||
#include "sec_uadk_benchmark.h"
|
||||
@@ -347,8 +348,12 @@ 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;
|
||||
+ int i, max_node;
|
||||
int ret = 0;
|
||||
- int i;
|
||||
+
|
||||
+ max_node = numa_max_node() + 1;
|
||||
+ if (max_node <= 0)
|
||||
+ return -EINVAL;
|
||||
|
||||
list = wd_get_accel_list(alg);
|
||||
if (!list) {
|
||||
@@ -369,13 +374,13 @@ static int init_ctx_config(char *alg, int subtype, int mode)
|
||||
|
||||
switch(subtype) {
|
||||
case CIPHER_TYPE:
|
||||
- g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, MAX_NUMA_NUM, wd_cipher_poll_ctx);
|
||||
+ g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, max_node, wd_cipher_poll_ctx);
|
||||
break;
|
||||
case AEAD_TYPE:
|
||||
- g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, MAX_NUMA_NUM, wd_aead_poll_ctx);
|
||||
+ g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, max_node, wd_aead_poll_ctx);
|
||||
break;
|
||||
case DIGEST_TYPE:
|
||||
- g_sched = wd_sched_rr_alloc(SCHED_POLICY_RR, 1, MAX_NUMA_NUM, wd_digest_poll_ctx);
|
||||
+ 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");
|
||||
diff --git a/wd_sched.c b/wd_sched.c
|
||||
index 8ca309c..b310077 100644
|
||||
--- a/wd_sched.c
|
||||
+++ b/wd_sched.c
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
+#include <numa.h>
|
||||
#include "wd_sched.h"
|
||||
|
||||
#define MAX_POLL_TIMES 1000
|
||||
@@ -37,6 +38,8 @@ struct sched_key {
|
||||
* @begin: the start pos in ctxs of config.
|
||||
* @end: the end pos in ctxx of config.
|
||||
* @last: the last one which be distributed.
|
||||
+ * @valid: the region used flag.
|
||||
+ * @lock: lock the currentscheduling region.
|
||||
*/
|
||||
struct sched_ctx_region {
|
||||
__u32 begin;
|
||||
@@ -64,14 +67,13 @@ struct wd_sched_info {
|
||||
* @policy: define the policy of the scheduler.
|
||||
* @numa_num: the max numa numbers of the scheduler.
|
||||
* @type_num: the max operation types of the scheduler.
|
||||
- * @numa_id: current task's numa id
|
||||
* @poll_func: the task's poll operation function.
|
||||
* @sched_info: the context of the scheduler
|
||||
*/
|
||||
struct wd_sched_ctx {
|
||||
__u32 policy;
|
||||
__u32 type_num;
|
||||
- __u8 numa_num;
|
||||
+ __u16 numa_num;
|
||||
user_poll_func poll_func;
|
||||
struct wd_sched_info sched_info[0];
|
||||
};
|
||||
@@ -200,11 +202,11 @@ static int session_sched_poll_policy(handle_t sched_ctx,
|
||||
{
|
||||
struct wd_sched_ctx *ctx = (struct wd_sched_ctx *)sched_ctx;
|
||||
struct wd_sched_info *sched_info;
|
||||
- int numa[MAX_NUMA_NUM];
|
||||
+ __u16 numa[NUMA_NUM_NODES];
|
||||
__u32 loop_time = 0;
|
||||
__u32 last_count = 0;
|
||||
- __u8 tail = 0;
|
||||
- __u8 i;
|
||||
+ __u16 tail = 0;
|
||||
+ __u16 i;
|
||||
int ret;
|
||||
|
||||
if (!sched_ctx || !count || !ctx) {
|
||||
@@ -212,6 +214,11 @@ static int session_sched_poll_policy(handle_t sched_ctx,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
+ if (ctx->numa_num > NUMA_NUM_NODES) {
|
||||
+ WD_ERR("ERROR: %s ctx numa num is invalid!\n", __FUNCTION__);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
sched_info = ctx->sched_info;
|
||||
for (i = 0; i < ctx->numa_num; i++)
|
||||
if (sched_info[i].valid)
|
||||
@@ -412,13 +419,23 @@ out:
|
||||
return;
|
||||
}
|
||||
|
||||
-struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num, __u8 numa_num,
|
||||
- user_poll_func func)
|
||||
+struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
|
||||
+ __u16 numa_num, user_poll_func func)
|
||||
{
|
||||
struct wd_sched_info *sched_info;
|
||||
struct wd_sched_ctx *sched_ctx;
|
||||
struct wd_sched *sched;
|
||||
- int i, j;
|
||||
+ int i, j, max_node;
|
||||
+
|
||||
+ max_node = numa_max_node() + 1;
|
||||
+ if (max_node <= 0)
|
||||
+ return NULL;
|
||||
+
|
||||
+ if (!numa_num || numa_num > max_node) {
|
||||
+ WD_ERR("Error: %s numa number = %u!\n", __FUNCTION__,
|
||||
+ numa_num);
|
||||
+ return NULL;
|
||||
+ }
|
||||
|
||||
if (sched_type >= SCHED_POLICY_BUTT || !type_num) {
|
||||
WD_ERR("Error: %s sched_type = %u or type_num = %u is invalid!\n",
|
||||
@@ -426,12 +443,6 @@ struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num, __u8 numa_num
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- if (!numa_num) {
|
||||
- WD_ERR("Warning: %s set numa number as %d!\n", __FUNCTION__,
|
||||
- MAX_NUMA_NUM);
|
||||
- numa_num = MAX_NUMA_NUM;
|
||||
- }
|
||||
-
|
||||
sched = calloc(1, sizeof(struct wd_sched));
|
||||
if (!sched) {
|
||||
WD_ERR("Error: %s wd_sched alloc error!\n", __FUNCTION__);
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index 3170f3c..3a1def5 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -357,26 +357,28 @@ static void wd_free_numa(struct wd_env_config *config)
|
||||
* @numa_dev_num: number of devices of the same type (like sec2) on each numa.
|
||||
* @numa_num: number of numa node that has this type of device.
|
||||
*/
|
||||
-static void wd_get_dev_numa(struct uacce_dev_list *head,
|
||||
- int *numa_dev_num, __u8 *numa_num, __u8 size)
|
||||
+static __u16 wd_get_dev_numa(struct uacce_dev_list *head,
|
||||
+ int *numa_dev_num, __u16 size)
|
||||
{
|
||||
struct uacce_dev_list *list = head;
|
||||
+ __u16 numa_num = 0;
|
||||
|
||||
while (list) {
|
||||
if (list->dev->numa_id < 0) {
|
||||
list->dev->numa_id = 0;
|
||||
} else if (list->dev->numa_id >= size) {
|
||||
WD_ERR("numa id is wrong(%d)\n", list->dev->numa_id);
|
||||
- *numa_num = 0;
|
||||
- return;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
if (!numa_dev_num[list->dev->numa_id])
|
||||
- (*numa_num)++;
|
||||
+ numa_num++;
|
||||
|
||||
numa_dev_num[list->dev->numa_id]++;
|
||||
list = list->next;
|
||||
}
|
||||
+
|
||||
+ return numa_num;
|
||||
}
|
||||
|
||||
static void wd_set_numa_dev(struct uacce_dev_list *head,
|
||||
@@ -400,39 +402,18 @@ static void wd_set_numa_dev(struct uacce_dev_list *head,
|
||||
}
|
||||
}
|
||||
|
||||
-static int wd_alloc_numa(struct wd_env_config *config,
|
||||
- const struct wd_alg_ops *ops)
|
||||
+static int wd_set_config_numa(struct wd_env_config *config,
|
||||
+ int *numa_dev_num, int max_node)
|
||||
{
|
||||
struct wd_env_config_per_numa *config_numa;
|
||||
- struct uacce_dev_list *head;
|
||||
- int numa_dev_num[MAX_NUMA_NUM] = {0};
|
||||
- __u8 numa_num = 0;
|
||||
- int i, ret;
|
||||
-
|
||||
- /* get uacce_dev */
|
||||
- head = wd_get_accel_list(ops->alg_name);
|
||||
- if (!head) {
|
||||
- WD_ERR("no device to support %s\n", ops->alg_name);
|
||||
- return -WD_ENODEV;
|
||||
- }
|
||||
-
|
||||
- /* get numa num and device num of each numa from uacce_dev list */
|
||||
- wd_get_dev_numa(head, numa_dev_num, &numa_num, MAX_NUMA_NUM);
|
||||
- if (numa_num == 0 || numa_num > MAX_NUMA_NUM) {
|
||||
- WD_ERR("numa num err(%u)!\n", numa_num);
|
||||
- wd_free_list_accels(head);
|
||||
- return -WD_ENODEV;
|
||||
- }
|
||||
+ int i;
|
||||
|
||||
- config->numa_num = numa_num;
|
||||
- config->config_per_numa = calloc(numa_num, sizeof(*config_numa));
|
||||
- if (!config->config_per_numa) {
|
||||
- ret = -WD_ENOMEM;
|
||||
- goto free_list;
|
||||
- }
|
||||
+ config->config_per_numa = calloc(config->numa_num, sizeof(*config_numa));
|
||||
+ if (!config->config_per_numa)
|
||||
+ return -WD_ENOMEM;
|
||||
|
||||
config_numa = config->config_per_numa;
|
||||
- for (i = 0; i < MAX_NUMA_NUM; i++) {
|
||||
+ for (i = 0; i < max_node; i++) {
|
||||
if (!numa_dev_num[i])
|
||||
continue;
|
||||
|
||||
@@ -440,24 +421,65 @@ static int wd_alloc_numa(struct wd_env_config *config,
|
||||
config_numa->dev = calloc(numa_dev_num[i],
|
||||
sizeof(struct uacce_dev));
|
||||
if (!config_numa->dev) {
|
||||
- ret = -WD_ENOMEM;
|
||||
- goto free_mem;
|
||||
+ /* free config_per_numa and all uacce dev */
|
||||
+ wd_free_numa(config);
|
||||
+ return -WD_ENOMEM;
|
||||
}
|
||||
|
||||
config_numa->dev_num = 0;
|
||||
config_numa++;
|
||||
}
|
||||
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int wd_alloc_numa(struct wd_env_config *config,
|
||||
+ const struct wd_alg_ops *ops)
|
||||
+{
|
||||
+ struct uacce_dev_list *head;
|
||||
+ int *numa_dev_num;
|
||||
+ int ret, max_node;
|
||||
+
|
||||
+ max_node = numa_max_node() + 1;
|
||||
+ if (max_node <= 0)
|
||||
+ return -WD_EINVAL;
|
||||
+
|
||||
+ numa_dev_num = calloc(max_node, sizeof(int));
|
||||
+ if (!numa_dev_num)
|
||||
+ return -WD_ENOMEM;
|
||||
+
|
||||
+ /* get uacce_dev */
|
||||
+ head = wd_get_accel_list(ops->alg_name);
|
||||
+ if (!head) {
|
||||
+ WD_ERR("no device to support %s\n", ops->alg_name);
|
||||
+ ret = -WD_ENODEV;
|
||||
+ goto free_numa_dev_num;
|
||||
+ }
|
||||
+
|
||||
+ /* get numa num and device num of each numa from uacce_dev list */
|
||||
+ config->numa_num = wd_get_dev_numa(head, numa_dev_num, max_node);
|
||||
+ if (config->numa_num == 0 || config->numa_num > max_node) {
|
||||
+ WD_ERR("numa num err(%u)!\n", config->numa_num);
|
||||
+ ret = -WD_ENODEV;
|
||||
+ goto free_list;
|
||||
+ }
|
||||
+
|
||||
+ /* alloc and init config_per_numa and all uacce dev */
|
||||
+ ret = wd_set_config_numa(config, numa_dev_num, max_node);
|
||||
+ if (ret)
|
||||
+ goto free_list;
|
||||
+
|
||||
/* set device and device num for config numa from uacce_dev list */
|
||||
wd_set_numa_dev(head, config);
|
||||
wd_free_list_accels(head);
|
||||
+ free(numa_dev_num);
|
||||
|
||||
return 0;
|
||||
|
||||
-free_mem:
|
||||
- wd_free_numa(config);
|
||||
free_list:
|
||||
wd_free_list_accels(head);
|
||||
+free_numa_dev_num:
|
||||
+ free(numa_dev_num);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -981,18 +1003,22 @@ static int wd_sched_fill_table(struct wd_env_config_per_numa *config_numa,
|
||||
static int wd_init_sched_config(struct wd_env_config *config)
|
||||
{
|
||||
struct wd_env_config_per_numa *config_numa;
|
||||
+ int i, j, ret, max_node, type_num;
|
||||
struct wd_sched *sched;
|
||||
- int type_num = config->op_type_num;
|
||||
- int i, j, ret;
|
||||
void *func = NULL;
|
||||
|
||||
+ max_node = numa_max_node() + 1;
|
||||
+ if (max_node <= 0)
|
||||
+ return -WD_EINVAL;
|
||||
+
|
||||
if (!config->enable_internal_poll)
|
||||
func = config->alg_poll_ctx;
|
||||
|
||||
config->internal_sched = false;
|
||||
+ type_num = config->op_type_num;
|
||||
if (!config->sched) {
|
||||
config->sched = wd_sched_rr_alloc(SCHED_POLICY_RR, type_num,
|
||||
- MAX_NUMA_NUM, func);
|
||||
+ max_node, func);
|
||||
if (!config->sched)
|
||||
return -WD_ENOMEM;
|
||||
|
||||
--
|
||||
2.31.1
|
||||
|
||||
27
0013-uadk-mempool-remove-MISC_DVE_UACCE_CTRL.patch
Normal file
27
0013-uadk-mempool-remove-MISC_DVE_UACCE_CTRL.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From cf1b23feddeba22869d35d5f1fa4b4675f9b8984 Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:07:26 +0800
|
||||
Subject: [PATCH 15/28] uadk: mempool: remove MISC_DVE_UACCE_CTRL
|
||||
|
||||
MISC_DVE_UACCE_CTRL is no longer used, clean it.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_mempool.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/wd_mempool.c b/wd_mempool.c
|
||||
index 2462560..bbf5edb 100644
|
||||
--- a/wd_mempool.c
|
||||
+++ b/wd_mempool.c
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#define SYSFS_NODE_PATH "/sys/devices/system/node/node"
|
||||
#define MAX_HP_STR_SIZE 64
|
||||
-#define MISC_DVE_UACCE_CTRL "/dev/uacce_ctrl"
|
||||
#define HUGETLB_FLAG_ENCODE_SHIFT 26
|
||||
|
||||
#define BITS_PER_LONG ((unsigned int)sizeof(unsigned long) * 8)
|
||||
--
|
||||
2.31.1
|
||||
|
||||
32
0014-uadk-mempool-check-stats-null-pointer.patch
Normal file
32
0014-uadk-mempool-check-stats-null-pointer.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 80fd67d79a66c45171890460ed8a8cc8bc83bb7a Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:07:28 +0800
|
||||
Subject: [PATCH 16/28] uadk: mempool: check stats null pointer
|
||||
|
||||
If user input's stats is null pointer, it will cause
|
||||
a segment fault, fix it.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_mempool.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/wd_mempool.c b/wd_mempool.c
|
||||
index bbf5edb..b6e1088 100644
|
||||
--- a/wd_mempool.c
|
||||
+++ b/wd_mempool.c
|
||||
@@ -958,6 +958,11 @@ void wd_mempool_stats(handle_t mempool, struct wd_mempool_stats *stats)
|
||||
return;
|
||||
}
|
||||
|
||||
+ if (!stats) {
|
||||
+ WD_ERR("wd_mempool: mempool stats is NULL\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
wd_spinlock(&mp->lock);
|
||||
|
||||
stats->page_type = mp->page_type;
|
||||
--
|
||||
2.31.1
|
||||
|
||||
29
0015-uadk-fix-wd_get_config_numa-info.patch
Normal file
29
0015-uadk-fix-wd_get_config_numa-info.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 19add2ea6da8525bafb8fb2747965cbb55dbea75 Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:07:29 +0800
|
||||
Subject: [PATCH 17/28] uadk: fix wd_get_config_numa info
|
||||
|
||||
wd_get_config_numa is used to get config numa
|
||||
by node id, not set a numa dev.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_util.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index 3a1def5..faaf821 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -391,7 +391,7 @@ static void wd_set_numa_dev(struct uacce_dev_list *head,
|
||||
while (list) {
|
||||
config_numa = wd_get_config_numa(config, list->dev->numa_id);
|
||||
if (!config_numa) {
|
||||
- WD_ERR("set numa dev err!\n");
|
||||
+ WD_ERR("%s got wrong numa node!\n", __func__);
|
||||
break;
|
||||
}
|
||||
|
||||
--
|
||||
2.31.1
|
||||
|
||||
46
0016-uadk-fix-static-check-warning.patch
Normal file
46
0016-uadk-fix-static-check-warning.patch
Normal file
@ -0,0 +1,46 @@
|
||||
From 0feee4ccc2b3d0f60d84d39310fc1f85a3d28d63 Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:07:30 +0800
|
||||
Subject: [PATCH 18/28] uadk: fix static check warning
|
||||
|
||||
1.set null pointer after free.
|
||||
2.define const pointer.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_sched.c | 4 +++-
|
||||
wd_util.c | 2 +-
|
||||
2 files changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/wd_sched.c b/wd_sched.c
|
||||
index b310077..3330a4d 100644
|
||||
--- a/wd_sched.c
|
||||
+++ b/wd_sched.c
|
||||
@@ -406,8 +406,10 @@ void wd_sched_rr_release(struct wd_sched *sched)
|
||||
sched_info = sched_ctx->sched_info;
|
||||
for (i = 0; i < sched_ctx->numa_num; i++) {
|
||||
for (j = 0; j < SCHED_MODE_BUTT; j++) {
|
||||
- if (sched_info[i].ctx_region[j])
|
||||
+ if (sched_info[i].ctx_region[j]) {
|
||||
free(sched_info[i].ctx_region[j]);
|
||||
+ sched_info[i].ctx_region[j] = NULL;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index faaf821..62f9359 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -403,7 +403,7 @@ static void wd_set_numa_dev(struct uacce_dev_list *head,
|
||||
}
|
||||
|
||||
static int wd_set_config_numa(struct wd_env_config *config,
|
||||
- int *numa_dev_num, int max_node)
|
||||
+ const int *numa_dev_num, int max_node)
|
||||
{
|
||||
struct wd_env_config_per_numa *config_numa;
|
||||
int i;
|
||||
--
|
||||
2.31.1
|
||||
|
||||
69
0017-uadk-fix-numa-array-use-too-much-stack-space.patch
Normal file
69
0017-uadk-fix-numa-array-use-too-much-stack-space.patch
Normal file
@ -0,0 +1,69 @@
|
||||
From 4a15745d3544eae2c41419d5fb64802e2a16a9f5 Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:07:31 +0800
|
||||
Subject: [PATCH 19/28] uadk: fix numa array use too much stack space
|
||||
|
||||
numa array will take 32768 bytes, too big for
|
||||
a process, replace it by check numa invalid status.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_sched.c | 19 ++++++++++++-------
|
||||
1 file changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/wd_sched.c b/wd_sched.c
|
||||
index 3330a4d..f97c15f 100644
|
||||
--- a/wd_sched.c
|
||||
+++ b/wd_sched.c
|
||||
@@ -202,10 +202,8 @@ static int session_sched_poll_policy(handle_t sched_ctx,
|
||||
{
|
||||
struct wd_sched_ctx *ctx = (struct wd_sched_ctx *)sched_ctx;
|
||||
struct wd_sched_info *sched_info;
|
||||
- __u16 numa[NUMA_NUM_NODES];
|
||||
__u32 loop_time = 0;
|
||||
__u32 last_count = 0;
|
||||
- __u16 tail = 0;
|
||||
__u16 i;
|
||||
int ret;
|
||||
|
||||
@@ -220,9 +218,6 @@ static int session_sched_poll_policy(handle_t sched_ctx,
|
||||
}
|
||||
|
||||
sched_info = ctx->sched_info;
|
||||
- for (i = 0; i < ctx->numa_num; i++)
|
||||
- if (sched_info[i].valid)
|
||||
- numa[tail++]= i;
|
||||
|
||||
/*
|
||||
* Try different numa's ctx if we can't receive any
|
||||
@@ -231,15 +226,25 @@ static int session_sched_poll_policy(handle_t sched_ctx,
|
||||
*/
|
||||
while (loop_time < MAX_POLL_TIMES) {
|
||||
loop_time++;
|
||||
- for (i = 0; i < tail;) {
|
||||
+ for (i = 0; i < ctx->numa_num;) {
|
||||
+ /* If current numa is not valid, find next. */
|
||||
+ if (!sched_info[i].valid) {
|
||||
+ i++;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
last_count = *count;
|
||||
- ret = session_poll_policy_rr(ctx, numa[i], expect, count);
|
||||
+ ret = session_poll_policy_rr(ctx, i, expect, count);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (expect == *count)
|
||||
return 0;
|
||||
|
||||
+ /*
|
||||
+ * If no package is received, find next numa,
|
||||
+ * otherwise, keep receiving packets at this node.
|
||||
+ */
|
||||
if (last_count == *count)
|
||||
i++;
|
||||
}
|
||||
--
|
||||
2.31.1
|
||||
|
||||
86
0018-uadk-fix-get_dev_info.patch
Normal file
86
0018-uadk-fix-get_dev_info.patch
Normal file
@ -0,0 +1,86 @@
|
||||
From 34b4dcc70a808c286378a9b6aeb72d5ba88493ef Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:07:32 +0800
|
||||
Subject: [PATCH 20/28] uadk: fix get_dev_info
|
||||
|
||||
Fix for get_int_attr and get_str_attr
|
||||
return value is not checked in get_dev_info.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd.c | 43 +++++++++++++++++++++++++++++++++----------
|
||||
1 file changed, 33 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/wd.c b/wd.c
|
||||
index 2bb2fdd..25386d7 100644
|
||||
--- a/wd.c
|
||||
+++ b/wd.c
|
||||
@@ -137,23 +137,43 @@ static int get_dev_info(struct uacce_dev *dev)
|
||||
int value = 0;
|
||||
int ret;
|
||||
|
||||
- get_int_attr(dev, "flags", &dev->flags);
|
||||
- get_str_attr(dev, "api", dev->api, WD_NAME_SIZE);
|
||||
-
|
||||
/* hardware err isolate flag */
|
||||
ret = access_attr(dev->dev_root, "isolate", F_OK);
|
||||
if (!ret) {
|
||||
- get_int_attr(dev, "isolate", &value);
|
||||
- if (value == 1)
|
||||
+ ret = get_int_attr(dev, "isolate", &value);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ else if (value == 1)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
- get_str_attr(dev, "algorithms", dev->algs, MAX_ATTR_STR_SIZE);
|
||||
- get_int_attr(dev, "region_mmio_size", &value);
|
||||
+ ret = get_int_attr(dev, "flags", &dev->flags);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = get_int_attr(dev, "region_mmio_size", &value);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
dev->qfrs_offs[UACCE_QFRT_MMIO] = value;
|
||||
- get_int_attr(dev, "region_dus_size", &value);
|
||||
+
|
||||
+ ret = get_int_attr(dev, "region_dus_size", &value);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
dev->qfrs_offs[UACCE_QFRT_DUS] = value;
|
||||
- get_int_attr(dev, "device/numa_node", &dev->numa_id);
|
||||
+
|
||||
+ ret = get_int_attr(dev, "device/numa_node", &dev->numa_id);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = get_str_attr(dev, "api", dev->api, WD_NAME_SIZE);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = get_str_attr(dev, "algorithms", dev->algs, MAX_ATTR_STR_SIZE);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -195,8 +215,11 @@ static struct uacce_dev *read_uacce_sysfs(const char *dev_name)
|
||||
goto out_dir;
|
||||
|
||||
ret = get_dev_info(dev);
|
||||
- if (ret)
|
||||
+ if (ret) {
|
||||
+ WD_ERR("failed to get dev info: ret = %d!\n", ret);
|
||||
goto out_dir;
|
||||
+ }
|
||||
+
|
||||
break;
|
||||
}
|
||||
if (!dev_dir)
|
||||
--
|
||||
2.31.1
|
||||
|
||||
92
0019-uadk-fix-pthread_spin_init.patch
Normal file
92
0019-uadk-fix-pthread_spin_init.patch
Normal file
@ -0,0 +1,92 @@
|
||||
From 913a84cbdce651aea50a6e12117ee93ccbbdbf1c Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:07:33 +0800
|
||||
Subject: [PATCH 21/28] uadk: fix pthread_spin_init
|
||||
|
||||
pthread_spin_init() may fail with errors,
|
||||
check return value for it.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
drv/hisi_qm_udrv.c | 16 ++++++++++++----
|
||||
wd_util.c | 9 +++++++--
|
||||
2 files changed, 19 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
|
||||
index 8282c51..845fa46 100644
|
||||
--- a/drv/hisi_qm_udrv.c
|
||||
+++ b/drv/hisi_qm_udrv.c
|
||||
@@ -298,7 +298,7 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
|
||||
ret = hisi_qm_get_qfrs_offs(qp->h_ctx, q_info);
|
||||
if (ret) {
|
||||
WD_ERR("get dev qfrs offset fail.\n");
|
||||
- return ret;
|
||||
+ goto err_out;
|
||||
}
|
||||
|
||||
ret = hisi_qm_setup_db(qp->h_ctx, q_info);
|
||||
@@ -323,7 +323,11 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
|
||||
q_info->region_size[UACCE_QFRT_DUS] - sizeof(uint32_t);
|
||||
q_info->ds_rx_base = q_info->ds_tx_base - sizeof(uint32_t);
|
||||
|
||||
- pthread_spin_init(&q_info->lock, PTHREAD_PROCESS_SHARED);
|
||||
+ ret = pthread_spin_init(&q_info->lock, PTHREAD_PROCESS_SHARED);
|
||||
+ if (ret) {
|
||||
+ WD_ERR("init qinfo lock fail\n");
|
||||
+ goto err_out;
|
||||
+ }
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -560,7 +564,7 @@ static struct hisi_sgl *hisi_qm_align_sgl(const void *sgl, __u32 sge_num)
|
||||
handle_t hisi_qm_create_sglpool(__u32 sgl_num, __u32 sge_num)
|
||||
{
|
||||
struct hisi_sgl_pool *sgl_pool;
|
||||
- int i;
|
||||
+ int i, ret;
|
||||
|
||||
if (!sgl_num || !sge_num || sge_num > HISI_SGE_NUM_IN_SGL) {
|
||||
WD_ERR("create sgl_pool failed, sgl_num=%u, sge_num=%u\n",
|
||||
@@ -601,7 +605,11 @@ handle_t hisi_qm_create_sglpool(__u32 sgl_num, __u32 sge_num)
|
||||
sgl_pool->sge_num = sge_num;
|
||||
sgl_pool->depth = sgl_num;
|
||||
sgl_pool->top = sgl_num;
|
||||
- pthread_spin_init(&sgl_pool->lock, PTHREAD_PROCESS_SHARED);
|
||||
+ ret = pthread_spin_init(&sgl_pool->lock, PTHREAD_PROCESS_SHARED);
|
||||
+ if (ret) {
|
||||
+ WD_ERR("init sgl pool lock failed.\n");
|
||||
+ goto err_out;
|
||||
+ }
|
||||
|
||||
return (handle_t)sgl_pool;
|
||||
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index 62f9359..83c77c4 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -68,7 +68,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
|
||||
struct wd_ctx_config *cfg)
|
||||
{
|
||||
struct wd_ctx_internal *ctxs;
|
||||
- int i;
|
||||
+ int i, ret;
|
||||
|
||||
if (!cfg->ctx_num) {
|
||||
WD_ERR("invalid parameters, ctx_num is 0!\n");
|
||||
@@ -93,7 +93,12 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
|
||||
}
|
||||
|
||||
clone_ctx_to_internal(cfg->ctxs + i, ctxs + i);
|
||||
- pthread_spin_init(&ctxs[i].lock, PTHREAD_PROCESS_SHARED);
|
||||
+ ret = pthread_spin_init(&ctxs[i].lock, PTHREAD_PROCESS_SHARED);
|
||||
+ if (ret) {
|
||||
+ WD_ERR("init ctxs lock failed!\n");
|
||||
+ free(ctxs);
|
||||
+ return ret;
|
||||
+ }
|
||||
}
|
||||
|
||||
in->ctxs = ctxs;
|
||||
--
|
||||
2.31.1
|
||||
|
||||
69
0020-uadk-env-optimize-find_async_queue.patch
Normal file
69
0020-uadk-env-optimize-find_async_queue.patch
Normal file
@ -0,0 +1,69 @@
|
||||
From 1c037d1a257714802890f83aaa970fc140786915 Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:07:34 +0800
|
||||
Subject: [PATCH 22/28] uadk: env: optimize find_async_queue
|
||||
|
||||
No need to find ctx idx from begin to end,
|
||||
if it is in ctx range, calculate its offset
|
||||
from begin ctx.
|
||||
If offset not set, find_async_queue should
|
||||
return NULL.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_util.c | 29 ++++++++++++++---------------
|
||||
1 file changed, 14 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index 83c77c4..ee1c084 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -1061,7 +1061,9 @@ static struct async_task_queue *find_async_queue(struct wd_env_config *config,
|
||||
struct wd_env_config_per_numa *config_numa;
|
||||
struct wd_ctx_range **ctx_table;
|
||||
struct async_task_queue *head;
|
||||
- int i, j, n = -1, num = 0;
|
||||
+ int offset = -1;
|
||||
+ int num = 0;
|
||||
+ int i;
|
||||
|
||||
FOREACH_NUMA(i, config, config_numa) {
|
||||
num += config_numa->sync_ctx_num + config_numa->async_ctx_num;
|
||||
@@ -1074,23 +1076,20 @@ static struct async_task_queue *find_async_queue(struct wd_env_config *config,
|
||||
|
||||
ctx_table = config_numa->ctx_table;
|
||||
for (i = 0; i < config_numa->op_type_num; i++) {
|
||||
- for (j = ctx_table[CTX_MODE_ASYNC][i].begin;
|
||||
- j <= ctx_table[CTX_MODE_ASYNC][i].end;
|
||||
- j++) {
|
||||
- if (j == idx) {
|
||||
- n = j - ctx_table[CTX_MODE_ASYNC][i].begin;
|
||||
- if (n >= config_numa->async_poll_num)
|
||||
- n = n % config_numa->async_poll_num;
|
||||
- break;
|
||||
- }
|
||||
+ if (idx <= ctx_table[CTX_MODE_ASYNC][i].end &&
|
||||
+ idx >= ctx_table[CTX_MODE_ASYNC][i].begin) {
|
||||
+ offset = idx - ctx_table[CTX_MODE_ASYNC][i].begin;
|
||||
+ if (offset >= config_numa->async_poll_num)
|
||||
+ offset = offset % config_numa->async_poll_num;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ if (offset < 0)
|
||||
+ return NULL;
|
||||
+
|
||||
head = (struct async_task_queue *)config_numa->async_task_queue_array;
|
||||
- if (n >= 0) {
|
||||
- head += n;
|
||||
- return head;
|
||||
- }
|
||||
- return head;
|
||||
+
|
||||
+ return head + offset;
|
||||
}
|
||||
|
||||
/* fix me: all return value here, and no config input */
|
||||
--
|
||||
2.31.1
|
||||
|
||||
175
0021-uadk-env-optimize-some-function.patch
Normal file
175
0021-uadk-env-optimize-some-function.patch
Normal file
@ -0,0 +1,175 @@
|
||||
From a98e9a6092ae5af499353a739f30506bee7db73f Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 12:15:29 +0800
|
||||
Subject: [PATCH 23/28] uadk: env: optimize some function
|
||||
|
||||
1.find_async_queue add some abnormal branch judgment
|
||||
2.wd_init_async_polling_thread_per_numa use queue_head
|
||||
to save a task queue head.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_util.c | 71 ++++++++++++++++++++++++++++++++-----------------------
|
||||
1 file changed, 41 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index ee1c084..49e1d66 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -1061,7 +1061,7 @@ static struct async_task_queue *find_async_queue(struct wd_env_config *config,
|
||||
struct wd_env_config_per_numa *config_numa;
|
||||
struct wd_ctx_range **ctx_table;
|
||||
struct async_task_queue *head;
|
||||
- int offset = -1;
|
||||
+ unsigned long offset;
|
||||
int num = 0;
|
||||
int i;
|
||||
|
||||
@@ -1071,8 +1071,15 @@ static struct async_task_queue *find_async_queue(struct wd_env_config *config,
|
||||
break;
|
||||
}
|
||||
|
||||
- if (i == config->numa_num)
|
||||
+ if (i == config->numa_num) {
|
||||
+ WD_ERR("failed to find a proper numa node!\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (!config_numa->async_poll_num) {
|
||||
+ WD_ERR("invalid parameter, async_poll_num of numa is zero!\n");
|
||||
return NULL;
|
||||
+ }
|
||||
|
||||
ctx_table = config_numa->ctx_table;
|
||||
for (i = 0; i < config_numa->op_type_num; i++) {
|
||||
@@ -1081,11 +1088,15 @@ static struct async_task_queue *find_async_queue(struct wd_env_config *config,
|
||||
offset = idx - ctx_table[CTX_MODE_ASYNC][i].begin;
|
||||
if (offset >= config_numa->async_poll_num)
|
||||
offset = offset % config_numa->async_poll_num;
|
||||
+
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
|
||||
- if (offset < 0)
|
||||
+ if (i == config_numa->op_type_num) {
|
||||
+ WD_ERR("failed to find async queue for ctx: idx %u!\n", idx);
|
||||
return NULL;
|
||||
+ }
|
||||
|
||||
head = (struct async_task_queue *)config_numa->async_task_queue_array;
|
||||
|
||||
@@ -1193,18 +1204,18 @@ static int wd_init_one_task_queue(struct async_task_queue *task_queue,
|
||||
void *alg_poll_ctx)
|
||||
|
||||
{
|
||||
- struct async_task *head;
|
||||
+ struct async_task *task_head;
|
||||
pthread_t thread_id;
|
||||
pthread_attr_t attr;
|
||||
int depth, ret;
|
||||
|
||||
task_queue->depth = depth = WD_ASYNC_DEF_QUEUE_DEPTH;
|
||||
|
||||
- head = calloc(task_queue->depth, sizeof(*head));
|
||||
- if (!head)
|
||||
+ task_head = calloc(task_queue->depth, sizeof(struct async_task));
|
||||
+ if (!task_head)
|
||||
return -WD_ENOMEM;
|
||||
|
||||
- task_queue->head = head;
|
||||
+ task_queue->head = task_head;
|
||||
task_queue->left_task = depth;
|
||||
task_queue->alg_poll_ctx = alg_poll_ctx;
|
||||
|
||||
@@ -1245,7 +1256,7 @@ err_uninit_full_sem:
|
||||
err_uninit_empty_sem:
|
||||
sem_destroy(&task_queue->empty_sem);
|
||||
err_free_head:
|
||||
- free(head);
|
||||
+ free(task_head);
|
||||
ret = -errno;
|
||||
return ret;
|
||||
}
|
||||
@@ -1272,45 +1283,45 @@ static void wd_uninit_one_task_queue(struct async_task_queue *task_queue)
|
||||
static int wd_init_async_polling_thread_per_numa(struct wd_env_config *config,
|
||||
struct wd_env_config_per_numa *config_numa)
|
||||
{
|
||||
- struct async_task_queue *task_queue, *head;
|
||||
- int i, j, n, ret;
|
||||
+ struct async_task_queue *task_queue, *queue_head;
|
||||
+ int i, j, poll_thread_num, ret;
|
||||
|
||||
if (!config_numa->async_ctx_num)
|
||||
return 0;
|
||||
|
||||
- if (config_numa->async_poll_num <= 0) {
|
||||
- WD_ERR("Invalid async poll number (%ld) is set.\n",
|
||||
+ if (!config_numa->async_poll_num) {
|
||||
+ WD_ERR("invalid async poll num (%lu) is set.\n",
|
||||
config_numa->async_poll_num);
|
||||
- WD_ERR("Change to default value: %d\n", WD_ASYNC_DEF_POLL_NUM);
|
||||
+ WD_ERR("change to default value: %d\n", WD_ASYNC_DEF_POLL_NUM);
|
||||
config_numa->async_poll_num = WD_ASYNC_DEF_POLL_NUM;
|
||||
}
|
||||
|
||||
+ poll_thread_num = config_numa->async_poll_num;
|
||||
+ if (poll_thread_num > config_numa->async_ctx_num) {
|
||||
+ poll_thread_num = config_numa->async_ctx_num;
|
||||
+ WD_ERR("downgrade poll thread num from %lu to %lu.\n",
|
||||
+ config_numa->async_poll_num,
|
||||
+ config_numa->async_ctx_num);
|
||||
+ }
|
||||
+
|
||||
/* make max task queues as the number of async ctxs */
|
||||
- task_queue = calloc(config_numa->async_ctx_num, sizeof(*head));
|
||||
- if (!task_queue)
|
||||
+ queue_head = calloc(config_numa->async_ctx_num, sizeof(*queue_head));
|
||||
+ if (!queue_head)
|
||||
return -WD_ENOMEM;
|
||||
- head = task_queue;
|
||||
- config_numa->async_task_queue_array = (void *)head;
|
||||
|
||||
- if (config_numa->async_poll_num > config_numa->async_ctx_num) {
|
||||
- n = config_numa->async_ctx_num;
|
||||
- WD_ERR("Can't create more async polling threads than the "
|
||||
- "number of ctx number. Downgrade it from %ld to %ld.\n",
|
||||
- config_numa->async_poll_num,
|
||||
- config_numa->async_ctx_num);
|
||||
- } else
|
||||
- n = config_numa->async_poll_num;
|
||||
- for (i = 0; i < n; task_queue++, i++) {
|
||||
+ task_queue = queue_head;
|
||||
+ for (i = 0; i < poll_thread_num; task_queue++, i++) {
|
||||
ret = wd_init_one_task_queue(task_queue, config->alg_poll_ctx);
|
||||
if (ret) {
|
||||
- task_queue = head;
|
||||
for (j = 0; j < i; task_queue++, j++)
|
||||
wd_uninit_one_task_queue(task_queue);
|
||||
- free(head);
|
||||
+ free(queue_head);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
+ config_numa->async_task_queue_array = (void *)queue_head;
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1322,10 +1333,10 @@ static void wd_uninit_async_polling_thread_per_numa(struct wd_env_config *cfg,
|
||||
|
||||
head = config_numa->async_task_queue_array;
|
||||
task_queue = head;
|
||||
+ n = config_numa->async_poll_num;
|
||||
if (config_numa->async_poll_num > config_numa->async_ctx_num)
|
||||
n = config_numa->async_ctx_num;
|
||||
- else
|
||||
- n = config_numa->async_poll_num;
|
||||
+
|
||||
for (i = 0; i < n; task_queue++, i++)
|
||||
wd_uninit_one_task_queue(task_queue);
|
||||
free(head);
|
||||
--
|
||||
2.31.1
|
||||
|
||||
37
0022-uadk-v1-delete-unused-parameter.patch
Normal file
37
0022-uadk-v1-delete-unused-parameter.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From 09db34533df0920fe0102e85ab573038ad69bf2d Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 20:34:50 +0800
|
||||
Subject: [PATCH 24/28] uadk: v1: delete unused parameter
|
||||
|
||||
capa is not used in copy_if_better.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
v1/wd.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/v1/wd.c b/v1/wd.c
|
||||
index 6568243..26f6692 100644
|
||||
--- a/v1/wd.c
|
||||
+++ b/v1/wd.c
|
||||
@@ -349,7 +349,7 @@ static int get_dev_info(struct dev_info *dinfo, const char *alg)
|
||||
}
|
||||
|
||||
static bool copy_if_better(struct dev_info *old, struct dev_info *new,
|
||||
- struct wd_capa *capa, unsigned int node_mask)
|
||||
+ unsigned int node_mask)
|
||||
{
|
||||
bool find_node = false;
|
||||
|
||||
@@ -437,7 +437,7 @@ static int find_available_dev(struct dev_info *dinfop,
|
||||
ret = get_dev_info(&dinfo, capa->alg);
|
||||
if (!ret) {
|
||||
cnt++;
|
||||
- if (copy_if_better(dinfop, &dinfo, capa, node_mask)) {
|
||||
+ if (copy_if_better(dinfop, &dinfo, node_mask)) {
|
||||
find_node = true;
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.31.1
|
||||
|
||||
212
0023-uadk-env-fix-wd_add_task_to_async_queue-return-value.patch
Normal file
212
0023-uadk-env-fix-wd_add_task_to_async_queue-return-value.patch
Normal file
@ -0,0 +1,212 @@
|
||||
From d827ac994867b2dd06d5723d62c6c618f0c5c77b Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 20:34:51 +0800
|
||||
Subject: [PATCH 25/28] uadk: env: fix wd_add_task_to_async_queue return value
|
||||
|
||||
wd_add_task_to_async_queue may fail with error code,
|
||||
add return value check after call it.
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_aead.c | 10 ++++++++--
|
||||
wd_cipher.c | 10 ++++++++--
|
||||
wd_comp.c | 4 +++-
|
||||
wd_dh.c | 6 ++++--
|
||||
wd_digest.c | 11 ++++++++---
|
||||
wd_ecc.c | 6 ++++--
|
||||
wd_rsa.c | 6 ++++--
|
||||
wd_util.c | 20 +++++++++++++-------
|
||||
8 files changed, 52 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/wd_aead.c b/wd_aead.c
|
||||
index f93f791..ebad440 100644
|
||||
--- a/wd_aead.c
|
||||
+++ b/wd_aead.c
|
||||
@@ -596,11 +596,17 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
|
||||
if (ret != -WD_EBUSY)
|
||||
WD_ERR("failed to send BD, hw is err!\n");
|
||||
|
||||
- wd_put_msg_to_pool(&wd_aead_setting.pool, idx, msg->tag);
|
||||
+ goto fail_with_msg;
|
||||
}
|
||||
|
||||
- wd_add_task_to_async_queue(&wd_aead_env_config, idx);
|
||||
+ ret = wd_add_task_to_async_queue(&wd_aead_env_config, idx);
|
||||
+ if (ret)
|
||||
+ goto fail_with_msg;
|
||||
+
|
||||
+ return 0;
|
||||
|
||||
+fail_with_msg:
|
||||
+ wd_put_msg_to_pool(&wd_aead_setting.pool, idx, msg->tag);
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/wd_cipher.c b/wd_cipher.c
|
||||
index 9977765..9c1f98c 100644
|
||||
--- a/wd_cipher.c
|
||||
+++ b/wd_cipher.c
|
||||
@@ -515,11 +515,17 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req)
|
||||
if (ret != -WD_EBUSY)
|
||||
WD_ERR("wd cipher async send err!\n");
|
||||
|
||||
- wd_put_msg_to_pool(&wd_cipher_setting.pool, idx, msg->tag);
|
||||
+ goto fail_with_msg;
|
||||
}
|
||||
|
||||
- wd_add_task_to_async_queue(&wd_cipher_env_config, idx);
|
||||
+ ret = wd_add_task_to_async_queue(&wd_cipher_env_config, idx);
|
||||
+ if (ret)
|
||||
+ goto fail_with_msg;
|
||||
+
|
||||
+ return 0;
|
||||
|
||||
+fail_with_msg:
|
||||
+ wd_put_msg_to_pool(&wd_cipher_setting.pool, idx, msg->tag);
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/wd_comp.c b/wd_comp.c
|
||||
index e34d590..fc355a9 100644
|
||||
--- a/wd_comp.c
|
||||
+++ b/wd_comp.c
|
||||
@@ -724,7 +724,9 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||
|
||||
pthread_spin_unlock(&ctx->lock);
|
||||
|
||||
- wd_add_task_to_async_queue(&wd_comp_env_config, idx);
|
||||
+ 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);
|
||||
|
||||
return ret;
|
||||
}
|
||||
diff --git a/wd_dh.c b/wd_dh.c
|
||||
index 177ffad..7b849ac 100644
|
||||
--- a/wd_dh.c
|
||||
+++ b/wd_dh.c
|
||||
@@ -341,9 +341,11 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req)
|
||||
}
|
||||
pthread_spin_unlock(&ctx->lock);
|
||||
|
||||
- wd_add_task_to_async_queue(&wd_dh_env_config, idx);
|
||||
+ ret = wd_add_task_to_async_queue(&wd_dh_env_config, idx);
|
||||
+ if (ret)
|
||||
+ goto fail_with_msg;
|
||||
|
||||
- return ret;
|
||||
+ return 0;
|
||||
|
||||
fail_with_msg:
|
||||
wd_put_msg_to_pool(&wd_dh_setting.pool, idx, mid);
|
||||
diff --git a/wd_digest.c b/wd_digest.c
|
||||
index bbb258f..2b3661d 100644
|
||||
--- a/wd_digest.c
|
||||
+++ b/wd_digest.c
|
||||
@@ -420,13 +420,18 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
|
||||
if (ret != -WD_EBUSY)
|
||||
WD_ERR("failed to send BD, hw is err!\n");
|
||||
|
||||
- wd_put_msg_to_pool(&wd_digest_setting.pool, idx, msg->tag);
|
||||
- return ret;
|
||||
+ goto fail_with_msg;
|
||||
}
|
||||
|
||||
- wd_add_task_to_async_queue(&wd_digest_env_config, idx);
|
||||
+ ret = wd_add_task_to_async_queue(&wd_digest_env_config, idx);
|
||||
+ if (ret)
|
||||
+ goto fail_with_msg;
|
||||
|
||||
return 0;
|
||||
+
|
||||
+fail_with_msg:
|
||||
+ wd_put_msg_to_pool(&wd_digest_setting.pool, idx, msg->tag);
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
int wd_digest_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||
diff --git a/wd_ecc.c b/wd_ecc.c
|
||||
index 8b625e4..e37fb39 100644
|
||||
--- a/wd_ecc.c
|
||||
+++ b/wd_ecc.c
|
||||
@@ -2187,9 +2187,11 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req)
|
||||
}
|
||||
pthread_spin_unlock(&ctx->lock);
|
||||
|
||||
- wd_add_task_to_async_queue(&wd_ecc_env_config, idx);
|
||||
+ ret = wd_add_task_to_async_queue(&wd_ecc_env_config, idx);
|
||||
+ if (ret)
|
||||
+ goto fail_with_msg;
|
||||
|
||||
- return ret;
|
||||
+ return 0;
|
||||
|
||||
fail_with_msg:
|
||||
wd_put_msg_to_pool(&wd_ecc_setting.pool, idx, mid);
|
||||
diff --git a/wd_rsa.c b/wd_rsa.c
|
||||
index 2831111..b6cc0d1 100644
|
||||
--- a/wd_rsa.c
|
||||
+++ b/wd_rsa.c
|
||||
@@ -397,9 +397,11 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req)
|
||||
if (ret)
|
||||
goto fail_with_msg;
|
||||
|
||||
- wd_add_task_to_async_queue(&wd_rsa_env_config, idx);
|
||||
+ ret = wd_add_task_to_async_queue(&wd_rsa_env_config, idx);
|
||||
+ if (ret)
|
||||
+ goto fail_with_msg;
|
||||
|
||||
- return ret;
|
||||
+ return 0;
|
||||
|
||||
fail_with_msg:
|
||||
wd_put_msg_to_pool(&wd_rsa_setting.pool, idx, mid);
|
||||
diff --git a/wd_util.c b/wd_util.c
|
||||
index 49e1d66..e04747b 100644
|
||||
--- a/wd_util.c
|
||||
+++ b/wd_util.c
|
||||
@@ -1108,17 +1108,20 @@ int wd_add_task_to_async_queue(struct wd_env_config *config, __u32 idx)
|
||||
{
|
||||
struct async_task_queue *task_queue;
|
||||
struct async_task *head, *task;
|
||||
- int prod;
|
||||
+ int prod, ret;
|
||||
|
||||
if (!config->enable_internal_poll)
|
||||
return 0;
|
||||
|
||||
task_queue = find_async_queue(config, idx);
|
||||
if (!task_queue)
|
||||
- return 0;
|
||||
+ return -WD_EINVAL;
|
||||
|
||||
- if (sem_wait(&task_queue->empty_sem))
|
||||
- return 0;
|
||||
+ ret = sem_wait(&task_queue->empty_sem);
|
||||
+ if (ret) {
|
||||
+ WD_ERR("failed to wait empty_sem!\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
pthread_mutex_lock(&task_queue->lock);
|
||||
|
||||
@@ -1135,10 +1138,13 @@ int wd_add_task_to_async_queue(struct wd_env_config *config, __u32 idx)
|
||||
|
||||
pthread_mutex_unlock(&task_queue->lock);
|
||||
|
||||
- if (sem_post(&task_queue->full_sem))
|
||||
- return 0;
|
||||
+ ret = sem_post(&task_queue->full_sem);
|
||||
+ if (ret) {
|
||||
+ WD_ERR("failed to post full_sem!\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
- return 1;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static void *async_poll_process_func(void *args)
|
||||
--
|
||||
2.31.1
|
||||
|
||||
36
0024-uadk-sched-fix-memory-leak.patch
Normal file
36
0024-uadk-sched-fix-memory-leak.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From 3ccff1938ec43efa1a4bb3f367d1985e35b91c0e Mon Sep 17 00:00:00 2001
|
||||
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
Date: Thu, 30 Dec 2021 20:34:52 +0800
|
||||
Subject: [PATCH 26/28] uadk: sched: fix memory leak
|
||||
|
||||
sched_ctx and sched must be associated to
|
||||
release the memory of sched_ctx
|
||||
|
||||
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||
---
|
||||
wd_sched.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/wd_sched.c b/wd_sched.c
|
||||
index f97c15f..a85fd95 100644
|
||||
--- a/wd_sched.c
|
||||
+++ b/wd_sched.c
|
||||
@@ -463,6 +463,7 @@ struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
+ sched->h_sched_ctx = (handle_t)sched_ctx;
|
||||
sched_info = sched_ctx->sched_info;
|
||||
|
||||
for (i = 0; i < numa_num; i++) {
|
||||
@@ -482,7 +483,6 @@ struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
|
||||
sched->sched_init = sched_table[sched_type].sched_init;
|
||||
sched->pick_next_ctx = sched_table[sched_type].pick_next_ctx;
|
||||
sched->poll_policy = sched_table[sched_type].poll_policy;
|
||||
- sched->h_sched_ctx = (handle_t)sched_ctx;
|
||||
|
||||
return sched;
|
||||
|
||||
--
|
||||
2.31.1
|
||||
|
||||
47
0025-hisi-sec-bugfix-for-out_bytes-checking.patch
Normal file
47
0025-hisi-sec-bugfix-for-out_bytes-checking.patch
Normal file
@ -0,0 +1,47 @@
|
||||
From 5927f19669247d738dfd4a687b5f134a2d289784 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Wed, 29 Dec 2021 17:14:11 +0800
|
||||
Subject: [PATCH 27/28] hisi-sec: bugfix for out_bytes checking
|
||||
|
||||
1. Add out_bytes checking for digest alg. and modify some log
|
||||
information.
|
||||
2. Optimize the in_bytes length checking.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
drv/hisi_sec.c | 11 ++++++++---
|
||||
1 file changed, 8 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
|
||||
index 603bdda..d31a1b9 100644
|
||||
--- a/drv/hisi_sec.c
|
||||
+++ b/drv/hisi_sec.c
|
||||
@@ -1279,9 +1279,9 @@ static void parse_digest_bd2(struct hisi_sec_sqe *sqe, struct wd_digest_msg *rec
|
||||
|
||||
static int digest_long_bd_check(struct wd_digest_msg *msg)
|
||||
{
|
||||
- if (msg->alg >= WD_DIGEST_SHA512 && msg->in_bytes % SHA512_ALIGN_SZ)
|
||||
+ if (msg->alg >= WD_DIGEST_SHA512 && msg->in_bytes & (SHA512_ALIGN_SZ - 1))
|
||||
return -WD_EINVAL;
|
||||
- else if (msg->in_bytes % SHA1_ALIGN_SZ)
|
||||
+ else if (msg->in_bytes & (SHA1_ALIGN_SZ - 1))
|
||||
return -WD_EINVAL;
|
||||
|
||||
return 0;
|
||||
@@ -1298,7 +1298,12 @@ static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type)
|
||||
}
|
||||
|
||||
if (unlikely(msg->in_bytes > MAX_INPUT_DATA_LEN)) {
|
||||
- WD_ERR("input data length is too long, size:%u!\n", msg->in_bytes);
|
||||
+ WD_ERR("digest input length is too long, size:%u!\n", msg->in_bytes);
|
||||
+ return -WD_EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ if (unlikely(msg->out_bytes & WORD_ALIGNMENT_MASK)) {
|
||||
+ WD_ERR("digest out length is error, size:%u!\n", msg->out_bytes);
|
||||
return -WD_EINVAL;
|
||||
}
|
||||
|
||||
--
|
||||
2.31.1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Name: libwd
|
||||
Summary: User Space Accelerator Development Kit
|
||||
Version: 2.3.21
|
||||
Release: 1
|
||||
Release: 2
|
||||
License: Apache-2.0
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
Vendor: Huawei Corporation
|
||||
@ -14,6 +14,31 @@ BuildRequires: numactl-devel, openssl-devel
|
||||
BuildRequires: automake, autoconf, libtool
|
||||
BuildRequires: gcc, make
|
||||
ExclusiveArch: aarch64
|
||||
Patch0001: 0001-uadk-digest-add-stream-mode-for-digest-sync.patch
|
||||
Patch0002: 0002-test-digest-support-the-digest-stream-mode.patch
|
||||
Patch0003: 0003-aead-cipher-digest-fix-some-code-issues.patch
|
||||
Patch0004: 0004-digest-v1-fixed-hmac-key-0-length-checking.patch
|
||||
Patch0005: 0005-digest-v1-check-the-length-of-the-key-need-to-be-cha.patch
|
||||
Patch0006: 0006-qm-v1-fixup-the-incorrect-configuration-of-the-type.patch
|
||||
Patch0007: 0007-qm-fixup-the-incorrect-configuration-of-the-type.patch
|
||||
Patch0008: 0008-uadk_benchmark-use-the-uadk_tool-instead-of-uadk_ben.patch
|
||||
Patch0009: 0009-digest-some-optimizations-for-digest-stream-mode.patch
|
||||
Patch0010: 0010-uadk-fix-error-of-wd_get_avail_ctx-return-value.patch
|
||||
Patch0011: 0011-uadk-fix-comment-content.patch
|
||||
Patch0012: 0012-uadk-max-numa-number-should-not-be-fixed.patch
|
||||
Patch0013: 0013-uadk-mempool-remove-MISC_DVE_UACCE_CTRL.patch
|
||||
Patch0014: 0014-uadk-mempool-check-stats-null-pointer.patch
|
||||
Patch0015: 0015-uadk-fix-wd_get_config_numa-info.patch
|
||||
Patch0016: 0016-uadk-fix-static-check-warning.patch
|
||||
Patch0017: 0017-uadk-fix-numa-array-use-too-much-stack-space.patch
|
||||
Patch0018: 0018-uadk-fix-get_dev_info.patch
|
||||
Patch0019: 0019-uadk-fix-pthread_spin_init.patch
|
||||
Patch0020: 0020-uadk-env-optimize-find_async_queue.patch
|
||||
Patch0021: 0021-uadk-env-optimize-some-function.patch
|
||||
Patch0022: 0022-uadk-v1-delete-unused-parameter.patch
|
||||
Patch0023: 0023-uadk-env-fix-wd_add_task_to_async_queue-return-value.patch
|
||||
Patch0024: 0024-uadk-sched-fix-memory-leak.patch
|
||||
Patch0025: 0025-hisi-sec-bugfix-for-out_bytes-checking.patch
|
||||
|
||||
%description
|
||||
This package contains the User Space Accelerator Library
|
||||
@ -171,10 +196,13 @@ fi
|
||||
/sbin/ldconfig
|
||||
|
||||
%changelog
|
||||
* Tue Jan 04 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-2
|
||||
- libwd: backport the patch of uadk from 2.3.21 to 2.3.24
|
||||
|
||||
* Mon Dec 06 2021 linwenkai <linwenkai6@hisilicon.com> 2.3.21-1
|
||||
- libwd: update uadk from 2.3.20 to 2.3.21
|
||||
|
||||
* Mon Nov 24 2021 linwenkai <linwenkai6@hisilicon.com> 2.3.20-2
|
||||
* Wed Nov 24 2021 linwenkai <linwenkai6@hisilicon.com> 2.3.20-2
|
||||
- libwd: add missing head files and fix install path
|
||||
|
||||
* Mon Nov 22 2021 Yang Shen <shenyang39@huawei.com> 2.3.20-1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user