Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ libhisi_hpre_la_SOURCES=drv/hisi_hpre.c drv/hisi_qm_udrv.c \
hisi_qm_udrv.h

libisa_ce_la_SOURCES=arm_arch_ce.h drv/isa_ce_sm3.c drv/isa_ce_sm3_armv8.S isa_ce_sm3.h \
drv/isa_ce_sm4.c drv/isa_ce_sm4_armv8.S drv/isa_ce_sm4.h
drv/isa_ce_sm4.c drv/isa_ce_sm4_armv8.S drv/isa_ce_sm4.h wd_util.c wd_util.h

libisa_sve_la_SOURCES=drv/hash_mb/hash_mb.c wd_digest_drv.h drv/hash_mb/hash_mb.h \
drv/hash_mb/sm3_sve_common.S drv/hash_mb/sm3_mb_asimd_x1.S \
Expand Down
48 changes: 19 additions & 29 deletions drv/hash_mb/hash_mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,52 +186,41 @@ static int hash_mb_queue_init(struct wd_ctx_config_internal *config)
return ret;
}

static int hash_mb_init(struct wd_alg_driver *drv, void *conf)
static int hash_mb_init(void *conf, void *priv)
{
struct wd_ctx_config_internal *config = conf;
struct hash_mb_ctx *priv;
int ret;
struct hash_mb_ctx *mb_ctx = priv;

/* Fallback init is NULL */
if (!drv || !conf)
if (!conf || !priv)
return 0;

priv = malloc(sizeof(struct hash_mb_ctx));
if (!priv)
return -WD_ENOMEM;

/* multibuff does not use epoll. */
config->epoll_en = 0;
memcpy(&priv->config, config, sizeof(struct wd_ctx_config_internal));

ret = hash_mb_queue_init(config);
if (ret) {
free(priv);
return ret;
}
memcpy(&mb_ctx->config, config, sizeof(struct wd_ctx_config_internal));

drv->priv = priv;

return WD_SUCCESS;
return hash_mb_queue_init(config);
}

static void hash_mb_exit(struct wd_alg_driver *drv)
static void hash_mb_exit(void *priv)
{
if(!drv || !drv->priv)
return;
struct hash_mb_ctx *mb_ctx = priv;
struct wd_ctx_config_internal *config;

struct hash_mb_ctx *priv = (struct hash_mb_ctx *)drv->priv;
if (!priv) {
WD_ERR("invalid: input parameter is NULL!\n");
return;
}

hash_mb_queue_uninit(&priv->config, priv->config.ctx_num);
free(priv);
drv->priv = NULL;
config = &mb_ctx->config;
hash_mb_queue_uninit(config, config->ctx_num);
}

static void hash_mb_pad_data(struct hash_pad *hash_pad, __u8 *in, __u32 partial,
__u64 total_len, bool transfer)
{
__u64 size = total_len << BYTES_TO_BITS_OFFSET;
__u8 *buffer = hash_pad->pad;
__u64 size = total_len << 3;

if (partial)
memcpy(buffer, in, partial);
Expand Down Expand Up @@ -266,7 +255,7 @@ static inline void hash_xor(__u8 *key_out, __u8 *key_in, __u32 key_len, __u8 xor
if (i < key_len)
key_out[i] = key_in[i] ^ xor_value;
else
key_out[i] = xor_value;
key_out[i] = 0x0 ^ xor_value;
}
}

Expand Down Expand Up @@ -554,7 +543,7 @@ static int hash_mb_check_param(struct hash_mb_queue *mb_queue, struct wd_digest_
return WD_SUCCESS;
}

static int hash_mb_send(struct wd_alg_driver *drv, handle_t ctx, void *drv_msg)
static int hash_mb_send(handle_t ctx, void *drv_msg)
{
struct wd_soft_ctx *s_ctx = (struct wd_soft_ctx *)ctx;
struct hash_mb_queue *mb_queue = s_ctx->priv;
Expand Down Expand Up @@ -775,7 +764,7 @@ static int hash_mb_do_jobs(struct hash_mb_queue *mb_queue)
return WD_SUCCESS;
}

