From: Longfang Liu <liulongfang@huawei.com> Adapt the user-space driver according to UADK's framework update method to ensure compatibility between the driver and the framework. Signed-off-by: Longfang Liu <liulongfang@huawei.com> --- drv/hash_mb/hash_mb.c | 1 + drv/hisi_comp.c | 2 +- drv/hisi_dae_common.c | 2 +- drv/hisi_hpre.c | 2 +- drv/hisi_sec.c | 8 +++++++- drv/hisi_udma.c | 2 +- drv/isa_ce_sm3.c | 3 +++ drv/isa_ce_sm4.c | 4 +++- 8 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drv/hash_mb/hash_mb.c b/drv/hash_mb/hash_mb.c index 5c0daf2..f205224 100644 --- a/drv/hash_mb/hash_mb.c +++ b/drv/hash_mb/hash_mb.c @@ -6,6 +6,7 @@ #include <stdlib.h> #include <string.h> #include "hash_mb.h" +#include "../wd_drv.h" #define MIN(a, b) (((a) > (b)) ? (b) : (a)) #define IPAD_VALUE 0x36 diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c index 9246de8..7c7104b 100644 --- a/drv/hisi_comp.c +++ b/drv/hisi_comp.c @@ -1491,7 +1491,7 @@ static int hisi_zip_init(void *conf, void *priv) memcpy(&zip_ctx->config, config, sizeof(struct wd_ctx_config_internal)); /* allocate qp for each context */ for (i = 0; i < config->ctx_num; i++) { - if (config->ctxs[i].ctx_type != UADK_CTX_HW || + if (config->ctxs[i].ctx_type != UADK_ALG_HW || !config->ctxs[i].ctx) continue; h_ctx = config->ctxs[i].ctx; diff --git a/drv/hisi_dae_common.c b/drv/hisi_dae_common.c index 74dc84f..82ae6f9 100644 --- a/drv/hisi_dae_common.c +++ b/drv/hisi_dae_common.c @@ -327,7 +327,7 @@ int dae_init(void *conf, void *priv) qm_priv.sqe_size = sizeof(struct dae_sqe); /* Allocate qp for each context */ for (i = 0; i < config->ctx_num; i++) { - if (config->ctxs[i].ctx_type != UADK_CTX_HW || + if (config->ctxs[i].ctx_type != UADK_ALG_HW || !config->ctxs[i].ctx) continue; h_ctx = config->ctxs[i].ctx; diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c index 0a0acc5..4b155a0 100644 --- a/drv/hisi_hpre.c +++ b/drv/hisi_hpre.c @@ -653,7 +653,7 @@ static int hpre_init_qm_priv(struct wd_ctx_config_internal *config, qm_priv->sqe_size = sizeof(struct hisi_hpre_sqe); for (i = 0; i < config->ctx_num; i++) { - if (config->ctxs[i].ctx_type != UADK_CTX_HW || + if (config->ctxs[i].ctx_type != UADK_ALG_HW || !config->ctxs[i].ctx) continue; h_ctx = config->ctxs[i].ctx; diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c index 0e17eb9..17c986d 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -10,6 +10,7 @@ #include "crypto/aes.h" #include "crypto/galois.h" #include "hisi_qm_udrv.h" +#include "wd_drv.h" #define BIT(nr) (1UL << (nr)) #define SEC_DIGEST_ALG_OFFSET 11 @@ -797,12 +798,15 @@ static int sec_aead_get_extend_ops(void *ops) .queue_num = SEC_CTX_Q_NUM_DEF,\ .op_type_num = 1,\ .fallback = 0,\ + .init_state = 0,\ .init = hisi_sec_init,\ .exit = hisi_sec_exit,\ .send = alg_type##_send,\ .recv = alg_type##_recv,\ .get_usage = hisi_sec_get_usage,\ .get_extend_ops = sec_aead_get_extend_ops,\ + .alloc_ctx = wd_hw_alloc_ctx, \ + .free_ctx = wd_hw_free_ctx, \ } static struct wd_alg_driver cipher_alg_driver[] = { @@ -3911,10 +3915,12 @@ static int hisi_sec_init(void *conf, void *priv) return -WD_EINVAL; } + WD_INFO("hisi_sec_init: ctx type: %u for %u ctx.\n", + config->ctxs[0].ctx_type, config->ctx_num); qm_priv.sqe_size = sizeof(struct hisi_sec_sqe); /* allocate qp for each context */ for (i = 0; i < config->ctx_num; i++) { - if (config->ctxs[i].ctx_type != UADK_CTX_HW || + if (config->ctxs[i].ctx_type != UADK_ALG_HW || !config->ctxs[i].ctx) continue; h_ctx = config->ctxs[i].ctx; diff --git a/drv/hisi_udma.c b/drv/hisi_udma.c index 62b83e7..424e9b1 100644 --- a/drv/hisi_udma.c +++ b/drv/hisi_udma.c @@ -461,7 +461,7 @@ static int udma_init(void *conf, void *priv) qm_priv.sqe_size = sizeof(struct udma_sqe); /* Allocate qp for each context */ for (i = 0; i < config->ctx_num; i++) { - if (config->ctxs[i].ctx_type != UADK_CTX_HW || + if (config->ctxs[i].ctx_type != UADK_ALG_HW || !config->ctxs[i].ctx) continue; h_ctx = config->ctxs[i].ctx; diff --git a/drv/isa_ce_sm3.c b/drv/isa_ce_sm3.c index 9dbd0a8..196001a 100644 --- a/drv/isa_ce_sm3.c +++ b/drv/isa_ce_sm3.c @@ -17,6 +17,7 @@ #include "drv/isa_ce_sm3.h" #include "drv/wd_digest_drv.h" #include "wd_digest.h" +#include "wd_drv.h" #define SM3_ALIGN_MASK 63U @@ -43,6 +44,8 @@ static struct wd_alg_driver sm3_ce_alg_driver = { .send = sm3_ce_drv_send, .recv = sm3_ce_drv_recv, .get_usage = sm3_ce_get_usage, + .alloc_ctx = wd_soft_alloc_ctx, + .free_ctx = wd_soft_free_ctx, }; static void __attribute__((constructor)) sm3_ce_probe(void) diff --git a/drv/isa_ce_sm4.c b/drv/isa_ce_sm4.c index 4c42693..8d3f606 100644 --- a/drv/isa_ce_sm4.c +++ b/drv/isa_ce_sm4.c @@ -11,10 +11,10 @@ * Copyright 2024 Huawei Technologies Co.,Ltd. All rights reserved. */ -#include "wd_alg.h" #include "drv/wd_cipher_drv.h" #include "isa_ce_sm4.h" #include "wd_cipher.h" +#include "wd_drv.h" #define SM4_ENCRYPT 1 #define SM4_DECRYPT 0 @@ -433,6 +433,8 @@ static int cipher_recv(handle_t ctx, void *msg) .exit = isa_ce_exit,\ .send = alg_type##_send,\ .recv = alg_type##_recv,\ + .alloc_ctx = wd_soft_alloc_ctx, \ + .free_ctx = wd_soft_free_ctx, \ } static struct wd_alg_driver cipher_alg_driver[] = { -- 2.43.0