LiteX: driver for MMCM
[linux/fpc-iii.git] / drivers / scsi / ufs / ufshcd-crypto.h
blobd53851be55416b81593f7712603a2ad524a80f0a
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright 2019 Google LLC
4 */
6 #ifndef _UFSHCD_CRYPTO_H
7 #define _UFSHCD_CRYPTO_H
9 #ifdef CONFIG_SCSI_UFS_CRYPTO
10 #include "ufshcd.h"
11 #include "ufshci.h"
13 static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
14 struct ufshcd_lrb *lrbp)
16 if (!rq || !rq->crypt_keyslot) {
17 lrbp->crypto_key_slot = -1;
18 return;
21 lrbp->crypto_key_slot = blk_ksm_get_slot_idx(rq->crypt_keyslot);
22 lrbp->data_unit_num = rq->crypt_ctx->bc_dun[0];
25 static inline void
26 ufshcd_prepare_req_desc_hdr_crypto(struct ufshcd_lrb *lrbp, u32 *dword_0,
27 u32 *dword_1, u32 *dword_3)
29 if (lrbp->crypto_key_slot >= 0) {
30 *dword_0 |= UTP_REQ_DESC_CRYPTO_ENABLE_CMD;
31 *dword_0 |= lrbp->crypto_key_slot;
32 *dword_1 = lower_32_bits(lrbp->data_unit_num);
33 *dword_3 = upper_32_bits(lrbp->data_unit_num);
37 bool ufshcd_crypto_enable(struct ufs_hba *hba);
39 int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba);
41 void ufshcd_init_crypto(struct ufs_hba *hba);
43 void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
44 struct request_queue *q);
46 void ufshcd_crypto_destroy_keyslot_manager(struct ufs_hba *hba);
48 #else /* CONFIG_SCSI_UFS_CRYPTO */
50 static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
51 struct ufshcd_lrb *lrbp) { }
53 static inline void
54 ufshcd_prepare_req_desc_hdr_crypto(struct ufshcd_lrb *lrbp, u32 *dword_0,
55 u32 *dword_1, u32 *dword_3) { }
57 static inline bool ufshcd_crypto_enable(struct ufs_hba *hba)
59 return false;
62 static inline int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
64 return 0;
67 static inline void ufshcd_init_crypto(struct ufs_hba *hba) { }
69 static inline void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
70 struct request_queue *q) { }
72 static inline void ufshcd_crypto_destroy_keyslot_manager(struct ufs_hba *hba)
73 { }
75 #endif /* CONFIG_SCSI_UFS_CRYPTO */
77 #endif /* _UFSHCD_CRYPTO_H */