Lines Matching refs:hw_ctx

236 	struct rkce_sha_contex *hw_ctx;  in rkce_sha_ctx_alloc()  local
238 hw_ctx = malloc(sizeof(*hw_ctx)); in rkce_sha_ctx_alloc()
239 if (!hw_ctx) in rkce_sha_ctx_alloc()
242 memset(hw_ctx, 0x00, sizeof(*hw_ctx)); in rkce_sha_ctx_alloc()
244 hw_ctx->td = rkce_cma_alloc(sizeof(struct rkce_hash_td)); in rkce_sha_ctx_alloc()
245 if (!hw_ctx->td) in rkce_sha_ctx_alloc()
248 memset(hw_ctx->td, 0x00, sizeof(struct rkce_hash_td)); in rkce_sha_ctx_alloc()
250 hw_ctx->td_buf = rkce_cma_alloc(sizeof(struct rkce_hash_td_buf)); in rkce_sha_ctx_alloc()
251 if (!hw_ctx->td_buf) in rkce_sha_ctx_alloc()
254 memset(hw_ctx->td_buf, 0x00, sizeof(struct rkce_hash_td_buf)); in rkce_sha_ctx_alloc()
256 return hw_ctx; in rkce_sha_ctx_alloc()
258 rkce_cma_free(hw_ctx->td); in rkce_sha_ctx_alloc()
259 rkce_cma_free(hw_ctx->td_buf); in rkce_sha_ctx_alloc()
260 free(hw_ctx); in rkce_sha_ctx_alloc()
265 static void rkce_sha_ctx_free(struct rkce_sha_contex *hw_ctx) in rkce_sha_ctx_free() argument
267 if (!hw_ctx) in rkce_sha_ctx_free()
270 rkce_cma_free(hw_ctx->td); in rkce_sha_ctx_free()
271 rkce_cma_free(hw_ctx->td_buf); in rkce_sha_ctx_free()
272 free(hw_ctx); in rkce_sha_ctx_free()
602 struct rkce_cipher_contex *hw_ctx; in rkce_cipher_ctx_alloc() local
604 hw_ctx = malloc(sizeof(*hw_ctx)); in rkce_cipher_ctx_alloc()
605 if (!hw_ctx) in rkce_cipher_ctx_alloc()
608 hw_ctx->td = rkce_cma_alloc(sizeof(struct rkce_symm_td)); in rkce_cipher_ctx_alloc()
609 if (!hw_ctx->td) in rkce_cipher_ctx_alloc()
612 memset(hw_ctx->td, 0x00, sizeof(struct rkce_symm_td)); in rkce_cipher_ctx_alloc()
614 hw_ctx->td_aad = rkce_cma_alloc(sizeof(struct rkce_symm_td)); in rkce_cipher_ctx_alloc()
615 if (!hw_ctx->td_aad) in rkce_cipher_ctx_alloc()
618 memset(hw_ctx->td_aad, 0x00, sizeof(struct rkce_symm_td)); in rkce_cipher_ctx_alloc()
620 hw_ctx->td_buf = rkce_cma_alloc(sizeof(struct rkce_symm_td_buf)); in rkce_cipher_ctx_alloc()
621 if (!hw_ctx->td_buf) in rkce_cipher_ctx_alloc()
624 memset(hw_ctx->td_buf, 0x00, sizeof(struct rkce_symm_td_buf)); in rkce_cipher_ctx_alloc()
626 return hw_ctx; in rkce_cipher_ctx_alloc()
628 rkce_cma_free(hw_ctx->td); in rkce_cipher_ctx_alloc()
629 rkce_cma_free(hw_ctx->td_aad); in rkce_cipher_ctx_alloc()
630 rkce_cma_free(hw_ctx->td_buf); in rkce_cipher_ctx_alloc()
631 free(hw_ctx); in rkce_cipher_ctx_alloc()
636 static void rkce_cipher_ctx_free(struct rkce_cipher_contex *hw_ctx) in rkce_cipher_ctx_free() argument
638 if (!hw_ctx) in rkce_cipher_ctx_free()
641 rkce_cma_free(hw_ctx->td); in rkce_cipher_ctx_free()
642 rkce_cma_free(hw_ctx->td_aad); in rkce_cipher_ctx_free()
643 rkce_cma_free(hw_ctx->td_buf); in rkce_cipher_ctx_free()
644 free(hw_ctx); in rkce_cipher_ctx_free()
756 struct rkce_cipher_contex *hw_ctx = NULL; in rk_crypto_cipher() local
770 hw_ctx = rkce_cipher_ctx_alloc(); in rk_crypto_cipher()
771 if (!hw_ctx) in rk_crypto_cipher()
774 rkce_init_symm_td(hw_ctx->td, hw_ctx->td_buf); in rk_crypto_cipher()
776 hw_ctx->td->ctrl.td_type = RKCE_TD_TYPE_SYMM; in rk_crypto_cipher()
777 hw_ctx->td->ctrl.is_dec = !enc; in rk_crypto_cipher()
778 hw_ctx->td->ctrl.symm_algo = ce_algo; in rk_crypto_cipher()
779 hw_ctx->td->ctrl.symm_mode = ce_mode; in rk_crypto_cipher()
780 hw_ctx->td->ctrl.key_size = rk_get_td_keysize(ce_algo, ce_mode, ctx->key_len); in rk_crypto_cipher()
781 hw_ctx->td->ctrl.first_pkg = 1; in rk_crypto_cipher()
782 hw_ctx->td->ctrl.last_pkg = 1; in rk_crypto_cipher()
783 hw_ctx->td->ctrl.int_en = 1; in rk_crypto_cipher()
784 hw_ctx->td->ctrl.key_sel = use_otpkey ? RKCE_KEY_SEL_KT : RKCE_KEY_SEL_USER; in rk_crypto_cipher()
786 memcpy(hw_ctx->td_buf->iv, ctx->iv, ctx->iv_len); in rk_crypto_cipher()
787 hw_ctx->td->ctrl.iv_len = ctx->iv_len; in rk_crypto_cipher()
790 ret = rk_set_symm_td_buf_key(hw_ctx->td_buf, ce_algo, ce_mode, ctx); in rk_crypto_cipher()
795 ret = rk_set_symm_td_sg(hw_ctx->td, in, len, out, len); in rk_crypto_cipher()
803 rkce_init_symm_td(hw_ctx->td_aad, hw_ctx->td_buf); in rk_crypto_cipher()
806 hw_ctx->td_buf->iv, ctx->iv_len, in rk_crypto_cipher()
808 hw_ctx->td_buf->iv, &new_iv_len); in rk_crypto_cipher()
812 ret = rk_set_symm_td_sg(hw_ctx->td_aad, new_aad, new_aad_len, NULL, 0); in rk_crypto_cipher()
816 hw_ctx->td->ctrl.iv_len = new_iv_len; in rk_crypto_cipher()
818 hw_ctx->td_buf->gcm_len.aad_len_l = new_aad_len; in rk_crypto_cipher()
820 hw_ctx->td_aad->ctrl = hw_ctx->td->ctrl; in rk_crypto_cipher()
821 hw_ctx->td_aad->ctrl.is_aad = 1; in rk_crypto_cipher()
823 crypto_flush_cacheline((ulong)hw_ctx->td_aad, sizeof(*hw_ctx->td_aad)); in rk_crypto_cipher()
824 crypto_flush_cacheline((ulong)hw_ctx->td_buf, sizeof(*hw_ctx->td_buf)); in rk_crypto_cipher()
829 ret = rkce_push_td_sync(priv->hardware, hw_ctx->td_aad, RKCE_SYMM_TIMEOUT_MS); in rk_crypto_cipher()
831 crypto_invalidate_cacheline((ulong)hw_ctx->td_buf, sizeof(*hw_ctx->td_buf)); in rk_crypto_cipher()
842 rkce_init_symm_td(hw_ctx->td_aad, hw_ctx->td_buf); in rk_crypto_cipher()
844 ret = rk_set_symm_td_sg(hw_ctx->td_aad, aad, aad_len, NULL, 0); in rk_crypto_cipher()
848 hw_ctx->td_buf->gcm_len.aad_len_l = aad_len; in rk_crypto_cipher()
849 hw_ctx->td_buf->gcm_len.pc_len_l = len; in rk_crypto_cipher()
851 hw_ctx->td_aad->ctrl = hw_ctx->td->ctrl; in rk_crypto_cipher()
852 hw_ctx->td_aad->ctrl.is_aad = 1; in rk_crypto_cipher()
854 crypto_flush_cacheline((ulong)hw_ctx->td_aad, sizeof(*hw_ctx->td_aad)); in rk_crypto_cipher()
855 crypto_flush_cacheline((ulong)hw_ctx->td_buf, sizeof(*hw_ctx->td_buf)); in rk_crypto_cipher()
860 ret = rkce_push_td_sync(priv->hardware, hw_ctx->td_aad, RKCE_SYMM_TIMEOUT_MS); in rk_crypto_cipher()
862 crypto_invalidate_cacheline((ulong)hw_ctx->td_buf, sizeof(*hw_ctx->td_buf)); in rk_crypto_cipher()
871 crypto_flush_cacheline((ulong)hw_ctx->td, sizeof(*hw_ctx->td)); in rk_crypto_cipher()
872 crypto_flush_cacheline((ulong)hw_ctx->td_buf, sizeof(*hw_ctx->td_buf)); in rk_crypto_cipher()
879 ret = rkce_push_td_sync(priv->hardware, hw_ctx->td, RKCE_SYMM_TIMEOUT_MS); in rk_crypto_cipher()
882 crypto_invalidate_cacheline((ulong)hw_ctx->td_buf, sizeof(*hw_ctx->td_buf)); in rk_crypto_cipher()
887 memcpy(tag, hw_ctx->td_buf->tag, sizeof(hw_ctx->td_buf->tag)); in rk_crypto_cipher()
889 rkce_cipher_ctx_free(hw_ctx); in rk_crypto_cipher()