Linux Audio

Check our new training course

Linux kernel drivers training

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