From: Weili Qian <qianweili(a)huawei.com>
The internal asynchronous polling interface is not
used in any scenario, remove it.
Upstream: YES
Feature or Bugfix:Bugfix
AR:AR20230706877890
DTS:DTS2026042322013
Signed-off-by: Weili Qian <qianweili(a)huawei.com>
---
include/wd_aead.h | 3 +-
include/wd_cipher.h | 3 +-
include/wd_comp.h | 3 +-
include/wd_digest.h | 3 +-
include/wd_ecc.h | 3 +-
include/wd_rsa.h | 3 +-
include/wd_util.h | 37 ----
wd_aead.c | 24 +--
wd_cipher.c | 24 +--
wd_comp.c | 28 +--
wd_dh.c | 24 +--
wd_digest.c | 24 +--
wd_ecc.c | 24 +--
wd_rsa.c | 24 +--
wd_util.c | 418 +-------------------------------------------
15 files changed, 70 insertions(+), 575 deletions(-)
diff --git a/include/wd_aead.h b/include/wd_aead.h
index 4b5095f..3585c86 100644
--- a/include/wd_aead.h
+++ b/include/wd_aead.h
@@ -254,7 +254,8 @@ void wd_aead_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
- * @is_enable return enable inner poll flag.
+ * @is_enable: return enable inner poll flag, inner poll is not
+ * supported, and is_enable will always be 0.
*
* If the current algorithm library does not require the type parameter,
* the type parameter is invalid. The function returns 0 to indicate that
diff --git a/include/wd_cipher.h b/include/wd_cipher.h
index a6f8be1..383d315 100644
--- a/include/wd_cipher.h
+++ b/include/wd_cipher.h
@@ -218,7 +218,8 @@ void wd_cipher_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
- * @is_enable return enable inner poll flag.
+ * @is_enable: return enable inner poll flag, inner poll is not
+ * supported, and is_enable will always be 0.
*/
int wd_cipher_get_env_param(__u32 node, __u32 type, __u32 mode,
__u32 *num, __u8 *is_enable);
diff --git a/include/wd_comp.h b/include/wd_comp.h
index 8579f93..890799a 100644
--- a/include/wd_comp.h
+++ b/include/wd_comp.h
@@ -252,7 +252,8 @@ void wd_comp_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
- * @is_enable return enable inner poll flag.
+ * @is_enable: return enable inner poll flag, inner poll is not
+ * supported, and is_enable will always be 0.
*
* If the current algorithm library does not require the type parameter,
* the type parameter is invalid. The function returns 0 to indicate that
diff --git a/include/wd_digest.h b/include/wd_digest.h
index 42a95db..410c7f9 100644
--- a/include/wd_digest.h
+++ b/include/wd_digest.h
@@ -278,7 +278,8 @@ void wd_digest_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
- * @is_enable return enable inner poll flag.
+ * @is_enable: return enable inner poll flag, inner poll is not
+ * supported, and is_enable will always be 0.
*/
int wd_digest_get_env_param(__u32 node, __u32 type, __u32 mode,
__u32 *num, __u8 *is_enable);
diff --git a/include/wd_ecc.h b/include/wd_ecc.h
index 18c1c0d..d868951 100644
--- a/include/wd_ecc.h
+++ b/include/wd_ecc.h
@@ -548,7 +548,8 @@ void wd_ecc_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
- * @is_enable return enable inner poll flag.
+ * @is_enable: return enable inner poll flag, inner poll is not
+ * supported, and is_enable will always be 0.
*/
int wd_ecc_get_env_param(__u32 node, __u32 type, __u32 mode,
__u32 *num, __u8 *is_enable);
diff --git a/include/wd_rsa.h b/include/wd_rsa.h
index 9c91432..b0ead0a 100644
--- a/include/wd_rsa.h
+++ b/include/wd_rsa.h
@@ -239,7 +239,8 @@ void wd_rsa_ctx_num_uninit(void);
* @type: operation type.
* @mode: 0: sync mode, 1: async mode
* @num: return ctx num.
- * @is_enable return enable inner poll flag.
+ * @is_enable: return enable inner poll flag, inner poll is not
+ * supported, and is_enable will always be 0.
*/
int wd_rsa_get_env_param(__u32 node, __u32 type, __u32 mode,
__u32 *num, __u8 *is_enable);
diff --git a/include/wd_util.h b/include/wd_util.h
index 42270d9..c24c554 100644
--- a/include/wd_util.h
+++ b/include/wd_util.h
@@ -78,16 +78,10 @@ struct wd_env_config_per_numa {
/* Resource begin */
struct uacce_dev *dev;
int dev_num;
- /* This can be made statically currently */
- unsigned long async_poll_num;
- void *async_task_queue_array;
};
struct wd_env_config {
struct wd_env_config_per_numa *config_per_numa;
- /* Let's make it as a gobal config, not per numa */
- bool enable_internal_poll;
-
/* resource config */
struct wd_sched *sched;
bool internal_sched;
@@ -273,28 +267,6 @@ int wd_check_datalist(struct wd_datalist *head, __u64 size);
*/
int wd_parse_ctx_num(struct wd_env_config *config, const char *s);
-/*
- * wd_parse_async_poll_en() - Parse async polling thread related environment
- * variable and store it.
- * @config: Pointer of wd_env_config which is used to store environment
- * variable information.
- * @s: Related environment variable string.
- *
- * More information, please see docs/wd_environment_variable.
- */
-int wd_parse_async_poll_en(struct wd_env_config *config, const char *s);
-
-/*
- * wd_parse_async_poll_num() - Parse async polling thread related environment
- * variable and store it.
- * @config: Pointer of wd_env_config which is used to store environment
- * variable information.
- * @s: Related environment variable string.
- *
- * More information, please see docs/wd_environment_variable.
- */
-int wd_parse_async_poll_num(struct wd_env_config *config, const char *s);
-
/*
* wd_alg_env_init() - Init wd algorithm environment variable configurations.
* This is a help function which can be used by specific
@@ -323,15 +295,6 @@ int wd_alg_env_init(struct wd_env_config *env_config,
void wd_alg_env_uninit(struct wd_env_config *env_config,
const struct wd_alg_ops *ops);
-/*
- * wd_add_task_to_async_queue() - Add an async request to its related async
- * task queue.
- * @config: Pointer of wd_env_config which is used to store environment
- * variable information.
- * @idx: Index of ctx in config.
- */
-int wd_add_task_to_async_queue(struct wd_env_config *config, __u32 idx);
-
/*
* dump_env_info() - dump wd algorithm ctx info.
* @config: Pointer of wd_env_config which is used to store environment
diff --git a/wd_aead.c b/wd_aead.c
index 748bf95..3e993a1 100644
--- a/wd_aead.c
+++ b/wd_aead.c
@@ -957,9 +957,6 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
}
wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx);
- ret = wd_add_task_to_async_queue(&wd_aead_env_config, idx);
- if (ret)
- goto fail_with_msg;
return 0;
@@ -1039,15 +1036,10 @@ int wd_aead_poll(__u32 expt, __u32 *count)
return sched->poll_policy(h_ctx, expt, count);
}
-static const struct wd_config_variable table[] = {
- { .name = "WD_AEAD_CTX_NUM",
- .def_val = "sync:2@0,async:2@0",
- .parse_fn = wd_parse_ctx_num
- },
- { .name = "WD_AEAD_ASYNC_POLL_EN",
- .def_val = "0",
- .parse_fn = wd_parse_async_poll_en
- }
+static const struct wd_config_variable table = {
+ .name = "WD_AEAD_CTX_NUM",
+ .def_val = "sync:2@0,async:2@0",
+ .parse_fn = wd_parse_ctx_num
};
static const struct wd_alg_ops wd_aead_ops = {
@@ -1062,8 +1054,8 @@ int wd_aead_env_init(struct wd_sched *sched)
{
wd_aead_env_config.sched = sched;
- return wd_alg_env_init(&wd_aead_env_config, table,
- &wd_aead_ops, ARRAY_SIZE(table), NULL);
+ return wd_alg_env_init(&wd_aead_env_config, &table,
+ &wd_aead_ops, 1, NULL);
}
void wd_aead_env_uninit(void)
@@ -1080,8 +1072,8 @@ int wd_aead_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
if (ret)
return ret;
- return wd_alg_env_init(&wd_aead_env_config, table,
- &wd_aead_ops, ARRAY_SIZE(table), &ctx_attr);
+ return wd_alg_env_init(&wd_aead_env_config, &table,
+ &wd_aead_ops, 1, &ctx_attr);
}
void wd_aead_ctx_num_uninit(void)
diff --git a/wd_cipher.c b/wd_cipher.c
index abedfb3..a4d6c63 100644
--- a/wd_cipher.c
+++ b/wd_cipher.c
@@ -800,9 +800,6 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req)
}
wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx);
- ret = wd_add_task_to_async_queue(&wd_cipher_env_config, idx);
- if (ret)
- goto fail_with_msg;
return 0;
@@ -883,15 +880,10 @@ int wd_cipher_poll(__u32 expt, __u32 *count)
return sched->poll_policy(h_ctx, expt, count);
}
-static const struct wd_config_variable table[] = {
- { .name = "WD_CIPHER_CTX_NUM",
- .def_val = "sync:2@0,async:2@0",
- .parse_fn = wd_parse_ctx_num
- },
- { .name = "WD_CIPHER_ASYNC_POLL_EN",
- .def_val = "0",
- .parse_fn = wd_parse_async_poll_en
- }
+static const struct wd_config_variable table = {
+ .name = "WD_CIPHER_CTX_NUM",
+ .def_val = "sync:2@0,async:2@0",
+ .parse_fn = wd_parse_ctx_num
};
static const struct wd_alg_ops wd_cipher_ops = {
@@ -906,8 +898,8 @@ int wd_cipher_env_init(struct wd_sched *sched)
{
wd_cipher_env_config.sched = sched;
- return wd_alg_env_init(&wd_cipher_env_config, table,
- &wd_cipher_ops, ARRAY_SIZE(table), NULL);
+ return wd_alg_env_init(&wd_cipher_env_config, &table,
+ &wd_cipher_ops, 1, NULL);
}
void wd_cipher_env_uninit(void)
@@ -924,8 +916,8 @@ int wd_cipher_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
if (ret)
return ret;
- return wd_alg_env_init(&wd_cipher_env_config, table,
- &wd_cipher_ops, ARRAY_SIZE(table), &ctx_attr);
+ return wd_alg_env_init(&wd_cipher_env_config, &table,
+ &wd_cipher_ops, 1, &ctx_attr);
}
void wd_cipher_ctx_num_uninit(void)
diff --git a/wd_comp.c b/wd_comp.c
index 247eadd..84fb079 100644
--- a/wd_comp.c
+++ b/wd_comp.c
@@ -880,9 +880,6 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
}
wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx);
- ret = wd_add_task_to_async_queue(&wd_comp_env_config, idx);
- if (unlikely(ret))
- goto fail_with_msg;
return 0;
@@ -908,19 +905,10 @@ int wd_comp_poll(__u32 expt, __u32 *count)
return sched->poll_policy(h_sched_ctx, expt, count);
}
-static const struct wd_config_variable table[] = {
- { .name = "WD_COMP_CTX_NUM",
- .def_val = "sync-comp:1@0,sync-decomp:1@0,async-comp:1@0,async-decomp:1@0",
- .parse_fn = wd_parse_ctx_num
- },
- { .name = "WD_COMP_ASYNC_POLL_EN",
- .def_val = "0",
- .parse_fn = wd_parse_async_poll_en
- },
- { .name = "WD_COMP_ASYNC_POLL_NUM",
- .def_val = "1@0",
- .parse_fn = wd_parse_async_poll_num
- }
+static const struct wd_config_variable table = {
+ .name = "WD_COMP_CTX_NUM",
+ .def_val = "sync-comp:1@0,sync-decomp:1@0,async-comp:1@0,async-decomp:1@0",
+ .parse_fn = wd_parse_ctx_num
};
static const struct wd_alg_ops wd_comp_ops = {
@@ -935,8 +923,8 @@ int wd_comp_env_init(struct wd_sched *sched)
{
wd_comp_env_config.sched = sched;
- return wd_alg_env_init(&wd_comp_env_config, table,
- &wd_comp_ops, ARRAY_SIZE(table), NULL);
+ return wd_alg_env_init(&wd_comp_env_config, &table,
+ &wd_comp_ops, 1, NULL);
}
void wd_comp_env_uninit(void)
@@ -958,8 +946,8 @@ int wd_comp_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
if (ret)
return ret;
- return wd_alg_env_init(&wd_comp_env_config, table,
- &wd_comp_ops, ARRAY_SIZE(table), &ctx_attr);
+ return wd_alg_env_init(&wd_comp_env_config, &table,
+ &wd_comp_ops, 1, &ctx_attr);
}
void wd_comp_ctx_num_uninit(void)
diff --git a/wd_dh.c b/wd_dh.c
index 3395060..7837114 100644
--- a/wd_dh.c
+++ b/wd_dh.c
@@ -441,9 +441,6 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req)
}
wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx);
- ret = wd_add_task_to_async_queue(&wd_dh_env_config, idx);
- if (ret)
- goto fail_with_msg;
return WD_SUCCESS;
@@ -654,15 +651,10 @@ void wd_dh_free_sess(handle_t sess)
free(sess_t);
}
-static const struct wd_config_variable table[] = {
- { .name = "WD_DH_CTX_NUM",
- .def_val = "sync:2@0,async:2@0",
- .parse_fn = wd_parse_ctx_num
- },
- { .name = "WD_DH_ASYNC_POLL_EN",
- .def_val = "0",
- .parse_fn = wd_parse_async_poll_en
- }
+static const struct wd_config_variable table = {
+ .name = "WD_DH_CTX_NUM",
+ .def_val = "sync:2@0,async:2@0",
+ .parse_fn = wd_parse_ctx_num
};
static const struct wd_alg_ops wd_dh_ops = {
@@ -677,8 +669,8 @@ int wd_dh_env_init(struct wd_sched *sched)
{
wd_dh_env_config.sched = sched;
- return wd_alg_env_init(&wd_dh_env_config, table,
- &wd_dh_ops, ARRAY_SIZE(table), NULL);
+ return wd_alg_env_init(&wd_dh_env_config, &table,
+ &wd_dh_ops, 1, NULL);
}
void wd_dh_env_uninit(void)
@@ -695,8 +687,8 @@ int wd_dh_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
if (ret)
return ret;
- return wd_alg_env_init(&wd_dh_env_config, table,
- &wd_dh_ops, ARRAY_SIZE(table), &ctx_attr);
+ return wd_alg_env_init(&wd_dh_env_config, &table,
+ &wd_dh_ops, 1, &ctx_attr);
}
void wd_dh_ctx_num_uninit(void)
diff --git a/wd_digest.c b/wd_digest.c
index 8e5bf94..bd3dd05 100644
--- a/wd_digest.c
+++ b/wd_digest.c
@@ -746,9 +746,6 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
}
wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx);
- ret = wd_add_task_to_async_queue(&wd_digest_env_config, idx);
- if (ret)
- goto fail_with_msg;
return 0;
@@ -830,15 +827,10 @@ int wd_digest_poll(__u32 expt, __u32 *count)
return sched->poll_policy(h_ctx, expt, count);
}
-static const struct wd_config_variable table[] = {
- { .name = "WD_DIGEST_CTX_NUM",
- .def_val = "sync:2@0,async:2@0",
- .parse_fn = wd_parse_ctx_num
- },
- { .name = "WD_DIGEST_ASYNC_POLL_EN",
- .def_val = "0",
- .parse_fn = wd_parse_async_poll_en
- }
+static const struct wd_config_variable table = {
+ .name = "WD_DIGEST_CTX_NUM",
+ .def_val = "sync:2@0,async:2@0",
+ .parse_fn = wd_parse_ctx_num
};
static const struct wd_alg_ops wd_digest_ops = {
@@ -853,8 +845,8 @@ int wd_digest_env_init(struct wd_sched *sched)
{
wd_digest_env_config.sched = sched;
- return wd_alg_env_init(&wd_digest_env_config, table,
- &wd_digest_ops, ARRAY_SIZE(table), NULL);
+ return wd_alg_env_init(&wd_digest_env_config, &table,
+ &wd_digest_ops, 1, NULL);
}
void wd_digest_env_uninit(void)
@@ -871,8 +863,8 @@ int wd_digest_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
if (ret)
return ret;
- return wd_alg_env_init(&wd_digest_env_config, table,
- &wd_digest_ops, ARRAY_SIZE(table), &ctx_attr);
+ return wd_alg_env_init(&wd_digest_env_config, &table,
+ &wd_digest_ops, 1, &ctx_attr);
}
void wd_digest_ctx_num_uninit(void)
diff --git a/wd_ecc.c b/wd_ecc.c
index c31495f..4c77a04 100644
--- a/wd_ecc.c
+++ b/wd_ecc.c
@@ -2319,9 +2319,6 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req)
}
wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx);
- ret = wd_add_task_to_async_queue(&wd_ecc_env_config, idx);
- if (ret)
- goto fail_with_msg;
return WD_SUCCESS;
@@ -2401,15 +2398,10 @@ int wd_ecc_poll(__u32 expt, __u32 *count)
return wd_ecc_setting.sched.poll_policy(h_sched_sess, expt, count);
}
-static const struct wd_config_variable table[] = {
- { .name = "WD_ECC_CTX_NUM",
- .def_val = "sync:2@0,async:2@0",
- .parse_fn = wd_parse_ctx_num
- },
- { .name = "WD_ECC_ASYNC_POLL_EN",
- .def_val = "0",
- .parse_fn = wd_parse_async_poll_en
- }
+static const struct wd_config_variable table = {
+ .name = "WD_ECC_CTX_NUM",
+ .def_val = "sync:2@0,async:2@0",
+ .parse_fn = wd_parse_ctx_num
};
static const struct wd_alg_ops wd_ecc_ops = {
@@ -2424,8 +2416,8 @@ int wd_ecc_env_init(struct wd_sched *sched)
{
wd_ecc_env_config.sched = sched;
- return wd_alg_env_init(&wd_ecc_env_config, table,
- &wd_ecc_ops, ARRAY_SIZE(table), NULL);
+ return wd_alg_env_init(&wd_ecc_env_config, &table,
+ &wd_ecc_ops, 1, NULL);
}
void wd_ecc_env_uninit(void)
@@ -2442,8 +2434,8 @@ int wd_ecc_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
if (ret)
return ret;
- return wd_alg_env_init(&wd_ecc_env_config, table,
- &wd_ecc_ops, ARRAY_SIZE(table), &ctx_attr);
+ return wd_alg_env_init(&wd_ecc_env_config, &table,
+ &wd_ecc_ops, 1, &ctx_attr);
}
void wd_ecc_ctx_num_uninit(void)
diff --git a/wd_rsa.c b/wd_rsa.c
index c020514..2242fed 100644
--- a/wd_rsa.c
+++ b/wd_rsa.c
@@ -502,9 +502,6 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req)
}
wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx);
- ret = wd_add_task_to_async_queue(&wd_rsa_env_config, idx);
- if (ret)
- goto fail_with_msg;
return WD_SUCCESS;
@@ -1266,15 +1263,10 @@ void wd_rsa_get_prikey(handle_t sess, struct wd_rsa_prikey **prikey)
*prikey = ((struct wd_rsa_sess *)sess)->prikey;
}
-static const struct wd_config_variable table[] = {
- { .name = "WD_RSA_CTX_NUM",
- .def_val = "sync:2@0,async:2@0",
- .parse_fn = wd_parse_ctx_num
- },
- { .name = "WD_RSA_ASYNC_POLL_EN",
- .def_val = "0",
- .parse_fn = wd_parse_async_poll_en
- }
+static const struct wd_config_variable table = {
+ .name = "WD_RSA_CTX_NUM",
+ .def_val = "sync:2@0,async:2@0",
+ .parse_fn = wd_parse_ctx_num
};
static const struct wd_alg_ops wd_rsa_ops = {
@@ -1289,8 +1281,8 @@ int wd_rsa_env_init(struct wd_sched *sched)
{
wd_rsa_env_config.sched = sched;
- return wd_alg_env_init(&wd_rsa_env_config, table,
- &wd_rsa_ops, ARRAY_SIZE(table), NULL);
+ return wd_alg_env_init(&wd_rsa_env_config, &table,
+ &wd_rsa_ops, 1, NULL);
}
void wd_rsa_env_uninit(void)
@@ -1307,8 +1299,8 @@ int wd_rsa_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode)
if (ret)
return ret;
- return wd_alg_env_init(&wd_rsa_env_config, table,
- &wd_rsa_ops, ARRAY_SIZE(table), &ctx_attr);
+ return wd_alg_env_init(&wd_rsa_env_config, &table,
+ &wd_rsa_ops, 1, &ctx_attr);
}
void wd_rsa_ctx_num_uninit(void)
diff --git a/wd_util.c b/wd_util.c
index f97b558..c174d7c 100644
--- a/wd_util.c
+++ b/wd_util.c
@@ -8,7 +8,6 @@
#include <dirent.h>
#include <dlfcn.h>
#include <pthread.h>
-#include <semaphore.h>
#include <string.h>
#include <ctype.h>
#include "wd_sched.h"
@@ -72,27 +71,6 @@ static const char *wd_env_name[WD_TYPE_MAX] = {
"WD_JOIN_GATHER_CTX_NUM",
};
-struct async_task {
- __u32 idx;
-};
-
-struct async_task_queue {
- struct async_task *head;
- int depth;
- /* the producer offset of task queue */
- int prod;
- /* the consumer offset of task queue */
- int cons;
- int cur_task;
- int left_task;
- int end;
- sem_t empty_sem;
- sem_t full_sem;
- pthread_mutex_t lock;
- pthread_t tid;
- int (*alg_poll_ctx)(__u32, __u32, __u32 *);
-};
-
struct drv_lib_list {
void *dlhandle;
struct drv_lib_list *next;
@@ -784,17 +762,6 @@ static int str_to_bool(const char *s, bool *target)
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;
@@ -1036,41 +1003,6 @@ int wd_parse_ctx_num(struct wd_env_config *config, const char *s)
return parse_ctx_num(config, s);
}
-int wd_parse_async_poll_num(struct wd_env_config *config, const char *s)
-{
- struct wd_env_config_per_numa *config_numa;
- char *left, *section, *start;
- int node, poll_num, ret;
-
- if (!config->enable_internal_poll) {
- WD_ERR("internal poll not enabled, skip parse poll number!\n");
- return 0;
- }
-
- start = strdup(s);
- if (!start)
- return -ENOMEM;
-
- left = start;
- while ((section = strsep(&left, ","))) {
- ret = parse_num_on_numa(section, &poll_num, &node);
- if (ret)
- goto out;
- config_numa = wd_get_config_numa(config, node);
- if (!config_numa) {
- ret = -WD_EINVAL;
- goto out;
- }
- config_numa->async_poll_num = poll_num;
- }
-
- free(start);
- return 0;
-out:
- free(start);
- return ret;
-}
-
static int wd_parse_env(struct wd_env_config *config)
{
const struct wd_config_variable *var;
@@ -1119,8 +1051,6 @@ static int wd_parse_ctx_attr(struct wd_env_config *env_config,
/* Use default sched and disable internal poll */
env_config->sched = NULL;
- env_config->enable_internal_poll = 0;
- config_numa->async_poll_num = 0;
return 0;
}
@@ -1348,21 +1278,17 @@ static int wd_init_sched_config(struct wd_env_config *config,
{
struct wd_env_config_per_numa *config_numa;
int i, j, ret, max_node, type_num;
- void *func = NULL;
type_num = config->op_type_num;
max_node = numa_max_node() + 1;
if (max_node <= 0)
return -WD_EINVAL;
- if (!config->enable_internal_poll)
- func = alg_poll_ctx;
-
config->internal_sched = false;
if (!config->sched) {
WD_ERR("no sched is specified, alloc a default sched!\n");
config->sched = wd_sched_rr_alloc(SCHED_POLICY_RR, type_num,
- max_node, func);
+ max_node, alg_poll_ctx);
if (!config->sched)
return -WD_ENOMEM;
@@ -1389,339 +1315,6 @@ err_release_sched:
return ret;
}
-static struct async_task_queue *find_async_queue(struct wd_env_config *config,
- __u32 idx)
-{
- struct wd_env_config_per_numa *config_numa;
- struct wd_ctx_range **ctx_table;
- struct async_task_queue *head;
- unsigned long offset = 0;
- __u32 i, num = 0;
-
- FOREACH_NUMA(i, config, config_numa) {
- num += config_numa->sync_ctx_num + config_numa->async_ctx_num;
- if (idx < num)
- break;
- }
-
- if (i == config->numa_num) {
- WD_ERR("failed to find a proper numa node!\n");
- return NULL;
- }
-
- if (!config_numa->async_poll_num) {
- WD_ERR("invalid: async_poll_num of numa is zero!\n");
- return NULL;
- }
-
- ctx_table = config_numa->ctx_table;
- for (i = 0; i < config_numa->op_type_num; i++) {
- if (idx <= ctx_table[CTX_MODE_ASYNC][i].end &&
- idx >= ctx_table[CTX_MODE_ASYNC][i].begin) {
- offset = (idx - ctx_table[CTX_MODE_ASYNC][i].begin) %
- config_numa->async_poll_num;
- break;
- }
- }
-
- if (i == config_numa->op_type_num) {
- WD_ERR("failed to find async queue for ctx: idx %u!\n", idx);
- return NULL;
- }
-
- head = (struct async_task_queue *)config_numa->async_task_queue_array;
-
- return head + offset;
-}
-
-int wd_add_task_to_async_queue(struct wd_env_config *config, __u32 idx)
-{
- struct async_task_queue *task_queue;
- struct async_task *task;
- int curr_prod, ret;
-
- if (!config->enable_internal_poll)
- return 0;
-
- task_queue = find_async_queue(config, idx);
- if (!task_queue)
- return -WD_EINVAL;
-
- ret = sem_wait(&task_queue->empty_sem);
- if (ret) {
- WD_ERR("failed to wait empty_sem!\n");
- return ret;
- }
-
- pthread_mutex_lock(&task_queue->lock);
-
- /* get an available async task and fill ctx idx */
- curr_prod = task_queue->prod;
- task = task_queue->head + curr_prod;
- task->idx = idx;
-
- /* update global information of task queue */
- task_queue->prod = (curr_prod + 1) % task_queue->depth;
- task_queue->cur_task++;
- task_queue->left_task--;
-
- pthread_mutex_unlock(&task_queue->lock);
-
- ret = sem_post(&task_queue->full_sem);
- if (ret) {
- WD_ERR("failed to post full_sem!\n");
- goto err_out;
- }
-
- return 0;
-
-err_out:
- pthread_mutex_lock(&task_queue->lock);
- task_queue->left_task++;
- task_queue->cur_task--;
- task_queue->prod = curr_prod;
- pthread_mutex_unlock(&task_queue->lock);
- sem_post(&task_queue->empty_sem);
-
- return ret;
-}
-
-static void *async_poll_process_func(void *args)
-{
- struct async_task_queue *task_queue = args;
- struct async_task *head, *task;
- __u32 count;
- int cons, ret;
-
- while (1) {
- if (sem_wait(&task_queue->full_sem)) {
- if (errno == EINTR) {
- continue;
- }
- }
- if (__atomic_load_n(&task_queue->end, __ATOMIC_ACQUIRE)) {
- __atomic_store_n(&task_queue->end, 0, __ATOMIC_RELEASE);
- goto out;
- }
-
- pthread_mutex_lock(&task_queue->lock);
-
- /* async sending message isn't submitted yet */
- if (task_queue->cons == task_queue->prod) {
- pthread_mutex_unlock(&task_queue->lock);
- sem_post(&task_queue->full_sem);
- continue;
- }
-
- cons = task_queue->cons;
- head = task_queue->head;
- task = head + cons;
-
- task_queue->cons = (cons + 1) % task_queue->depth;
- task_queue->cur_task--;
- task_queue->left_task++;
-
- pthread_mutex_unlock(&task_queue->lock);
-
- ret = task_queue->alg_poll_ctx(task->idx, 1, &count);
- if (ret < 0) {
- pthread_mutex_lock(&task_queue->lock);
- task_queue->cons = cons;
- task_queue->cur_task++;
- task_queue->left_task--;
- pthread_mutex_unlock(&task_queue->lock);
- if (ret == -WD_EAGAIN) {
- sem_post(&task_queue->full_sem);
- continue;
- } else
- goto out;
- }
-
- if (sem_post(&task_queue->empty_sem))
- goto out;
- }
-out:
- return NULL;
-}
-
-static int wd_init_one_task_queue(struct async_task_queue *task_queue,
- void *alg_poll_ctx)
-
-{
- struct async_task *head;
- pthread_t thread_id;
- pthread_attr_t attr;
- int depth, ret;
-
- task_queue->depth = depth = WD_ASYNC_DEF_QUEUE_DEPTH;
-
- head = calloc(task_queue->depth, sizeof(*head));
- if (!head)
- return -WD_ENOMEM;
-
- task_queue->head = head;
- task_queue->left_task = depth;
- task_queue->alg_poll_ctx = alg_poll_ctx;
-
- if (sem_init(&task_queue->empty_sem, 0, depth)) {
- WD_ERR("failed to init empty_sem!\n");
- goto err_free_head;
- }
-
- if (sem_init(&task_queue->full_sem, 0, 0)) {
- WD_ERR("failed to init full_sem!\n");
- goto err_uninit_empty_sem;
- }
-
- if (pthread_mutex_init(&task_queue->lock, NULL)) {
- WD_ERR("failed to init task queue's mutex lock!\n");
- goto err_uninit_full_sem;
- }
-
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- task_queue->tid = 0;
- if (pthread_create(&thread_id, &attr, async_poll_process_func,
- task_queue)) {
- WD_ERR("failed to create poll thread!\n");
- goto err_destory_mutex;
- }
-
- task_queue->tid = thread_id;
- pthread_attr_destroy(&attr);
-
- return 0;
-
-err_destory_mutex:
- pthread_attr_destroy(&attr);
- pthread_mutex_destroy(&task_queue->lock);
-err_uninit_full_sem:
- sem_destroy(&task_queue->full_sem);
-err_uninit_empty_sem:
- sem_destroy(&task_queue->empty_sem);
-err_free_head:
- free(head);
- ret = -errno;
- return ret;
-}
-
-static void wd_uninit_one_task_queue(struct async_task_queue *task_queue)
-{
- /*
- * If there's no async task, async_poll_process_func() is sleeping
- * on task_queue->full_sem. It'll cause that threads could not
- * be end and memory leak.
- */
- sem_post(&task_queue->full_sem);
- __atomic_store_n(&task_queue->end, 1, __ATOMIC_RELEASE);
- while (__atomic_load_n(&task_queue->end, __ATOMIC_ACQUIRE))
- sched_yield();
-
- pthread_mutex_destroy(&task_queue->lock);
- sem_destroy(&task_queue->full_sem);
- sem_destroy(&task_queue->empty_sem);
- free(task_queue->head);
- task_queue->head = NULL;
-}
-
-static int wd_init_async_polling_thread_per_numa(struct wd_env_config *config,
- struct wd_env_config_per_numa *config_numa,
- void *alg_poll_ctx)
-{
- struct async_task_queue *task_queue, *queue_head;
- int i, j, ret;
- double num;
-
- if (!config_numa->async_ctx_num)
- return 0;
-
- if (!config_numa->async_poll_num) {
- WD_ERR("invalid async poll num (%lu) is set.\n",
- config_numa->async_poll_num);
- WD_ERR("change to default value: %d\n", WD_ASYNC_DEF_POLL_NUM);
- config_numa->async_poll_num = WD_ASYNC_DEF_POLL_NUM;
- }
-
- num = MIN(config_numa->async_poll_num, config_numa->async_ctx_num);
-
- /* make max task queues as the number of async ctxs */
- queue_head = calloc(config_numa->async_ctx_num, sizeof(*queue_head));
- if (!queue_head)
- return -WD_ENOMEM;
-
- task_queue = queue_head;
- for (i = 0; i < num; task_queue++, i++) {
- ret = wd_init_one_task_queue(task_queue, alg_poll_ctx);
- if (ret) {
- for (j = 0; j < i; task_queue++, j++)
- wd_uninit_one_task_queue(task_queue);
- free(queue_head);
- return ret;
- }
- }
-
- config_numa->async_task_queue_array = (void *)queue_head;
-
- return 0;
-}
-
-static void wd_uninit_async_polling_thread_per_numa(struct wd_env_config *cfg,
- struct wd_env_config_per_numa *config_numa)
-{
- struct async_task_queue *task_queue, *head;
- double num;
- int i;
-
- if (!config_numa || !config_numa->async_task_queue_array)
- return;
-
- head = config_numa->async_task_queue_array;
- task_queue = head;
- num = MIN(config_numa->async_poll_num, config_numa->async_ctx_num);
-
- for (i = 0; i < num; task_queue++, i++)
- wd_uninit_one_task_queue(task_queue);
- free(head);
- config_numa->async_task_queue_array = NULL;
-}
-
-static int wd_init_async_polling_thread(struct wd_env_config *config,
- void *alg_poll_ctx)
-{
- struct wd_env_config_per_numa *config_numa;
- int i, ret;
-
- if (!config->enable_internal_poll)
- return 0;
-
- FOREACH_NUMA(i, config, config_numa) {
- ret = wd_init_async_polling_thread_per_numa(config, config_numa,
- alg_poll_ctx);
- if (ret)
- goto out;
- }
-
- return 0;
-
-out:
- FOREACH_NUMA(i, config, config_numa)
- wd_uninit_async_polling_thread_per_numa(config, config_numa);
-
- return ret;
-}
-
-static void wd_uninit_async_polling_thread(struct wd_env_config *config)
-{
- struct wd_env_config_per_numa *config_numa;
- int i;
-
- if (!config->enable_internal_poll)
- return;
-
- FOREACH_NUMA(i, config, config_numa)
- wd_uninit_async_polling_thread_per_numa(config, config_numa);
-}
-
static int wd_init_resource(struct wd_env_config *config,
const struct wd_alg_ops *ops)
{
@@ -1739,14 +1332,8 @@ static int wd_init_resource(struct wd_env_config *config,
if (ret)
goto err_uninit_sched;
- ret = wd_init_async_polling_thread(config, ops->alg_poll_ctx);
- if (ret)
- goto err_uninit_alg;
-
return 0;
-err_uninit_alg:
- ops->alg_uninit();
err_uninit_sched:
wd_uninit_sched_config(config);
err_uninit_ctx:
@@ -1757,7 +1344,6 @@ err_uninit_ctx:
static void wd_uninit_resource(struct wd_env_config *config,
const struct wd_alg_ops *ops)
{
- wd_uninit_async_polling_thread(config);
ops->alg_uninit();
wd_uninit_sched_config(config);
wd_free_ctx(config);
@@ -1811,7 +1397,7 @@ int wd_alg_get_env_param(struct wd_env_config *env_config,
return -WD_EINVAL;
}
- *is_enable = env_config->enable_internal_poll;
+ *is_enable = 0;
config_numa = wd_get_config_numa(env_config, attr.node);
if (!config_numa)
--
2.43.0