printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / blk-integrity.h
blobc7eae0bfb013f171eadb34e7b107cf451e356287
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_BLK_INTEGRITY_H
3 #define _LINUX_BLK_INTEGRITY_H
5 #include <linux/blk-mq.h>
6 #include <linux/bio-integrity.h>
8 struct request;
10 enum blk_integrity_flags {
11 BLK_INTEGRITY_NOVERIFY = 1 << 0,
12 BLK_INTEGRITY_NOGENERATE = 1 << 1,
13 BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2,
14 BLK_INTEGRITY_REF_TAG = 1 << 3,
15 BLK_INTEGRITY_STACKED = 1 << 4,
18 const char *blk_integrity_profile_name(struct blk_integrity *bi);
19 bool queue_limits_stack_integrity(struct queue_limits *t,
20 struct queue_limits *b);
21 static inline bool queue_limits_stack_integrity_bdev(struct queue_limits *t,
22 struct block_device *bdev)
24 return queue_limits_stack_integrity(t, &bdev->bd_disk->queue->limits);
27 #ifdef CONFIG_BLK_DEV_INTEGRITY
28 int blk_rq_map_integrity_sg(struct request *, struct scatterlist *);
29 int blk_rq_count_integrity_sg(struct request_queue *, struct bio *);
30 int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf,
31 ssize_t bytes);
33 static inline bool
34 blk_integrity_queue_supports_integrity(struct request_queue *q)
36 return q->limits.integrity.tuple_size;
39 static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
41 if (!blk_integrity_queue_supports_integrity(disk->queue))
42 return NULL;
43 return &disk->queue->limits.integrity;
46 static inline struct blk_integrity *
47 bdev_get_integrity(struct block_device *bdev)
49 return blk_get_integrity(bdev->bd_disk);
52 static inline unsigned short
53 queue_max_integrity_segments(const struct request_queue *q)
55 return q->limits.max_integrity_segments;
58 /**
59 * bio_integrity_intervals - Return number of integrity intervals for a bio
60 * @bi: blk_integrity profile for device
61 * @sectors: Size of the bio in 512-byte sectors
63 * Description: The block layer calculates everything in 512 byte
64 * sectors but integrity metadata is done in terms of the data integrity
65 * interval size of the storage device. Convert the block layer sectors
66 * to the appropriate number of integrity intervals.
68 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
69 unsigned int sectors)
71 return sectors >> (bi->interval_exp - 9);
74 static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
75 unsigned int sectors)
77 return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
80 static inline bool blk_integrity_rq(struct request *rq)
82 return rq->cmd_flags & REQ_INTEGRITY;
86 * Return the current bvec that contains the integrity data. bip_iter may be
87 * advanced to iterate over the integrity data.
89 static inline struct bio_vec rq_integrity_vec(struct request *rq)
91 return mp_bvec_iter_bvec(rq->bio->bi_integrity->bip_vec,
92 rq->bio->bi_integrity->bip_iter);
94 #else /* CONFIG_BLK_DEV_INTEGRITY */
95 static inline int blk_rq_count_integrity_sg(struct request_queue *q,
96 struct bio *b)
98 return 0;
100 static inline int blk_rq_map_integrity_sg(struct request *q,
101 struct scatterlist *s)
103 return 0;
105 static inline int blk_rq_integrity_map_user(struct request *rq,
106 void __user *ubuf,
107 ssize_t bytes)
109 return -EINVAL;
111 static inline struct blk_integrity *bdev_get_integrity(struct block_device *b)
113 return NULL;
115 static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
117 return NULL;
119 static inline bool
120 blk_integrity_queue_supports_integrity(struct request_queue *q)
122 return false;
124 static inline unsigned short
125 queue_max_integrity_segments(const struct request_queue *q)
127 return 0;
130 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
131 unsigned int sectors)
133 return 0;
136 static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
137 unsigned int sectors)
139 return 0;
141 static inline int blk_integrity_rq(struct request *rq)
143 return 0;
146 static inline struct bio_vec rq_integrity_vec(struct request *rq)
148 /* the optimizer will remove all calls to this function */
149 return (struct bio_vec){ };
151 #endif /* CONFIG_BLK_DEV_INTEGRITY */
153 #endif /* _LINUX_BLK_INTEGRITY_H */