Creating a CoMP Context and Block Memory Pool
You can also skip the following and use the wd_send/wd_recv interface to send/receive CoMP messages based on q. However, you need to fill in messages according to the algorithm message structure requirements. In addition, the input and key must use the memory reserved by the WD based on q. The interface is described in Memory Reservation Interface.
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; } |
Parent topic: CoMP Synchronization Interface Usage Examples