1.update the registration attribute of the driver of the hpre device. 2.update the driver registration properties of the zip device 3.update the driver registration properties of the sec device
Signed-off-by: Longfang Liu liulongfang@huawei.com --- drv/hisi_comp.c | 9 +++++---- drv/hisi_hpre.c | 52 +++++++++++++++++++++++++++++++------------------ drv/hisi_sec.c | 25 ++++++++++++------------ 3 files changed, 51 insertions(+), 35 deletions(-)
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c index 26df469..b6f4d19 100644 --- a/drv/hisi_comp.c +++ b/drv/hisi_comp.c @@ -1060,8 +1060,9 @@ static int hisi_zip_comp_recv(handle_t ctx, void *comp_msg) #define GEN_ZIP_ALG_DRIVER(zip_alg_name) \ {\ .drv_name = "hisi_zip",\ - .alg_name = zip_alg_name,\ - .priority = UADK_ALG_HW,\ + .alg_name = (zip_alg_name),\ + .calc_type = UADK_ALG_HW,\ + .priority = 100,\ .priv_size = sizeof(struct hisi_zip_ctx),\ .queue_num = ZIP_CTX_Q_NUM_DEF,\ .op_type_num = 2,\ @@ -1089,7 +1090,7 @@ static void __attribute__((constructor)) hisi_zip_probe(void)
for (i = 0; i < alg_num; i++) { ret = wd_alg_driver_register(&zip_alg_driver[i]); - if (ret) + if (ret && ret != -WD_ENODEV) WD_ERR("Error: register ZIP %s failed!\n", zip_alg_driver[i].alg_name); } @@ -1100,7 +1101,7 @@ static void __attribute__((destructor)) hisi_zip_remove(void) int alg_num = ARRAY_SIZE(zip_alg_driver); int i;
+ WD_INFO("Info: unregister ZIP alg drivers!\n"); for (i = 0; i < alg_num; i++) wd_alg_driver_unregister(&zip_alg_driver[i]); } - diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c index b9be464..15cadbe 100644 --- a/drv/hisi_hpre.c +++ b/drv/hisi_hpre.c @@ -2438,11 +2438,17 @@ static int ecc_recv(handle_t ctx, void *ecc_msg) return ecc_sqe_parse((struct hisi_qp *)h_qp, msg, &hw_msg); }
-#define GEN_HPRE_ECC_DRIVER(hpre_alg_name) \ +static int hpre_get_usage(void *param) +{ + return 0; +} + +#define GEN_HPRE_ALG_DRIVER(hpre_alg_name) \ {\ .drv_name = "hisi_hpre",\ - .alg_name = hpre_alg_name,\ - .priority = UADK_ALG_HW,\ + .alg_name = (hpre_alg_name),\ + .calc_type = UADK_ALG_HW,\ + .priority = 100,\ .priv_size = sizeof(struct hisi_hpre_ctx),\ .queue_num = HPRE_CTX_Q_NUM_DEF,\ .op_type_num = 1,\ @@ -2451,20 +2457,22 @@ static int ecc_recv(handle_t ctx, void *ecc_msg) .exit = hpre_exit,\ .send = ecc_send,\ .recv = ecc_recv,\ + .get_usage = hpre_get_usage,\ }
static struct wd_alg_driver hpre_ecc_driver[] = { - GEN_HPRE_ECC_DRIVER("sm2"), - GEN_HPRE_ECC_DRIVER("ecdh"), - GEN_HPRE_ECC_DRIVER("ecdsa"), - GEN_HPRE_ECC_DRIVER("x25519"), - GEN_HPRE_ECC_DRIVER("x448"), + GEN_HPRE_ALG_DRIVER("sm2"), + GEN_HPRE_ALG_DRIVER("ecdh"), + GEN_HPRE_ALG_DRIVER("ecdsa"), + GEN_HPRE_ALG_DRIVER("x25519"), + GEN_HPRE_ALG_DRIVER("x448"), };
static struct wd_alg_driver hpre_rsa_driver = { .drv_name = "hisi_hpre", .alg_name = "rsa", - .priority = UADK_ALG_HW, + .calc_type = UADK_ALG_HW, + .priority = 100, .priv_size = sizeof(struct hisi_hpre_ctx), .queue_num = HPRE_CTX_Q_NUM_DEF, .op_type_num = 1, @@ -2473,12 +2481,14 @@ static struct wd_alg_driver hpre_rsa_driver = { .exit = hpre_exit, .send = rsa_send, .recv = rsa_recv, + .get_usage = hpre_get_usage, };
static struct wd_alg_driver hpre_dh_driver = { .drv_name = "hisi_hpre", .alg_name = "dh", - .priority = UADK_ALG_HW, + .calc_type = UADK_ALG_HW, + .priority = 100, .priv_size = sizeof(struct hisi_hpre_ctx), .queue_num = HPRE_CTX_Q_NUM_DEF, .op_type_num = 1, @@ -2487,37 +2497,41 @@ static struct wd_alg_driver hpre_dh_driver = { .exit = hpre_exit, .send = dh_send, .recv = dh_recv, + .get_usage = hpre_get_usage, }; + static void __attribute__((constructor)) hisi_hpre_probe(void) { - int alg_num = ARRAY_SIZE(hpre_ecc_driver); - int i, ret; + __u32 alg_num = ARRAY_SIZE(hpre_ecc_driver); + __u32 i; + int ret;
WD_INFO("Info: register HPRE alg drivers!\n"); - ret = wd_alg_driver_register(&hpre_rsa_driver); - if (ret) + if (ret && ret != -WD_ENODEV) WD_ERR("failed to register HPRE rsa driver!\n");
ret = wd_alg_driver_register(&hpre_dh_driver); - if (ret) - WD_ERR("failed to register HPRE dh driver!\n"); + if (ret && ret != -WD_ENODEV) + WD_ERR("failed to register HPRE rsa driver!\n");
for (i = 0; i < alg_num; i++) { ret = wd_alg_driver_register(&hpre_ecc_driver[i]); - if (ret) + if (ret && ret != -WD_ENODEV) WD_ERR("failed to register HPRE %s driver!\n", hpre_ecc_driver[i].alg_name); } }
static void __attribute__((destructor)) hisi_hpre_remove(void) { - int alg_num = ARRAY_SIZE(hpre_ecc_driver); - int i; + __u32 alg_num = ARRAY_SIZE(hpre_ecc_driver); + __u32 i;
+ WD_INFO("Info: unregister HPRE alg drivers!\n"); for (i = 0; i < alg_num; i++) wd_alg_driver_unregister(&hpre_ecc_driver[i]);
wd_alg_driver_unregister(&hpre_dh_driver); + wd_alg_driver_unregister(&hpre_rsa_driver); } diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c index 0715c55..e6589a0 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -534,8 +534,8 @@ static __u32 g_sec_hmac_full_len[WD_DIGEST_TYPE_MAX] = { SEC_HMAC_SHA512_MAC_LEN, SEC_HMAC_SHA512_224_MAC_LEN, SEC_HMAC_SHA512_256_MAC_LEN };
-int hisi_sec_init(void *conf, void *priv); -void hisi_sec_exit(void *priv); +static int hisi_sec_init(void *conf, void *priv); +static void hisi_sec_exit(void *priv);
static int hisi_sec_get_usage(void *param) { @@ -545,8 +545,9 @@ static int hisi_sec_get_usage(void *param) #define GEN_SEC_ALG_DRIVER(sec_alg_name) \ {\ .drv_name = "hisi_sec2",\ - .alg_name = sec_alg_name,\ - .priority = UADK_ALG_HW,\ + .alg_name = (sec_alg_name),\ + .calc_type = UADK_ALG_HW,\ + .priority = 100,\ .priv_size = sizeof(struct hisi_sec_ctx),\ .queue_num = SEC_CTX_Q_NUM_DEF,\ .op_type_num = 1,\ @@ -3020,7 +3021,7 @@ static void hisi_sec_driver_adapter(struct hisi_qp *qp) } }
-int hisi_sec_init(void *conf, void *priv) +static int hisi_sec_init(void *conf, void *priv) { struct wd_ctx_config_internal *config = conf; struct hisi_sec_ctx *sec_ctx = priv; @@ -3063,15 +3064,15 @@ out: return -WD_EINVAL; }
-void hisi_sec_exit(void *priv) +static void hisi_sec_exit(void *priv) { struct hisi_sec_ctx *sec_ctx = priv; struct wd_ctx_config_internal *config; handle_t h_qp; __u32 i;
- if (!sec_ctx) { - WD_ERR("hisi sec exit input parameter is err!\n"); + if (!priv) { + WD_ERR("invalid: input parameter is NULL!\n"); return; }
@@ -3092,7 +3093,7 @@ static void __attribute__((constructor)) hisi_sec2_probe(void) alg_num = ARRAY_SIZE(cipher_alg_driver); for (i = 0; i < alg_num; i++) { ret = wd_alg_driver_register(&cipher_alg_driver[i]); - if (ret) + if (ret && ret != -WD_ENODEV) WD_ERR("Error: register SEC %s failed!\n", cipher_alg_driver[i].alg_name); } @@ -3100,7 +3101,7 @@ static void __attribute__((constructor)) hisi_sec2_probe(void) alg_num = ARRAY_SIZE(digest_alg_driver); for (i = 0; i < alg_num; i++) { ret = wd_alg_driver_register(&digest_alg_driver[i]); - if (ret) + if (ret && ret != -WD_ENODEV) WD_ERR("Error: register SEC %s failed!\n", digest_alg_driver[i].alg_name); } @@ -3108,7 +3109,7 @@ static void __attribute__((constructor)) hisi_sec2_probe(void) alg_num = ARRAY_SIZE(aead_alg_driver); for (i = 0; i < alg_num; i++) { ret = wd_alg_driver_register(&aead_alg_driver[i]); - if (ret) + if (ret && ret != -WD_ENODEV) WD_ERR("Error: register SEC %s failed!\n", aead_alg_driver[i].alg_name); } @@ -3119,6 +3120,7 @@ static void __attribute__((destructor)) hisi_sec2_remove(void) int alg_num; int i;
+ WD_INFO("Info: unregister SEC alg drivers!\n"); alg_num = ARRAY_SIZE(cipher_alg_driver); for (i = 0; i < alg_num; i++) wd_alg_driver_unregister(&cipher_alg_driver[i]); @@ -3131,4 +3133,3 @@ static void __attribute__((destructor)) hisi_sec2_remove(void) for (i = 0; i < alg_num; i++) wd_alg_driver_unregister(&aead_alg_driver[i]); } -