Lines Matching refs:rctx
243 static void ocs_aes_init_rctx(struct ocs_aes_rctx *rctx) in ocs_aes_init_rctx() argument
246 memset(rctx, 0, sizeof(*rctx)); in ocs_aes_init_rctx()
249 rctx->src_dll.dma_addr = DMA_MAPPING_ERROR; in ocs_aes_init_rctx()
250 rctx->dst_dll.dma_addr = DMA_MAPPING_ERROR; in ocs_aes_init_rctx()
251 rctx->aad_src_dll.dma_addr = DMA_MAPPING_ERROR; in ocs_aes_init_rctx()
252 rctx->aad_dst_dll.dma_addr = DMA_MAPPING_ERROR; in ocs_aes_init_rctx()
317 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_common() local
360 ocs_aes_init_rctx(rctx); in kmb_ocs_sk_common()
361 rctx->instruction = instruction; in kmb_ocs_sk_common()
362 rctx->mode = mode; in kmb_ocs_sk_common()
380 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_dma_cleanup() local
384 if (rctx->src_dma_count) { in kmb_ocs_sk_dma_cleanup()
385 dma_unmap_sg(dev, req->src, rctx->src_nents, DMA_TO_DEVICE); in kmb_ocs_sk_dma_cleanup()
386 rctx->src_dma_count = 0; in kmb_ocs_sk_dma_cleanup()
389 if (rctx->dst_dma_count) { in kmb_ocs_sk_dma_cleanup()
390 dma_unmap_sg(dev, req->dst, rctx->dst_nents, rctx->in_place ? in kmb_ocs_sk_dma_cleanup()
393 rctx->dst_dma_count = 0; in kmb_ocs_sk_dma_cleanup()
397 cleanup_ocs_dma_linked_list(dev, &rctx->src_dll); in kmb_ocs_sk_dma_cleanup()
398 cleanup_ocs_dma_linked_list(dev, &rctx->dst_dll); in kmb_ocs_sk_dma_cleanup()
404 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_prepare_inplace() local
416 if (rctx->mode == OCS_MODE_CBC && rctx->instruction == OCS_DECRYPT) in kmb_ocs_sk_prepare_inplace()
417 scatterwalk_map_and_copy(rctx->last_ct_blk, req->src, in kmb_ocs_sk_prepare_inplace()
421 if (rctx->cts_swap && rctx->instruction == OCS_DECRYPT) in kmb_ocs_sk_prepare_inplace()
422 sg_swap_blocks(req->dst, rctx->dst_nents, in kmb_ocs_sk_prepare_inplace()
427 rctx->dst_dma_count = dma_map_sg(tctx->aes_dev->dev, req->dst, in kmb_ocs_sk_prepare_inplace()
428 rctx->dst_nents, DMA_BIDIRECTIONAL); in kmb_ocs_sk_prepare_inplace()
429 if (rctx->dst_dma_count == 0) { in kmb_ocs_sk_prepare_inplace()
436 rctx->dst_dma_count, &rctx->dst_dll, in kmb_ocs_sk_prepare_inplace()
445 rctx->src_dll.dma_addr = rctx->dst_dll.dma_addr; in kmb_ocs_sk_prepare_inplace()
453 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_prepare_notinplace() local
457 rctx->src_nents = sg_nents_for_len(req->src, req->cryptlen); in kmb_ocs_sk_prepare_notinplace()
458 if (rctx->src_nents < 0) in kmb_ocs_sk_prepare_notinplace()
462 rctx->src_dma_count = dma_map_sg(tctx->aes_dev->dev, req->src, in kmb_ocs_sk_prepare_notinplace()
463 rctx->src_nents, DMA_TO_DEVICE); in kmb_ocs_sk_prepare_notinplace()
464 if (rctx->src_dma_count == 0) { in kmb_ocs_sk_prepare_notinplace()
471 rctx->src_dma_count, &rctx->src_dll, in kmb_ocs_sk_prepare_notinplace()
477 rctx->dst_dma_count = dma_map_sg(tctx->aes_dev->dev, req->dst, in kmb_ocs_sk_prepare_notinplace()
478 rctx->dst_nents, DMA_FROM_DEVICE); in kmb_ocs_sk_prepare_notinplace()
479 if (rctx->dst_dma_count == 0) { in kmb_ocs_sk_prepare_notinplace()
486 rctx->dst_dma_count, &rctx->dst_dll, in kmb_ocs_sk_prepare_notinplace()
492 if (!(rctx->cts_swap && rctx->instruction == OCS_DECRYPT)) in kmb_ocs_sk_prepare_notinplace()
502 rc = ocs_aes_bypass_op(tctx->aes_dev, rctx->dst_dll.dma_addr, in kmb_ocs_sk_prepare_notinplace()
503 rctx->src_dll.dma_addr, req->cryptlen); in kmb_ocs_sk_prepare_notinplace()
512 rctx->in_place = true; in kmb_ocs_sk_prepare_notinplace()
520 struct ocs_aes_rctx *rctx = skcipher_request_ctx(req); in kmb_ocs_sk_run() local
526 rctx->dst_nents = sg_nents_for_len(req->dst, req->cryptlen); in kmb_ocs_sk_run()
527 if (rctx->dst_nents < 0) in kmb_ocs_sk_run()
538 rctx->cts_swap = (rctx->mode == OCS_MODE_CTS && in kmb_ocs_sk_run()
542 rctx->in_place = (req->src == req->dst); in kmb_ocs_sk_run()
544 if (rctx->in_place) in kmb_ocs_sk_run()
552 rc = ocs_aes_op(aes_dev, rctx->mode, tctx->cipher, rctx->instruction, in kmb_ocs_sk_run()
553 rctx->dst_dll.dma_addr, rctx->src_dll.dma_addr, in kmb_ocs_sk_run()
562 if (rctx->cts_swap && rctx->instruction == OCS_ENCRYPT) { in kmb_ocs_sk_run()
563 sg_swap_blocks(req->dst, rctx->dst_nents, in kmb_ocs_sk_run()
570 if (rctx->mode == OCS_MODE_CBC) { in kmb_ocs_sk_run()
572 if (rctx->instruction == OCS_ENCRYPT) { in kmb_ocs_sk_run()
579 if (rctx->in_place) in kmb_ocs_sk_run()
580 memcpy(req->iv, rctx->last_ct_blk, iv_size); in kmb_ocs_sk_run()
644 struct ocs_aes_rctx *rctx = aead_request_ctx(req); in kmb_ocs_aead_common() local
678 ocs_aes_init_rctx(rctx); in kmb_ocs_aead_common()
679 rctx->instruction = instruction; in kmb_ocs_aead_common()
680 rctx->mode = mode; in kmb_ocs_aead_common()
688 struct ocs_aes_rctx *rctx = aead_request_ctx(req); in kmb_ocs_aead_dma_cleanup() local
691 if (rctx->src_dma_count) { in kmb_ocs_aead_dma_cleanup()
692 dma_unmap_sg(dev, req->src, rctx->src_nents, DMA_TO_DEVICE); in kmb_ocs_aead_dma_cleanup()
693 rctx->src_dma_count = 0; in kmb_ocs_aead_dma_cleanup()
696 if (rctx->dst_dma_count) { in kmb_ocs_aead_dma_cleanup()
697 dma_unmap_sg(dev, req->dst, rctx->dst_nents, rctx->in_place ? in kmb_ocs_aead_dma_cleanup()
700 rctx->dst_dma_count = 0; in kmb_ocs_aead_dma_cleanup()
703 cleanup_ocs_dma_linked_list(dev, &rctx->src_dll); in kmb_ocs_aead_dma_cleanup()
704 cleanup_ocs_dma_linked_list(dev, &rctx->dst_dll); in kmb_ocs_aead_dma_cleanup()
705 cleanup_ocs_dma_linked_list(dev, &rctx->aad_src_dll); in kmb_ocs_aead_dma_cleanup()
706 cleanup_ocs_dma_linked_list(dev, &rctx->aad_dst_dll); in kmb_ocs_aead_dma_cleanup()
726 struct ocs_aes_rctx *rctx = aead_request_ctx(req); in kmb_ocs_aead_dma_prepare() local
733 rctx->src_nents = sg_nents_for_len(req->src, in kmb_ocs_aead_dma_prepare()
735 if (rctx->src_nents < 0) in kmb_ocs_aead_dma_prepare()
738 if (rctx->instruction == OCS_DECRYPT) { in kmb_ocs_aead_dma_prepare()
761 sg_pcopy_to_buffer(req->src, rctx->src_nents, rctx->in_tag, in kmb_ocs_aead_dma_prepare()
778 out_size = (rctx->mode == OCS_MODE_CCM) ? in_size + tag_size : in kmb_ocs_aead_dma_prepare()
786 rctx->dst_nents = sg_nents_for_len(req->dst, dst_size); in kmb_ocs_aead_dma_prepare()
787 if (rctx->dst_nents < 0) in kmb_ocs_aead_dma_prepare()
790 rctx->in_place = (req->src == req->dst) ? 1 : 0; in kmb_ocs_aead_dma_prepare()
793 rctx->dst_dma_count = dma_map_sg(tctx->aes_dev->dev, req->dst, in kmb_ocs_aead_dma_prepare()
794 rctx->dst_nents, in kmb_ocs_aead_dma_prepare()
795 rctx->in_place ? DMA_BIDIRECTIONAL : in kmb_ocs_aead_dma_prepare()
797 if (rctx->dst_dma_count == 0 && rctx->dst_nents != 0) { in kmb_ocs_aead_dma_prepare()
804 rctx->dst_dma_count, in kmb_ocs_aead_dma_prepare()
805 &rctx->aad_dst_dll, req->assoclen, in kmb_ocs_aead_dma_prepare()
812 rctx->dst_dma_count, &rctx->dst_dll, in kmb_ocs_aead_dma_prepare()
817 if (rctx->in_place) { in kmb_ocs_aead_dma_prepare()
819 if (!(rctx->mode == OCS_MODE_CCM && in kmb_ocs_aead_dma_prepare()
820 rctx->instruction == OCS_ENCRYPT)) { in kmb_ocs_aead_dma_prepare()
826 rctx->src_dll.dma_addr = rctx->dst_dll.dma_addr; in kmb_ocs_aead_dma_prepare()
827 rctx->aad_src_dll.dma_addr = rctx->aad_dst_dll.dma_addr; in kmb_ocs_aead_dma_prepare()
837 rctx->dst_dma_count, in kmb_ocs_aead_dma_prepare()
838 &rctx->aad_src_dll, in kmb_ocs_aead_dma_prepare()
843 rctx->dst_dma_count, in kmb_ocs_aead_dma_prepare()
844 &rctx->src_dll, in_size, in kmb_ocs_aead_dma_prepare()
854 rctx->src_dma_count = dma_map_sg(tctx->aes_dev->dev, req->src, in kmb_ocs_aead_dma_prepare()
855 rctx->src_nents, DMA_TO_DEVICE); in kmb_ocs_aead_dma_prepare()
856 if (rctx->src_dma_count == 0 && rctx->src_nents != 0) { in kmb_ocs_aead_dma_prepare()
863 rctx->src_dma_count, in kmb_ocs_aead_dma_prepare()
864 &rctx->aad_src_dll, in kmb_ocs_aead_dma_prepare()
871 rctx->src_dma_count, in kmb_ocs_aead_dma_prepare()
872 &rctx->src_dll, in_size, in kmb_ocs_aead_dma_prepare()
881 rc = ocs_aes_bypass_op(tctx->aes_dev, rctx->aad_dst_dll.dma_addr, in kmb_ocs_aead_dma_prepare()
882 rctx->aad_src_dll.dma_addr, req->cryptlen); in kmb_ocs_aead_dma_prepare()
894 struct ocs_aes_rctx *rctx = aead_request_ctx(req); in kmb_ocs_aead_run() local
903 if (rctx->mode == OCS_MODE_CCM) { in kmb_ocs_aead_run()
905 rctx->instruction, rctx->dst_dll.dma_addr, in kmb_ocs_aead_run()
906 rctx->src_dll.dma_addr, in_size, in kmb_ocs_aead_run()
908 rctx->aad_src_dll.dma_addr, req->assoclen, in kmb_ocs_aead_run()
909 rctx->in_tag, tag_size); in kmb_ocs_aead_run()
914 rctx->instruction, in kmb_ocs_aead_run()
915 rctx->dst_dll.dma_addr, in kmb_ocs_aead_run()
916 rctx->src_dll.dma_addr, in_size, in kmb_ocs_aead_run()
918 rctx->aad_src_dll.dma_addr, req->assoclen, in kmb_ocs_aead_run()
919 rctx->out_tag, tag_size); in kmb_ocs_aead_run()
924 if (rctx->instruction == OCS_DECRYPT) { in kmb_ocs_aead_run()
925 rc = memcmp(rctx->in_tag, rctx->out_tag, tag_size) ? in kmb_ocs_aead_run()
936 sg_pcopy_from_buffer(req->dst, rctx->dst_nents, rctx->out_tag, in kmb_ocs_aead_run()