cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

ufshcd-crypto.h (1830B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/*
      3 * Copyright 2019 Google LLC
      4 */
      5
      6#ifndef _UFSHCD_CRYPTO_H
      7#define _UFSHCD_CRYPTO_H
      8
      9#include <scsi/scsi_cmnd.h>
     10#include <ufs/ufshcd.h>
     11#include "ufshcd-priv.h"
     12#include <ufs/ufshci.h>
     13
     14#ifdef CONFIG_SCSI_UFS_CRYPTO
     15
     16static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
     17					      struct ufshcd_lrb *lrbp)
     18{
     19	if (!rq || !rq->crypt_keyslot) {
     20		lrbp->crypto_key_slot = -1;
     21		return;
     22	}
     23
     24	lrbp->crypto_key_slot = blk_crypto_keyslot_index(rq->crypt_keyslot);
     25	lrbp->data_unit_num = rq->crypt_ctx->bc_dun[0];
     26}
     27
     28static inline void
     29ufshcd_prepare_req_desc_hdr_crypto(struct ufshcd_lrb *lrbp, u32 *dword_0,
     30				   u32 *dword_1, u32 *dword_3)
     31{
     32	if (lrbp->crypto_key_slot >= 0) {
     33		*dword_0 |= UTP_REQ_DESC_CRYPTO_ENABLE_CMD;
     34		*dword_0 |= lrbp->crypto_key_slot;
     35		*dword_1 = lower_32_bits(lrbp->data_unit_num);
     36		*dword_3 = upper_32_bits(lrbp->data_unit_num);
     37	}
     38}
     39
     40bool ufshcd_crypto_enable(struct ufs_hba *hba);
     41
     42int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba);
     43
     44void ufshcd_init_crypto(struct ufs_hba *hba);
     45
     46void ufshcd_crypto_register(struct ufs_hba *hba, struct request_queue *q);
     47
     48#else /* CONFIG_SCSI_UFS_CRYPTO */
     49
     50static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
     51					      struct ufshcd_lrb *lrbp) { }
     52
     53static inline void
     54ufshcd_prepare_req_desc_hdr_crypto(struct ufshcd_lrb *lrbp, u32 *dword_0,
     55				   u32 *dword_1, u32 *dword_3) { }
     56
     57static inline bool ufshcd_crypto_enable(struct ufs_hba *hba)
     58{
     59	return false;
     60}
     61
     62static inline int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
     63{
     64	return 0;
     65}
     66
     67static inline void ufshcd_init_crypto(struct ufs_hba *hba) { }
     68
     69static inline void ufshcd_crypto_register(struct ufs_hba *hba,
     70					  struct request_queue *q) { }
     71
     72#endif /* CONFIG_SCSI_UFS_CRYPTO */
     73
     74#endif /* _UFSHCD_CRYPTO_H */