libwd backport for uadk from 2.3.29 to 2.3.31
Update some patch for uadk from mainline. To get more infomation, please visit the homepage: https://github.com/Linaro/uadk Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
This commit is contained in:
parent
c7a2ce4a6f
commit
d2ed8a299c
86
0070-rsa-fix-interface-name-and-log-msg.patch
Normal file
86
0070-rsa-fix-interface-name-and-log-msg.patch
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
From 0bcb18fc0c90e6e1ad10a457de5765e7ff609be7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
Date: Wed, 2 Mar 2022 07:15:19 +0000
|
||||||
|
Subject: [PATCH 077/109] rsa: fix interface name and log msg
|
||||||
|
|
||||||
|
wd_rsa_key_bits() is used to get key bits,
|
||||||
|
changing its name to wd_rsa_get_key_bits()
|
||||||
|
can make the semantics clearer.
|
||||||
|
|
||||||
|
Signed-off-by: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||||
|
---
|
||||||
|
include/wd_rsa.h | 2 +-
|
||||||
|
test/hisi_hpre_test/test_hisi_hpre.c | 6 +++---
|
||||||
|
wd_rsa.c | 4 ++--
|
||||||
|
3 files changed, 6 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/include/wd_rsa.h b/include/wd_rsa.h
|
||||||
|
index 081bc2a..0978b79 100644
|
||||||
|
--- a/include/wd_rsa.h
|
||||||
|
+++ b/include/wd_rsa.h
|
||||||
|
@@ -67,7 +67,7 @@ struct wd_rsa_sess_setup {
|
||||||
|
};
|
||||||
|
|
||||||
|
bool wd_rsa_is_crt(handle_t sess);
|
||||||
|
-__u32 wd_rsa_key_bits(handle_t sess);
|
||||||
|
+__u32 wd_rsa_get_key_bits(handle_t sess);
|
||||||
|
void wd_rsa_get_pubkey(handle_t sess, struct wd_rsa_pubkey **pubkey);
|
||||||
|
void wd_rsa_get_prikey(handle_t sess, struct wd_rsa_prikey **prikey);
|
||||||
|
int wd_rsa_set_pubkey_params(handle_t sess, struct wd_dtb *e, struct wd_dtb *n);
|
||||||
|
diff --git a/test/hisi_hpre_test/test_hisi_hpre.c b/test/hisi_hpre_test/test_hisi_hpre.c
|
||||||
|
index 924adb7..57d76fd 100644
|
||||||
|
--- a/test/hisi_hpre_test/test_hisi_hpre.c
|
||||||
|
+++ b/test/hisi_hpre_test/test_hisi_hpre.c
|
||||||
|
@@ -6793,7 +6793,7 @@ static int get_rsa_key_from_test_sample(handle_t sess, char *pubkey_file,
|
||||||
|
memset(&wd_q, 0, sizeof(wd_q));
|
||||||
|
memset(&wd_p, 0, sizeof(wd_p));
|
||||||
|
|
||||||
|
- bits = wd_rsa_key_bits(sess);
|
||||||
|
+ bits = wd_rsa_get_key_bits(sess);
|
||||||
|
if (bits == 1024) {
|
||||||
|
e = rsa_e_1024;
|
||||||
|
p = rsa_p_1024;
|
||||||
|
@@ -7348,7 +7348,7 @@ int hpre_test_result_check(handle_t sess, struct wd_rsa_req *req, void *key)
|
||||||
|
}
|
||||||
|
|
||||||
|
wd_rsa_get_prikey(sess, &prikey);
|
||||||
|
- keybits = wd_rsa_key_bits(sess);
|
||||||
|
+ keybits = wd_rsa_get_key_bits(sess);
|
||||||
|
key_size = keybits >> 3;
|
||||||
|
if (req->op_type == WD_RSA_GENKEY) {
|
||||||
|
if (wd_rsa_is_crt(sess)) {
|
||||||
|
@@ -7907,7 +7907,7 @@ static void _rsa_cb(void *req_t)
|
||||||
|
struct test_hpre_pthread_dt *thread_info = tag->thread_info;
|
||||||
|
|
||||||
|
wd_rsa_get_prikey(sess, &prikey);
|
||||||
|
- keybits = wd_rsa_key_bits(sess);
|
||||||
|
+ keybits = wd_rsa_get_key_bits(sess);
|
||||||
|
key_size = keybits >> 3;
|
||||||
|
|
||||||
|
thread_info->recv_task_num++;
|
||||||
|
diff --git a/wd_rsa.c b/wd_rsa.c
|
||||||
|
index 2e61927..4c8fd71 100644
|
||||||
|
--- a/wd_rsa.c
|
||||||
|
+++ b/wd_rsa.c
|
||||||
|
@@ -599,7 +599,7 @@ struct wd_rsa_kg_out *wd_rsa_new_kg_out(handle_t sess)
|
||||||
|
|
||||||
|
kg_out = malloc(kg_out_size + sizeof(*kg_out));
|
||||||
|
if (!kg_out) {
|
||||||
|
- WD_ERR("sess malloc kg_in memory fail!\n");
|
||||||
|
+ WD_ERR("sess malloc kg_out memory fail!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -875,7 +875,7 @@ bool wd_rsa_is_crt(handle_t sess)
|
||||||
|
return ((struct wd_rsa_sess *)sess)->setup.is_crt;
|
||||||
|
}
|
||||||
|
|
||||||
|
-__u32 wd_rsa_key_bits(handle_t sess)
|
||||||
|
+__u32 wd_rsa_get_key_bits(handle_t sess)
|
||||||
|
{
|
||||||
|
if (!sess) {
|
||||||
|
WD_ERR("get rsa key bits, sess NULL!\n");
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
127
0071-uadk-modify-param-verification.patch
Normal file
127
0071-uadk-modify-param-verification.patch
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
From f15516b66eb92d0c9a90532eb23c96e93a14ee10 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
Date: Wed, 2 Mar 2022 07:25:49 +0000
|
||||||
|
Subject: [PATCH 078/109] uadk: modify param verification
|
||||||
|
|
||||||
|
When config->ctxs[0] is NULL, take ctxs[0].ctx
|
||||||
|
may cause a crash, so check config->ctxs[0] when
|
||||||
|
performing init param check.
|
||||||
|
|
||||||
|
Signed-off-by: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||||
|
---
|
||||||
|
v1/wd_sgl.c | 4 ++--
|
||||||
|
wd_aead.c | 2 +-
|
||||||
|
wd_cipher.c | 2 +-
|
||||||
|
wd_comp.c | 5 ++---
|
||||||
|
wd_dh.c | 2 +-
|
||||||
|
wd_digest.c | 2 +-
|
||||||
|
wd_ecc.c | 2 +-
|
||||||
|
7 files changed, 9 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/v1/wd_sgl.c b/v1/wd_sgl.c
|
||||||
|
index 97edbf4..9995d69 100644
|
||||||
|
--- a/v1/wd_sgl.c
|
||||||
|
+++ b/v1/wd_sgl.c
|
||||||
|
@@ -516,8 +516,8 @@ void wd_free_sgl(void *pool, struct wd_sgl *sgl)
|
||||||
|
struct wd_sgl *next;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
- if (unlikely(!p || !sgl)) {
|
||||||
|
- WD_ERR("pool or sgl is null!\n");
|
||||||
|
+ if (unlikely(!p || !sgl || !p->sgl_pool)) {
|
||||||
|
+ WD_ERR("pool or sgl or p->sgl_pool is null!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/wd_aead.c b/wd_aead.c
|
||||||
|
index d8581db..a78f152 100644
|
||||||
|
--- a/wd_aead.c
|
||||||
|
+++ b/wd_aead.c
|
||||||
|
@@ -392,7 +392,7 @@ 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) {
|
||||||
|
+ if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
WD_ERR("wd aead config or sched is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
diff --git a/wd_cipher.c b/wd_cipher.c
|
||||||
|
index 0b29fb5..8daac0f 100644
|
||||||
|
--- a/wd_cipher.c
|
||||||
|
+++ b/wd_cipher.c
|
||||||
|
@@ -157,7 +157,7 @@ static int cipher_key_len_check(struct wd_cipher_sess *sess, __u32 length)
|
||||||
|
static int cipher_init_check(struct wd_ctx_config *config,
|
||||||
|
struct wd_sched *sched)
|
||||||
|
{
|
||||||
|
- if (!config || !sched) {
|
||||||
|
+ if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
WD_ERR("wd cipher config or sched is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
diff --git a/wd_comp.c b/wd_comp.c
|
||||||
|
index 722666d..886e6fc 100644
|
||||||
|
--- a/wd_comp.c
|
||||||
|
+++ b/wd_comp.c
|
||||||
|
@@ -87,7 +87,7 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
void *priv;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- if (!config || !sched) {
|
||||||
|
+ if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
WD_ERR("invalid params, config or sched is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -223,8 +223,7 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
req = &msg->req;
|
||||||
|
req->src_len = msg->in_cons;
|
||||||
|
req->dst_len = msg->produced;
|
||||||
|
- if (req->cb)
|
||||||
|
- req->cb(req, req->cb_param);
|
||||||
|
+ req->cb(req, req->cb_param);
|
||||||
|
|
||||||
|
/* free msg cache to msg_pool */
|
||||||
|
wd_put_msg_to_pool(&wd_comp_setting.pool, idx, resp_msg.tag);
|
||||||
|
diff --git a/wd_dh.c b/wd_dh.c
|
||||||
|
index b361d5d..841a126 100644
|
||||||
|
--- a/wd_dh.c
|
||||||
|
+++ b/wd_dh.c
|
||||||
|
@@ -80,7 +80,7 @@ void wd_dh_set_driver(struct wd_dh_driver *drv)
|
||||||
|
|
||||||
|
static int param_check(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
{
|
||||||
|
- if (!config || !config->ctxs[0].ctx || !sched) {
|
||||||
|
+ if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
WD_ERR("config or sched NULL\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
diff --git a/wd_digest.c b/wd_digest.c
|
||||||
|
index 1c05851..21c3876 100644
|
||||||
|
--- a/wd_digest.c
|
||||||
|
+++ b/wd_digest.c
|
||||||
|
@@ -154,7 +154,7 @@ void wd_digest_free_sess(handle_t h_sess)
|
||||||
|
|
||||||
|
static int digest_init_check(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
{
|
||||||
|
- if (!config || !sched) {
|
||||||
|
+ if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
WD_ERR("failed to check input param!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
diff --git a/wd_ecc.c b/wd_ecc.c
|
||||||
|
index 89566ea..3232e67 100644
|
||||||
|
--- a/wd_ecc.c
|
||||||
|
+++ b/wd_ecc.c
|
||||||
|
@@ -134,7 +134,7 @@ void wd_ecc_set_driver(struct wd_ecc_driver *drv)
|
||||||
|
|
||||||
|
static int init_param_check(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
{
|
||||||
|
- if (!config || !config->ctxs[0].ctx || !sched) {
|
||||||
|
+ if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
WD_ERR("config or sched NULL\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
38
0072-uadk-v1-cleanup-ret-value.patch
Normal file
38
0072-uadk-v1-cleanup-ret-value.patch
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
From e0451ee34c5d5c258fbb359a89a7a925ace7efa4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
Date: Fri, 4 Mar 2022 01:56:08 +0000
|
||||||
|
Subject: [PATCH 079/109] uadk/v1: cleanup ret value
|
||||||
|
|
||||||
|
It is unnecessary to initialize variable 'ret' and
|
||||||
|
return it when the function is executed successfully,
|
||||||
|
so remove 'ret'.
|
||||||
|
|
||||||
|
Signed-off-by: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
---
|
||||||
|
v1/wd_aead.c | 3 +--
|
||||||
|
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/v1/wd_aead.c b/v1/wd_aead.c
|
||||||
|
index ad22426..6d8c541 100644
|
||||||
|
--- a/v1/wd_aead.c
|
||||||
|
+++ b/v1/wd_aead.c
|
||||||
|
@@ -263,7 +263,6 @@ free_ctx_id:
|
||||||
|
int wcrypto_aead_setauthsize(void *ctx, __u16 authsize)
|
||||||
|
{
|
||||||
|
struct wcrypto_aead_ctx *ctxt = ctx;
|
||||||
|
- int ret = WD_SUCCESS;
|
||||||
|
|
||||||
|
if (!ctx) {
|
||||||
|
WD_ERR("input param is NULL!\n");
|
||||||
|
@@ -277,7 +276,7 @@ int wcrypto_aead_setauthsize(void *ctx, __u16 authsize)
|
||||||
|
|
||||||
|
ctxt->auth_size = authsize;
|
||||||
|
|
||||||
|
- return ret;
|
||||||
|
+ return WD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wcrypto_aead_getauthsize(void *ctx)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
46
0073-uadk-wd-fixup-about-checking-device.patch
Normal file
46
0073-uadk-wd-fixup-about-checking-device.patch
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
From f5f79ed6d426809ef7ad4dc06bbdf7d2ba1bd9bc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
Date: Fri, 4 Mar 2022 02:22:19 +0000
|
||||||
|
Subject: [PATCH 080/109] uadk/wd: fixup about checking device
|
||||||
|
|
||||||
|
Add non-empty check for ctx->dev.
|
||||||
|
|
||||||
|
Signed-off-by: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
---
|
||||||
|
wd.c | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/wd.c b/wd.c
|
||||||
|
index 565c173..b88ee62 100644
|
||||||
|
--- a/wd.c
|
||||||
|
+++ b/wd.c
|
||||||
|
@@ -480,7 +480,7 @@ char *wd_ctx_get_api(handle_t h_ctx)
|
||||||
|
{
|
||||||
|
struct wd_ctx_h *ctx = (struct wd_ctx_h *)h_ctx;
|
||||||
|
|
||||||
|
- if (!ctx)
|
||||||
|
+ if (!ctx || !ctx->dev)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return ctx->dev->api;
|
||||||
|
@@ -508,7 +508,7 @@ int wd_is_sva(handle_t h_ctx)
|
||||||
|
{
|
||||||
|
struct wd_ctx_h *ctx = (struct wd_ctx_h *)h_ctx;
|
||||||
|
|
||||||
|
- if (!ctx)
|
||||||
|
+ if (!ctx || !ctx->dev)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
|
||||||
|
if ((unsigned int)ctx->dev->flags & UACCE_DEV_SVA)
|
||||||
|
@@ -521,7 +521,7 @@ int wd_get_numa_id(handle_t h_ctx)
|
||||||
|
{
|
||||||
|
struct wd_ctx_h *ctx = (struct wd_ctx_h *)h_ctx;
|
||||||
|
|
||||||
|
- if (!ctx)
|
||||||
|
+ if (!ctx || !ctx->dev)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
|
||||||
|
return ctx->dev->numa_id;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
347
0074-uadk-cleanup-hpre-code.patch
Normal file
347
0074-uadk-cleanup-hpre-code.patch
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
From 50b68c0405544702181deb9dda28381169b17d09 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
Date: Fri, 4 Mar 2022 02:25:54 +0000
|
||||||
|
Subject: [PATCH 081/109] uadk: cleanup hpre code
|
||||||
|
|
||||||
|
Includes:
|
||||||
|
1.Remove useless interface param.
|
||||||
|
2.Remove ASSERT.
|
||||||
|
3.Remove print address.
|
||||||
|
|
||||||
|
Signed-off-by: Junchong Pan <panjunchong@hisilicon.com>
|
||||||
|
---
|
||||||
|
drv/hisi_hpre.c | 26 +++++++++++++++-------
|
||||||
|
drv/hisi_qm_udrv.c | 2 --
|
||||||
|
v1/drv/hisi_hpre_udrv.c | 48 ++++++++++++++++++++++++++++-------------
|
||||||
|
v1/wd_ecc.c | 24 ++++++++++-----------
|
||||||
|
wd_ecc.c | 24 ++++++++++-----------
|
||||||
|
5 files changed, 75 insertions(+), 49 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
|
||||||
|
index fbb38e0..f1d7720 100644
|
||||||
|
--- a/drv/hisi_hpre.c
|
||||||
|
+++ b/drv/hisi_hpre.c
|
||||||
|
@@ -127,7 +127,7 @@ static bool is_hpre_bin_fmt(const char *data, int dsz, int bsz)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int crypto_bin_to_hpre_bin(char *dst, const char *src,
|
||||||
|
- int b_size, int d_size, const char *p_name)
|
||||||
|
+ __u32 b_size, __u32 d_size, const char *p_name)
|
||||||
|
{
|
||||||
|
int i = d_size - 1;
|
||||||
|
bool is_hpre_bin;
|
||||||
|
@@ -1469,6 +1469,11 @@ static struct wd_ecc_out *create_ecdh_out(struct wd_ecc_msg *msg)
|
||||||
|
struct wd_ecc_dh_out *dh_out;
|
||||||
|
struct wd_ecc_out *out;
|
||||||
|
|
||||||
|
+ if (!hsz) {
|
||||||
|
+ WD_ERR("get msg key size error!\n");
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
out = malloc(len);
|
||||||
|
if (!out) {
|
||||||
|
WD_ERR("failed to alloc, sz = %u!\n", len);
|
||||||
|
@@ -1601,6 +1606,11 @@ static int ecc_fill(struct wd_ecc_msg *msg, struct hisi_hpre_sqe *hw_msg)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (!hw_sz) {
|
||||||
|
+ WD_ERR("get msg key size error!\n");
|
||||||
|
+ return -WD_EINVAL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
memset(hw_msg, 0, sizeof(*hw_msg));
|
||||||
|
|
||||||
|
/* prepare algorithm */
|
||||||
|
@@ -1646,7 +1656,7 @@ static int sm2_enc_send(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx);
|
||||||
|
struct wd_sm2_enc_in *ein = msg->req.src;
|
||||||
|
struct wd_ecc_msg *msg_dst[2] = {NULL};
|
||||||
|
- struct hisi_hpre_sqe hw_msg[2] = {{0}};
|
||||||
|
+ struct hisi_hpre_sqe hw_msg[2] = {0};
|
||||||
|
struct wd_hash_mt *hash = &msg->hash;
|
||||||
|
__u16 send_cnt = 0;
|
||||||
|
int ret;
|
||||||
|
@@ -1918,7 +1928,7 @@ static __u32 get_hash_bytes(__u8 type)
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void msg_pack(char *dst, __u64 dst_len, __u64 *out_len,
|
||||||
|
+static void msg_pack(char *dst, __u64 *out_len,
|
||||||
|
const void *src, __u32 src_len)
|
||||||
|
{
|
||||||
|
if (unlikely(!src || !src_len))
|
||||||
|
@@ -1961,8 +1971,8 @@ static int sm2_kdf(struct wd_dtb *out, struct wd_ecc_point *x2y2,
|
||||||
|
ctr[2] = (i >> 8) & 0xFF;
|
||||||
|
ctr[1] = (i >> 16) & 0xFF;
|
||||||
|
ctr[0] = (i >> 24) & 0xFF;
|
||||||
|
- msg_pack(p_in, lens, &in_len, x2y2->x.data, x2y2_len);
|
||||||
|
- msg_pack(p_in, lens, &in_len, ctr, sizeof(ctr));
|
||||||
|
+ msg_pack(p_in, &in_len, x2y2->x.data, x2y2_len);
|
||||||
|
+ msg_pack(p_in, &in_len, ctr, sizeof(ctr));
|
||||||
|
|
||||||
|
t_out = m_len >= h_bytes ? tmp : p_out;
|
||||||
|
ret = hash->cb(p_in, in_len, t_out, h_bytes, hash->usr);
|
||||||
|
@@ -2026,9 +2036,9 @@ static int sm2_hash(struct wd_dtb *out, struct wd_ecc_point *x2y2,
|
||||||
|
if (unlikely(!p_in))
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
|
||||||
|
- msg_pack(p_in, lens, &in_len, x2y2->x.data, x2y2->x.dsize);
|
||||||
|
- msg_pack(p_in, lens, &in_len, msg->data, msg->dsize);
|
||||||
|
- msg_pack(p_in, lens, &in_len, x2y2->y.data, x2y2->y.dsize);
|
||||||
|
+ msg_pack(p_in, &in_len, x2y2->x.data, x2y2->x.dsize);
|
||||||
|
+ msg_pack(p_in, &in_len, msg->data, msg->dsize);
|
||||||
|
+ msg_pack(p_in, &in_len, x2y2->y.data, x2y2->y.dsize);
|
||||||
|
ret = hash->cb(p_in, in_len, hash_out, h_bytes, hash->usr);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
WD_ERR("failed to hash cb, ret = %d!\n", ret);
|
||||||
|
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
|
||||||
|
index 845fa46..2e692a1 100644
|
||||||
|
--- a/drv/hisi_qm_udrv.c
|
||||||
|
+++ b/drv/hisi_qm_udrv.c
|
||||||
|
@@ -896,8 +896,6 @@ void hisi_qm_dump_sgl(void *sgl)
|
||||||
|
int i;
|
||||||
|
|
||||||
|
while (tmp) {
|
||||||
|
- WD_ERR("sgl = %p\n", tmp);
|
||||||
|
- WD_ERR("sgl->next_dma : 0x%lx\n", tmp->next_dma);
|
||||||
|
WD_ERR("sgl->entry_sum_in_chain : %u\n",
|
||||||
|
tmp->entry_sum_in_chain);
|
||||||
|
WD_ERR("sgl->entry_sum_in_sgl : %u\n",
|
||||||
|
diff --git a/v1/drv/hisi_hpre_udrv.c b/v1/drv/hisi_hpre_udrv.c
|
||||||
|
index c6ca0ad..ba32114 100644
|
||||||
|
--- a/v1/drv/hisi_hpre_udrv.c
|
||||||
|
+++ b/v1/drv/hisi_hpre_udrv.c
|
||||||
|
@@ -499,7 +499,6 @@ int qm_fill_rsa_sqe(void *message, struct qm_queue_info *info, __u16 i)
|
||||||
|
hw_msg->low_tag = tag->ctx_id;
|
||||||
|
hw_msg->done = 0x1;
|
||||||
|
hw_msg->etype = 0x0;
|
||||||
|
- ASSERT(!info->req_cache[i]);
|
||||||
|
info->req_cache[i] = msg;
|
||||||
|
|
||||||
|
return WD_SUCCESS;
|
||||||
|
@@ -517,7 +516,10 @@ int qm_parse_rsa_sqe(void *msg, const struct qm_queue_info *info,
|
||||||
|
__u16 kbytes;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ASSERT(rsa_msg);
|
||||||
|
+ if (unlikely(!rsa_msg)) {
|
||||||
|
+ WD_ERR("info->req_cache is null at index:%hu\n", i);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
/* if this hardware message not belong to me, then try again */
|
||||||
|
if (usr && LOW_U16(hw_msg->low_tag) != usr)
|
||||||
|
@@ -700,7 +702,6 @@ int qm_fill_dh_sqe(void *message, struct qm_queue_info *info, __u16 i)
|
||||||
|
if (unlikely(ret))
|
||||||
|
goto map_xp_fail;
|
||||||
|
}
|
||||||
|
- ASSERT(!info->req_cache[i]);
|
||||||
|
info->req_cache[i] = msg;
|
||||||
|
|
||||||
|
ret = qm_final_fill_dh_sqe(q, msg, hw_msg);
|
||||||
|
@@ -726,7 +727,11 @@ int qm_parse_dh_sqe(void *msg, const struct qm_queue_info *info,
|
||||||
|
struct wd_queue *q = info->q;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ASSERT(dh_msg);
|
||||||
|
+ if (unlikely(!dh_msg)) {
|
||||||
|
+ WD_ERR("info->req_cache is null at index:%hu\n", i);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (usr && LOW_U16(hw_msg->low_tag) != usr)
|
||||||
|
return 0;
|
||||||
|
if (hw_msg->done != HPRE_HW_TASK_DONE || hw_msg->etype) {
|
||||||
|
@@ -1668,7 +1673,6 @@ static int qm_fill_ecc_sqe_general(void *message, struct qm_queue_info *info,
|
||||||
|
hw_msg->low_tag = tag->ctx_id;
|
||||||
|
hw_msg->done = 0x1;
|
||||||
|
hw_msg->etype = 0x0;
|
||||||
|
- ASSERT(!info->req_cache[i]);
|
||||||
|
info->req_cache[i] = msg;
|
||||||
|
|
||||||
|
return WD_SUCCESS;
|
||||||
|
@@ -1942,6 +1946,7 @@ static int fill_sm2_dec_sqe(void *message, struct qm_queue_info *info, __u16 i)
|
||||||
|
struct wd_mm_br *br = &qinfo->br;
|
||||||
|
__u32 ksz = req_src->key_bytes;
|
||||||
|
struct wcrypto_ecc_msg *dst;
|
||||||
|
+ int ret;
|
||||||
|
|
||||||
|
/* c2 data lens <= 4096 bit */
|
||||||
|
if (din->c2.dsize <= BITS_TO_BYTES(4096) &&
|
||||||
|
@@ -1966,11 +1971,21 @@ static int fill_sm2_dec_sqe(void *message, struct qm_queue_info *info, __u16 i)
|
||||||
|
dst->in = (void *)&din->c1;
|
||||||
|
dst->out = br->alloc(br->usr, ECDH_OUT_PARAMS_SZ(ksz));
|
||||||
|
if (unlikely(!dst->out)) {
|
||||||
|
- free(dst);
|
||||||
|
- return -WD_ENOMEM;
|
||||||
|
+ ret = -WD_ENOMEM;
|
||||||
|
+ goto free_dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
- return qm_fill_ecc_sqe_general(dst, info, i);
|
||||||
|
+ ret = qm_fill_ecc_sqe_general(dst, info, i);
|
||||||
|
+ if (ret)
|
||||||
|
+ goto free_out;
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+free_out:
|
||||||
|
+ br->free(br->usr, dst->out);
|
||||||
|
+free_dst:
|
||||||
|
+ free(dst);
|
||||||
|
+ return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int qm_fill_ecc_sqe(void *message, struct qm_queue_info *info, __u16 i)
|
||||||
|
@@ -1997,7 +2012,10 @@ static int qm_parse_ecc_sqe_general(void *msg, const struct qm_queue_info *info,
|
||||||
|
__u16 kbytes;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ASSERT(ecc_msg);
|
||||||
|
+ if (unlikely(!ecc_msg)) {
|
||||||
|
+ WD_ERR("info->req_cache is null at index:%hu\n", i);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
/* if this hw msg not belong to me, then try again */
|
||||||
|
if (usr && LOW_U16(hw_msg->low_tag) != usr)
|
||||||
|
@@ -2146,7 +2164,7 @@ static __u32 get_hash_bytes(__u8 type)
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void msg_pack(char *dst, __u64 dst_len, __u64 *out_len,
|
||||||
|
+static void msg_pack(char *dst, __u64 *out_len,
|
||||||
|
const void *src, __u32 src_len)
|
||||||
|
{
|
||||||
|
if (unlikely(!src || !src_len))
|
||||||
|
@@ -2191,8 +2209,8 @@ static int sm2_kdf(struct wd_dtb *out, struct wcrypto_ecc_point *x2y2,
|
||||||
|
ctr[1] = (i >> 16) & 0xFF;
|
||||||
|
ctr[0] = (i >> 24) & 0xFF;
|
||||||
|
in_len = 0;
|
||||||
|
- msg_pack(p_in, lens, &in_len, x2y2->x.data, x2y2_len);
|
||||||
|
- msg_pack(p_in, lens, &in_len, ctr, sizeof(ctr));
|
||||||
|
+ msg_pack(p_in, &in_len, x2y2->x.data, x2y2_len);
|
||||||
|
+ msg_pack(p_in, &in_len, ctr, sizeof(ctr));
|
||||||
|
|
||||||
|
t_out = m_len >= h_bytes ? tmp : p_out;
|
||||||
|
ret = hash->cb(p_in, in_len, t_out, h_bytes, hash->usr);
|
||||||
|
@@ -2257,9 +2275,9 @@ static int sm2_hash(struct wd_dtb *out, struct wcrypto_ecc_point *x2y2,
|
||||||
|
if (unlikely(!p_in))
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
|
||||||
|
- msg_pack(p_in, lens, &in_len, x2y2->x.data, x2y2->x.dsize);
|
||||||
|
- msg_pack(p_in, lens, &in_len, msg->data, msg->dsize);
|
||||||
|
- msg_pack(p_in, lens, &in_len, x2y2->y.data, x2y2->y.dsize);
|
||||||
|
+ msg_pack(p_in, &in_len, x2y2->x.data, x2y2->x.dsize);
|
||||||
|
+ msg_pack(p_in, &in_len, msg->data, msg->dsize);
|
||||||
|
+ msg_pack(p_in, &in_len, x2y2->y.data, x2y2->y.dsize);
|
||||||
|
ret = hash->cb(p_in, in_len, hash_out, h_bytes, hash->usr);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
WD_ERR("failed to hash cb, ret = %d!\n", ret);
|
||||||
|
diff --git a/v1/wd_ecc.c b/v1/wd_ecc.c
|
||||||
|
index c710d8a..2358243 100644
|
||||||
|
--- a/v1/wd_ecc.c
|
||||||
|
+++ b/v1/wd_ecc.c
|
||||||
|
@@ -1508,7 +1508,7 @@ static int ecc_request_init(struct wcrypto_ecc_msg *req,
|
||||||
|
return WD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void msg_pack(char *dst, __u64 dst_len, __u64 *out_len,
|
||||||
|
+static void msg_pack(char *dst, __u64 *out_len,
|
||||||
|
const void *src, __u32 src_len)
|
||||||
|
{
|
||||||
|
if (unlikely(!src || !src_len))
|
||||||
|
@@ -1831,17 +1831,17 @@ static int sm2_compute_za_hash(__u8 *za, __u32 *len, struct wd_dtb *id,
|
||||||
|
|
||||||
|
memset(p_in, 0, lens);
|
||||||
|
temp = id_bits >> 8;
|
||||||
|
- msg_pack(p_in, lens, &in_len, &temp, sizeof(__u8));
|
||||||
|
+ msg_pack(p_in, &in_len, &temp, sizeof(__u8));
|
||||||
|
temp = id_bits & 0xFF;
|
||||||
|
- msg_pack(p_in, lens, &in_len, &temp, sizeof(__u8));
|
||||||
|
+ msg_pack(p_in, &in_len, &temp, sizeof(__u8));
|
||||||
|
if (id)
|
||||||
|
- msg_pack(p_in, lens, &in_len, id->data, id_bytes);
|
||||||
|
- msg_pack(p_in, lens, &in_len, cv->a.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, cv->b.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, cv->g.x.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, cv->g.y.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, pub->x.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, pub->y.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, id->data, id_bytes);
|
||||||
|
+ msg_pack(p_in, &in_len, cv->a.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, cv->b.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, cv->g.x.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, cv->g.y.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, pub->x.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, pub->y.data, key_size);
|
||||||
|
|
||||||
|
hash_bytes = get_hash_bytes(hash->type);
|
||||||
|
*len = hash_bytes;
|
||||||
|
@@ -1885,8 +1885,8 @@ static int sm2_compute_digest(void *ctx, struct wd_dtb *hash_msg,
|
||||||
|
|
||||||
|
/* e = h(ZA || M) */
|
||||||
|
memset(p_in, 0, lens);
|
||||||
|
- msg_pack(p_in, lens, &in_len, za, za_len);
|
||||||
|
- msg_pack(p_in, lens, &in_len, plaintext->data, plaintext->dsize);
|
||||||
|
+ msg_pack(p_in, &in_len, za, za_len);
|
||||||
|
+ msg_pack(p_in, &in_len, plaintext->data, plaintext->dsize);
|
||||||
|
hash_msg->dsize = hash_bytes;
|
||||||
|
ret = hash->cb((const char *)p_in, in_len, hash_msg->data,
|
||||||
|
hash_bytes, hash->usr);
|
||||||
|
diff --git a/wd_ecc.c b/wd_ecc.c
|
||||||
|
index 3232e67..a9994b2 100644
|
||||||
|
--- a/wd_ecc.c
|
||||||
|
+++ b/wd_ecc.c
|
||||||
|
@@ -1396,7 +1396,7 @@ static int fill_ecc_msg(struct wd_ecc_msg *msg, struct wd_ecc_req *req,
|
||||||
|
return WD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void msg_pack(char *dst, __u64 dst_len, __u64 *out_len,
|
||||||
|
+static void msg_pack(char *dst, __u64 *out_len,
|
||||||
|
const void *src, __u32 src_len)
|
||||||
|
{
|
||||||
|
if (!src || !src_len)
|
||||||
|
@@ -1596,17 +1596,17 @@ static int sm2_compute_za_hash(__u8 *za, __u32 *len, struct wd_dtb *id,
|
||||||
|
|
||||||
|
memset(p_in, 0, lens);
|
||||||
|
temp = id_bits >> 8;
|
||||||
|
- msg_pack(p_in, lens, &in_len, &temp, sizeof(__u8));
|
||||||
|
+ msg_pack(p_in, &in_len, &temp, sizeof(__u8));
|
||||||
|
temp = id_bits & 0xFF;
|
||||||
|
- msg_pack(p_in, lens, &in_len, &temp, sizeof(__u8));
|
||||||
|
+ msg_pack(p_in, &in_len, &temp, sizeof(__u8));
|
||||||
|
if (id)
|
||||||
|
- msg_pack(p_in, lens, &in_len, id->data, id_bytes);
|
||||||
|
- msg_pack(p_in, lens, &in_len, cv->a.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, cv->b.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, cv->g.x.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, cv->g.y.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, pub->x.data, key_size);
|
||||||
|
- msg_pack(p_in, lens, &in_len, pub->y.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, id->data, id_bytes);
|
||||||
|
+ msg_pack(p_in, &in_len, cv->a.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, cv->b.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, cv->g.x.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, cv->g.y.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, pub->x.data, key_size);
|
||||||
|
+ msg_pack(p_in, &in_len, pub->y.data, key_size);
|
||||||
|
hash_bytes = get_hash_bytes(hash->type);
|
||||||
|
*len = hash_bytes;
|
||||||
|
ret = hash->cb((const char *)p_in, in_len,
|
||||||
|
@@ -1649,8 +1649,8 @@ static int sm2_compute_digest(struct wd_ecc_sess *sess, struct wd_dtb *hash_msg,
|
||||||
|
|
||||||
|
/* e = h(ZA || M) */
|
||||||
|
memset(p_in, 0, lens);
|
||||||
|
- msg_pack(p_in, lens, &in_len, za, za_len);
|
||||||
|
- msg_pack(p_in, lens, &in_len, plaintext->data, plaintext->dsize);
|
||||||
|
+ msg_pack(p_in, &in_len, za, za_len);
|
||||||
|
+ msg_pack(p_in, &in_len, plaintext->data, plaintext->dsize);
|
||||||
|
hash_msg->dsize = hash_bytes;
|
||||||
|
ret = hash->cb((const char *)p_in, in_len, hash_msg->data,
|
||||||
|
hash_bytes, hash->usr);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
31
0075-uadk-v1-fix-pool-cstatus-memset-problem.patch
Normal file
31
0075-uadk-v1-fix-pool-cstatus-memset-problem.patch
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
From 1c72d89b848290814601517e73f6a9d8eb6e5caa Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 3 Mar 2022 15:10:04 +0800
|
||||||
|
Subject: [PATCH 082/109] uadk: v1: fix pool cstatus memset problem
|
||||||
|
|
||||||
|
wd_alloc_id use __atomic_test_and_set to find
|
||||||
|
an available cookie with zero status,
|
||||||
|
it may not find a zero cookie with dirty memory,
|
||||||
|
so cookie status region should be set to zero.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
v1/wd_util.c | 2 ++
|
||||||
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/v1/wd_util.c b/v1/wd_util.c
|
||||||
|
index 715804c..112cc16 100644
|
||||||
|
--- a/v1/wd_util.c
|
||||||
|
+++ b/v1/wd_util.c
|
||||||
|
@@ -92,6 +92,8 @@ int wd_init_cookie_pool(struct wd_cookie_pool *pool,
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
|
||||||
|
pool->cstatus = (void *)((uintptr_t)pool->cookies + total_size);
|
||||||
|
+ memset(pool->cstatus, 0, cookies_num);
|
||||||
|
+
|
||||||
|
pool->cookies_num = cookies_num;
|
||||||
|
pool->cookies_size = cookies_size;
|
||||||
|
pool->cid = 0;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
108
0076-uadk-bugfix-segment-fault-when-uninitializing.patch
Normal file
108
0076-uadk-bugfix-segment-fault-when-uninitializing.patch
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
From 1d20eaf8c0829531ab5cb4fc8ecd4142147b482d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||||
|
Date: Wed, 9 Mar 2022 01:30:51 +0000
|
||||||
|
Subject: [PATCH 084/109] uadk: bugfix segment fault when uninitializing
|
||||||
|
|
||||||
|
When the initialization of each alg driver failed,
|
||||||
|
the wd_<alg>_setting.priv should be set to NULL.
|
||||||
|
Otherwise there will be segment fault when
|
||||||
|
uninitializing the alg driver.
|
||||||
|
|
||||||
|
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||||
|
---
|
||||||
|
wd_aead.c | 1 +
|
||||||
|
wd_cipher.c | 1 +
|
||||||
|
wd_comp.c | 1 +
|
||||||
|
wd_dh.c | 1 +
|
||||||
|
wd_digest.c | 1 +
|
||||||
|
wd_ecc.c | 1 +
|
||||||
|
wd_rsa.c | 1 +
|
||||||
|
7 files changed, 7 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/wd_aead.c b/wd_aead.c
|
||||||
|
index a78f152..7df8e80 100644
|
||||||
|
--- a/wd_aead.c
|
||||||
|
+++ b/wd_aead.c
|
||||||
|
@@ -458,6 +458,7 @@ int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
|
||||||
|
out_init:
|
||||||
|
free(priv);
|
||||||
|
+ wd_aead_setting.priv = NULL;
|
||||||
|
out_priv:
|
||||||
|
wd_uninit_async_request_pool(&wd_aead_setting.pool);
|
||||||
|
out_sched:
|
||||||
|
diff --git a/wd_cipher.c b/wd_cipher.c
|
||||||
|
index 8daac0f..afd8c4d 100644
|
||||||
|
--- a/wd_cipher.c
|
||||||
|
+++ b/wd_cipher.c
|
||||||
|
@@ -299,6 +299,7 @@ int wd_cipher_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
|
||||||
|
out_init:
|
||||||
|
free(priv);
|
||||||
|
+ wd_cipher_setting.priv = NULL;
|
||||||
|
out_priv:
|
||||||
|
wd_uninit_async_request_pool(&wd_cipher_setting.pool);
|
||||||
|
out_sched:
|
||||||
|
diff --git a/wd_comp.c b/wd_comp.c
|
||||||
|
index 886e6fc..8d0c603 100644
|
||||||
|
--- a/wd_comp.c
|
||||||
|
+++ b/wd_comp.c
|
||||||
|
@@ -145,6 +145,7 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
|
||||||
|
out_init:
|
||||||
|
free(priv);
|
||||||
|
+ wd_comp_setting.priv = NULL;
|
||||||
|
out_priv:
|
||||||
|
wd_uninit_async_request_pool(&wd_comp_setting.pool);
|
||||||
|
out_sched:
|
||||||
|
diff --git a/wd_dh.c b/wd_dh.c
|
||||||
|
index 841a126..f5d70a2 100644
|
||||||
|
--- a/wd_dh.c
|
||||||
|
+++ b/wd_dh.c
|
||||||
|
@@ -145,6 +145,7 @@ int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
|
||||||
|
out_init:
|
||||||
|
free(priv);
|
||||||
|
+ wd_dh_setting.priv = NULL;
|
||||||
|
out_priv:
|
||||||
|
wd_uninit_async_request_pool(&wd_dh_setting.pool);
|
||||||
|
out_sched:
|
||||||
|
diff --git a/wd_digest.c b/wd_digest.c
|
||||||
|
index 21c3876..06774be 100644
|
||||||
|
--- a/wd_digest.c
|
||||||
|
+++ b/wd_digest.c
|
||||||
|
@@ -220,6 +220,7 @@ int wd_digest_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
|
||||||
|
out_init:
|
||||||
|
free(priv);
|
||||||
|
+ wd_digest_setting.priv = NULL;
|
||||||
|
out_priv:
|
||||||
|
wd_uninit_async_request_pool(&wd_digest_setting.pool);
|
||||||
|
out_sched:
|
||||||
|
diff --git a/wd_ecc.c b/wd_ecc.c
|
||||||
|
index a9994b2..d925bc3 100644
|
||||||
|
--- a/wd_ecc.c
|
||||||
|
+++ b/wd_ecc.c
|
||||||
|
@@ -199,6 +199,7 @@ int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
|
||||||
|
out_init:
|
||||||
|
free(priv);
|
||||||
|
+ wd_ecc_setting.priv = NULL;
|
||||||
|
out_priv:
|
||||||
|
wd_uninit_async_request_pool(&wd_ecc_setting.pool);
|
||||||
|
out_sched:
|
||||||
|
diff --git a/wd_rsa.c b/wd_rsa.c
|
||||||
|
index 4c8fd71..8fc405f 100644
|
||||||
|
--- a/wd_rsa.c
|
||||||
|
+++ b/wd_rsa.c
|
||||||
|
@@ -185,6 +185,7 @@ int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
|
||||||
|
out_init:
|
||||||
|
free(priv);
|
||||||
|
+ wd_rsa_setting.priv = NULL;
|
||||||
|
out_priv:
|
||||||
|
wd_uninit_async_request_pool(&wd_rsa_setting.pool);
|
||||||
|
out_sched:
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
47
0077-drv-sec-support-sm4-ecb-alg-by-new-fs.patch
Normal file
47
0077-drv-sec-support-sm4-ecb-alg-by-new-fs.patch
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
From 4e2b91f8079ad1195e20c730cda4e33643918257 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kai Ye <yekai13@huawei.com>
|
||||||
|
Date: Tue, 8 Mar 2022 16:14:17 +0800
|
||||||
|
Subject: [PATCH 085/109] drv/sec: support sm4-ecb alg by new fs
|
||||||
|
|
||||||
|
Kunpeng 920 can supports sm4-ecb by test, and has
|
||||||
|
been updated the chip fs.
|
||||||
|
|
||||||
|
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||||
|
---
|
||||||
|
drv/hisi_sec.c | 4 ----
|
||||||
|
v1/drv/hisi_sec_udrv.c | 4 ----
|
||||||
|
2 files changed, 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
|
||||||
|
index 264d850..16fcb5f 100644
|
||||||
|
--- a/drv/hisi_sec.c
|
||||||
|
+++ b/drv/hisi_sec.c
|
||||||
|
@@ -656,10 +656,6 @@ static int fill_cipher_bd2_mode(struct wd_cipher_msg *msg,
|
||||||
|
|
||||||
|
switch (msg->mode) {
|
||||||
|
case WD_CIPHER_ECB:
|
||||||
|
- if (msg->alg == WD_CIPHER_SM4) {
|
||||||
|
- WD_ERR("kunpeng 920 not support ECB(SM4)!\n");
|
||||||
|
- return -WD_EINVAL;
|
||||||
|
- }
|
||||||
|
c_mode = C_MODE_ECB;
|
||||||
|
break;
|
||||||
|
case WD_CIPHER_CBC:
|
||||||
|
diff --git a/v1/drv/hisi_sec_udrv.c b/v1/drv/hisi_sec_udrv.c
|
||||||
|
index 7345baf..3e1e7d1 100644
|
||||||
|
--- a/v1/drv/hisi_sec_udrv.c
|
||||||
|
+++ b/v1/drv/hisi_sec_udrv.c
|
||||||
|
@@ -165,10 +165,6 @@ static int fill_cipher_bd2_mode(struct wcrypto_cipher_msg *msg,
|
||||||
|
|
||||||
|
switch (msg->mode) {
|
||||||
|
case WCRYPTO_CIPHER_ECB:
|
||||||
|
- if (msg->alg == WCRYPTO_CIPHER_SM4) {
|
||||||
|
- WD_ERR("kunpeng 920 not support ECB(SM4)!\n");
|
||||||
|
- return -WD_EINVAL;
|
||||||
|
- }
|
||||||
|
sqe->type2.c_mode = C_MODE_ECB;
|
||||||
|
break;
|
||||||
|
case WCRYPTO_CIPHER_CBC:
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
74
0078-digest-simplify-the-process-of-represent-BD-state.patch
Normal file
74
0078-digest-simplify-the-process-of-represent-BD-state.patch
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
From f83ee120e0dcab4120d65c045787a6bfc58b8c92 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kai Ye <yekai13@huawei.com>
|
||||||
|
Date: Tue, 8 Mar 2022 18:18:16 +0800
|
||||||
|
Subject: [PATCH 086/109] digest: simplify the process of represent BD state
|
||||||
|
|
||||||
|
The value of 'out_bytes' can be expressed the BD state. So not need to
|
||||||
|
use the marco variable. The BD state is non-zero value when the msg
|
||||||
|
recived successfully. Otherwise the BD state is zero.
|
||||||
|
|
||||||
|
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||||
|
---
|
||||||
|
wd_digest.c | 22 +++++++++++++---------
|
||||||
|
1 file changed, 13 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/wd_digest.c b/wd_digest.c
|
||||||
|
index 06774be..fb29746 100644
|
||||||
|
--- a/wd_digest.c
|
||||||
|
+++ b/wd_digest.c
|
||||||
|
@@ -21,7 +21,6 @@
|
||||||
|
|
||||||
|
#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,
|
||||||
|
@@ -48,10 +47,10 @@ struct wd_digest_sess {
|
||||||
|
__u32 key_bytes;
|
||||||
|
void *sched_key;
|
||||||
|
/*
|
||||||
|
- * Notify the BD state, 1 is final BD or middle BD,
|
||||||
|
- * 0 is normal mode or first BD, one session only supports one stream.
|
||||||
|
+ * Notify the BD state, zero is frist BD, non-zero
|
||||||
|
+ * is middle or final BD.
|
||||||
|
*/
|
||||||
|
- int state;
|
||||||
|
+ int bd_state;
|
||||||
|
/* Total of data for stream mode */
|
||||||
|
__u64 long_data_len;
|
||||||
|
};
|
||||||
|
@@ -301,11 +300,11 @@ 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, iv_bytes also means bd state */
|
||||||
|
- msg->iv_bytes = sess->state;
|
||||||
|
+ /* To store the stream BD state, iv_bytes also means BD state */
|
||||||
|
+ msg->iv_bytes = sess->bd_state;
|
||||||
|
if (req->has_next == 0) {
|
||||||
|
sess->long_data_len = 0;
|
||||||
|
- sess->state = 0;
|
||||||
|
+ sess->bd_state = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -339,8 +338,13 @@ static int send_recv_sync(struct wd_ctx_internal *ctx, struct wd_digest_sess *ds
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- if (msg->has_next && msg->result == WD_SUCCESS)
|
||||||
|
- dsess->state = STREAM_MODE_STATE;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * 'out_bytes' can be expressed BD state, non-zero is final BD or
|
||||||
|
+ * middle BD as stream mode.
|
||||||
|
+ */
|
||||||
|
+ if (msg->has_next)
|
||||||
|
+ dsess->bd_state = msg->out_bytes;
|
||||||
|
} while (ret < 0);
|
||||||
|
|
||||||
|
out:
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
45
0079-uadk-qm_udrv-Modify-goto-err_out.patch
Normal file
45
0079-uadk-qm_udrv-Modify-goto-err_out.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From d554782317fb25319690c2f6453994494a0396d0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: JunchongPan <panjunchong@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:58:46 +0800
|
||||||
|
Subject: [PATCH 087/109] uadk/qm_udrv: Modify goto err_out
|
||||||
|
|
||||||
|
In setup_region, when mmap_qfr return NULL, don't need
|
||||||
|
to set sq_base/mmio_base NULL, return ENOMEM direct.
|
||||||
|
|
||||||
|
Signed-off-by: JunchongPan <panjunchong@hisilicon.com>
|
||||||
|
---
|
||||||
|
drv/hisi_qm_udrv.c | 9 ++-------
|
||||||
|
1 file changed, 2 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
|
||||||
|
index 2e692a1..906dfa3 100644
|
||||||
|
--- a/drv/hisi_qm_udrv.c
|
||||||
|
+++ b/drv/hisi_qm_udrv.c
|
||||||
|
@@ -168,22 +168,17 @@ static int hisi_qm_setup_region(handle_t h_ctx,
|
||||||
|
q_info->sq_base = wd_ctx_mmap_qfr(h_ctx, UACCE_QFRT_DUS);
|
||||||
|
if (!q_info->sq_base) {
|
||||||
|
WD_ERR("mmap dus fail\n");
|
||||||
|
- goto err_out;
|
||||||
|
+ return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
q_info->mmio_base = wd_ctx_mmap_qfr(h_ctx, UACCE_QFRT_MMIO);
|
||||||
|
if (!q_info->mmio_base) {
|
||||||
|
wd_ctx_unmap_qfr(h_ctx, UACCE_QFRT_DUS);
|
||||||
|
WD_ERR("mmap mmio fail\n");
|
||||||
|
- goto err_out;
|
||||||
|
+ return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
-
|
||||||
|
-err_out:
|
||||||
|
- q_info->sq_base = NULL;
|
||||||
|
- q_info->mmio_base = NULL;
|
||||||
|
- return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hisi_qm_unset_region(handle_t h_ctx,
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
992
0080-uadk-unify-wd-print-format.patch
Normal file
992
0080-uadk-unify-wd-print-format.patch
Normal file
@ -0,0 +1,992 @@
|
|||||||
|
From 61912fcfdef3b29e22731b38fbb81dff47102568 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:03:18 +0800
|
||||||
|
Subject: [PATCH 088/109] uadk: unify wd print format
|
||||||
|
|
||||||
|
Unify print format with following rules:
|
||||||
|
1. failed to do sth.
|
||||||
|
2. invalid: sth is NULL.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
drv/hisi_qm_udrv.c | 63 ++++++++++++++++++------------------
|
||||||
|
wd.c | 6 ++--
|
||||||
|
wd_mempool.c | 61 ++++++++++++++++++++--------------
|
||||||
|
wd_sched.c | 52 ++++++++++++++---------------
|
||||||
|
wd_util.c | 81 ++++++++++++++++++++--------------------------
|
||||||
|
5 files changed, 130 insertions(+), 133 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
|
||||||
|
index 906dfa3..be06570 100644
|
||||||
|
--- a/drv/hisi_qm_udrv.c
|
||||||
|
+++ b/drv/hisi_qm_udrv.c
|
||||||
|
@@ -167,14 +167,14 @@ static int hisi_qm_setup_region(handle_t h_ctx,
|
||||||
|
{
|
||||||
|
q_info->sq_base = wd_ctx_mmap_qfr(h_ctx, UACCE_QFRT_DUS);
|
||||||
|
if (!q_info->sq_base) {
|
||||||
|
- WD_ERR("mmap dus fail\n");
|
||||||
|
+ WD_ERR("failed to mmap dus!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
q_info->mmio_base = wd_ctx_mmap_qfr(h_ctx, UACCE_QFRT_MMIO);
|
||||||
|
if (!q_info->mmio_base) {
|
||||||
|
wd_ctx_unmap_qfr(h_ctx, UACCE_QFRT_DUS);
|
||||||
|
- WD_ERR("mmap mmio fail\n");
|
||||||
|
+ WD_ERR("failed to mmap mmio!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -197,14 +197,14 @@ static __u32 get_version_id(handle_t h_ctx)
|
||||||
|
|
||||||
|
api_name = wd_ctx_get_api(h_ctx);
|
||||||
|
if (!api_name || strlen(api_name) <= VERSION_ID_SHIFT) {
|
||||||
|
- WD_ERR("api name error = %s\n", api_name);
|
||||||
|
+ WD_ERR("invalid: api name is %s!\n", api_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
id = api_name + VERSION_ID_SHIFT;
|
||||||
|
ver = strtoul(id, NULL, 10);
|
||||||
|
if (!ver || ver == ULONG_MAX) {
|
||||||
|
- WD_ERR("fail to strtoul, ver = %lu\n", ver);
|
||||||
|
+ WD_ERR("failed to strtoul, ver = %lu!\n", ver);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -250,7 +250,7 @@ static int his_qm_set_qp_ctx(handle_t h_ctx, struct hisi_qm_priv *config,
|
||||||
|
q_info->qc_type = qp_ctx.qc_type;
|
||||||
|
ret = wd_ctx_set_io_cmd(h_ctx, UACCE_CMD_QM_SET_QP_CTX, &qp_ctx);
|
||||||
|
if (ret < 0) {
|
||||||
|
- WD_ERR("HISI QM fail to set qc_type, use default value\n");
|
||||||
|
+ WD_ERR("failed to set qc_type, use default value!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -265,13 +265,13 @@ static int hisi_qm_get_qfrs_offs(handle_t h_ctx,
|
||||||
|
q_info->region_size[UACCE_QFRT_DUS] = wd_ctx_get_region_size(h_ctx,
|
||||||
|
UACCE_QFRT_DUS);
|
||||||
|
if (!q_info->region_size[UACCE_QFRT_DUS]) {
|
||||||
|
- WD_ERR("fail to get DUS qfrs offset.\n");
|
||||||
|
+ WD_ERR("failed to get DUS qfrs offset!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
q_info->region_size[UACCE_QFRT_MMIO] = wd_ctx_get_region_size(h_ctx,
|
||||||
|
UACCE_QFRT_MMIO);
|
||||||
|
if (!q_info->region_size[UACCE_QFRT_MMIO]) {
|
||||||
|
- WD_ERR("fail to get MMIO qfrs offset.\n");
|
||||||
|
+ WD_ERR("failed to get MMIO qfrs offset!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -286,25 +286,25 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
|
||||||
|
q_info = &qp->q_info;
|
||||||
|
ret = hisi_qm_setup_region(qp->h_ctx, q_info);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("setup region fail\n");
|
||||||
|
+ WD_ERR("failed to setup region!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = hisi_qm_get_qfrs_offs(qp->h_ctx, q_info);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("get dev qfrs offset fail.\n");
|
||||||
|
+ WD_ERR("failed to get dev qfrs offset!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = hisi_qm_setup_db(qp->h_ctx, q_info);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("setup db fail\n");
|
||||||
|
+ WD_ERR("failed to setup db!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = his_qm_set_qp_ctx(qp->h_ctx, config, q_info);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("setup io cmd fail\n");
|
||||||
|
+ WD_ERR("failed to setup io cmd!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -320,7 +320,7 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
|
||||||
|
|
||||||
|
ret = pthread_spin_init(&q_info->lock, PTHREAD_PROCESS_SHARED);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("init qinfo lock fail\n");
|
||||||
|
+ WD_ERR("failed to init qinfo lock!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -352,8 +352,8 @@ handle_t hisi_qm_alloc_qp(struct hisi_qm_priv *config, handle_t ctx)
|
||||||
|
if (!config)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
- if (config->sqe_size <= 0) {
|
||||||
|
- WD_ERR("invalid sqe size (%u)\n", config->sqe_size);
|
||||||
|
+ if (!config->sqe_size) {
|
||||||
|
+ WD_ERR("invalid: sqe size is zero!\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -367,7 +367,8 @@ handle_t hisi_qm_alloc_qp(struct hisi_qm_priv *config, handle_t ctx)
|
||||||
|
if (ret)
|
||||||
|
goto out_qp;
|
||||||
|
|
||||||
|
- qp->h_sgl_pool = hisi_qm_create_sglpool(HISI_SGL_NUM_IN_BD, HISI_SGE_NUM_IN_SGL);
|
||||||
|
+ qp->h_sgl_pool = hisi_qm_create_sglpool(HISI_SGL_NUM_IN_BD,
|
||||||
|
+ HISI_SGE_NUM_IN_SGL);
|
||||||
|
if (!qp->h_sgl_pool)
|
||||||
|
goto out_qp;
|
||||||
|
|
||||||
|
@@ -396,7 +397,7 @@ void hisi_qm_free_qp(handle_t h_qp)
|
||||||
|
struct hisi_qp *qp = (struct hisi_qp *)h_qp;
|
||||||
|
|
||||||
|
if (!qp) {
|
||||||
|
- WD_ERR("h_qp is NULL.\n");
|
||||||
|
+ WD_ERR("invalid: h_qp is NULL!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -461,7 +462,7 @@ static int hisi_qm_recv_single(struct hisi_qm_queue_info *q_info, void *resp)
|
||||||
|
j = CQE_SQ_HEAD_INDEX(cqe);
|
||||||
|
if (j >= QM_Q_DEPTH) {
|
||||||
|
pthread_spin_unlock(&q_info->lock);
|
||||||
|
- WD_ERR("CQE_SQ_HEAD_INDEX(%u) error\n", j);
|
||||||
|
+ WD_ERR("CQE_SQ_HEAD_INDEX(%u) error!\n", j);
|
||||||
|
return -WD_EIO;
|
||||||
|
}
|
||||||
|
memcpy(resp, (void *)((uintptr_t)q_info->sq_base +
|
||||||
|
@@ -535,7 +536,7 @@ static void *hisi_qm_create_sgl(__u32 sge_num)
|
||||||
|
sge_num * (sizeof(struct hisi_sge)) + HISI_SGL_ALIGE;
|
||||||
|
sgl = calloc(1, size);
|
||||||
|
if (!sgl) {
|
||||||
|
- WD_ERR("failed to create sgl\n");
|
||||||
|
+ WD_ERR("failed to create sgl!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -562,36 +563,34 @@ handle_t hisi_qm_create_sglpool(__u32 sgl_num, __u32 sge_num)
|
||||||
|
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",
|
||||||
|
+ WD_ERR("failed to create sgl_pool, sgl_num=%u, sge_num=%u!\n",
|
||||||
|
sgl_num, sge_num);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sgl_pool = calloc(1, sizeof(struct hisi_sgl_pool));
|
||||||
|
if (!sgl_pool) {
|
||||||
|
- WD_ERR("sgl pool alloc memory failed.\n");
|
||||||
|
+ WD_ERR("failed to alloc memory for sgl_pool!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sgl_pool->sgl = calloc(sgl_num, sizeof(void *));
|
||||||
|
if (!sgl_pool->sgl) {
|
||||||
|
- WD_ERR("sgl array alloc memory failed.\n");
|
||||||
|
+ WD_ERR("failed to alloc memory for sgl!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
sgl_pool->sgl_align = calloc(sgl_num, sizeof(void *));
|
||||||
|
if (!sgl_pool->sgl_align) {
|
||||||
|
- WD_ERR("sgl align array alloc memory failed.\n");
|
||||||
|
+ WD_ERR("failed to alloc memory for sgl align!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* base the sgl_num create the sgl chain */
|
||||||
|
for (i = 0; i < sgl_num; i++) {
|
||||||
|
sgl_pool->sgl[i] = hisi_qm_create_sgl(sge_num);
|
||||||
|
- if (!sgl_pool->sgl[i]) {
|
||||||
|
- WD_ERR("sgl create failed.\n");
|
||||||
|
+ if (!sgl_pool->sgl[i])
|
||||||
|
goto err_out;
|
||||||
|
- }
|
||||||
|
|
||||||
|
sgl_pool->sgl_align[i] = hisi_qm_align_sgl(sgl_pool->sgl[i], sge_num);
|
||||||
|
}
|
||||||
|
@@ -602,7 +601,7 @@ handle_t hisi_qm_create_sglpool(__u32 sgl_num, __u32 sge_num)
|
||||||
|
sgl_pool->top = sgl_num;
|
||||||
|
ret = pthread_spin_init(&sgl_pool->lock, PTHREAD_PROCESS_SHARED);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("init sgl pool lock failed.\n");
|
||||||
|
+ WD_ERR("failed to init sgl pool lock!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -619,7 +618,7 @@ void hisi_qm_destroy_sglpool(handle_t sgl_pool)
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!pool) {
|
||||||
|
- WD_ERR("sgl_pool is NULL\n");
|
||||||
|
+ WD_ERR("invalid: sgl_pool is NULL!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pool->sgl) {
|
||||||
|
@@ -642,7 +641,7 @@ static struct hisi_sgl *hisi_qm_sgl_pop(struct hisi_sgl_pool *pool)
|
||||||
|
pthread_spin_lock(&pool->lock);
|
||||||
|
|
||||||
|
if (pool->top == 0) {
|
||||||
|
- WD_ERR("The sgl pool is empty\n");
|
||||||
|
+ WD_ERR("invalid: the sgl pool is empty!\n");
|
||||||
|
pthread_spin_unlock(&pool->lock);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@@ -657,7 +656,7 @@ static int hisi_qm_sgl_push(struct hisi_sgl_pool *pool, struct hisi_sgl *hw_sgl)
|
||||||
|
{
|
||||||
|
pthread_spin_lock(&pool->lock);
|
||||||
|
if (pool->top >= pool->depth) {
|
||||||
|
- WD_ERR("The sgl pool is full\n");
|
||||||
|
+ WD_ERR("invalid: the sgl pool is full!\n");
|
||||||
|
pthread_spin_unlock(&pool->lock);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -705,7 +704,7 @@ void *hisi_qm_get_hw_sgl(handle_t sgl_pool, struct wd_datalist *sgl)
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (!pool || !sgl) {
|
||||||
|
- WD_ERR("get hw sgl pool or sgl is NULL\n");
|
||||||
|
+ WD_ERR("invalid: hw sgl pool or sgl is NULL!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -723,7 +722,7 @@ void *hisi_qm_get_hw_sgl(handle_t sgl_pool, struct wd_datalist *sgl)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmp->len > HISI_MAX_SIZE_IN_SGE) {
|
||||||
|
- WD_ERR("the data len is invalid: %u\n", tmp->len);
|
||||||
|
+ WD_ERR("invalid: the data len is %u!\n", tmp->len);
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -742,7 +741,7 @@ void *hisi_qm_get_hw_sgl(handle_t sgl_pool, struct wd_datalist *sgl)
|
||||||
|
if (i == pool->sge_num && tmp->next) {
|
||||||
|
next = hisi_qm_sgl_pop(pool);
|
||||||
|
if (!next) {
|
||||||
|
- WD_ERR("the sgl pool is not enough\n");
|
||||||
|
+ WD_ERR("invalid: the sgl pool is not enough!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
cur->next_dma = (uintptr_t)next;
|
||||||
|
diff --git a/wd.c b/wd.c
|
||||||
|
index b88ee62..0774837 100644
|
||||||
|
--- a/wd.c
|
||||||
|
+++ b/wd.c
|
||||||
|
@@ -59,14 +59,14 @@ static int get_raw_attr(const char *dev_root, const char *attr, char *buf,
|
||||||
|
|
||||||
|
fd = open(attr_path, O_RDONLY, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
- WD_ERR("open %s fail (%d)!\n", attr_path, -errno);
|
||||||
|
+ WD_ERR("failed to open %s(%d)!\n", attr_path, -errno);
|
||||||
|
return -WD_ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(buf, 0, sz);
|
||||||
|
size = read(fd, buf, sz);
|
||||||
|
if (size <= 0) {
|
||||||
|
- WD_ERR("read nothing at %s!\n", attr_path);
|
||||||
|
+ WD_ERR("failed to read anything at %s!\n", attr_path);
|
||||||
|
size = -WD_EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -601,7 +601,7 @@ static int check_alg_name(const char *alg_name)
|
||||||
|
while (alg_name[i] != '\0') {
|
||||||
|
i++;
|
||||||
|
if (i >= MAX_ATTR_STR_SIZE) {
|
||||||
|
- WD_ERR("get list failed, alg name is too long!\n");
|
||||||
|
+ WD_ERR("failed to get list, alg name is too long!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/wd_mempool.c b/wd_mempool.c
|
||||||
|
index b6e1088..bfacd28 100644
|
||||||
|
--- a/wd_mempool.c
|
||||||
|
+++ b/wd_mempool.c
|
||||||
|
@@ -206,12 +206,17 @@ static __always_inline unsigned long wd_ffs(unsigned long word)
|
||||||
|
|
||||||
|
static struct bitmap *create_bitmap(int bits)
|
||||||
|
{
|
||||||
|
- struct bitmap *bm = calloc(1, sizeof(*bm));
|
||||||
|
- if (!bm)
|
||||||
|
+ struct bitmap *bm;
|
||||||
|
+
|
||||||
|
+ bm = calloc(1, sizeof(*bm));
|
||||||
|
+ if (!bm) {
|
||||||
|
+ WD_ERR("failed to alloc memory for bitmap!\n");
|
||||||
|
return NULL;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
bm->map = calloc(BITS_TO_LONGS(bits), sizeof(unsigned long));
|
||||||
|
if (!bm->map) {
|
||||||
|
+ WD_ERR("failed to alloc memory for bitmap map!\n");
|
||||||
|
free(bm);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@@ -346,6 +351,7 @@ static int alloc_memzone(struct blkpool *bp, void *addr, size_t blk_num,
|
||||||
|
|
||||||
|
zone = calloc(1, sizeof(struct memzone));
|
||||||
|
if (!zone) {
|
||||||
|
+ WD_ERR("failed to alloc memory for memzone!\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -389,7 +395,8 @@ static void free_mem_to_mempool(struct blkpool *bp)
|
||||||
|
static int check_mempool_real_size(struct mempool *mp, struct blkpool *bp)
|
||||||
|
{
|
||||||
|
if (bp->blk_size * bp->depth > mp->real_size) {
|
||||||
|
- WD_ERR("wd_mempool: mempool too small: %lu\n", mp->real_size);
|
||||||
|
+ WD_ERR("invalid: mempool size is too small: %lu!\n",
|
||||||
|
+ mp->real_size);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -525,8 +532,10 @@ static int init_blkpool_elem(struct blkpool *bp)
|
||||||
|
int i;
|
||||||
|
|
||||||
|
bp->blk_elem = calloc(bp->depth, sizeof(void *));
|
||||||
|
- if (!bp->blk_elem)
|
||||||
|
+ if (!bp->blk_elem) {
|
||||||
|
+ WD_ERR("failed to alloc memory for blk_elem!\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
TAILQ_FOREACH(iter, &bp->mz_list, node) {
|
||||||
|
for (i = 0; i < iter->blk_num; i++)
|
||||||
|
@@ -544,7 +553,7 @@ handle_t wd_blockpool_create(handle_t mempool, size_t block_size,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!mp || !block_size || !block_num) {
|
||||||
|
- WD_ERR("wd_mempool: input parameter is invalid value\n");
|
||||||
|
+ WD_ERR("invalid: mempool is NULL or block param is 0!\n");
|
||||||
|
return (handle_t)(-WD_EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -552,8 +561,10 @@ handle_t wd_blockpool_create(handle_t mempool, size_t block_size,
|
||||||
|
return (handle_t)(-WD_EBUSY);
|
||||||
|
|
||||||
|
bp = calloc(1, sizeof(struct blkpool));
|
||||||
|
- if (!bp)
|
||||||
|
+ if (!bp) {
|
||||||
|
+ WD_ERR("failed to alloc memory for blkpool!\n");
|
||||||
|
return (handle_t)(-WD_ENOMEM);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
bp->top = block_num;
|
||||||
|
bp->depth = block_num;
|
||||||
|
@@ -563,13 +574,13 @@ handle_t wd_blockpool_create(handle_t mempool, size_t block_size,
|
||||||
|
|
||||||
|
ret = alloc_mem_from_mempool(mp, bp);
|
||||||
|
if (ret < 0) {
|
||||||
|
- WD_ERR("wd_mempool: failed to allocate memory from mempool\n");
|
||||||
|
+ WD_ERR("failed to allocate memory from mempool!\n");
|
||||||
|
goto err_free_bp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = init_blkpool_elem(bp);
|
||||||
|
if (ret < 0) {
|
||||||
|
- WD_ERR("wd_mempool: failed to init blkpool\n");
|
||||||
|
+ WD_ERR("failed to init blkpool!\n");
|
||||||
|
goto err_free_mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -590,7 +601,7 @@ void wd_blockpool_destroy(handle_t blkpool)
|
||||||
|
struct mempool *mp;
|
||||||
|
|
||||||
|
if (!bp) {
|
||||||
|
- WD_ERR("wd_mempool: blkpool is NULL\n");
|
||||||
|
+ WD_ERR("invalid: blkpool is NULL!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -620,13 +631,13 @@ static int get_value_from_sysfs(const char *path, ssize_t path_size)
|
||||||
|
|
||||||
|
fd = open(dev_path, O_RDONLY, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
- WD_ERR("wd_mempool: failed to open %s\n", dev_path);
|
||||||
|
+ WD_ERR("failed to open %s!\n", dev_path);
|
||||||
|
goto err_open;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = read(fd, buf, sizeof(buf));
|
||||||
|
if (size <= 0) {
|
||||||
|
- WD_ERR("wd_mempool: failed to read %s\n", dev_path);
|
||||||
|
+ WD_ERR("failed to read %s!\n", dev_path);
|
||||||
|
goto err_read;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -716,7 +727,7 @@ static int get_hugepage_info(struct mempool *mp)
|
||||||
|
|
||||||
|
dir = opendir(hugepage_path);
|
||||||
|
if (!dir) {
|
||||||
|
- WD_ERR("wd_mempool: failed to open %s\n", hugepage_path);
|
||||||
|
+ WD_ERR("failed to open %s\n!", hugepage_path);
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -728,13 +739,13 @@ static int get_hugepage_info(struct mempool *mp)
|
||||||
|
|
||||||
|
tmp = calloc(1, sizeof(*tmp));
|
||||||
|
if (!tmp) {
|
||||||
|
- WD_ERR("wd_mempool: failed to calloc\n");
|
||||||
|
+ WD_ERR("failed to calloc for sys_hugepage_config!\n");
|
||||||
|
goto err_free_list;
|
||||||
|
}
|
||||||
|
ret = get_hugepage_info_per_type(hugepage_path, MAX_HP_STR_SIZE,
|
||||||
|
hp_dir, tmp);
|
||||||
|
if (ret < 0) {
|
||||||
|
- WD_ERR("wd_mempool: failed to get hugepage info\n");
|
||||||
|
+ WD_ERR("failed to get hugepage info!\n");
|
||||||
|
goto err_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -779,7 +790,7 @@ static int mbind_memory(void *addr, size_t size, int node)
|
||||||
|
node_mask = 1U << (unsigned int)node;
|
||||||
|
ret = mbind(addr, size, MPOL_BIND, &node_mask, max_node, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
- WD_ERR("wd_mempool: failed to mbind memory, %d\n", ret);
|
||||||
|
+ WD_ERR("failed to mbind memory, ret is %d!\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -805,7 +816,7 @@ static int alloc_mem_from_hugepage(struct mempool *mp)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!iter) {
|
||||||
|
- WD_ERR("wd_mempool: failed to find proper hugepage\n");
|
||||||
|
+ WD_ERR("failed to find proper hugepage!\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_put_info;
|
||||||
|
}
|
||||||
|
@@ -826,7 +837,7 @@ static int alloc_mem_from_hugepage(struct mempool *mp)
|
||||||
|
p = mmap(NULL, real_size, PROT_READ | PROT_WRITE, MAP_PRIVATE |
|
||||||
|
MAP_ANONYMOUS | MAP_HUGETLB | flags, -1, 0);
|
||||||
|
if (p == MAP_FAILED) {
|
||||||
|
- WD_ERR("wd_mempool: failed to allocate huge page\n");
|
||||||
|
+ WD_ERR("failed to allocate huge page!\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_put_info;
|
||||||
|
}
|
||||||
|
@@ -862,7 +873,7 @@ static int alloc_mempool_memory(struct mempool *mp)
|
||||||
|
|
||||||
|
ret = alloc_mem_from_hugepage(mp);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("wd_mempool: failed to alloc memory from hugepage\n");
|
||||||
|
+ WD_ERR("failed to alloc memory from hugepage!\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -908,8 +919,10 @@ handle_t wd_mempool_create(size_t size, int node)
|
||||||
|
size += WD_MEMPOOL_BLOCK_SIZE - (WD_MEMPOOL_SIZE_MASK & size);
|
||||||
|
|
||||||
|
mp = calloc(1, sizeof(*mp));
|
||||||
|
- if (!mp)
|
||||||
|
+ if (!mp) {
|
||||||
|
+ WD_ERR("failed to alloc memory for mempool!\n");
|
||||||
|
return (handle_t)(-WD_ENOMEM);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
mp->node = node;
|
||||||
|
mp->size = size;
|
||||||
|
@@ -938,7 +951,7 @@ void wd_mempool_destroy(handle_t mempool)
|
||||||
|
struct mempool *mp = (struct mempool *)mempool;
|
||||||
|
|
||||||
|
if (!mp) {
|
||||||
|
- WD_ERR("wd_mempool: mempool is NULL\n");
|
||||||
|
+ WD_ERR("invalid: mempool is NULL!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -954,12 +967,12 @@ void wd_mempool_stats(handle_t mempool, struct wd_mempool_stats *stats)
|
||||||
|
struct mempool *mp = (struct mempool *)mempool;
|
||||||
|
|
||||||
|
if (!mp) {
|
||||||
|
- WD_ERR("wd_mempool: mempool is NULL\n");
|
||||||
|
+ WD_ERR("invalid: mempool is NULL!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stats) {
|
||||||
|
- WD_ERR("wd_mempool: mempool stats is NULL\n");
|
||||||
|
+ WD_ERR("invalid: mempool stats is NULL!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -984,7 +997,7 @@ void wd_blockpool_stats(handle_t blkpool, struct wd_blockpool_stats *stats)
|
||||||
|
struct memzone *iter;
|
||||||
|
|
||||||
|
if (!bp || !stats) {
|
||||||
|
- WD_ERR("wd_mempool: blkpool or stats is NULL\n");
|
||||||
|
+ WD_ERR("invalid: blkpool or stats is NULL!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1001,7 +1014,7 @@ void wd_blockpool_stats(handle_t blkpool, struct wd_blockpool_stats *stats)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!size) {
|
||||||
|
- WD_ERR("wd_mempool: blkpool size is zero\n");
|
||||||
|
+ WD_ERR("invalid: blkpool size is zero!\n");
|
||||||
|
wd_unspinlock(&bp->lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
diff --git a/wd_sched.c b/wd_sched.c
|
||||||
|
index ef90233..9b1998c 100644
|
||||||
|
--- a/wd_sched.c
|
||||||
|
+++ b/wd_sched.c
|
||||||
|
@@ -129,8 +129,8 @@ static bool sched_key_valid(struct wd_sched_ctx *ctx,
|
||||||
|
{
|
||||||
|
if (key->numa_id >= ctx->numa_num || key->mode >= SCHED_MODE_BUTT ||
|
||||||
|
key->type >= ctx->type_num) {
|
||||||
|
- WD_ERR("ERROR: %s key error - numa: %d, mode: %u, type: %u!\n",
|
||||||
|
- __FUNCTION__, key->numa_id, key->mode, key->type);
|
||||||
|
+ WD_ERR("invalid: sched key's numa: %d, mode: %u, type: %u!\n",
|
||||||
|
+ key->numa_id, key->mode, key->type);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -207,13 +207,13 @@ static int session_sched_poll_policy(handle_t sched_ctx,
|
||||||
|
__u16 i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- if (!sched_ctx || !count || !ctx) {
|
||||||
|
- WD_ERR("ERROR: %s the para is NULL!\n", __FUNCTION__);
|
||||||
|
+ if (!count || !ctx) {
|
||||||
|
+ WD_ERR("invalid: sched ctx is NULL or count is zero!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->numa_num > NUMA_NUM_NODES) {
|
||||||
|
- WD_ERR("ERROR: %s ctx numa num is invalid!\n", __FUNCTION__);
|
||||||
|
+ WD_ERR("invalid: ctx's numa number is %d!\n", ctx->numa_num);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -270,16 +270,14 @@ static __u32 session_sched_init_ctx(handle_t sched_ctx,
|
||||||
|
bool ret;
|
||||||
|
|
||||||
|
if (!ctx || !key) {
|
||||||
|
- WD_ERR("ERROR: %s the pointer para is NULL!\n", __FUNCTION__);
|
||||||
|
+ WD_ERR("invalid: sched ctx or key is NULL!\n");
|
||||||
|
return INVALID_POS;
|
||||||
|
}
|
||||||
|
|
||||||
|
key->mode = sched_mode;
|
||||||
|
ret = sched_key_valid(ctx, key);
|
||||||
|
- if (!ret) {
|
||||||
|
- WD_ERR("ERROR: %s the key is invalid!\n", __FUNCTION__);
|
||||||
|
+ if (!ret)
|
||||||
|
return INVALID_POS;
|
||||||
|
- }
|
||||||
|
|
||||||
|
region = sched_get_ctx_range(ctx, key);
|
||||||
|
if (!region)
|
||||||
|
@@ -295,7 +293,7 @@ handle_t session_sched_init(handle_t h_sched_ctx, void *sched_param)
|
||||||
|
|
||||||
|
skey = malloc(sizeof(struct sched_key));
|
||||||
|
if (!skey) {
|
||||||
|
- WD_ERR("fail to alloc session sched key!\n");
|
||||||
|
+ WD_ERR("failed to alloc memory for session sched key!\n");
|
||||||
|
return (handle_t)(-WD_ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -328,7 +326,7 @@ static __u32 session_sched_pick_next_ctx(handle_t sched_ctx,
|
||||||
|
struct sched_key *key = (struct sched_key *)sched_key;
|
||||||
|
|
||||||
|
if (unlikely(!sched_ctx || !key)) {
|
||||||
|
- WD_ERR("ERROR: %s the pointer para is NULL!\n", __FUNCTION__);
|
||||||
|
+ WD_ERR("invalid: sched ctx or key is NULL!\n");
|
||||||
|
return INVALID_POS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -357,13 +355,12 @@ int wd_sched_rr_instance(const struct wd_sched *sched,
|
||||||
|
int numa_id;
|
||||||
|
|
||||||
|
if (!sched || !sched->h_sched_ctx || !param) {
|
||||||
|
- WD_ERR("ERROR: %s para err: sched of h_sched_ctx is NULL!\n",
|
||||||
|
- __FUNCTION__);
|
||||||
|
+ WD_ERR("invalid: sched or sched_params is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param->begin > param->end) {
|
||||||
|
- WD_ERR("ERROR: sched_params's begin is larger than end!\n");
|
||||||
|
+ WD_ERR("invalid: sched_params's begin is larger than end!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -373,28 +370,28 @@ int wd_sched_rr_instance(const struct wd_sched *sched,
|
||||||
|
sched_ctx = (struct wd_sched_ctx *)sched->h_sched_ctx;
|
||||||
|
|
||||||
|
if (numa_id >= sched_ctx->numa_num || numa_id < 0) {
|
||||||
|
- WD_ERR("ERROR: %s para err: numa_id = %d, numa_num = %u\n",
|
||||||
|
- __FUNCTION__, numa_id, sched_ctx->numa_num);
|
||||||
|
+ WD_ERR("invalid: sched_ctx's numa_id is %d, numa_num is %u!\n",
|
||||||
|
+ numa_id, sched_ctx->numa_num);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type >= sched_ctx->type_num) {
|
||||||
|
- WD_ERR("ERROR: %s para err: type = %u, type_num = %u\n",
|
||||||
|
- __FUNCTION__, type, sched_ctx->type_num);
|
||||||
|
+ WD_ERR("invalid: sched_ctx's type is %u, type_num is %u!\n",
|
||||||
|
+ type, sched_ctx->type_num);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode >= SCHED_MODE_BUTT) {
|
||||||
|
- WD_ERR("ERROR: %s para err: mode = %u, mode_num = %d!\n",
|
||||||
|
- __FUNCTION__, mode, SCHED_MODE_BUTT);
|
||||||
|
+ WD_ERR("invalid: sched_ctx's mode is %u, mode_num is %d!\n",
|
||||||
|
+ mode, SCHED_MODE_BUTT);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sched_info = sched_ctx->sched_info;
|
||||||
|
|
||||||
|
if (!sched_info[numa_id].ctx_region[mode]) {
|
||||||
|
- WD_ERR("ERROR: %s ctx_region of numa_id = %d, mode = %u is NULL!\n",
|
||||||
|
- __FUNCTION__, numa_id, mode);
|
||||||
|
+ WD_ERR("invalid: ctx_region is NULL, numa: %d, mode: %u!\n",
|
||||||
|
+ numa_id, mode);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -454,27 +451,26 @@ struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!numa_num || numa_num > max_node) {
|
||||||
|
- WD_ERR("Error: %s numa number = %u!\n", __FUNCTION__,
|
||||||
|
- numa_num);
|
||||||
|
+ WD_ERR("invalid: numa number is %u!\n", 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",
|
||||||
|
- __FUNCTION__, sched_type, type_num);
|
||||||
|
+ WD_ERR("invalid: sched_type is %u or type_num is %u!\n",
|
||||||
|
+ sched_type, type_num);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sched = calloc(1, sizeof(struct wd_sched));
|
||||||
|
if (!sched) {
|
||||||
|
- WD_ERR("Error: %s wd_sched alloc error!\n", __FUNCTION__);
|
||||||
|
+ WD_ERR("failed to alloc memory for wd_sched!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sched_ctx = calloc(1, sizeof(struct wd_sched_ctx) +
|
||||||
|
sizeof(struct wd_sched_info) * numa_num);
|
||||||
|
if (!sched_ctx) {
|
||||||
|
- WD_ERR("Error: %s sched_ctx alloc error!\n", __FUNCTION__);
|
||||||
|
+ WD_ERR("failed to alloc memory for sched_ctx!\n");
|
||||||
|
goto err_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/wd_util.c b/wd_util.c
|
||||||
|
index 44c8909..03316b6 100644
|
||||||
|
--- a/wd_util.c
|
||||||
|
+++ b/wd_util.c
|
||||||
|
@@ -74,7 +74,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
|
||||||
|
int i, ret;
|
||||||
|
|
||||||
|
if (!cfg->ctx_num) {
|
||||||
|
- WD_ERR("invalid parameters, ctx_num is 0!\n");
|
||||||
|
+ WD_ERR("invalid: ctx_num is 0!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -90,7 +90,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
|
||||||
|
|
||||||
|
for (i = 0; i < cfg->ctx_num; i++) {
|
||||||
|
if (!cfg->ctxs[i].ctx) {
|
||||||
|
- WD_ERR("invalid parameters, ctx is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: ctx is NULL!\n");
|
||||||
|
free(ctxs);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -98,7 +98,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
|
||||||
|
clone_ctx_to_internal(cfg->ctxs + i, ctxs + i);
|
||||||
|
ret = pthread_spin_init(&ctxs[i].lock, PTHREAD_PROCESS_SHARED);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("init ctxs lock failed!\n");
|
||||||
|
+ WD_ERR("failed to init ctxs lock!\n");
|
||||||
|
free(ctxs);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@@ -243,7 +243,7 @@ void *wd_find_msg_in_pool(struct wd_async_msg_pool *pool,
|
||||||
|
|
||||||
|
/* tag value start from 1 */
|
||||||
|
if (tag == 0 || tag > msg_num) {
|
||||||
|
- WD_ERR("invalid message cache tag(%u)\n", tag);
|
||||||
|
+ WD_ERR("invalid: message cache tag is %u!\n", tag);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -279,7 +279,7 @@ void wd_put_msg_to_pool(struct wd_async_msg_pool *pool, int ctx_idx, __u32 tag)
|
||||||
|
|
||||||
|
/* tag value start from 1 */
|
||||||
|
if (!tag || tag > msg_num) {
|
||||||
|
- WD_ERR("invalid message cache idx(%u)\n", tag);
|
||||||
|
+ WD_ERR("invalid: message cache idx is %u!\n", tag);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -318,14 +318,11 @@ void dump_env_info(struct wd_env_config *config)
|
||||||
|
config_numa->async_ctx_num);
|
||||||
|
for (j = 0; j < CTX_MODE_MAX; j++)
|
||||||
|
for (k = 0; k < config_numa->op_type_num; k++) {
|
||||||
|
- WD_ERR("-> %s: %d: [%d][%d].begin: %u\n",
|
||||||
|
- __func__,
|
||||||
|
+ WD_ERR("-> %d: [%d][%d].begin: %u\n",
|
||||||
|
i, j, k, ctx_table[j][k].begin);
|
||||||
|
- WD_ERR("-> %s: %d: [%d][%d].end: %u\n",
|
||||||
|
- __func__,
|
||||||
|
+ WD_ERR("-> %d: [%d][%d].end: %u\n",
|
||||||
|
i, j, k, ctx_table[j][k].end);
|
||||||
|
- WD_ERR("-> %s: %d: [%d][%d].size: %u\n",
|
||||||
|
- __func__,
|
||||||
|
+ WD_ERR("-> %d: [%d][%d].size: %u\n",
|
||||||
|
i, j, k, ctx_table[j][k].size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -340,8 +337,10 @@ static void *wd_get_config_numa(struct wd_env_config *config, int node)
|
||||||
|
if (config_numa->node == node)
|
||||||
|
break;
|
||||||
|
|
||||||
|
- if (i == config->numa_num)
|
||||||
|
+ if (i == config->numa_num) {
|
||||||
|
+ WD_ERR("invalid: missing numa node is %d!\n", node);
|
||||||
|
return NULL;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return config_numa;
|
||||||
|
}
|
||||||
|
@@ -373,7 +372,7 @@ static __u16 wd_get_dev_numa(struct uacce_dev_list *head,
|
||||||
|
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);
|
||||||
|
+ WD_ERR("invalid: numa id is %d!\n", list->dev->numa_id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -396,10 +395,8 @@ 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("%s got wrong numa node!\n", __func__);
|
||||||
|
+ if (!config_numa)
|
||||||
|
break;
|
||||||
|
- }
|
||||||
|
|
||||||
|
dev = config_numa->dev + config_numa->dev_num;
|
||||||
|
memcpy(dev, list->dev, sizeof(*list->dev));
|
||||||
|
@@ -457,7 +454,7 @@ static int wd_alloc_numa(struct wd_env_config *config,
|
||||||
|
/* get uacce_dev */
|
||||||
|
head = wd_get_accel_list(ops->alg_name);
|
||||||
|
if (!head) {
|
||||||
|
- WD_ERR("no device to support %s\n", ops->alg_name);
|
||||||
|
+ WD_ERR("invalid: no device to support %s\n", ops->alg_name);
|
||||||
|
ret = -WD_ENODEV;
|
||||||
|
goto free_numa_dev_num;
|
||||||
|
}
|
||||||
|
@@ -465,7 +462,7 @@ static int wd_alloc_numa(struct wd_env_config *config,
|
||||||
|
/* 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);
|
||||||
|
+ WD_ERR("invalid: numa number is %u!\n", config->numa_num);
|
||||||
|
ret = -WD_ENODEV;
|
||||||
|
goto free_list;
|
||||||
|
}
|
||||||
|
@@ -519,13 +516,13 @@ int wd_parse_async_poll_en(struct wd_env_config *config, const char *s)
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
if (!is_number(s)) {
|
||||||
|
- WD_ERR("invalid async poll en flag: %s!\n", s);
|
||||||
|
+ WD_ERR("invalid: async poll en flag is %s!\n", s);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = strtol(s, NULL, 10);
|
||||||
|
if (tmp != 0 && tmp != 1) {
|
||||||
|
- WD_ERR("async poll en flag is not 0 or 1!\n");
|
||||||
|
+ WD_ERR("invalid: async poll en flag is not 0 or 1!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -539,7 +536,7 @@ static int parse_num_on_numa(const char *s, int *num, int *node)
|
||||||
|
char *sep, *start, *left;
|
||||||
|
|
||||||
|
if (!strlen(s)) {
|
||||||
|
- WD_ERR("input string length is zero!\n");
|
||||||
|
+ WD_ERR("invalid: input string length is zero!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -560,7 +557,7 @@ static int parse_num_on_numa(const char *s, int *num, int *node)
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
- WD_ERR("input env format is invalid:%s\n", s);
|
||||||
|
+ WD_ERR("invalid: input env format is %s!\n", s);
|
||||||
|
free(start);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -658,7 +655,7 @@ static int wd_parse_section(struct wd_env_config *config, char *section)
|
||||||
|
|
||||||
|
ctx_section = index(section, ':');
|
||||||
|
if (!ctx_section) {
|
||||||
|
- WD_ERR("%s got wrong format: %s!\n", __func__, section);
|
||||||
|
+ WD_ERR("invalid: ctx section got wrong format: %s!\n", section);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -669,10 +666,8 @@ static int wd_parse_section(struct wd_env_config *config, char *section)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
config_numa = wd_get_config_numa(config, node);
|
||||||
|
- if (!config_numa) {
|
||||||
|
- WD_ERR("%s got wrong numa node: %s!\n", __func__, section);
|
||||||
|
+ if (!config_numa)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
- }
|
||||||
|
|
||||||
|
config_numa->op_type_num = config->op_type_num;
|
||||||
|
ret = wd_alloc_ctx_table_per_numa(config_numa);
|
||||||
|
@@ -681,7 +676,8 @@ static int wd_parse_section(struct wd_env_config *config, char *section)
|
||||||
|
|
||||||
|
ret = get_and_fill_ctx_num(config_numa, section, ctx_num);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("%s got wrong ctx type: %s!\n", __func__, section);
|
||||||
|
+ WD_ERR("invalid: ctx section got wrong ctx type: %s!\n",
|
||||||
|
+ section);
|
||||||
|
wd_free_ctx_table_per_numa(config_numa);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@@ -798,8 +794,6 @@ int wd_parse_async_poll_num(struct wd_env_config *config, const char *s)
|
||||||
|
goto out;
|
||||||
|
config_numa = wd_get_config_numa(config, node);
|
||||||
|
if (!config_numa) {
|
||||||
|
- WD_ERR("%s got wrong numa node: %s!\n",
|
||||||
|
- __func__, section);
|
||||||
|
ret = -WD_EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
@@ -831,7 +825,7 @@ static int wd_parse_env(struct wd_env_config *config)
|
||||||
|
|
||||||
|
ret = var->parse_fn(config, var_s);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("fail to parse %s environment variable!\n",
|
||||||
|
+ WD_ERR("failed to parse %s environment variable!\n",
|
||||||
|
var->name);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -847,10 +841,8 @@ static int wd_parse_ctx_attr(struct wd_env_config *env_config,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
config_numa = wd_get_config_numa(env_config, attr->node);
|
||||||
|
- if (!config_numa) {
|
||||||
|
- WD_ERR("%s got wrong numa node!\n", __func__);
|
||||||
|
+ if (!config_numa)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
- }
|
||||||
|
|
||||||
|
config_numa->op_type_num = env_config->op_type_num;
|
||||||
|
ret = wd_alloc_ctx_table_per_numa(config_numa);
|
||||||
|
@@ -958,7 +950,7 @@ static int wd_get_wd_ctx(struct wd_env_config_per_numa *config,
|
||||||
|
h_ctx = request_ctx_on_numa(config);
|
||||||
|
if (!h_ctx) {
|
||||||
|
ret = -WD_EBUSY;
|
||||||
|
- WD_ERR("err: request too many ctxs\n");
|
||||||
|
+ WD_ERR("failed to request more ctxs!\n");
|
||||||
|
goto free_ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1149,7 +1141,7 @@ static struct async_task_queue *find_async_queue(struct wd_env_config *config,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config_numa->async_poll_num) {
|
||||||
|
- WD_ERR("invalid parameter, async_poll_num of numa is zero!\n");
|
||||||
|
+ WD_ERR("invalid: async_poll_num of numa is zero!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1304,17 +1296,17 @@ static int wd_init_one_task_queue(struct async_task_queue *task_queue,
|
||||||
|
task_queue->alg_poll_ctx = alg_poll_ctx;
|
||||||
|
|
||||||
|
if (sem_init(&task_queue->empty_sem, 0, depth)) {
|
||||||
|
- WD_ERR("empty_sem init failed.\n");
|
||||||
|
+ WD_ERR("failed to init empty_sem!\n");
|
||||||
|
goto err_free_head;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sem_init(&task_queue->full_sem, 0, 0)) {
|
||||||
|
- WD_ERR("full_sem init failed.\n");
|
||||||
|
+ WD_ERR("failed to init full_sem!\n");
|
||||||
|
goto err_uninit_empty_sem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pthread_mutex_init(&task_queue->lock, NULL)) {
|
||||||
|
- WD_ERR("mutex init failed.\n");
|
||||||
|
+ WD_ERR("failed to init task queue's mutex lock!\n");
|
||||||
|
goto err_uninit_full_sem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1323,7 +1315,7 @@ static int wd_init_one_task_queue(struct async_task_queue *task_queue,
|
||||||
|
task_queue->tid = 0;
|
||||||
|
if (pthread_create(&thread_id, &attr, async_poll_process_func,
|
||||||
|
task_queue)) {
|
||||||
|
- WD_ERR("create poll thread failed.\n");
|
||||||
|
+ WD_ERR("failed to create poll thread!\n");
|
||||||
|
goto err_destory_mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1547,18 +1539,15 @@ int wd_alg_get_env_param(struct wd_env_config *env_config,
|
||||||
|
struct wd_env_config_per_numa *config_numa;
|
||||||
|
|
||||||
|
if (!num || !is_enable) {
|
||||||
|
- WD_ERR("input parameter num or is_enable is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: input pointer num or is_enable is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*is_enable = env_config->enable_internal_poll;
|
||||||
|
|
||||||
|
config_numa = wd_get_config_numa(env_config, attr.node);
|
||||||
|
- if (!config_numa) {
|
||||||
|
- WD_ERR("%s got wrong numa node: %u!\n",
|
||||||
|
- __func__, attr.node);
|
||||||
|
+ if (!config_numa)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
- }
|
||||||
|
|
||||||
|
*num = (config_numa->ctx_table) ?
|
||||||
|
config_numa->ctx_table[attr.mode][attr.type].size : 0;
|
||||||
|
@@ -1570,7 +1559,7 @@ int wd_set_ctx_attr(struct wd_ctx_attr *ctx_attr,
|
||||||
|
__u32 node, __u32 type, __u8 mode, __u32 num)
|
||||||
|
{
|
||||||
|
if (mode >= CTX_MODE_MAX) {
|
||||||
|
- WD_ERR("wrong ctx mode(%u))!\n", mode);
|
||||||
|
+ WD_ERR("invalid: ctx mode is %u!\n", mode);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1594,7 +1583,7 @@ int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx)
|
||||||
|
|
||||||
|
ctx = config->ctxs + idx;
|
||||||
|
if (ctx->ctx_mode != mode) {
|
||||||
|
- WD_ERR("ctx %u mode = %hhu error!\n", idx, ctx->ctx_mode);
|
||||||
|
+ WD_ERR("invalid: ctx(%u) mode is %hhu!\n", idx, ctx->ctx_mode);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
68
0081-uadk-v1-fix-wd_bmm-pool_init.patch
Normal file
68
0081-uadk-v1-fix-wd_bmm-pool_init.patch
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
From b56736c04686f0611e6b3865dd894cba62a3b0a2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:03:12 +0800
|
||||||
|
Subject: [PATCH 089/109] uadk: v1: fix wd_bmm pool_init
|
||||||
|
|
||||||
|
setup br alloc and free should be checked at the same time,
|
||||||
|
wd_reserve_memory should be rolled back.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
v1/wd_bmm.c | 15 +++++----------
|
||||||
|
1 file changed, 5 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/v1/wd_bmm.c b/v1/wd_bmm.c
|
||||||
|
index af59983..11f2ee8 100644
|
||||||
|
--- a/v1/wd_bmm.c
|
||||||
|
+++ b/v1/wd_bmm.c
|
||||||
|
@@ -216,7 +216,7 @@ static void *pool_init(struct wd_queue *q, struct wd_blkpool *pool,
|
||||||
|
void *addr = NULL;
|
||||||
|
|
||||||
|
/* use user's memory, and its br alloc function */
|
||||||
|
- if (setup->br.alloc) {
|
||||||
|
+ if (setup->br.alloc && setup->br.free) {
|
||||||
|
addr = setup->br.alloc(setup->br.usr, pool->act_mem_sz);
|
||||||
|
if (!addr) {
|
||||||
|
WD_ERR("failed to allocate memory in user pool.\n");
|
||||||
|
@@ -226,14 +226,15 @@ static void *pool_init(struct wd_queue *q, struct wd_blkpool *pool,
|
||||||
|
pool->usr_mem_start = addr;
|
||||||
|
if (usr_pool_init(pool)) {
|
||||||
|
WD_ERR("failed to initialize user pool.\n");
|
||||||
|
- goto err_pool_init;
|
||||||
|
+ setup->br.free(setup->br.usr, addr);
|
||||||
|
+ return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* use wd to reserve memory */
|
||||||
|
addr = wd_reserve_memory(q, pool->act_mem_sz);
|
||||||
|
if (!addr) {
|
||||||
|
WD_ERR("wd pool failed to reserve memory.\n");
|
||||||
|
- goto err_pool_init;
|
||||||
|
+ return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pool->usr_mem_start = addr;
|
||||||
|
@@ -241,19 +242,13 @@ static void *pool_init(struct wd_queue *q, struct wd_blkpool *pool,
|
||||||
|
WD_ERR("failed to initialize wd pool.\n");
|
||||||
|
|
||||||
|
/* release q will free memory */
|
||||||
|
- goto err_pool_init;
|
||||||
|
+ return NULL;
|
||||||
|
}
|
||||||
|
setup->block_num = pool->setup.block_num;
|
||||||
|
pool->q = q;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pool;
|
||||||
|
-
|
||||||
|
-err_pool_init:
|
||||||
|
- if (setup->br.alloc && setup->br.free)
|
||||||
|
- setup->br.free(setup->br.usr, addr);
|
||||||
|
-
|
||||||
|
- return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *wd_blkpool_create(struct wd_queue *q, struct wd_blkpool_setup *setup)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
116
0082-uadk-v1-fix-wd-create-ctx-memory-leak.patch
Normal file
116
0082-uadk-v1-fix-wd-create-ctx-memory-leak.patch
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
From 5f9d701e8a56f4b7a0ff9c1b0c24fd130427cf1f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:03:13 +0800
|
||||||
|
Subject: [PATCH 090/109] uadk: v1: fix wd create ctx memory leak
|
||||||
|
|
||||||
|
ctx's block memory should be freed if wd fail to create ctx.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
v1/wd_aead.c | 12 ++++++++----
|
||||||
|
v1/wd_cipher.c | 5 ++++-
|
||||||
|
v1/wd_dh.c | 4 +++-
|
||||||
|
v1/wd_digest.c | 6 +++++-
|
||||||
|
4 files changed, 20 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/v1/wd_aead.c b/v1/wd_aead.c
|
||||||
|
index 6d8c541..ec537b3 100644
|
||||||
|
--- a/v1/wd_aead.c
|
||||||
|
+++ b/v1/wd_aead.c
|
||||||
|
@@ -229,14 +229,13 @@ void *wcrypto_create_aead_ctx(struct wd_queue *q,
|
||||||
|
ctx->ckey = setup->br.alloc(setup->br.usr, MAX_CIPHER_KEY_SIZE);
|
||||||
|
if (!ctx->ckey) {
|
||||||
|
WD_ERR("fail to alloc cipher ctx key!\n");
|
||||||
|
- free(ctx);
|
||||||
|
- goto free_ctx_id;
|
||||||
|
+ goto free_ctx;
|
||||||
|
}
|
||||||
|
ctx->akey = setup->br.alloc(setup->br.usr, MAX_AEAD_KEY_SIZE);
|
||||||
|
if (!ctx->akey) {
|
||||||
|
WD_ERR("fail to alloc authenticate ctx key!\n");
|
||||||
|
setup->br.free(setup->br.usr, ctx->ckey);
|
||||||
|
- goto free_ctx;
|
||||||
|
+ goto free_ctx_ckey;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->iv_blk_size = get_iv_block_size(setup->cmode);
|
||||||
|
@@ -244,11 +243,16 @@ void *wcrypto_create_aead_ctx(struct wd_queue *q,
|
||||||
|
sizeof(struct wcrypto_aead_cookie), WD_CTX_MSG_NUM);
|
||||||
|
if (ret) {
|
||||||
|
WD_ERR("fail to init cookie pool!\n");
|
||||||
|
- goto free_ctx;
|
||||||
|
+ goto free_ctx_akey;
|
||||||
|
}
|
||||||
|
init_aead_cookie(ctx, setup);
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
+
|
||||||
|
+free_ctx_akey:
|
||||||
|
+ setup->br.free(setup->br.usr, ctx->akey);
|
||||||
|
+free_ctx_ckey:
|
||||||
|
+ setup->br.free(setup->br.usr, ctx->ckey);
|
||||||
|
free_ctx:
|
||||||
|
free(ctx);
|
||||||
|
free_ctx_id:
|
||||||
|
diff --git a/v1/wd_cipher.c b/v1/wd_cipher.c
|
||||||
|
index 8bf71be..921c464 100644
|
||||||
|
--- a/v1/wd_cipher.c
|
||||||
|
+++ b/v1/wd_cipher.c
|
||||||
|
@@ -217,11 +217,14 @@ void *wcrypto_create_cipher_ctx(struct wd_queue *q,
|
||||||
|
sizeof(struct wcrypto_cipher_cookie), WD_CTX_MSG_NUM);
|
||||||
|
if (ret) {
|
||||||
|
WD_ERR("fail to init cookie pool!\n");
|
||||||
|
- goto free_ctx;
|
||||||
|
+ goto free_ctx_key;
|
||||||
|
}
|
||||||
|
init_cipher_cookie(ctx, setup);
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
+
|
||||||
|
+free_ctx_key:
|
||||||
|
+ setup->br.free(setup->br.usr, ctx->key);
|
||||||
|
free_ctx:
|
||||||
|
free(ctx);
|
||||||
|
free_ctx_id:
|
||||||
|
diff --git a/v1/wd_dh.c b/v1/wd_dh.c
|
||||||
|
index f83dd91..66f1081 100644
|
||||||
|
--- a/v1/wd_dh.c
|
||||||
|
+++ b/v1/wd_dh.c
|
||||||
|
@@ -174,10 +174,12 @@ void *wcrypto_create_dh_ctx(struct wd_queue *q, struct wcrypto_dh_ctx_setup *set
|
||||||
|
|
||||||
|
ret = wcrypto_init_dh_cookie(ctx);
|
||||||
|
if (ret)
|
||||||
|
- goto free_ctx;
|
||||||
|
+ goto free_ctx_gdata;
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
|
||||||
|
+free_ctx_gdata:
|
||||||
|
+ setup->br.free(setup->br.usr, ctx->g.data);
|
||||||
|
free_ctx:
|
||||||
|
free(ctx);
|
||||||
|
free_ctx_id:
|
||||||
|
diff --git a/v1/wd_digest.c b/v1/wd_digest.c
|
||||||
|
index 2179415..c84e71d 100644
|
||||||
|
--- a/v1/wd_digest.c
|
||||||
|
+++ b/v1/wd_digest.c
|
||||||
|
@@ -199,11 +199,15 @@ void *wcrypto_create_digest_ctx(struct wd_queue *q,
|
||||||
|
sizeof(struct wcrypto_digest_cookie), WD_CTX_MSG_NUM);
|
||||||
|
if (ret) {
|
||||||
|
WD_ERR("fail to init cookie pool!\n");
|
||||||
|
- goto free_ctx;
|
||||||
|
+ goto free_ctx_key;
|
||||||
|
}
|
||||||
|
init_digest_cookie(ctx, setup);
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
+
|
||||||
|
+free_ctx_key:
|
||||||
|
+ if (setup->mode == WCRYPTO_DIGEST_HMAC)
|
||||||
|
+ setup->br.free(setup->br.usr, ctx->key);
|
||||||
|
free_ctx:
|
||||||
|
free(ctx);
|
||||||
|
free_ctx_id:
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
51
0083-uadk-mempool-fix-redundant-assignment.patch
Normal file
51
0083-uadk-mempool-fix-redundant-assignment.patch
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
From 00d8dd57f97586658770a258f3e8fb331180f457 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:03:15 +0800
|
||||||
|
Subject: [PATCH 091/109] uadk: mempool: fix redundant assignment
|
||||||
|
|
||||||
|
1. pos_first is no need to be assinged because it
|
||||||
|
will get a value later.
|
||||||
|
2. improve performance by giving other threads or
|
||||||
|
processes a chance to run
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
wd_mempool.c | 7 +++++--
|
||||||
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/wd_mempool.c b/wd_mempool.c
|
||||||
|
index bfacd28..8467c48 100644
|
||||||
|
--- a/wd_mempool.c
|
||||||
|
+++ b/wd_mempool.c
|
||||||
|
@@ -14,6 +14,7 @@
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/queue.h>
|
||||||
|
+#include <pthread.h>
|
||||||
|
#include "wd.h"
|
||||||
|
|
||||||
|
#define SYSFS_NODE_PATH "/sys/devices/system/node/node"
|
||||||
|
@@ -409,8 +410,8 @@ static int alloc_block_from_mempool(struct mempool *mp,
|
||||||
|
int mem_combined_num,
|
||||||
|
int mem_splited_num)
|
||||||
|
{
|
||||||
|
- int pos_first = pos;
|
||||||
|
int pos_last = pos;
|
||||||
|
+ int pos_first;
|
||||||
|
int i, ret;
|
||||||
|
|
||||||
|
do {
|
||||||
|
@@ -607,7 +608,9 @@ void wd_blockpool_destroy(handle_t blkpool)
|
||||||
|
|
||||||
|
mp = bp->mp;
|
||||||
|
wd_atomic_sub(&bp->ref, 1);
|
||||||
|
- while(wd_atomic_load(&bp->ref));
|
||||||
|
+ while (wd_atomic_load(&bp->ref))
|
||||||
|
+ sched_yield();
|
||||||
|
+
|
||||||
|
free_mem_to_mempool(bp);
|
||||||
|
free(bp->blk_elem);
|
||||||
|
free(bp);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
126
0084-uadk-v1-fix-del-ctx.patch
Normal file
126
0084-uadk-v1-fix-del-ctx.patch
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
From 26661c4ae49d1c4c6914d8aba4e8d32db609d24b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:03:16 +0800
|
||||||
|
Subject: [PATCH 092/109] uadk: v1: fix del ctx
|
||||||
|
|
||||||
|
It is better to check whether the number of CTX
|
||||||
|
is greater than 0 before del ctx.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
v1/wd_aead.c | 11 +++++------
|
||||||
|
v1/wd_cipher.c | 12 ++++++------
|
||||||
|
v1/wd_comp.c | 13 +++++++------
|
||||||
|
v1/wd_digest.c | 11 +++++------
|
||||||
|
4 files changed, 23 insertions(+), 24 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/v1/wd_aead.c b/v1/wd_aead.c
|
||||||
|
index ec537b3..cf358bf 100644
|
||||||
|
--- a/v1/wd_aead.c
|
||||||
|
+++ b/v1/wd_aead.c
|
||||||
|
@@ -685,16 +685,15 @@ void wcrypto_del_aead_ctx(void *ctx)
|
||||||
|
qinfo = ctxt->q->qinfo;
|
||||||
|
wd_uninit_cookie_pool(&ctxt->pool);
|
||||||
|
wd_spinlock(&qinfo->qlock);
|
||||||
|
- wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, ctxt->ctx_id - 1,
|
||||||
|
- WD_MAX_CTX_NUM);
|
||||||
|
- qinfo->ctx_num--;
|
||||||
|
- if (!qinfo->ctx_num)
|
||||||
|
- memset(&qinfo->br, 0, sizeof(qinfo->br));
|
||||||
|
- if (qinfo->ctx_num < 0) {
|
||||||
|
+ if (qinfo->ctx_num <= 0) {
|
||||||
|
wd_unspinlock(&qinfo->qlock);
|
||||||
|
WD_ERR("fail to delete aead ctx!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
+ wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, ctxt->ctx_id - 1,
|
||||||
|
+ WD_MAX_CTX_NUM);
|
||||||
|
+ if (!(--qinfo->ctx_num))
|
||||||
|
+ memset(&qinfo->br, 0, sizeof(qinfo->br));
|
||||||
|
wd_unspinlock(&qinfo->qlock);
|
||||||
|
del_ctx_key(ctxt);
|
||||||
|
free(ctx);
|
||||||
|
diff --git a/v1/wd_cipher.c b/v1/wd_cipher.c
|
||||||
|
index 921c464..8eb6a6f 100644
|
||||||
|
--- a/v1/wd_cipher.c
|
||||||
|
+++ b/v1/wd_cipher.c
|
||||||
|
@@ -553,16 +553,16 @@ void wcrypto_del_cipher_ctx(void *ctx)
|
||||||
|
qinfo = c_ctx->q->qinfo;
|
||||||
|
wd_uninit_cookie_pool(&c_ctx->pool);
|
||||||
|
wd_spinlock(&qinfo->qlock);
|
||||||
|
- wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, c_ctx->ctx_id - 1,
|
||||||
|
- WD_MAX_CTX_NUM);
|
||||||
|
- qinfo->ctx_num--;
|
||||||
|
- if (!qinfo->ctx_num)
|
||||||
|
- memset(&qinfo->br, 0, sizeof(qinfo->br));
|
||||||
|
- if (qinfo->ctx_num < 0) {
|
||||||
|
+ if (qinfo->ctx_num <= 0) {
|
||||||
|
wd_unspinlock(&qinfo->qlock);
|
||||||
|
WD_ERR("error:repeat del cipher ctx!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
+ wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, c_ctx->ctx_id - 1,
|
||||||
|
+ WD_MAX_CTX_NUM);
|
||||||
|
+ if (!(--qinfo->ctx_num))
|
||||||
|
+ memset(&qinfo->br, 0, sizeof(qinfo->br));
|
||||||
|
+
|
||||||
|
wd_unspinlock(&qinfo->qlock);
|
||||||
|
del_ctx_key(c_ctx);
|
||||||
|
free(ctx);
|
||||||
|
diff --git a/v1/wd_comp.c b/v1/wd_comp.c
|
||||||
|
index 32d89c8..4ce79bd 100644
|
||||||
|
--- a/v1/wd_comp.c
|
||||||
|
+++ b/v1/wd_comp.c
|
||||||
|
@@ -339,16 +339,17 @@ void wcrypto_del_comp_ctx(void *ctx)
|
||||||
|
|
||||||
|
wd_uninit_cookie_pool(&cctx->pool);
|
||||||
|
wd_spinlock(&qinfo->qlock);
|
||||||
|
- wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, cctx->ctx_id -1,
|
||||||
|
- WD_MAX_CTX_NUM);
|
||||||
|
- qinfo->ctx_num--;
|
||||||
|
- if (!qinfo->ctx_num) {
|
||||||
|
- memset(&qinfo->br, 0, sizeof(qinfo->br));
|
||||||
|
- } else if (qinfo->ctx_num < 0) {
|
||||||
|
+ if (qinfo->ctx_num <= 0) {
|
||||||
|
wd_unspinlock(&qinfo->qlock);
|
||||||
|
WD_ERR("error: repeat delete compress ctx!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, cctx->ctx_id -1,
|
||||||
|
+ WD_MAX_CTX_NUM);
|
||||||
|
+ if (!(--qinfo->ctx_num))
|
||||||
|
+ memset(&qinfo->br, 0, sizeof(qinfo->br));
|
||||||
|
+
|
||||||
|
wd_unspinlock(&qinfo->qlock);
|
||||||
|
|
||||||
|
free(cctx);
|
||||||
|
diff --git a/v1/wd_digest.c b/v1/wd_digest.c
|
||||||
|
index c84e71d..5acb660 100644
|
||||||
|
--- a/v1/wd_digest.c
|
||||||
|
+++ b/v1/wd_digest.c
|
||||||
|
@@ -472,16 +472,15 @@ void wcrypto_del_digest_ctx(void *ctx)
|
||||||
|
qinfo = d_ctx->q->qinfo;
|
||||||
|
wd_uninit_cookie_pool(&d_ctx->pool);
|
||||||
|
wd_spinlock(&qinfo->qlock);
|
||||||
|
- wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, d_ctx->ctx_id - 1,
|
||||||
|
- WD_MAX_CTX_NUM);
|
||||||
|
- qinfo->ctx_num--;
|
||||||
|
- if (!qinfo->ctx_num)
|
||||||
|
- memset(&qinfo->br, 0, sizeof(qinfo->br));
|
||||||
|
- if (qinfo->ctx_num < 0) {
|
||||||
|
+ if (qinfo->ctx_num <= 0) {
|
||||||
|
wd_unspinlock(&qinfo->qlock);
|
||||||
|
WD_ERR("error: repeat del digest ctx!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
+ wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, d_ctx->ctx_id - 1,
|
||||||
|
+ WD_MAX_CTX_NUM);
|
||||||
|
+ if (!(--qinfo->ctx_num))
|
||||||
|
+ memset(&qinfo->br, 0, sizeof(qinfo->br));
|
||||||
|
wd_unspinlock(&qinfo->qlock);
|
||||||
|
del_ctx_key(d_ctx);
|
||||||
|
free(ctx);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
110
0085-uadk-v1-clean-code-for-wd.patch
Normal file
110
0085-uadk-v1-clean-code-for-wd.patch
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
From 3b201e8cfc8306e84dc51cbeccd86510e9c0da50 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:03:17 +0800
|
||||||
|
Subject: [PATCH 093/109] uadk: v1: clean code for wd
|
||||||
|
|
||||||
|
1. get_int_attr should return INT_MAX instead of
|
||||||
|
INT_MAX_SIZE.
|
||||||
|
2. qinfo should be set to NULL if memory is freed,
|
||||||
|
q_info memory should be freed at last.
|
||||||
|
3. optimize is_alg_support
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
v1/wd.c | 23 ++++++++++++++++-------
|
||||||
|
v1/wd.h | 1 -
|
||||||
|
2 files changed, 16 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/v1/wd.c b/v1/wd.c
|
||||||
|
index 26f6692..39c4167 100644
|
||||||
|
--- a/v1/wd.c
|
||||||
|
+++ b/v1/wd.c
|
||||||
|
@@ -27,6 +27,7 @@
|
||||||
|
#include <assert.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
|
+#include <limits.h>
|
||||||
|
|
||||||
|
#include "v1/wd.h"
|
||||||
|
#include "v1/wd_util.h"
|
||||||
|
@@ -118,8 +119,10 @@ static int get_int_attr(struct dev_info *dinfo, const char *attr)
|
||||||
|
* When the value is bigger than INT_MAX, it returns INT_MAX
|
||||||
|
*/
|
||||||
|
size = get_raw_attr(dinfo->dev_root, attr, buf, MAX_ATTR_STR_SIZE);
|
||||||
|
- if (size < 0 || size >= INT_MAX_SIZE)
|
||||||
|
+ if (size < 0)
|
||||||
|
return size;
|
||||||
|
+ else if (size >= INT_MAX_SIZE)
|
||||||
|
+ return INT_MAX;
|
||||||
|
/* Handing the read string's end tails '\n' to '\0' */
|
||||||
|
buf[size] = '\0';
|
||||||
|
return atoi((char *)buf);
|
||||||
|
@@ -186,19 +189,23 @@ static int get_ul_vec_attr(struct dev_info *dinfo, const char *attr,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int is_alg_support(struct dev_info *dinfo, const char *alg)
|
||||||
|
+static bool is_alg_support(struct dev_info *dinfo, const char *alg)
|
||||||
|
{
|
||||||
|
- int alg_support_flag = 0;
|
||||||
|
char *alg_save = NULL;
|
||||||
|
char *alg_tmp;
|
||||||
|
|
||||||
|
+ if (!alg)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
alg_tmp = strtok_r(dinfo->algs, "\n", &alg_save);
|
||||||
|
while (alg_tmp != NULL) {
|
||||||
|
- if (alg && !strcmp(alg_tmp, alg))
|
||||||
|
- alg_support_flag++;
|
||||||
|
+ if (!strcmp(alg_tmp, alg))
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
alg_tmp = strtok_r(NULL, "\n", &alg_save);
|
||||||
|
}
|
||||||
|
- return alg_support_flag;
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_weight_more(unsigned int new, unsigned int old)
|
||||||
|
@@ -279,7 +286,7 @@ static int get_str_attr_all(struct dev_info *dinfo, const char *alg)
|
||||||
|
|
||||||
|
/* Add algorithm check to cut later pointless logic */
|
||||||
|
ret = is_alg_support(dinfo, alg);
|
||||||
|
- if (ret == 0)
|
||||||
|
+ if (!ret)
|
||||||
|
return -EPFNOSUPPORT;
|
||||||
|
|
||||||
|
ret = get_str_attr(dinfo, "api", dinfo->api, WD_NAME_SIZE);
|
||||||
|
@@ -605,6 +612,7 @@ err_with_fd:
|
||||||
|
wd_close_queue(q);
|
||||||
|
err_with_dev:
|
||||||
|
free(dinfop);
|
||||||
|
+ q->qinfo = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -647,6 +655,7 @@ void wd_release_queue(struct wd_queue *q)
|
||||||
|
|
||||||
|
wd_close_queue(q);
|
||||||
|
free((void *)qinfo->dev_info);
|
||||||
|
+ q->qinfo = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wd_send(struct wd_queue *q, void *req)
|
||||||
|
diff --git a/v1/wd.h b/v1/wd.h
|
||||||
|
index 3dd69eb..429c6b6 100644
|
||||||
|
--- a/v1/wd.h
|
||||||
|
+++ b/v1/wd.h
|
||||||
|
@@ -28,7 +28,6 @@
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
-#include <limits.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include "uacce.h"
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
110
0086-uadk-v1-fix-drv_reserve_mem-memory-leak.patch
Normal file
110
0086-uadk-v1-fix-drv_reserve_mem-memory-leak.patch
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
From b68986ce59e52b57256eaef90c6e24493822a3ee Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:03:19 +0800
|
||||||
|
Subject: [PATCH 094/109] uadk: v1: fix drv_reserve_mem memory leak
|
||||||
|
|
||||||
|
share region memory should be freed and
|
||||||
|
qfr region should be unmaped if drv_reserve_mem fail.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
v1/wd.c | 9 +--------
|
||||||
|
v1/wd_adapter.c | 24 ++++++++++++++++++++++--
|
||||||
|
v1/wd_adapter.h | 1 +
|
||||||
|
3 files changed, 24 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/v1/wd.c b/v1/wd.c
|
||||||
|
index 39c4167..b94ec43 100644
|
||||||
|
--- a/v1/wd.c
|
||||||
|
+++ b/v1/wd.c
|
||||||
|
@@ -618,7 +618,6 @@ err_with_dev:
|
||||||
|
|
||||||
|
void wd_release_queue(struct wd_queue *q)
|
||||||
|
{
|
||||||
|
- struct wd_ss_region *rg;
|
||||||
|
struct wd_ss_region_list *head;
|
||||||
|
struct q_info *qinfo, *sqinfo;
|
||||||
|
|
||||||
|
@@ -645,13 +644,7 @@ void wd_release_queue(struct wd_queue *q)
|
||||||
|
if (qinfo->ss_size)
|
||||||
|
drv_unmap_reserve_mem(q, qinfo->ss_va, qinfo->ss_size);
|
||||||
|
|
||||||
|
- while (true) {
|
||||||
|
- rg = TAILQ_FIRST(&qinfo->ss_list);
|
||||||
|
- if (!rg)
|
||||||
|
- break;
|
||||||
|
- TAILQ_REMOVE(&qinfo->ss_list, rg, next);
|
||||||
|
- free(rg);
|
||||||
|
- }
|
||||||
|
+ drv_free_slice(q);
|
||||||
|
|
||||||
|
wd_close_queue(q);
|
||||||
|
free((void *)qinfo->dev_info);
|
||||||
|
diff --git a/v1/wd_adapter.c b/v1/wd_adapter.c
|
||||||
|
index f8bef2b..e53c561 100644
|
||||||
|
--- a/v1/wd_adapter.c
|
||||||
|
+++ b/v1/wd_adapter.c
|
||||||
|
@@ -150,6 +150,20 @@ int drv_recv(struct wd_queue *q, void **req, __u32 num)
|
||||||
|
return hw_dio_tbl[qinfo->hw_type_id].recv(q, req, num);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void drv_free_slice(struct wd_queue *q)
|
||||||
|
+{
|
||||||
|
+ struct q_info *qinfo = q->qinfo;
|
||||||
|
+ struct wd_ss_region *rgn;
|
||||||
|
+
|
||||||
|
+ while (true) {
|
||||||
|
+ rgn = TAILQ_FIRST(&qinfo->ss_list);
|
||||||
|
+ if (!rgn)
|
||||||
|
+ break;
|
||||||
|
+ TAILQ_REMOVE(&qinfo->ss_list, rgn, next);
|
||||||
|
+ free(rgn);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void drv_add_slice(struct wd_queue *q, struct wd_ss_region *rgn)
|
||||||
|
{
|
||||||
|
struct q_info *qinfo = q->qinfo;
|
||||||
|
@@ -209,12 +223,12 @@ void *drv_reserve_mem(struct wd_queue *q, size_t size)
|
||||||
|
if (ret < 0) {
|
||||||
|
drv_show_ss_slices(q);
|
||||||
|
WD_ERR("get DMA fail!\n");
|
||||||
|
- return NULL;
|
||||||
|
+ goto err_out;
|
||||||
|
}
|
||||||
|
rgn = malloc(sizeof(*rgn));
|
||||||
|
if (!rgn) {
|
||||||
|
WD_ERR("alloc ss region fail!\n");
|
||||||
|
- return NULL;
|
||||||
|
+ goto err_out;
|
||||||
|
}
|
||||||
|
memset(rgn, 0, sizeof(*rgn));
|
||||||
|
|
||||||
|
@@ -231,6 +245,12 @@ void *drv_reserve_mem(struct wd_queue *q, size_t size)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
+
|
||||||
|
+err_out:
|
||||||
|
+ drv_free_slice(q);
|
||||||
|
+ drv_unmap_reserve_mem(q, ptr, size);
|
||||||
|
+
|
||||||
|
+ return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drv_unmap_reserve_mem(struct wd_queue *q, void *addr, size_t size)
|
||||||
|
diff --git a/v1/wd_adapter.h b/v1/wd_adapter.h
|
||||||
|
index e1e1233..a5edd24 100644
|
||||||
|
--- a/v1/wd_adapter.h
|
||||||
|
+++ b/v1/wd_adapter.h
|
||||||
|
@@ -67,6 +67,7 @@ void drv_close(struct wd_queue *q);
|
||||||
|
int drv_send(struct wd_queue *q, void **req, __u32 num);
|
||||||
|
int drv_recv(struct wd_queue *q, void **req, __u32 num);
|
||||||
|
void drv_flush(struct wd_queue *q);
|
||||||
|
+void drv_free_slice(struct wd_queue *q);
|
||||||
|
void *drv_reserve_mem(struct wd_queue *q, size_t size);
|
||||||
|
void drv_unmap_reserve_mem(struct wd_queue *q, void *addr, size_t size);
|
||||||
|
int drv_get_sgl_info(struct wd_queue *q, struct hw_sgl_info *info);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
41
0087-uadk-cipher-fix-wd_cipher_check_params.patch
Normal file
41
0087-uadk-cipher-fix-wd_cipher_check_params.patch
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
From c79a52c5470ada323f3fabcc88d8dd8dc1300658 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:03:14 +0800
|
||||||
|
Subject: [PATCH 095/109] uadk: cipher: fix wd_cipher_check_params
|
||||||
|
|
||||||
|
no need to set ret and optimize the return line.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
wd_cipher.c | 8 ++------
|
||||||
|
1 file changed, 2 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/wd_cipher.c b/wd_cipher.c
|
||||||
|
index afd8c4d..88d3b04 100644
|
||||||
|
--- a/wd_cipher.c
|
||||||
|
+++ b/wd_cipher.c
|
||||||
|
@@ -384,7 +384,7 @@ static int wd_cipher_check_params(handle_t h_sess,
|
||||||
|
struct wd_cipher_req *req, __u8 mode)
|
||||||
|
{
|
||||||
|
struct wd_cipher_sess *sess = (struct wd_cipher_sess *)h_sess;
|
||||||
|
- int ret = 0;
|
||||||
|
+ int ret;
|
||||||
|
|
||||||
|
if (unlikely(!h_sess || !req)) {
|
||||||
|
WD_ERR("cipher input sess or req is NULL!\n");
|
||||||
|
@@ -419,11 +419,7 @@ static int wd_cipher_check_params(handle_t h_sess,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- ret = cipher_iv_len_check(req, sess);
|
||||||
|
- if (unlikely(ret))
|
||||||
|
- return ret;
|
||||||
|
-
|
||||||
|
- return 0;
|
||||||
|
+ return cipher_iv_len_check(req, sess);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int send_recv_sync(struct wd_ctx_internal *ctx,
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
308
0088-sec-unify-print-format.patch
Normal file
308
0088-sec-unify-print-format.patch
Normal file
@ -0,0 +1,308 @@
|
|||||||
|
From 634b2341b94ff972142da89d30f0a4c08586a0b6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kai Ye <yekai13@huawei.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:29:44 +0800
|
||||||
|
Subject: [PATCH 096/109] sec: unify print format
|
||||||
|
|
||||||
|
Unify print format with following rules:
|
||||||
|
1. failed to do sth.
|
||||||
|
2. invalid: sth is NULL.
|
||||||
|
|
||||||
|
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||||
|
---
|
||||||
|
drv/hisi_sec.c | 20 ++++++++++----------
|
||||||
|
wd_aead.c | 12 ++++++------
|
||||||
|
wd_cipher.c | 20 ++++++++++----------
|
||||||
|
wd_digest.c | 10 +++++-----
|
||||||
|
4 files changed, 31 insertions(+), 31 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
|
||||||
|
index 16fcb5f..aa86a6b 100644
|
||||||
|
--- a/drv/hisi_sec.c
|
||||||
|
+++ b/drv/hisi_sec.c
|
||||||
|
@@ -703,7 +703,7 @@ static void parse_cipher_bd2(struct hisi_sec_sqe *sqe,
|
||||||
|
|
||||||
|
done = sqe->type2.done_flag & SEC_DONE_MASK;
|
||||||
|
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type) {
|
||||||
|
- WD_ERR("SEC BD %s fail! done=0x%x, etype=0x%x\n", "cipher",
|
||||||
|
+ WD_ERR("failed to parse cipher BD2! done=0x%x, etype=0x%x\n",
|
||||||
|
done, sqe->type2.error_type);
|
||||||
|
recv_msg->result = WD_IN_EPARA;
|
||||||
|
} else {
|
||||||
|
@@ -927,7 +927,7 @@ int hisi_sec_cipher_send(handle_t ctx, struct wd_cipher_msg *msg)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!msg) {
|
||||||
|
- WD_ERR("input cipher msg is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: input cipher msg is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1130,7 +1130,7 @@ int hisi_sec_cipher_send_v3(handle_t ctx, struct wd_cipher_msg *msg)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!msg) {
|
||||||
|
- WD_ERR("input cipher msg is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: input cipher msg is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1175,7 +1175,7 @@ static void parse_cipher_bd3(struct hisi_sec_sqe3 *sqe,
|
||||||
|
|
||||||
|
done = sqe->done_flag & SEC_DONE_MASK;
|
||||||
|
if (done != SEC_HW_TASK_DONE || sqe->error_type) {
|
||||||
|
- WD_ERR("SEC BD3 %s fail! done=0x%x, etype=0x%x\n", "cipher",
|
||||||
|
+ WD_ERR("failed to parse cipher BD3! done=0x%x, etype=0x%x\n",
|
||||||
|
done, sqe->error_type);
|
||||||
|
recv_msg->result = WD_IN_EPARA;
|
||||||
|
} else {
|
||||||
|
@@ -1278,7 +1278,7 @@ static void parse_digest_bd2(struct hisi_sec_sqe *sqe,
|
||||||
|
|
||||||
|
done = sqe->type2.done_flag & SEC_DONE_MASK;
|
||||||
|
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type) {
|
||||||
|
- WD_ERR("SEC BD %s fail! done=0x%x, etype=0x%x\n", "digest",
|
||||||
|
+ WD_ERR("failed to parse digest BD2! done=0x%x, etype=0x%x\n",
|
||||||
|
done, sqe->type2.error_type);
|
||||||
|
recv_msg->result = WD_IN_EPARA;
|
||||||
|
} else {
|
||||||
|
@@ -1354,7 +1354,7 @@ int hisi_sec_digest_send(handle_t ctx, struct wd_digest_msg *msg)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!msg) {
|
||||||
|
- WD_ERR("input digest msg is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: input digest msg is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1510,7 +1510,7 @@ int hisi_sec_digest_send_v3(handle_t ctx, struct wd_digest_msg *msg)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!msg) {
|
||||||
|
- WD_ERR("input digest msg is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: input digest msg is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1578,7 +1578,7 @@ static void parse_digest_bd3(struct hisi_sec_sqe3 *sqe,
|
||||||
|
|
||||||
|
done = sqe->done_flag & SEC_DONE_MASK;
|
||||||
|
if (done != SEC_HW_TASK_DONE || sqe->error_type) {
|
||||||
|
- WD_ERR("SEC BD3 %s fail! done=0x%x, etype=0x%x\n", "digest",
|
||||||
|
+ WD_ERR("failed to parse digest BD3! done=0x%x, etype=0x%x\n",
|
||||||
|
done, sqe->error_type);
|
||||||
|
recv_msg->result = WD_IN_EPARA;
|
||||||
|
} else {
|
||||||
|
@@ -1927,7 +1927,7 @@ static void parse_aead_bd2(struct hisi_sec_sqe *sqe,
|
||||||
|
icv = (sqe->type2.done_flag & SEC_ICV_MASK) >> 1;
|
||||||
|
if (done != SEC_HW_TASK_DONE || sqe->type2.error_type ||
|
||||||
|
icv == SEC_HW_ICV_ERR) {
|
||||||
|
- WD_ERR("SEC BD aead fail! done=0x%x, etype=0x%x, icv=0x%x\n",
|
||||||
|
+ WD_ERR("failed to parse aead BD2! done=0x%x, etype=0x%x, icv=0x%x\n",
|
||||||
|
done, sqe->type2.error_type, icv);
|
||||||
|
recv_msg->result = WD_IN_EPARA;
|
||||||
|
} else {
|
||||||
|
@@ -2195,7 +2195,7 @@ static void parse_aead_bd3(struct hisi_sec_sqe3 *sqe,
|
||||||
|
icv = (sqe->done_flag & SEC_ICV_MASK) >> 1;
|
||||||
|
if (done != SEC_HW_TASK_DONE || sqe->error_type ||
|
||||||
|
icv == SEC_HW_ICV_ERR) {
|
||||||
|
- WD_ERR("SEC BD3 aead fail! done=0x%x, etype=0x%x, icv=0x%x\n",
|
||||||
|
+ WD_ERR("failed to parse aead BD3! done=0x%x, etype=0x%x, icv=0x%x\n",
|
||||||
|
done, sqe->error_type, icv);
|
||||||
|
recv_msg->result = WD_IN_EPARA;
|
||||||
|
} else {
|
||||||
|
diff --git a/wd_aead.c b/wd_aead.c
|
||||||
|
index 7df8e80..74047b5 100644
|
||||||
|
--- a/wd_aead.c
|
||||||
|
+++ b/wd_aead.c
|
||||||
|
@@ -63,14 +63,14 @@ static void wd_aead_set_static_drv(void)
|
||||||
|
{
|
||||||
|
wd_aead_setting.driver = wd_aead_get_driver();
|
||||||
|
if (!wd_aead_setting.driver)
|
||||||
|
- WD_ERR("fail to get driver\n");
|
||||||
|
+ WD_ERR("failed to get driver!\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void __attribute__((constructor)) wd_aead_open_driver(void)
|
||||||
|
{
|
||||||
|
wd_aead_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
|
||||||
|
if (!wd_aead_setting.dlhandle)
|
||||||
|
- WD_ERR("failed to open libhisi_sec.so\n");
|
||||||
|
+ WD_ERR("failed to open libhisi_sec.so!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __attribute__((destructor)) wd_aead_close_driver(void)
|
||||||
|
@@ -344,7 +344,7 @@ static int aead_param_check(struct wd_aead_sess *sess,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (unlikely(!sess || !req)) {
|
||||||
|
- WD_ERR("aead input sess or req is NULL.\n");
|
||||||
|
+ WD_ERR("invalid: aead input sess or req is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -393,7 +393,7 @@ 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 || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
- WD_ERR("wd aead config or sched is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: wd aead config or sched is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -594,7 +594,7 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
|
||||||
|
if (unlikely(!req->cb)) {
|
||||||
|
- WD_ERR("aead input req cb is NULL.\n");
|
||||||
|
+ WD_ERR("invalid: aead input req cb is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -647,7 +647,7 @@ int wd_aead_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!count) {
|
||||||
|
- WD_ERR("aead poll ctx input param is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: aead poll ctx input param is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/wd_cipher.c b/wd_cipher.c
|
||||||
|
index 88d3b04..563eece 100644
|
||||||
|
--- a/wd_cipher.c
|
||||||
|
+++ b/wd_cipher.c
|
||||||
|
@@ -75,14 +75,14 @@ static void wd_cipher_set_static_drv(void)
|
||||||
|
{
|
||||||
|
wd_cipher_setting.driver = wd_cipher_get_driver();
|
||||||
|
if (!wd_cipher_setting.driver)
|
||||||
|
- WD_ERR("fail to get driver\n");
|
||||||
|
+ WD_ERR("failed to get driver!\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void __attribute__((constructor)) wd_cipher_open_driver(void)
|
||||||
|
{
|
||||||
|
wd_cipher_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
|
||||||
|
if (!wd_cipher_setting.dlhandle)
|
||||||
|
- WD_ERR("fail to open libhisi_sec.so\n");
|
||||||
|
+ WD_ERR("failed to open libhisi_sec.so!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __attribute__((destructor)) wd_cipher_close_driver(void)
|
||||||
|
@@ -158,7 +158,7 @@ static int cipher_init_check(struct wd_ctx_config *config,
|
||||||
|
struct wd_sched *sched)
|
||||||
|
{
|
||||||
|
if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
- WD_ERR("wd cipher config or sched is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: wd cipher config or sched is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -177,7 +177,7 @@ int wd_cipher_set_key(handle_t h_sess, const __u8 *key, __u32 key_len)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!key || !sess) {
|
||||||
|
- WD_ERR("cipher set key input param err!\n");
|
||||||
|
+ WD_ERR("invalid: cipher set key input param err!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -205,13 +205,13 @@ handle_t wd_cipher_alloc_sess(struct wd_cipher_sess_setup *setup)
|
||||||
|
struct wd_cipher_sess *sess = NULL;
|
||||||
|
|
||||||
|
if (unlikely(!setup)) {
|
||||||
|
- WD_ERR("cipher input setup is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: cipher input setup is NULL!\n");
|
||||||
|
return (handle_t)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sess = malloc(sizeof(struct wd_cipher_sess));
|
||||||
|
if (!sess) {
|
||||||
|
- WD_ERR("fail to alloc session memory!\n");
|
||||||
|
+ WD_ERR("failed to alloc session memory!\n");
|
||||||
|
return (handle_t)0;
|
||||||
|
}
|
||||||
|
memset(sess, 0, sizeof(struct wd_cipher_sess));
|
||||||
|
@@ -235,7 +235,7 @@ void wd_cipher_free_sess(handle_t h_sess)
|
||||||
|
struct wd_cipher_sess *sess = (struct wd_cipher_sess *)h_sess;
|
||||||
|
|
||||||
|
if (unlikely(!sess)) {
|
||||||
|
- WD_ERR("cipher input h_sess is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: cipher input h_sess is NULL!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -387,12 +387,12 @@ static int wd_cipher_check_params(handle_t h_sess,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (unlikely(!h_sess || !req)) {
|
||||||
|
- WD_ERR("cipher input sess or req is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: cipher input sess or req is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(mode == CTX_MODE_ASYNC && !req->cb)) {
|
||||||
|
- WD_ERR("cipher req cb is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: cipher req cb is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -557,7 +557,7 @@ int wd_cipher_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (unlikely(!count)) {
|
||||||
|
- WD_ERR("wd cipher poll ctx input param is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: cipher poll ctx input param is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/wd_digest.c b/wd_digest.c
|
||||||
|
index fb29746..0ddc074 100644
|
||||||
|
--- a/wd_digest.c
|
||||||
|
+++ b/wd_digest.c
|
||||||
|
@@ -62,7 +62,7 @@ static void wd_digest_set_static_drv(void)
|
||||||
|
{
|
||||||
|
wd_digest_setting.driver = wd_digest_get_driver();
|
||||||
|
if (!wd_digest_setting.driver)
|
||||||
|
- WD_ERR("fail to get driver\n");
|
||||||
|
+ WD_ERR("failed to get driver!\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void __attribute__((constructor)) wd_digest_open_driver(void)
|
||||||
|
@@ -70,7 +70,7 @@ static void __attribute__((constructor)) wd_digest_open_driver(void)
|
||||||
|
/* Fix me: vendor driver should be put in /usr/lib/wd/ */
|
||||||
|
wd_digest_setting.dlhandle = dlopen("libhisi_sec.so", RTLD_NOW);
|
||||||
|
if (!wd_digest_setting.dlhandle)
|
||||||
|
- WD_ERR("fail to open libhisi_sec.so\n");
|
||||||
|
+ WD_ERR("failed to open libhisi_sec.so!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __attribute__((destructor)) wd_digest_close_driver(void)
|
||||||
|
@@ -252,7 +252,7 @@ static int digest_param_check(struct wd_digest_sess *sess,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (unlikely(!sess || !req)) {
|
||||||
|
- WD_ERR("digest input sess or req is NULL.\n");
|
||||||
|
+ WD_ERR("invalid: digest input sess or req is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -398,7 +398,7 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
|
||||||
|
if (unlikely(!req->cb)) {
|
||||||
|
- WD_ERR("digest input req cb is NULL.\n");
|
||||||
|
+ WD_ERR("invalid: digest input req cb is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -451,7 +451,7 @@ int wd_digest_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (unlikely(!count)) {
|
||||||
|
- WD_ERR("digest count is NULL.\n");
|
||||||
|
+ WD_ERR("invalid: digest poll ctx input param is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
514
0089-drv-hpre-unify-print-format.patch
Normal file
514
0089-drv-hpre-unify-print-format.patch
Normal file
@ -0,0 +1,514 @@
|
|||||||
|
From 6d87a3c206df306cff533d8aacf40cc5966d8441 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Weili Qian <qianweili@huawei.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:29:45 +0800
|
||||||
|
Subject: [PATCH 097/109] drv/hpre: unify print format
|
||||||
|
|
||||||
|
Unify print format with following rules:
|
||||||
|
1.failed to do sth.
|
||||||
|
2.add prefix "invalid: " for check parameters printf
|
||||||
|
3.add "!" at the end.unify print format
|
||||||
|
|
||||||
|
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||||
|
---
|
||||||
|
drv/hisi_hpre.c | 125 +++++++++++++++++++++++-------------------------
|
||||||
|
1 file changed, 60 insertions(+), 65 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
|
||||||
|
index f1d7720..11ef78b 100644
|
||||||
|
--- a/drv/hisi_hpre.c
|
||||||
|
+++ b/drv/hisi_hpre.c
|
||||||
|
@@ -134,12 +134,12 @@ static int crypto_bin_to_hpre_bin(char *dst, const char *src,
|
||||||
|
int j;
|
||||||
|
|
||||||
|
if (!dst || !src || b_size <= 0 || d_size <= 0) {
|
||||||
|
- WD_ERR("%s: trans to hpre bin parameters err!\n", p_name);
|
||||||
|
+ WD_ERR("invalid: %s trans to hpre bin parameters err!\n", p_name);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b_size < d_size) {
|
||||||
|
- WD_ERR("%s: trans to hpre bin data too long!\n", p_name);
|
||||||
|
+ WD_ERR("invalid: %s trans to hpre bin data too long!\n", p_name);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -165,7 +165,7 @@ static int hpre_bin_to_crypto_bin(char *dst, const char *src, int b_size,
|
||||||
|
int k = 0;
|
||||||
|
|
||||||
|
if (!dst || !src || b_size <= 0) {
|
||||||
|
- WD_ERR("%s trans to crypto bin: parameters err!\n", p_name);
|
||||||
|
+ WD_ERR("invalid: %s trans to crypto bin parameters err!\n", p_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -254,10 +254,9 @@ static int fill_rsa_pubkey(struct wd_rsa_pubkey *pubkey, void **data)
|
||||||
|
wd_rsa_get_pubkey_params(pubkey, &wd_e, &wd_n);
|
||||||
|
ret = crypto_bin_to_hpre_bin(wd_e->data, (const char *)wd_e->data,
|
||||||
|
wd_e->bsize, wd_e->dsize, "rsa e");
|
||||||
|
- if (ret) {
|
||||||
|
- WD_ERR("rsa pubkey e format fail!\n");
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
+
|
||||||
|
ret = crypto_bin_to_hpre_bin(wd_n->data, (const char *)wd_n->data,
|
||||||
|
wd_n->bsize, wd_n->dsize, "rsa n");
|
||||||
|
if (ret)
|
||||||
|
@@ -349,7 +348,7 @@ static int rsa_out_transfer(struct wd_rsa_msg *msg,
|
||||||
|
wd_rsa_get_kg_out_crt_params(key, &qinv, &dq, &dp);
|
||||||
|
ret = hpre_tri_bin_transfer(&qinv, &dq, &dp);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("parse rsa genkey qinv&&dq&&dp format fail!\n");
|
||||||
|
+ WD_ERR("failed to parse rsa genkey qinv&&dq&&dp format!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -361,7 +360,7 @@ static int rsa_out_transfer(struct wd_rsa_msg *msg,
|
||||||
|
wd_rsa_get_kg_out_params(key, &d, &n);
|
||||||
|
ret = hpre_tri_bin_transfer(&d, &n, NULL);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("parse rsa genkey1 d&&n format fail!\n");
|
||||||
|
+ WD_ERR("failed to parse rsa genkey1 d&&n format!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -402,7 +401,7 @@ static int rsa_prepare_key(struct wd_rsa_msg *msg,
|
||||||
|
return ret;
|
||||||
|
ret = wd_rsa_kg_in_data((void *)msg->key, (char **)&data);
|
||||||
|
if (ret < 0) {
|
||||||
|
- WD_ERR("Get rsa gen key data in fail!\n");
|
||||||
|
+ WD_ERR("failed to get rsa gen key data!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (hw_msg->alg == HPRE_ALG_NC_CRT)
|
||||||
|
@@ -410,7 +409,7 @@ static int rsa_prepare_key(struct wd_rsa_msg *msg,
|
||||||
|
else
|
||||||
|
hw_msg->alg = HPRE_ALG_KG_STD;
|
||||||
|
} else {
|
||||||
|
- WD_ERR("Invalid rsa operatin type!\n");
|
||||||
|
+ WD_ERR("invalid: rsa operatin type %u is error!\n", req->op_type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -546,10 +545,10 @@ static int rsa_recv(handle_t ctx, struct wd_rsa_msg *msg)
|
||||||
|
|
||||||
|
if (hw_msg.done != HPRE_HW_TASK_DONE ||
|
||||||
|
hw_msg.etype || hw_msg.etype1) {
|
||||||
|
- WD_ERR("HPRE do rsa fail!done=0x%x, etype=0x%x, etype1=0x%x\n",
|
||||||
|
+ WD_ERR("failed to do rsa task! done=0x%x, etype=0x%x, etype1=0x%x!\n",
|
||||||
|
hw_msg.done, hw_msg.etype, hw_msg.etype1);
|
||||||
|
if (hw_msg.etype1 & HPRE_HW_SVA_ERROR)
|
||||||
|
- WD_ERR("failed to SVA prefetch: status=%u\n",
|
||||||
|
+ WD_ERR("failed to SVA prefetch: status=%u!\n",
|
||||||
|
hw_msg.sva_status);
|
||||||
|
if (hw_msg.done == HPRE_HW_TASK_INIT)
|
||||||
|
msg->result = WD_EINVAL;
|
||||||
|
@@ -559,7 +558,7 @@ static int rsa_recv(handle_t ctx, struct wd_rsa_msg *msg)
|
||||||
|
msg->tag = LW_U16(hw_msg.low_tag);
|
||||||
|
ret = rsa_out_transfer(msg, &hw_msg);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("qm rsa out transfer fail!\n");
|
||||||
|
+ WD_ERR("failed to transfer out rsa BD!\n");
|
||||||
|
msg->result = WD_OUT_EPARA;
|
||||||
|
} else {
|
||||||
|
msg->result = WD_SUCCESS;
|
||||||
|
@@ -591,14 +590,14 @@ static int fill_dh_xp_params(struct wd_dh_msg *msg,
|
||||||
|
ret = crypto_bin_to_hpre_bin(x, (const char *)x,
|
||||||
|
msg->key_bytes, req->xbytes, "dh x");
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("dh x para format fail!\n");
|
||||||
|
+ WD_ERR("failed to transfer dh x para format to hpre bin!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = crypto_bin_to_hpre_bin(p, (const char *)p,
|
||||||
|
msg->key_bytes, req->pbytes, "dh p");
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("dh p para format fail!\n");
|
||||||
|
+ WD_ERR("failed to transfer dh p para format to hpre bin!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -654,7 +653,7 @@ static int dh_send(handle_t ctx, struct wd_dh_msg *msg)
|
||||||
|
(const char *)msg->g, msg->key_bytes,
|
||||||
|
msg->gbytes, "dh g");
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("dh g para format fail!\n");
|
||||||
|
+ WD_ERR("failed to transfer dh g para format to hpre bin!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -688,10 +687,10 @@ static int dh_recv(handle_t ctx, struct wd_dh_msg *msg)
|
||||||
|
|
||||||
|
if (hw_msg.done != HPRE_HW_TASK_DONE ||
|
||||||
|
hw_msg.etype || hw_msg.etype1) {
|
||||||
|
- WD_ERR("HPRE do dh fail!done=0x%x, etype=0x%x, etype1=0x%x\n",
|
||||||
|
+ WD_ERR("failed to do dh task! done=0x%x, etype=0x%x, etype1=0x%x!\n",
|
||||||
|
hw_msg.done, hw_msg.etype, hw_msg.etype1);
|
||||||
|
if (hw_msg.etype1 & HPRE_HW_SVA_ERROR)
|
||||||
|
- WD_ERR("failed to SVA prefetch: status=%u\n",
|
||||||
|
+ WD_ERR("failed to SVA prefetch: status=%u!\n",
|
||||||
|
hw_msg.sva_status);
|
||||||
|
if (hw_msg.done == HPRE_HW_TASK_INIT)
|
||||||
|
msg->result = WD_EINVAL;
|
||||||
|
@@ -701,7 +700,7 @@ static int dh_recv(handle_t ctx, struct wd_dh_msg *msg)
|
||||||
|
msg->tag = LW_U16(hw_msg.low_tag);
|
||||||
|
ret = dh_out_transfer(msg, &hw_msg);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("dh out transfer fail!\n");
|
||||||
|
+ WD_ERR("failed to transfer out dh BD!\n");
|
||||||
|
msg->result = WD_OUT_EPARA;
|
||||||
|
} else {
|
||||||
|
msg->result = WD_SUCCESS;
|
||||||
|
@@ -1021,7 +1020,7 @@ static int ecc_prepare_sign_in(struct wd_ecc_msg *msg,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!in->dgst_set) {
|
||||||
|
- WD_ERR("prepare sign_in, hash not set!\n");
|
||||||
|
+ WD_ERR("invalid: prepare sign_in, hash not set!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1029,17 +1028,17 @@ static int ecc_prepare_sign_in(struct wd_ecc_msg *msg,
|
||||||
|
k = &in->k;
|
||||||
|
if (!in->k_set) {
|
||||||
|
if (msg->req.op_type == WD_ECDSA_SIGN) {
|
||||||
|
- WD_ERR("random k not set!\n");
|
||||||
|
+ WD_ERR("invalid: random k not set!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
hw_msg->sm2_ksel = 1;
|
||||||
|
} else if (is_all_zero(k, msg)) {
|
||||||
|
- WD_ERR("ecc sign in k all zero!\n");
|
||||||
|
+ WD_ERR("invalid: ecc sign in k all zero!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_all_zero(e, msg)) {
|
||||||
|
- WD_ERR("ecc sign in e all zero!\n");
|
||||||
|
+ WD_ERR("invalid: ecc sign in e all zero!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1072,7 +1071,7 @@ static int ecc_prepare_verf_in(struct wd_ecc_msg *msg,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!vin->dgst_set) {
|
||||||
|
- WD_ERR("prepare verf_in, hash not set!\n");
|
||||||
|
+ WD_ERR("invalid: prepare verf_in, hash not set!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1081,7 +1080,7 @@ static int ecc_prepare_verf_in(struct wd_ecc_msg *msg,
|
||||||
|
r = &vin->r;
|
||||||
|
|
||||||
|
if (is_all_zero(e, msg)) {
|
||||||
|
- WD_ERR("ecc verf in e all zero!\n");
|
||||||
|
+ WD_ERR("invalid: ecc verf in e all zero!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1182,17 +1181,13 @@ static int ecc_prepare_dh_compute_in(struct wd_ecc_msg *msg,
|
||||||
|
|
||||||
|
ret = crypto_bin_to_hpre_bin(pbk->x.data, (const char *)pbk->x.data,
|
||||||
|
pbk->x.bsize, pbk->x.dsize, "ecdh compute x");
|
||||||
|
- if (ret) {
|
||||||
|
- WD_ERR("ecc dh compute in x format fail!\n");
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
ret = crypto_bin_to_hpre_bin(pbk->y.data, (const char *)pbk->y.data,
|
||||||
|
pbk->y.bsize, pbk->y.dsize, "ecdh compute y");
|
||||||
|
- if (ret) {
|
||||||
|
- WD_ERR("ecc dh compute in y format fail!\n");
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
*data = pbk->x.data;
|
||||||
|
|
||||||
|
@@ -1221,12 +1216,12 @@ static int u_is_in_p(struct wd_ecc_msg *msg)
|
||||||
|
if (msg->curve_id == WD_X25519)
|
||||||
|
pbk->x.data[0] &= 0x7f;
|
||||||
|
if (!less_than_latter(&pbk->x, p)) {
|
||||||
|
- WD_ERR("ux is out of p!\n");
|
||||||
|
+ WD_ERR("invalid: ux is out of p!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_all_zero(&pbk->x, msg)) {
|
||||||
|
- WD_ERR("ux is zero!\n");
|
||||||
|
+ WD_ERR("invalid: ux is zero!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1342,7 +1337,7 @@ static int ecc_prepare_iot(struct wd_ecc_msg *msg,
|
||||||
|
ecc_get_io_len(hw_msg->alg, kbytes, &i_sz, &o_sz);
|
||||||
|
ret = ecc_prepare_in(msg, hw_msg, &data);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("ecc_prepare_in fail!\n");
|
||||||
|
+ WD_ERR("failed to prepare ecc in!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
hw_msg->low_in = LW_U32((uintptr_t)data);
|
||||||
|
@@ -1350,7 +1345,7 @@ static int ecc_prepare_iot(struct wd_ecc_msg *msg,
|
||||||
|
|
||||||
|
ret = ecc_prepare_out(msg, &data);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("ecc_prepare_out fail!\n");
|
||||||
|
+ WD_ERR("failed to prepare ecc out!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1374,7 +1369,7 @@ static __u32 get_hw_keysz(__u32 ksz)
|
||||||
|
else if (ksz <= BITS_TO_BYTES(576))
|
||||||
|
size = BITS_TO_BYTES(576);
|
||||||
|
else
|
||||||
|
- WD_ERR("failed to get hw keysize : ksz = %u.\n", ksz);
|
||||||
|
+ WD_ERR("invalid: keysize %u is error!\n", ksz);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
@@ -1408,12 +1403,12 @@ static int set_param(struct wd_dtb *dst, const struct wd_dtb *src,
|
||||||
|
const char *p_name)
|
||||||
|
{
|
||||||
|
if (unlikely(!src || !src->data)) {
|
||||||
|
- WD_ERR("%s: src or data NULL!\n", p_name);
|
||||||
|
+ WD_ERR("invalid: %s src or data NULL!\n", p_name);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(!src->dsize || src->dsize > dst->bsize)) {
|
||||||
|
- WD_ERR("%s: src dsz = %u error, dst bsz = %u!\n",
|
||||||
|
+ WD_ERR("invalid: %s src dsz %u, dst bsz %u is error!\n",
|
||||||
|
p_name, src->dsize, dst->bsize);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -1470,13 +1465,13 @@ static struct wd_ecc_out *create_ecdh_out(struct wd_ecc_msg *msg)
|
||||||
|
struct wd_ecc_out *out;
|
||||||
|
|
||||||
|
if (!hsz) {
|
||||||
|
- WD_ERR("get msg key size error!\n");
|
||||||
|
+ WD_ERR("failed to get msg key size!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
out = malloc(len);
|
||||||
|
if (!out) {
|
||||||
|
- WD_ERR("failed to alloc, sz = %u!\n", len);
|
||||||
|
+ WD_ERR("failed to alloc out memory, sz = %u!\n", len);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1527,13 +1522,13 @@ static struct wd_ecc_msg *create_req(struct wd_ecc_msg *src, __u8 req_idx)
|
||||||
|
|
||||||
|
dst = malloc(sizeof(*dst) + sizeof(*src));
|
||||||
|
if (unlikely(!dst)) {
|
||||||
|
- WD_ERR("failed to alloc dst\n");
|
||||||
|
+ WD_ERR("failed to alloc dst!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ecc_key = malloc(sizeof(*ecc_key) + sizeof(*prikey));
|
||||||
|
if (unlikely(!ecc_key)) {
|
||||||
|
- WD_ERR("failed to alloc ecc_key\n");
|
||||||
|
+ WD_ERR("failed to alloc ecc_key!\n");
|
||||||
|
goto fail_alloc_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1541,7 +1536,7 @@ static struct wd_ecc_msg *create_req(struct wd_ecc_msg *src, __u8 req_idx)
|
||||||
|
ecc_key->prikey = prikey;
|
||||||
|
prikey->data = malloc(ECC_PRIKEY_SZ(src->key_bytes));
|
||||||
|
if (unlikely(!prikey->data)) {
|
||||||
|
- WD_ERR("failed to alloc prikey data\n");
|
||||||
|
+ WD_ERR("failed to alloc prikey data!\n");
|
||||||
|
goto fail_alloc_key_data;
|
||||||
|
}
|
||||||
|
init_prikey(prikey, src->key_bytes);
|
||||||
|
@@ -1551,7 +1546,7 @@ static struct wd_ecc_msg *create_req(struct wd_ecc_msg *src, __u8 req_idx)
|
||||||
|
|
||||||
|
ret = init_req(dst, src, ecc_key, req_idx);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
- WD_ERR("failed to init req, ret = %d\n", ret);
|
||||||
|
+ WD_ERR("failed to init req, ret = %d!\n", ret);
|
||||||
|
goto fail_set_prikey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1602,12 +1597,12 @@ static int ecc_fill(struct wd_ecc_msg *msg, struct hisi_hpre_sqe *hw_msg)
|
||||||
|
|
||||||
|
if (unlikely(!op_type || (op_type >= WD_EC_OP_MAX &&
|
||||||
|
op_type != HPRE_SM2_ENC && op_type != HPRE_SM2_DEC))) {
|
||||||
|
- WD_ERR("op_type = %u error!\n", op_type);
|
||||||
|
+ WD_ERR("invalid: input op_type %u is error!\n", op_type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hw_sz) {
|
||||||
|
- WD_ERR("get msg key size error!\n");
|
||||||
|
+ WD_ERR("failed to get msg key size!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1666,12 +1661,12 @@ static int sm2_enc_send(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
return ecc_general_send(ctx, msg);
|
||||||
|
|
||||||
|
if (unlikely(!ein->k_set)) {
|
||||||
|
- WD_ERR("error: k not set\n");
|
||||||
|
+ WD_ERR("invalid: k not set!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(!hash->cb || hash->type >= WD_HASH_MAX)) {
|
||||||
|
- WD_ERR("hash parameter error, type = %u\n", hash->type);
|
||||||
|
+ WD_ERR("invalid: input hash type %u is error!\n", hash->type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1682,19 +1677,19 @@ static int sm2_enc_send(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
*/
|
||||||
|
ret = split_req(msg, msg_dst);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
- WD_ERR("failed to split req, ret = %d\n", ret);
|
||||||
|
+ WD_ERR("failed to split req, ret = %d!\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ecc_fill(msg_dst[0], &hw_msg[0]);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
- WD_ERR("failed to fill 1th sqe, ret = %d\n", ret);
|
||||||
|
+ WD_ERR("failed to fill 1th sqe, ret = %d!\n", ret);
|
||||||
|
goto fail_fill_sqe;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ecc_fill(msg_dst[1], &hw_msg[1]);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
- WD_ERR("failed to fill 2th sqe, ret = %d\n", ret);
|
||||||
|
+ WD_ERR("failed to fill 2th sqe, ret = %d!\n", ret);
|
||||||
|
goto fail_fill_sqe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1725,7 +1720,7 @@ static int sm2_dec_send(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
return ecc_general_send(ctx, msg);
|
||||||
|
|
||||||
|
if (unlikely(!hash->cb || hash->type >= WD_HASH_MAX)) {
|
||||||
|
- WD_ERR("hash parameter error, type = %u\n", hash->type);
|
||||||
|
+ WD_ERR("invalid: input hash type %u is error!\n", hash->type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1779,7 +1774,7 @@ static int ecdh_out_transfer(struct wd_ecc_msg *msg, struct hisi_hpre_sqe *hw_ms
|
||||||
|
|
||||||
|
ret = hpre_tri_bin_transfer(&key->x, y, NULL);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("parse ecdh out format fail!\n");
|
||||||
|
+ WD_ERR("failed to transfer ecdh format to crypto bin!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1889,7 +1884,7 @@ static int ecc_out_transfer(struct wd_ecc_msg *msg,
|
||||||
|
hw_msg->alg == HPRE_ALG_X_DH_MULTIPLY)
|
||||||
|
ret = ecdh_out_transfer(msg, hw_msg);
|
||||||
|
else
|
||||||
|
- WD_ERR("ecc out trans fail algorithm %u error!\n", hw_msg->alg);
|
||||||
|
+ WD_ERR("invalid: algorithm type %u is error!\n", hw_msg->alg);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@@ -1921,7 +1916,7 @@ static __u32 get_hash_bytes(__u8 type)
|
||||||
|
val = BITS_TO_BYTES(512);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
- WD_ERR("get hash bytes: type %u error!\n", type);
|
||||||
|
+ WD_ERR("invalid: hash type %u is error!\n", type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1977,7 +1972,7 @@ static int sm2_kdf(struct wd_dtb *out, struct wd_ecc_point *x2y2,
|
||||||
|
t_out = m_len >= h_bytes ? tmp : p_out;
|
||||||
|
ret = hash->cb(p_in, in_len, t_out, h_bytes, hash->usr);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("failed to hash cb, ret = %d!\n", ret);
|
||||||
|
+ WD_ERR("%s failed to do hash cb, ret = %d!\n", __func__, ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2041,7 +2036,7 @@ static int sm2_hash(struct wd_dtb *out, struct wd_ecc_point *x2y2,
|
||||||
|
msg_pack(p_in, &in_len, x2y2->y.data, x2y2->y.dsize);
|
||||||
|
ret = hash->cb(p_in, in_len, hash_out, h_bytes, hash->usr);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
- WD_ERR("failed to hash cb, ret = %d!\n", ret);
|
||||||
|
+ WD_ERR("%s failed to do hash cb, ret = %d!\n", __func__, ret);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2088,7 +2083,7 @@ static int sm2_convert_enc_out(struct wd_ecc_msg *src,
|
||||||
|
/* C3 = hash(x2 || M || y2) */
|
||||||
|
ret = sm2_hash(&eout->c3, &x2y2, &ein->plaintext, hash);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
- WD_ERR("failed to sm2 hash, ret = %d!\n", ret);
|
||||||
|
+ WD_ERR("failed to do sm2 hash, ret = %d!\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2096,7 +2091,7 @@ static int sm2_convert_enc_out(struct wd_ecc_msg *src,
|
||||||
|
kdf_out = &eout->c2;
|
||||||
|
ret = sm2_kdf(kdf_out, &x2y2, ein->plaintext.dsize, hash);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
- WD_ERR("failed to sm2 kdf, ret = %d!\n", ret);
|
||||||
|
+ WD_ERR("%s failed to do sm2 kdf, ret = %d!\n", __func__, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2138,7 +2133,7 @@ static int sm2_convert_dec_out(struct wd_ecc_msg *src,
|
||||||
|
/* t = KDF(x2 || y2, klen) */
|
||||||
|
ret = sm2_kdf(&dout->plaintext, &x2y2, din->c2.dsize, &src->hash);
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
- WD_ERR("failed to sm2 kdf, ret = %d!\n", ret);
|
||||||
|
+ WD_ERR("%s failed to do sm2 kdf, ret = %d!\n", __func__, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2166,10 +2161,10 @@ static int ecc_sqe_parse(struct wd_ecc_msg *msg, struct hisi_hpre_sqe *hw_msg)
|
||||||
|
|
||||||
|
if (hw_msg->done != HPRE_HW_TASK_DONE ||
|
||||||
|
hw_msg->etype || hw_msg->etype1) {
|
||||||
|
- WD_ERR("HPRE do ecc fail!done=0x%x, etype=0x%x, etype1=0x%x\n",
|
||||||
|
+ WD_ERR("failed to do ecc task! done=0x%x, etype=0x%x, etype1=0x%x!\n",
|
||||||
|
hw_msg->done, hw_msg->etype, hw_msg->etype1);
|
||||||
|
if (hw_msg->etype1 & HPRE_HW_SVA_ERROR)
|
||||||
|
- WD_ERR("failed to SVA prefetch: status=%u\n",
|
||||||
|
+ WD_ERR("failed to SVA prefetch: status=%u!\n",
|
||||||
|
hw_msg->sva_status);
|
||||||
|
|
||||||
|
if (hw_msg->done == HPRE_HW_TASK_INIT)
|
||||||
|
@@ -2181,7 +2176,7 @@ static int ecc_sqe_parse(struct wd_ecc_msg *msg, struct hisi_hpre_sqe *hw_msg)
|
||||||
|
ret = ecc_out_transfer(msg, hw_msg);
|
||||||
|
if (ret) {
|
||||||
|
msg->result = WD_OUT_EPARA;
|
||||||
|
- WD_ERR("ecc out transfer fail!\n");
|
||||||
|
+ WD_ERR("failed to transfer out ecc BD, ret = %d!\n", ret);
|
||||||
|
}
|
||||||
|
msg->tag = LW_U16(hw_msg->low_tag);
|
||||||
|
}
|
||||||
|
@@ -2247,7 +2242,7 @@ static int sm2_enc_parse(handle_t h_qp,
|
||||||
|
hw_msg->low_tag = 0; /* use sync mode */
|
||||||
|
ret = ecc_sqe_parse(first, hw_msg);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("failed to parse first BD, ret = %d\n", ret);
|
||||||
|
+ WD_ERR("failed to parse first BD, ret = %d!\n", ret);
|
||||||
|
goto free_first;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2291,7 +2286,7 @@ static int sm2_dec_parse(handle_t ctx, struct wd_ecc_msg *msg,
|
||||||
|
hw_msg->low_tag = 0; /* use sync mode */
|
||||||
|
ret = ecc_sqe_parse(dst, hw_msg);
|
||||||
|
if (ret) {
|
||||||
|
- WD_ERR("failed to parse decode BD, ret = %d\n", ret);
|
||||||
|
+ WD_ERR("failed to parse decode BD, ret = %d!\n", ret);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
msg->result = dst->result;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
1294
0090-rsa-dh-ecc-unify-print-format.patch
Normal file
1294
0090-rsa-dh-ecc-unify-print-format.patch
Normal file
File diff suppressed because it is too large
Load Diff
66
0091-drv-hpre-free-memory-when-BD-sends-failed.patch
Normal file
66
0091-drv-hpre-free-memory-when-BD-sends-failed.patch
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
From e4ed630c442a7a5affb14dbcd70f20cbeaf6d969 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Weili Qian <qianweili@huawei.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:29:47 +0800
|
||||||
|
Subject: [PATCH 099/109] drv/hpre: free memory when BD sends failed
|
||||||
|
|
||||||
|
When BD fails to send to the hardware, the requested
|
||||||
|
memory needs to be freed.
|
||||||
|
|
||||||
|
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||||
|
---
|
||||||
|
drv/hisi_hpre.c | 23 +++++++++++++++++++----
|
||||||
|
1 file changed, 19 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
|
||||||
|
index 11ef78b..e46efef 100644
|
||||||
|
--- a/drv/hisi_hpre.c
|
||||||
|
+++ b/drv/hisi_hpre.c
|
||||||
|
@@ -1699,7 +1699,11 @@ static int sm2_enc_send(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
goto fail_fill_sqe;
|
||||||
|
}
|
||||||
|
|
||||||
|
- return hisi_qm_send(h_qp, &hw_msg, SM2_SQE_NUM, &send_cnt);
|
||||||
|
+ ret = hisi_qm_send(h_qp, &hw_msg, SM2_SQE_NUM, &send_cnt);
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
+ goto fail_fill_sqe;
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
|
||||||
|
fail_fill_sqe:
|
||||||
|
free_req(msg_dst[0]);
|
||||||
|
@@ -1713,6 +1717,7 @@ static int sm2_dec_send(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
struct wd_sm2_dec_in *din = (void *)msg->req.src;
|
||||||
|
struct wd_hash_mt *hash = &msg->hash;
|
||||||
|
struct wd_ecc_msg *dst;
|
||||||
|
+ int ret;
|
||||||
|
|
||||||
|
/* c2 data lens <= 4096 bit */
|
||||||
|
if (din->c2.dsize <= BITS_TO_BYTES(4096) &&
|
||||||
|
@@ -1739,11 +1744,21 @@ static int sm2_dec_send(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
/* dst->req.dst last store point "struct wd_ecc_msg *" */
|
||||||
|
dst->req.dst = create_ecdh_out(dst);
|
||||||
|
if (unlikely(!dst->req.dst)) {
|
||||||
|
- free(dst);
|
||||||
|
- return -WD_ENOMEM;
|
||||||
|
+ ret = -WD_ENOMEM;
|
||||||
|
+ goto free_dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
- return ecc_general_send(ctx, dst);
|
||||||
|
+ ret = ecc_general_send(ctx, dst);
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
+ goto free_req_dst;
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+free_req_dst:
|
||||||
|
+ free(dst->req.dst);
|
||||||
|
+free_dst:
|
||||||
|
+ free(dst);
|
||||||
|
+ return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ecc_send(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
29
0092-v1-hpre-add-unlikely-for-branch-prefetch.patch
Normal file
29
0092-v1-hpre-add-unlikely-for-branch-prefetch.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From 608b4ff6c4c5942d51086781956d36629465ca56 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Weili Qian <qianweili@huawei.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:29:48 +0800
|
||||||
|
Subject: [PATCH 100/109] v1/hpre: add unlikely() for branch prefetch
|
||||||
|
|
||||||
|
Add unlikely() on the route of doing request to improve
|
||||||
|
branch prefetch success rate.
|
||||||
|
|
||||||
|
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||||
|
---
|
||||||
|
v1/drv/hisi_hpre_udrv.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/v1/drv/hisi_hpre_udrv.c b/v1/drv/hisi_hpre_udrv.c
|
||||||
|
index ba32114..bd87cbe 100644
|
||||||
|
--- a/v1/drv/hisi_hpre_udrv.c
|
||||||
|
+++ b/v1/drv/hisi_hpre_udrv.c
|
||||||
|
@@ -1976,7 +1976,7 @@ static int fill_sm2_dec_sqe(void *message, struct qm_queue_info *info, __u16 i)
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = qm_fill_ecc_sqe_general(dst, info, i);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
goto free_out;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
207
0093-comp-unify-print-format.patch
Normal file
207
0093-comp-unify-print-format.patch
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
From e308fbdd62bb7a59b1550ed748b85cc79cfc2019 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yang Shen <shenyang39@huawei.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:29:49 +0800
|
||||||
|
Subject: [PATCH 101/109] comp: unify print format
|
||||||
|
|
||||||
|
Unify print format with following rules:
|
||||||
|
1.failed to do sth.
|
||||||
|
2.add prefix "invalid: " for check parameters printf
|
||||||
|
3.add "!" at the end.
|
||||||
|
|
||||||
|
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||||
|
---
|
||||||
|
wd_comp.c | 46 ++++++++++++++++++++++------------------------
|
||||||
|
1 file changed, 22 insertions(+), 24 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/wd_comp.c b/wd_comp.c
|
||||||
|
index 8d0c603..de71e9c 100644
|
||||||
|
--- a/wd_comp.c
|
||||||
|
+++ b/wd_comp.c
|
||||||
|
@@ -60,14 +60,14 @@ static void wd_comp_set_static_drv(void)
|
||||||
|
{
|
||||||
|
wd_comp_setting.driver = wd_comp_get_driver();
|
||||||
|
if (!wd_comp_setting.driver)
|
||||||
|
- WD_ERR("fail to get driver\n");
|
||||||
|
+ WD_ERR("failed to get driver!\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void __attribute__((constructor)) wd_comp_open_driver(void)
|
||||||
|
{
|
||||||
|
wd_comp_setting.dlhandle = dlopen("libhisi_zip.so", RTLD_NOW);
|
||||||
|
if (!wd_comp_setting.dlhandle)
|
||||||
|
- WD_ERR("Fail to open libhisi_zip.so\n");
|
||||||
|
+ WD_ERR("failed to open libhisi_zip.so!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __attribute__((destructor)) wd_comp_close_driver(void)
|
||||||
|
@@ -88,12 +88,12 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!config || !config->ctxs || !config->ctxs[0].ctx || !sched) {
|
||||||
|
- WD_ERR("invalid params, config or sched is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: config or sched is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wd_is_sva(config->ctxs[0].ctx)) {
|
||||||
|
- WD_ERR("err, non sva, please check system!\n");
|
||||||
|
+ WD_ERR("failed to find sva device, please check system!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -191,7 +191,7 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (unlikely(!count)) {
|
||||||
|
- WD_ERR("comp poll input count is NULL\n");
|
||||||
|
+ WD_ERR("invalid: comp poll count is 0!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -208,7 +208,7 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
priv);
|
||||||
|
if (ret < 0) {
|
||||||
|
if (ret == -WD_HW_EACCESS)
|
||||||
|
- WD_ERR("wd comp recv hw err!\n");
|
||||||
|
+ WD_ERR("wd comp recv hw error!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -217,7 +217,7 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
msg = wd_find_msg_in_pool(&wd_comp_setting.pool, idx,
|
||||||
|
resp_msg.tag);
|
||||||
|
if (!msg) {
|
||||||
|
- WD_ERR("get msg from pool is NULL!\n");
|
||||||
|
+ WD_ERR("failed to get msg from pool!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -341,7 +341,7 @@ static int wd_comp_check_buffer(struct wd_comp_req *req)
|
||||||
|
}
|
||||||
|
} else if (req->data_fmt == WD_SGL_BUF) {
|
||||||
|
if (!req->list_src || !req->list_dst) {
|
||||||
|
- WD_ERR("invalid: src or dst is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: list_src or list_dst is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -381,17 +381,17 @@ static int wd_comp_check_params(struct wd_comp_sess *sess,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == CTX_MODE_ASYNC && !req->cb) {
|
||||||
|
- WD_ERR("async comp input cb is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: async comp cb is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == CTX_MODE_ASYNC && !req->cb_param) {
|
||||||
|
- WD_ERR("async comp input cb param is NULL!\n");
|
||||||
|
+ WD_ERR("invalid: async comp cb param is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == CTX_MODE_SYNC && req->cb) {
|
||||||
|
- WD_ERR("sync comp input cb should be NULL!\n");
|
||||||
|
+ WD_ERR("invalid: sync comp cb should be NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -409,6 +409,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
|
||||||
|
__u64 recv_count = 0;
|
||||||
|
__u32 idx;
|
||||||
|
int ret;
|
||||||
|
+
|
||||||
|
idx = wd_comp_setting.sched.pick_next_ctx(h_sched_ctx,
|
||||||
|
sess->sched_key,
|
||||||
|
CTX_MODE_SYNC);
|
||||||
|
@@ -423,7 +424,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
|
||||||
|
ret = wd_comp_setting.driver->comp_send(ctx->ctx, msg, priv);
|
||||||
|
if (ret < 0) {
|
||||||
|
pthread_spin_unlock(&ctx->lock);
|
||||||
|
- WD_ERR("wd comp send err(%d)!\n", ret);
|
||||||
|
+ WD_ERR("wd comp send error, ret = %d!\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -431,17 +432,17 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
|
||||||
|
if (msg->is_polled) {
|
||||||
|
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
|
||||||
|
if (ret < 0)
|
||||||
|
- WD_ERR("wd ctx wait timeout(%d)!\n", ret);
|
||||||
|
+ WD_ERR("wd ctx wait timeout, ret = %d!\n", ret);
|
||||||
|
}
|
||||||
|
ret = wd_comp_setting.driver->comp_recv(ctx->ctx, msg, priv);
|
||||||
|
if (ret == -WD_HW_EACCESS) {
|
||||||
|
pthread_spin_unlock(&ctx->lock);
|
||||||
|
- WD_ERR("wd comp recv hw err!\n");
|
||||||
|
+ WD_ERR("wd comp recv hw error!\n");
|
||||||
|
return ret;
|
||||||
|
} else if (ret == -WD_EAGAIN) {
|
||||||
|
if (++recv_count > MAX_RETRY_COUNTS) {
|
||||||
|
pthread_spin_unlock(&ctx->lock);
|
||||||
|
- WD_ERR("wd comp recv timeout fail!\n");
|
||||||
|
+ WD_ERR("wd comp recv timeout!\n");
|
||||||
|
return -WD_ETIMEDOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -523,8 +524,7 @@ int wd_do_comp_sync2(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
|
||||||
|
ret = wd_do_comp_strm(h_sess, &strm_req);
|
||||||
|
if (ret < 0 || strm_req.status == WD_IN_EPARA) {
|
||||||
|
- WD_ERR("wd comp, invalid or incomplete data! "
|
||||||
|
- "ret(%d), req.status(%u)\n",
|
||||||
|
+ WD_ERR("wd comp, invalid or incomplete data! ret = %d, status = %u!\n",
|
||||||
|
ret, strm_req.status);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@@ -622,10 +622,8 @@ int wd_do_comp_strm(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = wd_comp_check_params(sess, req, CTX_MODE_SYNC);
|
||||||
|
- if (ret) {
|
||||||
|
- WD_ERR("fail to check params!\n");
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
if (req->data_fmt > WD_FLAT_BUF) {
|
||||||
|
WD_ERR("invalid: data_fmt is %d!\n", req->data_fmt);
|
||||||
|
@@ -696,7 +694,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
|
||||||
|
tag = wd_get_msg_from_pool(&wd_comp_setting.pool, idx, (void **)&msg);
|
||||||
|
if (tag < 0) {
|
||||||
|
- WD_ERR("busy, failed to get msg from pool!\n");
|
||||||
|
+ WD_ERR("failed to get msg from pool!\n");
|
||||||
|
return -WD_EBUSY;
|
||||||
|
}
|
||||||
|
fill_comp_msg(sess, msg, req);
|
||||||
|
@@ -709,7 +707,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
ret = wd_comp_setting.driver->comp_send(ctx->ctx, msg, priv);
|
||||||
|
if (ret < 0) {
|
||||||
|
pthread_spin_unlock(&ctx->lock);
|
||||||
|
- WD_ERR("wd comp send err(%d)!\n", ret);
|
||||||
|
+ WD_ERR("wd comp send error, ret = %d!\n", ret);
|
||||||
|
goto fail_with_msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -780,7 +778,7 @@ int wd_comp_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (type >= WD_DIR_MAX) {
|
||||||
|
- WD_ERR("wrong type(%u))!\n", type);
|
||||||
|
+ WD_ERR("invalid: op_type is %u!\n", type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -804,7 +802,7 @@ int wd_comp_get_env_param(__u32 node, __u32 type, __u32 mode,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (type >= WD_DIR_MAX) {
|
||||||
|
- WD_ERR("wrong type(%u))!\n", type);
|
||||||
|
+ WD_ERR("invalid: op_type is %u!\n", type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
217
0094-drv-comp-unify-print-format.patch
Normal file
217
0094-drv-comp-unify-print-format.patch
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
From be7121984d223d146348ede53626b0afb1026256 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yang Shen <shenyang39@huawei.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:29:50 +0800
|
||||||
|
Subject: [PATCH 102/109] drv/comp: unify print format
|
||||||
|
|
||||||
|
Unify print format with following rules:
|
||||||
|
1.failed to do sth.
|
||||||
|
2.add prefix "invalid: " for check parameters printf
|
||||||
|
3.add "!" at the end.
|
||||||
|
|
||||||
|
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||||
|
---
|
||||||
|
drv/hisi_comp.c | 50 +++++++++++++++++++++++++------------------------
|
||||||
|
1 file changed, 26 insertions(+), 24 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
|
||||||
|
index 0760908..5883bb4 100644
|
||||||
|
--- a/drv/hisi_comp.c
|
||||||
|
+++ b/drv/hisi_comp.c
|
||||||
|
@@ -192,12 +192,12 @@ struct hisi_zip_ctx {
|
||||||
|
static int buf_size_check_deflate(__u32 *in_size, __u32 *out_size)
|
||||||
|
{
|
||||||
|
if (unlikely(*in_size > HZ_MAX_SIZE)) {
|
||||||
|
- WD_ERR("invalid: out of range in_len(%u)!\n", *in_size);
|
||||||
|
+ WD_ERR("invalid: in_len(%u) is out of range!\n", *in_size);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(*out_size > HZ_MAX_SIZE)) {
|
||||||
|
- WD_ERR("warning: out of range avail_out(%u), will set 8MB size max!\n",
|
||||||
|
+ WD_ERR("warning: avail_out(%u) is out of range, will set 8MB size max!\n",
|
||||||
|
*out_size);
|
||||||
|
*out_size = HZ_MAX_SIZE;
|
||||||
|
}
|
||||||
|
@@ -295,19 +295,19 @@ static int fill_buf_addr_deflate_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
|
||||||
|
h_sgl_pool = hisi_qm_get_sglpool(h_qp);
|
||||||
|
if (!h_sgl_pool) {
|
||||||
|
- WD_ERR("failed to get sglpool\n");
|
||||||
|
+ WD_ERR("failed to get sglpool!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_in = hisi_qm_get_hw_sgl(h_sgl_pool, req->list_src);
|
||||||
|
if (!hw_sgl_in) {
|
||||||
|
- WD_ERR("failed to get hw sgl in\n");
|
||||||
|
+ WD_ERR("failed to get hw sgl in!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_out = hisi_qm_get_hw_sgl(h_sgl_pool, req->list_dst);
|
||||||
|
if (!hw_sgl_out) {
|
||||||
|
- WD_ERR("failed to get hw sgl out\n");
|
||||||
|
+ WD_ERR("failed to get hw sgl out!\n");
|
||||||
|
hisi_qm_put_hw_sgl(h_sgl_pool, hw_sgl_in);
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
@@ -419,17 +419,18 @@ static int fill_buf_lz77_zstd(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
void *ctx_buf = NULL;
|
||||||
|
|
||||||
|
if (unlikely(!data)) {
|
||||||
|
- WD_ERR("wd_lz77_zstd_data address is NULL\n");
|
||||||
|
+ WD_ERR("invalid: wd_lz77_zstd_data address is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(in_size > ZSTD_MAX_SIZE)) {
|
||||||
|
- WD_ERR("invalid input data size of lz77_zstd(%u)\n", in_size);
|
||||||
|
+ WD_ERR("invalid: in_len(%u) of lz77_zstd is out of range!\n",
|
||||||
|
+ in_size);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(out_size > HZ_MAX_SIZE)) {
|
||||||
|
- WD_ERR("warning: out of range avail_out(%u), will set 8MB size max!\n",
|
||||||
|
+ WD_ERR("warning: avail_out(%u) is out of range , will set 8MB size max!\n",
|
||||||
|
out_size);
|
||||||
|
out_size = HZ_MAX_SIZE;
|
||||||
|
}
|
||||||
|
@@ -439,7 +440,7 @@ static int fill_buf_lz77_zstd(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
* the frequency information about input data.
|
||||||
|
*/
|
||||||
|
if (unlikely(out_size < ZSTD_FREQ_DATA_SIZE + lit_size)) {
|
||||||
|
- WD_ERR("output buffer size of lz77_zstd is not enough(%u)\n",
|
||||||
|
+ WD_ERR("invalid: sequences output size(%u) is not enough!\n",
|
||||||
|
ZSTD_FREQ_DATA_SIZE + in_size);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -491,12 +492,13 @@ static int fill_buf_lz77_zstd_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (unlikely(in_size > ZSTD_MAX_SIZE)) {
|
||||||
|
- WD_ERR("invalid input data size of lz77_zstd(%u)\n", in_size);
|
||||||
|
+ WD_ERR("invalid: in_len(%u) of lz77_zstd is out of range!\n",
|
||||||
|
+ in_size);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(!data)) {
|
||||||
|
- WD_ERR("wd_lz77_zstd_data address is NULL\n");
|
||||||
|
+ WD_ERR("invalid: wd_lz77_zstd_data address is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -513,26 +515,26 @@ static int fill_buf_lz77_zstd_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
|
||||||
|
h_sgl_pool = hisi_qm_get_sglpool(h_qp);
|
||||||
|
if (!h_sgl_pool) {
|
||||||
|
- WD_ERR("failed to get sglpool\n");
|
||||||
|
+ WD_ERR("failed to get sglpool!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_in = hisi_qm_get_hw_sgl(h_sgl_pool, req->list_src);
|
||||||
|
if (!hw_sgl_in) {
|
||||||
|
- WD_ERR("failed to get hw sgl in\n");
|
||||||
|
+ WD_ERR("failed to get hw sgl in!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_out_lit = hisi_qm_get_hw_sgl(h_sgl_pool, req->list_dst);
|
||||||
|
if (!hw_sgl_out_lit) {
|
||||||
|
- WD_ERR("failed to get hw sgl out for literals\n");
|
||||||
|
+ WD_ERR("failed to get hw sgl out for literals!\n");
|
||||||
|
ret = -WD_ENOMEM;
|
||||||
|
goto err_free_sgl_in;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_out_seq = hisi_qm_get_hw_sgl(h_sgl_pool, seq_start);
|
||||||
|
if (!hw_sgl_out_seq) {
|
||||||
|
- WD_ERR("failed to get hw sgl out for sequences\n");
|
||||||
|
+ WD_ERR("failed to get hw sgl out for sequences!\n");
|
||||||
|
ret = -WD_ENOMEM;
|
||||||
|
goto err_free_sgl_out_lit;
|
||||||
|
}
|
||||||
|
@@ -626,7 +628,7 @@ static int fill_comp_level_lz77_zstd(struct hisi_zip_sqe *sqe, enum wd_comp_leve
|
||||||
|
sqe->dw9 = val;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
- WD_ERR("invalid: comp_lv in unsupported (%d)\n", comp_lv);
|
||||||
|
+ WD_ERR("invalid: comp_lv(%d) is unsupport!\n", comp_lv);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -821,7 +823,7 @@ static int fill_zip_comp_sqe(struct hisi_qp *qp, struct wd_comp_msg *msg,
|
||||||
|
|
||||||
|
if ((hw_type <= HISI_QM_API_VER2_BASE && alg_type > WD_GZIP) ||
|
||||||
|
(hw_type >= HISI_QM_API_VER3_BASE && alg_type >= WD_COMP_ALG_MAX)) {
|
||||||
|
- WD_ERR("invalid algorithm type(%d)\n", alg_type);
|
||||||
|
+ WD_ERR("invalid: algorithm type is %d!\n", alg_type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -870,13 +872,13 @@ static int hisi_zip_comp_send(handle_t ctx, struct wd_comp_msg *msg, void *priv)
|
||||||
|
|
||||||
|
ret = fill_zip_comp_sqe(qp, msg, &sqe);
|
||||||
|
if (ret < 0) {
|
||||||
|
- WD_ERR("failed to fill zip sqe(%d)!\n", ret);
|
||||||
|
+ WD_ERR("failed to fill zip sqe, ret = %d!\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = hisi_qm_send(h_qp, &sqe, 1, &count);
|
||||||
|
if (ret < 0) {
|
||||||
|
if (ret != -WD_EBUSY)
|
||||||
|
- WD_ERR("qm send is err(%d)!\n", ret);
|
||||||
|
+ WD_ERR("failed to send to hardware, ret = %d!\n", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@@ -919,7 +921,7 @@ static void free_hw_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
|
||||||
|
h_sgl_pool = hisi_qm_get_sglpool(h_qp);
|
||||||
|
if (!h_sgl_pool) {
|
||||||
|
- WD_ERR("failed to get sglpool to free hw sgl\n");
|
||||||
|
+ WD_ERR("failed to get sglpool to free hw sgl!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -949,7 +951,7 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe,
|
||||||
|
|
||||||
|
alg_type = get_alg_type(type);
|
||||||
|
if (alg_type < 0) {
|
||||||
|
- WD_ERR("failed to get request algorithm type(%u)\n", type);
|
||||||
|
+ WD_ERR("invalid: hardware type is %u!\n", type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -960,7 +962,7 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe,
|
||||||
|
if (qp->q_info.qp_mode == CTX_MODE_ASYNC) {
|
||||||
|
recv_msg = wd_comp_get_msg(qp->q_info.idx, tag);
|
||||||
|
if (!recv_msg) {
|
||||||
|
- WD_ERR("failed to get send msg! idx = %u, tag = %u.\n",
|
||||||
|
+ WD_ERR("failed to get send msg! idx = %u, tag = %u!\n",
|
||||||
|
qp->q_info.idx, tag);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -970,7 +972,7 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe,
|
||||||
|
|
||||||
|
if (status != 0 && status != HZ_NEGACOMPRESS &&
|
||||||
|
status != HZ_CRC_ERR && status != HZ_DECOMP_END) {
|
||||||
|
- WD_ERR("bad status(ctx_st=0x%x, s=0x%x, t=%u)\n",
|
||||||
|
+ WD_ERR("bad request(ctx_st = 0x%x, status = 0x%x, algorithm type = %u)!\n",
|
||||||
|
ctx_st, status, type);
|
||||||
|
recv_msg->req.status = WD_IN_EPARA;
|
||||||
|
}
|
||||||
|
@@ -993,7 +995,7 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe,
|
||||||
|
if (ctx_st == HZ_DECOMP_NO_SPACE)
|
||||||
|
recv_msg->req.status = WD_EAGAIN;
|
||||||
|
|
||||||
|
- dbg("zip recv lst =%hu, ctx_st=0x%x, status=0x%x, alg=%u\n", lstblk, ctx_st, status, type);
|
||||||
|
+ dbg("zip recv lst =%hu, ctx_st=0x%x, status=0x%x, alg=%u!\n", lstblk, ctx_st, status, type);
|
||||||
|
if (lstblk && (status == HZ_DECOMP_END))
|
||||||
|
recv_msg->req.status = WD_STREAM_END;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
272
0095-comp-add-unlikely-for-branch-prefetch.patch
Normal file
272
0095-comp-add-unlikely-for-branch-prefetch.patch
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
From bbbaf91e0819a3ef6953a434b229a105a1008892 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yang Shen <shenyang39@huawei.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:29:51 +0800
|
||||||
|
Subject: [PATCH 103/109] comp: add unlikely() for branch prefetch
|
||||||
|
|
||||||
|
Add unlikely() on the route of doing request to improve
|
||||||
|
branch prefetch success rate.
|
||||||
|
|
||||||
|
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||||
|
---
|
||||||
|
wd_comp.c | 69 ++++++++++++++++++++++++++++---------------------------
|
||||||
|
1 file changed, 35 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/wd_comp.c b/wd_comp.c
|
||||||
|
index de71e9c..9a71dfc 100644
|
||||||
|
--- a/wd_comp.c
|
||||||
|
+++ b/wd_comp.c
|
||||||
|
@@ -198,7 +198,7 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
*count = 0;
|
||||||
|
|
||||||
|
ret = wd_check_ctx(config, CTX_MODE_ASYNC, idx);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ctx = config->ctxs + idx;
|
||||||
|
@@ -206,7 +206,7 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
do {
|
||||||
|
ret = wd_comp_setting.driver->comp_recv(ctx->ctx, &resp_msg,
|
||||||
|
priv);
|
||||||
|
- if (ret < 0) {
|
||||||
|
+ if (unlikely(ret < 0)) {
|
||||||
|
if (ret == -WD_HW_EACCESS)
|
||||||
|
WD_ERR("wd comp recv hw error!\n");
|
||||||
|
return ret;
|
||||||
|
@@ -216,7 +216,7 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
|
||||||
|
|
||||||
|
msg = wd_find_msg_in_pool(&wd_comp_setting.pool, idx,
|
||||||
|
resp_msg.tag);
|
||||||
|
- if (!msg) {
|
||||||
|
+ if (unlikely(!msg)) {
|
||||||
|
WD_ERR("failed to get msg from pool!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -335,12 +335,12 @@ static void fill_comp_msg(struct wd_comp_sess *sess, struct wd_comp_msg *msg,
|
||||||
|
static int wd_comp_check_buffer(struct wd_comp_req *req)
|
||||||
|
{
|
||||||
|
if (req->data_fmt == WD_FLAT_BUF) {
|
||||||
|
- if (!req->src || !req->dst) {
|
||||||
|
+ if (unlikely(!req->src || !req->dst)) {
|
||||||
|
WD_ERR("invalid: src or dst is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
} else if (req->data_fmt == WD_SGL_BUF) {
|
||||||
|
- if (!req->list_src || !req->list_dst) {
|
||||||
|
+ if (unlikely(!req->list_src || !req->list_dst)) {
|
||||||
|
WD_ERR("invalid: list_src or list_dst is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -360,37 +360,37 @@ static int wd_comp_check_params(struct wd_comp_sess *sess,
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- if (!sess || !req) {
|
||||||
|
+ if (unlikely(!sess || !req)) {
|
||||||
|
WD_ERR("invalid: sess or req is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (req->data_fmt > WD_SGL_BUF) {
|
||||||
|
+ if (unlikely(req->data_fmt > WD_SGL_BUF)) {
|
||||||
|
WD_ERR("invalid: data_fmt is %d!\n", req->data_fmt);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = wd_comp_check_buffer(req);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (req->op_type != WD_DIR_COMPRESS &&
|
||||||
|
- req->op_type != WD_DIR_DECOMPRESS) {
|
||||||
|
+ if (unlikely(req->op_type != WD_DIR_COMPRESS &&
|
||||||
|
+ req->op_type != WD_DIR_DECOMPRESS)) {
|
||||||
|
WD_ERR("invalid: op_type is %d!\n", req->op_type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (mode == CTX_MODE_ASYNC && !req->cb) {
|
||||||
|
+ if (unlikely(mode == CTX_MODE_ASYNC && !req->cb)) {
|
||||||
|
WD_ERR("invalid: async comp cb is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (mode == CTX_MODE_ASYNC && !req->cb_param) {
|
||||||
|
+ if (unlikely(mode == CTX_MODE_ASYNC && !req->cb_param)) {
|
||||||
|
WD_ERR("invalid: async comp cb param is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (mode == CTX_MODE_SYNC && req->cb) {
|
||||||
|
+ if (unlikely(mode == CTX_MODE_SYNC && req->cb)) {
|
||||||
|
WD_ERR("invalid: sync comp cb should be NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -414,7 +414,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
|
||||||
|
sess->sched_key,
|
||||||
|
CTX_MODE_SYNC);
|
||||||
|
ret = wd_check_ctx(config, CTX_MODE_SYNC, idx);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ctx = config->ctxs + idx;
|
||||||
|
@@ -422,7 +422,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
|
||||||
|
pthread_spin_lock(&ctx->lock);
|
||||||
|
|
||||||
|
ret = wd_comp_setting.driver->comp_send(ctx->ctx, msg, priv);
|
||||||
|
- if (ret < 0) {
|
||||||
|
+ if (unlikely(ret < 0)) {
|
||||||
|
pthread_spin_unlock(&ctx->lock);
|
||||||
|
WD_ERR("wd comp send error, ret = %d!\n", ret);
|
||||||
|
return ret;
|
||||||
|
@@ -431,11 +431,11 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
|
||||||
|
do {
|
||||||
|
if (msg->is_polled) {
|
||||||
|
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
|
||||||
|
- if (ret < 0)
|
||||||
|
+ if (unlikely(ret < 0))
|
||||||
|
WD_ERR("wd ctx wait timeout, ret = %d!\n", ret);
|
||||||
|
}
|
||||||
|
ret = wd_comp_setting.driver->comp_recv(ctx->ctx, msg, priv);
|
||||||
|
- if (ret == -WD_HW_EACCESS) {
|
||||||
|
+ if (unlikely(ret == -WD_HW_EACCESS)) {
|
||||||
|
pthread_spin_unlock(&ctx->lock);
|
||||||
|
WD_ERR("wd comp recv hw error!\n");
|
||||||
|
return ret;
|
||||||
|
@@ -460,10 +460,10 @@ int wd_do_comp_sync(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = wd_comp_check_params(sess, req, CTX_MODE_SYNC);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (!req->src_len) {
|
||||||
|
+ if (unlikely(!req->src_len)) {
|
||||||
|
WD_ERR("invalid: req src_len is 0!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -476,7 +476,7 @@ int wd_do_comp_sync(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
msg.stream_mode = WD_COMP_STATELESS;
|
||||||
|
|
||||||
|
ret = wd_comp_sync_job(sess, req, &msg);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
req->src_len = msg.in_cons;
|
||||||
|
@@ -496,10 +496,10 @@ int wd_do_comp_sync2(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = wd_comp_check_params(sess, req, CTX_MODE_SYNC);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (!req->src_len) {
|
||||||
|
+ if (unlikely(!req->src_len)) {
|
||||||
|
WD_ERR("invalid: req src_len is 0!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -523,7 +523,7 @@ int wd_do_comp_sync2(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = wd_do_comp_strm(h_sess, &strm_req);
|
||||||
|
- if (ret < 0 || strm_req.status == WD_IN_EPARA) {
|
||||||
|
+ if (unlikely(ret < 0 || strm_req.status == WD_IN_EPARA)) {
|
||||||
|
WD_ERR("wd comp, invalid or incomplete data! ret = %d, status = %u!\n",
|
||||||
|
ret, strm_req.status);
|
||||||
|
return ret;
|
||||||
|
@@ -573,7 +573,7 @@ static int append_store_block(struct wd_comp_sess *sess,
|
||||||
|
__u32 isize = sess->isize;
|
||||||
|
|
||||||
|
if (sess->alg_type == WD_ZLIB) {
|
||||||
|
- if (req->dst_len < blocksize + sizeof(checksum))
|
||||||
|
+ if (unlikely(req->dst_len < blocksize + sizeof(checksum)))
|
||||||
|
return -WD_EINVAL;
|
||||||
|
memcpy(req->dst, store_block, blocksize);
|
||||||
|
req->dst_len = blocksize;
|
||||||
|
@@ -582,7 +582,8 @@ static int append_store_block(struct wd_comp_sess *sess,
|
||||||
|
memcpy(req->dst + blocksize, &checksum, sizeof(checksum));
|
||||||
|
req->dst_len += sizeof(checksum);
|
||||||
|
} else if (sess->alg_type == WD_GZIP) {
|
||||||
|
- if (req->dst_len < blocksize + sizeof(checksum) + sizeof(isize))
|
||||||
|
+ if (unlikely(req->dst_len < blocksize +
|
||||||
|
+ sizeof(checksum) + sizeof(isize)))
|
||||||
|
return -WD_EINVAL;
|
||||||
|
memcpy(req->dst, store_block, blocksize);
|
||||||
|
req->dst_len = blocksize;
|
||||||
|
@@ -622,10 +623,10 @@ int wd_do_comp_strm(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = wd_comp_check_params(sess, req, CTX_MODE_SYNC);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (req->data_fmt > WD_FLAT_BUF) {
|
||||||
|
+ if (unlikely(req->data_fmt > WD_FLAT_BUF)) {
|
||||||
|
WD_ERR("invalid: data_fmt is %d!\n", req->data_fmt);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -647,7 +648,7 @@ int wd_do_comp_strm(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
src_len = req->src_len;
|
||||||
|
|
||||||
|
ret = wd_comp_sync_job(sess, req, &msg);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
req->src_len = msg.in_cons;
|
||||||
|
@@ -675,10 +676,10 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
__u32 idx;
|
||||||
|
|
||||||
|
ret = wd_comp_check_params(sess, req, CTX_MODE_ASYNC);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (!req->src_len) {
|
||||||
|
+ if (unlikely(!req->src_len)) {
|
||||||
|
WD_ERR("invalid: req src_len is 0!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -687,13 +688,13 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
sess->sched_key,
|
||||||
|
CTX_MODE_ASYNC);
|
||||||
|
ret = wd_check_ctx(config, CTX_MODE_ASYNC, idx);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ctx = config->ctxs + idx;
|
||||||
|
|
||||||
|
tag = wd_get_msg_from_pool(&wd_comp_setting.pool, idx, (void **)&msg);
|
||||||
|
- if (tag < 0) {
|
||||||
|
+ if (unlikely(tag < 0)) {
|
||||||
|
WD_ERR("failed to get msg from pool!\n");
|
||||||
|
return -WD_EBUSY;
|
||||||
|
}
|
||||||
|
@@ -705,7 +706,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
pthread_spin_lock(&ctx->lock);
|
||||||
|
|
||||||
|
ret = wd_comp_setting.driver->comp_send(ctx->ctx, msg, priv);
|
||||||
|
- if (ret < 0) {
|
||||||
|
+ if (unlikely(ret < 0)) {
|
||||||
|
pthread_spin_unlock(&ctx->lock);
|
||||||
|
WD_ERR("wd comp send error, ret = %d!\n", ret);
|
||||||
|
goto fail_with_msg;
|
||||||
|
@@ -714,7 +715,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
pthread_spin_unlock(&ctx->lock);
|
||||||
|
|
||||||
|
ret = wd_add_task_to_async_queue(&wd_comp_env_config, idx);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
goto fail_with_msg;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
199
0096-drv-comp-add-unlikely-for-branch-prefetch.patch
Normal file
199
0096-drv-comp-add-unlikely-for-branch-prefetch.patch
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
From 4077df41a1ba2ccd155195e16026d0329d062f85 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yang Shen <shenyang39@huawei.com>
|
||||||
|
Date: Thu, 10 Mar 2022 20:29:52 +0800
|
||||||
|
Subject: [PATCH 104/109] drv/comp: add unlikely() for branch prefetch
|
||||||
|
|
||||||
|
Add unlikely() on the route of doing request to improve
|
||||||
|
branch prefetch success rate.
|
||||||
|
|
||||||
|
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
||||||
|
---
|
||||||
|
drv/hisi_comp.c | 46 +++++++++++++++++++++++-----------------------
|
||||||
|
1 file changed, 23 insertions(+), 23 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
|
||||||
|
index 5883bb4..860da43 100644
|
||||||
|
--- a/drv/hisi_comp.c
|
||||||
|
+++ b/drv/hisi_comp.c
|
||||||
|
@@ -246,7 +246,7 @@ static int fill_buf_deflate_generic(struct hisi_zip_sqe *sqe,
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = buf_size_check_deflate(&in_size, &out_size);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
fill_buf_size_deflate(sqe, in_size, out_size);
|
||||||
|
@@ -294,19 +294,19 @@ static int fill_buf_addr_deflate_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
handle_t h_sgl_pool;
|
||||||
|
|
||||||
|
h_sgl_pool = hisi_qm_get_sglpool(h_qp);
|
||||||
|
- if (!h_sgl_pool) {
|
||||||
|
+ if (unlikely(!h_sgl_pool)) {
|
||||||
|
WD_ERR("failed to get sglpool!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_in = hisi_qm_get_hw_sgl(h_sgl_pool, req->list_src);
|
||||||
|
- if (!hw_sgl_in) {
|
||||||
|
+ if (unlikely(!hw_sgl_in)) {
|
||||||
|
WD_ERR("failed to get hw sgl in!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_out = hisi_qm_get_hw_sgl(h_sgl_pool, req->list_dst);
|
||||||
|
- if (!hw_sgl_out) {
|
||||||
|
+ if (unlikely(!hw_sgl_out)) {
|
||||||
|
WD_ERR("failed to get hw sgl out!\n");
|
||||||
|
hisi_qm_put_hw_sgl(h_sgl_pool, hw_sgl_in);
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
@@ -345,7 +345,7 @@ static int fill_buf_deflate_slg_generic(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
fill_buf_type_sgl(sqe);
|
||||||
|
|
||||||
|
ret = fill_buf_addr_deflate_sgl(h_qp, sqe, msg);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (head != NULL && msg->req.op_type == WD_DIR_COMPRESS) {
|
||||||
|
@@ -514,26 +514,26 @@ static int fill_buf_lz77_zstd_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
fill_buf_size_lz77_zstd(sqe, in_size, lits_size, out_size - lits_size);
|
||||||
|
|
||||||
|
h_sgl_pool = hisi_qm_get_sglpool(h_qp);
|
||||||
|
- if (!h_sgl_pool) {
|
||||||
|
+ if (unlikely(!h_sgl_pool)) {
|
||||||
|
WD_ERR("failed to get sglpool!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_in = hisi_qm_get_hw_sgl(h_sgl_pool, req->list_src);
|
||||||
|
- if (!hw_sgl_in) {
|
||||||
|
+ if (unlikely(!hw_sgl_in)) {
|
||||||
|
WD_ERR("failed to get hw sgl in!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_out_lit = hisi_qm_get_hw_sgl(h_sgl_pool, req->list_dst);
|
||||||
|
- if (!hw_sgl_out_lit) {
|
||||||
|
+ if (unlikely(!hw_sgl_out_lit)) {
|
||||||
|
WD_ERR("failed to get hw sgl out for literals!\n");
|
||||||
|
ret = -WD_ENOMEM;
|
||||||
|
goto err_free_sgl_in;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw_sgl_out_seq = hisi_qm_get_hw_sgl(h_sgl_pool, seq_start);
|
||||||
|
- if (!hw_sgl_out_seq) {
|
||||||
|
+ if (unlikely(!hw_sgl_out_seq)) {
|
||||||
|
WD_ERR("failed to get hw sgl out for sequences!\n");
|
||||||
|
ret = -WD_ENOMEM;
|
||||||
|
goto err_free_sgl_out_lit;
|
||||||
|
@@ -680,7 +680,7 @@ static void get_data_size_lz77_zstd(struct hisi_zip_sqe *sqe, enum wd_comp_op_ty
|
||||||
|
struct wd_lz77_zstd_data *data = recv_msg->req.priv;
|
||||||
|
void *ctx_buf = recv_msg->ctx_buf;
|
||||||
|
|
||||||
|
- if (!data)
|
||||||
|
+ if (unlikely(!data))
|
||||||
|
return;
|
||||||
|
|
||||||
|
data->lit_num = sqe->comp_data_length;
|
||||||
|
@@ -782,7 +782,7 @@ static int hisi_zip_init(struct wd_ctx_config_internal *config, void *priv)
|
||||||
|
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
|
||||||
|
qm_priv.idx = i;
|
||||||
|
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
|
||||||
|
- if (!h_qp)
|
||||||
|
+ if (unlikely(!h_qp))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -821,14 +821,14 @@ static int fill_zip_comp_sqe(struct hisi_qp *qp, struct wd_comp_msg *msg,
|
||||||
|
__u8 state;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- if ((hw_type <= HISI_QM_API_VER2_BASE && alg_type > WD_GZIP) ||
|
||||||
|
- (hw_type >= HISI_QM_API_VER3_BASE && alg_type >= WD_COMP_ALG_MAX)) {
|
||||||
|
+ if (unlikely((hw_type <= HISI_QM_API_VER2_BASE && alg_type > WD_GZIP) ||
|
||||||
|
+ (hw_type >= HISI_QM_API_VER3_BASE && alg_type >= WD_COMP_ALG_MAX))) {
|
||||||
|
WD_ERR("invalid: algorithm type is %d!\n", alg_type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ops[alg_type].fill_buf[msg->req.data_fmt]((handle_t)qp, sqe, msg);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ops[alg_type].fill_sqe_type(sqe);
|
||||||
|
@@ -838,7 +838,7 @@ static int fill_zip_comp_sqe(struct hisi_qp *qp, struct wd_comp_msg *msg,
|
||||||
|
ops[alg_type].fill_tag(sqe, msg->tag);
|
||||||
|
|
||||||
|
ret = ops[alg_type].fill_comp_level(sqe, msg->comp_lv);
|
||||||
|
- if (ret)
|
||||||
|
+ if (unlikely(ret))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
state = (msg->stream_mode == WD_COMP_STATEFUL) ? HZ_STATEFUL :
|
||||||
|
@@ -871,12 +871,12 @@ static int hisi_zip_comp_send(handle_t ctx, struct wd_comp_msg *msg, void *priv)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = fill_zip_comp_sqe(qp, msg, &sqe);
|
||||||
|
- if (ret < 0) {
|
||||||
|
+ if (unlikely(ret < 0)) {
|
||||||
|
WD_ERR("failed to fill zip sqe, ret = %d!\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = hisi_qm_send(h_qp, &sqe, 1, &count);
|
||||||
|
- if (ret < 0) {
|
||||||
|
+ if (unlikely(ret < 0)) {
|
||||||
|
if (ret != -WD_EBUSY)
|
||||||
|
WD_ERR("failed to send to hardware, ret = %d!\n", ret);
|
||||||
|
|
||||||
|
@@ -920,7 +920,7 @@ static void free_hw_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
|
||||||
|
handle_t h_sgl_pool;
|
||||||
|
|
||||||
|
h_sgl_pool = hisi_qm_get_sglpool(h_qp);
|
||||||
|
- if (!h_sgl_pool) {
|
||||||
|
+ if (unlikely(!h_sgl_pool)) {
|
||||||
|
WD_ERR("failed to get sglpool to free hw sgl!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@@ -950,7 +950,7 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe,
|
||||||
|
__u32 tag;
|
||||||
|
|
||||||
|
alg_type = get_alg_type(type);
|
||||||
|
- if (alg_type < 0) {
|
||||||
|
+ if (unlikely(alg_type < 0)) {
|
||||||
|
WD_ERR("invalid: hardware type is %u!\n", type);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
@@ -961,7 +961,7 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe,
|
||||||
|
|
||||||
|
if (qp->q_info.qp_mode == CTX_MODE_ASYNC) {
|
||||||
|
recv_msg = wd_comp_get_msg(qp->q_info.idx, tag);
|
||||||
|
- if (!recv_msg) {
|
||||||
|
+ if (unlikely(!recv_msg)) {
|
||||||
|
WD_ERR("failed to get send msg! idx = %u, tag = %u!\n",
|
||||||
|
qp->q_info.idx, tag);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
@@ -970,8 +970,8 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe,
|
||||||
|
|
||||||
|
recv_msg->req.status = 0;
|
||||||
|
|
||||||
|
- if (status != 0 && status != HZ_NEGACOMPRESS &&
|
||||||
|
- status != HZ_CRC_ERR && status != HZ_DECOMP_END) {
|
||||||
|
+ if (unlikely(status != 0 && status != HZ_NEGACOMPRESS &&
|
||||||
|
+ status != HZ_CRC_ERR && status != HZ_DECOMP_END)) {
|
||||||
|
WD_ERR("bad request(ctx_st = 0x%x, status = 0x%x, algorithm type = %u)!\n",
|
||||||
|
ctx_st, status, type);
|
||||||
|
recv_msg->req.status = WD_IN_EPARA;
|
||||||
|
@@ -1019,7 +1019,7 @@ static int hisi_zip_comp_recv(handle_t ctx, struct wd_comp_msg *recv_msg,
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = hisi_qm_recv(h_qp, &sqe, 1, &count);
|
||||||
|
- if (ret < 0)
|
||||||
|
+ if (unlikely(ret < 0))
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return parse_zip_sqe(qp, &sqe, recv_msg);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
73
0097-hisi_hpre-modify-the-return-value-of-function.patch
Normal file
73
0097-hisi_hpre-modify-the-return-value-of-function.patch
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
From 8ebb63a449ec1514f7758aa866d29a6b94845e13 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Weili Qian <qianweili@huawei.com>
|
||||||
|
Date: Mon, 14 Mar 2022 18:47:57 +0800
|
||||||
|
Subject: [PATCH 106/109] hisi_hpre: modify the return value of function
|
||||||
|
|
||||||
|
When these functions are executed successfully,
|
||||||
|
the caller of these functions will not care about
|
||||||
|
the value of the data size, so there is no need
|
||||||
|
to return the data size, just returning a "WD_SUCCESS"
|
||||||
|
will be fine.
|
||||||
|
|
||||||
|
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||||
|
---
|
||||||
|
drv/hisi_hpre.c | 14 +++++++-------
|
||||||
|
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
|
||||||
|
index e46efef..d9546a6 100644
|
||||||
|
--- a/drv/hisi_hpre.c
|
||||||
|
+++ b/drv/hisi_hpre.c
|
||||||
|
@@ -221,8 +221,7 @@ static int fill_rsa_crt_prikey2(struct wd_rsa_prikey *prikey,
|
||||||
|
|
||||||
|
*data = wd_dq->data;
|
||||||
|
|
||||||
|
- return (int)(wd_dq->bsize + wd_qinv->bsize + wd_p->bsize +
|
||||||
|
- wd_q->bsize + wd_dp->bsize);
|
||||||
|
+ return WD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fill_rsa_prikey1(struct wd_rsa_prikey *prikey, void **data)
|
||||||
|
@@ -243,7 +242,7 @@ static int fill_rsa_prikey1(struct wd_rsa_prikey *prikey, void **data)
|
||||||
|
|
||||||
|
*data = wd_d->data;
|
||||||
|
|
||||||
|
- return (int)(wd_n->bsize + wd_d->bsize);
|
||||||
|
+ return WD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fill_rsa_pubkey(struct wd_rsa_pubkey *pubkey, void **data)
|
||||||
|
@@ -263,7 +262,8 @@ static int fill_rsa_pubkey(struct wd_rsa_pubkey *pubkey, void **data)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
*data = wd_e->data;
|
||||||
|
- return (int)(wd_n->bsize + wd_e->bsize);
|
||||||
|
+
|
||||||
|
+ return WD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fill_rsa_genkey_in(struct wd_rsa_kg_in *genkey)
|
||||||
|
@@ -382,17 +382,17 @@ static int rsa_prepare_key(struct wd_rsa_msg *msg,
|
||||||
|
if (req->op_type == WD_RSA_SIGN) {
|
||||||
|
if (hw_msg->alg == HPRE_ALG_NC_CRT) {
|
||||||
|
ret = fill_rsa_crt_prikey2((void *)msg->key, &data);
|
||||||
|
- if (ret <= 0)
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
ret = fill_rsa_prikey1((void *)msg->key, &data);
|
||||||
|
- if (ret < 0)
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
hw_msg->alg = HPRE_ALG_NC_NCRT;
|
||||||
|
}
|
||||||
|
} else if (req->op_type == WD_RSA_VERIFY) {
|
||||||
|
ret = fill_rsa_pubkey((void *)msg->key, &data);
|
||||||
|
- if (ret < 0)
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
hw_msg->alg = HPRE_ALG_NC_NCRT;
|
||||||
|
} else if (req->op_type == WD_RSA_GENKEY) {
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
955
0098-uadk-parse-epoll-flag-from-environment-variable.patch
Normal file
955
0098-uadk-parse-epoll-flag-from-environment-variable.patch
Normal file
@ -0,0 +1,955 @@
|
|||||||
|
From f01c1ddc862fc07ce247c8d64083918cf84009c8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Wed, 16 Mar 2022 18:55:28 +0800
|
||||||
|
Subject: [PATCH 107/109] uadk: parse epoll flag from environment variable
|
||||||
|
|
||||||
|
1.wd_set_epoll_en is used to parse epoll enable flag
|
||||||
|
from environment variable and store it to global variable.
|
||||||
|
2.When uadk works in synchronize mode, it will check the
|
||||||
|
global variable and decide whether to use wd_ctx_wait.
|
||||||
|
3.HPRE algorithm(ecc, rsa, dh) is also support epoll wait now.
|
||||||
|
4.hisi_qm_enable_interrupt is used to enable interrupt mode dynamically
|
||||||
|
when uadk send packets, but since we can init queue with fixed mode now,
|
||||||
|
it is not so efficient and can be replaced.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
docs/wd_environment_variable | 5 +++
|
||||||
|
drv/hisi_comp.c | 5 +--
|
||||||
|
drv/hisi_hpre.c | 3 ++
|
||||||
|
drv/hisi_qm_udrv.c | 21 ++----------
|
||||||
|
drv/hisi_sec.c | 15 ++-------
|
||||||
|
include/drv/wd_aead_drv.h | 2 --
|
||||||
|
include/drv/wd_cipher_drv.h | 2 --
|
||||||
|
include/drv/wd_comp_drv.h | 2 --
|
||||||
|
include/drv/wd_digest_drv.h | 2 --
|
||||||
|
include/hisi_qm_udrv.h | 4 +--
|
||||||
|
include/wd_alg_common.h | 3 ++
|
||||||
|
include/wd_util.h | 9 +++++
|
||||||
|
wd_aead.c | 23 +++++--------
|
||||||
|
wd_cipher.c | 23 +++++--------
|
||||||
|
wd_comp.c | 26 +++++++--------
|
||||||
|
wd_dh.c | 23 ++++++++-----
|
||||||
|
wd_digest.c | 24 ++++++--------
|
||||||
|
wd_ecc.c | 23 ++++++++-----
|
||||||
|
wd_rsa.c | 23 ++++++++-----
|
||||||
|
wd_sched.c | 2 +-
|
||||||
|
wd_util.c | 64 ++++++++++++++++++++++++++++--------
|
||||||
|
21 files changed, 163 insertions(+), 141 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/docs/wd_environment_variable b/docs/wd_environment_variable
|
||||||
|
index 3ada5fb..8ac2da7 100644
|
||||||
|
--- a/docs/wd_environment_variable
|
||||||
|
+++ b/docs/wd_environment_variable
|
||||||
|
@@ -47,6 +47,11 @@ WD_<alg>_ASYNC_POLL_NUM
|
||||||
|
WD_<alg>_ASYNC_POLL_NUM=2@0,4@2 means to configure 2 async polling threads in
|
||||||
|
node0, and 4 polling threads in node2.
|
||||||
|
|
||||||
|
+WD_<alg>_EPOLL_EN
|
||||||
|
+ Define if wd_do_<alg>_sync enable wd_ctx_wait in WD. WD_<alg>_EPOLL_EN=1
|
||||||
|
+ means enable wd_ctx_wait in WD, driver will wait to receive the package until
|
||||||
|
+ hardware is done with package, otherwise driver will try to receive the package
|
||||||
|
+ directly after the package is sent.
|
||||||
|
|
||||||
|
2. User model
|
||||||
|
=============
|
||||||
|
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
|
||||||
|
index 860da43..9fdf3f1 100644
|
||||||
|
--- a/drv/hisi_comp.c
|
||||||
|
+++ b/drv/hisi_comp.c
|
||||||
|
@@ -780,6 +780,9 @@ static int hisi_zip_init(struct wd_ctx_config_internal *config, void *priv)
|
||||||
|
qm_priv.sqe_size = sizeof(struct hisi_zip_sqe);
|
||||||
|
qm_priv.op_type = config->ctxs[i].op_type;
|
||||||
|
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
|
||||||
|
+ /* Setting the epoll en to 0 for ASYNC ctx */
|
||||||
|
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
|
||||||
|
+ config->epoll_en : 0;
|
||||||
|
qm_priv.idx = i;
|
||||||
|
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
|
||||||
|
if (unlikely(!h_qp))
|
||||||
|
@@ -883,8 +886,6 @@ static int hisi_zip_comp_send(handle_t ctx, struct wd_comp_msg *msg, void *priv)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
|
||||||
|
-
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
|
||||||
|
index d9546a6..7e14027 100644
|
||||||
|
--- a/drv/hisi_hpre.c
|
||||||
|
+++ b/drv/hisi_hpre.c
|
||||||
|
@@ -466,6 +466,9 @@ static int hpre_init(struct wd_ctx_config_internal *config, void *priv, const ch
|
||||||
|
for (i = 0; i < config->ctx_num; i++) {
|
||||||
|
h_ctx = config->ctxs[i].ctx;
|
||||||
|
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
|
||||||
|
+ /* Setting the epoll en to 0 for ASYNC ctx */
|
||||||
|
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
|
||||||
|
+ config->epoll_en : 0;
|
||||||
|
qm_priv.idx = i;
|
||||||
|
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
|
||||||
|
if (!h_qp) {
|
||||||
|
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
|
||||||
|
index be06570..2c0d87c 100644
|
||||||
|
--- a/drv/hisi_qm_udrv.c
|
||||||
|
+++ b/drv/hisi_qm_udrv.c
|
||||||
|
@@ -309,6 +309,7 @@ static int hisi_qm_setup_info(struct hisi_qp *qp, struct hisi_qm_priv *config)
|
||||||
|
}
|
||||||
|
|
||||||
|
q_info->qp_mode = config->qp_mode;
|
||||||
|
+ q_info->epoll_en = config->epoll_en;
|
||||||
|
q_info->idx = config->idx;
|
||||||
|
q_info->sqe_size = config->sqe_size;
|
||||||
|
q_info->cqc_phase = 1;
|
||||||
|
@@ -479,7 +480,7 @@ static int hisi_qm_recv_single(struct hisi_qm_queue_info *q_info, void *resp)
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
- q_info->db(q_info, QM_DBELL_CMD_CQ, i, 0);
|
||||||
|
+ q_info->db(q_info, QM_DBELL_CMD_CQ, i, q_info->epoll_en);
|
||||||
|
|
||||||
|
/* only support one thread poll one queue, so no need protect */
|
||||||
|
q_info->cq_head_index = i;
|
||||||
|
@@ -919,21 +920,3 @@ __u32 hisi_qm_get_list_size(struct wd_datalist *start_node,
|
||||||
|
|
||||||
|
return lits_size;
|
||||||
|
}
|
||||||
|
-
|
||||||
|
-void hisi_qm_enable_interrupt(handle_t ctx, __u8 enable)
|
||||||
|
-{
|
||||||
|
- struct hisi_qm_queue_info *q_info;
|
||||||
|
- struct hisi_qp *qp;
|
||||||
|
- handle_t h_qp;
|
||||||
|
-
|
||||||
|
- if (!enable)
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- h_qp = (handle_t)wd_ctx_get_priv(ctx);
|
||||||
|
- qp = (struct hisi_qp *)h_qp;
|
||||||
|
- q_info = &qp->q_info;
|
||||||
|
-
|
||||||
|
- pthread_spin_lock(&q_info->lock);
|
||||||
|
- q_info->db(q_info, QM_DBELL_CMD_CQ, q_info->cq_head_index, 1);
|
||||||
|
- pthread_spin_unlock(&q_info->lock);
|
||||||
|
-}
|
||||||
|
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
|
||||||
|
index aa86a6b..0732cdc 100644
|
||||||
|
--- a/drv/hisi_sec.c
|
||||||
|
+++ b/drv/hisi_sec.c
|
||||||
|
@@ -959,8 +959,6 @@ int hisi_sec_cipher_send(handle_t ctx, struct wd_cipher_msg *msg)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
|
||||||
|
-
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1162,8 +1160,6 @@ int hisi_sec_cipher_send_v3(handle_t ctx, struct wd_cipher_msg *msg)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
|
||||||
|
-
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1403,8 +1399,6 @@ int hisi_sec_digest_send(handle_t ctx, struct wd_digest_msg *msg)
|
||||||
|
goto put_sgl;
|
||||||
|
}
|
||||||
|
|
||||||
|
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
|
||||||
|
-
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
put_sgl:
|
||||||
|
@@ -1560,8 +1554,6 @@ int hisi_sec_digest_send_v3(handle_t ctx, struct wd_digest_msg *msg)
|
||||||
|
goto put_sgl;
|
||||||
|
}
|
||||||
|
|
||||||
|
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
|
||||||
|
-
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
put_sgl:
|
||||||
|
@@ -1913,8 +1905,6 @@ int hisi_sec_aead_send(handle_t ctx, struct wd_aead_msg *msg)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
|
||||||
|
-
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2181,8 +2171,6 @@ int hisi_sec_aead_send_v3(handle_t ctx, struct wd_aead_msg *msg)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
- hisi_qm_enable_interrupt(ctx, msg->is_polled);
|
||||||
|
-
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2285,6 +2273,9 @@ int hisi_sec_init(struct wd_ctx_config_internal *config, void *priv)
|
||||||
|
/* setting the type is 0 for sqc_type */
|
||||||
|
qm_priv.op_type = 0;
|
||||||
|
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
|
||||||
|
+ /* Setting the epoll en to 0 for ASYNC ctx */
|
||||||
|
+ qm_priv.epoll_en = (qm_priv.qp_mode == CTX_MODE_SYNC) ?
|
||||||
|
+ config->epoll_en : 0;
|
||||||
|
qm_priv.idx = i;
|
||||||
|
h_qp = hisi_qm_alloc_qp(&qm_priv, h_ctx);
|
||||||
|
if (!h_qp)
|
||||||
|
diff --git a/include/drv/wd_aead_drv.h b/include/drv/wd_aead_drv.h
|
||||||
|
index 78a5673..137e70a 100644
|
||||||
|
--- a/include/drv/wd_aead_drv.h
|
||||||
|
+++ b/include/drv/wd_aead_drv.h
|
||||||
|
@@ -31,8 +31,6 @@ struct wd_aead_msg {
|
||||||
|
__u8 data_fmt;
|
||||||
|
/* Operation result, denoted by WD error code */
|
||||||
|
__u8 result;
|
||||||
|
- /* epoll flag */
|
||||||
|
- __u8 is_polled;
|
||||||
|
|
||||||
|
/* in bytes */
|
||||||
|
__u32 in_bytes;
|
||||||
|
diff --git a/include/drv/wd_cipher_drv.h b/include/drv/wd_cipher_drv.h
|
||||||
|
index e649869..87b77d3 100644
|
||||||
|
--- a/include/drv/wd_cipher_drv.h
|
||||||
|
+++ b/include/drv/wd_cipher_drv.h
|
||||||
|
@@ -28,8 +28,6 @@ struct wd_cipher_msg {
|
||||||
|
__u8 data_fmt;
|
||||||
|
/* Operation result, denoted by WD error code */
|
||||||
|
__u8 result;
|
||||||
|
- /* epoll flag */
|
||||||
|
- __u8 is_polled;
|
||||||
|
|
||||||
|
/* Key bytes */
|
||||||
|
__u16 key_bytes;
|
||||||
|
diff --git a/include/drv/wd_comp_drv.h b/include/drv/wd_comp_drv.h
|
||||||
|
index 8146a50..73403b5 100644
|
||||||
|
--- a/include/drv/wd_comp_drv.h
|
||||||
|
+++ b/include/drv/wd_comp_drv.h
|
||||||
|
@@ -50,8 +50,6 @@ struct wd_comp_msg {
|
||||||
|
__u32 checksum;
|
||||||
|
/* Request identifier */
|
||||||
|
__u32 tag;
|
||||||
|
- /* Epoll flag */
|
||||||
|
- __u8 is_polled;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wd_comp_driver {
|
||||||
|
diff --git a/include/drv/wd_digest_drv.h b/include/drv/wd_digest_drv.h
|
||||||
|
index fdde772..6907bc5 100644
|
||||||
|
--- a/include/drv/wd_digest_drv.h
|
||||||
|
+++ b/include/drv/wd_digest_drv.h
|
||||||
|
@@ -27,8 +27,6 @@ struct wd_digest_msg {
|
||||||
|
__u8 data_fmt;
|
||||||
|
/* Operation result, denoted by WD error code */
|
||||||
|
__u8 result;
|
||||||
|
- /* epoll flag */
|
||||||
|
- __u8 is_polled;
|
||||||
|
/* user identifier: struct wcrypto_cb_tag */
|
||||||
|
__u64 usr_data;
|
||||||
|
|
||||||
|
diff --git a/include/hisi_qm_udrv.h b/include/hisi_qm_udrv.h
|
||||||
|
index 707d0e3..68de837 100644
|
||||||
|
--- a/include/hisi_qm_udrv.h
|
||||||
|
+++ b/include/hisi_qm_udrv.h
|
||||||
|
@@ -47,6 +47,7 @@ struct hisi_qm_priv {
|
||||||
|
__u16 op_type;
|
||||||
|
/* index of ctxs */
|
||||||
|
__u32 idx;
|
||||||
|
+ bool epoll_en;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hisi_qm_queue_info {
|
||||||
|
@@ -71,6 +72,7 @@ struct hisi_qm_queue_info {
|
||||||
|
bool cqc_phase;
|
||||||
|
pthread_spinlock_t lock;
|
||||||
|
unsigned long region_size[UACCE_QFRT_MAX];
|
||||||
|
+ bool epoll_en;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hisi_qp {
|
||||||
|
@@ -182,8 +184,6 @@ int hisi_qm_get_free_sqe_num(handle_t h_qp);
|
||||||
|
__u32 hisi_qm_get_list_size(struct wd_datalist *start_node,
|
||||||
|
struct wd_datalist *end_node);
|
||||||
|
|
||||||
|
-void hisi_qm_enable_interrupt(handle_t ctx, __u8 enable);
|
||||||
|
-
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h
|
||||||
|
index 94336f0..30d244f 100644
|
||||||
|
--- a/include/wd_alg_common.h
|
||||||
|
+++ b/include/wd_alg_common.h
|
||||||
|
@@ -9,6 +9,7 @@
|
||||||
|
|
||||||
|
#include <asm/types.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
+#include <stdbool.h>
|
||||||
|
#include "wd.h"
|
||||||
|
#include "wd_common.h"
|
||||||
|
|
||||||
|
@@ -27,6 +28,7 @@ extern "C" {
|
||||||
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
#define MAX_STR_LEN 256
|
||||||
|
#define CTX_TYPE_INVALID 9999
|
||||||
|
+#define POLL_TIME 1000
|
||||||
|
|
||||||
|
enum wd_ctx_mode {
|
||||||
|
CTX_MODE_SYNC = 0,
|
||||||
|
@@ -74,6 +76,7 @@ struct wd_ctx_config_internal {
|
||||||
|
struct wd_ctx_internal *ctxs;
|
||||||
|
void *priv;
|
||||||
|
int pid;
|
||||||
|
+ bool epoll_en;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/include/wd_util.h b/include/wd_util.h
|
||||||
|
index 2d3c1e4..a41b4c9 100644
|
||||||
|
--- a/include/wd_util.h
|
||||||
|
+++ b/include/wd_util.h
|
||||||
|
@@ -314,6 +314,15 @@ int wd_set_ctx_attr(struct wd_ctx_attr *ctx_attr,
|
||||||
|
*/
|
||||||
|
int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx);
|
||||||
|
|
||||||
|
+/**
|
||||||
|
+ * wd_set_epoll_en() - set epoll enable flag from environment variable value.
|
||||||
|
+ * @var_name: Environment variable name string.
|
||||||
|
+ * @epoll_en: epoll enable flag.
|
||||||
|
+ *
|
||||||
|
+ * Return 0 if the value is 0 or 1, otherwise return -WD_EINVAL.
|
||||||
|
+ */
|
||||||
|
+int wd_set_epoll_en(const char *var_name, bool *epoll_en);
|
||||||
|
+
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
diff --git a/wd_aead.c b/wd_aead.c
|
||||||
|
index 74047b5..2e006c3 100644
|
||||||
|
--- a/wd_aead.c
|
||||||
|
+++ b/wd_aead.c
|
||||||
|
@@ -21,8 +21,6 @@
|
||||||
|
#define WD_POOL_MAX_ENTRIES 1024
|
||||||
|
#define MAX_RETRY_COUNTS 200000000
|
||||||
|
|
||||||
|
-#define POLL_SIZE 70000
|
||||||
|
-#define POLL_TIME 1000
|
||||||
|
|
||||||
|
static int g_aead_mac_len[WD_DIGEST_TYPE_MAX] = {
|
||||||
|
WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN,
|
||||||
|
@@ -414,17 +412,18 @@ int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
+ ret = wd_set_epoll_en("WD_AEAD_EPOLL_EN",
|
||||||
|
+ &wd_aead_setting.config.epoll_en);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
ret = wd_init_ctx_config(&wd_aead_setting.config, config);
|
||||||
|
- if (ret) {
|
||||||
|
- WD_ERR("failed to set config, ret = %d\n", ret);
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
ret = wd_init_sched(&wd_aead_setting.sched, sched);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set sched, ret = %d\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
- }
|
||||||
|
|
||||||
|
/* set driver */
|
||||||
|
#ifdef WD_STATIC_DRV
|
||||||
|
@@ -435,10 +434,8 @@ int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
ret = wd_init_async_request_pool(&wd_aead_setting.pool,
|
||||||
|
config->ctx_num, WD_POOL_MAX_ENTRIES,
|
||||||
|
sizeof(struct wd_aead_msg));
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to init aead aysnc request pool.\n");
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out_sched;
|
||||||
|
- }
|
||||||
|
|
||||||
|
/* init ctx related resources in specific driver */
|
||||||
|
priv = calloc(1, wd_aead_setting.driver->drv_ctx_size);
|
||||||
|
@@ -525,7 +522,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx,
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
- if (msg->is_polled) {
|
||||||
|
+ if (wd_aead_setting.config.epoll_en) {
|
||||||
|
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
|
||||||
|
if (unlikely(ret < 0))
|
||||||
|
WD_ERR("wd aead ctx wait timeout(%d)!\n", ret);
|
||||||
|
@@ -563,7 +560,6 @@ int wd_do_aead_sync(handle_t h_sess, struct wd_aead_req *req)
|
||||||
|
|
||||||
|
memset(&msg, 0, sizeof(struct wd_aead_msg));
|
||||||
|
fill_request_msg(&msg, req, sess);
|
||||||
|
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
|
||||||
|
req->state = 0;
|
||||||
|
|
||||||
|
idx = wd_aead_setting.sched.pick_next_ctx(
|
||||||
|
@@ -616,7 +612,6 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
|
||||||
|
|
||||||
|
fill_request_msg(msg, req, sess);
|
||||||
|
msg->tag = msg_id;
|
||||||
|
- msg->is_polled = 0;
|
||||||
|
|
||||||
|
ret = wd_aead_setting.driver->aead_send(ctx->ctx, msg);
|
||||||
|
if (unlikely(ret < 0)) {
|
||||||
|
diff --git a/wd_cipher.c b/wd_cipher.c
|
||||||
|
index 563eece..6d286f9 100644
|
||||||
|
--- a/wd_cipher.c
|
||||||
|
+++ b/wd_cipher.c
|
||||||
|
@@ -22,8 +22,6 @@
|
||||||
|
#define DES_WEAK_KEY_NUM 16
|
||||||
|
#define MAX_RETRY_COUNTS 200000000
|
||||||
|
|
||||||
|
-#define POLL_SIZE 100000
|
||||||
|
-#define POLL_TIME 1000
|
||||||
|
|
||||||
|
static const unsigned char des_weak_keys[DES_WEAK_KEY_NUM][DES_KEY_SIZE] = {
|
||||||
|
/* weak keys */
|
||||||
|
@@ -255,17 +253,18 @@ int wd_cipher_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
+ ret = wd_set_epoll_en("WD_CIPHER_EPOLL_EN",
|
||||||
|
+ &wd_cipher_setting.config.epoll_en);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
ret = wd_init_ctx_config(&wd_cipher_setting.config, config);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set config, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
ret = wd_init_sched(&wd_cipher_setting.sched, sched);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set sched, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
- }
|
||||||
|
|
||||||
|
#ifdef WD_STATIC_DRV
|
||||||
|
/* set driver */
|
||||||
|
@@ -276,10 +275,8 @@ int wd_cipher_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
ret = wd_init_async_request_pool(&wd_cipher_setting.pool,
|
||||||
|
config->ctx_num, WD_POOL_MAX_ENTRIES,
|
||||||
|
sizeof(struct wd_cipher_msg));
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out_sched;
|
||||||
|
- }
|
||||||
|
|
||||||
|
/* init ctx related resources in specific driver */
|
||||||
|
priv = calloc(1, wd_cipher_setting.driver->drv_ctx_size);
|
||||||
|
@@ -436,7 +433,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx,
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
- if (msg->is_polled) {
|
||||||
|
+ if (wd_cipher_setting.config.epoll_en) {
|
||||||
|
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
|
||||||
|
if (unlikely(ret < 0))
|
||||||
|
WD_ERR("wd cipher ctx wait timeout(%d)!\n", ret);
|
||||||
|
@@ -476,7 +473,6 @@ int wd_do_cipher_sync(handle_t h_sess, struct wd_cipher_req *req)
|
||||||
|
|
||||||
|
memset(&msg, 0, sizeof(struct wd_cipher_msg));
|
||||||
|
fill_request_msg(&msg, req, sess);
|
||||||
|
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
|
||||||
|
req->state = 0;
|
||||||
|
|
||||||
|
idx = wd_cipher_setting.sched.pick_next_ctx(
|
||||||
|
@@ -526,7 +522,6 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req)
|
||||||
|
|
||||||
|
fill_request_msg(msg, req, sess);
|
||||||
|
msg->tag = msg_id;
|
||||||
|
- msg->is_polled = 0;
|
||||||
|
|
||||||
|
ret = wd_cipher_setting.driver->cipher_send(ctx->ctx, msg);
|
||||||
|
if (unlikely(ret < 0)) {
|
||||||
|
diff --git a/wd_comp.c b/wd_comp.c
|
||||||
|
index 9a71dfc..3bd7f43 100644
|
||||||
|
--- a/wd_comp.c
|
||||||
|
+++ b/wd_comp.c
|
||||||
|
@@ -22,8 +22,6 @@
|
||||||
|
#define HW_CTX_SIZE (64 * 1024)
|
||||||
|
#define STREAM_CHUNK (128 * 1024)
|
||||||
|
|
||||||
|
-#define POLL_SIZE 250000
|
||||||
|
-#define POLL_TIME 1000
|
||||||
|
|
||||||
|
#define swap_byte(x) \
|
||||||
|
((((x) & 0x000000ff) << 24) | \
|
||||||
|
@@ -97,16 +95,18 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ ret = wd_set_epoll_en("WD_COMP_EPOLL_EN",
|
||||||
|
+ &wd_comp_setting.config.epoll_en);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
ret = wd_init_ctx_config(&wd_comp_setting.config, config);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set config, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
+
|
||||||
|
ret = wd_init_sched(&wd_comp_setting.sched, sched);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set sched, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
- }
|
||||||
|
/*
|
||||||
|
* Fix me: ctx could be passed into wd_comp_set_static_drv to help to
|
||||||
|
* choose static compiled vendor driver. For dynamic vendor driver,
|
||||||
|
@@ -125,10 +125,9 @@ int wd_comp_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
ret = wd_init_async_request_pool(&wd_comp_setting.pool,
|
||||||
|
config->ctx_num, WD_POOL_MAX_ENTRIES,
|
||||||
|
sizeof(struct wd_comp_msg));
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out_sched;
|
||||||
|
- }
|
||||||
|
+
|
||||||
|
/* init ctx related resources in specific driver */
|
||||||
|
priv = calloc(1, wd_comp_setting.driver->drv_ctx_size);
|
||||||
|
if (!priv) {
|
||||||
|
@@ -429,7 +428,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
- if (msg->is_polled) {
|
||||||
|
+ if (config->epoll_en) {
|
||||||
|
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
|
||||||
|
if (unlikely(ret < 0))
|
||||||
|
WD_ERR("wd ctx wait timeout, ret = %d!\n", ret);
|
||||||
|
@@ -472,7 +471,6 @@ int wd_do_comp_sync(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
|
||||||
|
fill_comp_msg(sess, &msg, req);
|
||||||
|
msg.ctx_buf = sess->ctx_buf;
|
||||||
|
- msg.is_polled = (req->src_len >= POLL_SIZE);
|
||||||
|
msg.stream_mode = WD_COMP_STATELESS;
|
||||||
|
|
||||||
|
ret = wd_comp_sync_job(sess, req, &msg);
|
||||||
|
@@ -643,7 +641,6 @@ int wd_do_comp_strm(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
/* fill true flag */
|
||||||
|
msg.req.last = req->last;
|
||||||
|
msg.stream_mode = WD_COMP_STATEFUL;
|
||||||
|
- msg.is_polled = (req->src_len >= POLL_SIZE);
|
||||||
|
|
||||||
|
src_len = req->src_len;
|
||||||
|
|
||||||
|
@@ -701,7 +698,6 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
|
||||||
|
fill_comp_msg(sess, msg, req);
|
||||||
|
msg->tag = tag;
|
||||||
|
msg->stream_mode = WD_COMP_STATELESS;
|
||||||
|
- msg->is_polled = 0;
|
||||||
|
|
||||||
|
pthread_spin_lock(&ctx->lock);
|
||||||
|
|
||||||
|
diff --git a/wd_dh.c b/wd_dh.c
|
||||||
|
index c0d3e00..aaea812 100644
|
||||||
|
--- a/wd_dh.c
|
||||||
|
+++ b/wd_dh.c
|
||||||
|
@@ -101,17 +101,18 @@ int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
if (param_check(config, sched))
|
||||||
|
return -WD_EINVAL;
|
||||||
|
|
||||||
|
+ ret = wd_set_epoll_en("WD_DH_EPOLL_EN",
|
||||||
|
+ &wd_dh_setting.config.epoll_en);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
ret = wd_init_ctx_config(&wd_dh_setting.config, config);
|
||||||
|
- if (ret) {
|
||||||
|
- WD_ERR("failed to initialize ctx config, ret = %d!\n", ret);
|
||||||
|
+ if (ret)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
ret = wd_init_sched(&wd_dh_setting.sched, sched);
|
||||||
|
- if (ret) {
|
||||||
|
- WD_ERR("failed to initialize sched, ret = %d!\n", ret);
|
||||||
|
+ if (ret)
|
||||||
|
goto out;
|
||||||
|
- }
|
||||||
|
|
||||||
|
#ifdef WD_STATIC_DRV
|
||||||
|
wd_dh_set_static_drv();
|
||||||
|
@@ -121,10 +122,8 @@ int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
ret = wd_init_async_request_pool(&wd_dh_setting.pool,
|
||||||
|
config->ctx_num, WD_POOL_MAX_ENTRIES,
|
||||||
|
sizeof(struct wd_dh_msg));
|
||||||
|
- if (ret) {
|
||||||
|
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
|
||||||
|
+ if (ret)
|
||||||
|
goto out_sched;
|
||||||
|
- }
|
||||||
|
|
||||||
|
/* initialize ctx related resources in specific driver */
|
||||||
|
priv = calloc(1, wd_dh_setting.driver->drv_ctx_size);
|
||||||
|
@@ -236,6 +235,12 @@ static int dh_recv_sync(handle_t ctx, struct wd_dh_msg *msg)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
do {
|
||||||
|
+ if (wd_dh_setting.config.epoll_en) {
|
||||||
|
+ ret = wd_ctx_wait(ctx, POLL_TIME);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
ret = wd_dh_setting.driver->recv(ctx, msg);
|
||||||
|
if (ret == -WD_EAGAIN) {
|
||||||
|
if (rx_cnt++ >= DH_RECV_MAX_CNT) {
|
||||||
|
diff --git a/wd_digest.c b/wd_digest.c
|
||||||
|
index 0ddc074..7afbd9c 100644
|
||||||
|
--- a/wd_digest.c
|
||||||
|
+++ b/wd_digest.c
|
||||||
|
@@ -19,8 +19,6 @@
|
||||||
|
#define DES_WEAK_KEY_NUM 4
|
||||||
|
#define MAX_RETRY_COUNTS 200000000
|
||||||
|
|
||||||
|
-#define POLL_SIZE 100000
|
||||||
|
-#define POLL_TIME 1000
|
||||||
|
|
||||||
|
static int g_digest_mac_len[WD_DIGEST_TYPE_MAX] = {
|
||||||
|
WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN,
|
||||||
|
@@ -28,6 +26,7 @@ static int g_digest_mac_len[WD_DIGEST_TYPE_MAX] = {
|
||||||
|
WD_DIGEST_SHA384_LEN, WD_DIGEST_SHA512_LEN,
|
||||||
|
WD_DIGEST_SHA512_224_LEN, WD_DIGEST_SHA512_256_LEN
|
||||||
|
};
|
||||||
|
+
|
||||||
|
struct wd_digest_setting {
|
||||||
|
struct wd_ctx_config_internal config;
|
||||||
|
struct wd_sched sched;
|
||||||
|
@@ -175,17 +174,18 @@ int wd_digest_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
+ ret = wd_set_epoll_en("WD_DIGEST_EPOLL_EN",
|
||||||
|
+ &wd_digest_setting.config.epoll_en);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
ret = wd_init_ctx_config(&wd_digest_setting.config, config);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set config, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
ret = wd_init_sched(&wd_digest_setting.sched, sched);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set sched, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
- }
|
||||||
|
|
||||||
|
/* set driver */
|
||||||
|
#ifdef WD_STATIC_DRV
|
||||||
|
@@ -196,10 +196,8 @@ int wd_digest_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
ret = wd_init_async_request_pool(&wd_digest_setting.pool,
|
||||||
|
config->ctx_num, WD_POOL_MAX_ENTRIES,
|
||||||
|
sizeof(struct wd_digest_msg));
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to init req pool, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out_sched;
|
||||||
|
- }
|
||||||
|
|
||||||
|
/* init ctx related resources in specific driver */
|
||||||
|
priv = calloc(1, wd_digest_setting.driver->drv_ctx_size);
|
||||||
|
@@ -322,7 +320,7 @@ static int send_recv_sync(struct wd_ctx_internal *ctx, struct wd_digest_sess *ds
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
- if (msg->is_polled) {
|
||||||
|
+ if (wd_digest_setting.config.epoll_en) {
|
||||||
|
ret = wd_ctx_wait(ctx->ctx, POLL_TIME);
|
||||||
|
if (unlikely(ret < 0))
|
||||||
|
WD_ERR("wd digest ctx wait timeout(%d)!\n", ret);
|
||||||
|
@@ -367,7 +365,6 @@ int wd_do_digest_sync(handle_t h_sess, struct wd_digest_req *req)
|
||||||
|
|
||||||
|
memset(&msg, 0, sizeof(struct wd_digest_msg));
|
||||||
|
fill_request_msg(&msg, req, dsess);
|
||||||
|
- msg.is_polled = (req->in_bytes >= POLL_SIZE);
|
||||||
|
req->state = 0;
|
||||||
|
|
||||||
|
idx = wd_digest_setting.sched.pick_next_ctx(
|
||||||
|
@@ -420,7 +417,6 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
|
||||||
|
|
||||||
|
fill_request_msg(msg, req, dsess);
|
||||||
|
msg->tag = msg_id;
|
||||||
|
- msg->is_polled = 0;
|
||||||
|
|
||||||
|
ret = wd_digest_setting.driver->digest_send(ctx->ctx, msg);
|
||||||
|
if (unlikely(ret < 0)) {
|
||||||
|
diff --git a/wd_ecc.c b/wd_ecc.c
|
||||||
|
index af62b9a..a6c2209 100644
|
||||||
|
--- a/wd_ecc.c
|
||||||
|
+++ b/wd_ecc.c
|
||||||
|
@@ -155,17 +155,18 @@ int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
if (init_param_check(config, sched))
|
||||||
|
return -WD_EINVAL;
|
||||||
|
|
||||||
|
+ ret = wd_set_epoll_en("WD_ECC_EPOLL_EN",
|
||||||
|
+ &wd_ecc_setting.config.epoll_en);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
ret = wd_init_ctx_config(&wd_ecc_setting.config, config);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set config, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
ret = wd_init_sched(&wd_ecc_setting.sched, sched);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set sched, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
- }
|
||||||
|
|
||||||
|
#ifdef WD_STATIC_DRV
|
||||||
|
wd_ecc_set_static_drv();
|
||||||
|
@@ -175,10 +176,8 @@ int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
ret = wd_init_async_request_pool(&wd_ecc_setting.pool,
|
||||||
|
config->ctx_num, WD_POOL_MAX_ENTRIES,
|
||||||
|
sizeof(struct wd_ecc_msg));
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out_sched;
|
||||||
|
- }
|
||||||
|
|
||||||
|
/* initialize ctx related resources in specific driver */
|
||||||
|
priv = calloc(1, wd_ecc_setting.driver->drv_ctx_size);
|
||||||
|
@@ -1435,6 +1434,12 @@ static int ecc_recv_sync(handle_t ctx, struct wd_ecc_msg *msg)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
do {
|
||||||
|
+ if (wd_ecc_setting.config.epoll_en) {
|
||||||
|
+ ret = wd_ctx_wait(ctx, POLL_TIME);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
ret = wd_ecc_setting.driver->recv(ctx, msg);
|
||||||
|
if (ret == -WD_EAGAIN) {
|
||||||
|
if (rx_cnt++ >= ECC_RECV_MAX_CNT) {
|
||||||
|
diff --git a/wd_rsa.c b/wd_rsa.c
|
||||||
|
index 8371475..ca39cff 100644
|
||||||
|
--- a/wd_rsa.c
|
||||||
|
+++ b/wd_rsa.c
|
||||||
|
@@ -141,17 +141,18 @@ int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
if (param_check(config, sched))
|
||||||
|
return -WD_EINVAL;
|
||||||
|
|
||||||
|
+ ret = wd_set_epoll_en("WD_RSA_EPOLL_EN",
|
||||||
|
+ &wd_rsa_setting.config.epoll_en);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
ret = wd_init_ctx_config(&wd_rsa_setting.config, config);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set config, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
- }
|
||||||
|
|
||||||
|
ret = wd_init_sched(&wd_rsa_setting.sched, sched);
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to set sched, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
- }
|
||||||
|
|
||||||
|
#ifdef WD_STATIC_DRV
|
||||||
|
wd_rsa_set_static_drv();
|
||||||
|
@@ -161,10 +162,8 @@ int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched)
|
||||||
|
ret = wd_init_async_request_pool(&wd_rsa_setting.pool,
|
||||||
|
config->ctx_num, WD_POOL_MAX_ENTRIES,
|
||||||
|
sizeof(struct wd_rsa_msg));
|
||||||
|
- if (ret < 0) {
|
||||||
|
- WD_ERR("failed to initialize async req pool, ret = %d!\n", ret);
|
||||||
|
+ if (ret < 0)
|
||||||
|
goto out_sched;
|
||||||
|
- }
|
||||||
|
|
||||||
|
/* initialize ctx related resources in specific driver */
|
||||||
|
priv = calloc(1, wd_rsa_setting.driver->drv_ctx_size);
|
||||||
|
@@ -296,6 +295,12 @@ static int rsa_recv_sync(handle_t ctx, struct wd_rsa_msg *msg)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
do {
|
||||||
|
+ if (wd_rsa_setting.config.epoll_en) {
|
||||||
|
+ ret = wd_ctx_wait(ctx, POLL_TIME);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ WD_ERR("wd ctx wait timeout(%d)!\n", ret);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
ret = wd_rsa_setting.driver->recv(ctx, msg);
|
||||||
|
if (ret == -WD_EAGAIN) {
|
||||||
|
if (rx_cnt++ >= RSA_RECV_MAX_CNT) {
|
||||||
|
diff --git a/wd_sched.c b/wd_sched.c
|
||||||
|
index 9b1998c..dfd390b 100644
|
||||||
|
--- a/wd_sched.c
|
||||||
|
+++ b/wd_sched.c
|
||||||
|
@@ -213,7 +213,7 @@ static int session_sched_poll_policy(handle_t sched_ctx,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->numa_num > NUMA_NUM_NODES) {
|
||||||
|
- WD_ERR("invalid: ctx's numa number is %d!\n", ctx->numa_num);
|
||||||
|
+ WD_ERR("invalid: ctx's numa number is %u!\n", ctx->numa_num);
|
||||||
|
return -WD_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/wd_util.c b/wd_util.c
|
||||||
|
index 03316b6..57dafa7 100644
|
||||||
|
--- a/wd_util.c
|
||||||
|
+++ b/wd_util.c
|
||||||
|
@@ -85,8 +85,10 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
|
||||||
|
}
|
||||||
|
|
||||||
|
ctxs = calloc(1, cfg->ctx_num * sizeof(struct wd_ctx_internal));
|
||||||
|
- if (!ctxs)
|
||||||
|
+ if (!ctxs) {
|
||||||
|
+ WD_ERR("failed to alloc memory for internal ctxs!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
for (i = 0; i < cfg->ctx_num; i++) {
|
||||||
|
if (!cfg->ctxs[i].ctx) {
|
||||||
|
@@ -115,8 +117,10 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
|
||||||
|
int wd_init_sched(struct wd_sched *in, struct wd_sched *from)
|
||||||
|
{
|
||||||
|
if (!from->name || !from->sched_init ||
|
||||||
|
- !from->pick_next_ctx || !from->poll_policy)
|
||||||
|
+ !from->pick_next_ctx || !from->poll_policy) {
|
||||||
|
+ WD_ERR("invalid: member of wd_sched is NULL!\n");
|
||||||
|
return -WD_EINVAL;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
in->h_sched_ctx = from->h_sched_ctx;
|
||||||
|
in->name = strdup(from->name);
|
||||||
|
@@ -170,13 +174,16 @@ void wd_memset_zero(void *data, __u32 size)
|
||||||
|
static int init_msg_pool(struct msg_pool *pool, __u32 msg_num, __u32 msg_size)
|
||||||
|
{
|
||||||
|
pool->msgs = calloc(1, msg_num * msg_size);
|
||||||
|
- if (!pool->msgs)
|
||||||
|
+ if (!pool->msgs) {
|
||||||
|
+ WD_ERR("failed to alloc memory for msgs arrary of msg pool!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
pool->used = calloc(1, msg_num * sizeof(int));
|
||||||
|
if (!pool->used) {
|
||||||
|
free(pool->msgs);
|
||||||
|
pool->msgs = NULL;
|
||||||
|
+ WD_ERR("failed to alloc memory for used arrary of msg pool!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -204,8 +211,10 @@ int wd_init_async_request_pool(struct wd_async_msg_pool *pool, __u32 pool_num,
|
||||||
|
pool->pool_num = pool_num;
|
||||||
|
|
||||||
|
pool->pools = calloc(1, pool->pool_num * sizeof(struct msg_pool));
|
||||||
|
- if (!pool->pools)
|
||||||
|
+ if (!pool->pools) {
|
||||||
|
+ WD_ERR("failed to alloc memory for async msg pools!\n");
|
||||||
|
return -WD_ENOMEM;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
for (i = 0; i < pool->pool_num; i++) {
|
||||||
|
ret = init_msg_pool(&pool->pools[i], msg_num, msg_size);
|
||||||
|
@@ -510,27 +519,33 @@ static int is_number(const char *str)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-/* 1 enable, 0 disable, others error */
|
||||||
|
-int wd_parse_async_poll_en(struct wd_env_config *config, const char *s)
|
||||||
|
+static int str_to_bool(const char *s, bool *target)
|
||||||
|
{
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
- if (!is_number(s)) {
|
||||||
|
- WD_ERR("invalid: async poll en flag is %s!\n", s);
|
||||||
|
+ if (!is_number(s))
|
||||||
|
return -WD_EINVAL;
|
||||||
|
- }
|
||||||
|
|
||||||
|
tmp = strtol(s, NULL, 10);
|
||||||
|
- if (tmp != 0 && tmp != 1) {
|
||||||
|
- WD_ERR("invalid: async poll en flag is not 0 or 1!\n");
|
||||||
|
+ if (tmp != 0 && tmp != 1)
|
||||||
|
return -WD_EINVAL;
|
||||||
|
- }
|
||||||
|
|
||||||
|
- config->enable_internal_poll = tmp;
|
||||||
|
+ *target = tmp;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int wd_parse_async_poll_en(struct wd_env_config *config, const char *s)
|
||||||
|
+{
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ ret = str_to_bool(s, &config->enable_internal_poll);
|
||||||
|
+ if (ret)
|
||||||
|
+ WD_ERR("failed to parse async poll enable flag(%s)!\n", s);
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int parse_num_on_numa(const char *s, int *num, int *node)
|
||||||
|
{
|
||||||
|
char *sep, *start, *left;
|
||||||
|
@@ -1589,3 +1604,26 @@ int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx)
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+int wd_set_epoll_en(const char *var_name, bool *epoll_en)
|
||||||
|
+{
|
||||||
|
+ const char *s;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ s = secure_getenv(var_name);
|
||||||
|
+ if (!s || !strlen(s)) {
|
||||||
|
+ *epoll_en = 0;
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = str_to_bool(s, epoll_en);
|
||||||
|
+ if (ret) {
|
||||||
|
+ WD_ERR("failed to parse %s!\n", var_name);
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (*epoll_en)
|
||||||
|
+ WD_ERR("epoll wait is enabled!\n");
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
30
0099-test-enable-epoll-in-sanity-scripts.patch
Normal file
30
0099-test-enable-epoll-in-sanity-scripts.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From 1b4b3526112a4207f9ea84620fe0e91714f83729 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
Date: Wed, 16 Mar 2022 17:52:22 +0800
|
||||||
|
Subject: [PATCH 108/109] test: enable epoll in sanity scripts
|
||||||
|
|
||||||
|
epoll is enabled by WD_COMP_EPOLL_EN,
|
||||||
|
so set it to 1 to test the function.
|
||||||
|
|
||||||
|
Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
|
||||||
|
---
|
||||||
|
test/sanity_test.sh | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/test/sanity_test.sh b/test/sanity_test.sh
|
||||||
|
index 688485c..207eee5 100755
|
||||||
|
--- a/test/sanity_test.sh
|
||||||
|
+++ b/test/sanity_test.sh
|
||||||
|
@@ -362,7 +362,8 @@ run_zip_test_v2()
|
||||||
|
dd if=/var/log/syslog of=/tmp/syslog bs=1M count=16 >& /dev/null
|
||||||
|
sw_dfl_hw_ifl /tmp/syslog
|
||||||
|
hw_dfl_sw_ifl /tmp/syslog
|
||||||
|
- hw_dfl_hw_ifl /tmp/syslog
|
||||||
|
+ WD_COMP_EPOLL_EN=1 hw_dfl_hw_ifl /tmp/syslog
|
||||||
|
+ WD_COMP_EPOLL_EN=0 hw_dfl_hw_ifl /tmp/syslog
|
||||||
|
# test without environment variables
|
||||||
|
#zip_sva_perf -b 8192 -s 81920 -l 1000 --self
|
||||||
|
# test with environment variables
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
Name: libwd
|
Name: libwd
|
||||||
Summary: User Space Accelerator Development Kit
|
Summary: User Space Accelerator Development Kit
|
||||||
Version: 2.3.21
|
Version: 2.3.21
|
||||||
Release: 4
|
Release: 5
|
||||||
License: Apache-2.0
|
License: Apache-2.0
|
||||||
Source: %{name}-%{version}.tar.gz
|
Source: %{name}-%{version}.tar.gz
|
||||||
Vendor: Huawei Corporation
|
Vendor: Huawei Corporation
|
||||||
@ -83,6 +83,36 @@ Patch0066: 0066-uadk-tools-modify-uadk-benchmark-clean-code.patch
|
|||||||
Patch0067: 0067-uadk-v1-fix-for-cookie-initialization.patch
|
Patch0067: 0067-uadk-v1-fix-for-cookie-initialization.patch
|
||||||
Patch0068: 0068-uadk-update-file-permission-on-cleanup.patch
|
Patch0068: 0068-uadk-update-file-permission-on-cleanup.patch
|
||||||
Patch0069: 0069-uadk_tool-fix-build-warning-of-sec_wd_benchmark.patch
|
Patch0069: 0069-uadk_tool-fix-build-warning-of-sec_wd_benchmark.patch
|
||||||
|
Patch0070: 0070-rsa-fix-interface-name-and-log-msg.patch
|
||||||
|
Patch0071: 0071-uadk-modify-param-verification.patch
|
||||||
|
Patch0072: 0072-uadk-v1-cleanup-ret-value.patch
|
||||||
|
Patch0073: 0073-uadk-wd-fixup-about-checking-device.patch
|
||||||
|
Patch0074: 0074-uadk-cleanup-hpre-code.patch
|
||||||
|
Patch0075: 0075-uadk-v1-fix-pool-cstatus-memset-problem.patch
|
||||||
|
Patch0076: 0076-uadk-bugfix-segment-fault-when-uninitializing.patch
|
||||||
|
Patch0077: 0077-drv-sec-support-sm4-ecb-alg-by-new-fs.patch
|
||||||
|
Patch0078: 0078-digest-simplify-the-process-of-represent-BD-state.patch
|
||||||
|
Patch0079: 0079-uadk-qm_udrv-Modify-goto-err_out.patch
|
||||||
|
Patch0080: 0080-uadk-unify-wd-print-format.patch
|
||||||
|
Patch0081: 0081-uadk-v1-fix-wd_bmm-pool_init.patch
|
||||||
|
Patch0082: 0082-uadk-v1-fix-wd-create-ctx-memory-leak.patch
|
||||||
|
Patch0083: 0083-uadk-mempool-fix-redundant-assignment.patch
|
||||||
|
Patch0084: 0084-uadk-v1-fix-del-ctx.patch
|
||||||
|
Patch0085: 0085-uadk-v1-clean-code-for-wd.patch
|
||||||
|
Patch0086: 0086-uadk-v1-fix-drv_reserve_mem-memory-leak.patch
|
||||||
|
Patch0087: 0087-uadk-cipher-fix-wd_cipher_check_params.patch
|
||||||
|
Patch0088: 0088-sec-unify-print-format.patch
|
||||||
|
Patch0089: 0089-drv-hpre-unify-print-format.patch
|
||||||
|
Patch0090: 0090-rsa-dh-ecc-unify-print-format.patch
|
||||||
|
Patch0091: 0091-drv-hpre-free-memory-when-BD-sends-failed.patch
|
||||||
|
Patch0092: 0092-v1-hpre-add-unlikely-for-branch-prefetch.patch
|
||||||
|
Patch0093: 0093-comp-unify-print-format.patch
|
||||||
|
Patch0094: 0094-drv-comp-unify-print-format.patch
|
||||||
|
Patch0095: 0095-comp-add-unlikely-for-branch-prefetch.patch
|
||||||
|
Patch0096: 0096-drv-comp-add-unlikely-for-branch-prefetch.patch
|
||||||
|
Patch0097: 0097-hisi_hpre-modify-the-return-value-of-function.patch
|
||||||
|
Patch0098: 0098-uadk-parse-epoll-flag-from-environment-variable.patch
|
||||||
|
Patch0099: 0099-test-enable-epoll-in-sanity-scripts.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This package contains the User Space Accelerator Library
|
This package contains the User Space Accelerator Library
|
||||||
@ -240,6 +270,9 @@ fi
|
|||||||
/sbin/ldconfig
|
/sbin/ldconfig
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Mar 21 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-5
|
||||||
|
- libwd: backport the patch of uadk from 2.3.28 to 2.3.31
|
||||||
|
|
||||||
* Tue Mar 1 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-4
|
* Tue Mar 1 2022 Yang Shen <shenyang39@huawei.com> 2.3.21-4
|
||||||
- libwd: backport the patch of uadk from 2.3.27 to 2.3.28
|
- libwd: backport the patch of uadk from 2.3.27 to 2.3.28
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user