static int hash_mb_recv(struct wd_alg_driver *drv, handle_t ctx, void *drv_msg)
static int hash_mb_recv(handle_t ctx, void *drv_msg)
{
struct wd_soft_ctx *s_ctx = (struct wd_soft_ctx *)ctx;
struct hash_mb_queue *mb_queue = s_ctx->priv;
Expand Down Expand Up @@ -809,6 +798,7 @@ static int hash_mb_get_usage(void *param)
.alg_name = (hash_alg_name),\
.calc_type = UADK_ALG_SVE_INSTR,\
.priority = 100,\
.priv_size = sizeof(struct hash_mb_ctx),\
.queue_num = 1,\
.op_type_num = 1,\
.fallback = 0,\
Expand Down
32 changes: 12 additions & 20 deletions drv/hisi_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,11 +790,11 @@ static void hisi_zip_sqe_ops_adapt(handle_t h_qp)
}
}

static int hisi_zip_init(struct wd_alg_driver *drv, void *conf)
static int hisi_zip_init(void *conf, void *priv)
{
struct wd_ctx_config_internal *config = conf;
struct hisi_zip_ctx *zip_ctx = (struct hisi_zip_ctx *)priv;
struct hisi_qm_priv qm_priv;
struct hisi_zip_ctx *priv;
handle_t h_qp = 0;
handle_t h_ctx;
__u32 i, j;
Expand All @@ -804,13 +804,12 @@ static int hisi_zip_init(struct wd_alg_driver *drv, void *conf)
return -WD_EINVAL;
}

priv = malloc(sizeof(struct hisi_zip_ctx));
if (!priv)
return -WD_EINVAL;

memcpy(&priv->config, config, sizeof(struct wd_ctx_config_internal));
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 ||
!config->ctxs[i].ctx)
continue;
h_ctx = config->ctxs[i].ctx;
qm_priv.sqe_size = sizeof(struct hisi_zip_sqe);
qm_priv.op_type = config->ctxs[i].op_type;
Expand All @@ -826,35 +825,27 @@ static int hisi_zip_init(struct wd_alg_driver *drv, void *conf)
}

hisi_zip_sqe_ops_adapt(h_qp);
drv->priv = priv;

return 0;
out:
for (j = 0; j < i; j++) {
h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[j].ctx);
hisi_qm_free_qp(h_qp);
}
free(priv);
return -WD_EINVAL;
}

static void hisi_zip_exit(struct wd_alg_driver *drv)
static void hisi_zip_exit(void *priv)
{
if(!drv || !drv->priv)
return;

struct hisi_zip_ctx *priv = (struct hisi_zip_ctx *)drv->priv;
struct wd_ctx_config_internal *config;
struct hisi_zip_ctx *zip_ctx = (struct hisi_zip_ctx *)priv;
struct wd_ctx_config_internal *config = &zip_ctx->config;
handle_t h_qp;
__u32 i;

config = &priv->config;
for (i = 0; i < config->ctx_num; i++) {
h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[i].ctx);
hisi_qm_free_qp(h_qp);
}
free(priv);
drv->priv = NULL;
}

static int fill_zip_comp_sqe(struct hisi_qp *qp, struct wd_comp_msg *msg,
Expand Down Expand Up @@ -934,7 +925,7 @@ static void free_hw_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe,
}
}

static int hisi_zip_comp_send(struct wd_alg_driver *drv, handle_t ctx, void *comp_msg)
static int hisi_zip_comp_send(handle_t ctx, void *comp_msg)
{
struct hisi_qp *qp = wd_ctx_get_priv(ctx);
struct wd_comp_msg *msg = comp_msg;
Expand Down Expand Up @@ -1078,7 +1069,7 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe,
return 0;
}

