Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * CQHCI crypto engine (inline encryption) support
0004  *
0005  * Copyright 2020 Google LLC
0006  */
0007 
0008 #ifndef LINUX_MMC_CQHCI_CRYPTO_H
0009 #define LINUX_MMC_CQHCI_CRYPTO_H
0010 
0011 #include <linux/mmc/host.h>
0012 
0013 #include "cqhci.h"
0014 
0015 #ifdef CONFIG_MMC_CRYPTO
0016 
0017 int cqhci_crypto_init(struct cqhci_host *host);
0018 
0019 /*
0020  * Returns the crypto bits that should be set in bits 64-127 of the
0021  * task descriptor.
0022  */
0023 static inline u64 cqhci_crypto_prep_task_desc(struct mmc_request *mrq)
0024 {
0025     if (!mrq->crypto_ctx)
0026         return 0;
0027 
0028     /* We set max_dun_bytes_supported=4, so all DUNs should be 32-bit. */
0029     WARN_ON_ONCE(mrq->crypto_ctx->bc_dun[0] > U32_MAX);
0030 
0031     return CQHCI_CRYPTO_ENABLE_BIT |
0032            CQHCI_CRYPTO_KEYSLOT(mrq->crypto_key_slot) |
0033            mrq->crypto_ctx->bc_dun[0];
0034 }
0035 
0036 #else /* CONFIG_MMC_CRYPTO */
0037 
0038 static inline int cqhci_crypto_init(struct cqhci_host *host)
0039 {
0040     return 0;
0041 }
0042 
0043 static inline u64 cqhci_crypto_prep_task_desc(struct mmc_request *mrq)
0044 {
0045     return 0;
0046 }
0047 
0048 #endif /* !CONFIG_MMC_CRYPTO */
0049 
0050 #endif /* LINUX_MMC_CQHCI_CRYPTO_H */