1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_SCSI_TARGETS_STDEF_H 27 #define _SYS_SCSI_TARGETS_STDEF_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include <sys/sunddi.h> 32 #include <sys/note.h> 33 #include <sys/condvar.h> 34 #include <sys/kstat.h> 35 #include <sys/scsi/scsi_types.h> 36 #include <sys/mtio.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * Defines for SCSI tape drives. 44 */ 45 46 /* 47 * Maximum variable length record size for a single request 48 */ 49 #define ST_MAXRECSIZE_VARIABLE 65535 50 51 /* 52 * If the requested record size exceeds ST_MAXRECSIZE_VARIABLE, 53 * then the following define is used. 54 */ 55 #define ST_MAXRECSIZE_VARIABLE_LIMIT 65534 56 57 #define ST_MAXRECSIZE_FIXED (63<<10) /* maximum fixed record size */ 58 #define INF 1000000000 59 60 /* 61 * Supported tape device types plus default type for opening. 62 * Types 10 - 13, are special (ancient too) drives - *NOT SUPPORTED* 63 * Types 14 - 1f, are 1/4-inch cartridge drives. 64 * Types 20 - 28, are 1/2-inch cartridge or reel drives. 65 * Types 28+, are rdat (vcr) drives. 66 */ 67 #define ST_TYPE_INVALID 0x00 68 69 #define ST_TYPE_SYSGEN1 MT_ISSYSGEN11 /* Sysgen with QIC-11 only */ 70 #define ST_TYPE_SYSGEN MT_ISSYSGEN /* Sysgen with QIC-24 and QIC-11 */ 71 72 #define ST_TYPE_DEFAULT MT_ISDEFAULT /* Generic 1/4" or undetermined */ 73 #define ST_TYPE_EMULEX MT_ISMT02 /* Emulex MT-02 */ 74 #define ST_TYPE_ARCHIVE MT_ISVIPER1 /* Archive QIC-150 */ 75 #define ST_TYPE_WANGTEK MT_ISWANGTEK1 /* Wangtek QIC-150 */ 76 77 #define ST_TYPE_CDC MT_ISCDC /* CDC - (not tested) */ 78 #define ST_TYPE_FUJI MT_ISFUJI /* Fujitsu - (not tested) */ 79 #define ST_TYPE_KENNEDY MT_ISKENNEDY /* Kennedy */ 80 #define ST_TYPE_ANRITSU MT_ISANRITSU /* Anritsu */ 81 #define ST_TYPE_HP MT_ISHP /* HP */ 82 #define ST_TYPE_HIC MT_ISCCS23 /* Generic 1/2" Cartridge */ 83 #define ST_TYPE_REEL MT_ISCCS24 /* Generic 1/2" Reel Tape */ 84 #define ST_TYPE_DAT MT_ISCCS28 /* Generic DAT Tape */ 85 86 #define ST_TYPE_EXABYTE MT_ISEXABYTE /* Exabyte 8200 */ 87 #define ST_TYPE_EXB8500 MT_ISEXB8500 /* Exabyte 8500 */ 88 #define ST_TYPE_WANGTHS MT_ISWANGTHS /* Wangtek 6130HS */ 89 #define ST_TYPE_WANGDAT MT_ISWANGDAT /* WangDAT */ 90 #define ST_TYPE_PYTHON MT_ISPYTHON /* Archive Python DAT */ 91 #define ST_TYPE_STC3490 MT_ISSTC /* IBM STC 3490 */ 92 #define ST_TYPE_TAND25G MT_ISTAND25G /* TANDBERG 2.5G */ 93 #define ST_TYPE_DLT MT_ISDLT /* DLT */ 94 #define ST_TYPE_STK9840 MT_ISSTK9840 /* StorageTek 9840, 9940, 9840B */ 95 #define ST_TYPE_BMDLT1 MT_ISBMDLT1 /* Benchmark DTL1 */ 96 #define ST_TYPE_LTO MT_LTO /* sun: LTO's by HP, Seagate, IBM.. */ 97 #define ST_TYPE_AIT MT_ISAIT /* Sony AIT I, II, III and SAIT */ 98 #define ST_LAST_TYPE ST_TYPE_AIT /* Add new above type and change this */ 99 100 101 /* Internal flags */ 102 #define ST_DYNAMIC 0x2000 /* Device name has been dynamically */ 103 /* alloc'ed from the st.conf entry, */ 104 /* instead of being used from the */ 105 /* st_drivetypes array. */ 106 107 /* 108 * Defines for supported drive options 109 * 110 * WARNING : THESE OPTIONS SHOULD NEVER BE CHANGED, AS OLDER CONFIGURATIONS 111 * WILL DEPEND ON THE FLAG VALUES REMAINING THE SAME 112 */ 113 #define ST_VARIABLE 0x001 /* Device supports variable */ 114 /* length record sizes */ 115 #define ST_QIC 0x002 /* QIC tape device */ 116 #define ST_REEL 0x004 /* 1/2-inch reel tape device */ 117 #define ST_BSF 0x008 /* Device supports backspace */ 118 /* file as in mt(1) bsf : */ 119 /* backspace over EOF marks. */ 120 /* Devices not supporting bsf */ 121 /* will fail with ENOTTY upon */ 122 /* use of bsf */ 123 #define ST_BSR 0x010 /* Device supports backspace */ 124 /* record as in mt(1) bsr : */ 125 /* backspace over records. If */ 126 /* the device does not support */ 127 /* bsr, the st driver emulates */ 128 /* the action by rewinding the */ 129 /* tape and using forward space */ 130 /* file (fsf) to the correct */ 131 /* file and then uses forward */ 132 /* space record (fsr) to the */ 133 /* correct record */ 134 #define ST_LONG_ERASE 0x020 /* Device needs a longer time */ 135 /* than normal to erase */ 136 #define ST_AUTODEN_OVERRIDE 0x040 /* Auto-Density override flag */ 137 /* Device can figure out the */ 138 /* tape density automatically, */ 139 /* without issuing a */ 140 /* mode-select/mode-sense */ 141 #define ST_NOBUF 0x080 /* Don't use buffered mode. */ 142 /* This disables the device's */ 143 /* ability for buffered writes */ 144 /* I.e. The device acknowledges */ 145 /* write completion after the */ 146 /* data is written to the */ 147 /* device's buffer, but before */ 148 /* all the data is actually */ 149 /* written to tape */ 150 #define ST_RESERVED_BIT1 0x100 /* resreved bit */ 151 /* parity while talking to it. */ 152 #define ST_KNOWS_EOD 0x200 /* Device knows when EOD (End */ 153 /* of Data) has been reached. */ 154 /* If the device knows EOD, st */ 155 /* uses fast file skipping. */ 156 /* If it does not know EOD, */ 157 /* file skipping happens one */ 158 /* file at a time. */ 159 #define ST_UNLOADABLE 0x400 /* Device will not complain if */ 160 /* the st driver is unloaded & */ 161 /* loaded again; e.g. will */ 162 /* return the correct inquiry */ 163 /* string */ 164 #define ST_SOFT_ERROR_REPORTING 0x800 /* Do request or log sense on */ 165 /* close to report soft errors. */ 166 /* Currently only Exabyte and */ 167 /* DAT drives support this */ 168 /* feature. */ 169 #define ST_LONG_TIMEOUTS 0x1000 /* Device needs 5 times longer */ 170 /* timeouts for normal */ 171 /* operation */ 172 #define ST_BUFFERED_WRITES 0x4000 /* The data is buffered in the */ 173 /* driver and pre-acked to the */ 174 /* application */ 175 #define ST_NO_RECSIZE_LIMIT 0x8000 /* For variable record size */ 176 /* devices only. If flag is */ 177 /* set, then don't limit */ 178 /* record size to 64k as in */ 179 /* pre-Solaris 2.4 releases. */ 180 /* The only limit on the */ 181 /* record size will be the max */ 182 /* record size the device can */ 183 /* handle or the max DMA */ 184 /* transfer size of the */ 185 /* machine, which ever is */ 186 /* smaller. Beware of */ 187 /* incompatabilities with */ 188 /* tapes of pre-Solaris 2.4 */ 189 /* OS's written with large */ 190 /* (>64k) block sizes, as */ 191 /* their true block size is */ 192 /* a max of approx 64k */ 193 #define ST_MODE_SEL_COMP 0x10000 /* use mode select of device */ 194 /* configuration page (0x10) to */ 195 /* enable/disable compression */ 196 /* instead of density codes for */ 197 /* the "c" and "u" devices */ 198 #define ST_NO_RESERVE_RELEASE 0x20000 /* For devices which do not */ 199 /* support RESERVE/RELEASE SCSI */ 200 /* command. If this is enabled */ 201 /* then reserve/release would */ 202 /* not be used during open/ */ 203 /* close for High Availability */ 204 #define ST_READ_IGNORE_ILI 0x40000 /* This flag is only applicable */ 205 /* to variable block devices */ 206 /* which support the SILI bit */ 207 /* option. It indicates that */ 208 /* the SILI bit will be ignored */ 209 /* during reads */ 210 #define ST_READ_IGNORE_EOFS 0x80000 /* When this flag is set two */ 211 /* EOF marks do not indicate an */ 212 /* EOM. This option is only */ 213 /* supported on 1/2" reel tapes */ 214 #define ST_SHORT_FILEMARKS 0x100000 /* This option applies only to */ 215 /* EXABYTE 8mm tape drives */ 216 /* which support short */ 217 /* filemarks. When this flag */ 218 /* is set, short filemarks */ 219 /* will be used for writing */ 220 /* filemarks. */ 221 #define ST_EJECT_ON_CHANGER_FAILURE 0x200000 /* When this flag is set */ 222 /* and the tape is trapped in */ 223 /* the medium changer, the tape */ 224 /* is automatically ejected */ 225 #define ST_RETRY_ON_RECOVERED_DEFERRED_ERROR 0x400000 226 /* This option applies only to */ 227 /* IBM MAGSTAR 3590. If this */ 228 /* flag is set, the st driver */ 229 /* will retry the last cmd if */ 230 /* the last error cause a check */ 231 /* condition with error code */ 232 /* 0x71 and sense code 0x01 */ 233 #define ST_KNOWS_MEDIA 0x800000 /* Use configured media type */ 234 /* detected to select correct */ 235 /* density code. */ 236 #define ST_WORMABLE 0x1000000 237 /* Drive is capable of doing */ 238 /* Write Appends only at EOM */ 239 /* if WORM media type is loaded */ 240 #define ST_CLN_TYPE_1 0x10000000 /* When this flag is set, */ 241 /* the tape drive provides the */ 242 /* clean bit information in */ 243 /* byte 21, bitmask 0x08 of */ 244 /* Request Sense data */ 245 #define ST_CLN_TYPE_2 0x20000000 /* When this flag is set, */ 246 /* the tape drive provides the */ 247 /* clean bit information in */ 248 /* byte 70, bitmask 0xc0 of */ 249 /* Request Sense data */ 250 #define ST_CLN_TYPE_3 0x40000000 /* When this flag is set, */ 251 /* the tape drive provides the */ 252 /* clean bit information in */ 253 /* byte 18, bitmask 0x01 of */ 254 /* Request Sense data */ 255 256 #define ST_CLN_MASK (ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3) 257 #define ST_VALID_OPTS (ST_VARIABLE | ST_QIC | ST_REEL | ST_BSF | ST_BSR |\ 258 ST_LONG_ERASE | ST_AUTODEN_OVERRIDE | ST_NOBUF | ST_KNOWS_EOD |\ 259 ST_UNLOADABLE | ST_SOFT_ERROR_REPORTING | ST_LONG_TIMEOUTS |\ 260 ST_NO_RECSIZE_LIMIT | ST_MODE_SEL_COMP | ST_NO_RESERVE_RELEASE |\ 261 ST_READ_IGNORE_ILI | ST_READ_IGNORE_EOFS | ST_SHORT_FILEMARKS |\ 262 ST_EJECT_ON_CHANGER_FAILURE | ST_RETRY_ON_RECOVERED_DEFERRED_ERROR |\ 263 ST_WORMABLE | ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3) 264 265 #define NDENSITIES MT_NDENSITIES 266 #define NSPEEDS MT_NSPEEDS 267 268 /* 269 * defines for Log Sense Pages 270 */ 271 #define SUPPORTED_LOG_PAGES_PAGE 0x00 272 #define TAPE_SEQUENTIAL_PAGE 0x0c 273 #define TAPE_ALERT_PAGE 0x2e 274 275 /* 276 * Log Page Control definitions 277 */ 278 #define CURRENT_THRESHOLD_VALUES 0x00 279 #define CURRENT_CUMULATIVE_VALUES 0x40 280 #define DEFAULT_THRESHOLD_VALUES 0x80 281 #define DEFAULT_CUMULATIVE_VALUES 0xC0 282 283 /* 284 * Tape Alert Flag definitions 285 */ 286 typedef enum { 287 TAF_READ_WARN = 0x01, 288 TAF_WRITE_WARN = 0x02, 289 TAF_HARD_ERR = 0x03, 290 TAF_MEDIA_ERR = 0x04, 291 TAF_READ_FAIL = 0x05, 292 TAF_WRITE_FAIL = 0x06, 293 TAF_MEDIA_LIFE = 0x07, 294 TAF_MEDIA_NOT_DATA_GRADE = 0x08, 295 TAF_WRITE_PROTECTED = 0x09, 296 TAF_NO_MEDIA_REMOVE = 0x0A, 297 TAF_CLEANING_MEDIA = 0x0B, 298 TAF_UNSUPPERTED_FORMAT = 0x0C, 299 TAF_RECOVERED_TAPE_BREAK = 0x0D, 300 TAF_TAPE_BREAK_FAUL = 0x0E, 301 TAF_CART_MEM_FAIL = 0x0F, 302 TAF_FORCED_EJECT = 0x10, 303 TAF_READ_ONLY_FORMAT = 0x11, 304 TAF_TAPE_DIR_CORRUPT = 0x12, 305 TAF_NEARING_MEDIA_LIFE = 0x13, 306 TAF_CLEAN_NOW = 0x14, 307 TAF_CLEAN_PERIODIC = 0x15, 308 TAF_EXP_CLEAN_CART = 0x16, 309 TAF_INVALID_CLEAN_MEDIA = 0x17, 310 TAF_RETENSION_REQUEST = 0x18, 311 TAF_DUAL_PORT_INTERFACE_ERR = 0x19, 312 TAF_COOLING_FAN_FAIL = 0x1A, 313 TAF_POWER_SUPPLY_FAIL = 0x1B, 314 TAF_POWER_CONSUMPTION = 0x1C, 315 TAF_DRIVE_MAINT_REQUEST = 0x1D, 316 TAF_HARDWARE_A = 0x1E, 317 TAF_HARDWARE_B = 0x1F, 318 TAF_INTERFACE = 0x20, 319 TAF_EJECT_MEDIA = 0x21, 320 TAF_DOWNLOAD_FAIL = 0x22, 321 TAF_DRIVE_HUMIDITY = 0x23, 322 TAF_DRIVE_TEMP = 0x24, 323 TAF_DRIVE_VOLTAGE = 0x25, 324 TAF_PREDICTIVE_FAIL = 0x26, 325 TAF_DIAG_REQUIRED = 0x27, 326 TAF_LOADER_HDWR_A = 0x28, 327 TAF_LOADER_STRAY_TAPE = 0x29, 328 TAF_LOADER_HDWR_B = 0x2A, 329 TAF_LOADER_DOOR = 0x2B, 330 TAF_LOADER_HDWR_C = 0x2C, 331 TAF_LOADER_MAGAZINE = 0x2D, 332 TAF_LOADER_PREDICTIVE_FAIL = 0x2E, 333 TAF_LOST_STATISTICS = 0x32, 334 TAF_TAPE_DIR_CURRUPT_UNLOAD = 0x33, 335 TAF_TAPE_SYS_WRT_FAIL = 0x34, 336 TAF_TAPE_SYS_RD_FAIL = 0x35, 337 TAF_NO_START_OF_DATA = 0x36, 338 TAF_WORM_INTEGRITY = 0x3B, 339 TAF_WORM_OVRWRT_ATTEMPT = 0x3C 340 }tape_alert_flags; 341 342 /* 343 * For ST_TYPE_STK9840 drives only. STK drive doesn't support retension 344 * so they reuse TAF_RETENSION_REQUEST. 345 */ 346 #define CLEAN_FOR_ERRORS 0x18 347 348 349 #define TAPE_ALERT_SUPPORT_UNKNOWN 0x00 350 #define TAPE_ALERT_NOT_SUPPORTED 0x01 351 #define TAPE_ALERT_SUPPORTED 0x02 352 #define TAPE_ALERT_STILL_DIRTY 0x04 353 #define TAPE_SEQUENTIAL_SUPPORTED 0x08 354 #define TAPE_PREVIOUSLY_DIRTY 0x10 355 356 #define TAPE_ALERT_MAX_PARA 64 357 #define TAPE_SEQUENTIAL_PAGE_PARA 64 /* way more then really used */ 358 #define SEQUENTIAL_NEED_CLN 0x0100 359 360 /* 361 * Parameters 362 */ 363 #define ST_NAMESIZE 44 /* size of pretty string for vid/pid */ 364 #define VIDLEN 8 /* size of vendor identifier length */ 365 #define PIDLEN 16 /* size of product identifier length */ 366 #define VIDPIDLEN (VIDLEN + PIDLEN) 367 368 369 struct st_drivetype { 370 char name[ST_NAMESIZE]; /* Name, for debug */ 371 char length; /* Length of vendor id */ 372 char vid[VIDPIDLEN]; /* Vendor id and model (product) id */ 373 char type; /* Drive type for driver */ 374 int bsize; /* Block size */ 375 int options; /* Drive options */ 376 int max_rretries; /* Max read retries */ 377 int max_wretries; /* Max write retries */ 378 uchar_t densities[NDENSITIES]; /* density codes, low->hi */ 379 uchar_t default_density; /* default density for this drive */ 380 uchar_t mediatype[NDENSITIES]; /* was speed. mediatype for density. */ 381 ushort_t non_motion_timeout; /* Inquiry type commands */ 382 ushort_t io_timeout; /* I/O timeout in seconds */ 383 ushort_t rewind_timeout; /* rewind timeout in seconds */ 384 ushort_t space_timeout; /* space cmd timeout in seconds */ 385 ushort_t load_timeout; /* load tape time in seconds */ 386 ushort_t unload_timeout; /* unload tape time in seconds */ 387 ushort_t erase_timeout; /* erase timeout. seconds */ 388 }; 389 390 #define MINUTES(val) ((val) * 60) 391 392 struct comp_mode_page { 393 #if defined(_BIT_FIELDS_LTOH) 394 uchar_t : 6, 395 dcc: 1, /* Data Compression Capable */ 396 dce: 1; /* Data Compression Enable */ 397 uchar_t : 5, 398 red: 2, /* Report Exceptions on Decompress */ 399 dde: 1; /* Data Decompression Enabled */ 400 uchar_t comp_alg_msb; /* Compression Algorithm */ 401 uchar_t comp_alg_high; 402 uchar_t comp_alg_low; 403 uchar_t comp_alg_lsb; 404 uchar_t decomp_alg_msb; /* Decompression Algorithm */ 405 uchar_t decomp_alg_high; 406 uchar_t decomp_alg_low; 407 uchar_t decomp_alg_lsb; 408 uchar_t reservered0; 409 uchar_t reservered1; 410 uchar_t reservered2; 411 uchar_t reservered3; 412 413 #elif defined(_BIT_FIELDS_HTOL) 414 uchar_t dce: 1, /* Data Compression Enable */ 415 dcc: 1, /* Data Compression Capable */ 416 : 6; 417 uchar_t dde: 1, /* Data Decompression Enabled */ 418 red: 2, /* Report Exceptions on Decompress */ 419 : 5; 420 uchar_t comp_alg_msb; /* Compression Algorithm */ 421 uchar_t comp_alg_high; 422 uchar_t comp_alg_low; 423 uchar_t comp_alg_lsb; 424 uchar_t decomp_alg_msb; /* Decompression Algorithm */ 425 uchar_t decomp_alg_high; 426 uchar_t decomp_alg_low; 427 uchar_t decomp_alg_lsb; 428 uchar_t reservered0; 429 uchar_t reservered1; 430 uchar_t reservered2; 431 uchar_t reservered3; 432 #endif 433 }; 434 435 struct dev_mode_page { 436 #if defined(_BIT_FIELDS_LTOH) 437 uchar_t act_format: 5, /* active format */ 438 caf: 1, /* Change Active Format */ 439 cap: 1, /* Change Active Partition OBSOLETE */ 440 : 1; 441 uchar_t act_partition; /* active partition */ 442 uchar_t wrt_buf_full_ratio; /* write buffer full ratio */ 443 uchar_t rd_buf_full_ratio; /* read buffer full ratio */ 444 uchar_t wrt_delay_time_msb; /* write delay time MSB */ 445 uchar_t wrt_delay_time_lsb; /* write delay time LSB */ 446 uchar_t rew: 1, /* Report Early Warning */ 447 robo: 1, /* Reverse Object Buffer Order */ 448 socf: 2, /* Stop On Consecutive Filemarks */ 449 avc: 1, /* Automatic Velocity Control */ 450 rsmk: 1, /* Report SetMarKs OBSOLETE */ 451 lois: 1, /* Logical Object Identifiers Support */ 452 obr: 1; /* Object Buffer Recovery */ 453 uchar_t gap_size; /* OBSOLETE */ 454 uchar_t bam: 1, /* Block Address Mode */ 455 bmal: 1, /* Block Address Mode Lock */ 456 swp: 1, /* Software Write Protection */ 457 sew: 1, /* Sync data after Early Warning */ 458 eeg: 1, /* Enable Early Waring */ 459 eod_defined: 3; 460 uchar_t buf_size_leot_msb; /* Buffer size after early warning */ 461 uchar_t buf_size_leot_mid; 462 uchar_t buf_size_leot_lsb; 463 uchar_t comp_alg; /* Compression Algorithm (enable) */ 464 uchar_t prmwp: 1, /* PeRManent Write Protect */ 465 perswp: 1, /* persistant write protection */ 466 asocwp: 1, /* associated write protect */ 467 rew_on_rst: 2, /* rewind on reset */ 468 oir: 1, /* Only If Reserved */ 469 wtre: 2; /* Worm Tamper Read Enable */ 470 471 #elif defined(_BIT_FIELDS_HTOL) 472 uchar_t : 1, 473 cap: 1, /* Change Active Partition OBSOLETE */ 474 caf: 1, /* Change Active Format */ 475 act_format: 5; /* active format */ 476 uchar_t act_partition; /* active partition */ 477 uchar_t wrt_buf_full_ratio; /* write buffer full ratio */ 478 uchar_t rd_buf_full_ratio; /* read buffer full ratio */ 479 uchar_t wrt_delay_time_msb; /* write delay time MSB */ 480 uchar_t wrt_delay_time_lsb; /* write delay time LSB */ 481 uchar_t obr: 1, /* Object Buffer Recovery */ 482 lois: 1, /* Logical Object Identifiers Support */ 483 rsmk: 1, /* Report SetMarKs OBSOLETE */ 484 avc: 1, /* Automatic Velocity Control */ 485 socf: 2, /* Stop On Consecutive Filemarks */ 486 robo: 1, /* Reverse Object Buffer Order */ 487 rew: 1; /* Report Early Warning */ 488 uchar_t gap_size; /* OBSELETE */ 489 uchar_t eod_defined: 3, 490 eeg: 1, /* Enable Early Waring */ 491 sew: 1, /* Sync data after Early Warning */ 492 swp: 1, /* Software Write Protection */ 493 bmal: 1, /* Block Address Mode Lock */ 494 bam: 1; /* Block Address Mode */ 495 uchar_t buf_size_leot_msb; /* Buffer size after early warning */ 496 uchar_t buf_size_leot_mid; 497 uchar_t buf_size_leot_lsb; 498 uchar_t comp_alg; /* Compression Algorithm (enable) */ 499 uchar_t wtre: 2, /* Worm Tamper Read Enable */ 500 oir: 1, /* Only If Reserved */ 501 rew_on_rst: 2, /* rewind on reset */ 502 asocwp: 1, /* associated write protect */ 503 perswp: 1, /* persistant write protection */ 504 prmwp: 1; /* PeRManent Write Protect */ 505 #endif 506 }; 507 508 typedef union { 509 struct comp_mode_page comp; 510 struct dev_mode_page dev; 511 }modepage; 512 513 /* 514 * 515 * Parameter list for the MODE_SELECT and MODE_SENSE commands. 516 * The parameter list contains a header, followed by zero or more 517 * block descriptors, followed by vendor unique parameters, if any. 518 * 519 */ 520 #define MSIZE 0x0c /* Size without additional pages */ 521 struct seq_mode { 522 #if defined(_BIT_FIELDS_LTOH) 523 uchar_t data_len; /* sense data length, sense only */ 524 uchar_t media_type; /* medium type, sense only */ 525 uchar_t speed :4, /* speed */ 526 bufm :3, /* buffered mode */ 527 wp :1; /* write protected, sense only */ 528 uchar_t bd_len; /* block length in bytes */ 529 uchar_t density; /* density code */ 530 uchar_t high_nb; /* number of logical blocks on the medium */ 531 uchar_t mid_nb; /* that are to be formatted with the density */ 532 uchar_t low_nb; /* code and block length in block descriptor */ 533 uchar_t reserved; /* reserved */ 534 uchar_t high_bl; /* block length */ 535 uchar_t mid_bl; /* " " */ 536 uchar_t low_bl; /* " " */ 537 uchar_t page_code: 6, 538 : 1, 539 ps: 1; /* Page Savable sense only */ 540 uchar_t page_len; 541 modepage page; 542 543 #elif defined(_BIT_FIELDS_HTOL) 544 uchar_t data_len; /* sense data length, sense only */ 545 uchar_t media_type; /* medium type, sense only */ 546 uchar_t wp :1, /* write protected, sense only */ 547 bufm :3, /* buffered mode */ 548 speed :4; /* speed */ 549 uchar_t bd_len; /* block length in bytes */ 550 uchar_t density; /* density code */ 551 uchar_t high_nb; /* number of logical blocks on the medium */ 552 uchar_t mid_nb; /* that are to be formatted with the density */ 553 uchar_t low_nb; /* code and block length in block descriptor */ 554 uchar_t reserved; /* reserved */ 555 uchar_t high_bl; /* block length */ 556 uchar_t mid_bl; /* " " */ 557 uchar_t low_bl; /* " " */ 558 uchar_t ps: 1, /* Page Savable sense only */ 559 : 1, 560 page_code: 6; 561 uchar_t page_len; 562 modepage page; 563 #else 564 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 565 #endif /* _BIT_FIELDS_LTOH */ 566 }; 567 568 /* 569 * Data returned from the READ BLOCK LIMITS command. 570 */ 571 572 #define RBLSIZE (sizeof (struct read_blklim)) 573 struct read_blklim { 574 #if defined(_BIT_FIELDS_HTOL) 575 uchar_t reserved: 3; /* reserved */ 576 uchar_t granularity: 5; /* Minimum Modularity */ 577 #elif defined(_BIT_FIELDS_LTOH) 578 uchar_t granularity: 5; /* Minimum Modularity */ 579 uchar_t reserved: 3; /* reserved */ 580 #endif 581 uchar_t max_hi; /* Maximum block length, high byte */ 582 uchar_t max_mid; /* Maximum block length, middle byte */ 583 uchar_t max_lo; /* Maximum block length, low byte */ 584 uchar_t min_hi; /* Minimum block length, high byte */ 585 uchar_t min_lo; /* Minimum block length, low byte */ 586 }; 587 588 #ifdef _KERNEL 589 590 #if defined(__i386) || defined(__amd64) 591 /* Data structure used in big block I/O on x86/x64 platform */ 592 593 /* 594 * alloc more than one contig_mem, so mutiple I/O can be 595 * on-going simultaneously 596 */ 597 #define ST_MAX_CONTIG_MEM_NUM 3 598 599 /* 600 * 60K is used due to the limitation(size) of the intermediate buffer 601 * in DMA bind code(rootnex.c), which is 64K. If the I/O buf is page 602 * aligned, HBA can do 64K DMA, but if not, HBA can only do 603 * 64K - PAGESIZE = 60K DMA due to the copy to/from intermediate 604 * buffer will keep the page offset. 605 */ 606 #define ST_BIGBLK_XFER 60 * 1024 607 struct contig_mem { 608 struct contig_mem *cm_next; 609 size_t cm_len; 610 caddr_t cm_addr; 611 ddi_acc_handle_t cm_acc_hdl; 612 struct buf *cm_bp; 613 int cm_use_sbuf; 614 }; 615 616 #endif 617 618 #endif /* _KERNEL */ 619 620 /* 621 * eof/eot/eom codes. 622 */ 623 624 typedef enum { 625 ST_NO_EOF, /* 0x00 */ 626 ST_EOF_PENDING, /* 0x01 filemark pending */ 627 ST_EOF, /* 0x02 at filemark */ 628 ST_EOT_PENDING, /* 0x03 logical eot pending */ 629 ST_EOT, /* 0x04 at logical eot */ 630 ST_EOM, /* 0x05 at physical eot */ 631 ST_WRITE_AFTER_EOM /* 0x06 flag for allowing writes after EOM */ 632 }media_st; 633 634 #define IN_EOF(un) (un->un_eof == ST_EOF_PENDING || un->un_eof == ST_EOF) 635 636 /* 637 * operation codes 638 */ 639 typedef enum { 640 ST_OP_NIL, /* 0 */ 641 ST_OP_CTL, /* 1 */ 642 ST_OP_READ, /* 2 */ 643 ST_OP_WRITE, /* 3 */ 644 ST_OP_WEOF /* 4 */ 645 }optype; 646 647 typedef enum { RDWR, RDONLY, WORM, RDWORM, ERROR } writablity; 648 649 /* 650 * Private info for scsi tapes. Pointed to by the un_private pointer 651 * of one of the SCSI_DEVICE chains. 652 */ 653 654 struct scsi_tape { 655 struct scsi_device *un_sd; /* back pointer to SCSI_DEVICE */ 656 struct scsi_pkt *un_rqs; /* ptr to request sense command */ 657 struct scsi_pkt *un_mkr_pkt; /* ptr to marker packet */ 658 kcondvar_t un_sbuf_cv; /* cv on ownership of special buf */ 659 kcondvar_t un_queue_cv; /* cv on all queued commands */ 660 struct buf *un_sbufp; /* for use in special io */ 661 char *un_srqbufp; /* sense buffer for special io */ 662 kcondvar_t un_clscv; /* closing cv */ 663 struct buf *un_quef; /* head of wait queue */ 664 struct buf *un_quel; /* tail of wait queue */ 665 struct buf *un_runqf; /* head of run queue */ 666 struct buf *un_runql; /* tail of run queue */ 667 struct seq_mode *un_mspl; /* ptr to mode select info */ 668 struct st_drivetype *un_dp; /* ptr to drive table entry */ 669 uint_t un_dp_size; /* size of un_dp alloc'ed */ 670 caddr_t un_tmpbuf; /* buf for append, autodens ops */ 671 daddr_t un_blkno; /* block # in file (512 byte blocks) */ 672 int un_oflags; /* open flags */ 673 int un_fileno; /* current file number on tape */ 674 int un_err_fileno; /* file where error occurred */ 675 daddr_t un_err_blkno; /* block in file where err occurred */ 676 uint_t un_err_resid; /* resid from last error */ 677 short un_fmneeded; /* filemarks to be written - HP only */ 678 dev_t un_dev; /* unix device */ 679 uchar_t un_attached; /* unit known && attached */ 680 int un_pwr_mgmt; /* power management state */ 681 uchar_t un_density_known; /* density is known */ 682 uchar_t un_curdens; /* index into density table */ 683 optype un_lastop; /* last I/O was: read/write/ctl */ 684 media_st un_eof; /* eof states */ 685 uchar_t un_laststate; /* last state */ 686 uchar_t un_state; /* current state */ 687 uchar_t un_status; /* status from last sense */ 688 uchar_t un_retry_ct; /* retry count */ 689 uchar_t un_tran_retry_ct; /* transport retry count */ 690 writablity un_read_only; /* RDWR, RDONLY, WORM, RDWORM */ 691 uchar_t un_test_append; /* check writing at end of tape */ 692 uchar_t un_arq_enabled; /* auto request sense enabled */ 693 uchar_t un_untagged_qing; /* hba has untagged quing */ 694 uchar_t un_allow_large_xfer; /* allow >64k xfers if requested */ 695 uchar_t un_sbuf_busy; /* sbuf busy flag */ 696 uchar_t un_ncmds; /* number of commands outstanding */ 697 uchar_t un_throttle; /* curr. max number of cmds outst. */ 698 uchar_t un_last_throttle; /* saved max number of cmds outst. */ 699 uchar_t un_max_throttle; /* max poss. number cmds outstanding */ 700 uchar_t un_persistence; /* 1 = persistence on, 0 off */ 701 uchar_t un_persist_errors; /* 1 = persistenced flagged */ 702 uchar_t un_flush_on_errors; /* HBA will flush all I/O's on a */ 703 /* check condidtion or error */ 704 uint_t un_kbytes_xferred; /* bytes (in K) counter */ 705 uint_t un_last_resid; /* keep last resid, for PE */ 706 uint_t un_last_count; /* keep last count, for PE */ 707 struct kstat *un_stats; /* for I/O statistics */ 708 struct buf *un_rqs_bp; /* bp used in rqpkt */ 709 struct buf *un_wf; /* head of write queue */ 710 struct buf *un_wl; /* tail of write queue */ 711 struct read_blklim *un_rbl; /* ptr to read block limit info */ 712 int un_maxdma; /* max dma xfer allowed by HBA */ 713 uint_t un_bsize; /* block size currently being used */ 714 int un_maxbsize; /* max block size allowed by drive */ 715 uint_t un_minbsize; /* min block size allowed by drive */ 716 int un_errno; /* errno (b_error) */ 717 kcondvar_t un_state_cv; /* mediastate condition variable */ 718 enum mtio_state un_mediastate; /* current media state */ 719 enum mtio_state un_specified_mediastate; /* expected state */ 720 timeout_id_t un_delay_tid; /* delayed cv tid */ 721 timeout_id_t un_hib_tid; /* handle interrupt busy tid */ 722 opaque_t un_swr_token; /* scsi_watch request token */ 723 uchar_t un_comp_page; /* compression page */ 724 uchar_t un_rsvd_status; /* Reservation Status */ 725 kstat_t *un_errstats; /* for error statistics */ 726 int un_init_options; /* Init time drive options */ 727 int un_save_fileno; /* Save here for recovery */ 728 daddr_t un_save_blkno; /* Save here for recovery */ 729 uchar_t un_restore_pos; /* Indication to do recovery */ 730 int un_suspend_fileno; /* Save fileno for SUSPEND */ 731 daddr_t un_suspend_blkno; /* Save blkno for SUSPEND */ 732 uchar_t un_silent_skip; /* to catch short reads */ 733 short un_tids_at_suspend; /* timeouts set at suspend */ 734 kcondvar_t un_tape_busy_cv; /* busy cv */ 735 kcondvar_t un_suspend_cv; /* busy cv */ 736 /* restore on close */ 737 uchar_t un_eject_tape_on_failure; /* 1 = eject tape, 0 = don't */ 738 uchar_t un_HeadClean; /* support and need head cleaning? */ 739 uchar_t un_rqs_state; /* see define below */ 740 caddr_t un_uscsi_rqs_buf; /* uscsi_rqs: buffer for RQS data */ 741 uchar_t un_data_mod; /* Device required data mod */ 742 writablity (*un_wormable) (struct scsi_tape *un); /* worm test fuct */ 743 int un_max_cdb_sz; /* max cdb size to use */ 744 745 #if defined(__i386) || defined(__amd64) 746 ddi_dma_handle_t un_contig_mem_hdl; 747 struct contig_mem *un_contig_mem; 748 int un_contig_mem_available_num; 749 int un_contig_mem_total_num; 750 size_t un_max_contig_mem_len; 751 kcondvar_t un_contig_mem_cv; 752 #endif 753 754 }; 755 756 757 /* 758 * device error kstats 759 */ 760 struct st_errstats { 761 struct kstat_named st_softerrs; 762 struct kstat_named st_harderrs; 763 struct kstat_named st_transerrs; 764 struct kstat_named st_vid; 765 struct kstat_named st_pid; 766 struct kstat_named st_revision; 767 struct kstat_named st_serial; 768 }; 769 770 /* 771 * generic log page struct 772 */ 773 struct log_page { 774 #if defined(_BIT_FIELDS_LTOH) 775 uchar_t code :6, /* page code number */ 776 :2; /* reserved */ 777 #elif defined(_BIT_FIELDS_HTOL) 778 uchar_t :2, /* reserved */ 779 code :6; /* page code number */ 780 #endif /* _BIT_FIELDS_LTOH */ 781 uchar_t reserved; /* reserved */ 782 uchar_t length_hi; /* length of bytes to follow (msb) */ 783 uchar_t length_lo; /* length of bytes to follow (lsb) */ 784 /* 785 * Log parameters follow right after this... 786 */ 787 }; 788 789 /* 790 * generic log page parameter struct 791 */ 792 struct log_param { 793 uchar_t pc_hi; /* parameter code (msb) */ 794 uchar_t pc_lo; /* parameter code (lsb) */ 795 #if defined(_BIT_FIELDS_LTOH) 796 uchar_t lp : 1, /* list parameter */ 797 : 1, /* reserved */ 798 tmc : 2, /* threshold met criteria */ 799 etc : 1, /* enable threshold comparison */ 800 tsd : 1, /* target save disable */ 801 ds : 1, /* disable save */ 802 du : 1; /* disable update */ 803 #elif defined(_BIT_FIELDS_HTOL) 804 uchar_t du : 1, /* disable update */ 805 ds : 1, /* disable save */ 806 tsd : 1, /* target save disable */ 807 etc : 1, /* enable threshold comparison */ 808 tmc : 2, /* threshold met criteria */ 809 : 1, /* reserved */ 810 lp : 1; /* list parameter */ 811 #endif /* _BIT_FIELDS_LTOH */ 812 uchar_t length; /* length of bytes to follow */ 813 /* 814 * Parameter values follow right after this... 815 */ 816 }; 817 /* 818 * TapeAlert structures 819 */ 820 821 struct st_tape_alert_parameter { 822 struct log_param log_param; 823 uchar_t param_value; 824 }; 825 826 struct st_tape_alert { 827 struct log_page log_page; 828 struct st_tape_alert_parameter param[TAPE_ALERT_MAX_PARA]; 829 }; 830 831 #define TAPE_ALERT_PARAMETER_LENGTH \ 832 (sizeof (struct st_tape_alert_parameter)) * TAPE_ALERT_MAX_PARA 833 834 struct log_sequential_page_parameter { 835 struct log_param log_param; 836 uchar_t param_value[8]; 837 }; 838 839 struct log_sequential_page { 840 struct log_page log_page; 841 struct log_sequential_page_parameter param[TAPE_SEQUENTIAL_PAGE_PARA]; 842 }; 843 844 #if !defined(__lint) 845 _NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, scsi_tape)) 846 _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_tape::un_dp)) 847 _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_tape::un_sd)) 848 _NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_tape::un_rqs)) 849 _NOTE(SCHEME_PROTECTS_DATA("protected by cv", scsi_tape::un_sbufp)) 850 _NOTE(DATA_READABLE_WITHOUT_LOCK(scsi_tape::un_bsize)) 851 _NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_arq_status)) 852 _NOTE(SCHEME_PROTECTS_DATA("save sharing", 853 scsi_tape::un_allow_large_xfer 854 scsi_tape::un_maxbsize 855 scsi_tape::un_maxdma 856 )) 857 #if defined(__i386) || defined(__amd64) 858 _NOTE(DATA_READABLE_WITHOUT_LOCK(scsi_tape::un_contig_mem_hdl)) 859 _NOTE(SCHEME_PROTECTS_DATA("not shared", contig_mem)) 860 #endif 861 #endif 862 863 864 /* 865 * driver states.. 866 */ 867 #define ST_STATE_CLOSED 0 868 #define ST_STATE_OFFLINE 1 869 #define ST_STATE_INITIALIZING 2 870 #define ST_STATE_OPENING 3 871 #define ST_STATE_OPEN_PENDING_IO 4 872 #define ST_STATE_APPEND_TESTING 5 873 #define ST_STATE_OPEN 6 874 #define ST_STATE_RESOURCE_WAIT 7 875 #define ST_STATE_CLOSING 8 876 #define ST_STATE_SENSING 9 877 #define ST_STATE_CLOSE_PENDING_OPEN 10 878 879 /* 880 * Power management state 881 */ 882 #define ST_PWR_NORMAL 0 883 #define ST_PWR_SUSPENDED 1 884 885 886 887 888 /* un_rqs_state codes */ 889 890 #define ST_RQS_OVR 0x1 /* RQS data was overwritten */ 891 #define ST_RQS_VALID 0x2 /* RQS data is valid */ 892 #define ST_RQS_READ 0x4 /* RQS data was read */ 893 #define ST_RQS_ERROR 0x8 /* RQS resulted in an EIO */ 894 895 /* 896 * stintr codes 897 */ 898 899 #define COMMAND_DONE 0 900 #define COMMAND_DONE_ERROR 1 901 #define COMMAND_DONE_ERROR_RECOVERED 2 902 #define QUE_COMMAND 3 903 #define QUE_BUSY_COMMAND 4 904 #define QUE_SENSE 5 905 #define JUST_RETURN 6 906 #define COMMAND_DONE_EACCES 7 907 #define QUE_LAST_COMMAND 8 908 909 910 /* 911 * Reservation Status 912 * 913 * ST_INIT_RESERVE -Used to check if the reservation has been lost 914 * in between opens and also to indicate the reservation 915 * has not been done till now. 916 * ST_RELEASE -Tape Unit is Released. 917 * ST_RESERVE -Tape Unit is Reserved. 918 * ST_PRESERVE_RESERVE -Reservation is to be preserved across opens. 919 * 920 */ 921 #define ST_INIT_RESERVE 0x001 922 #define ST_RELEASE 0x002 923 #define ST_RESERVE 0x004 924 #define ST_PRESERVE_RESERVE 0x008 925 #define ST_RESERVATION_CONFLICT 0x010 926 #define ST_LOST_RESERVE 0x020 927 #define ST_APPLICATION_RESERVATIONS 0x040 928 #define ST_LOST_RESERVE_BETWEEN_OPENS \ 929 (ST_RESERVE | ST_LOST_RESERVE | ST_PRESERVE_RESERVE) 930 931 /* 932 * Service action defines for Persistant Reservation Commands 933 */ 934 #define ST_SA_SCSI3_REGISTER 0x00 935 #define ST_SA_SCSI3_RESERVE 0x01 936 #define ST_SA_SCSI3_RELEASE 0x02 937 #define ST_SA_SCSI3_CLEAR 0x03 938 #define ST_SA_SCSI3_PREEMPT 0x04 939 #define ST_SA_SCSI3_PREEMPTANDABORT 0x05 940 #define ST_SA_SCSI3_REGISTERANDIGNOREKEY 0x06 941 #define ST_SA_MASK 0x1f 942 943 #define ST_RESERVATION_DELAY 500000 944 945 /* 946 * Asynch I/O tunables 947 */ 948 #define ST_MAX_THROTTLE 4 949 950 /* 951 * 60 minutes seems a reasonable amount of time 952 * to wait for tape space operations to complete. 953 * 954 */ 955 #define ST_SPACE_TIME MINUTES(60) /* 60 minutes per space operation */ 956 #define ST_LONG_SPACE_TIME_X 5 /* multipiler for long space ops */ 957 958 /* 959 * 2 minutes seems a reasonable amount of time 960 * to wait for tape i/o operations to complete. 961 * 962 */ 963 #define ST_IO_TIME MINUTES(2) /* minutes per i/o */ 964 #define ST_LONG_TIMEOUT_X 5 /* multiplier for very long timeouts */ 965 966 967 /* 968 * 10 seconds is what we'll wait if we get a Busy Status back 969 */ 970 #define ST_STATUS_BUSY_TIMEOUT 10*hz /* seconds Busy Waiting */ 971 #define ST_TRAN_BUSY_TIMEOUT 1*hz /* seconds retry on TRAN_BSY */ 972 #define ST_INTERRUPT_CONTEXT 1 973 #define ST_START_CONTEXT 2 974 975 /* 976 * Number of times we'll retry a normal operation. 977 * 978 * XXX This includes retries due to transport failure as well as 979 * XXX busy timeouts- Need to distinguish between Target and Transport 980 * XXX failure. 981 */ 982 983 #define ST_RETRY_COUNT 20 984 985 /* 986 * Number of times to retry a failed selection 987 */ 988 #define ST_SEL_RETRY_COUNT 2 989 990 /* 991 * es_code value for deferred error 992 * should be moved to sense.h 993 */ 994 995 #define ST_DEFERRED_ERROR 0x01 996 997 /* 998 * Maximum number of units (determined by minor device byte) 999 */ 1000 #define ST_MAXUNIT 128 1001 1002 /* 1003 * Time to wait for completion of a command before cancelling it. 1004 * For SUSPEND use only 1005 */ 1006 #define ST_WAIT_CMDS_COMPLETE 10 /* seconds */ 1007 1008 #ifndef SECSIZE 1009 #define SECSIZE 512 1010 #endif 1011 #ifndef SECDIV 1012 #define SECDIV 9 1013 #endif 1014 1015 /* 1016 * convenient defines 1017 */ 1018 #define ST_SCSI_DEVP (un->un_sd) 1019 #define ST_DEVINFO (ST_SCSI_DEVP->sd_dev) 1020 #define ST_INQUIRY (ST_SCSI_DEVP->sd_inq) 1021 #define ST_RQSENSE (ST_SCSI_DEVP->sd_sense) 1022 #define ST_MUTEX (&ST_SCSI_DEVP->sd_mutex) 1023 #define ROUTE (&ST_SCSI_DEVP->sd_address) 1024 1025 #define BSD_BEHAVIOR (getminor(un->un_dev) & MT_BSD) 1026 #define SVR4_BEHAVIOR ((getminor(un->un_dev) & MT_BSD) == 0) 1027 #define SCBP(pkt) ((struct scsi_status *)(pkt)->pkt_scbp) 1028 #define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & STATUS_MASK) 1029 #define CDBP(pkt) ((union scsi_cdb *)(pkt)->pkt_cdbp) 1030 #define BP_PKT(bp) ((struct scsi_pkt *)(bp)->av_back) 1031 #define SET_BP_PKT(bp, pkt) ((bp)->av_back = (struct buf *)(pkt)) 1032 #define BP_UCMD(bp) ((struct uscsi_cmd *)(bp)->b_back) 1033 #define USCSI_CMD(bp) (((bp) == un->un_sbufp) && (BP_UCMD(bp))) 1034 1035 #define IS_CLOSING(un) ((un)->un_state == ST_STATE_CLOSING || \ 1036 ((un)->un_state == ST_STATE_SENSING && \ 1037 (un)->un_laststate == ST_STATE_CLOSING)) 1038 1039 #define ASYNC_CMD 0 1040 #define SYNC_CMD 1 1041 1042 /* 1043 * Flush tape wait queue as needed. 1044 */ 1045 1046 #define IS_PE_FLAG_SET(un) ((un)->un_persistence && (un)->un_persist_errors) 1047 1048 #define TURN_PE_ON(un) st_turn_pe_on(un) 1049 #define TURN_PE_OFF(un) st_turn_pe_off(un) 1050 #define SET_PE_FLAG(un) st_set_pe_flag(un) 1051 #define CLEAR_PE(un) st_clear_pe(un) 1052 1053 #define st_bioerror(bp, error) \ 1054 { bioerror(bp, error); \ 1055 un->un_errno = error; } 1056 1057 /* 1058 * Macros for internal coding of count for SPACE command: 1059 * 1060 * Isfmk is 1 when spacing filemarks; 0 when spacing records: 1061 * bit 24 set indicates a space filemark command. 1062 * Fmk sets the filemark bit (24) and changes a backspace 1063 * count into a positive number with the sign bit set. 1064 * Blk changes a backspace count into a positive number with 1065 * the sign bit set. 1066 * space_cnt converts backwards counts to negative numbers. 1067 */ 1068 #define Isfmk(x) ((x & (1<<24)) != 0) 1069 #define Fmk(x) ((1<<24)|((x < 0) ? ((-(x)) | (1<<30)): x)) 1070 #define Blk(x) ((x < 0)? ((-(x))|(1<<30)): x) 1071 #define space_cnt(x) (((x) & (1<<30))? (-((x)&((1<<24)-1))):(x)&((1<<24)-1)) 1072 1073 1074 #define GET_SOFT_STATE(dev) \ 1075 register struct scsi_tape *un; \ 1076 register int instance; \ 1077 \ 1078 instance = MTUNIT(dev); \ 1079 if ((un = ddi_get_soft_state(st_state, instance)) == NULL) \ 1080 return (ENXIO); 1081 1082 /* 1083 * Debugging turned on via conditional compilation switch -DSTDEBUG 1084 */ 1085 #ifdef DEBUG 1086 #define STDEBUG 1087 #endif 1088 1089 #ifdef STDEBUG 1090 #define DEBUGGING ((scsi_options & SCSI_DEBUG_TGT) || st_debug > 1) 1091 1092 1093 #define ST_DEBUG1 if (st_debug >= 1) scsi_log /* initialization */ 1094 #define ST_DEBUG ST_DEBUG1 1095 1096 #define ST_DEBUG2 if (st_debug >= 2) scsi_log /* errors and UA's */ 1097 #define ST_DEBUG3 if (st_debug >= 3) scsi_log /* func calls */ 1098 #define ST_DEBUG4 if (st_debug >= 4) scsi_log /* ioctl calls */ 1099 #define ST_DEBUG5 if (st_debug >= 5) scsi_log 1100 #define ST_DEBUG6 if (st_debug >= 6) scsi_log /* full data tracking */ 1101 1102 #define ST_DEBUG_SP if (st_debug == 10) scsi_log /* special cases */ 1103 1104 #else 1105 1106 #define st_debug (0) 1107 #define DEBUGGING (0) 1108 #define ST_DEBUG if (0) scsi_log 1109 #define ST_DEBUG1 if (0) scsi_log 1110 #define ST_DEBUG2 if (0) scsi_log 1111 #define ST_DEBUG3 if (0) scsi_log 1112 #define ST_DEBUG4 if (0) scsi_log 1113 #define ST_DEBUG5 if (0) scsi_log 1114 #define ST_DEBUG6 if (0) scsi_log 1115 1116 #define ST_DEBUG_SP if (0) scsi_log /* special cases */ 1117 1118 #endif 1119 1120 /* 1121 * Media access values 1122 */ 1123 #define MEDIA_ACCESS_DELAY 5000000 /* usecs wait for media state change */ 1124 1125 /* 1126 * SCSI tape mode sense page information 1127 */ 1128 #define ST_DEV_CONFIG_PAGE 0x10 /* device config mode page */ 1129 #define ST_DEV_CONFIG_NO_COMP 0x00 /* use no compression */ 1130 #define ST_DEV_CONFIG_DEF_COMP 0x01 /* use default compression alg */ 1131 #define ST_COMPRESSION_DENSITY 3 /* compression minor number */ 1132 1133 /* 1134 * SCSI tape data compression Page definition. 1135 */ 1136 #define ST_DEV_DATACOMP_PAGE 0x0F /* data compression page */ 1137 1138 1139 1140 /* 1141 * maxbsize values 1142 */ 1143 #define MAXBSIZE_UNKNOWN -2 /* not found yet */ 1144 1145 #define ONE_MEG (1024 * 1024) 1146 1147 /* 1148 * generic soft error reporting 1149 * 1150 * What we are doing here is allowing a greater number of errors to occur on 1151 * smaller transfers (i.e. usually at the beginning of the tape), than on 1152 * the rest of the tape. 1153 * 1154 * A small transfer is defined as : 1155 * Transfers <= SOFT_ERROR_WARNING_THRESHOLD allow about 1.5 times more errors 1156 * 1157 * A larget tranfer is defined as : 1158 * Transfers > SOFT_ERROR_WARNING_THRESHOLD allow normal amount 1159 * 1160 */ 1161 #define READ_SOFT_ERROR_WARNING_THRESHOLD (25 * ONE_MEG) 1162 #define WRITE_SOFT_ERROR_WARNING_THRESHOLD (20 * ONE_MEG) 1163 1164 /* 1165 * soft error reporting for exabyte 1166 */ 1167 #define TAPE_SENSE_LENGTH 32 /* allows for softerror info */ 1168 1169 #define SENSE_19_BITS \ 1170 "\20\10PF\07BPE\06FPE\05ME\04ECO\03TME\02TNP\01LBOT" 1171 #define SENSE_20_BITS \ 1172 "\20\10RSVD\07RSVD\06WP\05FMKE\04URE\03WE1\02SSE\01FW" 1173 #define SENSE_21_BITS \ 1174 "\20\10RSVD\07RSVD\06RRR\05CLND\04CLN\03PEOT\02WSEB\01WSE0" 1175 1176 /* these are defined in percentages */ 1177 #define EXABYTE_WRITE_ERROR_THRESHOLD 6 1178 #define EXABYTE_READ_ERROR_THRESHOLD 3 1179 /* 1180 * minumum amount of data transfer(MB) for checking soft error rate. 1181 */ 1182 #define EXABYTE_MIN_TRANSFER (25 * ONE_MEG) 1183 1184 #define CLN 0x8 1185 #define CLND 0x10 1186 1187 /* 1188 * soft error reporting for Archive 4mm DAT 1189 */ 1190 1191 #define LOG_SENSE_LENGTH 0xff 1192 #define MIN_LOG_SENSE_LENGTH 0x2b 1193 #define DAT_SMALL_WRITE_ERROR_THRESHOLD 40 /* retries per 20 mg */ 1194 #define DAT_LARGE_WRITE_ERROR_THRESHOLD 200 /* retries for more 20 mg */ 1195 #define DAT_SMALL_READ_ERROR_THRESHOLD 5 /* errors allowed */ 1196 #define DAT_LARGE_READ_ERROR_THRESHOLD 3 /* errors allowed */ 1197 1198 /* 1199 * ST timeouts that need to be cancelled for suspend 1200 */ 1201 #define ST_HIB_TID 0x01 1202 #define ST_DELAY_TID 0x02 1203 1204 #ifdef __cplusplus 1205 } 1206 #endif 1207 1208 #endif /* _SYS_SCSI_TARGETS_STDEF_H */ 1209