crypto.c (d0034a7a4ac7fae708146ac0059b9c47a1543f0d) crypto.c (86c639ce08266ed521974038f0592739fec1c11a)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * MMC crypto engine (inline encryption) support
4 *
5 * Copyright 2020 Google LLC
6 */
7
8#include <linux/blk-crypto.h>

--- 17 unchanged lines hidden (view full) ---

26}
27EXPORT_SYMBOL_GPL(mmc_crypto_setup_queue);
28
29void mmc_crypto_prepare_req(struct mmc_queue_req *mqrq)
30{
31 struct request *req = mmc_queue_req_to_req(mqrq);
32 struct mmc_request *mrq = &mqrq->brq.mrq;
33
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * MMC crypto engine (inline encryption) support
4 *
5 * Copyright 2020 Google LLC
6 */
7
8#include <linux/blk-crypto.h>

--- 17 unchanged lines hidden (view full) ---

26}
27EXPORT_SYMBOL_GPL(mmc_crypto_setup_queue);
28
29void mmc_crypto_prepare_req(struct mmc_queue_req *mqrq)
30{
31 struct request *req = mmc_queue_req_to_req(mqrq);
32 struct mmc_request *mrq = &mqrq->brq.mrq;
33
34 if (!req->crypt_keyslot)
34 if (!req->crypt_ctx)
35 return;
36
35 return;
36
37 mrq->crypto_enabled = true;
38 mrq->crypto_key_slot = blk_ksm_get_slot_idx(req->crypt_keyslot);
39
40 /*
41 * For now we assume that all MMC drivers set max_dun_bytes_supported=4,
42 * which is the limit for CQHCI crypto. So all DUNs should be 32-bit.
43 */
44 WARN_ON_ONCE(req->crypt_ctx->bc_dun[0] > U32_MAX);
45
46 mrq->data_unit_num = req->crypt_ctx->bc_dun[0];
37 mrq->crypto_ctx = req->crypt_ctx;
38 if (req->crypt_keyslot)
39 mrq->crypto_key_slot = blk_ksm_get_slot_idx(req->crypt_keyslot);
47}
48EXPORT_SYMBOL_GPL(mmc_crypto_prepare_req);
40}
41EXPORT_SYMBOL_GPL(mmc_crypto_prepare_req);