Lines Matching refs:rctx
287 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req); in stm32_hash_write_ctrl() local
290 struct stm32_hash_state *state = &rctx->state; in stm32_hash_write_ctrl()
306 reg |= (rctx->data_type << HASH_CR_DATATYPE_POS); in stm32_hash_write_ctrl()
326 rctx->state.blocklen -= sizeof(u32); in stm32_hash_write_ctrl()
332 static void stm32_hash_append_sg(struct stm32_hash_request_ctx *rctx) in stm32_hash_append_sg() argument
334 struct stm32_hash_state *state = &rctx->state; in stm32_hash_append_sg()
337 while ((state->bufcnt < state->blocklen) && rctx->total) { in stm32_hash_append_sg()
338 count = min(rctx->sg->length - rctx->offset, rctx->total); in stm32_hash_append_sg()
342 if ((rctx->sg->length == 0) && !sg_is_last(rctx->sg)) { in stm32_hash_append_sg()
343 rctx->sg = sg_next(rctx->sg); in stm32_hash_append_sg()
351 rctx->sg, rctx->offset, count, 0); in stm32_hash_append_sg()
354 rctx->offset += count; in stm32_hash_append_sg()
355 rctx->total -= count; in stm32_hash_append_sg()
357 if (rctx->offset == rctx->sg->length) { in stm32_hash_append_sg()
358 rctx->sg = sg_next(rctx->sg); in stm32_hash_append_sg()
359 if (rctx->sg) in stm32_hash_append_sg()
360 rctx->offset = 0; in stm32_hash_append_sg()
362 rctx->total = 0; in stm32_hash_append_sg()
370 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req); in stm32_hash_xmit_cpu() local
371 struct stm32_hash_state *state = &rctx->state; in stm32_hash_xmit_cpu()
429 static int hash_swap_reg(struct stm32_hash_request_ctx *rctx) in hash_swap_reg() argument
431 struct stm32_hash_state *state = &rctx->state; in hash_swap_reg()
470 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req); in stm32_hash_update_cpu() local
471 struct stm32_hash_state *state = &rctx->state; in stm32_hash_update_cpu()
480 while ((rctx->total >= state->blocklen) || in stm32_hash_update_cpu()
481 (state->bufcnt + rctx->total >= state->blocklen)) { in stm32_hash_update_cpu()
482 stm32_hash_append_sg(rctx); in stm32_hash_update_cpu()
490 stm32_hash_append_sg(rctx); in stm32_hash_update_cpu()
504 swap_reg = hash_swap_reg(rctx); in stm32_hash_update_cpu()
588 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req); in stm32_hash_hmac_dma_send() local
593 if (ctx->keylen < rctx->state.blocklen || hdev->dma_mode == 1) { in stm32_hash_hmac_dma_send()
599 sg_init_one(&rctx->sg_key, ctx->key, in stm32_hash_hmac_dma_send()
602 rctx->dma_ct = dma_map_sg(hdev->dev, &rctx->sg_key, 1, in stm32_hash_hmac_dma_send()
604 if (rctx->dma_ct == 0) { in stm32_hash_hmac_dma_send()
609 err = stm32_hash_xmit_dma(hdev, &rctx->sg_key, ctx->keylen, 0); in stm32_hash_hmac_dma_send()
611 dma_unmap_sg(hdev->dev, &rctx->sg_key, 1, DMA_TO_DEVICE); in stm32_hash_hmac_dma_send()
653 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req); in stm32_hash_dma_send() local
654 u32 *buffer = (void *)rctx->state.buffer; in stm32_hash_dma_send()
660 rctx->sg = hdev->req->src; in stm32_hash_dma_send()
661 rctx->total = hdev->req->nbytes; in stm32_hash_dma_send()
663 rctx->nents = sg_nents(rctx->sg); in stm32_hash_dma_send()
664 if (rctx->nents < 0) in stm32_hash_dma_send()
675 for_each_sg(rctx->sg, tsg, rctx->nents, i) { in stm32_hash_dma_send()
679 if (sg_is_last(sg) || (bufcnt + sg[0].length) >= rctx->total) { in stm32_hash_dma_send()
680 sg->length = rctx->total - bufcnt; in stm32_hash_dma_send()
686 rctx->sg, rctx->nents, in stm32_hash_dma_send()
687 rctx->state.buffer, sg->length - len, in stm32_hash_dma_send()
688 rctx->total - sg->length + len); in stm32_hash_dma_send()
700 rctx->dma_ct = dma_map_sg(hdev->dev, sg, 1, in stm32_hash_dma_send()
702 if (rctx->dma_ct == 0) { in stm32_hash_dma_send()
771 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_dma_aligned_data() local
776 if (!hdev->dma_lch || req->nbytes <= rctx->state.blocklen) in stm32_hash_dma_aligned_data()
799 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_init() local
801 struct stm32_hash_state *state = &rctx->state; in stm32_hash_init()
804 rctx->hdev = hdev; in stm32_hash_init()
811 rctx->digcnt = crypto_ahash_digestsize(tfm); in stm32_hash_init()
812 switch (rctx->digcnt) { in stm32_hash_init()
854 rctx->state.bufcnt = 0; in stm32_hash_init()
855 rctx->state.blocklen = crypto_ahash_blocksize(tfm) + sizeof(u32); in stm32_hash_init()
856 if (rctx->state.blocklen > HASH_BUFLEN) { in stm32_hash_init()
860 rctx->total = 0; in stm32_hash_init()
861 rctx->offset = 0; in stm32_hash_init()
862 rctx->data_type = HASH_DATA_8_BITS; in stm32_hash_init()
874 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(hdev->req); in stm32_hash_update_req() local
875 struct stm32_hash_state *state = &rctx->state; in stm32_hash_update_req()
886 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_final_req() local
887 struct stm32_hash_state *state = &rctx->state; in stm32_hash_final_req()
902 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_emptymsg_fallback() local
903 struct stm32_hash_dev *hdev = rctx->hdev; in stm32_hash_emptymsg_fallback()
922 ret = crypto_shash_tfm_digest(ctx->xtfm, NULL, 0, rctx->digest); in stm32_hash_emptymsg_fallback()
930 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_copy_hash() local
931 struct stm32_hash_state *state = &rctx->state; in stm32_hash_copy_hash()
932 struct stm32_hash_dev *hdev = rctx->hdev; in stm32_hash_copy_hash()
933 __be32 *hash = (void *)rctx->digest; in stm32_hash_copy_hash()
953 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_finish() local
956 reg = stm32_hash_read(rctx->hdev, HASH_SR); in stm32_hash_finish()
958 stm32_hash_write(rctx->hdev, HASH_SR, reg); in stm32_hash_finish()
963 memcpy(req->result, rctx->digest, rctx->digcnt); in stm32_hash_finish()
970 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_finish_req() local
971 struct stm32_hash_dev *hdev = rctx->hdev; in stm32_hash_finish_req()
995 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_one_request() local
997 struct stm32_hash_state *state = &rctx->state; in stm32_hash_one_request()
1005 rctx->op, req->nbytes); in stm32_hash_one_request()
1011 swap_reg = hash_swap_reg(rctx); in stm32_hash_one_request()
1014 u32 *preg = rctx->state.hw_context; in stm32_hash_one_request()
1035 if (rctx->op == HASH_OP_UPDATE) in stm32_hash_one_request()
1037 else if (rctx->op == HASH_OP_FINAL) in stm32_hash_one_request()
1059 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_enqueue() local
1063 rctx->op = op; in stm32_hash_enqueue()
1070 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_update() local
1071 struct stm32_hash_state *state = &rctx->state; in stm32_hash_update()
1076 rctx->total = req->nbytes; in stm32_hash_update()
1077 rctx->sg = req->src; in stm32_hash_update()
1078 rctx->offset = 0; in stm32_hash_update()
1080 if ((state->bufcnt + rctx->total < state->blocklen)) { in stm32_hash_update()
1081 stm32_hash_append_sg(rctx); in stm32_hash_update()
1090 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_final() local
1091 struct stm32_hash_state *state = &rctx->state; in stm32_hash_final()
1100 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_finup() local
1103 struct stm32_hash_state *state = &rctx->state; in stm32_hash_finup()
1109 rctx->total = req->nbytes; in stm32_hash_finup()
1110 rctx->sg = req->src; in stm32_hash_finup()
1111 rctx->offset = 0; in stm32_hash_finup()
1127 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_export() local
1129 memcpy(out, &rctx->state, sizeof(rctx->state)); in stm32_hash_export()
1136 struct stm32_hash_request_ctx *rctx = ahash_request_ctx(req); in stm32_hash_import() local
1139 memcpy(&rctx->state, in, sizeof(rctx->state)); in stm32_hash_import()