Lines Matching refs:nx_ctx
53 int nx_hcall_sync(struct nx_crypto_ctx *nx_ctx, in nx_hcall_sync() argument
60 atomic_inc(&(nx_ctx->stats->sync_ops)); in nx_hcall_sync()
69 atomic_inc(&(nx_ctx->stats->errors)); in nx_hcall_sync()
70 atomic_set(&(nx_ctx->stats->last_error), op->hcall_err); in nx_hcall_sync()
71 atomic_set(&(nx_ctx->stats->last_error_pid), current->pid); in nx_hcall_sync()
271 int nx_build_sg_lists(struct nx_crypto_ctx *nx_ctx, in nx_build_sg_lists() argument
281 struct nx_sg *nx_insg = nx_ctx->in_sg; in nx_build_sg_lists()
282 struct nx_sg *nx_outsg = nx_ctx->out_sg; in nx_build_sg_lists()
285 max_sg_len = min_t(u64, nx_ctx->ap->sglen, in nx_build_sg_lists()
288 nx_ctx->ap->databytelen/NX_PAGE_SIZE); in nx_build_sg_lists()
293 *nbytes = min_t(u64, *nbytes, nx_ctx->ap->databytelen); in nx_build_sg_lists()
306 nx_ctx->op.inlen = trim_sg_list(nx_ctx->in_sg, nx_insg, delta, nbytes); in nx_build_sg_lists()
307 nx_ctx->op.outlen = trim_sg_list(nx_ctx->out_sg, nx_outsg, delta, nbytes); in nx_build_sg_lists()
318 void nx_ctx_init(struct nx_crypto_ctx *nx_ctx, unsigned int function) in nx_ctx_init() argument
320 spin_lock_init(&nx_ctx->lock); in nx_ctx_init()
321 memset(nx_ctx->kmem, 0, nx_ctx->kmem_len); in nx_ctx_init()
322 nx_ctx->csbcpb->csb.valid |= NX_CSB_VALID_BIT; in nx_ctx_init()
324 nx_ctx->op.flags = function; in nx_ctx_init()
325 nx_ctx->op.csbcpb = __pa(nx_ctx->csbcpb); in nx_ctx_init()
326 nx_ctx->op.in = __pa(nx_ctx->in_sg); in nx_ctx_init()
327 nx_ctx->op.out = __pa(nx_ctx->out_sg); in nx_ctx_init()
329 if (nx_ctx->csbcpb_aead) { in nx_ctx_init()
330 nx_ctx->csbcpb_aead->csb.valid |= NX_CSB_VALID_BIT; in nx_ctx_init()
332 nx_ctx->op_aead.flags = function; in nx_ctx_init()
333 nx_ctx->op_aead.csbcpb = __pa(nx_ctx->csbcpb_aead); in nx_ctx_init()
334 nx_ctx->op_aead.in = __pa(nx_ctx->in_sg); in nx_ctx_init()
335 nx_ctx->op_aead.out = __pa(nx_ctx->out_sg); in nx_ctx_init()
667 static int nx_crypto_ctx_init(struct nx_crypto_ctx *nx_ctx, u32 fc, u32 mode) in nx_crypto_ctx_init() argument
677 nx_ctx->kmem_len = (5 * NX_PAGE_SIZE) + in nx_crypto_ctx_init()
680 nx_ctx->kmem_len = (4 * NX_PAGE_SIZE) + in nx_crypto_ctx_init()
683 nx_ctx->kmem = kmalloc(nx_ctx->kmem_len, GFP_KERNEL); in nx_crypto_ctx_init()
684 if (!nx_ctx->kmem) in nx_crypto_ctx_init()
688 nx_ctx->csbcpb = (struct nx_csbcpb *)(round_up((u64)nx_ctx->kmem, in nx_crypto_ctx_init()
690 nx_ctx->in_sg = (struct nx_sg *)((u8 *)nx_ctx->csbcpb + NX_PAGE_SIZE); in nx_crypto_ctx_init()
691 nx_ctx->out_sg = (struct nx_sg *)((u8 *)nx_ctx->in_sg + NX_PAGE_SIZE); in nx_crypto_ctx_init()
694 nx_ctx->csbcpb_aead = in nx_crypto_ctx_init()
695 (struct nx_csbcpb *)((u8 *)nx_ctx->out_sg + in nx_crypto_ctx_init()
700 nx_ctx->stats = &nx_driver.stats; in nx_crypto_ctx_init()
701 memcpy(nx_ctx->props, nx_driver.of.ap[fc][mode], in nx_crypto_ctx_init()
761 struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(tfm); in nx_crypto_ctx_exit() local
763 kzfree(nx_ctx->kmem); in nx_crypto_ctx_exit()
764 nx_ctx->csbcpb = NULL; in nx_crypto_ctx_exit()
765 nx_ctx->csbcpb_aead = NULL; in nx_crypto_ctx_exit()
766 nx_ctx->in_sg = NULL; in nx_crypto_ctx_exit()
767 nx_ctx->out_sg = NULL; in nx_crypto_ctx_exit()
772 struct nx_crypto_ctx *nx_ctx = crypto_aead_ctx(tfm); in nx_crypto_ctx_aead_exit() local
774 kzfree(nx_ctx->kmem); in nx_crypto_ctx_aead_exit()