xref: /titanic_50/usr/src/uts/common/sys/scsi/targets/stdef.h (revision 551bc2a66868b5cb5be6b70ab9f55515e77a39a9)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SCSI_TARGETS_STDEF_H
27 #define	_SYS_SCSI_TARGETS_STDEF_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/sunddi.h>
32 #include <sys/note.h>
33 #include <sys/condvar.h>
34 #include <sys/kstat.h>
35 #include <sys/int_limits.h>
36 #include <sys/scsi/scsi_types.h>
37 #include <sys/scsi/generic/sense.h>
38 #include <sys/mtio.h>
39 #include <sys/taskq.h>
40 #include <sys/taskq_impl.h>
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * Defines for SCSI tape drives.
48  */
49 
50 /*
51  * Maximum variable length record size for a single request
52  */
53 #define	ST_MAXRECSIZE_VARIABLE	65535
54 
55 /*
56  * If the requested record size exceeds ST_MAXRECSIZE_VARIABLE,
57  * then the following define is used.
58  */
59 #define	ST_MAXRECSIZE_VARIABLE_LIMIT	65534
60 
61 #define	ST_MAXRECSIZE_FIXED	(63<<10)	/* maximum fixed record size */
62 #define	INF 1000000000
63 
64 /*
65  * Supported tape device types plus default type for opening.
66  * Types 10 - 13, are special (ancient too) drives - *NOT SUPPORTED*
67  * Types 14 - 1f, are 1/4-inch cartridge drives.
68  * Types 20 - 28, are 1/2-inch cartridge or reel drives.
69  * Types 28+, are rdat (vcr) drives.
70  */
71 #define	ST_TYPE_INVALID		0x00
72 
73 #define	ST_TYPE_SYSGEN1	MT_ISSYSGEN11	/* Sysgen with QIC-11 only */
74 #define	ST_TYPE_SYSGEN	MT_ISSYSGEN	/* Sysgen with QIC-24 and QIC-11 */
75 
76 #define	ST_TYPE_DEFAULT	MT_ISDEFAULT	/* Generic 1/4" or undetermined  */
77 #define	ST_TYPE_EMULEX	MT_ISMT02	/* Emulex MT-02 */
78 #define	ST_TYPE_ARCHIVE	MT_ISVIPER1	/* Archive QIC-150 */
79 #define	ST_TYPE_WANGTEK	MT_ISWANGTEK1	/* Wangtek QIC-150 */
80 
81 #define	ST_TYPE_CDC	MT_ISCDC	/* CDC - (not tested) */
82 #define	ST_TYPE_FUJI	MT_ISFUJI	/* Fujitsu - (not tested) */
83 #define	ST_TYPE_KENNEDY	MT_ISKENNEDY	/* Kennedy */
84 #define	ST_TYPE_ANRITSU	MT_ISANRITSU	/* Anritsu */
85 #define	ST_TYPE_HP	MT_ISHP		/* HP */
86 #define	ST_TYPE_HIC	MT_ISCCS23	/* Generic 1/2" Cartridge */
87 #define	ST_TYPE_REEL	MT_ISCCS24	/* Generic 1/2" Reel Tape */
88 #define	ST_TYPE_DAT	MT_ISCCS28	/* Generic DAT Tape */
89 
90 #define	ST_TYPE_EXABYTE	MT_ISEXABYTE	/* Exabyte 8200 */
91 #define	ST_TYPE_EXB8500	MT_ISEXB8500	/* Exabyte 8500 */
92 #define	ST_TYPE_WANGTHS	MT_ISWANGTHS	/* Wangtek 6130HS */
93 #define	ST_TYPE_WANGDAT	MT_ISWANGDAT	/* WangDAT */
94 #define	ST_TYPE_PYTHON  MT_ISPYTHON	/* Archive Python DAT */
95 #define	ST_TYPE_STC3490 MT_ISSTC	/* IBM STC 3490 */
96 #define	ST_TYPE_TAND25G MT_ISTAND25G	/* TANDBERG 2.5G */
97 #define	ST_TYPE_DLT	MT_ISDLT	/* DLT */
98 #define	ST_TYPE_STK9840	MT_ISSTK9840	/* StorageTek 9840, 9940, 9840B */
99 #define	ST_TYPE_BMDLT1	MT_ISBMDLT1	/* Benchmark DTL1 */
100 #define	ST_TYPE_LTO	MT_LTO		/* sun: LTO's by HP, Seagate, IBM.. */
101 #define	ST_TYPE_AIT	MT_ISAIT	/* Sony AIT I, II, III and SAIT */
102 #define	ST_LAST_TYPE	ST_TYPE_AIT	/* Add new above type and change this */
103 
104 
105 /* Internal flags */
106 #define	ST_DYNAMIC		0x2000	/* Device name has been dynamically */
107 					/* alloc'ed from the st.conf entry, */
108 					/* instead of being used from the */
109 					/* st_drivetypes array. */
110 
111 /*
112  * Defines for supported drive options
113  *
114  * WARNING : THESE OPTIONS SHOULD NEVER BE CHANGED, AS OLDER CONFIGURATIONS
115  * 		WILL DEPEND ON THE FLAG VALUES REMAINING THE SAME
116  */
117 #define	ST_VARIABLE		0x001	/* Device supports variable	*/
118 					/* length record sizes		*/
119 #define	ST_QIC			0x002	/* QIC tape device 		*/
120 #define	ST_REEL			0x004	/* 1/2-inch reel tape device	*/
121 #define	ST_BSF			0x008	/* Device supports backspace	*/
122 					/* file as in mt(1) bsf : 	*/
123 					/* backspace over EOF marks.	*/
124 					/* Devices not supporting bsf 	*/
125 					/* will fail with ENOTTY upon	*/
126 					/* use of bsf			*/
127 #define	ST_BSR			0x010	/* Device supports backspace	*/
128 					/* record as in mt(1) bsr :	*/
129 					/* backspace over records. If	*/
130 					/* the device does not support 	*/
131 					/* bsr, the st driver emulates	*/
132 					/* the action by rewinding the	*/
133 					/* tape and using forward space	*/
134 					/* file (fsf) to the correct	*/
135 					/* file and then uses forward	*/
136 					/* space record (fsr) to the	*/
137 					/* correct  record		*/
138 #define	ST_LONG_ERASE		0x020	/* Device needs a longer time	*/
139 					/* than normal to erase		*/
140 #define	ST_AUTODEN_OVERRIDE	0x040	/* Auto-Density override flag	*/
141 					/* Device can figure out the	*/
142 					/* tape density automatically,	*/
143 					/* without issuing a		*/
144 					/* mode-select/mode-sense 	*/
145 #define	ST_NOBUF		0x080	/* Don't use buffered mode.	*/
146 					/* This disables the device's	*/
147 					/* ability for buffered	writes	*/
148 					/* I.e. The device acknowledges	*/
149 					/* write completion after the	*/
150 					/* data is written to the	*/
151 					/* device's buffer, but before	*/
152 					/* all the data is actually	*/
153 					/* written to tape		*/
154 #define	ST_RESERVED_BIT1	0x100	/* resreved bit 		*/
155 					/* parity while talking to it. 	*/
156 #define	ST_KNOWS_EOD		0x200	/* Device knows when EOD (End	*/
157 					/* of Data) has been reached.	*/
158 					/* If the device knows EOD, st	*/
159 					/* uses fast file skipping.	*/
160 					/* If it does not know EOD,	*/
161 					/* file skipping happens one	*/
162 					/* file at a time. 		*/
163 #define	ST_UNLOADABLE		0x400	/* Device will not complain if	*/
164 					/* the st driver is unloaded &	*/
165 					/* loaded again; e.g. will	*/
166 					/* return the correct inquiry	*/
167 					/* string			*/
168 #define	ST_SOFT_ERROR_REPORTING 0x800	/* Do request or log sense on	*/
169 					/* close to report soft errors.	*/
170 					/* Currently only Exabyte and	*/
171 					/* DAT drives support this	*/
172 					/* feature.  			*/
173 #define	ST_LONG_TIMEOUTS	0x1000	/* Device needs 5 times longer	*/
174 					/* timeouts for normal		*/
175 					/* operation			*/
176 #define	ST_BUFFERED_WRITES	0x4000	/* The data is buffered in the	*/
177 					/* driver and pre-acked to the	*/
178 					/* application 			*/
179 #define	ST_NO_RECSIZE_LIMIT	0x8000	/* For variable record size	*/
180 					/* devices only. If flag is	*/
181 					/* set, then don't limit	*/
182 					/* record size to 64k as in	*/
183 					/* pre-Solaris 2.4 releases.	*/
184 					/* The only limit on the	*/
185 					/* record size will be the max	*/
186 					/* record size the device can	*/
187 					/* handle or the max DMA	*/
188 					/* transfer size of the		*/
189 					/* machine, which ever is	*/
190 					/* smaller. Beware of		*/
191 					/* incompatabilities with	*/
192 					/* tapes of pre-Solaris 2.4	*/
193 					/* OS's written with large	*/
194 					/* (>64k) block sizes, as	*/
195 					/* their true block size is	*/
196 					/* a max of approx 64k		*/
197 #define	ST_MODE_SEL_COMP	0x10000	/* use mode select of device	*/
198 					/* configuration page (0x10) to */
199 					/* enable/disable compression	*/
200 					/* instead of density codes for */
201 					/* the "c" and "u" devices	*/
202 #define	ST_NO_RESERVE_RELEASE	0x20000	/* For devices which do not	*/
203 					/* support RESERVE/RELEASE SCSI	*/
204 					/* command. If this is enabled	*/
205 					/* then reserve/release would	*/
206 					/* not be used during open/	*/
207 					/* close for High Availability	*/
208 #define	ST_READ_IGNORE_ILI	0x40000 /* This flag is only applicable */
209 					/* to variable block devices 	*/
210 					/* which support the SILI bit	*/
211 					/* option. It indicates that 	*/
212 					/* the SILI bit will be ignored */
213 					/* during reads  		*/
214 #define	ST_READ_IGNORE_EOFS 	0x80000 /* When this flag is set two 	*/
215 					/* EOF marks do not indicate an */
216 					/* EOM. This option is only	*/
217 					/* supported on 1/2" reel tapes */
218 #define	ST_SHORT_FILEMARKS	0x100000 /* This option applies only to */
219 					/* EXABYTE 8mm tape drives 	*/
220 					/* which support short 		*/
221 					/* filemarks. When this flag 	*/
222 					/* is set, short filemarks 	*/
223 					/* will be used for writing	*/
224 					/* filemarks. 			*/
225 #define	ST_EJECT_ON_CHANGER_FAILURE 0x200000 /* When this flag is set   */
226 					/* and the tape is trapped in   */
227 					/* the medium changer, the tape */
228 					/* is automatically ejected	*/
229 #define	ST_RETRY_ON_RECOVERED_DEFERRED_ERROR 0x400000
230 					/* This option applies only to  */
231 					/* IBM MAGSTAR 3590. If this    */
232 					/* flag is set, the st driver   */
233 					/* will retry the last cmd if   */
234 					/* the last error cause a check */
235 					/* condition with error code    */
236 					/* 0x71 and sense code  0x01 	*/
237 #define	ST_KNOWS_MEDIA		0x800000 /* Use configured media type	*/
238 					/* detected to select correct   */
239 					/* density code.		*/
240 #define	ST_WORMABLE		0x1000000
241 					/* Drive is capable of doing	*/
242 					/* Write Appends only at EOM	*/
243 					/* if WORM media type is loaded */
244 #define	ST_CLN_TYPE_1		0x10000000 /* When this flag is set,	*/
245 					/* the tape drive provides the	*/
246 					/* clean bit information in	*/
247 					/* byte 21, bitmask 0x08 of	*/
248 					/* Request Sense data		*/
249 #define	ST_CLN_TYPE_2		0x20000000 /* When this flag is set,	*/
250 					/* the tape drive provides the	*/
251 					/* clean bit information in	*/
252 					/* byte 70, bitmask 0xc0 of	*/
253 					/* Request Sense data		*/
254 #define	ST_CLN_TYPE_3		0x40000000 /* When this flag is set,	*/
255 					/* the tape drive provides the	*/
256 					/* clean bit information in	*/
257 					/* byte 18, bitmask 0x01 of	*/
258 					/* Request Sense data		*/
259 
260 #define	ST_CLN_MASK	(ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3)
261 #define	ST_VALID_OPTS	(ST_VARIABLE | ST_QIC | ST_REEL | ST_BSF | ST_BSR |\
262 	ST_LONG_ERASE | ST_AUTODEN_OVERRIDE | ST_NOBUF | ST_KNOWS_EOD |\
263 	ST_UNLOADABLE | ST_SOFT_ERROR_REPORTING | ST_LONG_TIMEOUTS |\
264 	ST_NO_RECSIZE_LIMIT | ST_MODE_SEL_COMP | ST_NO_RESERVE_RELEASE |\
265 	ST_READ_IGNORE_ILI | ST_READ_IGNORE_EOFS | ST_SHORT_FILEMARKS |\
266 	ST_EJECT_ON_CHANGER_FAILURE | ST_RETRY_ON_RECOVERED_DEFERRED_ERROR |\
267 	ST_WORMABLE | ST_CLN_TYPE_1 | ST_CLN_TYPE_2 | ST_CLN_TYPE_3)
268 
269 #define	NDENSITIES	MT_NDENSITIES
270 #define	NSPEEDS		MT_NSPEEDS
271 
272 /*
273  * defines for Log Sense Pages
274  */
275 #define	SUPPORTED_LOG_PAGES_PAGE	0x00
276 #define	TAPE_SEQUENTIAL_PAGE		0x0c
277 #define	TAPE_ALERT_PAGE			0x2e
278 
279 /*
280  * Log Page Control definitions
281  */
282 #define	CURRENT_THRESHOLD_VALUES	0x00
283 #define	CURRENT_CUMULATIVE_VALUES	0x40
284 #define	DEFAULT_THRESHOLD_VALUES	0x80
285 #define	DEFAULT_CUMULATIVE_VALUES	0xC0
286 
287 /*
288  * Tape Alert Flag definitions
289  */
290 typedef enum {
291 	TAF_READ_WARN			= 0x01,
292 	TAF_WRITE_WARN			= 0x02,
293 	TAF_HARD_ERR			= 0x03,
294 	TAF_MEDIA_ERR			= 0x04,
295 	TAF_READ_FAIL			= 0x05,
296 	TAF_WRITE_FAIL			= 0x06,
297 	TAF_MEDIA_LIFE			= 0x07,
298 	TAF_MEDIA_NOT_DATA_GRADE	= 0x08,
299 	TAF_WRITE_PROTECTED		= 0x09,
300 	TAF_NO_MEDIA_REMOVE		= 0x0A,
301 	TAF_CLEANING_MEDIA		= 0x0B,
302 	TAF_UNSUPPERTED_FORMAT		= 0x0C,
303 	TAF_RECOVERED_TAPE_BREAK	= 0x0D,
304 	TAF_TAPE_BREAK_FAUL		= 0x0E,
305 	TAF_CART_MEM_FAIL		= 0x0F,
306 	TAF_FORCED_EJECT		= 0x10,
307 	TAF_READ_ONLY_FORMAT		= 0x11,
308 	TAF_TAPE_DIR_CORRUPT		= 0x12,
309 	TAF_NEARING_MEDIA_LIFE		= 0x13,
310 	TAF_CLEAN_NOW			= 0x14,
311 	TAF_CLEAN_PERIODIC		= 0x15,
312 	TAF_EXP_CLEAN_CART		= 0x16,
313 	TAF_INVALID_CLEAN_MEDIA		= 0x17,
314 	TAF_RETENSION_REQUEST		= 0x18,
315 	TAF_DUAL_PORT_INTERFACE_ERR	= 0x19,
316 	TAF_COOLING_FAN_FAIL		= 0x1A,
317 	TAF_POWER_SUPPLY_FAIL		= 0x1B,
318 	TAF_POWER_CONSUMPTION		= 0x1C,
319 	TAF_DRIVE_MAINT_REQUEST		= 0x1D,
320 	TAF_HARDWARE_A			= 0x1E,
321 	TAF_HARDWARE_B			= 0x1F,
322 	TAF_INTERFACE			= 0x20,
323 	TAF_EJECT_MEDIA			= 0x21,
324 	TAF_DOWNLOAD_FAIL		= 0x22,
325 	TAF_DRIVE_HUMIDITY		= 0x23,
326 	TAF_DRIVE_TEMP			= 0x24,
327 	TAF_DRIVE_VOLTAGE		= 0x25,
328 	TAF_PREDICTIVE_FAIL		= 0x26,
329 	TAF_DIAG_REQUIRED		= 0x27,
330 	TAF_LOADER_HDWR_A		= 0x28,
331 	TAF_LOADER_STRAY_TAPE		= 0x29,
332 	TAF_LOADER_HDWR_B		= 0x2A,
333 	TAF_LOADER_DOOR			= 0x2B,
334 	TAF_LOADER_HDWR_C		= 0x2C,
335 	TAF_LOADER_MAGAZINE		= 0x2D,
336 	TAF_LOADER_PREDICTIVE_FAIL	= 0x2E,
337 	TAF_LOST_STATISTICS		= 0x32,
338 	TAF_TAPE_DIR_CURRUPT_UNLOAD	= 0x33,
339 	TAF_TAPE_SYS_WRT_FAIL		= 0x34,
340 	TAF_TAPE_SYS_RD_FAIL		= 0x35,
341 	TAF_NO_START_OF_DATA		= 0x36,
342 	TAF_WORM_INTEGRITY		= 0x3B,
343 	TAF_WORM_OVRWRT_ATTEMPT		= 0x3C
344 }tape_alert_flags;
345 
346 /*
347  * For ST_TYPE_STK9840 drives only. STK drive doesn't support retension
348  * so they reuse TAF_RETENSION_REQUEST.
349  */
350 #define	CLEAN_FOR_ERRORS		 0x18
351 
352 
353 #define	TAPE_ALERT_SUPPORT_UNKNOWN	0x00
354 #define	TAPE_ALERT_NOT_SUPPORTED	0x01
355 #define	TAPE_ALERT_SUPPORTED		0x02
356 #define	TAPE_ALERT_STILL_DIRTY		0x04
357 #define	TAPE_SEQUENTIAL_SUPPORTED	0x08
358 #define	TAPE_PREVIOUSLY_DIRTY		0x10
359 
360 #define	TAPE_ALERT_MAX_PARA		64
361 #define	TAPE_SEQUENTIAL_PAGE_PARA	64	/* way more then really used */
362 #define	SEQUENTIAL_NEED_CLN		0x0100
363 
364 /*
365  * Parameters
366  */
367 #define	ST_NAMESIZE	44	/* size of pretty string for vid/pid */
368 #define	VIDLEN		8	/* size of vendor identifier length */
369 #define	PIDLEN		16	/* size of product identifier length */
370 #define	VIDPIDLEN	(VIDLEN + PIDLEN)
371 
372 
373 struct st_drivetype {
374 	char	name[ST_NAMESIZE];	/* Name, for debug */
375 	char	length;			/* Length of vendor id */
376 	char	vid[VIDPIDLEN];		/* Vendor id and model (product) id */
377 	char	type;			/* Drive type for driver */
378 	int	bsize;			/* Block size */
379 	int	options;		/* Drive options */
380 	int	max_rretries;		/* Max read retries */
381 	int	max_wretries;		/* Max write retries */
382 	uchar_t	densities[NDENSITIES];	/* density codes, low->hi */
383 	uchar_t	default_density;	/* default density for this drive */
384 	uchar_t	mediatype[NDENSITIES];	/* was speed. mediatype for density. */
385 	ushort_t non_motion_timeout;	/* Inquiry type commands */
386 	ushort_t io_timeout;		/* I/O timeout in seconds */
387 	ushort_t rewind_timeout;	/* rewind timeout in seconds */
388 	ushort_t space_timeout;		/* space cmd timeout in seconds */
389 	ushort_t load_timeout;		/* load tape time in seconds */
390 	ushort_t unload_timeout;	/* unload tape time in seconds */
391 	ushort_t erase_timeout;		/* erase timeout. seconds */
392 };
393 
394 #define	MINUTES(val)	((val) * 60)
395 
396 struct comp_mode_page {
397 #if defined(_BIT_FIELDS_LTOH)
398 	uchar_t	:		6,
399 		dcc:		1,	/* Data Compression Capable */
400 		dce:		1;	/* Data Compression Enable */
401 	uchar_t	:		5,
402 		red:		2,	/* Report Exceptions on Decompress */
403 		dde:		1;	/* Data Decompression Enabled */
404 	uchar_t	comp_alg_msb;		/* Compression Algorithm */
405 	uchar_t comp_alg_high;
406 	uchar_t	comp_alg_low;
407 	uchar_t	comp_alg_lsb;
408 	uchar_t	decomp_alg_msb;		/* Decompression Algorithm */
409 	uchar_t decomp_alg_high;
410 	uchar_t	decomp_alg_low;
411 	uchar_t	decomp_alg_lsb;
412 	uchar_t	reservered0;
413 	uchar_t	reservered1;
414 	uchar_t	reservered2;
415 	uchar_t	reservered3;
416 
417 #elif defined(_BIT_FIELDS_HTOL)
418 	uchar_t	dce:		1,	/* Data Compression Enable */
419 		dcc:		1,	/* Data Compression Capable */
420 		:		6;
421 	uchar_t	dde:		1,	/* Data Decompression Enabled */
422 		red:		2,	/* Report Exceptions on Decompress */
423 		:		5;
424 	uchar_t	comp_alg_msb;		/* Compression Algorithm */
425 	uchar_t comp_alg_high;
426 	uchar_t	comp_alg_low;
427 	uchar_t	comp_alg_lsb;
428 	uchar_t	decomp_alg_msb;		/* Decompression Algorithm */
429 	uchar_t decomp_alg_high;
430 	uchar_t	decomp_alg_low;
431 	uchar_t	decomp_alg_lsb;
432 	uchar_t	reservered0;
433 	uchar_t	reservered1;
434 	uchar_t	reservered2;
435 	uchar_t	reservered3;
436 #endif
437 };
438 
439 struct dev_mode_page {
440 #if defined(_BIT_FIELDS_LTOH)
441 	uchar_t	act_format:	5,	/* active format */
442 		caf:		1,	/* Change Active Format */
443 		cap:		1,	/* Change Active Partition OBSOLETE */
444 		:		1;
445 	uchar_t	act_partition;		/* active partition */
446 	uchar_t	wrt_buf_full_ratio;	/* write buffer full ratio */
447 	uchar_t	rd_buf_full_ratio;	/* read buffer full ratio */
448 	uchar_t	wrt_delay_time_msb;	/* write delay time MSB */
449 	uchar_t	wrt_delay_time_lsb;	/* write delay time LSB */
450 	uchar_t	rew:		1,	/* Report Early Warning */
451 		robo:		1,	/* Reverse Object Buffer Order */
452 		socf:		2,	/* Stop On Consecutive Filemarks */
453 		avc:		1,	/* Automatic Velocity Control */
454 		rsmk:		1,	/* Report SetMarKs OBSOLETE */
455 		lois:		1,	/* Logical Object Identifiers Support */
456 		obr:		1;	/* Object Buffer Recovery */
457 	uchar_t	gap_size;		/* OBSOLETE */
458 	uchar_t	bam:		1,	/* Block Address Mode */
459 		bmal:		1,	/* Block Address Mode Lock */
460 		swp:		1,	/* Software Write Protection */
461 		sew:		1,	/* Sync data after Early Warning */
462 		eeg:		1,	/* Enable Early Waring */
463 		eod_defined:	3;
464 	uchar_t	buf_size_leot_msb;	/* Buffer size after early warning */
465 	uchar_t	buf_size_leot_mid;
466 	uchar_t	buf_size_leot_lsb;
467 	uchar_t	comp_alg;		/* Compression Algorithm (enable) */
468 	uchar_t	prmwp:		1,	/* PeRManent Write Protect */
469 		perswp:		1,	/* persistant write protection */
470 		asocwp:		1,	/* associated write protect */
471 		rew_on_rst:	2,	/* rewind on reset */
472 		oir:		1,	/* Only If Reserved */
473 		wtre:		2;	/* Worm Tamper Read Enable */
474 
475 #elif defined(_BIT_FIELDS_HTOL)
476 	uchar_t	:		1,
477 		cap:		1,	/* Change Active Partition OBSOLETE */
478 		caf:		1,	/* Change Active Format */
479 		act_format:	5;	/* active format */
480 	uchar_t	act_partition;		/* active partition */
481 	uchar_t	wrt_buf_full_ratio;	/* write buffer full ratio */
482 	uchar_t	rd_buf_full_ratio;	/* read buffer full ratio */
483 	uchar_t	wrt_delay_time_msb;	/* write delay time MSB */
484 	uchar_t	wrt_delay_time_lsb;	/* write delay time LSB */
485 	uchar_t	obr:		1,	/* Object Buffer Recovery */
486 		lois:		1,	/* Logical Object Identifiers Support */
487 		rsmk:		1,	/* Report SetMarKs OBSOLETE */
488 		avc:		1,	/* Automatic Velocity Control */
489 		socf:		2,	/* Stop On Consecutive Filemarks */
490 		robo:		1,	/* Reverse Object Buffer Order */
491 		rew:		1;	/* Report Early Warning */
492 	uchar_t	gap_size;		/* OBSELETE */
493 	uchar_t	eod_defined:	3,
494 		eeg:		1,	/* Enable Early Waring */
495 		sew:		1,	/* Sync data after Early Warning */
496 		swp:		1,	/* Software Write Protection */
497 		bmal:		1,	/* Block Address Mode Lock */
498 		bam:		1;	/* Block Address Mode */
499 	uchar_t	buf_size_leot_msb;	/* Buffer size after early warning */
500 	uchar_t	buf_size_leot_mid;
501 	uchar_t	buf_size_leot_lsb;
502 	uchar_t	comp_alg;		/* Compression Algorithm (enable) */
503 	uchar_t	wtre:		2,	/* Worm Tamper Read Enable */
504 		oir:		1,	/* Only If Reserved */
505 		rew_on_rst:	2,	/* rewind on reset */
506 		asocwp:		1,	/* associated write protect */
507 		perswp:		1,	/* persistant write protection */
508 		prmwp:		1;	/* PeRManent Write Protect */
509 #endif
510 };
511 
512 typedef union {
513 	struct comp_mode_page	comp;
514 	struct dev_mode_page	dev;
515 }modepage;
516 
517 /*
518  *
519  * Parameter list for the MODE_SELECT and MODE_SENSE commands.
520  * The parameter list contains a header, followed by zero or more
521  * block descriptors, followed by vendor unique parameters, if any.
522  *
523  */
524 #define	MSIZE	0x0c		/* Size without additional pages */
525 struct seq_mode {
526 #if defined(_BIT_FIELDS_LTOH)
527 	uchar_t	data_len;	/* sense data length, sense only */
528 	uchar_t	media_type;	/* medium type, sense only */
529 	uchar_t	speed	:4,	/* speed */
530 		bufm	:3,	/* buffered mode */
531 		wp	:1;	/* write protected, sense only */
532 	uchar_t	bd_len;		/* block length in bytes */
533 	uchar_t	density;	/* density code */
534 	uchar_t	high_nb;	/* number of logical blocks on the medium */
535 	uchar_t	mid_nb;		/* that are to be formatted with the density */
536 	uchar_t	low_nb;		/* code and block length in block descriptor */
537 	uchar_t	reserved;	/* reserved */
538 	uchar_t	high_bl;	/* block length */
539 	uchar_t	mid_bl;		/*   "      "   */
540 	uchar_t	low_bl;		/*   "      "   */
541 	uchar_t page_code:	6,
542 		:		1,
543 		ps:		1; /* Page Savable sense only */
544 	uchar_t	page_len;
545 	modepage page;
546 
547 #elif defined(_BIT_FIELDS_HTOL)
548 	uchar_t	data_len;	/* sense data length, sense only */
549 	uchar_t	media_type;	/* medium type, sense only */
550 	uchar_t	wp	:1,	/* write protected, sense only */
551 		bufm	:3,	/* buffered mode */
552 		speed	:4;	/* speed */
553 	uchar_t	bd_len;		/* block length in bytes */
554 	uchar_t	density;	/* density code */
555 	uchar_t	high_nb;	/* number of logical blocks on the medium */
556 	uchar_t	mid_nb;		/* that are to be formatted with the density */
557 	uchar_t	low_nb;		/* code and block length in block descriptor */
558 	uchar_t	reserved;	/* reserved */
559 	uchar_t	high_bl;	/* block length */
560 	uchar_t	mid_bl;		/*   "      "   */
561 	uchar_t	low_bl;		/*   "      "   */
562 	uchar_t	ps:		1, /* Page Savable sense only */
563 		:		1,
564 		page_code:	6;
565 	uchar_t	page_len;
566 	modepage page;
567 #else
568 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
569 #endif	/* _BIT_FIELDS_LTOH */
570 };
571 
572 /*
573  * One_command parameter data for REPORT SUPPORTED OPERATION CODES.
574  */
575 struct one_com_des {
576 #if defined(_BIT_FIELDS_LTOH)
577 	uchar_t reserved0;
578 	uchar_t support:	3,	/* support value */
579 		reserved1:	4,
580 		ctdp:		1;	/* cmd timeouts descriptor present */
581 	ushort_t cdb_size;		/* cdb size */
582 	uchar_t usage[CDB_GROUP4];	/* 16 bytes, the largest CDB group */
583 #elif defined(_BIT_FIELDS_HTOL)
584 	uchar_t reserved0;
585 	uchar_t ctdp:		1,	/* cmd timeouts descriptor present */
586 		reserved1:	4,
587 		support:	3;	/* support value */
588 	ushort_t cdb_size;		/* cdb size */
589 	uchar_t usage[CDB_GROUP4];	/* 16 bytes, the largest CDB group */
590 #else
591 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
592 #endif /* _BIT_FIELDS_LTOH */
593 };
594 
595 /*
596  * Command timeouts descriptor
597  */
598 struct com_timeout_des {
599 	ushort_t des_len;	/* descriptor length */
600 	uchar_t reserved;
601 	uchar_t com_spe;	/* command specific */
602 	uint_t nom_timeout;	/* nominal command processing timeout */
603 	uint_t rec_timeout;	/* recommended command timeout */
604 };
605 
606 /*
607  * Reporting options
608  */
609 #define	ALL_COMMAND_DATA_FORMAT			0
610 #define	ONE_COMMAND_NO_SERVICE_DATA_FORMAT	1
611 #define	ONE_COMMAND_DATA_FORMAT			2
612 
613 /*
614  * Support values in One_command parameter data
615  */
616 #define	SUPPORT_VALUES_NOT_AVAILABLE		0
617 #define	SUPPORT_VALUES_NOT_SUPPORT		1
618 #define	SUPPORT_VALUES_SUPPORT_SCSI		3
619 #define	SUPPORT_VALUES_SUPPORT_VENDOR		5
620 
621 /*
622  * Parameter data for REPORT DENSITY SUPPORT command
623  */
624 struct report_density_header {
625 	ushort_t ava_dens_len;		/* available density support length */
626 	uchar_t reserved0;
627 	uchar_t reserved1;
628 };
629 
630 struct report_density_desc {
631 #if defined(_BIT_FIELDS_LTOH)
632 	uchar_t pri_den;		/* primary density code */
633 	uchar_t sec_den;		/* secondary density code */
634 	uchar_t dlv:1;			/* descriptor length valid */
635 	uchar_t reserved:4;
636 	uchar_t deflt:1;		/* is default density */
637 	uchar_t dup:1;			/* pri density has one descriptor */
638 	uchar_t wrtok:1;		/* support writing to media */
639 	uchar_t desc_len_hi;		/* descriptor length high */
640 	uchar_t desc_len_low;		/* descriptor length low */
641 	uchar_t bits_per_mm[3];		/* bits per mm */
642 	uchar_t media_width_hi;		/* media width high */
643 	uchar_t media_width_low;	/* media width low */
644 	ushort_t tracks;		/* tracks */
645 	uint_t capacity;		/* capacity */
646 	uchar_t ass_org[8];		/* assigning organization */
647 	uchar_t den_name[8];		/* density name */
648 	uchar_t description[20];	/* description */
649 #elif defined(_BIT_FIELDS_HTOL)
650 	uchar_t pri_den;		/* primary density code */
651 	uchar_t sec_den;		/* secondary density code */
652 	uchar_t wrtok:1;		/* support writing to media */
653 	uchar_t dup:1;			/* pri density has one descriptor */
654 	uchar_t deflt:1;		/* is default density */
655 	uchar_t reserved:4;
656 	uchar_t dlv:1;			/* descriptor length valid */
657 	uchar_t desc_len_hi;		/* descriptor length high */
658 	uchar_t desc_len_low;		/* descriptor length low */
659 	uchar_t bits_per_mm[3];		/* bits per mm */
660 	uchar_t media_width_hi;		/* media width high */
661 	uchar_t media_width_low;	/* media width low */
662 	ushort_t tracks;		/* tracks */
663 	uint_t capacity;		/* capacity */
664 	uchar_t ass_org[8];		/* assigning organization */
665 	uchar_t den_name[8];		/* density name */
666 	uchar_t description[20];	/* description */
667 #else
668 #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
669 #endif  /* _BIT_FIELDS_LTOH */
670 };
671 
672 /*
673  * Data returned from the READ BLOCK LIMITS command.
674  */
675 
676 #define	RBLSIZE	(sizeof (struct read_blklim))
677 struct read_blklim {
678 #if defined(_BIT_FIELDS_HTOL)
679 	uchar_t	reserved:	3;	/* reserved */
680 	uchar_t granularity:	5;	/* Minimum Modularity */
681 #elif defined(_BIT_FIELDS_LTOH)
682 	uchar_t granularity:	5;	/* Minimum Modularity */
683 	uchar_t	reserved:	3;	/* reserved */
684 #endif
685 	uchar_t	max_hi;			/* Maximum block length, high byte */
686 	uchar_t	max_mid;		/* Maximum block length, middle byte */
687 	uchar_t	max_lo;			/* Maximum block length, low byte */
688 	uchar_t	min_hi;			/* Minimum block length, high byte */
689 	uchar_t	min_lo;			/* Minimum block length, low byte */
690 };
691 
692 /*
693  * operation codes
694  */
695 typedef enum {
696 	ST_OP_NIL,
697 	ST_OP_CTL,
698 	ST_OP_READ,
699 	ST_OP_WRITE,
700 	ST_OP_WEOF
701 }optype;
702 
703 /*
704  * eof/eot/eom codes.
705  */
706 typedef enum {
707 	ST_NO_EOF,
708 	ST_EOF_PENDING,		/* filemark pending */
709 	ST_EOF,			/* at filemark */
710 	ST_EOT_PENDING,		/* logical eot pending */
711 	ST_EOT,			/* at logical eot */
712 	ST_EOM,			/* at physical eot */
713 	ST_WRITE_AFTER_EOM	/* flag for allowing writes after EOM */
714 }pstatus;
715 
716 typedef enum { invalid, legacy, logical } posmode;
717 
718 typedef struct tapepos {
719 	uint64_t lgclblkno;
720 	int32_t fileno;
721 	int32_t blkno;
722 	int32_t partition;
723 	pstatus eof;			/* eof states */
724 	posmode	pmode;
725 	uint32_t: 32;
726 }tapepos_t;
727 
728 /* byte 1 of cdb for type of read position command */
729 typedef enum {
730 	SHORT_POS	= 0,
731 	LONG_POS	= 6,
732 	EXT_POS		= 8,
733 	NO_POS		= 0xff	/* Drive doesn't support read position */
734 } read_p_types;
735 
736 
737 /*
738  * Data returned from the READ POSITION command.
739  */
740 
741 typedef struct tape_position {
742 #if defined(_BIT_FIELDS_HTOL)
743 	uchar_t begin_of_part:	1;
744 	uchar_t end_of_part:	1;
745 	uchar_t blk_cnt_unkwn:	1;
746 	uchar_t byte_cnt_unkwn:	1;
747 	uchar_t reserved0:	1;
748 	uchar_t blk_posi_unkwn:	1;
749 	uchar_t posi_err:	1;
750 	uchar_t reserved1:	1;
751 #elif defined(_BIT_FIELDS_LTOH)
752 	uchar_t reserved1:	1;
753 	uchar_t posi_err:	1;
754 	uchar_t blk_posi_unkwn:	1;
755 	uchar_t reserved0:	1;
756 	uchar_t byte_cnt_unkwn:	1;
757 	uchar_t blk_cnt_unkwn:	1;
758 	uchar_t end_of_part:	1;
759 	uchar_t begin_of_part:	1;
760 #endif
761 	uchar_t partition_number;
762 	uchar_t reserved2[2];
763 	uint32_t host_block;
764 	uint32_t media_block;
765 	uchar_t reserved3;
766 	uchar_t block_in_buff[3];
767 	uint32_t byte_in_buff;
768 }tape_position_t;
769 
770 
771 typedef struct tape_position_long {
772 #if defined(_BIT_FIELDS_HTOL)
773 	uint32_t begin_of_part:	1;
774 	uint32_t end_of_part:	1;
775 	uint32_t reserved0:	2;
776 	uint32_t mrk_posi_unkwn:1;
777 	uint32_t blk_posi_unkwn:1;
778 	uint32_t reserved1:	2;
779 #elif defined(_BIT_FIELDS_LTOH)
780 	uint32_t reserved1:	2;
781 	uint32_t blk_posi_unkwn:1;
782 	uint32_t mrk_posi_unkwn:1;
783 	uint32_t reserved0:	2;
784 	uint32_t end_of_part:   1;
785 	uint32_t begin_of_part: 1;
786 #endif
787 	uint32_t reserved2:	24;
788 	uint32_t partition;
789 	uint64_t block_number;
790 	uint64_t file_number;
791 	uint64_t set_number;
792 }tape_position_long_t;
793 
794 typedef struct tape_position_ext {
795 #if defined(_BIT_FIELDS_HTOL)
796 	uchar_t begin_of_part:	1;
797 	uchar_t end_of_part:	1;
798 	uchar_t blk_cnt_unkwn:	1;
799 	uchar_t byte_cnt_unkwn:	1;
800 	uchar_t mrk_posi_unkwn:	1;
801 	uchar_t blk_posi_unkwn:	1;
802 	uchar_t posi_err:	1;
803 	uchar_t reserved0:	1;
804 
805 	uchar_t partition;
806 	uint16_t parameter_len;
807 /* start next word */
808 	uint32_t reserved1:	8;
809 	uint32_t blks_in_buf:	24;
810 #elif defined(_BIT_FIELDS_LTOH)
811 	uchar_t reserved0:	1;
812 	uchar_t posi_err:	1;
813 	uchar_t blk_posi_unkwn:	1;
814 	uchar_t mrk_posi_unkwn:	1;
815 	uchar_t byte_cnt_unkwn:	1;
816 	uchar_t blk_cnt_unkwn:	1;
817 	uchar_t end_of_part:	1;
818 	uchar_t begin_of_part:	1;
819 
820 	uchar_t partition;
821 	uint16_t parameter_len;
822 /* start next word */
823 	uint32_t blks_in_buf:	24;
824 	uint32_t reserved1:	8;
825 #endif
826 	uint64_t host_block;
827 	uint64_t media_block;
828 	uint64_t byte_in_buf;
829 }tape_position_ext_t;
830 
831 typedef union {
832 	tape_position_t srt;
833 	tape_position_ext_t ext;
834 	tape_position_long_t lng;
835 }read_pos_data_t;
836 
837 typedef struct {
838 	unsigned char cmd;
839 	unsigned char
840 		requires_reserve:	1,	/* reserve must be done */
841 		retriable:		1,	/* can be retried */
842 		chg_tape_pos:		1,	/* position will change */
843 		chg_tape_data:		1,	/* data on media will change */
844 		explicit:		1,	/* explicit command set */
845 		/*
846 		 * 0 doesn't, 1 forward,
847 		 * 2 back, 3 either
848 		 */
849 		chg_tape_direction:	2;	/* direction of pos change */
850 #define	DIR_NONE	0
851 #define	DIR_FORW	1
852 #define	DIR_REVC	2
853 #define	DIR_EITH	3
854 	unsigned char
855 		/*
856 		 * 0 doesn't 1 read, 2 write
857 		 */
858 		transfers_data:		2,
859 #define	TRAN_NONE	0
860 #define	TRAN_READ	1
861 #define	TRAN_WRTE	2
862 		recov_pos_type:		1,
863 #define	POS_EXPECTED	0
864 #define	POS_STARTING	1
865 		do_not_recover:		1;
866 	uchar_t reserve_byte;
867 	uint32_t reserve_mask;
868 	uint64_t (*get_cnt)(uchar_t *);
869 	uint64_t (*get_lba)(uchar_t *);
870 }cmd_attribute;
871 
872 typedef struct {
873 	buf_t *cmd_bp;
874 	size_t privatelen;
875 }pkt_info;
876 
877 typedef struct {
878 	buf_t *cmd_bp;
879 	size_t privatelen;
880 	tapepos_t pos;
881 	const cmd_attribute *cmd_attrib;
882 }recov_info;
883 
884 #ifdef _KERNEL
885 
886 #ifdef	__x86
887 /* Data structure used in big block I/O on x86/x64 platform */
888 
889 /*
890  * alloc more than one contig_mem, so mutiple I/O can be
891  * on-going simultaneously
892  */
893 #define	ST_MAX_CONTIG_MEM_NUM	3
894 
895 struct contig_mem {
896 	struct contig_mem *cm_next;
897 	size_t cm_len;
898 	caddr_t cm_addr;
899 	ddi_acc_handle_t cm_acc_hdl;
900 	struct buf *cm_bp;
901 	int cm_use_sbuf;
902 };
903 
904 #endif
905 
906 #endif /* _KERNEL */
907 
908 /*
909  * driver states..
910  */
911 typedef enum {
912 	ST_STATE_CLOSED,
913 	ST_STATE_OFFLINE,
914 	ST_STATE_INITIALIZING,
915 	ST_STATE_OPENING,
916 	ST_STATE_OPEN_PENDING_IO,
917 	ST_STATE_APPEND_TESTING,
918 	ST_STATE_OPEN,
919 	ST_STATE_RESOURCE_WAIT,
920 	ST_STATE_CLOSING,
921 	ST_STATE_SENSING,
922 	ST_STATE_CLOSE_PENDING_OPEN
923 }st_states;
924 
925 typedef enum { RDWR, RDONLY, WORM, RDWORM, FAILED } writablity;
926 
927 
928 /*
929  * Private info for scsi tapes. Pointed to by the un_private pointer
930  * of one of the SCSI_DEVICE chains.
931  */
932 
933 struct scsi_tape {
934 	struct scsi_device *un_sd;	/* back pointer to SCSI_DEVICE */
935 	struct scsi_pkt *un_rqs;	/* ptr to request sense command */
936 	struct scsi_pkt *un_mkr_pkt;	/* ptr to marker packet */
937 	kcondvar_t un_sbuf_cv;		/* cv on ownership of special buf */
938 	kcondvar_t un_queue_cv;		/* cv on all queued commands */
939 	struct	buf *un_sbufp;		/* for use in special io */
940 	char	*un_srqbufp;		/* sense buffer for special io */
941 	kcondvar_t un_clscv;		/* closing cv */
942 	struct	buf *un_quef;		/* head of wait queue */
943 	struct	buf *un_quel;		/* tail of wait queue */
944 	struct	buf *un_runqf;		/* head of run queue */
945 	struct	buf *un_runql;		/* tail of run queue */
946 	struct seq_mode *un_mspl;	/* ptr to mode select info */
947 	struct st_drivetype *un_dp;	/* ptr to drive table entry */
948 	uint_t	un_dp_size;		/* size of un_dp alloc'ed */
949 	caddr_t	un_tmpbuf;		/* buf for append, autodens ops */
950 	tapepos_t un_pos;		/* Current tape position */
951 	int	un_oflags;		/* open flags */
952 	tapepos_t un_err_pos;		/* block in file where err occurred */
953 	uint_t	un_err_resid;		/* resid from last error */
954 	short	un_fmneeded;		/* filemarks to be written - HP only */
955 	dev_t	un_dev;			/* unix device */
956 	uchar_t	un_attached;		/* unit known && attached */
957 	int	un_pwr_mgmt;		/* power management state */
958 	uchar_t	un_density_known;	/* density is known */
959 	uchar_t	un_curdens;		/* index into density table */
960 	optype	un_lastop;		/* last I/O was: read/write/ctl */
961 	st_states un_laststate;		/* last state */
962 	st_states un_state;		/* current state */
963 	uchar_t	un_status;		/* status from last sense */
964 	uchar_t	un_retry_ct;		/* retry count */
965 	uchar_t	un_tran_retry_ct;	/* transport retry count */
966 	writablity un_read_only;	/* RDWR, RDONLY, WORM, RDWORM */
967 	uchar_t	un_test_append;		/* check writing at end of tape */
968 	uchar_t un_arq_enabled;		/* auto request sense enabled */
969 	uchar_t un_untagged_qing;	/* hba has untagged quing */
970 	uchar_t	un_allow_large_xfer;	/* allow >64k xfers if requested */
971 	uchar_t	un_sbuf_busy;		/* sbuf busy flag */
972 	uchar_t	un_ncmds;		/* number of commands outstanding */
973 	uchar_t	un_throttle;		/* curr. max number of cmds outst. */
974 	uchar_t	un_last_throttle;	/* saved max number of cmds outst. */
975 	uchar_t	un_max_throttle;	/* max poss. number cmds outstanding */
976 	uchar_t	un_persistence;		/* 1 = persistence on, 0 off */
977 	uchar_t	un_persist_errors;	/* 1 = persistenced flagged */
978 	uchar_t	un_flush_on_errors;	/* HBA will flush all I/O's on a */
979 					/* check condidtion or error */
980 	uint_t	un_kbytes_xferred;	/* bytes (in K) counter */
981 	uint_t	un_last_resid;		/* keep last resid, for PE */
982 	uint_t	un_last_count;		/* keep last count, for PE */
983 	struct 	kstat *un_stats;	/* for I/O statistics */
984 	struct buf *un_rqs_bp;		/* bp used in rqpkt */
985 	struct	buf *un_wf;		/* head of write queue */
986 	struct	buf *un_wl;		/* tail of write queue */
987 	struct	read_blklim *un_rbl;	/* ptr to read block limit info */
988 	int	un_maxdma;		/* max dma xfer allowed by HBA */
989 	uint_t	un_bsize;		/* block size currently being used */
990 	int	un_maxbsize;		/* max block size allowed by drive */
991 	uint_t	un_minbsize;		/* min block size allowed by drive */
992 	int	un_errno;		/* errno (b_error) */
993 	kcondvar_t	un_state_cv;	/* mediastate condition variable */
994 	enum mtio_state	un_mediastate;	/* current media state */
995 	enum mtio_state	un_specified_mediastate;	/* expected state */
996 	timeout_id_t	un_delay_tid;	/* delayed cv tid */
997 	timeout_id_t	un_hib_tid;	/* handle interrupt busy tid */
998 	opaque_t	un_swr_token;	/* scsi_watch request token */
999 	uchar_t	un_comp_page;		/* compression page */
1000 	uchar_t	un_rsvd_status;		/* Reservation Status */
1001 	kstat_t *un_errstats;		/* for error statistics */
1002 	int	un_init_options;	/* Init time drive options */
1003 	int	un_save_fileno;		/* Save here for recovery */
1004 	daddr_t	un_save_blkno;		/* Save here for recovery */
1005 	uchar_t un_restore_pos;		/* Indication to do recovery */
1006 	tapepos_t un_suspend_pos;	/* Save blkno for SUSPEND */
1007 	uchar_t	un_silent_skip;		/* to catch short reads */
1008 	short	un_tids_at_suspend;	/* timeouts set at suspend */
1009 	kcondvar_t un_tape_busy_cv;	/* busy cv */
1010 	kcondvar_t un_suspend_cv;	/* busy cv */
1011 					/* restore on close */
1012 	uchar_t	un_eject_tape_on_failure; /* 1 = eject tape, 0 = don't */
1013 	uchar_t	un_HeadClean; 		/* support and need head cleaning? */
1014 	uchar_t	un_rqs_state;		/* see define below */
1015 	struct scsi_extended_sense
1016 	    *un_uscsi_rqs_buf;		/* uscsi_rqs: buffer for RQS data */
1017 	uchar_t	un_data_mod;		/* Device required data mod */
1018 	writablity (*un_wormable) (struct scsi_tape *un); /* worm test fuct */
1019 	int un_max_cdb_sz;		/* max cdb size to use */
1020 	read_p_types un_read_pos_type;
1021 	read_pos_data_t *un_read_pos_data;
1022 	struct mterror_entry_stack *un_error_entry_stk;
1023 					/* latest sense cmd buffer */
1024 
1025 #ifdef	__x86
1026 	ddi_dma_handle_t un_contig_mem_hdl;
1027 	struct contig_mem *un_contig_mem;
1028 	int un_contig_mem_available_num;
1029 	int un_contig_mem_total_num;
1030 	size_t un_max_contig_mem_len;
1031 	kcondvar_t un_contig_mem_cv;
1032 	int un_maxdma_arch;		/* max dma xfer allowed by HBA & arch */
1033 #endif
1034 	caddr_t un_media_id;
1035 	int un_media_id_len;
1036 	int (*un_media_id_method)(struct scsi_tape *, int (*)());
1037 	buf_t *un_recov_buf;		/* buf to recover failed commands */
1038 	kcondvar_t un_recov_buf_cv;	/* cv for buf un_recov_buf */
1039 	uchar_t un_recov_buf_busy;
1040 #ifdef _KERNEL
1041 	ddi_taskq_t *un_recov_taskq;
1042 #else
1043 	void *un_recov_taskq;
1044 #endif
1045 	tapepos_t un_running;
1046 	uchar_t un_unit_attention_flags;
1047 };
1048 
1049 typedef int (*bufunc_t)(struct scsi_tape *, int, int64_t, int);
1050 typedef int (*ubufunc_t)(struct scsi_tape *, struct uscsi_cmd *, int);
1051 
1052 
1053 /*
1054  * device error kstats
1055  */
1056 struct st_errstats {
1057 	struct kstat_named	st_softerrs;
1058 	struct kstat_named	st_harderrs;
1059 	struct kstat_named	st_transerrs;
1060 	struct kstat_named	st_vid;
1061 	struct kstat_named	st_pid;
1062 	struct kstat_named	st_revision;
1063 	struct kstat_named	st_serial;
1064 };
1065 
1066 /*
1067  * generic log page struct
1068  */
1069 struct log_page {
1070 #if defined(_BIT_FIELDS_LTOH)
1071 	uchar_t	code	:6,	/* page code number */
1072 			:2;	/* reserved */
1073 #elif defined(_BIT_FIELDS_HTOL)
1074 	uchar_t		:2,	/* reserved */
1075 		code	:6;	/* page code number */
1076 #endif	/* _BIT_FIELDS_LTOH */
1077 	uchar_t	reserved;	/* reserved */
1078 	uchar_t	length_hi;	/* length of bytes to follow (msb) */
1079 	uchar_t	length_lo;	/* length of bytes to follow (lsb) */
1080 	/*
1081 	 * Log parameters follow right after this...
1082 	 */
1083 };
1084 
1085 /*
1086  * generic log page parameter struct
1087  */
1088 struct log_param {
1089 	uchar_t	pc_hi;			/* parameter code (msb) */
1090 	uchar_t	pc_lo;			/* parameter code (lsb) */
1091 #if defined(_BIT_FIELDS_LTOH)
1092 	uchar_t		lp	: 1,	/* list parameter */
1093 				: 1,	/* reserved */
1094 			tmc	: 2,	/* threshold met criteria */
1095 			etc	: 1,	/* enable threshold comparison */
1096 			tsd	: 1,	/* target save disable */
1097 			ds	: 1,	/* disable save */
1098 			du	: 1;	/* disable update */
1099 #elif defined(_BIT_FIELDS_HTOL)
1100 	uchar_t		du	: 1,	/* disable update */
1101 			ds	: 1,	/* disable save */
1102 			tsd	: 1,	/* target save disable */
1103 			etc	: 1,	/* enable threshold comparison */
1104 			tmc	: 2,	/* threshold met criteria */
1105 				: 1,	/* reserved */
1106 			lp	: 1;	/* list parameter */
1107 #endif	/* _BIT_FIELDS_LTOH */
1108 	uchar_t	length;		/* length of bytes to follow */
1109 	/*
1110 	 * Parameter values follow right after this...
1111 	 */
1112 };
1113 /*
1114  * TapeAlert structures
1115  */
1116 
1117 struct st_tape_alert_parameter {
1118 	struct log_param log_param;
1119 	uchar_t	param_value;
1120 };
1121 
1122 struct st_tape_alert {
1123 	struct log_page log_page;
1124 	struct st_tape_alert_parameter param[TAPE_ALERT_MAX_PARA];
1125 };
1126 
1127 #define	TAPE_ALERT_PARAMETER_LENGTH \
1128 	(sizeof (struct st_tape_alert_parameter)) * TAPE_ALERT_MAX_PARA
1129 
1130 struct log_sequential_page_parameter {
1131 	struct log_param log_param;
1132 	uchar_t param_value[8];
1133 };
1134 
1135 struct log_sequential_page {
1136 	struct log_page log_page;
1137 	struct log_sequential_page_parameter param[TAPE_SEQUENTIAL_PAGE_PARA];
1138 };
1139 
1140 #if !defined(__lint)
1141 _NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, scsi_tape))
1142 _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_tape::un_dp))
1143 _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_tape::un_sd))
1144 _NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_tape::un_rqs))
1145 _NOTE(SCHEME_PROTECTS_DATA("protected by cv", scsi_tape::un_sbufp))
1146 _NOTE(DATA_READABLE_WITHOUT_LOCK(scsi_tape::un_bsize))
1147 _NOTE(SCHEME_PROTECTS_DATA("not shared", scsi_arq_status))
1148 _NOTE(SCHEME_PROTECTS_DATA("save sharing",
1149 	scsi_tape::un_allow_large_xfer
1150 	scsi_tape::un_maxbsize
1151 	scsi_tape::un_maxdma
1152 ))
1153 #ifdef	__x86
1154 _NOTE(DATA_READABLE_WITHOUT_LOCK(scsi_tape::un_contig_mem_hdl))
1155 _NOTE(SCHEME_PROTECTS_DATA("not shared", contig_mem))
1156 #endif
1157 #endif
1158 
1159 
1160 /*
1161  * Power management state
1162  */
1163 #define	ST_PWR_NORMAL				0
1164 #define	ST_PWR_SUSPENDED			1
1165 
1166 
1167 #define	IN_EOF(pos)	(pos.eof == ST_EOF_PENDING || pos.eof == ST_EOF)
1168 
1169 /* un_rqs_state codes */
1170 
1171 #define	ST_RQS_OVR		0x1	/* RQS data was overwritten */
1172 #define	ST_RQS_VALID		0x2	/* RQS data is valid */
1173 #define	ST_RQS_READ		0x4	/* RQS data was read */
1174 #define	ST_RQS_ERROR		0x8	/* RQS resulted in an EIO */
1175 
1176 /*
1177  * st_intr codes
1178  */
1179 typedef enum {
1180 	COMMAND_DONE,
1181 	COMMAND_DONE_ERROR,
1182 	COMMAND_DONE_ERROR_RECOVERED,
1183 	QUE_COMMAND,
1184 	QUE_BUSY_COMMAND,
1185 	QUE_SENSE,
1186 	JUST_RETURN,
1187 	COMMAND_DONE_EACCES,
1188 	QUE_LAST_COMMAND,
1189 	COMMAND_TIMEOUT,
1190 	PATH_FAILED,
1191 	DEVICE_RESET,
1192 	DEVICE_TAMPER,
1193 	ATTEMPT_RETRY
1194 }errstate;
1195 #ifdef _KERNEL
1196 typedef struct {
1197 	struct scsi_pkt ei_failed_pkt;
1198 	struct scsi_arq_status ei_failing_status;
1199 	tapepos_t ei_expected_pos;
1200 	errstate ei_error_type;
1201 	buf_t *ei_failing_bp;
1202 } st_err_info;
1203 #endif
1204 
1205 
1206 /*
1207  *	Reservation Status
1208  *
1209  * ST_INIT_RESERVE      -Used to check if the reservation has been lost
1210  *		         in between opens and also to indicate the reservation
1211  *		         has not been done till now.
1212  * ST_RELEASE	        -Tape Unit is Released.
1213  * ST_RESERVE	        -Tape Unit is Reserved.
1214  * ST_PRESERVE_RESERVE  -Reservation is to be preserved across opens.
1215  *
1216  */
1217 #define	ST_INIT_RESERVE			0x001
1218 #define	ST_RELEASE			0x002
1219 #define	ST_RESERVE			0x004
1220 #define	ST_PRESERVE_RESERVE		0x008
1221 #define	ST_RESERVATION_CONFLICT 	0x010
1222 #define	ST_LOST_RESERVE			0x020
1223 #define	ST_APPLICATION_RESERVATIONS	0x040
1224 #define	ST_INITIATED_RESET		0x080
1225 #define	ST_LOST_RESERVE_BETWEEN_OPENS  \
1226 		(ST_RESERVE | ST_LOST_RESERVE | ST_PRESERVE_RESERVE)
1227 
1228 /*
1229  * Service action defines for Persistant Reservation Commands
1230  */
1231 #define	ST_SA_SCSI3_REGISTER			0x00
1232 #define	ST_SA_SCSI3_RESERVE			0x01
1233 #define	ST_SA_SCSI3_RELEASE			0x02
1234 #define	ST_SA_SCSI3_CLEAR			0x03
1235 #define	ST_SA_SCSI3_PREEMPT			0x04
1236 #define	ST_SA_SCSI3_PREEMPTANDABORT		0x05
1237 #define	ST_SA_SCSI3_REGISTERANDIGNOREKEY	0x06
1238 #define	ST_SA_MASK				0x1f
1239 
1240 #define	ST_RESERVATION_DELAY		500000
1241 
1242 /*
1243  * Asynch I/O tunables
1244  */
1245 #define	ST_MAX_THROTTLE		4
1246 
1247 /*
1248  * 60 minutes seems a reasonable amount of time
1249  * to wait for tape space operations to complete.
1250  *
1251  */
1252 #define	ST_SPACE_TIME	MINUTES(60)	/* 60 minutes per space operation */
1253 #define	ST_LONG_SPACE_TIME_X	5	/* multipiler for long space ops */
1254 
1255 /*
1256  * 2 minutes seems a reasonable amount of time
1257  * to wait for tape i/o operations to complete.
1258  *
1259  */
1260 #define	ST_IO_TIME	MINUTES(2)	/* minutes per i/o */
1261 #define	ST_LONG_TIMEOUT_X	5	/* multiplier for very long timeouts */
1262 
1263 
1264 /*
1265  * 10 seconds is what we'll wait if we get a Busy Status back
1266  */
1267 #define	ST_STATUS_BUSY_TIMEOUT	10*hz	/* seconds Busy Waiting */
1268 #define	ST_TRAN_BUSY_TIMEOUT	1*hz	/* seconds retry on TRAN_BSY */
1269 #define	ST_INTERRUPT_CONTEXT	1
1270 #define	ST_START_CONTEXT	2
1271 
1272 /*
1273  * Number of times we'll retry a normal operation.
1274  *
1275  * XXX This includes retries due to transport failure as well as
1276  * XXX busy timeouts- Need to distinguish between Target and Transport
1277  * XXX failure.
1278  */
1279 
1280 #define	ST_RETRY_COUNT		20
1281 
1282 /*
1283  * Number of times to retry a failed selection
1284  */
1285 #define	ST_SEL_RETRY_COUNT		2
1286 
1287 /*
1288  * es_code value for deferred error
1289  * should be moved to sense.h
1290  */
1291 
1292 #define	ST_DEFERRED_ERROR		0x01
1293 
1294 /*
1295  * Maximum number of units (determined by minor device byte)
1296  */
1297 #define	ST_MAXUNIT	128
1298 
1299 /*
1300  * Time to wait for completion of a command before cancelling it.
1301  * For SUSPEND use only
1302  */
1303 #define	ST_WAIT_CMDS_COMPLETE		10	/* seconds */
1304 
1305 #ifndef	SECSIZE
1306 #define	SECSIZE	512
1307 #endif
1308 #ifndef	SECDIV
1309 #define	SECDIV	9
1310 #endif
1311 
1312 /*
1313  * convenient defines
1314  */
1315 #define	ST_SCSI_DEVP		(un->un_sd)
1316 #define	ST_DEVINFO		(ST_SCSI_DEVP->sd_dev)
1317 #define	ST_INQUIRY		(ST_SCSI_DEVP->sd_inq)
1318 #define	ST_RQSENSE		(ST_SCSI_DEVP->sd_sense)
1319 #define	ST_MUTEX		(&ST_SCSI_DEVP->sd_mutex)
1320 #define	ROUTE			(&ST_SCSI_DEVP->sd_address)
1321 
1322 #define	BSD_BEHAVIOR	(getminor(un->un_dev) & MT_BSD)
1323 #define	SVR4_BEHAVIOR	((getminor(un->un_dev) & MT_BSD) == 0)
1324 #define	SCBP(pkt)		((struct scsi_status *)(pkt)->pkt_scbp)
1325 #define	SCBP_C(pkt)		((*(pkt)->pkt_scbp) & STATUS_MASK)
1326 #define	CDBP(pkt)		((union scsi_cdb *)(pkt)->pkt_cdbp)
1327 #define	BP_PKT(bp)		((struct scsi_pkt *)(bp)->av_back)
1328 #define	SET_BP_PKT(bp, pkt)	((bp)->av_back = (struct buf *)(pkt))
1329 #define	BP_UCMD(bp)		((struct uscsi_cmd *)(bp)->b_back)
1330 #define	USCSI_CMD(bp)	(((bp) == un->un_sbufp) && (BP_UCMD(bp)))
1331 
1332 #define	IS_CLOSING(un)	((un)->un_state == ST_STATE_CLOSING || \
1333 	((un)->un_state == ST_STATE_SENSING && \
1334 		(un)->un_laststate == ST_STATE_CLOSING))
1335 
1336 #define	ASYNC_CMD	0
1337 #define	SYNC_CMD	1
1338 
1339 #define	st_bioerror(bp, error) \
1340 		{ bioerror(bp, error); \
1341 		un->un_errno = error; }
1342 
1343 /*
1344  * Macros for internal coding of count for SPACE command:
1345  *
1346  * Top 3 bits of b_bcount define direction and type of space.
1347  * Since b_bcount (size_t) is 32 bits on 32 platforms and 64 bits on
1348  * 64 bit platforms different defines are used.
1349  * if SP_BACKSP is set direction is backward (toward BOP)
1350  * The type of space (Blocks, Filemark or sequential filemarks) is
1351  * carried in the next 2 bits. The remaining bits a signed count of
1352  * how many of that direction and type to do.
1353  */
1354 #if (SIZE_MAX < UINT64_MAX)
1355 
1356 #define	SP_BLK		UINT32_C(0x00000000)
1357 #define	SP_FLM		UINT32_C(0x20000000)
1358 #define	SP_SQFLM	UINT32_C(0x40000000)
1359 #define	SP_EOD		UINT32_C(0x60000000)
1360 #define	SP_BACKSP	UINT32_C(0x80000000)
1361 #define	SP_CMD_MASK	UINT32_C(0x60000000)
1362 #define	SP_CNT_MASK	UINT32_C(0x1fffffff)
1363 
1364 /* Macros to interpret space cmds */
1365 #define	SPACE_CNT(x)	(((x) & SP_BACKSP)? \
1366 	(-((x)&(SP_CNT_MASK))):(x)&(SP_CNT_MASK))
1367 #define	SPACE_TYPE(x)	((x & SP_CMD_MASK)>>29)
1368 
1369 #else /* end of small size_t in buf_t */
1370 
1371 #define	SP_BLK		UINT64_C(0x0000000000000000)
1372 #define	SP_FLM		UINT64_C(0x2000000000000000)
1373 #define	SP_SQFLM	UINT64_C(0x4000000000000000)
1374 #define	SP_EOD		UINT64_C(0x6000000000000000)
1375 #define	SP_BACKSP	UINT64_C(0x8000000000000000)
1376 #define	SP_CMD_MASK	UINT64_C(0x6000000000000000)
1377 #define	SP_CNT_MASK	UINT64_C(0x1fffffffffffffff)
1378 
1379 /* Macros to interpret space cmds */
1380 #define	SPACE_CNT(x)	(((x) & SP_BACKSP)? \
1381 	(-((x)&(SP_CNT_MASK))):(x)&(SP_CNT_MASK))
1382 #define	SPACE_TYPE(x)	((x & SP_CMD_MASK)>>61)
1383 
1384 #endif /* end of big size_t in buf_t */
1385 
1386 /* Macros to assemble space cmds */
1387 #define	SPACE(cmd, cnt)	((cnt < 0) ? (SP_BACKSP | (-(cnt)) | cmd) : (cmd | cnt))
1388 #define	Fmk(x)		SPACE(SP_FLM, x)
1389 #define	Blk(x)		SPACE(SP_BLK, x)
1390 
1391 
1392 
1393 /* Defines for byte 4 of load/unload cmd */
1394 #define	LD_UNLOAD	0
1395 #define	LD_LOAD		1
1396 #define	LD_RETEN	2
1397 #define	LD_EOT		4
1398 #define	LD_HOLD		8
1399 
1400 /* Defines for byte 4 of prevent/allow media removal */
1401 #define	MR_UNLOCK	0
1402 #define	MR_LOCK		1
1403 
1404 #define	GET_SOFT_STATE(dev)						\
1405 	register struct scsi_tape *un;					\
1406 	register int instance;						\
1407 									\
1408 	instance = MTUNIT(dev);						\
1409 	if ((un = ddi_get_soft_state(st_state, instance)) == NULL)	\
1410 		return (ENXIO);
1411 
1412 /*
1413  * Debugging turned on via conditional compilation switch -DSTDEBUG
1414  */
1415 #ifdef DEBUG
1416 #define	STDEBUG
1417 #endif
1418 
1419 #ifdef	STDEBUG
1420 #define	DEBUGGING\
1421 	((scsi_options & SCSI_DEBUG_TGT) || (st_debug & 0x7))
1422 
1423 #define	ST_DARGS(d) st_label, ((d == st_lastdev || d == 0) ?CE_CONT:CE_NOTE)
1424 
1425 	/* initialization */
1426 #define	ST_DEBUG1	if ((st_debug & 0x7) >= 1) scsi_log
1427 #define	ST_DEBUG	ST_DEBUG1
1428 
1429 	/* errors and UA's */
1430 #define	ST_DEBUG2	if ((st_debug & 0x7) >= 2) scsi_log
1431 
1432 	/* func calls */
1433 #define	ST_DEBUG3	if ((st_debug & 0x7) >= 3) scsi_log
1434 
1435 	/* ioctl calls */
1436 #define	ST_DEBUG4	if ((st_debug & 0x7) >= 4) scsi_log
1437 
1438 #define	ST_DEBUG5	if ((st_debug & 0x7) >= 5) scsi_log
1439 
1440 	/* full data tracking */
1441 #define	ST_DEBUG6	if ((st_debug & 0x7) >= 6) scsi_log
1442 
1443 	/* debug error recovery */
1444 #define	ST_RECOV	if (st_debug & 0x8) scsi_log
1445 
1446 	/* Entry Point Functions */
1447 #define	ST_ENTR(d, fn)\
1448     if (st_debug & 0x10) { scsi_log(d, ST_DARGS(d), #fn);\
1449     if (d != 0 && d != st_lastdev) st_lastdev = d; }
1450 
1451 	/* Non-Entry Point Functions */
1452 #define	ST_FUNC(d, fn)\
1453     if (st_debug & 0x20) { scsi_log(d, ST_DARGS(d), #fn);\
1454     if (d != 0 && d != st_lastdev) st_lastdev = d; }
1455 
1456 	/* Space Information */
1457 #define	ST_SPAC		if (st_debug & 0x40) scsi_log
1458 
1459 	/* CDB's sent */
1460 #define	ST_CDB(d, cmnt, cdb) if (st_debug & 0x180) { \
1461     st_print_cdb(d, ST_DARGS(d), cmnt, cdb);\
1462     if (d != 0 && d != st_lastdev) st_lastdev = d; }
1463 	/* sense data */
1464 #define	ST_SENSE(d, cmnt, sense, size) if (st_debug & 0x200) { \
1465     st_clean_print(d, ST_DARGS(d), cmnt, sense, size);\
1466     if (d != 0 && d != st_lastdev) st_lastdev = d; }
1467 	/* position data */
1468 #define	ST_POS(d, cmnt, pdata) if (st_debug & 0x400) { \
1469     st_print_position(d, ST_DARGS(d), cmnt, pdata);\
1470     if (d != 0 && d != st_lastdev) st_lastdev = d; }
1471 
1472 
1473 #else
1474 
1475 #define	st_debug	(0)
1476 #define	DEBUGGING	(0)
1477 #define	ST_DEBUG	if (0) scsi_log
1478 #define	ST_DEBUG1	if (0) scsi_log
1479 #define	ST_DEBUG2	if (0) scsi_log
1480 #define	ST_DEBUG3	if (0) scsi_log
1481 #define	ST_DEBUG4	if (0) scsi_log
1482 #define	ST_DEBUG5	if (0) scsi_log
1483 #define	ST_DEBUG6	if (0) scsi_log
1484 #define	ST_RECOV	if (0) scsi_log
1485 
1486 #define	ST_ENTR(d, fn)
1487 #define	ST_FUNC(d, fn)
1488 #define	ST_SPAC		if (0) scsi_log
1489 #define	ST_CDB(d, cmnt, cdb)
1490 #define	ST_SENSE(d, cmnt, sense, size)
1491 #define	ST_SENSE(d, cmnt, sense, size)
1492 #define	ST_POS(d, cmnt, pdata)
1493 
1494 #endif
1495 
1496 /*
1497  * Media access values
1498  */
1499 #define	MEDIA_ACCESS_DELAY 5000000	/* usecs wait for media state change */
1500 
1501 /*
1502  * SCSI tape mode sense page information
1503  */
1504 #define	ST_DEV_CONFIG_PAGE	0x10	/* device config mode page */
1505 #define	ST_DEV_CONFIG_NO_COMP	0x00	/* use no compression */
1506 #define	ST_DEV_CONFIG_DEF_COMP	0x01	/* use default compression alg */
1507 #define	ST_COMPRESSION_DENSITY	3	/* compression minor number */
1508 
1509 /*
1510  * SCSI tape data compression Page definition.
1511  */
1512 #define	ST_DEV_DATACOMP_PAGE	0x0F	/* data compression page */
1513 
1514 
1515 
1516 /*
1517  * maxbsize values
1518  */
1519 #define	MAXBSIZE_UNKNOWN	-2	/*  not found yet */
1520 
1521 #define	ONE_MEG			(1024 * 1024)
1522 
1523 /*
1524  * generic soft error reporting
1525  *
1526  * What we are doing here is allowing a greater number of errors to occur on
1527  * smaller transfers (i.e. usually at the beginning of the tape), than on
1528  * the rest of the tape.
1529  *
1530  * A small transfer is defined as :
1531  * Transfers <= SOFT_ERROR_WARNING_THRESHOLD  allow about 1.5 times more errors
1532  *
1533  * A larget tranfer is defined as :
1534  * Transfers >  SOFT_ERROR_WARNING_THRESHOLD  allow normal amount
1535  *
1536  */
1537 #define	READ_SOFT_ERROR_WARNING_THRESHOLD    (25 * ONE_MEG)
1538 #define	WRITE_SOFT_ERROR_WARNING_THRESHOLD    (20 * ONE_MEG)
1539 
1540 /*
1541  * soft error reporting for exabyte
1542  */
1543 #define	TAPE_SENSE_LENGTH	32	/* allows for softerror info */
1544 
1545 #define	SENSE_19_BITS  \
1546 	"\20\10PF\07BPE\06FPE\05ME\04ECO\03TME\02TNP\01LBOT"
1547 #define	SENSE_20_BITS  \
1548 	"\20\10RSVD\07RSVD\06WP\05FMKE\04URE\03WE1\02SSE\01FW"
1549 #define	SENSE_21_BITS  \
1550 	"\20\10RSVD\07RSVD\06RRR\05CLND\04CLN\03PEOT\02WSEB\01WSE0"
1551 
1552 /* these are defined in percentages */
1553 #define	EXABYTE_WRITE_ERROR_THRESHOLD	6
1554 #define	EXABYTE_READ_ERROR_THRESHOLD	3
1555 /*
1556  * minumum amount of data transfer(MB) for checking soft error rate.
1557  */
1558 #define	EXABYTE_MIN_TRANSFER			(25 * ONE_MEG)
1559 
1560 #define	CLN	0x8
1561 #define	CLND	0x10
1562 
1563 /*
1564  * soft error reporting for Archive 4mm DAT
1565  */
1566 
1567 #define	LOG_SENSE_LENGTH		0xff
1568 #define	MIN_LOG_SENSE_LENGTH		0x2b
1569 #define	DAT_SMALL_WRITE_ERROR_THRESHOLD	40	/* retries per 20 mg */
1570 #define	DAT_LARGE_WRITE_ERROR_THRESHOLD	200	/* retries for more 20 mg */
1571 #define	DAT_SMALL_READ_ERROR_THRESHOLD	5	/* errors allowed */
1572 #define	DAT_LARGE_READ_ERROR_THRESHOLD	3	/* errors allowed */
1573 
1574 /*
1575  * ST timeouts that need to be cancelled for suspend
1576  */
1577 #define	ST_HIB_TID	0x01
1578 #define	ST_DELAY_TID	0x02
1579 
1580 #ifdef	__cplusplus
1581 }
1582 #endif
1583 
1584 #endif	/* _SYS_SCSI_TARGETS_STDEF_H */
1585