If the -lwd link is not added, dlsym fails to search for wd_alg_driver_register symbol.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index bd7b36f..c66bbfe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -118,7 +118,7 @@ libwd_crypto_la_LIBADD= -lwd -ldl -lnuma libwd_crypto_la_LDFLAGS=$(UADK_VERSION) $(UADK_CRYPTO_SYMBOL) libwd_crypto_la_DEPENDENCIES= libwd.la
-libhisi_zip_la_LIBADD= -ldl +libhisi_zip_la_LIBADD= -ldl -lwd libhisi_zip_la_LDFLAGS=$(UADK_VERSION)
libhisi_sec_la_LIBADD= -lwd -lwd_crypto
The driver name must match the actual driver name of the kernel.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- drv/hisi_sec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c index 0527bff..a84cc7a 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -527,7 +527,7 @@ static int hisi_sec_get_usage(void *param)
#define GEN_SEC_ALG_DRIVER(sec_alg_name) \ {\ - .drv_name = "hisi_sec2_cipher",\ + .drv_name = "hisi_sec2",\ .alg_name = sec_alg_name,\ .priority = UADK_ALG_HW,\ .priv_size = sizeof(struct hisi_sec_ctx),\
wd_env_set_ctx_nums is used to parse the configuration information about the number of CTXs from a specific environment variable and set the configuration information to the ctx_nums array.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- include/wd_util.h | 8 ++++++ wd_util.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/include/wd_util.h b/include/wd_util.h index a730f36..434f068 100644 --- a/include/wd_util.h +++ b/include/wd_util.h @@ -482,6 +482,14 @@ void wd_dlclose_drv(void *dlh_list); */ int wd_get_lib_file_path(char *lib_file, char *lib_path, bool is_dir);
+/** + * wd_env_set_ctx_ctx_nums() - Set the ctx_set_num by parsing the environment variable. + * @name: the name of the environment variable. + * @ctx_nums: array to be initialized. + * @size: array size. + */ +int wd_env_set_ctx_nums(const char *name, struct wd_ctx_nums *ctx_nums, __u32 size); + /** * wd_dfx_msg_cnt() - Message counter interface for ctx * @msg: Shared memory addr. diff --git a/wd_util.c b/wd_util.c index dab4fc8..b8a3355 100644 --- a/wd_util.c +++ b/wd_util.c @@ -2017,8 +2017,10 @@ int wd_ctx_param_init(struct wd_ctx_params *ctx_params, }
for (i = 0; i < ctx_params->op_type_num; i++) { - ctx_set_num[i].sync_ctx_num = driver->queue_num; - ctx_set_num[i].async_ctx_num = driver->queue_num; + if (!ctx_set_num[i].sync_ctx_num || !ctx_set_num[i].async_ctx_num) { + ctx_set_num[i].sync_ctx_num = driver->queue_num; + ctx_set_num[i].async_ctx_num = driver->queue_num; + } } } else { ctx_params->bmp = user_ctx_params->bmp; @@ -2581,3 +2583,63 @@ void wd_alg_attrs_uninit(struct wd_init_attrs *attrs) wd_sched_rr_release(alg_sched); }
+static int wd_set_ctx_nums(struct wd_ctx_nums *ctx_nums, const char *section, + __u32 op_type_num, int is_comp) +{ + int i, j, ctx_num, node, ret; + char *ctx_section; + const char *type; + + if (is_comp && op_type_num > ARRAY_SIZE(comp_ctx_type)) + return -WD_EINVAL; + + ctx_section = index(section, ':'); + ctx_section++; + ret = parse_num_on_numa(ctx_section, &ctx_num, &node); + if (ret) + return ret; + + for (i = 0; i < CTX_MODE_MAX; i++) { + for (j = 0; j < op_type_num; j++) { + type = is_comp ? comp_ctx_type[i][j] : ctx_type[i][0]; + if (strncmp(section, type, strlen(type))) + continue; + + if (!i) + ctx_nums[j].sync_ctx_num = ctx_num; + else + ctx_nums[j].async_ctx_num = ctx_num; + + return 0; + } + } + + return -WD_EINVAL; +} + +int wd_env_set_ctx_nums(const char *name, struct wd_ctx_nums *ctx_nums, __u32 size) +{ + char *left, *section, *start, *var_s; + int ret, is_comp; + + is_comp = strncmp(name, "WD_COMP_CTX_NUM", strlen(name)) ? 0 : 1; + + var_s = secure_getenv(name); + if (!var_s || !strlen(var_s)) + return 0; + + start = strdup(var_s); + if (!start) + return -WD_ENOMEM; + + left = start; + while ((section = strsep(&left, ","))) { + ret = wd_set_ctx_nums(ctx_nums, section, size, is_comp); + if (ret) + goto out_free_str; + } + +out_free_str: + free(start); + return ret; +}
Use wd_env_set_ctx_nums to set ctx nums from environment information.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- wd_cipher.c | 6 ++++++ wd_comp.c | 7 +++++++ wd_dh.c | 6 ++++++ wd_ecc.c | 6 ++++++ wd_rsa.c | 6 ++++++ 5 files changed, 31 insertions(+)
diff --git a/wd_cipher.c b/wd_cipher.c index eca9711..80d4be2 100644 --- a/wd_cipher.c +++ b/wd_cipher.c @@ -422,6 +422,12 @@ res_retry: goto out_dlopen; }
+ ret = wd_env_set_ctx_nums("WD_CIPHER_CTX_NUM", cipher_ctx_num, WD_CIPHER_DECRYPTION + 1); + if (ret) { + WD_ERR("fail to init cipher ctx nums from env!\n"); + goto out_driver; + } + ret = wd_ctx_param_init(&cipher_ctx_params, ctx_params, cipher_ctx_num, wd_cipher_setting.driver, WD_CIPHER_DECRYPTION + 1); diff --git a/wd_comp.c b/wd_comp.c index b7e0eb7..99553c5 100644 --- a/wd_comp.c +++ b/wd_comp.c @@ -243,6 +243,13 @@ res_retry: goto out_dlopen; }
+ + ret = wd_env_set_ctx_nums("WD_COMP_CTX_NUM", comp_ctx_num, WD_DIR_MAX); + if (ret) { + WD_ERR("fail to init comp ctx nums from env!\n"); + goto out_driver; + } + ret = wd_ctx_param_init(&comp_ctx_params, ctx_params, comp_ctx_num, wd_comp_setting.driver, WD_DIR_MAX); diff --git a/wd_dh.c b/wd_dh.c index d45ac89..bb8e76f 100644 --- a/wd_dh.c +++ b/wd_dh.c @@ -235,6 +235,12 @@ res_retry: goto out_dlopen; }
+ ret = wd_env_set_ctx_nums("WD_DH_CTX_NUM", dh_ctx_num, WD_DH_PHASE2); + if (ret) { + WD_ERR("fail to init dh ctx nums from env!\n"); + goto out_driver; + } + ret = wd_ctx_param_init(&dh_ctx_params, ctx_params, dh_ctx_num, wd_dh_setting.driver, WD_DH_PHASE2); diff --git a/wd_ecc.c b/wd_ecc.c index 57954e0..bef7982 100644 --- a/wd_ecc.c +++ b/wd_ecc.c @@ -291,6 +291,12 @@ res_retry: goto out_dlopen; }
+ ret = wd_env_set_ctx_nums("WD_ECC_CTX_NUM", ecc_ctx_num, WD_EC_OP_MAX); + if (ret) { + WD_ERR("fail to init ecc ctx nums from env!\n"); + goto out_driver; + } + ret = wd_ctx_param_init(&ecc_ctx_params, ctx_params, ecc_ctx_num, wd_ecc_setting.driver, WD_EC_OP_MAX); diff --git a/wd_rsa.c b/wd_rsa.c index 77fe5c0..9f5fb57 100644 --- a/wd_rsa.c +++ b/wd_rsa.c @@ -276,6 +276,12 @@ res_retry: goto out_dlopen; }
+ ret = wd_env_set_ctx_nums("WD_RSA_CTX_NUM", rsa_ctx_num, WD_RSA_GENKEY); + if (ret) { + WD_ERR("fail to init rsa ctx nums from env!\n"); + goto out_driver; + } + ret = wd_ctx_param_init(&rsa_ctx_params, ctx_params, rsa_ctx_num, wd_rsa_setting.driver, WD_RSA_GENKEY);