17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5e213afc3Srralphs  * Common Development and Distribution License (the "License").
6e213afc3Srralphs  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*af483cc8Sjianfei wang - Sun Microsystems - Beijing China  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_SCSI_TARGETS_STDEF_H
277c478bd9Sstevel@tonic-gate #define	_SYS_SCSI_TARGETS_STDEF_H
287c478bd9Sstevel@tonic-gate 
29f3531714Scz #include <sys/sunddi.h>
307c478bd9Sstevel@tonic-gate #include <sys/note.h>
317c478bd9Sstevel@tonic-gate #include <sys/condvar.h>
327c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
33f218e94bSrralphs #include <sys/int_limits.h>
347c478bd9Sstevel@tonic-gate #include <sys/scsi/scsi_types.h>
35c6914c10Srralphs #include <sys/scsi/generic/sense.h>
367c478bd9Sstevel@tonic-gate #include <sys/mtio.h>
37f218e94bSrralphs #include <sys/taskq.h>
38f218e94bSrralphs #include <sys/taskq_impl.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
417c478bd9Sstevel@tonic-gate extern "C" {
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * Defines for SCSI tape drives.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * Maximum variable length record size for a single request
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate #define	ST_MAXRECSIZE_VARIABLE	65535
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  * If the requested record size exceeds ST_MAXRECSIZE_VARIABLE,
557c478bd9Sstevel@tonic-gate  * then the following define is used.
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate #define	ST_MAXRECSIZE_VARIABLE_LIMIT	65534
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #define	ST_MAXRECSIZE_FIXED	(63<<10)	/* maximum fixed record size */
60a6ccd511Srralphs #define	INF 1000000000	/* old external count backwards from this from EOF */
61a6ccd511Srralphs #define	LASTBLK (-1)	/* new internal count backwards from EOF */
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /*
647c478bd9Sstevel@tonic-gate  * Supported tape device types plus default type for opening.
657c478bd9Sstevel@tonic-gate  * Types 10 - 13, are special (ancient too) drives - *NOT SUPPORTED*
667c478bd9Sstevel@tonic-gate  * Types 14 - 1f, are 1/4-inch cartridge drives.
677c478bd9Sstevel@tonic-gate  * Types 20 - 28, are 1/2-inch cartridge or reel drives.
687c478bd9Sstevel@tonic-gate  * Types 28+, are rdat (vcr) drives.
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate #define	ST_TYPE_INVALID		0x00
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate #define	ST_TYPE_SYSGEN1	MT_ISSYSGEN11	/* Sysgen with QIC-11 only */
737c478bd9Sstevel@tonic-gate #define	ST_TYPE_SYSGEN	MT_ISSYSGEN	/* Sysgen with QIC-24 and QIC-11 */
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #define	ST_TYPE_DEFAULT	MT_ISDEFAULT	/* Generic 1/4" or undetermined  */
767c478bd9Sstevel@tonic-gate #define	ST_TYPE_EMULEX	MT_ISMT02	/* Emulex MT-02 */
777c478bd9Sstevel@tonic-gate #define	ST_TYPE_ARCHIVE	MT_ISVIPER1	/* Archive QIC-150 */
787c478bd9Sstevel@tonic-gate #define	ST_TYPE_WANGTEK	MT_ISWANGTEK1	/* Wangtek QIC-150 */
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #define	ST_TYPE_CDC	MT_ISCDC	/* CDC - (not tested) */
817c478bd9Sstevel@tonic-gate #define	ST_TYPE_FUJI	MT_ISFUJI	/* Fujitsu - (not tested) */
827c478bd9Sstevel@tonic-gate #define	ST_TYPE_KENNEDY	MT_ISKENNEDY	/* Kennedy */
837c478bd9Sstevel@tonic-gate #define	ST_TYPE_ANRITSU	MT_ISANRITSU	/* Anritsu */
847c478bd9Sstevel@tonic-gate #define	ST_TYPE_HP	MT_ISHP		/* HP */
857c478bd9Sstevel@tonic-gate #define	ST_TYPE_HIC	MT_ISCCS23	/* Generic 1/2" Cartridge */
867c478bd9Sstevel@tonic-gate #define	ST_TYPE_REEL	MT_ISCCS24	/* Generic 1/2" Reel Tape */
877c478bd9Sstevel@tonic-gate #define	ST_TYPE_DAT	MT_ISCCS28	/* Generic DAT Tape */
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #define	ST_TYPE_EXABYTE	MT_ISEXABYTE	/* Exabyte 8200 */
907c478bd9Sstevel@tonic-gate #define	ST_TYPE_EXB8500	MT_ISEXB8500	/* Exabyte 8500 */
917c478bd9Sstevel@tonic-gate #define	ST_TYPE_WANGTHS	MT_ISWANGTHS	/* Wangtek 6130HS */
927c478bd9Sstevel@tonic-gate #define	ST_TYPE_WANGDAT	MT_ISWANGDAT	/* WangDAT */
937c478bd9Sstevel@tonic-gate #define	ST_TYPE_PYTHON  MT_ISPYTHON	/* Archive Python DAT */
947c478bd9Sstevel@tonic-gate #define	ST_TYPE_STC3490 MT_ISSTC	/* IBM STC 3490 */
957c478bd9Sstevel@tonic-gate #define	ST_TYPE_TAND25G MT_ISTAND25G	/* TANDBERG 2.5G */
967c478bd9Sstevel@tonic-gate #define	ST_TYPE_DLT	MT_ISDLT	/* DLT */
977c478bd9Sstevel@tonic-gate #define	ST_TYPE_STK9840	MT_ISSTK9840	/* StorageTek 9840, 9940, 9840B */
987c478bd9Sstevel@tonic-gate #define	ST_TYPE_BMDLT1	MT_ISBMDLT1	/* Benchmark DTL1 */
997c478bd9Sstevel@tonic-gate #define	ST_TYPE_LTO	MT_LTO		/* sun: LTO's by HP, Seagate, IBM.. */
1005988135dSrralphs #define	ST_TYPE_AIT	MT_ISAIT	/* Sony AIT I, II, III and SAIT */
1015988135dSrralphs #define	ST_LAST_TYPE	ST_TYPE_AIT	/* Add new above type and change this */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /* Internal flags */
1057c478bd9Sstevel@tonic-gate #define	ST_DYNAMIC		0x2000	/* Device name has been dynamically */
1067c478bd9Sstevel@tonic-gate 					/* alloc'ed from the st.conf entry, */
1077c478bd9Sstevel@tonic-gate 					/* instead of being used from the */
1087c478bd9Sstevel@tonic-gate 					/* st_drivetypes array. */
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * Defines for supported drive options
1127c478bd9Sstevel@tonic-gate  *
1137c478bd9Sstevel@tonic-gate  * WARNING : THESE OPTIONS SHOULD NEVER BE CHANGED, AS OLDER CONFIGURATIONS
1147c478bd9Sstevel@tonic-gate  * 		WILL DEPEND ON THE FLAG VALUES REMAINING THE SAME
1157c478bd9Sstevel@tonic-gate  */
1167c478bd9Sstevel@tonic-gate #define	ST_VARIABLE		0x001	/* Device supports variable	*/
1177c478bd9Sstevel@tonic-gate 					/* length record sizes		*/
1187c478bd9Sstevel@tonic-gate #define	ST_QIC			0x002	/* QIC tape device 		*/
1197c478bd9Sstevel@tonic-gate #define	ST_REEL			0x004	/* 1/2-inch reel tape device	*/
1207c478bd9Sstevel@tonic-gate #define	ST_BSF			0x008	/* Device supports backspace	*/
1217c478bd9Sstevel@tonic-gate 					/* file as in mt(1) bsf : 	*/
1227c478bd9Sstevel@tonic-gate 					/* backspace over EOF marks.	*/
1237c478bd9Sstevel@tonic-gate 					/* Devices not supporting bsf 	*/
1247c478bd9Sstevel@tonic-gate 					/* will fail with ENOTTY upon	*/
1257c478bd9Sstevel@tonic-gate 					/* use of bsf			*/
1267c478bd9Sstevel@tonic-gate #define	ST_BSR			0x010	/* Device supports backspace	*/
1277c478bd9Sstevel@tonic-gate 					/* record as in mt(1) bsr :	*/
1287c478bd9Sstevel@tonic-gate 					/* backspace over records. If	*/
1297c478bd9Sstevel@tonic-gate 					/* the device does not support 	*/
1307c478bd9Sstevel@tonic-gate 					/* bsr, the st driver emulates	*/
1317c478bd9Sstevel@tonic-gate 					/* the action by rewinding the	*/
1327c478bd9Sstevel@tonic-gate 					/* tape and using forward space	*/
1337c478bd9Sstevel@tonic-gate 					/* file (fsf) to the correct	*/
1347c478bd9Sstevel@tonic-gate 					/* file and then uses forward	*/
1357c478bd9Sstevel@tonic-gate 					/* space record (fsr) to the	*/
1367c478bd9Sstevel@tonic-gate 					/* correct  record		*/
1377c478bd9Sstevel@tonic-gate #define	ST_LONG_ERASE		0x020	/* Device needs a longer time	*/
1387c478bd9Sstevel@tonic-gate 					/* than normal to erase		*/
1397c478bd9Sstevel@tonic-gate #define	ST_AUTODEN_OVERRIDE	0x040	/* Auto-Density override flag	*/
1407c478bd9Sstevel@tonic-gate 					/* Device can figure out the	*/
1417c478bd9Sstevel@tonic-gate 					/* tape density automatically,	*/
1427c478bd9Sstevel@tonic-gate 					/* without issuing a		*/
1437c478bd9Sstevel@tonic-gate 					/* mode-select/mode-sense 	*/
1447c478bd9Sstevel@tonic-gate #define	ST_NOBUF		0x080	/* Don't use buffered mode.	*/
1457c478bd9Sstevel@tonic-gate 					/* This disables the device's	*/
1467c478bd9Sstevel@tonic-gate 					/* ability for buffered	writes	*/
1477c478bd9Sstevel@tonic-gate 					/* I.e. The device acknowledges	*/
1487c478bd9Sstevel@tonic-gate 					/* write completion after the	*/
1497c478bd9Sstevel@tonic-gate 					/* data is written to the	*/
1507c478bd9Sstevel@tonic-gate 					/* device's buffer, but before	*/
1517c478bd9Sstevel@tonic-gate 					/* all the data is actually	*/
1527c478bd9Sstevel@tonic-gate 					/* written to tape		*/
1537c478bd9Sstevel@tonic-gate #define	ST_RESERVED_BIT1	0x100	/* resreved bit 		*/
1547c478bd9Sstevel@tonic-gate 					/* parity while talking to it. 	*/
1557c478bd9Sstevel@tonic-gate #define	ST_KNOWS_EOD		0x200	/* Device knows when EOD (End	*/
1567c478bd9Sstevel@tonic-gate 					/* of Data) has been reached.	*/
1577c478bd9Sstevel@tonic-gate 					/* If the device knows EOD, st	*/
1587c478bd9Sstevel@tonic-gate 					/* uses fast file skipping.	*/
1597c478bd9Sstevel@tonic-gate 					/* If it does not know EOD,	*/
1607c478bd9Sstevel@tonic-gate 					/* file skipping happens one	*/
1617c478bd9Sstevel@tonic-gate 					/* file at a time. 		*/
1627c478bd9Sstevel@tonic-gate #define	ST_UNLOADABLE		0x400	/* Device will not complain if	*/
1637c478bd9Sstevel@tonic-gate 					/* the st driver is unloaded &	*/
1647c478bd9Sstevel@tonic-gate 					/* loaded again; e.g. will	*/
1657c478bd9Sstevel@tonic-gate 					/* return the correct inquiry	*/
1667c478bd9Sstevel@tonic-gate 					/* string			*/
1677c478bd9Sstevel@tonic-gate #define	ST_SOFT_ERROR_REPORTING 0x800	/* Do request or log sense on	*/
1687c478bd9Sstevel@tonic-gate 					/* close to report soft errors.	*/
1697c478bd9Sstevel@tonic-gate 					/* Currently only Exabyte and	*/
1707c478bd9Sstevel@tonic-gate 					/* DAT drives support this	*/
1717c478bd9Sstevel@tonic-gate 					/* feature.  			*/
1727c478bd9Sstevel@tonic-gate #define	ST_LONG_TIMEOUTS	0x1000	/* Device needs 5 times longer	*/
1737c478bd9Sstevel@tonic-gate 					/* timeouts for normal		*/
1747c478bd9Sstevel@tonic-gate 					/* operation			*/
1757c478bd9Sstevel@tonic-gate #define	ST_BUFFERED_WRITES	0x4000	/* The data is buffered in the	*/
1767c478bd9Sstevel@tonic-gate 					/* driver and pre-acked to the	*/
1777c478bd9Sstevel@tonic-gate 					/* application 			*/
1787c478bd9Sstevel@tonic-gate #define	ST_NO_RECSIZE_LIMIT	0x8000	/* For variable record size	*/
1797c478bd9Sstevel@tonic-gate 					/* devices only. If flag is	*/
1807c478bd9Sstevel@tonic-gate 					/* set, then don't limit	*/
1817c478bd9Sstevel@tonic-gate 					/* record size to 64k as in	*/
1827c478bd9Sstevel@tonic-gate 					/* pre-Solaris 2.4 releases.	*/
1837c478bd9Sstevel@tonic-gate 					/* The only limit on the	*/
1847c478bd9Sstevel@tonic-gate 					/* record size will be the max	*/
1857c478bd9Sstevel@tonic-gate 					/* record size the device can	*/
1867c478bd9Sstevel@tonic-gate 					/* handle or the max DMA	*/
1877c478bd9Sstevel@tonic-gate 					/* transfer size of the		*/
1887c478bd9Sstevel@tonic-gate 					/* machine, which ever is	*/
1897c478bd9Sstevel@tonic-gate 					/* smaller. Beware of		*/
1907c478bd9Sstevel@tonic-gate 					/* incompatabilities with	*/
1917c478bd9Sstevel@tonic-gate 					/* tapes of pre-Solaris 2.4	*/
1927c478bd9Sstevel@tonic-gate 					/* OS's written with large	*/
1937c478bd9Sstevel@tonic-gate 					/* (>64k) block sizes, as	*/
1947c478bd9Sstevel@tonic-gate 					/* their true block size is	*/
1957c478bd9Sstevel@tonic-gate 					/* a max of approx 64k		*/
1967c478bd9Sstevel@tonic-gate #define	ST_MODE_SEL_COMP	0x10000	/* use mode select of device	*/
1977c478bd9Sstevel@tonic-gate 					/* configuration page (0x10) to */
1987c478bd9Sstevel@tonic-gate 					/* enable/disable compression	*/
1997c478bd9Sstevel@tonic-gate 					/* instead of density codes for */
2007c478bd9Sstevel@tonic-gate 					/* the "c" and "u" devices	*/
2017c478bd9Sstevel@tonic-gate #define	ST_NO_RESERVE_RELEASE	0x20000	/* For devices which do not	*/
2027c478bd9Sstevel@tonic-gate 					/* support RESERVE/RELEASE SCSI	*/
2037c478bd9Sstevel@tonic-gate 					/* command. If this is enabled	*/
2047c478bd9Sstevel@tonic-gate 					/* then reserve/release would	*/
2057c478bd9Sstevel@tonic-gate 					/* not be used during open/	*/
2067c478bd9Sstevel@tonic-gate 					/* close for High Availability	*/
2077c478bd9Sstevel@tonic-gate #define	ST_READ_IGNORE_ILI	0x40000 /* This flag is only applicable */
2087c478bd9Sstevel@tonic-gate 					/* to variable block devices 	*/
2097c478bd9Sstevel@tonic-gate 					/* which support the SILI bit	*/
2107c478bd9Sstevel@tonic-gate 					/* option. It indicates that 	*/
2117c478bd9Sstevel@tonic-gate 					/* the SILI bit will be ignored */
2127c478bd9Sstevel@tonic-gate 					/* during reads  		*/
2137c478bd9Sstevel@tonic-gate #define	ST_READ_IGNORE_EOFS 	0x80000 /* When this flag is set two 	*/
2147c478bd9Sstevel@tonic-gate 					/* EOF marks do not indicate an */
2157c478bd9Sstevel@tonic-gate 					/* EOM. This option is only	*/
2167c478bd9Sstevel@tonic-gate 					/* supported on 1/2" reel tapes */
2177c478bd9Sstevel@tonic-gate #define	ST_SHORT_FILEMARKS	0x100000 /* This option applies only to */
2187c478bd9Sstevel@tonic-gate 					/* EXABYTE 8mm tape drives 	*/
2197c478bd9Sstevel@tonic-gate 					/* which support short 		*/
2207c478bd9Sstevel@tonic-gate 					/* filemarks. When this flag 	*/
2217c478bd9Sstevel@tonic-gate 					/* is set, short filemarks 	*/
2227c478bd9Sstevel@tonic-gate 					/* will be used for writing	*/
2237c478bd9Sstevel@tonic-gate 					/* filemarks. 			*/
2247c478bd9Sstevel@tonic-gate #define	ST_EJECT_ON_CHANGER_FAILURE 0x200000 /* When this flag is set   */
2257c478bd9Sstevel@tonic-gate 					/* and the tape is trapped in   */
2267c478bd9Sstevel@tonic-gate 					/* the medium changer, the tape */
2277c478bd9Sstevel@tonic-gate 					/* is automatically ejected	*/
2287c478bd9Sstevel@tonic-gate #define	ST_RETRY_ON_RECOVERED_DEFERRED_ERROR 0x400000
2297c478bd9Sstevel@tonic-gate 					/* This option applies only to  */
2307c478bd9Sstevel@tonic-gate 					/* IBM MAGSTAR 3590. If this    */
2317c478bd9Sstevel@tonic-gate 					/* flag is set, the st driver   */
2327c478bd9Sstevel@tonic-gate 					/* will retry the last cmd if   */
2337c478bd9Sstevel@tonic-gate 					/* the last error cause a check */
2347c478bd9Sstevel@tonic-gate 					/* condition with error code    */
2357c478bd9Sstevel@tonic-gate 					/* 0x71 and sense code  0x01 	*/
2367c478bd9Sstevel@tonic-gate #define	ST_KNOWS_MEDIA		0x800000 /* Use configured media type	*/
2377c478bd9Sstevel@tonic-gate 					/* detected to select correct   */
2387c478bd9Sstevel@tonic-gate 					/* density code.		*/
2395988135dSrralphs #define	ST_WORMABLE		0x1000000
2405988135dSrralphs 					/* Drive is capable of doing	*/
2415988135dSrralphs 					/* Write Appends only at EOM	*/
2425988135dSrralphs 					/* if WORM media type is loaded */
2437c478bd9Sstevel@tonic-gate #define	ST_CLN_TYPE_1		0x10000000 /* When this flag is set,	*/
2447c478bd9Sstevel@tonic-gate 					/* the tape drive provides the	*/
2457c478bd9Sstevel@tonic-gate 					/* clean bit information in	*/
2467c478bd9Sstevel@tonic-gate 					/* byte 21, bitmask 0x08 of	*/
2477c478bd9Sstevel@tonic-gate 					/* Request Sense data		*/
2487c478bd9Sstevel@tonic-gate #define	ST_CLN_TYPE_2		0x20000000 /* When this flag is set,	*/
2497c478bd9Sstevel@tonic-gate 					/* the tape drive provides the	*/
2507c478bd9Sstevel@tonic-gate 					/* clean bit information in	*/
2517c478bd9Sstevel@tonic-gate 					/* byte 70, bitmask 0xc0 of	*/
2527c478bd9Sstevel@tonic-gate 					/* Request Sense data		*/
2537c478bd9Sstevel@tonic-gate #define	ST_CLN_TYPE_3		0x40000000 /* When this flag is set,	*/
2547c478bd9Sstevel@tonic-gate 					/* the tape drive provides the	*/
2557c478bd9Sstevel@tonic-gate 					/* clean bit information in	*/
2567c478bd9Sstevel@tonic-gate 					/* byte 18, bitmask 0x01 of	*/
2577c478bd9Sstevel@tonic-gate 					/* Request Sense data		*/
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate #define	ST_CLN_MASK	(ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3)
2607c478bd9Sstevel@tonic-gate #define	ST_VALID_OPTS	(ST_VARIABLE | ST_QIC | ST_REEL | ST_BSF | ST_BSR |\
2617c478bd9Sstevel@tonic-gate 	ST_LONG_ERASE | ST_AUTODEN_OVERRIDE | ST_NOBUF | ST_KNOWS_EOD |\
2627c478bd9Sstevel@tonic-gate 	ST_UNLOADABLE | ST_SOFT_ERROR_REPORTING | ST_LONG_TIMEOUTS |\
2637c478bd9Sstevel@tonic-gate 	ST_NO_RECSIZE_LIMIT | ST_MODE_SEL_COMP | ST_NO_RESERVE_RELEASE |\
2647c478bd9Sstevel@tonic-gate 	ST_READ_IGNORE_ILI | ST_READ_IGNORE_EOFS | ST_SHORT_FILEMARKS |\
2657c478bd9Sstevel@tonic-gate 	ST_EJECT_ON_CHANGER_FAILURE | ST_RETRY_ON_RECOVERED_DEFERRED_ERROR |\
2665988135dSrralphs 	ST_WORMABLE | ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3)
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate #define	NDENSITIES	MT_NDENSITIES
2697c478bd9Sstevel@tonic-gate #define	NSPEEDS		MT_NSPEEDS
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate /*
2727c478bd9Sstevel@tonic-gate  * defines for Log Sense Pages
2737c478bd9Sstevel@tonic-gate  */
2747c478bd9Sstevel@tonic-gate #define	SUPPORTED_LOG_PAGES_PAGE	0x00
2757c478bd9Sstevel@tonic-gate #define	TAPE_SEQUENTIAL_PAGE		0x0c
2767c478bd9Sstevel@tonic-gate #define	TAPE_ALERT_PAGE			0x2e
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate /*
2797c478bd9Sstevel@tonic-gate  * Log Page Control definitions
2807c478bd9Sstevel@tonic-gate  */
2817c478bd9Sstevel@tonic-gate #define	CURRENT_THRESHOLD_VALUES	0x00
2827c478bd9Sstevel@tonic-gate #define	CURRENT_CUMULATIVE_VALUES	0x40
2837c478bd9Sstevel@tonic-gate #define	DEFAULT_THRESHOLD_VALUES	0x80
2847c478bd9Sstevel@tonic-gate #define	DEFAULT_CUMULATIVE_VALUES	0xC0
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate /*
2877c478bd9Sstevel@tonic-gate  * Tape Alert Flag definitions
2887c478bd9Sstevel@tonic-gate  */
2895988135dSrralphs typedef enum {
2905988135dSrralphs 	TAF_READ_WARN			= 0x01,
2915988135dSrralphs 	TAF_WRITE_WARN			= 0x02,
2925988135dSrralphs 	TAF_HARD_ERR			= 0x03,
2935988135dSrralphs 	TAF_MEDIA_ERR			= 0x04,
2945988135dSrralphs 	TAF_READ_FAIL			= 0x05,
2955988135dSrralphs 	TAF_WRITE_FAIL			= 0x06,
2965988135dSrralphs 	TAF_MEDIA_LIFE			= 0x07,
2975988135dSrralphs 	TAF_MEDIA_NOT_DATA_GRADE	= 0x08,
2985988135dSrralphs 	TAF_WRITE_PROTECTED		= 0x09,
2995988135dSrralphs 	TAF_NO_MEDIA_REMOVE		= 0x0A,
3005988135dSrralphs 	TAF_CLEANING_MEDIA		= 0x0B,
3015988135dSrralphs 	TAF_UNSUPPERTED_FORMAT		= 0x0C,
3025988135dSrralphs 	TAF_RECOVERED_TAPE_BREAK	= 0x0D,
3035988135dSrralphs 	TAF_TAPE_BREAK_FAUL		= 0x0E,
3045988135dSrralphs 	TAF_CART_MEM_FAIL		= 0x0F,
3055988135dSrralphs 	TAF_FORCED_EJECT		= 0x10,
3065988135dSrralphs 	TAF_READ_ONLY_FORMAT		= 0x11,
3075988135dSrralphs 	TAF_TAPE_DIR_CORRUPT		= 0x12,
3085988135dSrralphs 	TAF_NEARING_MEDIA_LIFE		= 0x13,
3095988135dSrralphs 	TAF_CLEAN_NOW			= 0x14,
3105988135dSrralphs 	TAF_CLEAN_PERIODIC		= 0x15,
3115988135dSrralphs 	TAF_EXP_CLEAN_CART		= 0x16,
3125988135dSrralphs 	TAF_INVALID_CLEAN_MEDIA		= 0x17,
3135988135dSrralphs 	TAF_RETENSION_REQUEST		= 0x18,
3145988135dSrralphs 	TAF_DUAL_PORT_INTERFACE_ERR	= 0x19,
3155988135dSrralphs 	TAF_COOLING_FAN_FAIL		= 0x1A,
3165988135dSrralphs 	TAF_POWER_SUPPLY_FAIL		= 0x1B,
3175988135dSrralphs 	TAF_POWER_CONSUMPTION		= 0x1C,
3185988135dSrralphs 	TAF_DRIVE_MAINT_REQUEST		= 0x1D,
3195988135dSrralphs 	TAF_HARDWARE_A			= 0x1E,
3205988135dSrralphs 	TAF_HARDWARE_B			= 0x1F,
3215988135dSrralphs 	TAF_INTERFACE			= 0x20,
3225988135dSrralphs 	TAF_EJECT_MEDIA			= 0x21,
3235988135dSrralphs 	TAF_DOWNLOAD_FAIL		= 0x22,
3245988135dSrralphs 	TAF_DRIVE_HUMIDITY		= 0x23,
3255988135dSrralphs 	TAF_DRIVE_TEMP			= 0x24,
3265988135dSrralphs 	TAF_DRIVE_VOLTAGE		= 0x25,
3275988135dSrralphs 	TAF_PREDICTIVE_FAIL		= 0x26,
3285988135dSrralphs 	TAF_DIAG_REQUIRED		= 0x27,
3295988135dSrralphs 	TAF_LOADER_HDWR_A		= 0x28,
3305988135dSrralphs 	TAF_LOADER_STRAY_TAPE		= 0x29,
3315988135dSrralphs 	TAF_LOADER_HDWR_B		= 0x2A,
3325988135dSrralphs 	TAF_LOADER_DOOR			= 0x2B,
3335988135dSrralphs 	TAF_LOADER_HDWR_C		= 0x2C,
3345988135dSrralphs 	TAF_LOADER_MAGAZINE		= 0x2D,
3355988135dSrralphs 	TAF_LOADER_PREDICTIVE_FAIL	= 0x2E,
3365988135dSrralphs 	TAF_LOST_STATISTICS		= 0x32,
3375988135dSrralphs 	TAF_TAPE_DIR_CURRUPT_UNLOAD	= 0x33,
3385988135dSrralphs 	TAF_TAPE_SYS_WRT_FAIL		= 0x34,
3395988135dSrralphs 	TAF_TAPE_SYS_RD_FAIL		= 0x35,
3405988135dSrralphs 	TAF_NO_START_OF_DATA		= 0x36,
3415988135dSrralphs 	TAF_WORM_INTEGRITY		= 0x3B,
3425988135dSrralphs 	TAF_WORM_OVRWRT_ATTEMPT		= 0x3C
3435988135dSrralphs }tape_alert_flags;
3445988135dSrralphs 
3455988135dSrralphs /*
3465988135dSrralphs  * For ST_TYPE_STK9840 drives only. STK drive doesn't support retension
3475988135dSrralphs  * so they reuse TAF_RETENSION_REQUEST.
3485988135dSrralphs  */
3495988135dSrralphs #define	CLEAN_FOR_ERRORS		 0x18
3505988135dSrralphs 
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate #define	TAPE_ALERT_SUPPORT_UNKNOWN	0x00
3537c478bd9Sstevel@tonic-gate #define	TAPE_ALERT_NOT_SUPPORTED	0x01
3547c478bd9Sstevel@tonic-gate #define	TAPE_ALERT_SUPPORTED		0x02
3557c478bd9Sstevel@tonic-gate #define	TAPE_ALERT_STILL_DIRTY		0x04
3567c478bd9Sstevel@tonic-gate #define	TAPE_SEQUENTIAL_SUPPORTED	0x08
3577c478bd9Sstevel@tonic-gate #define	TAPE_PREVIOUSLY_DIRTY		0x10
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate #define	TAPE_ALERT_MAX_PARA		64
3607c478bd9Sstevel@tonic-gate #define	TAPE_SEQUENTIAL_PAGE_PARA	64	/* way more then really used */
3617c478bd9Sstevel@tonic-gate #define	SEQUENTIAL_NEED_CLN		0x0100
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate /*
3647c478bd9Sstevel@tonic-gate  * Parameters
3657c478bd9Sstevel@tonic-gate  */
3667c478bd9Sstevel@tonic-gate #define	ST_NAMESIZE	44	/* size of pretty string for vid/pid */
3677c478bd9Sstevel@tonic-gate #define	VIDLEN		8	/* size of vendor identifier length */
3687c478bd9Sstevel@tonic-gate #define	PIDLEN		16	/* size of product identifier length */
3697c478bd9Sstevel@tonic-gate #define	VIDPIDLEN	(VIDLEN + PIDLEN)
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate struct st_drivetype {
3737c478bd9Sstevel@tonic-gate 	char	name[ST_NAMESIZE];	/* Name, for debug */
3747c478bd9Sstevel@tonic-gate 	char	length;			/* Length of vendor id */
3757c478bd9Sstevel@tonic-gate 	char	vid[VIDPIDLEN];		/* Vendor id and model (product) id */
3767c478bd9Sstevel@tonic-gate 	char	type;			/* Drive type for driver */
3777c478bd9Sstevel@tonic-gate 	int	bsize;			/* Block size */
3787c478bd9Sstevel@tonic-gate 	int	options;		/* Drive options */
3797c478bd9Sstevel@tonic-gate 	int	max_rretries;		/* Max read retries */
3807c478bd9Sstevel@tonic-gate 	int	max_wretries;		/* Max write retries */
3817c478bd9Sstevel@tonic-gate 	uchar_t	densities[NDENSITIES];	/* density codes, low->hi */
3827c478bd9Sstevel@tonic-gate 	uchar_t	default_density;	/* default density for this drive */
3837c478bd9Sstevel@tonic-gate 	uchar_t	mediatype[NDENSITIES];	/* was speed. mediatype for density. */
3847c478bd9Sstevel@tonic-gate 	ushort_t non_motion_timeout;	/* Inquiry type commands */
3857c478bd9Sstevel@tonic-gate 	ushort_t io_timeout;		/* I/O timeout in seconds */
3867c478bd9Sstevel@tonic-gate 	ushort_t rewind_timeout;	/* rewind timeout in seconds */
3877c478bd9Sstevel@tonic-gate 	ushort_t space_timeout;		/* space cmd timeout in seconds */
3887c478bd9Sstevel@tonic-gate 	ushort_t load_timeout;		/* load tape time in seconds */
3897c478bd9Sstevel@tonic-gate 	ushort_t unload_timeout;	/* unload tape time in seconds */
3907c478bd9Sstevel@tonic-gate 	ushort_t erase_timeout;		/* erase timeout. seconds */
3917c478bd9Sstevel@tonic-gate };
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate #define	MINUTES(val)	((val) * 60)
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate struct comp_mode_page {
3967c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
3977c478bd9Sstevel@tonic-gate 	uchar_t	:		6,
3987c478bd9Sstevel@tonic-gate 		dcc:		1,	/* Data Compression Capable */
3997c478bd9Sstevel@tonic-gate 		dce:		1;	/* Data Compression Enable */
4007c478bd9Sstevel@tonic-gate 	uchar_t	:		5,
4017c478bd9Sstevel@tonic-gate 		red:		2,	/* Report Exceptions on Decompress */
4027c478bd9Sstevel@tonic-gate 		dde:		1;	/* Data Decompression Enabled */
4037c478bd9Sstevel@tonic-gate 	uchar_t	comp_alg_msb;		/* Compression Algorithm */
4047c478bd9Sstevel@tonic-gate 	uchar_t comp_alg_high;
4057c478bd9Sstevel@tonic-gate 	uchar_t	comp_alg_low;
4067c478bd9Sstevel@tonic-gate 	uchar_t	comp_alg_lsb;
4077c478bd9Sstevel@tonic-gate 	uchar_t	decomp_alg_msb;		/* Decompression Algorithm */
4087c478bd9Sstevel@tonic-gate 	uchar_t decomp_alg_high;
4097c478bd9Sstevel@tonic-gate 	uchar_t	decomp_alg_low;
4107c478bd9Sstevel@tonic-gate 	uchar_t	decomp_alg_lsb;
4117c478bd9Sstevel@tonic-gate 	uchar_t	reservered0;
4127c478bd9Sstevel@tonic-gate 	uchar_t	reservered1;
4137c478bd9Sstevel@tonic-gate 	uchar_t	reservered2;
4147c478bd9Sstevel@tonic-gate 	uchar_t	reservered3;
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
4177c478bd9Sstevel@tonic-gate 	uchar_t	dce:		1,	/* Data Compression Enable */
4187c478bd9Sstevel@tonic-gate 		dcc:		1,	/* Data Compression Capable */
4197c478bd9Sstevel@tonic-gate 		:		6;
4207c478bd9Sstevel@tonic-gate 	uchar_t	dde:		1,	/* Data Decompression Enabled */
4217c478bd9Sstevel@tonic-gate 		red:		2,	/* Report Exceptions on Decompress */
4227c478bd9Sstevel@tonic-gate 		:		5;
4237c478bd9Sstevel@tonic-gate 	uchar_t	comp_alg_msb;		/* Compression Algorithm */
4247c478bd9Sstevel@tonic-gate 	uchar_t comp_alg_high;
4257c478bd9Sstevel@tonic-gate 	uchar_t	comp_alg_low;
4267c478bd9Sstevel@tonic-gate 	uchar_t	comp_alg_lsb;
4277c478bd9Sstevel@tonic-gate 	uchar_t	decomp_alg_msb;		/* Decompression Algorithm */
4287c478bd9Sstevel@tonic-gate 	uchar_t decomp_alg_high;
4297c478bd9Sstevel@tonic-gate 	uchar_t	decomp_alg_low;
4307c478bd9Sstevel@tonic-gate 	uchar_t	decomp_alg_lsb;
4317c478bd9Sstevel@tonic-gate 	uchar_t	reservered0;
4327c478bd9Sstevel@tonic-gate 	uchar_t	reservered1;
4337c478bd9Sstevel@tonic-gate 	uchar_t	reservered2;
4347c478bd9Sstevel@tonic-gate 	uchar_t	reservered3;
4357c478bd9Sstevel@tonic-gate #endif
4367c478bd9Sstevel@tonic-gate };
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate struct dev_mode_page {
4397c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
4407c478bd9Sstevel@tonic-gate 	uchar_t	act_format:	5,	/* active format */
4417c478bd9Sstevel@tonic-gate 		caf:		1,	/* Change Active Format */
4425988135dSrralphs 		cap:		1,	/* Change Active Partition OBSOLETE */
4437c478bd9Sstevel@tonic-gate 		:		1;
4447c478bd9Sstevel@tonic-gate 	uchar_t	act_partition;		/* active partition */
4457c478bd9Sstevel@tonic-gate 	uchar_t	wrt_buf_full_ratio;	/* write buffer full ratio */
4467c478bd9Sstevel@tonic-gate 	uchar_t	rd_buf_full_ratio;	/* read buffer full ratio */
4477c478bd9Sstevel@tonic-gate 	uchar_t	wrt_delay_time_msb;	/* write delay time MSB */
4487c478bd9Sstevel@tonic-gate 	uchar_t	wrt_delay_time_lsb;	/* write delay time LSB */
4497c478bd9Sstevel@tonic-gate 	uchar_t	rew:		1,	/* Report Early Warning */
4505988135dSrralphs 		robo:		1,	/* Reverse Object Buffer Order */
4517c478bd9Sstevel@tonic-gate 		socf:		2,	/* Stop On Consecutive Filemarks */
4527c478bd9Sstevel@tonic-gate 		avc:		1,	/* Automatic Velocity Control */
4535988135dSrralphs 		rsmk:		1,	/* Report SetMarKs OBSOLETE */
4545988135dSrralphs 		lois:		1,	/* Logical Object Identifiers Support */
4555988135dSrralphs 		obr:		1;	/* Object Buffer Recovery */
4565988135dSrralphs 	uchar_t	gap_size;		/* OBSOLETE */
4575988135dSrralphs 	uchar_t	bam:		1,	/* Block Address Mode */
4585988135dSrralphs 		bmal:		1,	/* Block Address Mode Lock */
4595988135dSrralphs 		swp:		1,	/* Software Write Protection */
4607c478bd9Sstevel@tonic-gate 		sew:		1,	/* Sync data after Early Warning */
4617c478bd9Sstevel@tonic-gate 		eeg:		1,	/* Enable Early Waring */
4627c478bd9Sstevel@tonic-gate 		eod_defined:	3;
4637c478bd9Sstevel@tonic-gate 	uchar_t	buf_size_leot_msb;	/* Buffer size after early warning */
4647c478bd9Sstevel@tonic-gate 	uchar_t	buf_size_leot_mid;
4657c478bd9Sstevel@tonic-gate 	uchar_t	buf_size_leot_lsb;
4667c478bd9Sstevel@tonic-gate 	uchar_t	comp_alg;		/* Compression Algorithm (enable) */
4675988135dSrralphs 	uchar_t	prmwp:		1,	/* PeRManent Write Protect */
4685988135dSrralphs 		perswp:		1,	/* persistant write protection */
4695988135dSrralphs 		asocwp:		1,	/* associated write protect */
4705988135dSrralphs 		rew_on_rst:	2,	/* rewind on reset */
4715988135dSrralphs 		oir:		1,	/* Only If Reserved */
4725988135dSrralphs 		wtre:		2;	/* Worm Tamper Read Enable */
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
4757c478bd9Sstevel@tonic-gate 	uchar_t	:		1,
4765988135dSrralphs 		cap:		1,	/* Change Active Partition OBSOLETE */
4777c478bd9Sstevel@tonic-gate 		caf:		1,	/* Change Active Format */
4787c478bd9Sstevel@tonic-gate 		act_format:	5;	/* active format */
4797c478bd9Sstevel@tonic-gate 	uchar_t	act_partition;		/* active partition */
4807c478bd9Sstevel@tonic-gate 	uchar_t	wrt_buf_full_ratio;	/* write buffer full ratio */
4817c478bd9Sstevel@tonic-gate 	uchar_t	rd_buf_full_ratio;	/* read buffer full ratio */
4827c478bd9Sstevel@tonic-gate 	uchar_t	wrt_delay_time_msb;	/* write delay time MSB */
4837c478bd9Sstevel@tonic-gate 	uchar_t	wrt_delay_time_lsb;	/* write delay time LSB */
4845988135dSrralphs 	uchar_t	obr:		1,	/* Object Buffer Recovery */
4855988135dSrralphs 		lois:		1,	/* Logical Object Identifiers Support */
4865988135dSrralphs 		rsmk:		1,	/* Report SetMarKs OBSOLETE */
4877c478bd9Sstevel@tonic-gate 		avc:		1,	/* Automatic Velocity Control */
4887c478bd9Sstevel@tonic-gate 		socf:		2,	/* Stop On Consecutive Filemarks */
4895988135dSrralphs 		robo:		1,	/* Reverse Object Buffer Order */
4907c478bd9Sstevel@tonic-gate 		rew:		1;	/* Report Early Warning */
4915988135dSrralphs 	uchar_t	gap_size;		/* OBSELETE */
4927c478bd9Sstevel@tonic-gate 	uchar_t	eod_defined:	3,
4937c478bd9Sstevel@tonic-gate 		eeg:		1,	/* Enable Early Waring */
4947c478bd9Sstevel@tonic-gate 		sew:		1,	/* Sync data after Early Warning */
4955988135dSrralphs 		swp:		1,	/* Software Write Protection */
4965988135dSrralphs 		bmal:		1,	/* Block Address Mode Lock */
4975988135dSrralphs 		bam:		1;	/* Block Address Mode */
4987c478bd9Sstevel@tonic-gate 	uchar_t	buf_size_leot_msb;	/* Buffer size after early warning */
4997c478bd9Sstevel@tonic-gate 	uchar_t	buf_size_leot_mid;
5007c478bd9Sstevel@tonic-gate 	uchar_t	buf_size_leot_lsb;
5017c478bd9Sstevel@tonic-gate 	uchar_t	comp_alg;		/* Compression Algorithm (enable) */
5025988135dSrralphs 	uchar_t	wtre:		2,	/* Worm Tamper Read Enable */
5035988135dSrralphs 		oir:		1,	/* Only If Reserved */
5045988135dSrralphs 		rew_on_rst:	2,	/* rewind on reset */
5055988135dSrralphs 		asocwp:		1,	/* associated write protect */
5065988135dSrralphs 		perswp:		1,	/* persistant write protection */
5075988135dSrralphs 		prmwp:		1;	/* PeRManent Write Protect */
5087c478bd9Sstevel@tonic-gate #endif
5097c478bd9Sstevel@tonic-gate };
5107c478bd9Sstevel@tonic-gate 
511*af483cc8Sjianfei wang - Sun Microsystems - Beijing China struct sas_lun_mode {
512*af483cc8Sjianfei wang - Sun Microsystems - Beijing China #if defined(_BIT_FIELDS_HTOL)
513*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	uchar_t :		3,
514*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 		tran_layer_ret:	1,
515*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 		protocol_id:	4;
516*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	uchar_t reserved[5];
517*af483cc8Sjianfei wang - Sun Microsystems - Beijing China #elif defined(_BIT_FIELDS_LTOH)
518*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	uchar_t protocol_id:	4,
519*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 		tran_layer_ret:	1,
520*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 		:		3;
521*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	uchar_t reserved[5];
522*af483cc8Sjianfei wang - Sun Microsystems - Beijing China #endif
523*af483cc8Sjianfei wang - Sun Microsystems - Beijing China };
5247c478bd9Sstevel@tonic-gate typedef union {
5257c478bd9Sstevel@tonic-gate 	struct comp_mode_page	comp;
5267c478bd9Sstevel@tonic-gate 	struct dev_mode_page	dev;
527*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	struct sas_lun_mode	saslun;
5287c478bd9Sstevel@tonic-gate }modepage;
5297c478bd9Sstevel@tonic-gate 
5307c478bd9Sstevel@tonic-gate /*
5317c478bd9Sstevel@tonic-gate  *
5327c478bd9Sstevel@tonic-gate  * Parameter list for the MODE_SELECT and MODE_SENSE commands.
5337c478bd9Sstevel@tonic-gate  * The parameter list contains a header, followed by zero or more
5347c478bd9Sstevel@tonic-gate  * block descriptors, followed by vendor unique parameters, if any.
5357c478bd9Sstevel@tonic-gate  *
5367c478bd9Sstevel@tonic-gate  */
5377c478bd9Sstevel@tonic-gate #define	MSIZE	0x0c		/* Size without additional pages */
5387c478bd9Sstevel@tonic-gate struct seq_mode {
5397c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
5407c478bd9Sstevel@tonic-gate 	uchar_t	data_len;	/* sense data length, sense only */
5417c478bd9Sstevel@tonic-gate 	uchar_t	media_type;	/* medium type, sense only */
5427c478bd9Sstevel@tonic-gate 	uchar_t	speed	:4,	/* speed */
5437c478bd9Sstevel@tonic-gate 		bufm	:3,	/* buffered mode */
5447c478bd9Sstevel@tonic-gate 		wp	:1;	/* write protected, sense only */
5457c478bd9Sstevel@tonic-gate 	uchar_t	bd_len;		/* block length in bytes */
5467c478bd9Sstevel@tonic-gate 	uchar_t	density;	/* density code */
5477c478bd9Sstevel@tonic-gate 	uchar_t	high_nb;	/* number of logical blocks on the medium */
5487c478bd9Sstevel@tonic-gate 	uchar_t	mid_nb;		/* that are to be formatted with the density */
5497c478bd9Sstevel@tonic-gate 	uchar_t	low_nb;		/* code and block length in block descriptor */
5507c478bd9Sstevel@tonic-gate 	uchar_t	reserved;	/* reserved */
5517c478bd9Sstevel@tonic-gate 	uchar_t	high_bl;	/* block length */
5527c478bd9Sstevel@tonic-gate 	uchar_t	mid_bl;		/*   "      "   */
5537c478bd9Sstevel@tonic-gate 	uchar_t	low_bl;		/*   "      "   */
5547c478bd9Sstevel@tonic-gate 	uchar_t page_code:	6,
5557c478bd9Sstevel@tonic-gate 		:		1,
5567c478bd9Sstevel@tonic-gate 		ps:		1; /* Page Savable sense only */
5577c478bd9Sstevel@tonic-gate 	uchar_t	page_len;
5587c478bd9Sstevel@tonic-gate 	modepage page;
5597c478bd9Sstevel@tonic-gate 
5607c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
5617c478bd9Sstevel@tonic-gate 	uchar_t	data_len;	/* sense data length, sense only */
5627c478bd9Sstevel@tonic-gate 	uchar_t	media_type;	/* medium type, sense only */
5637c478bd9Sstevel@tonic-gate 	uchar_t	wp	:1,	/* write protected, sense only */
5647c478bd9Sstevel@tonic-gate 		bufm	:3,	/* buffered mode */
5657c478bd9Sstevel@tonic-gate 		speed	:4;	/* speed */
5667c478bd9Sstevel@tonic-gate 	uchar_t	bd_len;		/* block length in bytes */
5677c478bd9Sstevel@tonic-gate 	uchar_t	density;	/* density code */
5687c478bd9Sstevel@tonic-gate 	uchar_t	high_nb;	/* number of logical blocks on the medium */
5697c478bd9Sstevel@tonic-gate 	uchar_t	mid_nb;		/* that are to be formatted with the density */
5707c478bd9Sstevel@tonic-gate 	uchar_t	low_nb;		/* code and block length in block descriptor */
5717c478bd9Sstevel@tonic-gate 	uchar_t	reserved;	/* reserved */
5727c478bd9Sstevel@tonic-gate 	uchar_t	high_bl;	/* block length */
5737c478bd9Sstevel@tonic-gate 	uchar_t	mid_bl;		/*   "      "   */
5747c478bd9Sstevel@tonic-gate 	uchar_t	low_bl;		/*   "      "   */
5757c478bd9Sstevel@tonic-gate 	uchar_t	ps:		1, /* Page Savable sense only */
5767c478bd9Sstevel@tonic-gate 		:		1,
5777c478bd9Sstevel@tonic-gate 		page_code:	6;
5787c478bd9Sstevel@tonic-gate 	uchar_t	page_len;
5797c478bd9Sstevel@tonic-gate 	modepage page;
5807c478bd9Sstevel@tonic-gate #else
5817c478bd9Sstevel@tonic-gate #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
5827c478bd9Sstevel@tonic-gate #endif	/* _BIT_FIELDS_LTOH */
5837c478bd9Sstevel@tonic-gate };
5847c478bd9Sstevel@tonic-gate 
5859f931db8Syl /*
5869f931db8Syl  * One_command parameter data for REPORT SUPPORTED OPERATION CODES.
5879f931db8Syl  */
5889f931db8Syl struct one_com_des {
5899f931db8Syl #if defined(_BIT_FIELDS_LTOH)
5909f931db8Syl 	uchar_t reserved0;
5919f931db8Syl 	uchar_t support:	3,	/* support value */
5929f931db8Syl 		reserved1:	4,
5939f931db8Syl 		ctdp:		1;	/* cmd timeouts descriptor present */
5949f931db8Syl 	ushort_t cdb_size;		/* cdb size */
5959f931db8Syl 	uchar_t usage[CDB_GROUP4];	/* 16 bytes, the largest CDB group */
5969f931db8Syl #elif defined(_BIT_FIELDS_HTOL)
5979f931db8Syl 	uchar_t reserved0;
5989f931db8Syl 	uchar_t ctdp:		1,	/* cmd timeouts descriptor present */
5999f931db8Syl 		reserved1:	4,
6009f931db8Syl 		support:	3;	/* support value */
6019f931db8Syl 	ushort_t cdb_size;		/* cdb size */
6029f931db8Syl 	uchar_t usage[CDB_GROUP4];	/* 16 bytes, the largest CDB group */
6039f931db8Syl #else
6049f931db8Syl #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
6059f931db8Syl #endif /* _BIT_FIELDS_LTOH */
6069f931db8Syl };
6079f931db8Syl 
6089f931db8Syl /*
6099f931db8Syl  * Command timeouts descriptor
6109f931db8Syl  */
6119f931db8Syl struct com_timeout_des {
6129f931db8Syl 	ushort_t des_len;	/* descriptor length */
6139f931db8Syl 	uchar_t reserved;
6149f931db8Syl 	uchar_t com_spe;	/* command specific */
6159f931db8Syl 	uint_t nom_timeout;	/* nominal command processing timeout */
6169f931db8Syl 	uint_t rec_timeout;	/* recommended command timeout */
6179f931db8Syl };
6189f931db8Syl 
6199f931db8Syl /*
6209f931db8Syl  * Reporting options
6219f931db8Syl  */
6229f931db8Syl #define	ALL_COMMAND_DATA_FORMAT			0
6239f931db8Syl #define	ONE_COMMAND_NO_SERVICE_DATA_FORMAT	1
6249f931db8Syl #define	ONE_COMMAND_DATA_FORMAT			2
6259f931db8Syl 
6269f931db8Syl /*
6279f931db8Syl  * Support values in One_command parameter data
6289f931db8Syl  */
6299f931db8Syl #define	SUPPORT_VALUES_NOT_AVAILABLE		0
6309f931db8Syl #define	SUPPORT_VALUES_NOT_SUPPORT		1
6319f931db8Syl #define	SUPPORT_VALUES_SUPPORT_SCSI		3
6329f931db8Syl #define	SUPPORT_VALUES_SUPPORT_VENDOR		5
6339f931db8Syl 
6349f931db8Syl /*
6359f931db8Syl  * Parameter data for REPORT DENSITY SUPPORT command
6369f931db8Syl  */
6379f931db8Syl struct report_density_header {
6389f931db8Syl 	ushort_t ava_dens_len;		/* available density support length */
6399f931db8Syl 	uchar_t reserved0;
6409f931db8Syl 	uchar_t reserved1;
6419f931db8Syl };
6429f931db8Syl 
6439f931db8Syl struct report_density_desc {
6449f931db8Syl #if defined(_BIT_FIELDS_LTOH)
6459f931db8Syl 	uchar_t pri_den;		/* primary density code */
6469f931db8Syl 	uchar_t sec_den;		/* secondary density code */
6479f931db8Syl 	uchar_t dlv:1;			/* descriptor length valid */
6489f931db8Syl 	uchar_t reserved:4;
6499f931db8Syl 	uchar_t deflt:1;		/* is default density */
6509f931db8Syl 	uchar_t dup:1;			/* pri density has one descriptor */
6519f931db8Syl 	uchar_t wrtok:1;		/* support writing to media */
6529f931db8Syl 	uchar_t desc_len_hi;		/* descriptor length high */
6539f931db8Syl 	uchar_t desc_len_low;		/* descriptor length low */
6549f931db8Syl 	uchar_t bits_per_mm[3];		/* bits per mm */
6559f931db8Syl 	uchar_t media_width_hi;		/* media width high */
6569f931db8Syl 	uchar_t media_width_low;	/* media width low */
6579f931db8Syl 	ushort_t tracks;		/* tracks */
6589f931db8Syl 	uint_t capacity;		/* capacity */
6599f931db8Syl 	uchar_t ass_org[8];		/* assigning organization */
6609f931db8Syl 	uchar_t den_name[8];		/* density name */
6619f931db8Syl 	uchar_t description[20];	/* description */
6629f931db8Syl #elif defined(_BIT_FIELDS_HTOL)
6639f931db8Syl 	uchar_t pri_den;		/* primary density code */
6649f931db8Syl 	uchar_t sec_den;		/* secondary density code */
6659f931db8Syl 	uchar_t wrtok:1;		/* support writing to media */
6669f931db8Syl 	uchar_t dup:1;			/* pri density has one descriptor */
6679f931db8Syl 	uchar_t deflt:1;		/* is default density */
6689f931db8Syl 	uchar_t reserved:4;
6699f931db8Syl 	uchar_t dlv:1;			/* descriptor length valid */
6709f931db8Syl 	uchar_t desc_len_hi;		/* descriptor length high */
6719f931db8Syl 	uchar_t desc_len_low;		/* descriptor length low */
6729f931db8Syl 	uchar_t bits_per_mm[3];		/* bits per mm */
6739f931db8Syl 	uchar_t media_width_hi;		/* media width high */
6749f931db8Syl 	uchar_t media_width_low;	/* media width low */
6759f931db8Syl 	ushort_t tracks;		/* tracks */
6769f931db8Syl 	uint_t capacity;		/* capacity */
6779f931db8Syl 	uchar_t ass_org[8];		/* assigning organization */
6789f931db8Syl 	uchar_t den_name[8];		/* density name */
6799f931db8Syl 	uchar_t description[20];	/* description */
6809f931db8Syl #else
6819f931db8Syl #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
6829f931db8Syl #endif  /* _BIT_FIELDS_LTOH */
6839f931db8Syl };
6849f931db8Syl 
6857c478bd9Sstevel@tonic-gate /*
6867c478bd9Sstevel@tonic-gate  * Data returned from the READ BLOCK LIMITS command.
6877c478bd9Sstevel@tonic-gate  */
6887c478bd9Sstevel@tonic-gate 
6897c478bd9Sstevel@tonic-gate #define	RBLSIZE	(sizeof (struct read_blklim))
6907c478bd9Sstevel@tonic-gate struct read_blklim {
6917c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_HTOL)
6927c478bd9Sstevel@tonic-gate 	uchar_t	reserved:	3;	/* reserved */
6937c478bd9Sstevel@tonic-gate 	uchar_t granularity:	5;	/* Minimum Modularity */
6947c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_LTOH)
6957c478bd9Sstevel@tonic-gate 	uchar_t granularity:	5;	/* Minimum Modularity */
6967c478bd9Sstevel@tonic-gate 	uchar_t	reserved:	3;	/* reserved */
6977c478bd9Sstevel@tonic-gate #endif
6987c478bd9Sstevel@tonic-gate 	uchar_t	max_hi;			/* Maximum block length, high byte */
6997c478bd9Sstevel@tonic-gate 	uchar_t	max_mid;		/* Maximum block length, middle byte */
7007c478bd9Sstevel@tonic-gate 	uchar_t	max_lo;			/* Maximum block length, low byte */
7017c478bd9Sstevel@tonic-gate 	uchar_t	min_hi;			/* Minimum block length, high byte */
7027c478bd9Sstevel@tonic-gate 	uchar_t	min_lo;			/* Minimum block length, low byte */
7037c478bd9Sstevel@tonic-gate };
7047c478bd9Sstevel@tonic-gate 
705c6914c10Srralphs /*
706c6914c10Srralphs  * operation codes
707c6914c10Srralphs  */
708c6914c10Srralphs typedef enum {
709c6914c10Srralphs 	ST_OP_NIL,
710c6914c10Srralphs 	ST_OP_CTL,
711c6914c10Srralphs 	ST_OP_READ,
712c6914c10Srralphs 	ST_OP_WRITE,
713c6914c10Srralphs 	ST_OP_WEOF
714c6914c10Srralphs }optype;
715c6914c10Srralphs 
716c6914c10Srralphs /*
717c6914c10Srralphs  * eof/eot/eom codes.
718c6914c10Srralphs  */
719c6914c10Srralphs typedef enum {
720c6914c10Srralphs 	ST_NO_EOF,
721c6914c10Srralphs 	ST_EOF_PENDING,		/* filemark pending */
722c6914c10Srralphs 	ST_EOF,			/* at filemark */
723c6914c10Srralphs 	ST_EOT_PENDING,		/* logical eot pending */
724c6914c10Srralphs 	ST_EOT,			/* at logical eot */
725c6914c10Srralphs 	ST_EOM,			/* at physical eot */
726c6914c10Srralphs 	ST_WRITE_AFTER_EOM	/* flag for allowing writes after EOM */
727c6914c10Srralphs }pstatus;
728c6914c10Srralphs 
729c6914c10Srralphs typedef enum { invalid, legacy, logical } posmode;
730c6914c10Srralphs 
731c6914c10Srralphs typedef struct tapepos {
732c6914c10Srralphs 	uint64_t lgclblkno;
733c6914c10Srralphs 	int32_t fileno;
734c6914c10Srralphs 	int32_t blkno;
735c6914c10Srralphs 	int32_t partition;
736c6914c10Srralphs 	pstatus eof;			/* eof states */
737c6914c10Srralphs 	posmode	pmode;
738f218e94bSrralphs 	uint32_t: 32;
739c6914c10Srralphs }tapepos_t;
740c6914c10Srralphs 
741c6914c10Srralphs /* byte 1 of cdb for type of read position command */
742c6914c10Srralphs typedef enum {
743c6914c10Srralphs 	SHORT_POS	= 0,
744c6914c10Srralphs 	LONG_POS	= 6,
745c6914c10Srralphs 	EXT_POS		= 8,
746c6914c10Srralphs 	NO_POS		= 0xff	/* Drive doesn't support read position */
747c6914c10Srralphs } read_p_types;
748c6914c10Srralphs 
749c6914c10Srralphs 
750c6914c10Srralphs /*
751c6914c10Srralphs  * Data returned from the READ POSITION command.
752c6914c10Srralphs  */
753c6914c10Srralphs 
754c6914c10Srralphs typedef struct tape_position {
755c6914c10Srralphs #if defined(_BIT_FIELDS_HTOL)
756c6914c10Srralphs 	uchar_t begin_of_part:	1;
757c6914c10Srralphs 	uchar_t end_of_part:	1;
758c6914c10Srralphs 	uchar_t blk_cnt_unkwn:	1;
759c6914c10Srralphs 	uchar_t byte_cnt_unkwn:	1;
760c6914c10Srralphs 	uchar_t reserved0:	1;
761c6914c10Srralphs 	uchar_t blk_posi_unkwn:	1;
762c6914c10Srralphs 	uchar_t posi_err:	1;
763c6914c10Srralphs 	uchar_t reserved1:	1;
764c6914c10Srralphs #elif defined(_BIT_FIELDS_LTOH)
765c6914c10Srralphs 	uchar_t reserved1:	1;
766c6914c10Srralphs 	uchar_t posi_err:	1;
767c6914c10Srralphs 	uchar_t blk_posi_unkwn:	1;
768c6914c10Srralphs 	uchar_t reserved0:	1;
769c6914c10Srralphs 	uchar_t byte_cnt_unkwn:	1;
770c6914c10Srralphs 	uchar_t blk_cnt_unkwn:	1;
771c6914c10Srralphs 	uchar_t end_of_part:	1;
772c6914c10Srralphs 	uchar_t begin_of_part:	1;
773c6914c10Srralphs #endif
774c6914c10Srralphs 	uchar_t partition_number;
775c6914c10Srralphs 	uchar_t reserved2[2];
776c6914c10Srralphs 	uint32_t host_block;
777c6914c10Srralphs 	uint32_t media_block;
778c6914c10Srralphs 	uchar_t reserved3;
779c6914c10Srralphs 	uchar_t block_in_buff[3];
780c6914c10Srralphs 	uint32_t byte_in_buff;
781c6914c10Srralphs }tape_position_t;
782c6914c10Srralphs 
783c6914c10Srralphs 
784c6914c10Srralphs typedef struct tape_position_long {
785c6914c10Srralphs #if defined(_BIT_FIELDS_HTOL)
786c6914c10Srralphs 	uint32_t begin_of_part:	1;
787c6914c10Srralphs 	uint32_t end_of_part:	1;
788c6914c10Srralphs 	uint32_t reserved0:	2;
789c6914c10Srralphs 	uint32_t mrk_posi_unkwn:1;
790c6914c10Srralphs 	uint32_t blk_posi_unkwn:1;
791c6914c10Srralphs 	uint32_t reserved1:	2;
792c6914c10Srralphs #elif defined(_BIT_FIELDS_LTOH)
793c6914c10Srralphs 	uint32_t reserved1:	2;
794c6914c10Srralphs 	uint32_t blk_posi_unkwn:1;
795c6914c10Srralphs 	uint32_t mrk_posi_unkwn:1;
796c6914c10Srralphs 	uint32_t reserved0:	2;
797c6914c10Srralphs 	uint32_t end_of_part:   1;
798c6914c10Srralphs 	uint32_t begin_of_part: 1;
799c6914c10Srralphs #endif
800c6914c10Srralphs 	uint32_t reserved2:	24;
801c6914c10Srralphs 	uint32_t partition;
802c6914c10Srralphs 	uint64_t block_number;
803c6914c10Srralphs 	uint64_t file_number;
804c6914c10Srralphs 	uint64_t set_number;
805c6914c10Srralphs }tape_position_long_t;
806c6914c10Srralphs 
807c6914c10Srralphs typedef struct tape_position_ext {
808c6914c10Srralphs #if defined(_BIT_FIELDS_HTOL)
809f218e94bSrralphs 	uchar_t begin_of_part:	1;
810f218e94bSrralphs 	uchar_t end_of_part:	1;
811f218e94bSrralphs 	uchar_t blk_cnt_unkwn:	1;
812f218e94bSrralphs 	uchar_t byte_cnt_unkwn:	1;
813f218e94bSrralphs 	uchar_t mrk_posi_unkwn:	1;
814f218e94bSrralphs 	uchar_t blk_posi_unkwn:	1;
815f218e94bSrralphs 	uchar_t posi_err:	1;
816f218e94bSrralphs 	uchar_t reserved0:	1;
817f218e94bSrralphs 
818f218e94bSrralphs 	uchar_t partition;
819f218e94bSrralphs 	uint16_t parameter_len;
820c6914c10Srralphs /* start next word */
821c6914c10Srralphs 	uint32_t reserved1:	8;
822c6914c10Srralphs 	uint32_t blks_in_buf:	24;
823c6914c10Srralphs #elif defined(_BIT_FIELDS_LTOH)
824f218e94bSrralphs 	uchar_t reserved0:	1;
825f218e94bSrralphs 	uchar_t posi_err:	1;
826f218e94bSrralphs 	uchar_t blk_posi_unkwn:	1;
827f218e94bSrralphs 	uchar_t mrk_posi_unkwn:	1;
828f218e94bSrralphs 	uchar_t byte_cnt_unkwn:	1;
829f218e94bSrralphs 	uchar_t blk_cnt_unkwn:	1;
830f218e94bSrralphs 	uchar_t end_of_part:	1;
831f218e94bSrralphs 	uchar_t begin_of_part:	1;
832f218e94bSrralphs 
833f218e94bSrralphs 	uchar_t partition;
834f218e94bSrralphs 	uint16_t parameter_len;
835c6914c10Srralphs /* start next word */
836c6914c10Srralphs 	uint32_t blks_in_buf:	24;
837c6914c10Srralphs 	uint32_t reserved1:	8;
838c6914c10Srralphs #endif
839c6914c10Srralphs 	uint64_t host_block;
840c6914c10Srralphs 	uint64_t media_block;
841c6914c10Srralphs 	uint64_t byte_in_buf;
842c6914c10Srralphs }tape_position_ext_t;
843c6914c10Srralphs 
844c6914c10Srralphs typedef union {
845c6914c10Srralphs 	tape_position_t srt;
846c6914c10Srralphs 	tape_position_ext_t ext;
847c6914c10Srralphs 	tape_position_long_t lng;
848c6914c10Srralphs }read_pos_data_t;
849c6914c10Srralphs 
850f218e94bSrralphs typedef struct {
851f218e94bSrralphs 	unsigned char cmd;
852f218e94bSrralphs 	unsigned char
853f218e94bSrralphs 		requires_reserve:	1,	/* reserve must be done */
854f218e94bSrralphs 		retriable:		1,	/* can be retried */
855f218e94bSrralphs 		chg_tape_pos:		1,	/* position will change */
856f218e94bSrralphs 		chg_tape_data:		1,	/* data on media will change */
8579fa098b4Sbo zhou - Sun Microsystems - Beijing China 		explicit_cmd_set:	1,	/* explicit command set */
858f218e94bSrralphs 		/*
859f218e94bSrralphs 		 * 0 doesn't, 1 forward,
860f218e94bSrralphs 		 * 2 back, 3 either
861f218e94bSrralphs 		 */
862f218e94bSrralphs 		chg_tape_direction:	2;	/* direction of pos change */
863f218e94bSrralphs #define	DIR_NONE	0
864f218e94bSrralphs #define	DIR_FORW	1
865f218e94bSrralphs #define	DIR_REVC	2
866f218e94bSrralphs #define	DIR_EITH	3
867f218e94bSrralphs 	unsigned char
868f218e94bSrralphs 		/*
869f218e94bSrralphs 		 * 0 doesn't 1 read, 2 write
870f218e94bSrralphs 		 */
871f218e94bSrralphs 		transfers_data:		2,
872f218e94bSrralphs #define	TRAN_NONE	0
873f218e94bSrralphs #define	TRAN_READ	1
874f218e94bSrralphs #define	TRAN_WRTE	2
875f218e94bSrralphs 		recov_pos_type:		1,
876f218e94bSrralphs #define	POS_EXPECTED	0
877f218e94bSrralphs #define	POS_STARTING	1
878f218e94bSrralphs 		do_not_recover:		1;
879f218e94bSrralphs 	uchar_t reserve_byte;
880f218e94bSrralphs 	uint32_t reserve_mask;
881f218e94bSrralphs 	uint64_t (*get_cnt)(uchar_t *);
882f218e94bSrralphs 	uint64_t (*get_lba)(uchar_t *);
883f218e94bSrralphs }cmd_attribute;
884f218e94bSrralphs 
885f218e94bSrralphs typedef struct {
886f218e94bSrralphs 	buf_t *cmd_bp;
887f218e94bSrralphs 	size_t privatelen;
8880205780bSrralphs 	int str_retry_cnt;
8890205780bSrralphs 	int pkt_retry_cnt;
890f218e94bSrralphs }pkt_info;
891f218e94bSrralphs 
892f218e94bSrralphs typedef struct {
893f218e94bSrralphs 	buf_t *cmd_bp;
894f218e94bSrralphs 	size_t privatelen;
8950205780bSrralphs 	int str_retry_cnt;
8960205780bSrralphs 	int pkt_retry_cnt;
897f218e94bSrralphs 	tapepos_t pos;
898f218e94bSrralphs 	const cmd_attribute *cmd_attrib;
899f218e94bSrralphs }recov_info;
900f218e94bSrralphs 
901f3531714Scz #ifdef _KERNEL
902f3531714Scz 
90336945f79Smrj #ifdef	__x86
904f3531714Scz /* Data structure used in big block I/O on x86/x64 platform */
905f3531714Scz 
906f3531714Scz /*
907f3531714Scz  * alloc more than one contig_mem, so mutiple I/O can be
908f3531714Scz  * on-going simultaneously
909f3531714Scz  */
910f3531714Scz #define	ST_MAX_CONTIG_MEM_NUM	3
911f3531714Scz 
912f3531714Scz struct contig_mem {
913f3531714Scz 	struct contig_mem *cm_next;
914f3531714Scz 	size_t cm_len;
915f3531714Scz 	caddr_t cm_addr;
916f3531714Scz 	ddi_acc_handle_t cm_acc_hdl;
917f3531714Scz 	struct buf *cm_bp;
918f3531714Scz 	int cm_use_sbuf;
919f3531714Scz };
9204ebb14b2Sfrits 
921f3531714Scz #endif
922f3531714Scz 
923f3531714Scz #endif /* _KERNEL */
924f3531714Scz 
9255988135dSrralphs /*
926c6914c10Srralphs  * driver states..
9275988135dSrralphs  */
9285988135dSrralphs typedef enum {
929c6914c10Srralphs 	ST_STATE_CLOSED,
930c6914c10Srralphs 	ST_STATE_OFFLINE,
931c6914c10Srralphs 	ST_STATE_INITIALIZING,
932c6914c10Srralphs 	ST_STATE_OPENING,
933c6914c10Srralphs 	ST_STATE_OPEN_PENDING_IO,
934c6914c10Srralphs 	ST_STATE_APPEND_TESTING,
935c6914c10Srralphs 	ST_STATE_OPEN,
936c6914c10Srralphs 	ST_STATE_RESOURCE_WAIT,
937c6914c10Srralphs 	ST_STATE_CLOSING,
938c6914c10Srralphs 	ST_STATE_SENSING,
939c6914c10Srralphs 	ST_STATE_CLOSE_PENDING_OPEN
940c6914c10Srralphs }st_states;
941c6914c10Srralphs 
942c6914c10Srralphs typedef enum { RDWR, RDONLY, WORM, RDWORM, FAILED } writablity;
943*af483cc8Sjianfei wang - Sun Microsystems - Beijing China typedef enum {
944*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	TLR_NOT_KNOWN,
945*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	TLR_NOT_SUPPORTED,
946*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	TLR_SAS_ONE_DEVICE,
947*af483cc8Sjianfei wang - Sun Microsystems - Beijing China 	TLR_SAS_TWO_DEVICE
948*af483cc8Sjianfei wang - Sun Microsystems - Beijing China }st_tlr_state;
9495988135dSrralphs 
9505988135dSrralphs 
9517c478bd9Sstevel@tonic-gate /*
9527c478bd9Sstevel@tonic-gate  * Private info for scsi tapes. Pointed to by the un_private pointer
9537c478bd9Sstevel@tonic-gate  * of one of the SCSI_DEVICE chains.
9547c478bd9Sstevel@tonic-gate  */
9557c478bd9Sstevel@tonic-gate 
9567c478bd9Sstevel@tonic-gate struct scsi_tape {
9577c478bd9Sstevel@tonic-gate 	struct scsi_device *un_sd;	/* back pointer to SCSI_DEVICE */
9587c478bd9Sstevel@tonic-gate 	struct scsi_pkt *un_rqs;	/* ptr to request sense command */
9597c478bd9Sstevel@tonic-gate 	struct scsi_pkt *un_mkr_pkt;	/* ptr to marker packet */
9607c478bd9Sstevel@tonic-gate 	kcondvar_t un_sbuf_cv;		/* cv on ownership of special buf */
9617c478bd9Sstevel@tonic-gate 	kcondvar_t un_queue_cv;		/* cv on all queued commands */
9627c478bd9Sstevel@tonic-gate 	struct	buf *un_sbufp;		/* for use in special io */
9637c478bd9Sstevel@tonic-gate 	char	*un_srqbufp;		/* sense buffer for special io */
9647c478bd9Sstevel@tonic-gate 	kcondvar_t un_clscv;		/* closing cv */
9657c478bd9Sstevel@tonic-gate 	struct	buf *un_quef;		/* head of wait queue */
9667c478bd9Sstevel@tonic-gate 	struct	buf *un_quel;		/* tail of wait queue */
9677c478bd9Sstevel@tonic-gate 	struct	buf *un_runqf;		/* head of run queue */
9687c478bd9Sstevel@tonic-gate 	struct	buf *un_runql;		/* tail of run queue */
9697c478bd9Sstevel@tonic-gate 	struct seq_mode *un_mspl;	/* ptr to mode select info */
9707c478bd9Sstevel@tonic-gate 	struct st_drivetype *un_dp;	/* ptr to drive table entry */
9717c478bd9Sstevel@tonic-gate 	uint_t	un_dp_size;		/* size of un_dp alloc'ed */
9727c478bd9Sstevel@tonic-gate 	caddr_t	un_tmpbuf;		/* buf for append, autodens ops */
973c6914c10Srralphs 	tapepos_t un_pos;		/* Current tape position */
9747c478bd9Sstevel@tonic-gate 	int	un_oflags;		/* open flags */
975c6914c10Srralphs 	tapepos_t un_err_pos;		/* block in file where err occurred */
9767c478bd9Sstevel@tonic-gate 	uint_t	un_err_resid;		/* resid from last error */
9777c478bd9Sstevel@tonic-gate 	short	un_fmneeded;		/* filemarks to be written - HP only */
9787c478bd9Sstevel@tonic-gate 	dev_t	un_dev;			/* unix device */
9797c478bd9Sstevel@tonic-gate 	uchar_t	un_attached;		/* unit known && attached */
9807c478bd9Sstevel@tonic-gate 	int	un_pwr_mgmt;		/* power management state */
9817c478bd9Sstevel@tonic-gate 	uchar_t	un_density_known;	/* density is known */
9827c478bd9Sstevel@tonic-gate 	uchar_t	un_curdens;		/* index into density table */
9835988135dSrralphs 	optype	un_lastop;		/* last I/O was: read/write/ctl */
984c6914c10Srralphs 	st_states un_laststate;		/* last state */
985c6914c10Srralphs 	st_states un_state;		/* current state */
9867c478bd9Sstevel@tonic-gate 	uchar_t	un_status;		/* status from last sense */
9877c478bd9Sstevel@tonic-gate 	uchar_t	un_retry_ct;		/* retry count */
9885988135dSrralphs 	writablity un_read_only;	/* RDWR, RDONLY, WORM, RDWORM */
9897c478bd9Sstevel@tonic-gate 	uchar_t	un_test_append;		/* check writing at end of tape */
9907c478bd9Sstevel@tonic-gate 	uchar_t un_arq_enabled;		/* auto request sense enabled */
9917c478bd9Sstevel@tonic-gate 	uchar_t un_untagged_qing;	/* hba has untagged quing */
9927c478bd9Sstevel@tonic-gate 	uchar_t	un_allow_large_xfer;	/* allow >64k xfers if requested */
9937c478bd9Sstevel@tonic-gate 	uchar_t	un_sbuf_busy;		/* sbuf busy flag */
9947c478bd9Sstevel@tonic-gate 	uchar_t	un_ncmds;		/* number of commands outstanding */
9957c478bd9Sstevel@tonic-gate 	uchar_t	un_throttle;		/* curr. max number of cmds outst. */
9967c478bd9Sstevel@tonic-gate 	uchar_t	un_last_throttle;	/* saved max number of cmds outst. */
9977c478bd9Sstevel@tonic-gate 	uchar_t	un_max_throttle;	/* max poss. number cmds outstanding */
9987c478bd9Sstevel@tonic-gate 	uchar_t	un_persistence;		/* 1 = persistence on, 0 off */
9997c478bd9Sstevel@tonic-gate 	uchar_t	un_persist_errors;	/* 1 = persistenced flagged */
10007c478bd9Sstevel@tonic-gate 	uchar_t	un_flush_on_errors;	/* HBA will flush all I/O's on a */
10017c478bd9Sstevel@tonic-gate 					/* check condidtion or error */
10027c478bd9Sstevel@tonic-gate 	uint_t	un_kbytes_xferred;	/* bytes (in K) counter */
10037c478bd9Sstevel@tonic-gate 	uint_t	un_last_resid;		/* keep last resid, for PE */
10047c478bd9Sstevel@tonic-gate 	uint_t	un_last_count;		/* keep last count, for PE */
10057c478bd9Sstevel@tonic-gate 	struct 	kstat *un_stats;	/* for I/O statistics */
10067c478bd9Sstevel@tonic-gate 	struct buf *un_rqs_bp;		/* bp used in rqpkt */
10077c478bd9Sstevel@tonic-gate 	struct	buf *un_wf;		/* head of write queue */
10087c478bd9Sstevel@tonic-gate 	struct	buf *un_wl;		/* tail of write queue */
1009