• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright 2019 Google LLC
4  */
5 
6 #ifndef __LINUX_BLK_CRYPTO_H
7 #define __LINUX_BLK_CRYPTO_H
8 
9 #include <linux/bio.h>
10 
11 #ifdef CONFIG_BLK_INLINE_ENCRYPTION
12 
13 int blk_crypto_submit_bio(struct bio **bio_ptr);
14 
15 bool blk_crypto_endio(struct bio *bio);
16 
17 int blk_crypto_init_key(struct blk_crypto_key *blk_key,
18 			const u8 *raw_key, unsigned int raw_key_size,
19 			enum blk_crypto_mode_num crypto_mode,
20 			unsigned int data_unit_size);
21 
22 int blk_crypto_evict_key(struct request_queue *q,
23 			 const struct blk_crypto_key *key);
24 
25 #else /* CONFIG_BLK_INLINE_ENCRYPTION */
26 
blk_crypto_submit_bio(struct bio ** bio_ptr)27 static inline int blk_crypto_submit_bio(struct bio **bio_ptr)
28 {
29 	return 0;
30 }
31 
blk_crypto_endio(struct bio * bio)32 static inline bool blk_crypto_endio(struct bio *bio)
33 {
34 	return true;
35 }
36 
37 #endif /* CONFIG_BLK_INLINE_ENCRYPTION */
38 
39 #ifdef CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK
40 
41 int blk_crypto_start_using_mode(enum blk_crypto_mode_num mode_num,
42 				unsigned int data_unit_size,
43 				struct request_queue *q);
44 
45 int blk_crypto_fallback_init(void);
46 
47 #else /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */
48 
49 static inline int
blk_crypto_start_using_mode(enum blk_crypto_mode_num mode_num,unsigned int data_unit_size,struct request_queue * q)50 blk_crypto_start_using_mode(enum blk_crypto_mode_num mode_num,
51 			    unsigned int data_unit_size,
52 			    struct request_queue *q)
53 {
54 	return 0;
55 }
56 
blk_crypto_fallback_init(void)57 static inline int blk_crypto_fallback_init(void)
58 {
59 	return 0;
60 }
61 
62 #endif /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */
63 
64 #endif /* __LINUX_BLK_CRYPTO_H */
65