static int hisi_zip_comp_recv(struct wd_alg_driver *drv, handle_t ctx, void *comp_msg)
static int hisi_zip_comp_recv(handle_t ctx, void *comp_msg)
{
struct hisi_qp *qp = wd_ctx_get_priv(ctx);
struct wd_comp_msg *recv_msg = comp_msg;
Expand All @@ -1100,6 +1091,7 @@ static int hisi_zip_comp_recv(struct wd_alg_driver *drv, handle_t ctx, void *com
.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,\
.fallback = 0,\
Expand Down
39 changes: 18 additions & 21 deletions drv/hisi_dae.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ static int check_hashagg_param(struct wd_agg_msg *msg)
return WD_SUCCESS;
}

static int hashagg_send(struct wd_alg_driver *drv, handle_t ctx, void *hashagg_msg)
static int hashagg_send(handle_t ctx, void *hashagg_msg)
{
handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx);
struct hisi_qp *qp = (struct hisi_qp *)h_qp;
Expand Down Expand Up @@ -657,7 +657,7 @@ static void fill_hashagg_msg_task_err(struct dae_sqe *sqe, struct wd_agg_msg *ms
}
}

static int hashagg_recv(struct wd_alg_driver *drv, handle_t ctx, void *hashagg_msg)
static int hashagg_recv(handle_t ctx, void *hashagg_msg)
{
handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx);
struct hisi_qp *qp = (struct hisi_qp *)h_qp;
Expand Down Expand Up @@ -1554,11 +1554,11 @@ static int dae_hash_table_init(struct wd_dae_hash_table *hash_table, void *priv)
return ret;
}

static int dae_init(struct wd_alg_driver *drv, void *conf)
static int dae_init(void *conf, void *priv)
{
struct wd_ctx_config_internal *config = conf;
struct hisi_dae_ctx *dae_ctx = priv;
struct hisi_qm_priv qm_priv;
struct hisi_dae_ctx *priv;
handle_t h_qp = 0;
handle_t h_ctx;
__u32 i, j;
Expand All @@ -1569,14 +1569,13 @@ static int dae_init(struct wd_alg_driver *drv, void *conf)
return -WD_EINVAL;
}

priv = malloc(sizeof(struct hisi_dae_ctx));
if (!priv)
return -WD_ENOMEM;

qm_priv.op_type = DAE_HASH_AGG_TYPE;
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 ||
!config->ctxs[i].ctx)
continue;
h_ctx = config->ctxs[i].ctx;
qm_priv.qp_mode = config->ctxs[i].ctx_mode;
/* Setting the epoll en to 0 for ASYNC ctx */
Expand All @@ -1593,10 +1592,9 @@ static int dae_init(struct wd_alg_driver *drv, void *conf)
if (ret)
goto free_h_qp;
}
memcpy(&priv->config, config, sizeof(struct wd_ctx_config_internal));
drv->priv = priv;
memcpy(&dae_ctx->config, config, sizeof(struct wd_ctx_config_internal));

return WD_SUCCESS;
return 0;

free_h_qp:
hisi_qm_free_qp(h_qp);
Expand All @@ -1606,29 +1604,27 @@ static int dae_init(struct wd_alg_driver *drv, void *conf)
dae_uninit_qp_priv(h_qp);
hisi_qm_free_qp(h_qp);
}
free(priv);
return ret;
}

static void dae_exit(struct wd_alg_driver *drv)
static void dae_exit(void *priv)
{
if(!drv || !drv->priv)
return;

struct hisi_dae_ctx *priv = (struct hisi_dae_ctx *)drv->priv;
struct hisi_dae_ctx *dae_ctx = priv;
struct wd_ctx_config_internal *config;
handle_t h_qp;
__u32 i;

config = &priv->config;
if (!priv) {
WD_ERR("invalid: input parameter is NULL!\n");
return;
}

config = &dae_ctx->config;
for (i = 0; i < config->ctx_num; i++) {
h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[i].ctx);
dae_uninit_qp_priv(h_qp);
hisi_qm_free_qp(h_qp);
}

free(priv);
drv->priv = NULL;
}

static int dae_get_usage(void *param)
Expand Down Expand Up @@ -1656,6 +1652,7 @@ static struct wd_alg_driver hashagg_driver = {
.alg_name = "hashagg",
.calc_type = UADK_ALG_HW,
.priority = 100,
.priv_size = sizeof(struct hisi_dae_ctx),
.queue_num = DAE_CTX_Q_NUM_DEF,
.op_type_num = 1,
.fallback = 0,
Expand Down
Loading