10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51697Srralphs * Common Development and Distribution License (the "License"). 61697Srralphs * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*10740SJianfei.Wang@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_SCSI_TARGETS_STDEF_H 270Sstevel@tonic-gate #define _SYS_SCSI_TARGETS_STDEF_H 280Sstevel@tonic-gate 29177Scz147101 #include <sys/sunddi.h> 300Sstevel@tonic-gate #include <sys/note.h> 310Sstevel@tonic-gate #include <sys/condvar.h> 320Sstevel@tonic-gate #include <sys/kstat.h> 335628Srralphs #include <sys/int_limits.h> 340Sstevel@tonic-gate #include <sys/scsi/scsi_types.h> 354549Srralphs #include <sys/scsi/generic/sense.h> 360Sstevel@tonic-gate #include <sys/mtio.h> 375628Srralphs #include <sys/taskq.h> 385628Srralphs #include <sys/taskq_impl.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef __cplusplus 410Sstevel@tonic-gate extern "C" { 420Sstevel@tonic-gate #endif 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* 450Sstevel@tonic-gate * Defines for SCSI tape drives. 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * Maximum variable length record size for a single request 500Sstevel@tonic-gate */ 510Sstevel@tonic-gate #define ST_MAXRECSIZE_VARIABLE 65535 520Sstevel@tonic-gate 530Sstevel@tonic-gate /* 540Sstevel@tonic-gate * If the requested record size exceeds ST_MAXRECSIZE_VARIABLE, 550Sstevel@tonic-gate * then the following define is used. 560Sstevel@tonic-gate */ 570Sstevel@tonic-gate #define ST_MAXRECSIZE_VARIABLE_LIMIT 65534 580Sstevel@tonic-gate 590Sstevel@tonic-gate #define ST_MAXRECSIZE_FIXED (63<<10) /* maximum fixed record size */ 605775Srralphs #define INF 1000000000 /* old external count backwards from this from EOF */ 615775Srralphs #define LASTBLK (-1) /* new internal count backwards from EOF */ 620Sstevel@tonic-gate 630Sstevel@tonic-gate /* 640Sstevel@tonic-gate * Supported tape device types plus default type for opening. 650Sstevel@tonic-gate * Types 10 - 13, are special (ancient too) drives - *NOT SUPPORTED* 660Sstevel@tonic-gate * Types 14 - 1f, are 1/4-inch cartridge drives. 670Sstevel@tonic-gate * Types 20 - 28, are 1/2-inch cartridge or reel drives. 680Sstevel@tonic-gate * Types 28+, are rdat (vcr) drives. 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate #define ST_TYPE_INVALID 0x00 710Sstevel@tonic-gate 720Sstevel@tonic-gate #define ST_TYPE_SYSGEN1 MT_ISSYSGEN11 /* Sysgen with QIC-11 only */ 730Sstevel@tonic-gate #define ST_TYPE_SYSGEN MT_ISSYSGEN /* Sysgen with QIC-24 and QIC-11 */ 740Sstevel@tonic-gate 750Sstevel@tonic-gate #define ST_TYPE_DEFAULT MT_ISDEFAULT /* Generic 1/4" or undetermined */ 760Sstevel@tonic-gate #define ST_TYPE_EMULEX MT_ISMT02 /* Emulex MT-02 */ 770Sstevel@tonic-gate #define ST_TYPE_ARCHIVE MT_ISVIPER1 /* Archive QIC-150 */ 780Sstevel@tonic-gate #define ST_TYPE_WANGTEK MT_ISWANGTEK1 /* Wangtek QIC-150 */ 790Sstevel@tonic-gate 800Sstevel@tonic-gate #define ST_TYPE_CDC MT_ISCDC /* CDC - (not tested) */ 810Sstevel@tonic-gate #define ST_TYPE_FUJI MT_ISFUJI /* Fujitsu - (not tested) */ 820Sstevel@tonic-gate #define ST_TYPE_KENNEDY MT_ISKENNEDY /* Kennedy */ 830Sstevel@tonic-gate #define ST_TYPE_ANRITSU MT_ISANRITSU /* Anritsu */ 840Sstevel@tonic-gate #define ST_TYPE_HP MT_ISHP /* HP */ 850Sstevel@tonic-gate #define ST_TYPE_HIC MT_ISCCS23 /* Generic 1/2" Cartridge */ 860Sstevel@tonic-gate #define ST_TYPE_REEL MT_ISCCS24 /* Generic 1/2" Reel Tape */ 870Sstevel@tonic-gate #define ST_TYPE_DAT MT_ISCCS28 /* Generic DAT Tape */ 880Sstevel@tonic-gate 890Sstevel@tonic-gate #define ST_TYPE_EXABYTE MT_ISEXABYTE /* Exabyte 8200 */ 900Sstevel@tonic-gate #define ST_TYPE_EXB8500 MT_ISEXB8500 /* Exabyte 8500 */ 910Sstevel@tonic-gate #define ST_TYPE_WANGTHS MT_ISWANGTHS /* Wangtek 6130HS */ 920Sstevel@tonic-gate #define ST_TYPE_WANGDAT MT_ISWANGDAT /* WangDAT */ 930Sstevel@tonic-gate #define ST_TYPE_PYTHON MT_ISPYTHON /* Archive Python DAT */ 940Sstevel@tonic-gate #define ST_TYPE_STC3490 MT_ISSTC /* IBM STC 3490 */ 950Sstevel@tonic-gate #define ST_TYPE_TAND25G MT_ISTAND25G /* TANDBERG 2.5G */ 960Sstevel@tonic-gate #define ST_TYPE_DLT MT_ISDLT /* DLT */ 970Sstevel@tonic-gate #define ST_TYPE_STK9840 MT_ISSTK9840 /* StorageTek 9840, 9940, 9840B */ 980Sstevel@tonic-gate #define ST_TYPE_BMDLT1 MT_ISBMDLT1 /* Benchmark DTL1 */ 990Sstevel@tonic-gate #define ST_TYPE_LTO MT_LTO /* sun: LTO's by HP, Seagate, IBM.. */ 1002537Srralphs #define ST_TYPE_AIT MT_ISAIT /* Sony AIT I, II, III and SAIT */ 1012537Srralphs #define ST_LAST_TYPE ST_TYPE_AIT /* Add new above type and change this */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate /* Internal flags */ 1050Sstevel@tonic-gate #define ST_DYNAMIC 0x2000 /* Device name has been dynamically */ 1060Sstevel@tonic-gate /* alloc'ed from the st.conf entry, */ 1070Sstevel@tonic-gate /* instead of being used from the */ 1080Sstevel@tonic-gate /* st_drivetypes array. */ 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate /* 1110Sstevel@tonic-gate * Defines for supported drive options 1120Sstevel@tonic-gate * 1130Sstevel@tonic-gate * WARNING : THESE OPTIONS SHOULD NEVER BE CHANGED, AS OLDER CONFIGURATIONS 1140Sstevel@tonic-gate * WILL DEPEND ON THE FLAG VALUES REMAINING THE SAME 1150Sstevel@tonic-gate */ 1160Sstevel@tonic-gate #define ST_VARIABLE 0x001 /* Device supports variable */ 1170Sstevel@tonic-gate /* length record sizes */ 1180Sstevel@tonic-gate #define ST_QIC 0x002 /* QIC tape device */ 1190Sstevel@tonic-gate #define ST_REEL 0x004 /* 1/2-inch reel tape device */ 1200Sstevel@tonic-gate #define ST_BSF 0x008 /* Device supports backspace */ 1210Sstevel@tonic-gate /* file as in mt(1) bsf : */ 1220Sstevel@tonic-gate /* backspace over EOF marks. */ 1230Sstevel@tonic-gate /* Devices not supporting bsf */ 1240Sstevel@tonic-gate /* will fail with ENOTTY upon */ 1250Sstevel@tonic-gate /* use of bsf */ 1260Sstevel@tonic-gate #define ST_BSR 0x010 /* Device supports backspace */ 1270Sstevel@tonic-gate /* record as in mt(1) bsr : */ 1280Sstevel@tonic-gate /* backspace over records. If */ 1290Sstevel@tonic-gate /* the device does not support */ 1300Sstevel@tonic-gate /* bsr, the st driver emulates */ 1310Sstevel@tonic-gate /* the action by rewinding the */ 1320Sstevel@tonic-gate /* tape and using forward space */ 1330Sstevel@tonic-gate /* file (fsf) to the correct */ 1340Sstevel@tonic-gate /* file and then uses forward */ 1350Sstevel@tonic-gate /* space record (fsr) to the */ 1360Sstevel@tonic-gate /* correct record */ 1370Sstevel@tonic-gate #define ST_LONG_ERASE 0x020 /* Device needs a longer time */ 1380Sstevel@tonic-gate /* than normal to erase */ 1390Sstevel@tonic-gate #define ST_AUTODEN_OVERRIDE 0x040 /* Auto-Density override flag */ 1400Sstevel@tonic-gate /* Device can figure out the */ 1410Sstevel@tonic-gate /* tape density automatically, */ 1420Sstevel@tonic-gate /* without issuing a */ 1430Sstevel@tonic-gate /* mode-select/mode-sense */ 1440Sstevel@tonic-gate #define ST_NOBUF 0x080 /* Don't use buffered mode. */ 1450Sstevel@tonic-gate /* This disables the device's */ 1460Sstevel@tonic-gate /* ability for buffered writes */ 1470Sstevel@tonic-gate /* I.e. The device acknowledges */ 1480Sstevel@tonic-gate /* write completion after the */ 1490Sstevel@tonic-gate /* data is written to the */ 1500Sstevel@tonic-gate /* device's buffer, but before */ 1510Sstevel@tonic-gate /* all the data is actually */ 1520Sstevel@tonic-gate /* written to tape */ 1530Sstevel@tonic-gate #define ST_RESERVED_BIT1 0x100 /* resreved bit */ 1540Sstevel@tonic-gate /* parity while talking to it. */ 1550Sstevel@tonic-gate #define ST_KNOWS_EOD 0x200 /* Device knows when EOD (End */ 1560Sstevel@tonic-gate /* of Data) has been reached. */ 1570Sstevel@tonic-gate /* If the device knows EOD, st */ 1580Sstevel@tonic-gate /* uses fast file skipping. */ 1590Sstevel@tonic-gate /* If it does not know EOD, */ 1600Sstevel@tonic-gate /* file skipping happens one */ 1610Sstevel@tonic-gate /* file at a time. */ 1620Sstevel@tonic-gate #define ST_UNLOADABLE 0x400 /* Device will not complain if */ 1630Sstevel@tonic-gate /* the st driver is unloaded & */ 1640Sstevel@tonic-gate /* loaded again; e.g. will */ 1650Sstevel@tonic-gate /* return the correct inquiry */ 1660Sstevel@tonic-gate /* string */ 1670Sstevel@tonic-gate #define ST_SOFT_ERROR_REPORTING 0x800 /* Do request or log sense on */ 1680Sstevel@tonic-gate /* close to report soft errors. */ 1690Sstevel@tonic-gate /* Currently only Exabyte and */ 1700Sstevel@tonic-gate /* DAT drives support this */ 1710Sstevel@tonic-gate /* feature. */ 1720Sstevel@tonic-gate #define ST_LONG_TIMEOUTS 0x1000 /* Device needs 5 times longer */ 1730Sstevel@tonic-gate /* timeouts for normal */ 1740Sstevel@tonic-gate /* operation */ 1750Sstevel@tonic-gate #define ST_BUFFERED_WRITES 0x4000 /* The data is buffered in the */ 1760Sstevel@tonic-gate /* driver and pre-acked to the */ 1770Sstevel@tonic-gate /* application */ 1780Sstevel@tonic-gate #define ST_NO_RECSIZE_LIMIT 0x8000 /* For variable record size */ 1790Sstevel@tonic-gate /* devices only. If flag is */ 1800Sstevel@tonic-gate /* set, then don't limit */ 1810Sstevel@tonic-gate /* record size to 64k as in */ 1820Sstevel@tonic-gate /* pre-Solaris 2.4 releases. */ 1830Sstevel@tonic-gate /* The only limit on the */ 1840Sstevel@tonic-gate /* record size will be the max */ 1850Sstevel@tonic-gate /* record size the device can */ 1860Sstevel@tonic-gate /* handle or the max DMA */ 1870Sstevel@tonic-gate /* transfer size of the */ 1880Sstevel@tonic-gate /* machine, which ever is */ 1890Sstevel@tonic-gate /* smaller. Beware of */ 1900Sstevel@tonic-gate /* incompatabilities with */ 1910Sstevel@tonic-gate /* tapes of pre-Solaris 2.4 */ 1920Sstevel@tonic-gate /* OS's written with large */ 1930Sstevel@tonic-gate /* (>64k) block sizes, as */ 1940Sstevel@tonic-gate /* their true block size is */ 1950Sstevel@tonic-gate /* a max of approx 64k */ 1960Sstevel@tonic-gate #define ST_MODE_SEL_COMP 0x10000 /* use mode select of device */ 1970Sstevel@tonic-gate /* configuration page (0x10) to */ 1980Sstevel@tonic-gate /* enable/disable compression */ 1990Sstevel@tonic-gate /* instead of density codes for */ 2000Sstevel@tonic-gate /* the "c" and "u" devices */ 2010Sstevel@tonic-gate #define ST_NO_RESERVE_RELEASE 0x20000 /* For devices which do not */ 2020Sstevel@tonic-gate /* support RESERVE/RELEASE SCSI */ 2030Sstevel@tonic-gate /* command. If this is enabled */ 2040Sstevel@tonic-gate /* then reserve/release would */ 2050Sstevel@tonic-gate /* not be used during open/ */ 2060Sstevel@tonic-gate /* close for High Availability */ 2070Sstevel@tonic-gate #define ST_READ_IGNORE_ILI 0x40000 /* This flag is only applicable */ 2080Sstevel@tonic-gate /* to variable block devices */ 2090Sstevel@tonic-gate /* which support the SILI bit */ 2100Sstevel@tonic-gate /* option. It indicates that */ 2110Sstevel@tonic-gate /* the SILI bit will be ignored */ 2120Sstevel@tonic-gate /* during reads */ 2130Sstevel@tonic-gate #define ST_READ_IGNORE_EOFS 0x80000 /* When this flag is set two */ 2140Sstevel@tonic-gate /* EOF marks do not indicate an */ 2150Sstevel@tonic-gate /* EOM. This option is only */ 2160Sstevel@tonic-gate /* supported on 1/2" reel tapes */ 2170Sstevel@tonic-gate #define ST_SHORT_FILEMARKS 0x100000 /* This option applies only to */ 2180Sstevel@tonic-gate /* EXABYTE 8mm tape drives */ 2190Sstevel@tonic-gate /* which support short */ 2200Sstevel@tonic-gate /* filemarks. When this flag */ 2210Sstevel@tonic-gate /* is set, short filemarks */ 2220Sstevel@tonic-gate /* will be used for writing */ 2230Sstevel@tonic-gate /* filemarks. */ 2240Sstevel@tonic-gate #define ST_EJECT_ON_CHANGER_FAILURE 0x200000 /* When this flag is set */ 2250Sstevel@tonic-gate /* and the tape is trapped in */ 2260Sstevel@tonic-gate /* the medium changer, the tape */ 2270Sstevel@tonic-gate /* is automatically ejected */ 2280Sstevel@tonic-gate #define ST_RETRY_ON_RECOVERED_DEFERRED_ERROR 0x400000 2290Sstevel@tonic-gate /* This option applies only to */ 2300Sstevel@tonic-gate /* IBM MAGSTAR 3590. If this */ 2310Sstevel@tonic-gate /* flag is set, the st driver */ 2320Sstevel@tonic-gate /* will retry the last cmd if */ 2330Sstevel@tonic-gate /* the last error cause a check */ 2340Sstevel@tonic-gate /* condition with error code */ 2350Sstevel@tonic-gate /* 0x71 and sense code 0x01 */ 2360Sstevel@tonic-gate #define ST_KNOWS_MEDIA 0x800000 /* Use configured media type */ 2370Sstevel@tonic-gate /* detected to select correct */ 2380Sstevel@tonic-gate /* density code. */ 2392537Srralphs #define ST_WORMABLE 0x1000000 2402537Srralphs /* Drive is capable of doing */ 2412537Srralphs /* Write Appends only at EOM */ 2422537Srralphs /* if WORM media type is loaded */ 2430Sstevel@tonic-gate #define ST_CLN_TYPE_1 0x10000000 /* When this flag is set, */ 2440Sstevel@tonic-gate /* the tape drive provides the */ 2450Sstevel@tonic-gate /* clean bit information in */ 2460Sstevel@tonic-gate /* byte 21, bitmask 0x08 of */ 2470Sstevel@tonic-gate /* Request Sense data */ 2480Sstevel@tonic-gate #define ST_CLN_TYPE_2 0x20000000 /* When this flag is set, */ 2490Sstevel@tonic-gate /* the tape drive provides the */ 2500Sstevel@tonic-gate /* clean bit information in */ 2510Sstevel@tonic-gate /* byte 70, bitmask 0xc0 of */ 2520Sstevel@tonic-gate /* Request Sense data */ 2530Sstevel@tonic-gate #define ST_CLN_TYPE_3 0x40000000 /* When this flag is set, */ 2540Sstevel@tonic-gate /* the tape drive provides the */ 2550Sstevel@tonic-gate /* clean bit information in */ 2560Sstevel@tonic-gate /* byte 18, bitmask 0x01 of */ 2570Sstevel@tonic-gate /* Request Sense data */ 2580Sstevel@tonic-gate 2590Sstevel@tonic-gate #define ST_CLN_MASK (ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3) 2600Sstevel@tonic-gate #define ST_VALID_OPTS (ST_VARIABLE | ST_QIC | ST_REEL | ST_BSF | ST_BSR |\ 2610Sstevel@tonic-gate ST_LONG_ERASE | ST_AUTODEN_OVERRIDE | ST_NOBUF | ST_KNOWS_EOD |\ 2620Sstevel@tonic-gate ST_UNLOADABLE | ST_SOFT_ERROR_REPORTING | ST_LONG_TIMEOUTS |\ 2630Sstevel@tonic-gate ST_NO_RECSIZE_LIMIT | ST_MODE_SEL_COMP | ST_NO_RESERVE_RELEASE |\ 2640Sstevel@tonic-gate ST_READ_IGNORE_ILI | ST_READ_IGNORE_EOFS | ST_SHORT_FILEMARKS |\ 2650Sstevel@tonic-gate ST_EJECT_ON_CHANGER_FAILURE | ST_RETRY_ON_RECOVERED_DEFERRED_ERROR |\ 2662537Srralphs ST_WORMABLE | ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3) 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate #define NDENSITIES MT_NDENSITIES 2690Sstevel@tonic-gate #define NSPEEDS MT_NSPEEDS 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate /* 2720Sstevel@tonic-gate * defines for Log Sense Pages 2730Sstevel@tonic-gate */ 2740Sstevel@tonic-gate #define SUPPORTED_LOG_PAGES_PAGE 0x00 2750Sstevel@tonic-gate #define TAPE_SEQUENTIAL_PAGE 0x0c 2760Sstevel@tonic-gate #define TAPE_ALERT_PAGE 0x2e 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate /* 2790Sstevel@tonic-gate * Log Page Control definitions 2800Sstevel@tonic-gate */ 2810Sstevel@tonic-gate #define CURRENT_THRESHOLD_VALUES 0x00 2820Sstevel@tonic-gate #define CURRENT_CUMULATIVE_VALUES 0x40 2830Sstevel@tonic-gate #define DEFAULT_THRESHOLD_VALUES 0x80 2840Sstevel@tonic-gate #define DEFAULT_CUMULATIVE_VALUES 0xC0 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate /* 2870Sstevel@tonic-gate * Tape Alert Flag definitions 2880Sstevel@tonic-gate */ 2892537Srralphs typedef enum { 2902537Srralphs TAF_READ_WARN = 0x01, 2912537Srralphs TAF_WRITE_WARN = 0x02, 2922537Srralphs TAF_HARD_ERR = 0x03, 2932537Srralphs TAF_MEDIA_ERR = 0x04, 2942537Srralphs TAF_READ_FAIL = 0x05, 2952537Srralphs TAF_WRITE_FAIL = 0x06, 2962537Srralphs TAF_MEDIA_LIFE = 0x07, 2972537Srralphs TAF_MEDIA_NOT_DATA_GRADE = 0x08, 2982537Srralphs TAF_WRITE_PROTECTED = 0x09, 2992537Srralphs TAF_NO_MEDIA_REMOVE = 0x0A, 3002537Srralphs TAF_CLEANING_MEDIA = 0x0B, 3012537Srralphs TAF_UNSUPPERTED_FORMAT = 0x0C, 3022537Srralphs TAF_RECOVERED_TAPE_BREAK = 0x0D, 3032537Srralphs TAF_TAPE_BREAK_FAUL = 0x0E, 3042537Srralphs TAF_CART_MEM_FAIL = 0x0F, 3052537Srralphs TAF_FORCED_EJECT = 0x10, 3062537Srralphs TAF_READ_ONLY_FORMAT = 0x11, 3072537Srralphs TAF_TAPE_DIR_CORRUPT = 0x12, 3082537Srralphs TAF_NEARING_MEDIA_LIFE = 0x13, 3092537Srralphs TAF_CLEAN_NOW = 0x14, 3102537Srralphs TAF_CLEAN_PERIODIC = 0x15, 3112537Srralphs TAF_EXP_CLEAN_CART = 0x16, 3122537Srralphs TAF_INVALID_CLEAN_MEDIA = 0x17, 3132537Srralphs TAF_RETENSION_REQUEST = 0x18, 3142537Srralphs TAF_DUAL_PORT_INTERFACE_ERR = 0x19, 3152537Srralphs TAF_COOLING_FAN_FAIL = 0x1A, 3162537Srralphs TAF_POWER_SUPPLY_FAIL = 0x1B, 3172537Srralphs TAF_POWER_CONSUMPTION = 0x1C, 3182537Srralphs TAF_DRIVE_MAINT_REQUEST = 0x1D, 3192537Srralphs TAF_HARDWARE_A = 0x1E, 3202537Srralphs TAF_HARDWARE_B = 0x1F, 3212537Srralphs TAF_INTERFACE = 0x20, 3222537Srralphs TAF_EJECT_MEDIA = 0x21, 3232537Srralphs TAF_DOWNLOAD_FAIL = 0x22, 3242537Srralphs TAF_DRIVE_HUMIDITY = 0x23, 3252537Srralphs TAF_DRIVE_TEMP = 0x24, 3262537Srralphs TAF_DRIVE_VOLTAGE = 0x25, 3272537Srralphs TAF_PREDICTIVE_FAIL = 0x26, 3282537Srralphs TAF_DIAG_REQUIRED = 0x27, 3292537Srralphs TAF_LOADER_HDWR_A = 0x28, 3302537Srralphs TAF_LOADER_STRAY_TAPE = 0x29, 3312537Srralphs TAF_LOADER_HDWR_B = 0x2A, 3322537Srralphs TAF_LOADER_DOOR = 0x2B, 3332537Srralphs TAF_LOADER_HDWR_C = 0x2C, 3342537Srralphs TAF_LOADER_MAGAZINE = 0x2D, 3352537Srralphs TAF_LOADER_PREDICTIVE_FAIL = 0x2E, 3362537Srralphs TAF_LOST_STATISTICS = 0x32, 3372537Srralphs TAF_TAPE_DIR_CURRUPT_UNLOAD = 0x33, 3382537Srralphs TAF_TAPE_SYS_WRT_FAIL = 0x34, 3392537Srralphs TAF_TAPE_SYS_RD_FAIL = 0x35, 3402537Srralphs TAF_NO_START_OF_DATA = 0x36, 3412537Srralphs TAF_WORM_INTEGRITY = 0x3B, 3422537Srralphs TAF_WORM_OVRWRT_ATTEMPT = 0x3C 3432537Srralphs }tape_alert_flags; 3442537Srralphs 3452537Srralphs /* 3462537Srralphs * For ST_TYPE_STK9840 drives only. STK drive doesn't support retension 3472537Srralphs * so they reuse TAF_RETENSION_REQUEST. 3482537Srralphs */ 3492537Srralphs #define CLEAN_FOR_ERRORS 0x18 3502537Srralphs 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate #define TAPE_ALERT_SUPPORT_UNKNOWN 0x00 3530Sstevel@tonic-gate #define TAPE_ALERT_NOT_SUPPORTED 0x01 3540Sstevel@tonic-gate #define TAPE_ALERT_SUPPORTED 0x02 3550Sstevel@tonic-gate #define TAPE_ALERT_STILL_DIRTY 0x04 3560Sstevel@tonic-gate #define TAPE_SEQUENTIAL_SUPPORTED 0x08 3570Sstevel@tonic-gate #define TAPE_PREVIOUSLY_DIRTY 0x10 3580Sstevel@tonic-gate 3590Sstevel@tonic-gate #define TAPE_ALERT_MAX_PARA 64 3600Sstevel@tonic-gate #define TAPE_SEQUENTIAL_PAGE_PARA 64 /* way more then really used */ 3610Sstevel@tonic-gate #define SEQUENTIAL_NEED_CLN 0x0100 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate /* 3640Sstevel@tonic-gate * Parameters 3650Sstevel@tonic-gate */ 3660Sstevel@tonic-gate #define ST_NAMESIZE 44 /* size of pretty string for vid/pid */ 3670Sstevel@tonic-gate #define VIDLEN 8 /* size of vendor identifier length */ 3680Sstevel@tonic-gate #define PIDLEN 16 /* size of product identifier length */ 3690Sstevel@tonic-gate #define VIDPIDLEN (VIDLEN + PIDLEN) 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate struct st_drivetype { 3730Sstevel@tonic-gate char name[ST_NAMESIZE]; /* Name, for debug */ 3740Sstevel@tonic-gate char length; /* Length of vendor id */ 3750Sstevel@tonic-gate char vid[VIDPIDLEN]; /* Vendor id and model (product) id */ 3760Sstevel@tonic-gate char type; /* Drive type for driver */ 3770Sstevel@tonic-gate int bsize; /* Block size */ 3780Sstevel@tonic-gate int options; /* Drive options */ 3790Sstevel@tonic-gate int max_rretries; /* Max read retries */ 3800Sstevel@tonic-gate int max_wretries; /* Max write retries */ 3810Sstevel@tonic-gate uchar_t densities[NDENSITIES]; /* density codes, low->hi */ 3820Sstevel@tonic-gate uchar_t default_density; /* default density for this drive */ 3830Sstevel@tonic-gate uchar_t mediatype[NDENSITIES]; /* was speed. mediatype for density. */ 3840Sstevel@tonic-gate ushort_t non_motion_timeout; /* Inquiry type commands */ 3850Sstevel@tonic-gate ushort_t io_timeout; /* I/O timeout in seconds */ 3860Sstevel@tonic-gate ushort_t rewind_timeout; /* rewind timeout in seconds */ 3870Sstevel@tonic-gate ushort_t space_timeout; /* space cmd timeout in seconds */ 3880Sstevel@tonic-gate ushort_t load_timeout; /* load tape time in seconds */ 3890Sstevel@tonic-gate ushort_t unload_timeout; /* unload tape time in seconds */ 3900Sstevel@tonic-gate ushort_t erase_timeout; /* erase timeout. seconds */ 3910Sstevel@tonic-gate }; 3920Sstevel@tonic-gate 3930Sstevel@tonic-gate #define MINUTES(val) ((val) * 60) 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate struct comp_mode_page { 3960Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH) 3970Sstevel@tonic-gate uchar_t : 6, 3980Sstevel@tonic-gate dcc: 1, /* Data Compression Capable */ 3990Sstevel@tonic-gate dce: 1; /* Data Compression Enable */ 4000Sstevel@tonic-gate uchar_t : 5, 4010Sstevel@tonic-gate red: 2, /* Report Exceptions on Decompress */ 4020Sstevel@tonic-gate dde: 1; /* Data Decompression Enabled */ 4030Sstevel@tonic-gate uchar_t comp_alg_msb; /* Compression Algorithm */ 4040Sstevel@tonic-gate uchar_t comp_alg_high; 4050Sstevel@tonic-gate uchar_t comp_alg_low; 4060Sstevel@tonic-gate uchar_t comp_alg_lsb; 4070Sstevel@tonic-gate uchar_t decomp_alg_msb; /* Decompression Algorithm */ 4080Sstevel@tonic-gate uchar_t decomp_alg_high; 4090Sstevel@tonic-gate uchar_t decomp_alg_low; 4100Sstevel@tonic-gate uchar_t decomp_alg_lsb; 4110Sstevel@tonic-gate uchar_t reservered0; 4120Sstevel@tonic-gate uchar_t reservered1; 4130Sstevel@tonic-gate uchar_t reservered2; 4140Sstevel@tonic-gate uchar_t reservered3; 4150Sstevel@tonic-gate 4160Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL) 4170Sstevel@tonic-gate uchar_t dce: 1, /* Data Compression Enable */ 4180Sstevel@tonic-gate dcc: 1, /* Data Compression Capable */ 4190Sstevel@tonic-gate : 6; 4200Sstevel@tonic-gate uchar_t dde: 1, /* Data Decompression Enabled */ 4210Sstevel@tonic-gate red: 2, /* Report Exceptions on Decompress */ 4220Sstevel@tonic-gate : 5; 4230Sstevel@tonic-gate uchar_t comp_alg_msb; /* Compression Algorithm */ 4240Sstevel@tonic-gate uchar_t comp_alg_high; 4250Sstevel@tonic-gate uchar_t comp_alg_low; 4260Sstevel@tonic-gate uchar_t comp_alg_lsb; 4270Sstevel@tonic-gate uchar_t decomp_alg_msb; /* Decompression Algorithm */ 4280Sstevel@tonic-gate uchar_t decomp_alg_high; 4290Sstevel@tonic-gate uchar_t decomp_alg_low; 4300Sstevel@tonic-gate uchar_t decomp_alg_lsb; 4310Sstevel@tonic-gate uchar_t reservered0; 4320Sstevel@tonic-gate uchar_t reservered1; 4330Sstevel@tonic-gate uchar_t reservered2; 4340Sstevel@tonic-gate uchar_t reservered3; 4350Sstevel@tonic-gate #endif 4360Sstevel@tonic-gate }; 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate struct dev_mode_page { 4390Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH) 4400Sstevel@tonic-gate uchar_t act_format: 5, /* active format */ 4410Sstevel@tonic-gate caf: 1, /* Change Active Format */ 4422537Srralphs cap: 1, /* Change Active Partition OBSOLETE */ 4430Sstevel@tonic-gate : 1; 4440Sstevel@tonic-gate uchar_t act_partition; /* active partition */ 4450Sstevel@tonic-gate uchar_t wrt_buf_full_ratio; /* write buffer full ratio */ 4460Sstevel@tonic-gate uchar_t rd_buf_full_ratio; /* read buffer full ratio */ 4470Sstevel@tonic-gate uchar_t wrt_delay_time_msb; /* write delay time MSB */ 4480Sstevel@tonic-gate uchar_t wrt_delay_time_lsb; /* write delay time LSB */ 4490Sstevel@tonic-gate uchar_t rew: 1, /* Report Early Warning */ 4502537Srralphs robo: 1, /* Reverse Object Buffer Order */ 4510Sstevel@tonic-gate socf: 2, /* Stop On Consecutive Filemarks */ 4520Sstevel@tonic-gate avc: 1, /* Automatic Velocity Control */ 4532537Srralphs rsmk: 1, /* Report SetMarKs OBSOLETE */ 4542537Srralphs lois: 1, /* Logical Object Identifiers Support */ 4552537Srralphs obr: 1; /* Object Buffer Recovery */ 4562537Srralphs uchar_t gap_size; /* OBSOLETE */ 4572537Srralphs uchar_t bam: 1, /* Block Address Mode */ 4582537Srralphs bmal: 1, /* Block Address Mode Lock */ 4592537Srralphs swp: 1, /* Software Write Protection */ 4600Sstevel@tonic-gate sew: 1, /* Sync data after Early Warning */ 4610Sstevel@tonic-gate eeg: 1, /* Enable Early Waring */ 4620Sstevel@tonic-gate eod_defined: 3; 4630Sstevel@tonic-gate uchar_t buf_size_leot_msb; /* Buffer size after early warning */ 4640Sstevel@tonic-gate uchar_t buf_size_leot_mid; 4650Sstevel@tonic-gate uchar_t buf_size_leot_lsb; 4660Sstevel@tonic-gate uchar_t comp_alg; /* Compression Algorithm (enable) */ 4672537Srralphs uchar_t prmwp: 1, /* PeRManent Write Protect */ 4682537Srralphs perswp: 1, /* persistant write protection */ 4692537Srralphs asocwp: 1, /* associated write protect */ 4702537Srralphs rew_on_rst: 2, /* rewind on reset */ 4712537Srralphs oir: 1, /* Only If Reserved */ 4722537Srralphs wtre: 2; /* Worm Tamper Read Enable */ 4730Sstevel@tonic-gate 4740Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL) 4750Sstevel@tonic-gate uchar_t : 1, 4762537Srralphs cap: 1, /* Change Active Partition OBSOLETE */ 4770Sstevel@tonic-gate caf: 1, /* Change Active Format */ 4780Sstevel@tonic-gate act_format: 5; /* active format */ 4790Sstevel@tonic-gate uchar_t act_partition; /* active partition */ 4800Sstevel@tonic-gate uchar_t wrt_buf_full_ratio; /* write buffer full ratio */ 4810Sstevel@tonic-gate uchar_t rd_buf_full_ratio; /* read buffer full ratio */ 4820Sstevel@tonic-gate uchar_t wrt_delay_time_msb; /* write delay time MSB */ 4830Sstevel@tonic-gate uchar_t wrt_delay_time_lsb; /* write delay time LSB */ 4842537Srralphs uchar_t obr: 1, /* Object Buffer Recovery */ 4852537Srralphs lois: 1, /* Logical Object Identifiers Support */ 4862537Srralphs rsmk: 1, /* Report SetMarKs OBSOLETE */ 4870Sstevel@tonic-gate avc: 1, /* Automatic Velocity Control */ 4880Sstevel@tonic-gate socf: 2, /* Stop On Consecutive Filemarks */ 4892537Srralphs robo: 1, /* Reverse Object Buffer Order */ 4900Sstevel@tonic-gate rew: 1; /* Report Early Warning */ 4912537Srralphs uchar_t gap_size; /* OBSELETE */ 4920Sstevel@tonic-gate uchar_t eod_defined: 3, 4930Sstevel@tonic-gate eeg: 1, /* Enable Early Waring */ 4940Sstevel@tonic-gate sew: 1, /* Sync data after Early Warning */ 4952537Srralphs swp: 1, /* Software Write Protection */ 4962537Srralphs bmal: 1, /* Block Address Mode Lock */ 4972537Srralphs bam: 1; /* Block Address Mode */ 4980Sstevel@tonic-gate uchar_t buf_size_leot_msb; /* Buffer size after early warning */ 4990Sstevel@tonic-gate uchar_t buf_size_leot_mid; 5000Sstevel@tonic-gate uchar_t buf_size_leot_lsb; 5010Sstevel@tonic-gate uchar_t comp_alg; /* Compression Algorithm (enable) */ 5022537Srralphs uchar_t wtre: 2, /* Worm Tamper Read Enable */ 5032537Srralphs oir: 1, /* Only If Reserved */ 5042537Srralphs rew_on_rst: 2, /* rewind on reset */ 5052537Srralphs asocwp: 1, /* associated write protect */ 5062537Srralphs perswp: 1, /* persistant write protection */ 5072537Srralphs prmwp: 1; /* PeRManent Write Protect */ 5080Sstevel@tonic-gate #endif 5090Sstevel@tonic-gate }; 5100Sstevel@tonic-gate 511*10740SJianfei.Wang@Sun.COM struct sas_lun_mode { 512*10740SJianfei.Wang@Sun.COM #if defined(_BIT_FIELDS_HTOL) 513*10740SJianfei.Wang@Sun.COM uchar_t : 3, 514*10740SJianfei.Wang@Sun.COM tran_layer_ret: 1, 515*10740SJianfei.Wang@Sun.COM protocol_id: 4; 516*10740SJianfei.Wang@Sun.COM uchar_t reserved[5]; 517*10740SJianfei.Wang@Sun.COM #elif defined(_BIT_FIELDS_LTOH) 518*10740SJianfei.Wang@Sun.COM uchar_t protocol_id: 4, 519*10740SJianfei.Wang@Sun.COM tran_layer_ret: 1, 520*10740SJianfei.Wang@Sun.COM : 3; 521*10740SJianfei.Wang@Sun.COM uchar_t reserved[5]; 522*10740SJianfei.Wang@Sun.COM #endif 523*10740SJianfei.Wang@Sun.COM }; 5240Sstevel@tonic-gate typedef union { 5250Sstevel@tonic-gate struct comp_mode_page comp; 5260Sstevel@tonic-gate struct dev_mode_page dev; 527*10740SJianfei.Wang@Sun.COM struct sas_lun_mode saslun; 5280Sstevel@tonic-gate }modepage; 5290Sstevel@tonic-gate 5300Sstevel@tonic-gate /* 5310Sstevel@tonic-gate * 5320Sstevel@tonic-gate * Parameter list for the MODE_SELECT and MODE_SENSE commands. 5330Sstevel@tonic-gate * The parameter list contains a header, followed by zero or more 5340Sstevel@tonic-gate * block descriptors, followed by vendor unique parameters, if any. 5350Sstevel@tonic-gate * 5360Sstevel@tonic-gate */ 5370Sstevel@tonic-gate #define MSIZE 0x0c /* Size without additional pages */ 5380Sstevel@tonic-gate struct seq_mode { 5390Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH) 5400Sstevel@tonic-gate uchar_t data_len; /* sense data length, sense only */ 5410Sstevel@tonic-gate uchar_t media_type; /* medium type, sense only */ 5420Sstevel@tonic-gate uchar_t speed :4, /* speed */ 5430Sstevel@tonic-gate bufm :3, /* buffered mode */ 5440Sstevel@tonic-gate wp :1; /* write protected, sense only */ 5450Sstevel@tonic-gate uchar_t bd_len; /* block length in bytes */ 5460Sstevel@tonic-gate uchar_t density; /* density code */ 5470Sstevel@tonic-gate uchar_t high_nb; /* number of logical blocks on the medium */ 5480Sstevel@tonic-gate uchar_t mid_nb; /* that are to be formatted with the density */ 5490Sstevel@tonic-gate uchar_t low_nb; /* code and block length in block descriptor */ 5500Sstevel@tonic-gate uchar_t reserved; /* reserved */ 5510Sstevel@tonic-gate uchar_t high_bl; /* block length */ 5520Sstevel@tonic-gate uchar_t mid_bl; /* " " */ 5530Sstevel@tonic-gate uchar_t low_bl; /* " " */ 5540Sstevel@tonic-gate uchar_t page_code: 6, 5550Sstevel@tonic-gate : 1, 5560Sstevel@tonic-gate ps: 1; /* Page Savable sense only */ 5570Sstevel@tonic-gate uchar_t page_len; 5580Sstevel@tonic-gate modepage page; 5590Sstevel@tonic-gate 5600Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL) 5610Sstevel@tonic-gate uchar_t data_len; /* sense data length, sense only */ 5620Sstevel@tonic-gate uchar_t media_type; /* medium type, sense only */ 5630Sstevel@tonic-gate uchar_t wp :1, /* write protected, sense only */ 5640Sstevel@tonic-gate bufm :3, /* buffered mode */ 5650Sstevel@tonic-gate speed :4; /* speed */ 5660Sstevel@tonic-gate uchar_t bd_len; /* block length in bytes */ 5670Sstevel@tonic-gate uchar_t density; /* density code */ 5680Sstevel@tonic-gate uchar_t high_nb; /* number of logical blocks on the medium */ 5690Sstevel@tonic-gate uchar_t mid_nb; /* that are to be formatted with the density */ 5700Sstevel@tonic-gate uchar_t low_nb; /* code and block length in block descriptor */ 5710Sstevel@tonic-gate uchar_t reserved; /* reserved */ 5720Sstevel@tonic-gate uchar_t high_bl; /* block length */ 5730Sstevel@tonic-gate uchar_t mid_bl; /* " " */ 5740Sstevel@tonic-gate uchar_t low_bl; /* " " */ 5750Sstevel@tonic-gate uchar_t ps: 1, /* Page Savable sense only */ 5760Sstevel@tonic-gate : 1, 5770Sstevel@tonic-gate page_code: 6; 5780Sstevel@tonic-gate uchar_t page_len; 5790Sstevel@tonic-gate modepage page; 5800Sstevel@tonic-gate #else 5810Sstevel@tonic-gate #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 5820Sstevel@tonic-gate #endif /* _BIT_FIELDS_LTOH */ 5830Sstevel@tonic-gate }; 5840Sstevel@tonic-gate 5850Sstevel@tonic-gate /* 5865425Syl194034 * One_command parameter data for REPORT SUPPORTED OPERATION CODES. 5875425Syl194034 */ 5885425Syl194034 struct one_com_des { 5895425Syl194034 #if defined(_BIT_FIELDS_LTOH) 5905425Syl194034 uchar_t reserved0; 5915425Syl194034 uchar_t support: 3, /* support value */ 5925425Syl194034 reserved1: 4, 5935425Syl194034 ctdp: 1; /* cmd timeouts descriptor present */ 5945425Syl194034 ushort_t cdb_size; /* cdb size */ 5955425Syl194034 uchar_t usage[CDB_GROUP4]; /* 16 bytes, the largest CDB group */ 5965425Syl194034 #elif defined(_BIT_FIELDS_HTOL) 5975425Syl194034 uchar_t reserved0; 5985425Syl194034 uchar_t ctdp: 1, /* cmd timeouts descriptor present */ 5995425Syl194034 reserved1: 4, 6005425Syl194034 support: 3; /* support value */ 6015425Syl194034 ushort_t cdb_size; /* cdb size */ 6025425Syl194034 uchar_t usage[CDB_GROUP4]; /* 16 bytes, the largest CDB group */ 6035425Syl194034 #else 6045425Syl194034 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 6055425Syl194034 #endif /* _BIT_FIELDS_LTOH */ 6065425Syl194034 }; 6075425Syl194034 6085425Syl194034 /* 6095425Syl194034 * Command timeouts descriptor 6105425Syl194034 */ 6115425Syl194034 struct com_timeout_des { 6125425Syl194034 ushort_t des_len; /* descriptor length */ 6135425Syl194034 uchar_t reserved; 6145425Syl194034 uchar_t com_spe; /* command specific */ 6155425Syl194034 uint_t nom_timeout; /* nominal command processing timeout */ 6165425Syl194034 uint_t rec_timeout; /* recommended command timeout */ 6175425Syl194034 }; 6185425Syl194034 6195425Syl194034 /* 6205425Syl194034 * Reporting options 6215425Syl194034 */ 6225425Syl194034 #define ALL_COMMAND_DATA_FORMAT 0 6235425Syl194034 #define ONE_COMMAND_NO_SERVICE_DATA_FORMAT 1 6245425Syl194034 #define ONE_COMMAND_DATA_FORMAT 2 6255425Syl194034 6265425Syl194034 /* 6275425Syl194034 * Support values in One_command parameter data 6285425Syl194034 */ 6295425Syl194034 #define SUPPORT_VALUES_NOT_AVAILABLE 0 6305425Syl194034 #define SUPPORT_VALUES_NOT_SUPPORT 1 6315425Syl194034 #define SUPPORT_VALUES_SUPPORT_SCSI 3 6325425Syl194034 #define SUPPORT_VALUES_SUPPORT_VENDOR 5 6335425Syl194034 6345425Syl194034 /* 6355425Syl194034 * Parameter data for REPORT DENSITY SUPPORT command 6365425Syl194034 */ 6375425Syl194034 struct report_density_header { 6385425Syl194034 ushort_t ava_dens_len; /* available density support length */ 6395425Syl194034 uchar_t reserved0; 6405425Syl194034 uchar_t reserved1; 6415425Syl194034 }; 6425425Syl194034 6435425Syl194034 struct report_density_desc { 6445425Syl194034 #if defined(_BIT_FIELDS_LTOH) 6455425Syl194034 uchar_t pri_den; /* primary density code */ 6465425Syl194034 uchar_t sec_den; /* secondary density code */ 6475425Syl194034 uchar_t dlv:1; /* descriptor length valid */ 6485425Syl194034 uchar_t reserved:4; 6495425Syl194034 uchar_t deflt:1; /* is default density */ 6505425Syl194034 uchar_t dup:1; /* pri density has one descriptor */ 6515425Syl194034 uchar_t wrtok:1; /* support writing to media */ 6525425Syl194034 uchar_t desc_len_hi; /* descriptor length high */ 6535425Syl194034 uchar_t desc_len_low; /* descriptor length low */ 6545425Syl194034 uchar_t bits_per_mm[3]; /* bits per mm */ 6555425Syl194034 uchar_t media_width_hi; /* media width high */ 6565425Syl194034 uchar_t media_width_low; /* media width low */ 6575425Syl194034 ushort_t tracks; /* tracks */ 6585425Syl194034 uint_t capacity; /* capacity */ 6595425Syl194034 uchar_t ass_org[8]; /* assigning organization */ 6605425Syl194034 uchar_t den_name[8]; /* density name */ 6615425Syl194034 uchar_t description[20]; /* description */ 6625425Syl194034 #elif defined(_BIT_FIELDS_HTOL) 6635425Syl194034 uchar_t pri_den; /* primary density code */ 6645425Syl194034 uchar_t sec_den; /* secondary density code */ 6655425Syl194034 uchar_t wrtok:1; /* support writing to media */ 6665425Syl194034 uchar_t dup:1; /* pri density has one descriptor */ 6675425Syl194034 uchar_t deflt:1; /* is default density */ 6685425Syl194034 uchar_t reserved:4; 6695425Syl194034 uchar_t dlv:1; /* descriptor length valid */ 6705425Syl194034 uchar_t desc_len_hi; /* descriptor length high */ 6715425Syl194034 uchar_t desc_len_low; /* descriptor length low */ 6725425Syl194034 uchar_t bits_per_mm[3]; /* bits per mm */ 6735425Syl194034 uchar_t media_width_hi; /* media width high */ 6745425Syl194034 uchar_t media_width_low; /* media width low */ 6755425Syl194034 ushort_t tracks; /* tracks */ 6765425Syl194034 uint_t capacity; /* capacity */ 6775425Syl194034 uchar_t ass_org[8]; /* assigning organization */ 6785425Syl194034 uchar_t den_name[8]; /* density name */ 6795425Syl194034 uchar_t description[20]; /* description */ 6805425Syl194034 #else 6815425Syl194034 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 6825425Syl194034 #endif /* _BIT_FIELDS_LTOH */ 6835425Syl194034 }; 6845425Syl194034 6855425Syl194034 /* 6860Sstevel@tonic-gate * Data returned from the READ BLOCK LIMITS command. 6870Sstevel@tonic-gate */ 6880Sstevel@tonic-gate 6890Sstevel@tonic-gate #define RBLSIZE (sizeof (struct read_blklim)) 6900Sstevel@tonic-gate struct read_blklim { 6910Sstevel@tonic-gate #if defined(_BIT_FIELDS_HTOL) 6920Sstevel@tonic-gate uchar_t reserved: 3; /* reserved */ 6930Sstevel@tonic-gate uchar_t granularity: 5; /* Minimum Modularity */ 6940Sstevel@tonic-gate #elif defined(_BIT_FIELDS_LTOH) 6950Sstevel@tonic-gate uchar_t granularity: 5; /* Minimum Modularity */ 6960Sstevel@tonic-gate uchar_t reserved: 3; /* reserved */ 6970Sstevel@tonic-gate #endif 6980Sstevel@tonic-gate uchar_t max_hi; /* Maximum block length, high byte */ 6990Sstevel@tonic-gate uchar_t max_mid; /* Maximum block length, middle byte */ 7000Sstevel@tonic-gate uchar_t max_lo; /* Maximum block length, low byte */ 7010Sstevel@tonic-gate uchar_t min_hi; /* Minimum block length, high byte */ 7020Sstevel@tonic-gate uchar_t min_lo; /* Minimum block length, low byte */ 7030Sstevel@tonic-gate }; 7040Sstevel@tonic-gate 7054549Srralphs /* 7064549Srralphs * operation codes 7074549Srralphs */ 7084549Srralphs typedef enum { 7094549Srralphs ST_OP_NIL, 7104549Srralphs ST_OP_CTL, 7114549Srralphs ST_OP_READ, 7124549Srralphs ST_OP_WRITE, 7134549Srralphs ST_OP_WEOF 7144549Srralphs }optype; 7154549Srralphs 7164549Srralphs /* 7174549Srralphs * eof/eot/eom codes. 7184549Srralphs */ 7194549Srralphs typedef enum { 7204549Srralphs ST_NO_EOF, 7214549Srralphs ST_EOF_PENDING, /* filemark pending */ 7224549Srralphs ST_EOF, /* at filemark */ 7234549Srralphs ST_EOT_PENDING, /* logical eot pending */ 7244549Srralphs ST_EOT, /* at logical eot */ 7254549Srralphs ST_EOM, /* at physical eot */ 7264549Srralphs ST_WRITE_AFTER_EOM /* flag for allowing writes after EOM */ 7274549Srralphs }pstatus; 7284549Srralphs 7294549Srralphs typedef enum { invalid, legacy, logical } posmode; 7304549Srralphs 7314549Srralphs typedef struct tapepos { 7324549Srralphs uint64_t lgclblkno; 7334549Srralphs int32_t fileno; 7344549Srralphs int32_t blkno; 7354549Srralphs int32_t partition; 7364549Srralphs pstatus eof; /* eof states */ 7374549Srralphs posmode pmode; 7385628Srralphs uint32_t: 32; 7394549Srralphs }tapepos_t; 7404549Srralphs 7414549Srralphs /* byte 1 of cdb for type of read position command */ 7424549Srralphs typedef enum { 7434549Srralphs SHORT_POS = 0, 7444549Srralphs LONG_POS = 6, 7454549Srralphs EXT_POS = 8, 7464549Srralphs NO_POS = 0xff /* Drive doesn't support read position */ 7474549Srralphs } read_p_types; 7484549Srralphs 7494549Srralphs 7504549Srralphs /* 7514549Srralphs * Data returned from the READ POSITION command. 7524549Srralphs */ 7534549Srralphs 7544549Srralphs typedef struct tape_position { 7554549Srralphs #if defined(_BIT_FIELDS_HTOL) 7564549Srralphs uchar_t begin_of_part: 1; 7574549Srralphs uchar_t end_of_part: 1; 7584549Srralphs uchar_t blk_cnt_unkwn: 1; 7594549Srralphs uchar_t byte_cnt_unkwn: 1; 7604549Srralphs uchar_t reserved0: 1; 7614549Srralphs uchar_t blk_posi_unkwn: 1; 7624549Srralphs uchar_t posi_err: 1; 7634549Srralphs uchar_t reserved1: 1; 7644549Srralphs #elif defined(_BIT_FIELDS_LTOH) 7654549Srralphs uchar_t reserved1: 1; 7664549Srralphs uchar_t posi_err: 1; 7674549Srralphs uchar_t blk_posi_unkwn: 1; 7684549Srralphs uchar_t reserved0: 1; 7694549Srralphs uchar_t byte_cnt_unkwn: 1; 7704549Srralphs uchar_t blk_cnt_unkwn: 1; 7714549Srralphs uchar_t end_of_part: 1; 7724549Srralphs uchar_t begin_of_part: 1; 7734549Srralphs #endif 7744549Srralphs uchar_t partition_number; 7754549Srralphs uchar_t reserved2[2]; 7764549Srralphs uint32_t host_block; 7774549Srralphs uint32_t media_block; 7784549Srralphs uchar_t reserved3; 7794549Srralphs uchar_t block_in_buff[3]; 7804549Srralphs uint32_t byte_in_buff; 7814549Srralphs }tape_position_t; 7824549Srralphs 7834549Srralphs 7844549Srralphs typedef struct tape_position_long { 7854549Srralphs #if defined(_BIT_FIELDS_HTOL) 7864549Srralphs uint32_t begin_of_part: 1; 7874549Srralphs uint32_t end_of_part: 1; 7884549Srralphs uint32_t reserved0: 2; 7894549Srralphs uint32_t mrk_posi_unkwn:1; 7904549Srralphs uint32_t blk_posi_unkwn:1; 7914549Srralphs uint32_t reserved1: 2; 7924549Srralphs #elif defined(_BIT_FIELDS_LTOH) 7934549Srralphs uint32_t reserved1: 2; 7944549Srralphs uint32_t blk_posi_unkwn:1; 7954549Srralphs uint32_t mrk_posi_unkwn:1; 7964549Srralphs uint32_t reserved0: 2; 7974549Srralphs uint32_t end_of_part: 1; 7984549Srralphs uint32_t begin_of_part: 1; 7994549Srralphs #endif 8004549Srralphs uint32_t reserved2: 24; 8014549Srralphs uint32_t partition; 8024549Srralphs uint64_t block_number; 8034549Srralphs uint64_t file_number; 8044549Srralphs uint64_t set_number; 8054549Srralphs }tape_position_long_t; 8064549Srralphs 8074549Srralphs typedef struct tape_position_ext { 8084549Srralphs #if defined(_BIT_FIELDS_HTOL) 8095628Srralphs uchar_t begin_of_part: 1; 8105628Srralphs uchar_t end_of_part: 1; 8115628Srralphs uchar_t blk_cnt_unkwn: 1; 8125628Srralphs uchar_t byte_cnt_unkwn: 1; 8135628Srralphs uchar_t mrk_posi_unkwn: 1; 8145628Srralphs uchar_t blk_posi_unkwn: 1; 8155628Srralphs uchar_t posi_err: 1; 8165628Srralphs uchar_t reserved0: 1; 8175628Srralphs 8185628Srralphs uchar_t partition; 8195628Srralphs uint16_t parameter_len; 8204549Srralphs /* start next word */ 8214549Srralphs uint32_t reserved1: 8; 8224549Srralphs uint32_t blks_in_buf: 24; 8234549Srralphs #elif defined(_BIT_FIELDS_LTOH) 8245628Srralphs uchar_t reserved0: 1; 8255628Srralphs uchar_t posi_err: 1; 8265628Srralphs uchar_t blk_posi_unkwn: 1; 8275628Srralphs uchar_t mrk_posi_unkwn: 1; 8285628Srralphs uchar_t byte_cnt_unkwn: 1; 8295628Srralphs uchar_t blk_cnt_unkwn: 1; 8305628Srralphs uchar_t end_of_part: 1; 8315628Srralphs uchar_t begin_of_part: 1; 8325628Srralphs 8335628Srralphs uchar_t partition; 8345628Srralphs uint16_t parameter_len; 8354549Srralphs /* start next word */ 8364549Srralphs uint32_t blks_in_buf: 24; 8374549Srralphs uint32_t reserved1: 8; 8384549Srralphs #endif 8394549Srralphs uint64_t host_block; 8404549Srralphs uint64_t media_block; 8414549Srralphs uint64_t byte_in_buf; 8424549Srralphs }tape_position_ext_t; 8434549Srralphs 8444549Srralphs typedef union { 8454549Srralphs tape_position_t srt; 8464549Srralphs tape_position_ext_t ext; 8474549Srralphs tape_position_long_t lng; 8484549Srralphs }read_pos_data_t; 8494549Srralphs 8505628Srralphs typedef struct { 8515628Srralphs unsigned char cmd; 8525628Srralphs unsigned char 8535628Srralphs requires_reserve: 1, /* reserve must be done */ 8545628Srralphs retriable: 1, /* can be retried */ 8555628Srralphs chg_tape_pos: 1, /* position will change */ 8565628Srralphs chg_tape_data: 1, /* data on media will change */ 8578437SBo.Zhou@Sun.COM explicit_cmd_set: 1, /* explicit command set */ 8585628Srralphs /* 8595628Srralphs * 0 doesn't, 1 forward, 8605628Srralphs * 2 back, 3 either 8615628Srralphs */ 8625628Srralphs chg_tape_direction: 2; /* direction of pos change */ 8635628Srralphs #define DIR_NONE 0 8645628Srralphs #define DIR_FORW 1 8655628Srralphs #define DIR_REVC 2 8665628Srralphs #define DIR_EITH 3 8675628Srralphs unsigned char 8685628Srralphs /* 8695628Srralphs * 0 doesn't 1 read, 2 write 8705628Srralphs */ 8715628Srralphs transfers_data: 2, 8725628Srralphs #define TRAN_NONE 0 8735628Srralphs #define TRAN_READ 1 8745628Srralphs #define TRAN_WRTE 2 8755628Srralphs recov_pos_type: 1, 8765628Srralphs #define POS_EXPECTED 0 8775628Srralphs #define POS_STARTING 1 8785628Srralphs do_not_recover: 1; 8795628Srralphs uchar_t reserve_byte; 8805628Srralphs uint32_t reserve_mask; 8815628Srralphs uint64_t (*get_cnt)(uchar_t *); 8825628Srralphs uint64_t (*get_lba)(uchar_t *); 8835628Srralphs }cmd_attribute; 8845628Srralphs 8855628Srralphs typedef struct { 8865628Srralphs buf_t *cmd_bp; 8875628Srralphs size_t privatelen; 8886941Srralphs int str_retry_cnt; 8896941Srralphs int pkt_retry_cnt; 8905628Srralphs }pkt_info; 8915628Srralphs 8925628Srralphs typedef struct { 8935628Srralphs buf_t *cmd_bp; 8945628Srralphs size_t privatelen; 8956941Srralphs int str_retry_cnt; 8966941Srralphs int pkt_retry_cnt; 8975628Srralphs tapepos_t pos; 8985628Srralphs const cmd_attribute *cmd_attrib; 8995628Srralphs }recov_info; 9005628Srralphs 901177Scz147101 #ifdef _KERNEL 902177Scz147101 9035251Smrj #ifdef __x86 904177Scz147101 /* Data structure used in big block I/O on x86/x64 platform */ 905177Scz147101 906177Scz147101 /* 907177Scz147101 * alloc more than one contig_mem, so mutiple I/O can be 908177Scz147101 * on-going simultaneously 909177Scz147101 */ 910177Scz147101 #define ST_MAX_CONTIG_MEM_NUM 3 911177Scz147101 912177Scz147101 struct contig_mem { 913177Scz147101 struct contig_mem *cm_next; 914177Scz147101 size_t cm_len; 915177Scz147101 caddr_t cm_addr; 916177Scz147101 ddi_acc_handle_t cm_acc_hdl; 917177Scz147101 struct buf *cm_bp; 918177Scz147101 int cm_use_sbuf; 919177Scz147101 }; 9203138Sfrits 921177Scz147101 #endif 922177Scz147101 923177Scz147101 #endif /* _KERNEL */ 924177Scz147101 9250Sstevel@tonic-gate /* 9264549Srralphs * driver states.. 9272537Srralphs */ 9282537Srralphs typedef enum { 9294549Srralphs ST_STATE_CLOSED, 9304549Srralphs ST_STATE_OFFLINE, 9314549Srralphs ST_STATE_INITIALIZING, 9324549Srralphs ST_STATE_OPENING, 9334549Srralphs ST_STATE_OPEN_PENDING_IO, 9344549Srralphs ST_STATE_APPEND_TESTING, 9354549Srralphs ST_STATE_OPEN, 9364549Srralphs ST_STATE_RESOURCE_WAIT, 9374549Srralphs ST_STATE_CLOSING, 9384549Srralphs ST_STATE_SENSING, 9394549Srralphs ST_STATE_CLOSE_PENDING_OPEN 9404549Srralphs }st_states; 9412537Srralphs 9424549Srralphs typedef enum { RDWR, RDONLY, WORM, RDWORM, FAILED } writablity; 943*10740SJianfei.Wang@Sun.COM typedef enum { 944*10740SJianfei.Wang@Sun.COM TLR_NOT_KNOWN, 945*10740SJianfei.Wang@Sun.COM TLR_NOT_SUPPORTED, 946*10740SJianfei.Wang@Sun.COM TLR_SAS_ONE_DEVICE, 947*10740SJianfei.Wang@Sun.COM TLR_SAS_TWO_DEVICE 948*10740SJianfei.Wang@Sun.COM }st_tlr_state; 9494549Srralphs 9502537Srralphs 9512537Srralphs /* 9520Sstevel@tonic-gate * Private info for scsi tapes. Pointed to by the un_private pointer 9530Sstevel@tonic-gate * of one of the SCSI_DEVICE chains. 9540Sstevel@tonic-gate */ 9550Sstevel@tonic-gate 9560Sstevel@tonic-gate struct scsi_tape { 9570Sstevel@tonic-gate struct scsi_device *un_sd; /* back pointer to SCSI_DEVICE */ 9580Sstevel@tonic-gate struct scsi_pkt *un_rqs; /* ptr to request sense command */ 9590Sstevel@tonic-gate struct scsi_pkt *un_mkr_pkt; /* ptr to marker packet */ 9600Sstevel@tonic-gate kcondvar_t un_sbuf_cv; /* cv on ownership of special buf */ 9610Sstevel@tonic-gate kcondvar_t un_queue_cv; /* cv on all queued commands */ 9620Sstevel@tonic-gate struct buf *un_sbufp; /* for use in special io */ 9630Sstevel@tonic-gate char *un_srqbufp; /* sense buffer for special io */ 9640Sstevel@tonic-gate kcondvar_t un_clscv; /* closing cv */ 9650Sstevel@tonic-gate struct buf *un_quef; /* head of wait queue */ 9660Sstevel@tonic-gate struct buf *un_quel; /* tail of wait queue */ 9670Sstevel@tonic-gate struct buf *un_runqf; /* head of run queue */ 9680Sstevel@tonic-gate struct buf *un_runql; /* tail of run queue */ 9690Sstevel@tonic-gate struct seq_mode *un_mspl; /* ptr to mode select info */ 9700Sstevel@tonic-gate struct st_drivetype *un_dp; /* ptr to drive table entry */ 9710Sstevel@tonic-gate uint_t un_dp_size; /* size of un_dp alloc'ed */ 9720Sstevel@tonic-gate caddr_t un_tmpbuf; /* buf for append, autodens ops */ 9734549Srralphs tapepos_t un_pos; /* Current tape position */ 9740Sstevel@tonic-gate int un_oflags; /* open flags */ 9754549Srralphs tapepos_t un_err_pos; /* block in file where err occurred */ 9760Sstevel@tonic-gate uint_t un_err_resid; /* resid from last error */ 9770Sstevel@tonic-gate short un_fmneeded; /* filemarks to be written - HP only */ 9780Sstevel@tonic-gate dev_t un_dev; /* unix device */ 9790Sstevel@tonic-gate uchar_t un_attached; /* unit known && attached */ 9800Sstevel@tonic-gate int un_pwr_mgmt; /* power management state */ 9810Sstevel@tonic-gate uchar_t un_density_known; /* density is known */ 9820Sstevel@tonic-gate uchar_t un_curdens; /* index into density table */ 9832537Srralphs optype un_lastop; /* last I/O was: read/write/ctl */ 9844549Srralphs st_states un_laststate; /* last state */ 9854549Srralphs st_states un_state; /* current state */ 9860Sstevel@tonic-gate uchar_t un_status; /* status from last sense */ 9870Sstevel@tonic-gate uchar_t un_retry_ct; /* retry count */ 9882537Srralphs writablity un_read_only; /* RDWR, RDONLY, WORM, RDWORM */ 9890Sstevel@tonic-gate uchar_t un_test_append; /* check writing at end of tape */ 9900Sstevel@tonic-gate uchar_t un_arq_enabled; /* auto request sense enabled */ 9910Sstevel@tonic-gate uchar_t un_untagged_qing; /* hba has untagged quing */ 9920Sstevel@tonic-gate uchar_t un_allow_large_xfer; /* allow >64k xfers if requested */ 9930Sstevel@tonic-gate uchar_t un_sbuf_busy; /* sbuf busy flag */ 9940Sstevel@tonic-gate uchar_t un_ncmds; /* number of commands outstanding */ 9950Sstevel@tonic-gate uchar_t un_throttle; /* curr. max number of cmds outst. */ 9960Sstevel@tonic-gate uchar_t un_last_throttle; /* saved max number of cmds outst. */ 9970Sstevel@tonic-gate uchar_t un_max_throttle; /* max poss. number cmds outstanding */ 9980Sstevel@tonic-gate uchar_t un_persistence; /* 1 = persistence on, 0 off */ 9990Sstevel@tonic-gate uchar_t un_persist_errors; /* 1 = persistenced flagged */ 10000Sstevel@tonic-gate uchar_t un_flush_on_errors; /* HBA will flush all I/O's on a */ 10010Sstevel@tonic-gate /* check condidtion or error */ 10020Sstevel@tonic-gate uint_t un_kbytes_xferred; /* bytes (in K) counter */ 10030Sstevel@tonic-gate uint_t un_last_resid; /* keep last resid, for PE */ 10040Sstevel@tonic-gate uint_t un_last_count; /* keep last count, for PE */ 10050Sstevel@tonic-gate struct kstat *un_stats; /* for I/O statistics */ 10060Sstevel@tonic-gate struct buf *un_rqs_bp; /* bp used in rqpkt */ 10070Sstevel@tonic-gate struct buf *un_wf; /* head of write queue */ 10080Sstevel@tonic-gate struct buf *un_wl; /* tail of write queue */ 10090Sstevel@tonic-gate struct read_blklim *un_rbl; /* ptr to read block limit info */ 10100Sstevel@tonic-gate int un_maxdma; /* max dma xfer allowed by HBA */ 10110Sstevel@tonic-gate uint_t un_bsize; /* block size currently being used */ 10120Sstevel@tonic-gate int un_maxbsize; /* max block size allowed by drive */ 10130Sstevel@tonic-gate uint_t un_minbsize; /* min block size allowed by drive */ 10140Sstevel@tonic-gate int un_errno; /* errno (b_error) */ 10150Sstevel@tonic-gate kcondvar_t un_state_cv; /* mediastate condition variable */ 10160Sstevel@tonic-gate enum mtio_state un_mediastate; /* current media state */ 10170Sstevel@tonic-gate enum mtio_state un_specified_mediastate; /* expected state */ 10180Sstevel@tonic-gate timeout_id_t un_delay_tid; /* delayed cv tid */ 10190Sstevel@tonic-gate timeout_id_t un_hib_tid; /* handle interrupt busy tid */ 10200Sstevel@tonic-gate opaque_t un_swr_token; /* scsi_watch request token */ 10210Sstevel@tonic-gate uchar_t un_comp_page; /* compression page */ 10220Sstevel@tonic-gate uchar_t un_rsvd_status; /* Reservation Status */ 10230Sstevel@tonic-gate kstat_t *un_errstats; /* for error statistics */ 10245628Srralphs int un_init_options; /* Init time drive options */ 10250Sstevel@tonic-gate int un_save_fileno; /* Save here for recovery */ 10260Sstevel@tonic-gate daddr_t un_save_blkno; /* Save here for recovery */ 10274549Srralphs uchar_t un_restore_pos; /* Indication to do recovery */ 10284549Srralphs tapepos_t un_suspend_pos; /* Save blkno for SUSPEND */ 10290Sstevel@tonic-gate uchar_t un_silent_skip; /* to catch short reads */ 10304549Srralphs short un_tids_at_suspend; /* timeouts set at suspend */ 10314549Srralphs kcondvar_t un_tape_busy_cv; /* busy cv */ 10324549Srralphs kcondvar_t un_suspend_cv; /* busy cv */ 10330Sstevel@tonic-gate /* restore on close */ 10340Sstevel@tonic-gate uchar_t un_eject_tape_on_failure; /* 1 = eject tape, 0 = don't */ 10350Sstevel@tonic-gate uchar_t un_HeadClean; /* support and need head cleaning? */ 10360Sstevel@tonic-gate uchar_t un_rqs_state; /* see define below */ 10374549Srralphs struct scsi_extended_sense 10384549Srralphs *un_uscsi_rqs_buf; /* uscsi_rqs: buffer for RQS data */ 10390Sstevel@tonic-gate uchar_t un_data_mod; /* Device required data mod */ 10402537Srralphs writablity (*un_wormable) (struct scsi_tape *un); /* worm test fuct */ 10412537Srralphs int un_max_cdb_sz; /* max cdb size to use */ 10424549Srralphs read_p_types un_read_pos_type; 10434549Srralphs read_pos_data_t *un_read_pos_data; 10445077Sbz211116 struct mterror_entry_stack *un_error_entry_stk; 10455077Sbz211116 /* latest sense cmd buffer */ 10465251Smrj #ifdef __x86 1047177Scz147101 ddi_dma_handle_t un_contig_mem_hdl; 1048177Scz147101 struct contig_mem *un_contig_mem; 1049177Scz147101 int un_contig_mem_available_num; 1050177Scz147101 int un_contig_mem_total_num; 1051932Scz147101 size_t un_max_contig_mem_len; 1052177Scz147101 kcondvar_t un_contig_mem_cv; 10535251Smrj int un_maxdma_arch; /* max dma xfer allowed by HBA & arch */ 1054177Scz147101 #endif 10555628Srralphs caddr_t un_media_id; 10565628Srralphs int un_media_id_len; 10575628Srralphs int (*un_media_id_method)(struct scsi_tape *, int (*)()); 10585628Srralphs buf_t *un_recov_buf; /* buf to recover failed commands */ 10595628Srralphs kcondvar_t un_recov_buf_cv; /* cv for buf un_recov_buf */ 10605628Srralphs uchar_t un_recov_buf_busy; 10615628Srralphs #ifdef _KERNEL 10625628Srralphs ddi_taskq_t *un_recov_taskq; 10635628Srralphs #else 10645628Srralphs void *un_recov_taskq; 10655628Srralphs #endif 10665628Srralphs tapepos_t un_running; 10675628Srralphs uchar_t un_unit_attention_flags; 10686941Srralphs uchar_t un_multipath; 10696941Srralphs ulong_t un_last_path_instance; 1070*10740SJianfei.Wang@Sun.COM st_tlr_state un_tlr_flag; /* tape support TLR flag */ 10710Sstevel@tonic-gate }; 10723138Sfrits 10735628Srralphs typedef int (*bufunc_t)(struct scsi_tape *, int, int64_t, int); 10745628Srralphs typedef int (*ubufunc_t)(struct scsi_tape *, struct uscsi_cmd *, int); 10755628Srralphs 10763138Sfrits 10770Sstevel@tonic-gate /* 10780Sstevel@tonic-gate * device error kstats 10790Sstevel@tonic-gate */ 10800Sstevel@tonic-gate struct st_errstats { 10810Sstevel@tonic-gate struct kstat_named st_softerrs; 10820Sstevel@tonic-gate struct kstat_named st_harderrs; 10830Sstevel@tonic-gate struct kstat_named st_transerrs; 10840Sstevel@tonic-gate struct kstat_named st_vid; 10850Sstevel@tonic-gate struct kstat_named st_pid; 10860Sstevel@tonic-gate struct kstat_named st_revision; 10870Sstevel@tonic-gate struct kstat_named st_serial; 10880Sstevel@tonic-gate }; 10890Sstevel@tonic-gate 10900Sstevel@tonic-gate /* 10910Sstevel@tonic-gate * generic log page struct 10920Sstevel@tonic-gate */ 10930Sstevel@tonic-gate struct log_page { 10940Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH) 10950Sstevel@tonic-gate uchar_t code :6, /* page code number */ 10960Sstevel@tonic-gate :2; /* reserved */ 10970Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL) 10980Sstevel@tonic-gate uchar_t :2, /* reserved */ 10990Sstevel@tonic-gate code :6; /* page code number */ 11000Sstevel@tonic-gate #endif /* _BIT_FIELDS_LTOH */ 11010Sstevel@tonic-gate uchar_t reserved; /* reserved */ 11020Sstevel@tonic-gate uchar_t length_hi; /* length of bytes to follow (msb) */ 11030Sstevel@tonic-gate uchar_t length_lo; /* length of bytes to follow (lsb) */ 11040Sstevel@tonic-gate /* 11050Sstevel@tonic-gate * Log parameters follow right after this... 11060Sstevel@tonic-gate */ 11070Sstevel@tonic-gate }; 11080Sstevel@tonic-gate 11090Sstevel@tonic-gate /* 11100Sstevel@tonic-gate * generic log page parameter struct 11110Sstevel@tonic-gate */ 11120Sstevel@tonic-gate struct log_param { 11130Sstevel@tonic-gate uchar_t pc_hi; /* parameter code (msb) */ 11140Sstevel@tonic-gate uchar_t pc_lo; /* parameter code (lsb) */ 11150Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH) 11160Sstevel@tonic-gate uchar_t lp : 1, /* list parameter */ 11170Sstevel@tonic-gate : 1, /* reserved */ 11180Sstevel@tonic-gate tmc : 2, /* threshold met criteria */ 11190Sstevel@tonic-gate etc : 1, /* enable threshold comparison */ 11200Sstevel@tonic-gate tsd : 1, /* target save disable */ 11210Sstevel@tonic-gate ds : 1, /* disable save */ 11220Sstevel@tonic-gate du : 1; /* disable update */ 11230Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL) 11240Sstevel@tonic-gate uchar_t du : 1, /* disable update */ 11250Sstevel@tonic-gate ds : 1, /* disable save */ 11260Sstevel@tonic-gate tsd : 1, /* target save disable */ 11270Sstevel@tonic-gate etc : 1, /* enable threshold comparison */ 11280Sstevel@tonic-gate tmc : 2, /* threshold met criteria */ 11290Sstevel@tonic-gate : 1, /* reserved */ 11300Sstevel@tonic-gate lp : 1; /* list parameter */ 11310Sstevel@tonic-gate #endif /* _BIT_FIELDS_LTOH */ 11320Sstevel@tonic-gate uchar_t length; /* length of bytes to follow */ 11330Sstevel@tonic-gate /* 11340Sstevel@tonic-gate * Parameter values follow right after this... 11350Sstevel@tonic-gate */ 11360Sstevel@tonic-gate }; 11370Sstevel@tonic-gate /* 11380Sstevel@tonic-gate * TapeAlert structures 11390Sstevel@tonic-gate */ 11400Sstevel@tonic-gate 11410Sstevel@tonic-gate struct st_tape_alert_parameter { 11420Sstevel@tonic-gate struct log_param log_param; 11430Sstevel@tonic-gate uchar_t param_value; 11440Sstevel@tonic-gate }; 11450Sstevel@tonic-gate 11460Sstevel@tonic-gate struct st_tape_alert { 11470Sstevel@tonic-gate struct log_page log_page; 11480Sstevel@tonic-gate struct st_tape_alert_parameter param[TAPE_ALERT_MAX_PARA]; 11490Sstevel@tonic-gate }; 11500Sstevel@tonic-gate 11510Sstevel@tonic-gate #define TAPE_ALERT_PARAMETER_LENGTH \ 11520Sstevel@tonic-gate (sizeof (struct st_tape_alert_parameter)) * TAPE_ALERT_MAX_PARA 11530Sstevel@tonic-gate 11540Sstevel@tonic-gate struct log_sequential_page_parameter { 11550Sstevel@tonic-gate struct log_param log_param; 11560Sstevel@tonic-gate uchar_t param_value[8]; 11570Sstevel@tonic-gate }; 11580Sstevel@tonic-gate 11590Sstevel@tonic-gate struct log_sequential_page { 11600Sstevel@tonic-gate struct log_page log_page; 11610Sstevel@tonic-gate struct log_sequential_page_parameter param[TAPE_SEQUENTIAL_PAGE_PARA]; 11620Sstevel@tonic-gate }; 11630Sstevel@tonic-gate 11640Sstevel@tonic-gate #if !defined(__lint) 11650Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, scsi_tape)) 11660Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_tape::un_dp)) 11670Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_tape::un_sd)) 11680Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_tape::un_rqs)) 11693138Sfrits _NOTE(SCHEME_PROTECTS_DATA("protected by cv", scsi_tape::un_sbufp)) 11700Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(scsi_tape::un_bsize)) 11710Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_arq_status)) 11720Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("save sharing", 11730Sstevel@tonic-gate scsi_tape::un_allow_large_xfer 11740Sstevel@tonic-gate scsi_tape::un_maxbsize 11750Sstevel@tonic-gate scsi_tape::un_maxdma 11760Sstevel@tonic-gate )) 11775251Smrj #ifdef __x86 11783138Sfrits _NOTE(DATA_READABLE_WITHOUT_LOCK(scsi_tape::un_contig_mem_hdl)) 11793138Sfrits _NOTE(SCHEME_PROTECTS_DATA("not shared", contig_mem)) 11803138Sfrits #endif 11810Sstevel@tonic-gate #endif 11820Sstevel@tonic-gate 11830Sstevel@tonic-gate 11840Sstevel@tonic-gate /* 11850Sstevel@tonic-gate * Power management state 11860Sstevel@tonic-gate */ 11870Sstevel@tonic-gate #define ST_PWR_NORMAL 0 11880Sstevel@tonic-gate #define ST_PWR_SUSPENDED 1 11890Sstevel@tonic-gate 11900Sstevel@tonic-gate 11914549Srralphs #define IN_EOF(pos) (pos.eof == ST_EOF_PENDING || pos.eof == ST_EOF) 11920Sstevel@tonic-gate 11930Sstevel@tonic-gate /* un_rqs_state codes */ 11940Sstevel@tonic-gate 11950Sstevel@tonic-gate #define ST_RQS_OVR 0x1 /* RQS data was overwritten */ 11960Sstevel@tonic-gate #define ST_RQS_VALID 0x2 /* RQS data is valid */ 11970Sstevel@tonic-gate #define ST_RQS_READ 0x4 /* RQS data was read */ 11980Sstevel@tonic-gate #define ST_RQS_ERROR 0x8 /* RQS resulted in an EIO */ 11990Sstevel@tonic-gate 12000Sstevel@tonic-gate /* 12015628Srralphs * st_intr codes 12020Sstevel@tonic-gate */ 12035628Srralphs typedef enum { 12045628Srralphs COMMAND_DONE, 12055628Srralphs COMMAND_DONE_ERROR, 12065628Srralphs COMMAND_DONE_ERROR_RECOVERED, 12075628Srralphs QUE_COMMAND, 12085628Srralphs QUE_BUSY_COMMAND, 12095628Srralphs QUE_SENSE, 12105628Srralphs JUST_RETURN, 12115628Srralphs COMMAND_DONE_EACCES, 12125628Srralphs QUE_LAST_COMMAND, 12135628Srralphs COMMAND_TIMEOUT, 12145628Srralphs PATH_FAILED, 12155628Srralphs DEVICE_RESET, 12165628Srralphs DEVICE_TAMPER, 12175628Srralphs ATTEMPT_RETRY 12185628Srralphs }errstate; 12195628Srralphs #ifdef _KERNEL 12205628Srralphs typedef struct { 12216640Scth struct scsi_arq_status ei_failing_status; 12226640Scth tapepos_t ei_expected_pos; 12236640Scth errstate ei_error_type; 12246640Scth buf_t *ei_failing_bp; 12256640Scth struct scsi_pkt ei_failed_pkt; /* must be last */ 12266640Scth /* ...scsi_pkt_size() */ 12275628Srralphs } st_err_info; 12286640Scth #define ST_ERR_INFO_SIZE (sizeof (st_err_info) - \ 12296640Scth sizeof (struct scsi_pkt) + scsi_pkt_size()) 12305628Srralphs #endif 12310Sstevel@tonic-gate 12320Sstevel@tonic-gate 12330Sstevel@tonic-gate /* 12340Sstevel@tonic-gate * Reservation Status 12350Sstevel@tonic-gate * 12360Sstevel@tonic-gate * ST_INIT_RESERVE -Used to check if the reservation has been lost 12370Sstevel@tonic-gate * in between opens and also to indicate the reservation 12380Sstevel@tonic-gate * has not been done till now. 12390Sstevel@tonic-gate * ST_RELEASE -Tape Unit is Released. 12400Sstevel@tonic-gate * ST_RESERVE -Tape Unit is Reserved. 12410Sstevel@tonic-gate * ST_PRESERVE_RESERVE -Reservation is to be preserved across opens. 12420Sstevel@tonic-gate * 12430Sstevel@tonic-gate */ 12440Sstevel@tonic-gate #define ST_INIT_RESERVE 0x001 12450Sstevel@tonic-gate #define ST_RELEASE 0x002 12460Sstevel@tonic-gate #define ST_RESERVE 0x004 12470Sstevel@tonic-gate #define ST_PRESERVE_RESERVE 0x008 12480Sstevel@tonic-gate #define ST_RESERVATION_CONFLICT 0x010 12490Sstevel@tonic-gate #define ST_LOST_RESERVE 0x020 12501697Srralphs #define ST_APPLICATION_RESERVATIONS 0x040 12515628Srralphs #define ST_INITIATED_RESET 0x080 12521697Srralphs #define ST_LOST_RESERVE_BETWEEN_OPENS \ 12531697Srralphs (ST_RESERVE | ST_LOST_RESERVE | ST_PRESERVE_RESERVE) 12540Sstevel@tonic-gate 12551697Srralphs /* 12561697Srralphs * Service action defines for Persistant Reservation Commands 12571697Srralphs */ 12581697Srralphs #define ST_SA_SCSI3_REGISTER 0x00 12591697Srralphs #define ST_SA_SCSI3_RESERVE 0x01 12601697Srralphs #define ST_SA_SCSI3_RELEASE 0x02 12611697Srralphs #define ST_SA_SCSI3_CLEAR 0x03 12621697Srralphs #define ST_SA_SCSI3_PREEMPT 0x04 12631697Srralphs #define ST_SA_SCSI3_PREEMPTANDABORT 0x05 12641697Srralphs #define ST_SA_SCSI3_REGISTERANDIGNOREKEY 0x06 12651697Srralphs #define ST_SA_MASK 0x1f 12660Sstevel@tonic-gate 12670Sstevel@tonic-gate #define ST_RESERVATION_DELAY 500000 12680Sstevel@tonic-gate 12690Sstevel@tonic-gate /* 12700Sstevel@tonic-gate * Asynch I/O tunables 12710Sstevel@tonic-gate */ 12720Sstevel@tonic-gate #define ST_MAX_THROTTLE 4 12730Sstevel@tonic-gate 12740Sstevel@tonic-gate /* 12750Sstevel@tonic-gate * 60 minutes seems a reasonable amount of time 12760Sstevel@tonic-gate * to wait for tape space operations to complete. 12770Sstevel@tonic-gate * 12780Sstevel@tonic-gate */ 12790Sstevel@tonic-gate #define ST_SPACE_TIME MINUTES(60) /* 60 minutes per space operation */ 12800Sstevel@tonic-gate #define ST_LONG_SPACE_TIME_X 5 /* multipiler for long space ops */ 12810Sstevel@tonic-gate 12820Sstevel@tonic-gate /* 12830Sstevel@tonic-gate * 2 minutes seems a reasonable amount of time 12840Sstevel@tonic-gate * to wait for tape i/o operations to complete. 12850Sstevel@tonic-gate * 12860Sstevel@tonic-gate */ 12870Sstevel@tonic-gate #define ST_IO_TIME MINUTES(2) /* minutes per i/o */ 12880Sstevel@tonic-gate #define ST_LONG_TIMEOUT_X 5 /* multiplier for very long timeouts */ 12890Sstevel@tonic-gate 12900Sstevel@tonic-gate 12910Sstevel@tonic-gate /* 12920Sstevel@tonic-gate * 10 seconds is what we'll wait if we get a Busy Status back 12930Sstevel@tonic-gate */ 12940Sstevel@tonic-gate #define ST_STATUS_BUSY_TIMEOUT 10*hz /* seconds Busy Waiting */ 12956941Srralphs #define ST_TRAN_BUSY_TIMEOUT 4*hz /* seconds retry on TRAN_BSY */ 12960Sstevel@tonic-gate #define ST_INTERRUPT_CONTEXT 1 12970Sstevel@tonic-gate #define ST_START_CONTEXT 2 12980Sstevel@tonic-gate 12990Sstevel@tonic-gate /* 13000Sstevel@tonic-gate * Number of times we'll retry a normal operation. 13010Sstevel@tonic-gate * 13020Sstevel@tonic-gate * XXX This includes retries due to transport failure as well as 13030Sstevel@tonic-gate * XXX busy timeouts- Need to distinguish between Target and Transport 13040Sstevel@tonic-gate * XXX failure. 13050Sstevel@tonic-gate */ 13060Sstevel@tonic-gate 13070Sstevel@tonic-gate #define ST_RETRY_COUNT 20 13080Sstevel@tonic-gate 13090Sstevel@tonic-gate /* 13100Sstevel@tonic-gate * Number of times to retry a failed selection 13110Sstevel@tonic-gate */ 13120Sstevel@tonic-gate #define ST_SEL_RETRY_COUNT 2 13130Sstevel@tonic-gate 13140Sstevel@tonic-gate /* 13150Sstevel@tonic-gate * es_code value for deferred error 13160Sstevel@tonic-gate * should be moved to sense.h 13170Sstevel@tonic-gate */ 13180Sstevel@tonic-gate 13190Sstevel@tonic-gate #define ST_DEFERRED_ERROR 0x01 13200Sstevel@tonic-gate 13210Sstevel@tonic-gate /* 13220Sstevel@tonic-gate * Maximum number of units (determined by minor device byte) 13230Sstevel@tonic-gate */ 13240Sstevel@tonic-gate #define ST_MAXUNIT 128 13250Sstevel@tonic-gate 13260Sstevel@tonic-gate /* 13270Sstevel@tonic-gate * Time to wait for completion of a command before cancelling it. 13280Sstevel@tonic-gate * For SUSPEND use only 13290Sstevel@tonic-gate */ 13300Sstevel@tonic-gate #define ST_WAIT_CMDS_COMPLETE 10 /* seconds */ 13310Sstevel@tonic-gate 13320Sstevel@tonic-gate #ifndef SECSIZE 13330Sstevel@tonic-gate #define SECSIZE 512 13340Sstevel@tonic-gate #endif 13350Sstevel@tonic-gate #ifndef SECDIV 13360Sstevel@tonic-gate #define SECDIV 9 13370Sstevel@tonic-gate #endif 13380Sstevel@tonic-gate 13390Sstevel@tonic-gate /* 13400Sstevel@tonic-gate * convenient defines 13410Sstevel@tonic-gate */ 13425628Srralphs #define ST_SCSI_DEVP (un->un_sd) 13430Sstevel@tonic-gate #define ST_DEVINFO (ST_SCSI_DEVP->sd_dev) 13440Sstevel@tonic-gate #define ST_INQUIRY (ST_SCSI_DEVP->sd_inq) 13450Sstevel@tonic-gate #define ST_RQSENSE (ST_SCSI_DEVP->sd_sense) 13460Sstevel@tonic-gate #define ST_MUTEX (&ST_SCSI_DEVP->sd_mutex) 13470Sstevel@tonic-gate #define ROUTE (&ST_SCSI_DEVP->sd_address) 13480Sstevel@tonic-gate 13490Sstevel@tonic-gate #define BSD_BEHAVIOR (getminor(un->un_dev) & MT_BSD) 13500Sstevel@tonic-gate #define SVR4_BEHAVIOR ((getminor(un->un_dev) & MT_BSD) == 0) 13516941Srralphs #define ST_STATUS_MASK (STATUS_MASK | STATUS_TASK_ABORT) 13520Sstevel@tonic-gate #define SCBP(pkt) ((struct scsi_status *)(pkt)->pkt_scbp) 13536941Srralphs #define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & ST_STATUS_MASK) 13540Sstevel@tonic-gate #define CDBP(pkt) ((union scsi_cdb *)(pkt)->pkt_cdbp) 13550Sstevel@tonic-gate #define BP_PKT(bp) ((struct scsi_pkt *)(bp)->av_back) 13560Sstevel@tonic-gate #define SET_BP_PKT(bp, pkt) ((bp)->av_back = (struct buf *)(pkt)) 13570Sstevel@tonic-gate #define BP_UCMD(bp) ((struct uscsi_cmd *)(bp)->b_back) 13580Sstevel@tonic-gate #define USCSI_CMD(bp) (((bp) == un->un_sbufp) && (BP_UCMD(bp))) 13590Sstevel@tonic-gate 13600Sstevel@tonic-gate #define IS_CLOSING(un) ((un)->un_state == ST_STATE_CLOSING || \ 13610Sstevel@tonic-gate ((un)->un_state == ST_STATE_SENSING && \ 13620Sstevel@tonic-gate (un)->un_laststate == ST_STATE_CLOSING)) 13630Sstevel@tonic-gate 13640Sstevel@tonic-gate #define ASYNC_CMD 0 13650Sstevel@tonic-gate #define SYNC_CMD 1 13660Sstevel@tonic-gate 13670Sstevel@tonic-gate #define st_bioerror(bp, error) \ 13680Sstevel@tonic-gate { bioerror(bp, error); \ 13690Sstevel@tonic-gate un->un_errno = error; } 13700Sstevel@tonic-gate 13710Sstevel@tonic-gate /* 13720Sstevel@tonic-gate * Macros for internal coding of count for SPACE command: 13730Sstevel@tonic-gate * 13745628Srralphs * Top 3 bits of b_bcount define direction and type of space. 13755628Srralphs * Since b_bcount (size_t) is 32 bits on 32 platforms and 64 bits on 13765628Srralphs * 64 bit platforms different defines are used. 13775628Srralphs * if SP_BACKSP is set direction is backward (toward BOP) 13785628Srralphs * The type of space (Blocks, Filemark or sequential filemarks) is 13795628Srralphs * carried in the next 2 bits. The remaining bits a signed count of 13805628Srralphs * how many of that direction and type to do. 13810Sstevel@tonic-gate */ 13826941Srralphs 13836941Srralphs #if (defined(__lock_lint)) 13846941Srralphs /* 13856941Srralphs * This is a workaround for warlock not being able to parse an #ULL constant. 13866941Srralphs */ 13876941Srralphs #undef UINT64_MAX 13886941Srralphs #define UINT64_MAX (18446744073709551615UL) 13896941Srralphs #endif /* __lock_lint */ 13906941Srralphs 13916941Srralphs #if (defined(__lock_lint) || (SIZE_MAX < UINT64_MAX)) 13925628Srralphs 13935628Srralphs #define SP_BLK UINT32_C(0x00000000) 13945628Srralphs #define SP_FLM UINT32_C(0x20000000) 13955628Srralphs #define SP_SQFLM UINT32_C(0x40000000) 13965628Srralphs #define SP_EOD UINT32_C(0x60000000) 13975628Srralphs #define SP_BACKSP UINT32_C(0x80000000) 13985628Srralphs #define SP_CMD_MASK UINT32_C(0x60000000) 13995628Srralphs #define SP_CNT_MASK UINT32_C(0x1fffffff) 14005628Srralphs 14015628Srralphs /* Macros to interpret space cmds */ 14025628Srralphs #define SPACE_CNT(x) (((x) & SP_BACKSP)? \ 14035628Srralphs (-((x)&(SP_CNT_MASK))):(x)&(SP_CNT_MASK)) 14045628Srralphs #define SPACE_TYPE(x) ((x & SP_CMD_MASK)>>29) 14055628Srralphs 14065628Srralphs #else /* end of small size_t in buf_t */ 14075628Srralphs 14085628Srralphs #define SP_BLK UINT64_C(0x0000000000000000) 14095628Srralphs #define SP_FLM UINT64_C(0x2000000000000000) 14105628Srralphs #define SP_SQFLM UINT64_C(0x4000000000000000) 14115628Srralphs #define SP_EOD UINT64_C(0x6000000000000000) 14125628Srralphs #define SP_BACKSP UINT64_C(0x8000000000000000) 14135628Srralphs #define SP_CMD_MASK UINT64_C(0x6000000000000000) 14145628Srralphs #define SP_CNT_MASK UINT64_C(0x1fffffffffffffff) 14155628Srralphs 14165628Srralphs /* Macros to interpret space cmds */ 14175628Srralphs #define SPACE_CNT(x) (((x) & SP_BACKSP)? \ 14185628Srralphs (-((x)&(SP_CNT_MASK))):(x)&(SP_CNT_MASK)) 14195628Srralphs #define SPACE_TYPE(x) ((x & SP_CMD_MASK)>>61) 14205628Srralphs 14215628Srralphs #endif /* end of big size_t in buf_t */ 14224549Srralphs 14234549Srralphs /* Macros to assemble space cmds */ 14244549Srralphs #define SPACE(cmd, cnt) ((cnt < 0) ? (SP_BACKSP | (-(cnt)) | cmd) : (cmd | cnt)) 14254549Srralphs #define Fmk(x) SPACE(SP_FLM, x) 14264549Srralphs #define Blk(x) SPACE(SP_BLK, x) 14270Sstevel@tonic-gate 14284549Srralphs 14294549Srralphs 14304549Srralphs /* Defines for byte 4 of load/unload cmd */ 14314549Srralphs #define LD_UNLOAD 0 14324549Srralphs #define LD_LOAD 1 14334549Srralphs #define LD_RETEN 2 14344549Srralphs #define LD_EOT 4 14354549Srralphs #define LD_HOLD 8 14364549Srralphs 14374549Srralphs /* Defines for byte 4 of prevent/allow media removal */ 14384549Srralphs #define MR_UNLOCK 0 14394549Srralphs #define MR_LOCK 1 14400Sstevel@tonic-gate 14410Sstevel@tonic-gate #define GET_SOFT_STATE(dev) \ 14420Sstevel@tonic-gate register struct scsi_tape *un; \ 14430Sstevel@tonic-gate register int instance; \ 14440Sstevel@tonic-gate \ 14450Sstevel@tonic-gate instance = MTUNIT(dev); \ 14460Sstevel@tonic-gate if ((un = ddi_get_soft_state(st_state, instance)) == NULL) \ 14470Sstevel@tonic-gate return (ENXIO); 14480Sstevel@tonic-gate 14490Sstevel@tonic-gate /* 14500Sstevel@tonic-gate * Debugging turned on via conditional compilation switch -DSTDEBUG 14510Sstevel@tonic-gate */ 14520Sstevel@tonic-gate #ifdef DEBUG 14530Sstevel@tonic-gate #define STDEBUG 14540Sstevel@tonic-gate #endif 14550Sstevel@tonic-gate 14560Sstevel@tonic-gate #ifdef STDEBUG 14575628Srralphs #define DEBUGGING\ 14585628Srralphs ((scsi_options & SCSI_DEBUG_TGT) || (st_debug & 0x7)) 14594549Srralphs 14606941Srralphs #define DEBLOCK(d) int lev = CE_NOTE; mutex_enter(&st_debug_mutex); \ 14616941Srralphs if (d == st_lastdev || d == 0) lev = CE_CONT; mutex_exit(&st_debug_mutex); 14626941Srralphs 14636941Srralphs #define DEBUNLOCK(d) mutex_enter(&st_debug_mutex); \ 14646941Srralphs if (d != 0 && d != st_lastdev) st_lastdev = d; mutex_exit(&st_debug_mutex); 14650Sstevel@tonic-gate 14664549Srralphs /* initialization */ 14675628Srralphs #define ST_DEBUG1 if ((st_debug & 0x7) >= 1) scsi_log 14680Sstevel@tonic-gate #define ST_DEBUG ST_DEBUG1 14690Sstevel@tonic-gate 14704549Srralphs /* errors and UA's */ 14715628Srralphs #define ST_DEBUG2 if ((st_debug & 0x7) >= 2) scsi_log 14724549Srralphs 14734549Srralphs /* func calls */ 14745628Srralphs #define ST_DEBUG3 if ((st_debug & 0x7) >= 3) scsi_log 14754549Srralphs 14764549Srralphs /* ioctl calls */ 14775628Srralphs #define ST_DEBUG4 if ((st_debug & 0x7) >= 4) scsi_log 14784549Srralphs 14795628Srralphs #define ST_DEBUG5 if ((st_debug & 0x7) >= 5) scsi_log 14804549Srralphs 14814549Srralphs /* full data tracking */ 14825628Srralphs #define ST_DEBUG6 if ((st_debug & 0x7) >= 6) scsi_log 14830Sstevel@tonic-gate 14845628Srralphs /* debug error recovery */ 14855628Srralphs #define ST_RECOV if (st_debug & 0x8) scsi_log 14864549Srralphs 14874549Srralphs /* Entry Point Functions */ 14886941Srralphs #define ST_ENTR(d, fn) if (st_debug & 0x10) { DEBLOCK(d) \ 14896941Srralphs scsi_log(d, st_label, lev, #fn); DEBUNLOCK(d) } 14904549Srralphs 14914549Srralphs /* Non-Entry Point Functions */ 14926941Srralphs #define ST_FUNC(d, fn) if (st_debug & 0x20) { DEBLOCK(d) \ 14936941Srralphs scsi_log(d, st_label, lev, #fn); DEBUNLOCK(d) } 14944549Srralphs 14954549Srralphs /* Space Information */ 14964549Srralphs #define ST_SPAC if (st_debug & 0x40) scsi_log 14974549Srralphs 14984549Srralphs /* CDB's sent */ 14996941Srralphs #define ST_CDB(d, cmnt, cdb) if (st_debug & 0x180) { DEBLOCK(d) \ 15006941Srralphs st_print_cdb(d, st_label, lev, cmnt, cdb); DEBUNLOCK(d) } 15016941Srralphs 15025628Srralphs /* sense data */ 15036941Srralphs #define ST_SENSE(d, cmnt, sense, size) if (st_debug & 0x200) { DEBLOCK(d) \ 15046941Srralphs st_clean_print(d, st_label, lev, cmnt, sense, size); DEBUNLOCK(d) } 15056941Srralphs 15065628Srralphs /* position data */ 15076941Srralphs #define ST_POS(d, cmnt, pdata) if (st_debug & 0x400) { DEBLOCK(d) \ 15086941Srralphs st_print_position(d, st_label, lev, cmnt, pdata); DEBUNLOCK(d) } 15095628Srralphs 15100Sstevel@tonic-gate 15110Sstevel@tonic-gate #else 15120Sstevel@tonic-gate 15130Sstevel@tonic-gate #define st_debug (0) 15140Sstevel@tonic-gate #define DEBUGGING (0) 15150Sstevel@tonic-gate #define ST_DEBUG if (0) scsi_log 15160Sstevel@tonic-gate #define ST_DEBUG1 if (0) scsi_log 15170Sstevel@tonic-gate #define ST_DEBUG2 if (0) scsi_log 15180Sstevel@tonic-gate #define ST_DEBUG3 if (0) scsi_log 15190Sstevel@tonic-gate #define ST_DEBUG4 if (0) scsi_log 15200Sstevel@tonic-gate #define ST_DEBUG5 if (0) scsi_log 15210Sstevel@tonic-gate #define ST_DEBUG6 if (0) scsi_log 15225628Srralphs #define ST_RECOV if (0) scsi_log 15230Sstevel@tonic-gate 15244549Srralphs #define ST_ENTR(d, fn) 15254549Srralphs #define ST_FUNC(d, fn) 15264549Srralphs #define ST_SPAC if (0) scsi_log 15274549Srralphs #define ST_CDB(d, cmnt, cdb) 15284549Srralphs #define ST_SENSE(d, cmnt, sense, size) 15295628Srralphs #define ST_SENSE(d, cmnt, sense, size) 15305628Srralphs #define ST_POS(d, cmnt, pdata) 15314549Srralphs 15320Sstevel@tonic-gate #endif 15330Sstevel@tonic-gate 15340Sstevel@tonic-gate /* 15350Sstevel@tonic-gate * Media access values 15360Sstevel@tonic-gate */ 15370Sstevel@tonic-gate #define MEDIA_ACCESS_DELAY 5000000 /* usecs wait for media state change */ 15380Sstevel@tonic-gate 15390Sstevel@tonic-gate /* 15400Sstevel@tonic-gate * SCSI tape mode sense page information 15410Sstevel@tonic-gate */ 15420Sstevel@tonic-gate #define ST_DEV_CONFIG_PAGE 0x10 /* device config mode page */ 15430Sstevel@tonic-gate #define ST_DEV_CONFIG_NO_COMP 0x00 /* use no compression */ 15440Sstevel@tonic-gate #define ST_DEV_CONFIG_DEF_COMP 0x01 /* use default compression alg */ 15450Sstevel@tonic-gate #define ST_COMPRESSION_DENSITY 3 /* compression minor number */ 15460Sstevel@tonic-gate 15470Sstevel@tonic-gate /* 15480Sstevel@tonic-gate * SCSI tape data compression Page definition. 15490Sstevel@tonic-gate */ 15500Sstevel@tonic-gate #define ST_DEV_DATACOMP_PAGE 0x0F /* data compression page */ 15510Sstevel@tonic-gate 15520Sstevel@tonic-gate 15530Sstevel@tonic-gate 15540Sstevel@tonic-gate /* 15550Sstevel@tonic-gate * maxbsize values 15560Sstevel@tonic-gate */ 15570Sstevel@tonic-gate #define MAXBSIZE_UNKNOWN -2 /* not found yet */ 15580Sstevel@tonic-gate 15590Sstevel@tonic-gate #define ONE_MEG (1024 * 1024) 15600Sstevel@tonic-gate 15610Sstevel@tonic-gate /* 15620Sstevel@tonic-gate * generic soft error reporting 15630Sstevel@tonic-gate * 15640Sstevel@tonic-gate * What we are doing here is allowing a greater number of errors to occur on 15650Sstevel@tonic-gate * smaller transfers (i.e. usually at the beginning of the tape), than on 15660Sstevel@tonic-gate * the rest of the tape. 15670Sstevel@tonic-gate * 15680Sstevel@tonic-gate * A small transfer is defined as : 15690Sstevel@tonic-gate * Transfers <= SOFT_ERROR_WARNING_THRESHOLD allow about 1.5 times more errors 15700Sstevel@tonic-gate * 15710Sstevel@tonic-gate * A larget tranfer is defined as : 15720Sstevel@tonic-gate * Transfers > SOFT_ERROR_WARNING_THRESHOLD allow normal amount 15730Sstevel@tonic-gate * 15740Sstevel@tonic-gate */ 15750Sstevel@tonic-gate #define READ_SOFT_ERROR_WARNING_THRESHOLD (25 * ONE_MEG) 15760Sstevel@tonic-gate #define WRITE_SOFT_ERROR_WARNING_THRESHOLD (20 * ONE_MEG) 15770Sstevel@tonic-gate 15780Sstevel@tonic-gate /* 15790Sstevel@tonic-gate * soft error reporting for exabyte 15800Sstevel@tonic-gate */ 15810Sstevel@tonic-gate #define TAPE_SENSE_LENGTH 32 /* allows for softerror info */ 15820Sstevel@tonic-gate 15830Sstevel@tonic-gate #define SENSE_19_BITS \ 15840Sstevel@tonic-gate "\20\10PF\07BPE\06FPE\05ME\04ECO\03TME\02TNP\01LBOT" 15850Sstevel@tonic-gate #define SENSE_20_BITS \ 15860Sstevel@tonic-gate "\20\10RSVD\07RSVD\06WP\05FMKE\04URE\03WE1\02SSE\01FW" 15870Sstevel@tonic-gate #define SENSE_21_BITS \ 15880Sstevel@tonic-gate "\20\10RSVD\07RSVD\06RRR\05CLND\04CLN\03PEOT\02WSEB\01WSE0" 15890Sstevel@tonic-gate 15900Sstevel@tonic-gate /* these are defined in percentages */ 15910Sstevel@tonic-gate #define EXABYTE_WRITE_ERROR_THRESHOLD 6 15920Sstevel@tonic-gate #define EXABYTE_READ_ERROR_THRESHOLD 3 15930Sstevel@tonic-gate /* 15940Sstevel@tonic-gate * minumum amount of data transfer(MB) for checking soft error rate. 15950Sstevel@tonic-gate */ 15960Sstevel@tonic-gate #define EXABYTE_MIN_TRANSFER (25 * ONE_MEG) 15970Sstevel@tonic-gate 15980Sstevel@tonic-gate #define CLN 0x8 15990Sstevel@tonic-gate #define CLND 0x10 16000Sstevel@tonic-gate 16010Sstevel@tonic-gate /* 16020Sstevel@tonic-gate * soft error reporting for Archive 4mm DAT 16030Sstevel@tonic-gate */ 16040Sstevel@tonic-gate 16050Sstevel@tonic-gate #define LOG_SENSE_LENGTH 0xff 16060Sstevel@tonic-gate #define MIN_LOG_SENSE_LENGTH 0x2b 16070Sstevel@tonic-gate #define DAT_SMALL_WRITE_ERROR_THRESHOLD 40 /* retries per 20 mg */ 16080Sstevel@tonic-gate #define DAT_LARGE_WRITE_ERROR_THRESHOLD 200 /* retries for more 20 mg */ 16090Sstevel@tonic-gate #define DAT_SMALL_READ_ERROR_THRESHOLD 5 /* errors allowed */ 16100Sstevel@tonic-gate #define DAT_LARGE_READ_ERROR_THRESHOLD 3 /* errors allowed */ 16110Sstevel@tonic-gate 16120Sstevel@tonic-gate /* 16130Sstevel@tonic-gate * ST timeouts that need to be cancelled for suspend 16140Sstevel@tonic-gate */ 16150Sstevel@tonic-gate #define ST_HIB_TID 0x01 16160Sstevel@tonic-gate #define ST_DELAY_TID 0x02 16170Sstevel@tonic-gate 16180Sstevel@tonic-gate #ifdef __cplusplus 16190Sstevel@tonic-gate } 16200Sstevel@tonic-gate #endif 16210Sstevel@tonic-gate 16220Sstevel@tonic-gate #endif /* _SYS_SCSI_TARGETS_STDEF_H */ 1623