[SCSI] st: add struct rq_map_data support
[linux-block.git] / drivers / scsi / st.h
CommitLineData
1da177e4
LT
1
2#ifndef _ST_H
3#define _ST_H
4
5#include <linux/completion.h>
28f85009 6#include <linux/mutex.h>
f03a5670 7#include <linux/kref.h>
8b05b773 8#include <scsi/scsi_cmnd.h>
1da177e4
LT
9
10/* Descriptor for analyzed sense data */
11struct st_cmdstatus {
12 int midlevel_result;
13 struct scsi_sense_hdr sense_hdr;
14 int have_sense;
40f6b36c 15 int residual;
1da177e4
LT
16 u64 uremainder64;
17 u8 flags;
18 u8 remainder_valid;
19 u8 fixed_format;
20 u8 deferred;
21};
22
8b05b773
MC
23struct scsi_tape;
24
25/* scsi tape command */
26struct st_request {
27 unsigned char cmd[MAX_COMMAND_SIZE];
28 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
29 int result;
30 struct scsi_tape *stp;
31 struct completion *waiting;
32};
33
1da177e4
LT
34/* The tape buffer descriptor. */
35struct st_buffer {
1da177e4
LT
36 unsigned char dma; /* DMA-able buffer */
37 unsigned char do_dio; /* direct i/o set up? */
40f6b36c 38 unsigned char cleared; /* internal buffer cleared after open? */
1da177e4
LT
39 int buffer_size;
40 int buffer_blocks;
41 int buffer_bytes;
42 int read_pointer;
43 int writing;
44 int syscall_result;
8b05b773 45 struct st_request *last_SRpnt;
1da177e4 46 struct st_cmdstatus cmdstat;
d0e1ae31
FT
47 struct page **reserved_pages;
48 struct rq_map_data map_data;
1da177e4
LT
49 unsigned char *b_data;
50 unsigned short use_sg; /* zero or max number of s/g segments for this adapter */
51 unsigned short sg_segs; /* number of segments in s/g list */
52 unsigned short orig_frp_segs; /* number of segments allocated at first try */
53 unsigned short frp_segs; /* number of buffer segments */
54 unsigned int frp_sg_current; /* driver buffer length currently in s/g list */
55 struct st_buf_fragment *frp; /* the allocated buffer fragment list */
56 struct scatterlist sg[1]; /* MUST BE last item */
57};
58
59/* The tape buffer fragment descriptor */
60struct st_buf_fragment {
61 struct page *page;
62 unsigned int length;
63};
64
65/* The tape mode definition */
66struct st_modedef {
67 unsigned char defined;
68 unsigned char sysv; /* SYS V semantics? */
69 unsigned char do_async_writes;
70 unsigned char do_buffer_writes;
71 unsigned char do_read_ahead;
72 unsigned char defaults_for_writes;
73 unsigned char default_compression; /* 0 = don't touch, etc */
74 short default_density; /* Forced density, -1 = no value */
75 int default_blksize; /* Forced blocksize, -1 = no value */
76 struct cdev *cdevs[2]; /* Auto-rewind and non-rewind devices */
77};
78
79/* Number of modes can be changed by changing ST_NBR_MODE_BITS. The maximum
80 number of modes is 16 (ST_NBR_MODE_BITS 4) */
81#define ST_NBR_MODE_BITS 2
82#define ST_NBR_MODES (1 << ST_NBR_MODE_BITS)
83#define ST_MODE_SHIFT (7 - ST_NBR_MODE_BITS)
84#define ST_MODE_MASK ((ST_NBR_MODES - 1) << ST_MODE_SHIFT)
85
86#define ST_MAX_TAPES 128
87#define ST_MAX_TAPE_ENTRIES (ST_MAX_TAPES << (ST_NBR_MODE_BITS + 1))
88
89/* The status related to each partition */
90struct st_partstat {
91 unsigned char rw;
92 unsigned char eof;
93 unsigned char at_sm;
94 unsigned char last_block_valid;
95 u32 last_block_visited;
96 int drv_block; /* The block where the drive head is */
97 int drv_file;
98};
99
100#define ST_NBR_PARTITIONS 4
101
102/* The tape drive descriptor */
103struct scsi_tape {
104 struct scsi_driver *driver;
105 struct scsi_device *device;
28f85009 106 struct mutex lock; /* For serialization */
1da177e4
LT
107 struct completion wait; /* For SCSI commands */
108 struct st_buffer *buffer;
109
110 /* Drive characteristics */
111 unsigned char omit_blklims;
112 unsigned char do_auto_lock;
113 unsigned char can_bsr;
114 unsigned char can_partitions;
115 unsigned char two_fm;
116 unsigned char fast_mteom;
117 unsigned char immediate;
118 unsigned char restr_dma;
119 unsigned char scsi2_logical;
120 unsigned char default_drvbuffer; /* 0xff = don't touch, value 3 bits */
121 unsigned char cln_mode; /* 0 = none, otherwise sense byte nbr */
122 unsigned char cln_sense_value;
123 unsigned char cln_sense_mask;
124 unsigned char use_pf; /* Set Page Format bit in all mode selects? */
9abe16c6
KM
125 unsigned char try_dio; /* try direct i/o in general? */
126 unsigned char try_dio_now; /* try direct i/o before next close? */
1da177e4
LT
127 unsigned char c_algo; /* compression algorithm */
128 unsigned char pos_unknown; /* after reset position unknown */
40f6b36c 129 unsigned char sili; /* use SILI when reading in variable b mode */
1da177e4
LT
130 int tape_type;
131 int long_timeout; /* timeout for commands known to take long time */
132
133 unsigned long max_pfn; /* the maximum page number reachable by the HBA */
134
135 /* Mode characteristics */
136 struct st_modedef modes[ST_NBR_MODES];
137 int current_mode;
138
139 /* Status variables */
140 int partition;
141 int new_partition;
142 int nbr_partitions; /* zero until partition support enabled */
143 struct st_partstat ps[ST_NBR_PARTITIONS];
144 unsigned char dirty;
145 unsigned char ready;
146 unsigned char write_prot;
147 unsigned char drv_write_prot;
148 unsigned char in_use;
149 unsigned char blksize_changed;
150 unsigned char density_changed;
151 unsigned char compression_changed;
152 unsigned char drv_buffer;
153 unsigned char density;
154 unsigned char door_locked;
155 unsigned char autorew_dev; /* auto-rewind device */
156 unsigned char rew_at_close; /* rewind necessary at close */
157 unsigned char inited;
158 unsigned char cleaning_req; /* cleaning requested? */
159 int block_size;
160 int min_block;
161 int max_block;
162 int recover_count; /* From tape opening */
163 int recover_reg; /* From last status call */
164
165#if DEBUG
166 unsigned char write_pending;
167 int nbr_finished;
168 int nbr_waits;
169 int nbr_requests;
170 int nbr_dio;
171 int nbr_pages;
1da177e4
LT
172 unsigned char last_cmnd[6];
173 unsigned char last_sense[16];
174#endif
175 struct gendisk *disk;
f03a5670 176 struct kref kref;
1da177e4
LT
177};
178
179/* Bit masks for use_pf */
180#define USE_PF 1
181#define PF_TESTED 2
182
183/* Values of eof */
184#define ST_NOEOF 0
185#define ST_FM_HIT 1
186#define ST_FM 2
187#define ST_EOM_OK 3
188#define ST_EOM_ERROR 4
189#define ST_EOD_1 5
190#define ST_EOD_2 6
191#define ST_EOD 7
192/* EOD hit while reading => ST_EOD_1 => return zero => ST_EOD_2 =>
193 return zero => ST_EOD, return ENOSPC */
194/* When writing: ST_EOM_OK == early warning found, write OK
195 ST_EOD_1 == allow trying new write after early warning
196 ST_EOM_ERROR == early warning found, not able to write all */
197
198/* Values of rw */
199#define ST_IDLE 0
200#define ST_READING 1
201#define ST_WRITING 2
202
203/* Values of ready state */
204#define ST_READY 0
205#define ST_NOT_READY 1
206#define ST_NO_TAPE 2
207
208/* Values for door lock state */
209#define ST_UNLOCKED 0
210#define ST_LOCKED_EXPLICIT 1
211#define ST_LOCKED_AUTO 2
212#define ST_LOCK_FAILS 3
213
214/* Positioning SCSI-commands for Tandberg, etc. drives */
215#define QFA_REQUEST_BLOCK 0x02
216#define QFA_SEEK_BLOCK 0x0c
217
218/* Setting the binary options */
219#define ST_DONT_TOUCH 0
220#define ST_NO 1
221#define ST_YES 2
222
223#define EXTENDED_SENSE_START 18
224
225/* Masks for some conditions in the sense data */
226#define SENSE_FMK 0x80
227#define SENSE_EOM 0x40
228#define SENSE_ILI 0x20
229
230#endif