0001
0002
0003 #ifndef _ST_H
0004 #define _ST_H
0005
0006 #include <linux/completion.h>
0007 #include <linux/mutex.h>
0008 #include <linux/kref.h>
0009 #include <scsi/scsi_cmnd.h>
0010
0011
0012 struct st_cmdstatus {
0013 int midlevel_result;
0014 struct scsi_sense_hdr sense_hdr;
0015 int have_sense;
0016 int residual;
0017 u64 uremainder64;
0018 u8 flags;
0019 u8 remainder_valid;
0020 u8 fixed_format;
0021 u8 deferred;
0022 };
0023
0024 struct scsi_tape;
0025
0026
0027 struct st_request {
0028 unsigned char cmd[MAX_COMMAND_SIZE];
0029 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
0030 int result;
0031 struct scsi_tape *stp;
0032 struct completion *waiting;
0033 struct bio *bio;
0034 };
0035
0036
0037 struct st_buffer {
0038 unsigned char cleared;
0039 unsigned short do_dio;
0040 int buffer_size;
0041 int buffer_blocks;
0042 int buffer_bytes;
0043 int read_pointer;
0044 int writing;
0045 int syscall_result;
0046 struct st_request *last_SRpnt;
0047 struct st_cmdstatus cmdstat;
0048 struct page **reserved_pages;
0049 int reserved_page_order;
0050 struct page **mapped_pages;
0051 struct rq_map_data map_data;
0052 unsigned char *b_data;
0053 unsigned short use_sg;
0054 unsigned short sg_segs;
0055 unsigned short frp_segs;
0056 };
0057
0058
0059 struct st_modedef {
0060 unsigned char defined;
0061 unsigned char sysv;
0062 unsigned char do_async_writes;
0063 unsigned char do_buffer_writes;
0064 unsigned char do_read_ahead;
0065 unsigned char defaults_for_writes;
0066 unsigned char default_compression;
0067 short default_density;
0068 int default_blksize;
0069 struct scsi_tape *tape;
0070 struct device *devs[2];
0071 struct cdev *cdevs[2];
0072 };
0073
0074
0075
0076 #define ST_NBR_MODE_BITS 2
0077 #define ST_NBR_MODES (1 << ST_NBR_MODE_BITS)
0078 #define ST_MODE_SHIFT (7 - ST_NBR_MODE_BITS)
0079 #define ST_MODE_MASK ((ST_NBR_MODES - 1) << ST_MODE_SHIFT)
0080
0081 #define ST_MAX_TAPES (1 << (20 - (ST_NBR_MODE_BITS + 1)))
0082 #define ST_MAX_TAPE_ENTRIES (ST_MAX_TAPES << (ST_NBR_MODE_BITS + 1))
0083
0084
0085 struct st_partstat {
0086 unsigned char rw;
0087 unsigned char eof;
0088 unsigned char at_sm;
0089 unsigned char last_block_valid;
0090 u32 last_block_visited;
0091 int drv_block;
0092 int drv_file;
0093 };
0094
0095
0096 struct scsi_tape_stats {
0097 atomic64_t read_byte_cnt;
0098 atomic64_t write_byte_cnt;
0099 atomic64_t in_flight;
0100 atomic64_t read_cnt;
0101 atomic64_t write_cnt;
0102 atomic64_t other_cnt;
0103
0104
0105 atomic64_t resid_cnt;
0106 atomic64_t tot_read_time;
0107 atomic64_t tot_write_time;
0108 atomic64_t tot_io_time;
0109 ktime_t read_time;
0110 ktime_t write_time;
0111 ktime_t other_time;
0112 atomic_t last_read_size;
0113 atomic_t last_write_size;
0114 };
0115
0116 #define ST_NBR_PARTITIONS 4
0117
0118
0119 struct scsi_tape {
0120 struct scsi_device *device;
0121 struct mutex lock;
0122 struct completion wait;
0123 struct st_buffer *buffer;
0124 int index;
0125
0126
0127 unsigned char omit_blklims;
0128 unsigned char do_auto_lock;
0129 unsigned char can_bsr;
0130 unsigned char can_partitions;
0131 unsigned char two_fm;
0132 unsigned char fast_mteom;
0133 unsigned char immediate;
0134 unsigned char scsi2_logical;
0135 unsigned char default_drvbuffer;
0136 unsigned char cln_mode;
0137 unsigned char cln_sense_value;
0138 unsigned char cln_sense_mask;
0139 unsigned char use_pf;
0140 unsigned char try_dio;
0141 unsigned char try_dio_now;
0142 unsigned char c_algo;
0143 unsigned char pos_unknown;
0144 unsigned char sili;
0145 unsigned char immediate_filemark;
0146 int tape_type;
0147 int long_timeout;
0148
0149
0150 struct st_modedef modes[ST_NBR_MODES];
0151 int current_mode;
0152
0153
0154 int partition;
0155 int new_partition;
0156 int nbr_partitions;
0157 struct st_partstat ps[ST_NBR_PARTITIONS];
0158 unsigned char dirty;
0159 unsigned char ready;
0160 unsigned char write_prot;
0161 unsigned char drv_write_prot;
0162 unsigned char in_use;
0163 unsigned char blksize_changed;
0164 unsigned char density_changed;
0165 unsigned char compression_changed;
0166 unsigned char drv_buffer;
0167 unsigned char density;
0168 unsigned char door_locked;
0169 unsigned char autorew_dev;
0170 unsigned char rew_at_close;
0171 unsigned char inited;
0172 unsigned char cleaning_req;
0173 int block_size;
0174 int min_block;
0175 int max_block;
0176 int recover_count;
0177 int recover_reg;
0178
0179 #if DEBUG
0180 unsigned char write_pending;
0181 int nbr_finished;
0182 int nbr_waits;
0183 int nbr_requests;
0184 int nbr_dio;
0185 int nbr_pages;
0186 unsigned char last_cmnd[6];
0187 unsigned char last_sense[16];
0188 #endif
0189 char name[DISK_NAME_LEN];
0190 struct kref kref;
0191 struct scsi_tape_stats *stats;
0192 };
0193
0194
0195 #define USE_PF 1
0196 #define PF_TESTED 2
0197
0198
0199 #define ST_NOEOF 0
0200 #define ST_FM_HIT 1
0201 #define ST_FM 2
0202 #define ST_EOM_OK 3
0203 #define ST_EOM_ERROR 4
0204 #define ST_EOD_1 5
0205 #define ST_EOD_2 6
0206 #define ST_EOD 7
0207
0208
0209
0210
0211
0212
0213
0214 #define ST_IDLE 0
0215 #define ST_READING 1
0216 #define ST_WRITING 2
0217
0218
0219 #define ST_READY 0
0220 #define ST_NOT_READY 1
0221 #define ST_NO_TAPE 2
0222
0223
0224 #define ST_UNLOCKED 0
0225 #define ST_LOCKED_EXPLICIT 1
0226 #define ST_LOCKED_AUTO 2
0227 #define ST_LOCK_FAILS 3
0228
0229
0230 #define QFA_REQUEST_BLOCK 0x02
0231 #define QFA_SEEK_BLOCK 0x0c
0232
0233
0234 #define ST_DONT_TOUCH 0
0235 #define ST_NO 1
0236 #define ST_YES 2
0237
0238 #define EXTENDED_SENSE_START 18
0239
0240
0241 #define SENSE_FMK 0x80
0242 #define SENSE_EOM 0x40
0243 #define SENSE_ILI 0x20
0244
0245 #endif