Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright 2019 Google LLC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #ifndef _UFSHCD_CRYPTO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #define _UFSHCD_CRYPTO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #ifdef CONFIG_SCSI_UFS_CRYPTO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "ufshcd.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "ufshci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 					      struct ufshcd_lrb *lrbp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	if (!rq || !rq->crypt_keyslot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		lrbp->crypto_key_slot = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	lrbp->crypto_key_slot = blk_ksm_get_slot_idx(rq->crypt_keyslot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	lrbp->data_unit_num = rq->crypt_ctx->bc_dun[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) ufshcd_prepare_req_desc_hdr_crypto(struct ufshcd_lrb *lrbp, u32 *dword_0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 				   u32 *dword_1, u32 *dword_3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	if (lrbp->crypto_key_slot >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		*dword_0 |= UTP_REQ_DESC_CRYPTO_ENABLE_CMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		*dword_0 |= lrbp->crypto_key_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		*dword_1 = lower_32_bits(lrbp->data_unit_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		*dword_3 = upper_32_bits(lrbp->data_unit_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static inline void ufshcd_crypto_clear_prdt(struct ufs_hba *hba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 					    struct ufshcd_lrb *lrbp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	if (!(hba->quirks & UFSHCD_QUIRK_KEYS_IN_PRDT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	if (!lrbp->cmd->request->crypt_ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	memzero_explicit(lrbp->ucd_prdt_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 			 hba->sg_entry_size * scsi_sg_count(lrbp->cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) bool ufshcd_crypto_enable(struct ufs_hba *hba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void ufshcd_init_crypto(struct ufs_hba *hba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 					    struct request_queue *q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #else /* CONFIG_SCSI_UFS_CRYPTO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 					      struct ufshcd_lrb *lrbp) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ufshcd_prepare_req_desc_hdr_crypto(struct ufshcd_lrb *lrbp, u32 *dword_0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 				   u32 *dword_1, u32 *dword_3) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static inline void ufshcd_crypto_clear_prdt(struct ufs_hba *hba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 					    struct ufshcd_lrb *lrbp) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static inline bool ufshcd_crypto_enable(struct ufs_hba *hba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static inline int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static inline void ufshcd_init_crypto(struct ufs_hba *hba) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static inline void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 						struct request_queue *q) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #endif /* CONFIG_SCSI_UFS_CRYPTO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #endif /* _UFSHCD_CRYPTO_H */