Files
kernel_xiaomi_sm8250/drivers/scsi/ufs/ufshcd-crypto.h
Blagovest Kolenichev 49875670fa File and metadata encryption changes from android-4.19.96-107
Added required changes to fit properly android-4.19.79-95
crypto content into msm-4.19 branch. Modifications in
abi_gki_aarch64.xml are discarded completely. The order of
applying is bottom to top:

1f876610fe ANDROID: dm: Add wrapped key support in dm-default-key
b785dbcb87 ANDROID: dm: add support for passing through derive_raw_secret
66b3c81270 ANDROID: block: Prevent crypto fallback for wrapped keys
36500bffb9 fscrypt: support passing a keyring key to FS_IOC_ADD_ENCRYPTION_KEY
b32863f17f ANDROID: dm: add dm-default-key target for metadata encryption
94706caf62 ANDROID: dm: enable may_passthrough_inline_crypto on some targets
44e1174c18 ANDROID: dm: add support for passing through inline crypto support
e65d08ae68 ANDROID: block: Introduce passthrough keyslot manager
8f48f6657d ANDROID: ext4, f2fs: enable direct I/O with inline encryption
bbee78199f FROMLIST: scsi: ufs: add program_key() variant op
0f1c72a2f5 ANDROID: block: export symbols needed for modules to use inline crypto
35b62551b9 ANDROID: block: fix some inline crypto bugs
23b81578bf ANDROID: fscrypt: add support for hardware-wrapped keys
a076eebee0 ANDROID: block: add KSM op to derive software secret from wrapped key
3e8c41805f ANDROID: block: provide key size as input to inline crypto APIs
bb7f6203fb ANDROID: ufshcd-crypto: export cap find API
b01c73ea71 BACKPORT: FROMLIST: Update Inline Encryption from v5 to v6 of patch series

Change-Id: Ic741913aa478500da94a52eace02bb9192e581b9
Git-repo: https://android.googlesource.com/kernel/common/+/refs/heads/android-4.19
Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2020-04-21 06:19:04 -07:00

168 lines
4.1 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 <linux/keyslot-manager.h>
#include "ufshcd.h"
#include "ufshci.h"
static inline int ufshcd_num_keyslots(struct ufs_hba *hba)
{
return hba->crypto_capabilities.config_count + 1;
}
static inline bool ufshcd_keyslot_valid(struct ufs_hba *hba, unsigned int slot)
{
/*
* The actual number of configurations supported is (CFGC+1), so slot
* numbers range from 0 to config_count inclusive.
*/
return slot < ufshcd_num_keyslots(hba);
}
static inline bool ufshcd_hba_is_crypto_supported(struct ufs_hba *hba)
{
return hba->crypto_capabilities.reg_val != 0;
}
static inline bool ufshcd_is_crypto_enabled(struct ufs_hba *hba)
{
return hba->caps & UFSHCD_CAP_CRYPTO;
}
/* Functions implementing UFSHCI v2.1 specification behaviour */
int ufshcd_crypto_cap_find(struct ufs_hba *hba,
enum blk_crypto_mode_num crypto_mode,
unsigned int data_unit_size);
int ufshcd_prepare_lrbp_crypto_spec(struct ufs_hba *hba,
struct scsi_cmnd *cmd,
struct ufshcd_lrb *lrbp);
void ufshcd_crypto_enable_spec(struct ufs_hba *hba);
void ufshcd_crypto_disable_spec(struct ufs_hba *hba);
struct keyslot_mgmt_ll_ops;
int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba,
const struct keyslot_mgmt_ll_ops *ksm_ops);
void ufshcd_crypto_setup_rq_keyslot_manager_spec(struct ufs_hba *hba,
struct request_queue *q);
void ufshcd_crypto_destroy_rq_keyslot_manager_spec(struct ufs_hba *hba,
struct request_queue *q);
static inline bool ufshcd_lrbp_crypto_enabled(struct ufshcd_lrb *lrbp)
{
return lrbp->crypto_enable;
}
/* Crypto Variant Ops Support */
void ufshcd_crypto_enable(struct ufs_hba *hba);
void ufshcd_crypto_disable(struct ufs_hba *hba);
int ufshcd_hba_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_rq_keyslot_manager(struct ufs_hba *hba,
struct request_queue *q);
int ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
struct scsi_cmnd *cmd,
struct ufshcd_lrb *lrbp);
int ufshcd_complete_lrbp_crypto(struct ufs_hba *hba,
struct scsi_cmnd *cmd,
struct ufshcd_lrb *lrbp);
void ufshcd_crypto_debug(struct ufs_hba *hba);
int ufshcd_crypto_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op);
int ufshcd_crypto_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op);
void ufshcd_crypto_set_vops(struct ufs_hba *hba,
struct ufs_hba_crypto_variant_ops *crypto_vops);
#else /* CONFIG_SCSI_UFS_CRYPTO */
static inline bool ufshcd_keyslot_valid(struct ufs_hba *hba,
unsigned int slot)
{
return false;
}
static inline bool ufshcd_hba_is_crypto_supported(struct ufs_hba *hba)
{
return false;
}
static inline bool ufshcd_is_crypto_enabled(struct ufs_hba *hba)
{
return false;
}
static inline void ufshcd_crypto_enable(struct ufs_hba *hba) { }
static inline void ufshcd_crypto_disable(struct ufs_hba *hba) { }
static inline int ufshcd_hba_init_crypto(struct ufs_hba *hba)
{
return 0;
}
static inline void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
struct request_queue *q) { }
static inline void ufshcd_crypto_destroy_rq_keyslot_manager(struct ufs_hba *hba,
struct request_queue *q) { }
static inline int ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
struct scsi_cmnd *cmd,
struct ufshcd_lrb *lrbp)
{
return 0;
}
static inline bool ufshcd_lrbp_crypto_enabled(struct ufshcd_lrb *lrbp)
{
return false;
}
static inline int ufshcd_complete_lrbp_crypto(struct ufs_hba *hba,
struct scsi_cmnd *cmd,
struct ufshcd_lrb *lrbp)
{
return 0;
}
static inline void ufshcd_crypto_debug(struct ufs_hba *hba) { }
static inline int ufshcd_crypto_suspend(struct ufs_hba *hba,
enum ufs_pm_op pm_op)
{
return 0;
}
static inline int ufshcd_crypto_resume(struct ufs_hba *hba,
enum ufs_pm_op pm_op)
{
return 0;
}
static inline void ufshcd_crypto_set_vops(struct ufs_hba *hba,
struct ufs_hba_crypto_variant_ops *crypto_vops) { }
#endif /* CONFIG_SCSI_UFS_CRYPTO */
#endif /* _UFSHCD_CRYPTO_H */