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