mirror of
https://github.com/torvalds/linux.git
synced 2024-12-14 23:25:54 +00:00
df043c745e
Wire up ufshcd.c with the UFS Crypto API, the block layer inline encryption additions and the keyslot manager. Many existing inline crypto devices require some additional behaviour not specified in the UFSHCI v2.1 specification - as such the vendor specific drivers will need to be updated where necessary to make it possible to use those devices. Some of these changes have already been proposed upstream, such as for the Qualcomm 845 SoC at https://lkml.kernel.org/linux-scsi/20200501045111.665881-1-ebiggers@kernel.org/ and for ufs-mediatek at https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-stanley.chu@mediatek.com/ This patch has been tested on the db845c, sm8150-mtp and sm8250-mtp (which have Qualcomm chipsets) and on some mediatek chipsets using these aforementioned vendor specific driver updates. Link: https://lore.kernel.org/r/20200706200414.2027450-4-satyat@google.com Reviewed-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Stanley Chu <stanley.chu@mediatek.com> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Signed-off-by: Satya Tangirala <satyat@google.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
78 lines
1.9 KiB
C
78 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright 2019 Google LLC
|
|
*/
|
|
|
|
#ifndef _UFSHCD_CRYPTO_H
|
|
#define _UFSHCD_CRYPTO_H
|
|
|
|
#ifdef CONFIG_SCSI_UFS_CRYPTO
|
|
#include "ufshcd.h"
|
|
#include "ufshci.h"
|
|
|
|
static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
|
|
struct ufshcd_lrb *lrbp)
|
|
{
|
|
if (!rq || !rq->crypt_keyslot) {
|
|
lrbp->crypto_key_slot = -1;
|
|
return;
|
|
}
|
|
|
|
lrbp->crypto_key_slot = blk_ksm_get_slot_idx(rq->crypt_keyslot);
|
|
lrbp->data_unit_num = rq->crypt_ctx->bc_dun[0];
|
|
}
|
|
|
|
static inline void
|
|
ufshcd_prepare_req_desc_hdr_crypto(struct ufshcd_lrb *lrbp, u32 *dword_0,
|
|
u32 *dword_1, u32 *dword_3)
|
|
{
|
|
if (lrbp->crypto_key_slot >= 0) {
|
|
*dword_0 |= UTP_REQ_DESC_CRYPTO_ENABLE_CMD;
|
|
*dword_0 |= lrbp->crypto_key_slot;
|
|
*dword_1 = lower_32_bits(lrbp->data_unit_num);
|
|
*dword_3 = upper_32_bits(lrbp->data_unit_num);
|
|
}
|
|
}
|
|
|
|
bool ufshcd_crypto_enable(struct ufs_hba *hba);
|
|
|
|
int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba);
|
|
|
|
void ufshcd_init_crypto(struct ufs_hba *hba);
|
|
|
|
void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
|
|
struct request_queue *q);
|
|
|
|
void ufshcd_crypto_destroy_keyslot_manager(struct ufs_hba *hba);
|
|
|
|
#else /* CONFIG_SCSI_UFS_CRYPTO */
|
|
|
|
static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
|
|
struct ufshcd_lrb *lrbp) { }
|
|
|
|
static inline void
|
|
ufshcd_prepare_req_desc_hdr_crypto(struct ufshcd_lrb *lrbp, u32 *dword_0,
|
|
u32 *dword_1, u32 *dword_3) { }
|
|
|
|
static inline bool ufshcd_crypto_enable(struct ufs_hba *hba)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void ufshcd_init_crypto(struct ufs_hba *hba) { }
|
|
|
|
static inline void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
|
|
struct request_queue *q) { }
|
|
|
|
static inline void ufshcd_crypto_destroy_keyslot_manager(struct ufs_hba *hba)
|
|
{ }
|
|
|
|
#endif /* CONFIG_SCSI_UFS_CRYPTO */
|
|
|
|
#endif /* _UFSHCD_CRYPTO_H */
|