cqhci-crypto.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * CQHCI crypto engine (inline encryption) support
  4. *
  5. * Copyright 2020 Google LLC
  6. */
  7. #ifndef LINUX_MMC_CQHCI_CRYPTO_H
  8. #define LINUX_MMC_CQHCI_CRYPTO_H
  9. #include <linux/mmc/host.h>
  10. #include "cqhci.h"
  11. #ifdef CONFIG_MMC_CRYPTO
  12. int cqhci_crypto_init(struct cqhci_host *host);
  13. /*
  14. * Returns the crypto bits that should be set in bits 64-127 of the
  15. * task descriptor.
  16. */
  17. static inline u64 cqhci_crypto_prep_task_desc(struct mmc_request *mrq)
  18. {
  19. if (!mrq->crypto_ctx)
  20. return 0;
  21. /* We set max_dun_bytes_supported=4, so all DUNs should be 32-bit. */
  22. WARN_ON_ONCE(mrq->crypto_ctx->bc_dun[0] > U32_MAX);
  23. return CQHCI_CRYPTO_ENABLE_BIT |
  24. CQHCI_CRYPTO_KEYSLOT(mrq->crypto_key_slot) |
  25. mrq->crypto_ctx->bc_dun[0];
  26. }
  27. #else /* CONFIG_MMC_CRYPTO */
  28. static inline int cqhci_crypto_init(struct cqhci_host *host)
  29. {
  30. return 0;
  31. }
  32. static inline u64 cqhci_crypto_prep_task_desc(struct mmc_request *mrq)
  33. {
  34. return 0;
  35. }
  36. #endif /* !CONFIG_MMC_CRYPTO */
  37. #endif /* LINUX_MMC_CQHCI_CRYPTO_H */