blk-crypto-internal.h (87a0b2fafc09766d8c55461a18345a1cfb10a7fe) blk-crypto-internal.h (20f01f163203666010ee1560852590a0c0572726)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright 2019 Google LLC
4 */
5
6#ifndef __LINUX_BLK_CRYPTO_INTERNAL_H
7#define __LINUX_BLK_CRYPTO_INTERNAL_H
8
9#include <linux/bio.h>
10#include <linux/blk-mq.h>
11
12/* Represents a crypto mode supported by blk-crypto */
13struct blk_crypto_mode {
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright 2019 Google LLC
4 */
5
6#ifndef __LINUX_BLK_CRYPTO_INTERNAL_H
7#define __LINUX_BLK_CRYPTO_INTERNAL_H
8
9#include <linux/bio.h>
10#include <linux/blk-mq.h>
11
12/* Represents a crypto mode supported by blk-crypto */
13struct blk_crypto_mode {
14 const char *name; /* name of this mode, shown in sysfs */
14 const char *cipher_str; /* crypto API name (for fallback case) */
15 unsigned int keysize; /* key size in bytes */
16 unsigned int ivsize; /* iv size in bytes */
17};
18
19extern const struct blk_crypto_mode blk_crypto_modes[];
20
21#ifdef CONFIG_BLK_INLINE_ENCRYPTION
22
15 const char *cipher_str; /* crypto API name (for fallback case) */
16 unsigned int keysize; /* key size in bytes */
17 unsigned int ivsize; /* iv size in bytes */
18};
19
20extern const struct blk_crypto_mode blk_crypto_modes[];
21
22#ifdef CONFIG_BLK_INLINE_ENCRYPTION
23
24int blk_crypto_sysfs_register(struct request_queue *q);
25
26void blk_crypto_sysfs_unregister(struct request_queue *q);
27
23void bio_crypt_dun_increment(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE],
24 unsigned int inc);
25
26bool bio_crypt_rq_ctx_compatible(struct request *rq, struct bio *bio);
27
28bool bio_crypt_ctx_mergeable(struct bio_crypt_ctx *bc1, unsigned int bc1_bytes,
29 struct bio_crypt_ctx *bc2);
30

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

57
58static inline bool blk_crypto_rq_is_encrypted(struct request *rq)
59{
60 return rq->crypt_ctx;
61}
62
63#else /* CONFIG_BLK_INLINE_ENCRYPTION */
64
28void bio_crypt_dun_increment(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE],
29 unsigned int inc);
30
31bool bio_crypt_rq_ctx_compatible(struct request *rq, struct bio *bio);
32
33bool bio_crypt_ctx_mergeable(struct bio_crypt_ctx *bc1, unsigned int bc1_bytes,
34 struct bio_crypt_ctx *bc2);
35

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

62
63static inline bool blk_crypto_rq_is_encrypted(struct request *rq)
64{
65 return rq->crypt_ctx;
66}
67
68#else /* CONFIG_BLK_INLINE_ENCRYPTION */
69
70static inline int blk_crypto_sysfs_register(struct request_queue *q)
71{
72 return 0;
73}
74
75static inline void blk_crypto_sysfs_unregister(struct request_queue *q) { }
76
65static inline bool bio_crypt_rq_ctx_compatible(struct request *rq,
66 struct bio *bio)
67{
68 return true;
69}
70
71static inline bool bio_crypt_ctx_front_mergeable(struct request *req,
72 struct bio *bio)

--- 140 unchanged lines hidden ---
77static inline bool bio_crypt_rq_ctx_compatible(struct request *rq,
78 struct bio *bio)
79{
80 return true;
81}
82
83static inline bool bio_crypt_ctx_front_mergeable(struct request *req,
84 struct bio *bio)

--- 140 unchanged lines hidden ---