[SCSI] sg: fix iovec bugs introduced by the block layer conversion
[linux-2.6] / drivers / scsi / osst.h
1 /*
2  *      $Header: /cvsroot/osst/Driver/osst.h,v 1.16 2005/01/01 21:13:35 wriede Exp $
3  */
4
5 #include <asm/byteorder.h>
6 #include <linux/completion.h>
7 #include <linux/mutex.h>
8
9 /*      FIXME - rename and use the following two types or delete them!
10  *              and the types really should go to st.h anyway...
11  *      INQUIRY packet command - Data Format (From Table 6-8 of QIC-157C)
12  */
13 typedef struct {
14         unsigned        device_type     :5;     /* Peripheral Device Type */
15         unsigned        reserved0_765   :3;     /* Peripheral Qualifier - Reserved */
16         unsigned        reserved1_6t0   :7;     /* Reserved */
17         unsigned        rmb             :1;     /* Removable Medium Bit */
18         unsigned        ansi_version    :3;     /* ANSI Version */
19         unsigned        ecma_version    :3;     /* ECMA Version */
20         unsigned        iso_version     :2;     /* ISO Version */
21         unsigned        response_format :4;     /* Response Data Format */
22         unsigned        reserved3_45    :2;     /* Reserved */
23         unsigned        reserved3_6     :1;     /* TrmIOP - Reserved */
24         unsigned        reserved3_7     :1;     /* AENC - Reserved */
25         u8              additional_length;      /* Additional Length (total_length-4) */
26         u8              rsv5, rsv6, rsv7;       /* Reserved */
27         u8              vendor_id[8];           /* Vendor Identification */
28         u8              product_id[16];         /* Product Identification */
29         u8              revision_level[4];      /* Revision Level */
30         u8              vendor_specific[20];    /* Vendor Specific - Optional */
31         u8              reserved56t95[40];      /* Reserved - Optional */
32                                                 /* Additional information may be returned */
33 } idetape_inquiry_result_t;
34
35 /*
36  *      READ POSITION packet command - Data Format (From Table 6-57)
37  */
38 typedef struct {
39         unsigned        reserved0_10    :2;     /* Reserved */
40         unsigned        bpu             :1;     /* Block Position Unknown */    
41         unsigned        reserved0_543   :3;     /* Reserved */
42         unsigned        eop             :1;     /* End Of Partition */
43         unsigned        bop             :1;     /* Beginning Of Partition */
44         u8              partition;              /* Partition Number */
45         u8              reserved2, reserved3;   /* Reserved */
46         u32             first_block;            /* First Block Location */
47         u32             last_block;             /* Last Block Location (Optional) */
48         u8              reserved12;             /* Reserved */
49         u8              blocks_in_buffer[3];    /* Blocks In Buffer - (Optional) */
50         u32             bytes_in_buffer;        /* Bytes In Buffer (Optional) */
51 } idetape_read_position_result_t;
52
53 /*
54  *      Follows structures which are related to the SELECT SENSE / MODE SENSE
55  *      packet commands. 
56  */
57 #define COMPRESSION_PAGE           0x0f
58 #define COMPRESSION_PAGE_LENGTH    16
59
60 #define CAPABILITIES_PAGE          0x2a
61 #define CAPABILITIES_PAGE_LENGTH   20
62
63 #define TAPE_PARAMTR_PAGE          0x2b
64 #define TAPE_PARAMTR_PAGE_LENGTH   16
65
66 #define NUMBER_RETRIES_PAGE        0x2f
67 #define NUMBER_RETRIES_PAGE_LENGTH 4
68
69 #define BLOCK_SIZE_PAGE            0x30
70 #define BLOCK_SIZE_PAGE_LENGTH     4
71
72 #define BUFFER_FILLING_PAGE        0x33
73 #define BUFFER_FILLING_PAGE_LENGTH 4
74
75 #define VENDOR_IDENT_PAGE          0x36
76 #define VENDOR_IDENT_PAGE_LENGTH   8
77
78 #define LOCATE_STATUS_PAGE         0x37
79 #define LOCATE_STATUS_PAGE_LENGTH  0
80
81 #define MODE_HEADER_LENGTH         4
82
83
84 /*
85  *      REQUEST SENSE packet command result - Data Format.
86  */
87 typedef struct {
88         unsigned        error_code      :7;     /* Current of deferred errors */
89         unsigned        valid           :1;     /* The information field conforms to QIC-157C */
90         u8              reserved1       :8;     /* Segment Number - Reserved */
91         unsigned        sense_key       :4;     /* Sense Key */
92         unsigned        reserved2_4     :1;     /* Reserved */
93         unsigned        ili             :1;     /* Incorrect Length Indicator */
94         unsigned        eom             :1;     /* End Of Medium */
95         unsigned        filemark        :1;     /* Filemark */
96         u32             information __attribute__ ((packed));
97         u8              asl;                    /* Additional sense length (n-7) */
98         u32             command_specific;       /* Additional command specific information */
99         u8              asc;                    /* Additional Sense Code */
100         u8              ascq;                   /* Additional Sense Code Qualifier */
101         u8              replaceable_unit_code;  /* Field Replaceable Unit Code */
102         unsigned        sk_specific1    :7;     /* Sense Key Specific */
103         unsigned        sksv            :1;     /* Sense Key Specific information is valid */
104         u8              sk_specific2;           /* Sense Key Specific */
105         u8              sk_specific3;           /* Sense Key Specific */
106         u8              pad[2];                 /* Padding to 20 bytes */
107 } idetape_request_sense_result_t;
108
109 /*
110  *      Mode Parameter Header for the MODE SENSE packet command
111  */
112 typedef struct {
113         u8              mode_data_length;       /* Length of the following data transfer */
114         u8              medium_type;            /* Medium Type */
115         u8              dsp;                    /* Device Specific Parameter */
116         u8              bdl;                    /* Block Descriptor Length */
117 } osst_mode_parameter_header_t;
118
119 /*
120  *      Mode Parameter Block Descriptor the MODE SENSE packet command
121  *
122  *      Support for block descriptors is optional.
123  */
124 typedef struct {
125         u8              density_code;           /* Medium density code */
126         u8              blocks[3];              /* Number of blocks */
127         u8              reserved4;              /* Reserved */
128         u8              length[3];              /* Block Length */
129 } osst_parameter_block_descriptor_t;
130
131 /*
132  *      The Data Compression Page, as returned by the MODE SENSE packet command.
133  */
134 typedef struct {
135 #if   defined(__BIG_ENDIAN_BITFIELD)
136         unsigned        ps              :1;
137         unsigned        reserved0       :1;     /* Reserved */
138         unsigned        page_code       :6;     /* Page Code - Should be 0xf */
139 #elif defined(__LITTLE_ENDIAN_BITFIELD)
140         unsigned        page_code       :6;     /* Page Code - Should be 0xf */
141         unsigned        reserved0       :1;     /* Reserved */
142         unsigned        ps              :1;
143 #else
144 #error "Please fix <asm/byteorder.h>"
145 #endif
146         u8              page_length;            /* Page Length - Should be 14 */
147 #if   defined(__BIG_ENDIAN_BITFIELD)
148         unsigned        dce             :1;     /* Data Compression Enable */
149         unsigned        dcc             :1;     /* Data Compression Capable */
150         unsigned        reserved2       :6;     /* Reserved */
151 #elif defined(__LITTLE_ENDIAN_BITFIELD)
152         unsigned        reserved2       :6;     /* Reserved */
153         unsigned        dcc             :1;     /* Data Compression Capable */
154         unsigned        dce             :1;     /* Data Compression Enable */
155 #else
156 #error "Please fix <asm/byteorder.h>"
157 #endif
158 #if   defined(__BIG_ENDIAN_BITFIELD)
159         unsigned        dde             :1;     /* Data Decompression Enable */
160         unsigned        red             :2;     /* Report Exception on Decompression */
161         unsigned        reserved3       :5;     /* Reserved */
162 #elif defined(__LITTLE_ENDIAN_BITFIELD)
163         unsigned        reserved3       :5;     /* Reserved */
164         unsigned        red             :2;     /* Report Exception on Decompression */
165         unsigned        dde             :1;     /* Data Decompression Enable */
166 #else
167 #error "Please fix <asm/byteorder.h>"
168 #endif
169         u32             ca;                     /* Compression Algorithm */
170         u32             da;                     /* Decompression Algorithm */
171         u8              reserved[4];            /* Reserved */
172 } osst_data_compression_page_t;
173
174 /*
175  *      The Medium Partition Page, as returned by the MODE SENSE packet command.
176  */
177 typedef struct {
178 #if   defined(__BIG_ENDIAN_BITFIELD)
179         unsigned        ps              :1;
180         unsigned        reserved1_6     :1;     /* Reserved */
181         unsigned        page_code       :6;     /* Page Code - Should be 0x11 */
182 #elif defined(__LITTLE_ENDIAN_BITFIELD)
183         unsigned        page_code       :6;     /* Page Code - Should be 0x11 */
184         unsigned        reserved1_6     :1;     /* Reserved */
185         unsigned        ps              :1;
186 #else
187 #error "Please fix <asm/byteorder.h>"
188 #endif
189         u8              page_length;            /* Page Length - Should be 6 */
190         u8              map;                    /* Maximum Additional Partitions - Should be 0 */
191         u8              apd;                    /* Additional Partitions Defined - Should be 0 */
192 #if   defined(__BIG_ENDIAN_BITFIELD)
193         unsigned        fdp             :1;     /* Fixed Data Partitions */
194         unsigned        sdp             :1;     /* Should be 0 */
195         unsigned        idp             :1;     /* Should be 0 */
196         unsigned        psum            :2;     /* Should be 0 */
197         unsigned        reserved4_012   :3;     /* Reserved */
198 #elif defined(__LITTLE_ENDIAN_BITFIELD)
199         unsigned        reserved4_012   :3;     /* Reserved */
200         unsigned        psum            :2;     /* Should be 0 */
201         unsigned        idp             :1;     /* Should be 0 */
202         unsigned        sdp             :1;     /* Should be 0 */
203         unsigned        fdp             :1;     /* Fixed Data Partitions */
204 #else
205 #error "Please fix <asm/byteorder.h>"
206 #endif
207         u8              mfr;                    /* Medium Format Recognition */
208         u8              reserved[2];            /* Reserved */
209 } osst_medium_partition_page_t;
210
211 /*
212  *      Capabilities and Mechanical Status Page
213  */
214 typedef struct {
215 #if   defined(__BIG_ENDIAN_BITFIELD)
216         unsigned        reserved1_67    :2;
217         unsigned        page_code       :6;     /* Page code - Should be 0x2a */
218 #elif defined(__LITTLE_ENDIAN_BITFIELD)
219         unsigned        page_code       :6;     /* Page code - Should be 0x2a */
220         unsigned        reserved1_67    :2;
221 #else
222 #error "Please fix <asm/byteorder.h>"
223 #endif
224         u8              page_length;            /* Page Length - Should be 0x12 */
225         u8              reserved2, reserved3;
226 #if   defined(__BIG_ENDIAN_BITFIELD)
227         unsigned        reserved4_67    :2;
228         unsigned        sprev           :1;     /* Supports SPACE in the reverse direction */
229         unsigned        reserved4_1234  :4;
230         unsigned        ro              :1;     /* Read Only Mode */
231 #elif defined(__LITTLE_ENDIAN_BITFIELD)
232         unsigned        ro              :1;     /* Read Only Mode */
233         unsigned        reserved4_1234  :4;
234         unsigned        sprev           :1;     /* Supports SPACE in the reverse direction */
235         unsigned        reserved4_67    :2;
236 #else
237 #error "Please fix <asm/byteorder.h>"
238 #endif
239 #if   defined(__BIG_ENDIAN_BITFIELD)
240         unsigned        reserved5_67    :2;
241         unsigned        qfa             :1;     /* Supports the QFA two partition formats */
242         unsigned        reserved5_4     :1;
243         unsigned        efmt            :1;     /* Supports ERASE command initiated formatting */
244         unsigned        reserved5_012   :3;
245 #elif defined(__LITTLE_ENDIAN_BITFIELD)
246         unsigned        reserved5_012   :3;
247         unsigned        efmt            :1;     /* Supports ERASE command initiated formatting */
248         unsigned        reserved5_4     :1;
249         unsigned        qfa             :1;     /* Supports the QFA two partition formats */
250         unsigned        reserved5_67    :2;
251 #else
252 #error "Please fix <asm/byteorder.h>"
253 #endif
254 #if   defined(__BIG_ENDIAN_BITFIELD)
255         unsigned        cmprs           :1;     /* Supports data compression */
256         unsigned        ecc             :1;     /* Supports error correction */
257         unsigned        reserved6_45    :2;     /* Reserved */  
258         unsigned        eject           :1;     /* The device can eject the volume */
259         unsigned        prevent         :1;     /* The device defaults in the prevent state after power up */
260         unsigned        locked          :1;     /* The volume is locked */
261         unsigned        lock            :1;     /* Supports locking the volume */
262 #elif defined(__LITTLE_ENDIAN_BITFIELD)
263         unsigned        lock            :1;     /* Supports locking the volume */
264         unsigned        locked          :1;     /* The volume is locked */
265         unsigned        prevent         :1;     /* The device defaults in the prevent state after power up */
266         unsigned        eject           :1;     /* The device can eject the volume */
267         unsigned        reserved6_45    :2;     /* Reserved */  
268         unsigned        ecc             :1;     /* Supports error correction */
269         unsigned        cmprs           :1;     /* Supports data compression */
270 #else
271 #error "Please fix <asm/byteorder.h>"
272 #endif
273 #if   defined(__BIG_ENDIAN_BITFIELD)
274         unsigned        blk32768        :1;     /* slowb - the device restricts the byte count for PIO */
275                                                 /* transfers for slow buffer memory ??? */
276                                                 /* Also 32768 block size in some cases */
277         unsigned        reserved7_3_6   :4;
278         unsigned        blk1024         :1;     /* Supports 1024 bytes block size */
279         unsigned        blk512          :1;     /* Supports 512 bytes block size */
280         unsigned        reserved7_0     :1;
281 #elif defined(__LITTLE_ENDIAN_BITFIELD)
282         unsigned        reserved7_0     :1;
283         unsigned        blk512          :1;     /* Supports 512 bytes block size */
284         unsigned        blk1024         :1;     /* Supports 1024 bytes block size */
285         unsigned        reserved7_3_6   :4;
286         unsigned        blk32768        :1;     /* slowb - the device restricts the byte count for PIO */
287                                                 /* transfers for slow buffer memory ??? */
288                                                 /* Also 32768 block size in some cases */
289 #else
290 #error "Please fix <asm/byteorder.h>"
291 #endif
292         __be16          max_speed;              /* Maximum speed supported in KBps */
293         u8              reserved10, reserved11;
294         __be16          ctl;                    /* Continuous Transfer Limit in blocks */
295         __be16          speed;                  /* Current Speed, in KBps */
296         __be16          buffer_size;            /* Buffer Size, in 512 bytes */
297         u8              reserved18, reserved19;
298 } osst_capabilities_page_t;
299
300 /*
301  *      Block Size Page
302  */
303 typedef struct {
304 #if   defined(__BIG_ENDIAN_BITFIELD)
305         unsigned        ps              :1;
306         unsigned        reserved1_6     :1;
307         unsigned        page_code       :6;     /* Page code - Should be 0x30 */
308 #elif defined(__LITTLE_ENDIAN_BITFIELD)
309         unsigned        page_code       :6;     /* Page code - Should be 0x30 */
310         unsigned        reserved1_6     :1;
311         unsigned        ps              :1;
312 #else
313 #error "Please fix <asm/byteorder.h>"
314 #endif
315         u8              page_length;            /* Page Length - Should be 2 */
316         u8              reserved2;
317 #if   defined(__BIG_ENDIAN_BITFIELD)
318         unsigned        one             :1;
319         unsigned        reserved2_6     :1;
320         unsigned        record32_5      :1;
321         unsigned        record32        :1;
322         unsigned        reserved2_23    :2;
323         unsigned        play32_5        :1;
324         unsigned        play32          :1;
325 #elif defined(__LITTLE_ENDIAN_BITFIELD)
326         unsigned        play32          :1;
327         unsigned        play32_5        :1;
328         unsigned        reserved2_23    :2;
329         unsigned        record32        :1;
330         unsigned        record32_5      :1;
331         unsigned        reserved2_6     :1;
332         unsigned        one             :1;
333 #else
334 #error "Please fix <asm/byteorder.h>"
335 #endif
336 } osst_block_size_page_t;
337
338 /*
339  *      Tape Parameters Page
340  */
341 typedef struct {
342 #if   defined(__BIG_ENDIAN_BITFIELD)
343         unsigned        ps              :1;
344         unsigned        reserved1_6     :1;
345         unsigned        page_code       :6;     /* Page code - Should be 0x2b */
346 #elif defined(__LITTLE_ENDIAN_BITFIELD)
347         unsigned        page_code       :6;     /* Page code - Should be 0x2b */
348         unsigned        reserved1_6     :1;
349         unsigned        ps              :1;
350 #else
351 #error "Please fix <asm/byteorder.h>"
352 #endif
353         u8              reserved2;
354         u8              density;
355         u8              reserved3,reserved4;
356         __be16          segtrk;
357         __be16          trks;
358         u8              reserved5,reserved6,reserved7,reserved8,reserved9,reserved10;
359 } osst_tape_paramtr_page_t;
360
361 /* OnStream definitions */
362
363 #define OS_CONFIG_PARTITION     (0xff)
364 #define OS_DATA_PARTITION       (0)
365 #define OS_PARTITION_VERSION    (1)
366
367 /*
368  * partition
369  */
370 typedef struct os_partition_s {
371         __u8    partition_num;
372         __u8    par_desc_ver;
373         __be16  wrt_pass_cntr;
374         __be32  first_frame_ppos;
375         __be32  last_frame_ppos;
376         __be32  eod_frame_ppos;
377 } os_partition_t;
378
379 /*
380  * DAT entry
381  */
382 typedef struct os_dat_entry_s {
383         __be32  blk_sz;
384         __be16  blk_cnt;
385         __u8    flags;
386         __u8    reserved;
387 } os_dat_entry_t;
388
389 /*
390  * DAT
391  */
392 #define OS_DAT_FLAGS_DATA       (0xc)
393 #define OS_DAT_FLAGS_MARK       (0x1)
394
395 typedef struct os_dat_s {
396         __u8            dat_sz;
397         __u8            reserved1;
398         __u8            entry_cnt;
399         __u8            reserved3;
400         os_dat_entry_t  dat_list[16];
401 } os_dat_t;
402
403 /*
404  * Frame types
405  */
406 #define OS_FRAME_TYPE_FILL      (0)
407 #define OS_FRAME_TYPE_EOD       (1 << 0)
408 #define OS_FRAME_TYPE_MARKER    (1 << 1)
409 #define OS_FRAME_TYPE_HEADER    (1 << 3)
410 #define OS_FRAME_TYPE_DATA      (1 << 7)
411
412 /*
413  * AUX
414  */
415 typedef struct os_aux_s {
416         __be32          format_id;              /* hardware compability AUX is based on */
417         char            application_sig[4];     /* driver used to write this media */
418         __be32          hdwr;                   /* reserved */
419         __be32          update_frame_cntr;      /* for configuration frame */
420         __u8            frame_type;
421         __u8            frame_type_reserved;
422         __u8            reserved_18_19[2];
423         os_partition_t  partition;
424         __u8            reserved_36_43[8];
425         __be32          frame_seq_num;
426         __be32          logical_blk_num_high;
427         __be32          logical_blk_num;
428         os_dat_t        dat;
429         __u8            reserved188_191[4];
430         __be32          filemark_cnt;
431         __be32          phys_fm;
432         __be32          last_mark_ppos;
433         __u8            reserved204_223[20];
434
435         /*
436          * __u8         app_specific[32];
437          *
438          * Linux specific fields:
439          */
440          __be32         next_mark_ppos;         /* when known, points to next marker */
441          __be32         last_mark_lbn;          /* storing log_blk_num of last mark is extends ADR spec */
442          __u8           linux_specific[24];
443
444         __u8            reserved_256_511[256];
445 } os_aux_t;
446
447 #define OS_FM_TAB_MAX 1024
448
449 typedef struct os_fm_tab_s {
450         __u8            fm_part_num;
451         __u8            reserved_1;
452         __u8            fm_tab_ent_sz;
453         __u8            reserved_3;
454         __be16          fm_tab_ent_cnt;
455         __u8            reserved6_15[10];
456         __be32          fm_tab_ent[OS_FM_TAB_MAX];
457 } os_fm_tab_t;
458
459 typedef struct os_ext_trk_ey_s {
460         __u8            et_part_num;
461         __u8            fmt;
462         __be16          fm_tab_off;
463         __u8            reserved4_7[4];
464         __be32          last_hlb_hi;
465         __be32          last_hlb;
466         __be32          last_pp;
467         __u8            reserved20_31[12];
468 } os_ext_trk_ey_t;
469
470 typedef struct os_ext_trk_tb_s {
471         __u8            nr_stream_part;
472         __u8            reserved_1;
473         __u8            et_ent_sz;
474         __u8            reserved3_15[13];
475         os_ext_trk_ey_t dat_ext_trk_ey;
476         os_ext_trk_ey_t qfa_ext_trk_ey;
477 } os_ext_trk_tb_t;
478
479 typedef struct os_header_s {
480         char            ident_str[8];
481         __u8            major_rev;
482         __u8            minor_rev;
483         __be16          ext_trk_tb_off;
484         __u8            reserved12_15[4];
485         __u8            pt_par_num;
486         __u8            pt_reserved1_3[3];
487         os_partition_t  partition[16];
488         __be32          cfg_col_width;
489         __be32          dat_col_width;
490         __be32          qfa_col_width;
491         __u8            cartridge[16];
492         __u8            reserved304_511[208];
493         __be32          old_filemark_list[16680/4];             /* in ADR 1.4 __u8 track_table[16680] */
494         os_ext_trk_tb_t ext_track_tb;
495         __u8            reserved17272_17735[464];
496         os_fm_tab_t     dat_fm_tab;
497         os_fm_tab_t     qfa_fm_tab;
498         __u8            reserved25960_32767[6808];
499 } os_header_t;
500
501
502 /*
503  * OnStream ADRL frame
504  */
505 #define OS_FRAME_SIZE   (32 * 1024 + 512)
506 #define OS_DATA_SIZE    (32 * 1024)
507 #define OS_AUX_SIZE     (512)
508 //#define OSST_MAX_SG      2
509
510 /* The OnStream tape buffer descriptor. */
511 struct osst_buffer {
512   unsigned char in_use;
513   unsigned char dma;    /* DMA-able buffer */
514   int buffer_size;
515   int buffer_blocks;
516   int buffer_bytes;
517   int read_pointer;
518   int writing;
519   int midlevel_result;
520   int syscall_result;
521   struct osst_request *last_SRpnt;
522   struct st_cmdstatus cmdstat;
523   struct rq_map_data map_data;
524   unsigned char *b_data;
525   os_aux_t *aux;               /* onstream AUX structure at end of each block     */
526   unsigned short use_sg;       /* zero or number of s/g segments for this adapter */
527   unsigned short sg_segs;      /* number of segments in s/g list                  */
528   unsigned short orig_sg_segs; /* number of segments allocated at first try       */
529   struct scatterlist sg[1];    /* MUST BE last item                               */
530 } ;
531
532 /* The OnStream tape drive descriptor */
533 struct osst_tape {
534   struct scsi_driver *driver;
535   unsigned capacity;
536   struct scsi_device *device;
537   struct mutex lock;           /* for serialization */
538   struct completion wait;      /* for SCSI commands */
539   struct osst_buffer * buffer;
540
541   /* Drive characteristics */
542   unsigned char omit_blklims;
543   unsigned char do_auto_lock;
544   unsigned char can_bsr;
545   unsigned char can_partitions;
546   unsigned char two_fm;
547   unsigned char fast_mteom;
548   unsigned char restr_dma;
549   unsigned char scsi2_logical;
550   unsigned char default_drvbuffer;  /* 0xff = don't touch, value 3 bits */
551   unsigned char pos_unknown;        /* after reset position unknown */
552   int write_threshold;
553   int timeout;                  /* timeout for normal commands */
554   int long_timeout;             /* timeout for commands known to take long time*/
555
556   /* Mode characteristics */
557   struct st_modedef modes[ST_NBR_MODES];
558   int current_mode;
559
560   /* Status variables */
561   int partition;
562   int new_partition;
563   int nbr_partitions;    /* zero until partition support enabled */
564   struct st_partstat ps[ST_NBR_PARTITIONS];
565   unsigned char dirty;
566   unsigned char ready;
567   unsigned char write_prot;
568   unsigned char drv_write_prot;
569   unsigned char in_use;
570   unsigned char blksize_changed;
571   unsigned char density_changed;
572   unsigned char compression_changed;
573   unsigned char drv_buffer;
574   unsigned char density;
575   unsigned char door_locked;
576   unsigned char rew_at_close;
577   unsigned char inited;
578   int block_size;
579   int min_block;
580   int max_block;
581   int recover_count;            /* from tape opening */
582   int abort_count;
583   int write_count;
584   int read_count;
585   int recover_erreg;            /* from last status call */
586   /*
587    * OnStream specific data
588    */
589   int      os_fw_rev;                          /* the firmware revision * 10000 */
590   unsigned char  raw;                          /* flag OnStream raw access (32.5KB block size) */
591   unsigned char  poll;                         /* flag that this drive needs polling (IDE|firmware) */
592   unsigned char  frame_in_buffer;              /* flag that the frame as per frame_seq_number
593                                                 * has been read into STp->buffer and is valid */
594   int      frame_seq_number;                   /* logical frame number */
595   int      logical_blk_num;                    /* logical block number */
596   unsigned first_frame_position;               /* physical frame to be transferred to/from host */
597   unsigned last_frame_position;                /* physical frame to be transferd to/from tape */
598   int      cur_frames;                         /* current number of frames in internal buffer */
599   int      max_frames;                         /* max number of frames in internal buffer */
600   char     application_sig[5];                 /* application signature */
601   unsigned char  fast_open;                    /* flag that reminds us we didn't check headers at open */
602   unsigned short wrt_pass_cntr;                /* write pass counter */
603   int      update_frame_cntr;                  /* update frame counter */
604   int      onstream_write_error;               /* write error recovery active */
605   int      header_ok;                          /* header frame verified ok */
606   int      linux_media;                        /* reading linux-specifc media */
607   int      linux_media_version;
608   os_header_t * header_cache;                  /* cache is kept for filemark positions */
609   int      filemark_cnt;
610   int      first_mark_ppos;
611   int      last_mark_ppos;
612   int      last_mark_lbn;                       /* storing log_blk_num of last mark is extends ADR spec */
613   int      first_data_ppos;
614   int      eod_frame_ppos;
615   int      eod_frame_lfa;
616   int      write_type;                          /* used in write error recovery */
617   int      read_error_frame;                    /* used in read error recovery */
618   unsigned long cmd_start_time;
619   unsigned long max_cmd_time;
620
621 #if DEBUG
622   unsigned char write_pending;
623   int nbr_finished;
624   int nbr_waits;
625   unsigned char last_cmnd[6];
626   unsigned char last_sense[16];
627 #endif
628   struct gendisk *drive;
629 } ;
630
631 /* scsi tape command */
632 struct osst_request {
633         unsigned char cmd[MAX_COMMAND_SIZE];
634         unsigned char sense[SCSI_SENSE_BUFFERSIZE];
635         int result;
636         struct osst_tape *stp;
637         struct completion *waiting;
638         struct bio *bio;
639 };
640
641 /* Values of write_type */
642 #define OS_WRITE_DATA      0
643 #define OS_WRITE_EOD       1
644 #define OS_WRITE_NEW_MARK  2
645 #define OS_WRITE_LAST_MARK 3
646 #define OS_WRITE_HEADER    4
647 #define OS_WRITE_FILLER    5
648
649 /* Additional rw state */
650 #define OS_WRITING_COMPLETE 3