hc
2023-03-21 4b55d97acc464242bcd6a8ae77b8ff37c22dec58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright 2020 Google LLC
 */
 
#include <linux/blk-crypto.h>
#include <linux/blkdev.h>
#include <linux/keyslot-manager.h>
#include <linux/mmc/host.h>
 
#include "core.h"
#include "queue.h"
 
void mmc_crypto_setup_queue(struct mmc_host *host, struct request_queue *q)
{
   if (host->caps2 & MMC_CAP2_CRYPTO)
       q->ksm = host->ksm;
}
EXPORT_SYMBOL_GPL(mmc_crypto_setup_queue);
 
void mmc_crypto_free_host(struct mmc_host *host)
{
   keyslot_manager_destroy(host->ksm);
}
 
void mmc_crypto_prepare_req(struct mmc_queue_req *mqrq)
{
   struct request *req = mmc_queue_req_to_req(mqrq);
   struct mmc_request *mrq = &mqrq->brq.mrq;
   const struct bio_crypt_ctx *bc;
 
   if (!bio_crypt_should_process(req))
       return;
 
   bc = req->bio->bi_crypt_context;
   mrq->crypto_key_slot = bc->bc_keyslot;
   mrq->data_unit_num = bc->bc_dun[0];
   mrq->crypto_key = bc->bc_key;
}
EXPORT_SYMBOL_GPL(mmc_crypto_prepare_req);