Lines Matching refs:rctx
240 static void ocs_aes_init_rctx(struct ocs_aes_rctx *rctx) in ocs_aes_init_rctx() argument
243 memset(rctx, 0, sizeof(*rctx)); in ocs_aes_init_rctx()
246 rctx->src_dll.dma_addr = DMA_MAPPING_ERROR; in ocs_aes_init_rctx()
247 rctx->dst_dll.dma_addr = DMA_MAPPING_ERROR; in ocs_aes_init_rctx()
248 rctx->aad_src_dll.dma_addr = DMA_MAPPING_ERROR; in ocs_aes_init_rctx()
249 rctx->aad_dst_dll.dma_addr = DMA_MAPPING_ERROR; in ocs_aes_init_rctx()
314 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_common() local
357 ocs_aes_init_rctx(rctx); in kmb_ocs_sk_common()
358 rctx->instruction = instruction; in kmb_ocs_sk_common()
359 rctx->mode = mode; in kmb_ocs_sk_common()
377 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_dma_cleanup() local
381 if (rctx->src_dma_count) { in kmb_ocs_sk_dma_cleanup()
382 dma_unmap_sg(dev, req->src, rctx->src_nents, DMA_TO_DEVICE); in kmb_ocs_sk_dma_cleanup()
383 rctx->src_dma_count = 0; in kmb_ocs_sk_dma_cleanup()
386 if (rctx->dst_dma_count) { in kmb_ocs_sk_dma_cleanup()
387 dma_unmap_sg(dev, req->dst, rctx->dst_nents, rctx->in_place ? in kmb_ocs_sk_dma_cleanup()
390 rctx->dst_dma_count = 0; in kmb_ocs_sk_dma_cleanup()
394 cleanup_ocs_dma_linked_list(dev, &rctx->src_dll); in kmb_ocs_sk_dma_cleanup()
395 cleanup_ocs_dma_linked_list(dev, &rctx->dst_dll); in kmb_ocs_sk_dma_cleanup()
401 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_prepare_inplace() local
413 if (rctx->mode == OCS_MODE_CBC && rctx->instruction == OCS_DECRYPT) in kmb_ocs_sk_prepare_inplace()
414 scatterwalk_map_and_copy(rctx->last_ct_blk, req->src, in kmb_ocs_sk_prepare_inplace()
418 if (rctx->cts_swap && rctx->instruction == OCS_DECRYPT) in kmb_ocs_sk_prepare_inplace()
419 sg_swap_blocks(req->dst, rctx->dst_nents, in kmb_ocs_sk_prepare_inplace()
424 rctx->dst_dma_count = dma_map_sg(tctx->aes_dev->dev, req->dst, in kmb_ocs_sk_prepare_inplace()
425 rctx->dst_nents, DMA_BIDIRECTIONAL); in kmb_ocs_sk_prepare_inplace()
426 if (rctx->dst_dma_count == 0) { in kmb_ocs_sk_prepare_inplace()
433 rctx->dst_dma_count, &rctx->dst_dll, in kmb_ocs_sk_prepare_inplace()
442 rctx->src_dll.dma_addr = rctx->dst_dll.dma_addr; in kmb_ocs_sk_prepare_inplace()
450 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_prepare_notinplace() local
454 rctx->src_nents = sg_nents_for_len(req->src, req->cryptlen); in kmb_ocs_sk_prepare_notinplace()
455 if (rctx->src_nents < 0) in kmb_ocs_sk_prepare_notinplace()
459 rctx->src_dma_count = dma_map_sg(tctx->aes_dev->dev, req->src, in kmb_ocs_sk_prepare_notinplace()
460 rctx->src_nents, DMA_TO_DEVICE); in kmb_ocs_sk_prepare_notinplace()
461 if (rctx->src_dma_count == 0) { in kmb_ocs_sk_prepare_notinplace()
468 rctx->src_dma_count, &rctx->src_dll, in kmb_ocs_sk_prepare_notinplace()
474 rctx->dst_dma_count = dma_map_sg(tctx->aes_dev->dev, req->dst, in kmb_ocs_sk_prepare_notinplace()
475 rctx->dst_nents, DMA_FROM_DEVICE); in kmb_ocs_sk_prepare_notinplace()
476 if (rctx->dst_dma_count == 0) { in kmb_ocs_sk_prepare_notinplace()
483 rctx->dst_dma_count, &rctx->dst_dll, in kmb_ocs_sk_prepare_notinplace()
489 if (!(rctx->cts_swap && rctx->instruction == OCS_DECRYPT)) in kmb_ocs_sk_prepare_notinplace()
499 rc = ocs_aes_bypass_op(tctx->aes_dev, rctx->dst_dll.dma_addr, in kmb_ocs_sk_prepare_notinplace()
500 rctx->src_dll.dma_addr, req->cryptlen); in kmb_ocs_sk_prepare_notinplace()
509 rctx->in_place = true; in kmb_ocs_sk_prepare_notinplace()
517 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_run() local
523 rctx->dst_nents = sg_nents_for_len(req->dst, req->cryptlen); in kmb_ocs_sk_run()
524 if (rctx->dst_nents < 0) in kmb_ocs_sk_run()
535 rctx->cts_swap = (rctx->mode == OCS_MODE_CTS && in kmb_ocs_sk_run()
539 rctx->in_place = (req->src == req->dst); in kmb_ocs_sk_run()
541 if (rctx->in_place) in kmb_ocs_sk_run()
549 rc = ocs_aes_op(aes_dev, rctx->mode, tctx->cipher, rctx->instruction, in kmb_ocs_sk_run()
550 rctx->dst_dll.dma_addr, rctx->src_dll.dma_addr, in kmb_ocs_sk_run()
559 if (rctx->cts_swap && rctx->instruction == OCS_ENCRYPT) { in kmb_ocs_sk_run()
560 sg_swap_blocks(req->dst, rctx->dst_nents, in kmb_ocs_sk_run()
567 if (rctx->mode == OCS_MODE_CBC) { in kmb_ocs_sk_run()
569 if (rctx->instruction == OCS_ENCRYPT) { in kmb_ocs_sk_run()
576 if (rctx->in_place) in kmb_ocs_sk_run()
577 memcpy(req->iv, rctx->last_ct_blk, iv_size); in kmb_ocs_sk_run()
641 struct ocs_aes_rctx *rctx = aead_request_ctx(req); in kmb_ocs_aead_common() local
675 ocs_aes_init_rctx(rctx); in kmb_ocs_aead_common()
676 rctx->instruction = instruction; in kmb_ocs_aead_common()
677 rctx->mode = mode; in kmb_ocs_aead_common()
685 struct ocs_aes_rctx *rctx = aead_request_ctx(req); in kmb_ocs_aead_dma_cleanup() local
688 if (rctx->src_dma_count) { in kmb_ocs_aead_dma_cleanup()
689 dma_unmap_sg(dev, req->src, rctx->src_nents, DMA_TO_DEVICE); in kmb_ocs_aead_dma_cleanup()
690 rctx->src_dma_count = 0; in kmb_ocs_aead_dma_cleanup()
693 if (rctx->dst_dma_count) { in kmb_ocs_aead_dma_cleanup()
694 dma_unmap_sg(dev, req->dst, rctx->dst_nents, rctx->in_place ? in kmb_ocs_aead_dma_cleanup()
697 rctx->dst_dma_count = 0; in kmb_ocs_aead_dma_cleanup()
700 cleanup_ocs_dma_linked_list(dev, &rctx->src_dll); in kmb_ocs_aead_dma_cleanup()
701 cleanup_ocs_dma_linked_list(dev, &rctx->dst_dll); in kmb_ocs_aead_dma_cleanup()
702 cleanup_ocs_dma_linked_list(dev, &rctx->aad_src_dll); in kmb_ocs_aead_dma_cleanup()
703 cleanup_ocs_dma_linked_list(dev, &rctx->aad_dst_dll); in kmb_ocs_aead_dma_cleanup()
723 struct ocs_aes_rctx *rctx = aead_request_ctx(req); in kmb_ocs_aead_dma_prepare() local
730 rctx->src_nents = sg_nents_for_len(req->src, in kmb_ocs_aead_dma_prepare()
732 if (rctx->src_nents < 0) in kmb_ocs_aead_dma_prepare()
735 if (rctx->instruction == OCS_DECRYPT) { in kmb_ocs_aead_dma_prepare()
758 sg_pcopy_to_buffer(req->src, rctx->src_nents, rctx->in_tag, in kmb_ocs_aead_dma_prepare()
775 out_size = (rctx->mode == OCS_MODE_CCM) ? in_size + tag_size : in kmb_ocs_aead_dma_prepare()
783 rctx->dst_nents = sg_nents_for_len(req->dst, dst_size); in kmb_ocs_aead_dma_prepare()
784 if (rctx->dst_nents < 0) in kmb_ocs_aead_dma_prepare()
787 rctx->in_place = (req->src == req->dst) ? 1 : 0; in kmb_ocs_aead_dma_prepare()
790 rctx->dst_dma_count = dma_map_sg(tctx->aes_dev->dev, req->dst, in kmb_ocs_aead_dma_prepare()
791 rctx->dst_nents, in kmb_ocs_aead_dma_prepare()
792 rctx->in_place ? DMA_BIDIRECTIONAL : in kmb_ocs_aead_dma_prepare()
794 if (rctx->dst_dma_count == 0 && rctx->dst_nents != 0) { in kmb_ocs_aead_dma_prepare()
801 rctx->dst_dma_count, in kmb_ocs_aead_dma_prepare()
802 &rctx->aad_dst_dll, req->assoclen, in kmb_ocs_aead_dma_prepare()
809 rctx->dst_dma_count, &rctx->dst_dll, in kmb_ocs_aead_dma_prepare()
814 if (rctx->in_place) { in kmb_ocs_aead_dma_prepare()
816 if (!(rctx->mode == OCS_MODE_CCM && in kmb_ocs_aead_dma_prepare()
817 rctx->instruction == OCS_ENCRYPT)) { in kmb_ocs_aead_dma_prepare()
823 rctx->src_dll.dma_addr = rctx->dst_dll.dma_addr; in kmb_ocs_aead_dma_prepare()
824 rctx->aad_src_dll.dma_addr = rctx->aad_dst_dll.dma_addr; in kmb_ocs_aead_dma_prepare()
834 rctx->dst_dma_count, in kmb_ocs_aead_dma_prepare()
835 &rctx->aad_src_dll, in kmb_ocs_aead_dma_prepare()
840 rctx->dst_dma_count, in kmb_ocs_aead_dma_prepare()
841 &rctx->src_dll, in_size, in kmb_ocs_aead_dma_prepare()
851 rctx->src_dma_count = dma_map_sg(tctx->aes_dev->dev, req->src, in kmb_ocs_aead_dma_prepare()
852 rctx->src_nents, DMA_TO_DEVICE); in kmb_ocs_aead_dma_prepare()
853 if (rctx->src_dma_count == 0 && rctx->src_nents != 0) { in kmb_ocs_aead_dma_prepare()
860 rctx->src_dma_count, in kmb_ocs_aead_dma_prepare()
861 &rctx->aad_src_dll, in kmb_ocs_aead_dma_prepare()
868 rctx->src_dma_count, in kmb_ocs_aead_dma_prepare()
869 &rctx->src_dll, in_size, in kmb_ocs_aead_dma_prepare()
878 rc = ocs_aes_bypass_op(tctx->aes_dev, rctx->aad_dst_dll.dma_addr, in kmb_ocs_aead_dma_prepare()
879 rctx->aad_src_dll.dma_addr, req->cryptlen); in kmb_ocs_aead_dma_prepare()
891 struct ocs_aes_rctx *rctx = aead_request_ctx(req); in kmb_ocs_aead_run() local
900 if (rctx->mode == OCS_MODE_CCM) { in kmb_ocs_aead_run()
902 rctx->instruction, rctx->dst_dll.dma_addr, in kmb_ocs_aead_run()
903 rctx->src_dll.dma_addr, in_size, in kmb_ocs_aead_run()
905 rctx->aad_src_dll.dma_addr, req->assoclen, in kmb_ocs_aead_run()
906 rctx->in_tag, tag_size); in kmb_ocs_aead_run()
911 rctx->instruction, in kmb_ocs_aead_run()
912 rctx->dst_dll.dma_addr, in kmb_ocs_aead_run()
913 rctx->src_dll.dma_addr, in_size, in kmb_ocs_aead_run()
915 rctx->aad_src_dll.dma_addr, req->assoclen, in kmb_ocs_aead_run()
916 rctx->out_tag, tag_size); in kmb_ocs_aead_run()
921 if (rctx->instruction == OCS_DECRYPT) { in kmb_ocs_aead_run()
922 rc = memcmp(rctx->in_tag, rctx->out_tag, tag_size) ? in kmb_ocs_aead_run()
933 sg_pcopy_from_buffer(req->dst, rctx->dst_nents, rctx->out_tag, in kmb_ocs_aead_run()