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