创建COMP context和创建blk块内存池
也可不创建,直接基于第一步中的q用wd_send/wd_recv接口COMP算法消息的收发,但需严格按照算法消息结构要求来填写,且输入以及key均需采用WD基于上述第一步中的q所预留的内存,接口为内存预留接口所示的接口。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
struct wcrypto_comp_ctx_setup ctx_setup; struct wcrypto_comp_opdata *opdata; struct wcrypto_paras *priv; unsigned int block_mm_num; memset(&mm_setup, 0, sizeof(mm_setup)); mm_setup.block_size = DMEMSIZE; mm_setup.block_num = block_mm_num; mm_setup.align_size = 128; pool = wd_blkpool_create(q, &mm_setup); if (!pool) { WD_ERR("%s(): create pool fail!\n", __func__); ret = -ENOMEM; goto release_q; } in = wd_alloc_blk(pool); out = wd_alloc_blk(pool); memset(&ctx_setup, 0, sizeof(ctx_setup)); ctx_setup.alg_type = alg_type; ctx_setup.stream_mode = WCRYPTO_COMP_STATEFUL; ctx_setup.br.alloc = (void *)wd_alloc_blk; ctx_setup.br.free = (void *)wd_free_blk; ctx_setup.br.iova_map = (void *)wd_blk_iova_map; ctx_setup.br.iova_unmap = (void *)wd_blk_iova_unmap; ctx_setup.br.usr = pool; zip_ctx = wcrypto_create_comp_ctx(q, &ctx_setup); opdata = calloc(1, sizeof(struct wcrypto_comp_op_data)); opdata->in = in; opdata->out = out; opdata->stream_pos = WCRYPTO_COMP_STREAM_NEW; opdata->alg_type = ctx_setup.alg_type; ctl = calloc(1, sizeof(struct zip_ctl)); ctl->pool = pool; ctl->in = in; /* temp for opdata->in*/ ctl->out = out; ctl->ctx = zip_ctx; ctl->queue = q; ctl->opdata = opdata; zstrm->next_in = in; zstrm->next_out = out; zstrm->reserved = ctl; } |
父主题: COMP同步接口使用示例