drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / include / linux / bio-integrity.h
blobdbf0f74c15291327c11af3c393386ec13cc3906f
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_BIO_INTEGRITY_H
3 #define _LINUX_BIO_INTEGRITY_H
5 #include <linux/bio.h>
7 enum bip_flags {
8 BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */
9 BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */
10 BIP_CTRL_NOCHECK = 1 << 2, /* disable HBA integrity checking */
11 BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */
12 BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */
13 BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */
16 struct bio_integrity_payload {
17 struct bio *bip_bio; /* parent bio */
19 struct bvec_iter bip_iter;
21 unsigned short bip_vcnt; /* # of integrity bio_vecs */
22 unsigned short bip_max_vcnt; /* integrity bio_vec slots */
23 unsigned short bip_flags; /* control flags */
25 struct bvec_iter bio_iter; /* for rewinding parent bio */
27 struct work_struct bip_work; /* I/O completion */
29 struct bio_vec *bip_vec;
30 struct bio_vec bip_inline_vecs[];/* embedded bvec array */
33 #ifdef CONFIG_BLK_DEV_INTEGRITY
35 #define bip_for_each_vec(bvl, bip, iter) \
36 for_each_bvec(bvl, (bip)->bip_vec, iter, (bip)->bip_iter)
38 #define bio_for_each_integrity_vec(_bvl, _bio, _iter) \
39 for_each_bio(_bio) \
40 bip_for_each_vec(_bvl, _bio->bi_integrity, _iter)
42 static inline struct bio_integrity_payload *bio_integrity(struct bio *bio)
44 if (bio->bi_opf & REQ_INTEGRITY)
45 return bio->bi_integrity;
47 return NULL;
50 static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)
52 struct bio_integrity_payload *bip = bio_integrity(bio);
54 if (bip)
55 return bip->bip_flags & flag;
57 return false;
60 static inline sector_t bip_get_seed(struct bio_integrity_payload *bip)
62 return bip->bip_iter.bi_sector;
65 static inline void bip_set_seed(struct bio_integrity_payload *bip,
66 sector_t seed)
68 bip->bip_iter.bi_sector = seed;
71 struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp,
72 unsigned int nr);
73 int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len,
74 unsigned int offset);
75 int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t len);
76 void bio_integrity_unmap_user(struct bio *bio);
77 bool bio_integrity_prep(struct bio *bio);
78 void bio_integrity_advance(struct bio *bio, unsigned int bytes_done);
79 void bio_integrity_trim(struct bio *bio);
80 int bio_integrity_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp_mask);
81 int bioset_integrity_create(struct bio_set *bs, int pool_size);
82 void bioset_integrity_free(struct bio_set *bs);
83 void bio_integrity_init(void);
85 #else /* CONFIG_BLK_DEV_INTEGRITY */
87 static inline struct bio_integrity_payload *bio_integrity(struct bio *bio)
89 return NULL;
92 static inline int bioset_integrity_create(struct bio_set *bs, int pool_size)
94 return 0;
97 static inline void bioset_integrity_free(struct bio_set *bs)
101 static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf,
102 ssize_t len)
104 return -EINVAL;
107 static inline void bio_integrity_unmap_user(struct bio *bio)
111 static inline bool bio_integrity_prep(struct bio *bio)
113 return true;
116 static inline int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
117 gfp_t gfp_mask)
119 return 0;
122 static inline void bio_integrity_advance(struct bio *bio,
123 unsigned int bytes_done)
127 static inline void bio_integrity_trim(struct bio *bio)
131 static inline void bio_integrity_init(void)
135 static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)
137 return false;
140 static inline struct bio_integrity_payload *
141 bio_integrity_alloc(struct bio *bio, gfp_t gfp, unsigned int nr)
143 return ERR_PTR(-EINVAL);
146 static inline int bio_integrity_add_page(struct bio *bio, struct page *page,
147 unsigned int len, unsigned int offset)
149 return 0;
151 #endif /* CONFIG_BLK_DEV_INTEGRITY */
152 #endif /* _LINUX_BIO_INTEGRITY_H */