• 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 			bool is_hw_wrapped,
20 			enum blk_crypto_mode_num crypto_mode,
21 			unsigned int dun_bytes,
22 			unsigned int data_unit_size);
23 
24 int blk_crypto_start_using_mode(enum blk_crypto_mode_num crypto_mode,
25 				unsigned int dun_bytes,
26 				unsigned int data_unit_size,
27 				bool is_hw_wrapped_key,
28 				struct request_queue *q);
29 
30 int blk_crypto_evict_key(struct request_queue *q,
31 			 const struct blk_crypto_key *key);
32 
33 #else /* CONFIG_BLK_INLINE_ENCRYPTION */
34 
blk_crypto_submit_bio(struct bio ** bio_ptr)35 static inline int blk_crypto_submit_bio(struct bio **bio_ptr)
36 {
37 	return 0;
38 }
39 
blk_crypto_endio(struct bio * bio)40 static inline bool blk_crypto_endio(struct bio *bio)
41 {
42 	return true;
43 }
44 
45 #endif /* CONFIG_BLK_INLINE_ENCRYPTION */
46 
47 #ifdef CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK
48 
49 int blk_crypto_fallback_init(void);
50 
51 #else /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */
52 
blk_crypto_fallback_init(void)53 static inline int blk_crypto_fallback_init(void)
54 {
55 	return 0;
56 }
57 
58 #endif /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */
59 
60 #endif /* __LINUX_BLK_CRYPTO_H */
61