st.h 5.8 KB

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