1#ifndef _SCSI_DISK_H
2#define _SCSI_DISK_H
3
4
5
6
7
8
9#define SD_MAJORS 16
10
11
12
13
14
15#define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26)
16
17
18
19
20#define SD_TIMEOUT (30 * HZ)
21#define SD_MOD_TIMEOUT (75 * HZ)
22#define SD_FLUSH_TIMEOUT (60 * HZ)
23
24
25
26
27#define SD_MAX_RETRIES 5
28#define SD_PASSTHROUGH_RETRIES 1
29
30
31
32
33#define SD_BUF_SIZE 512
34
35
36
37
38
39#define SD_LAST_BUGGY_SECTORS 8
40
41enum {
42 SD_EXT_CDB_SIZE = 32,
43 SD_MEMPOOL_SIZE = 2,
44};
45
46enum {
47 SD_LBP_FULL = 0,
48 SD_LBP_UNMAP,
49 SD_LBP_WS16,
50 SD_LBP_WS10,
51 SD_LBP_ZERO,
52 SD_LBP_DISABLE,
53};
54
55struct scsi_disk {
56 struct scsi_driver *driver;
57 struct scsi_device *device;
58 struct device dev;
59 struct gendisk *disk;
60 atomic_t openers;
61 sector_t capacity;
62 u32 max_ws_blocks;
63 u32 max_unmap_blocks;
64 u32 unmap_granularity;
65 u32 unmap_alignment;
66 u32 index;
67 unsigned int physical_block_size;
68 u8 media_present;
69 u8 write_prot;
70 u8 protection_type;
71 u8 provisioning_mode;
72 unsigned ATO : 1;
73 unsigned WCE : 1;
74 unsigned RCD : 1;
75 unsigned DPOFUA : 1;
76 unsigned first_scan : 1;
77 unsigned lbpme : 1;
78 unsigned lbprz : 1;
79 unsigned lbpu : 1;
80 unsigned lbpws : 1;
81 unsigned lbpws10 : 1;
82 unsigned lbpvpd : 1;
83};
84#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
85
86static inline struct scsi_disk *scsi_disk(struct gendisk *disk)
87{
88 return container_of(disk->private_data, struct scsi_disk, driver);
89}
90
91#define sd_printk(prefix, sdsk, fmt, a...) \
92 (sdsk)->disk ? \
93 sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \
94 (sdsk)->disk->disk_name, ##a) : \
95 sdev_printk(prefix, (sdsk)->device, fmt, ##a)
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111enum sd_dif_target_protection_types {
112 SD_DIF_TYPE0_PROTECTION = 0x0,
113 SD_DIF_TYPE1_PROTECTION = 0x1,
114 SD_DIF_TYPE2_PROTECTION = 0x2,
115 SD_DIF_TYPE3_PROTECTION = 0x3,
116};
117
118
119
120
121struct sd_dif_tuple {
122 __be16 guard_tag;
123 __be16 app_tag;
124 __be32 ref_tag;
125};
126
127#ifdef CONFIG_BLK_DEV_INTEGRITY
128
129extern void sd_dif_config_host(struct scsi_disk *);
130extern int sd_dif_prepare(struct request *rq, sector_t, unsigned int);
131extern void sd_dif_complete(struct scsi_cmnd *, unsigned int);
132
133#else
134
135static inline void sd_dif_config_host(struct scsi_disk *disk)
136{
137}
138static inline int sd_dif_prepare(struct request *rq, sector_t s, unsigned int a)
139{
140 return 0;
141}
142static inline void sd_dif_complete(struct scsi_cmnd *cmd, unsigned int a)
143{
144}
145
146#endif
147
148#endif
149