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
52c9565cfSls  * Common Development and Distribution License (the "License").
62c9565cfSls  * 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  */
21f1cc607eSJeffry Molanus 
227c478bd9Sstevel@tonic-gate /*
232ee4dfc7SJane Chu  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25f1cc607eSJeffry Molanus  * Copyright 2017 Nexenta Systems, Inc.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_SYS_SCSI_GENERIC_MODE_H
297c478bd9Sstevel@tonic-gate #define	_SYS_SCSI_GENERIC_MODE_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  *
377c478bd9Sstevel@tonic-gate  * Defines and Structures for SCSI Mode Sense/Select data - generic
387c478bd9Sstevel@tonic-gate  *
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * Structures and defines common for all device types
437c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * Mode Sense/Select Header - Group 0 (6-byte).
477c478bd9Sstevel@tonic-gate  *
487c478bd9Sstevel@tonic-gate  * Mode Sense/Select data consists of a header, followed by zero or more
497c478bd9Sstevel@tonic-gate  * block descriptors, followed by zero or more mode pages.
507c478bd9Sstevel@tonic-gate  *
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate struct mode_header {
547c478bd9Sstevel@tonic-gate 	uchar_t length;		/* number of bytes following */
557c478bd9Sstevel@tonic-gate 	uchar_t medium_type;	/* device specific */
567c478bd9Sstevel@tonic-gate 	uchar_t device_specific;	/* device specific parameters */
577c478bd9Sstevel@tonic-gate 	uchar_t bdesc_length;	/* length of block descriptor(s), if any */
587c478bd9Sstevel@tonic-gate };
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #define	MODE_HEADER_LENGTH	(sizeof (struct mode_header))
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Mode Sense/Select Header - Group 1 (10-bytes)
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate struct mode_header_g1 {
677c478bd9Sstevel@tonic-gate 	ushort_t	length;		/* number of bytes following */
687c478bd9Sstevel@tonic-gate 	uchar_t		medium_type;	/* device specific */
697c478bd9Sstevel@tonic-gate 	uchar_t		device_specific;	/* device specific parameters */
707c478bd9Sstevel@tonic-gate 	uchar_t		reserved[2];	/* device specific parameters */
717c478bd9Sstevel@tonic-gate 	ushort_t	bdesc_length;	/* len of block descriptor(s), if any */
727c478bd9Sstevel@tonic-gate };
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate #define	MODE_HEADER_LENGTH_G1	(sizeof (struct mode_header_g1))
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * Block Descriptor. Zero, one, or more may normally follow the mode header.
787c478bd9Sstevel@tonic-gate  *
797c478bd9Sstevel@tonic-gate  * The density code is device specific.
807c478bd9Sstevel@tonic-gate  *
817c478bd9Sstevel@tonic-gate  * The 24-bit value described by blks_{hi, mid, lo} describes the number of
827c478bd9Sstevel@tonic-gate  * blocks which this block descriptor applies to. A value of zero means
837c478bd9Sstevel@tonic-gate  * 'the rest of the blocks on the device'.
847c478bd9Sstevel@tonic-gate  *
857c478bd9Sstevel@tonic-gate  * The 24-bit value described by blksize_{hi, mid, lo} describes the blocksize
867c478bd9Sstevel@tonic-gate  * (in bytes) applicable for this block descriptor. For Sequential Access
877c478bd9Sstevel@tonic-gate  * devices, if this value is zero, the block size will be derived from
887c478bd9Sstevel@tonic-gate  * the transfer length in I/O operations.
897c478bd9Sstevel@tonic-gate  *
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate struct block_descriptor {
937c478bd9Sstevel@tonic-gate 	uchar_t density_code;	/* device specific */
947c478bd9Sstevel@tonic-gate 	uchar_t blks_hi;	/* hi  */
957c478bd9Sstevel@tonic-gate 	uchar_t blks_mid;	/* mid */
967c478bd9Sstevel@tonic-gate 	uchar_t blks_lo;	/* low */
977c478bd9Sstevel@tonic-gate 	uchar_t reserved;	/* reserved */
987c478bd9Sstevel@tonic-gate 	uchar_t blksize_hi;	/* hi  */
997c478bd9Sstevel@tonic-gate 	uchar_t blksize_mid;	/* mid */
1007c478bd9Sstevel@tonic-gate 	uchar_t blksize_lo;	/* low */
1017c478bd9Sstevel@tonic-gate };
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #define	MODE_BLK_DESC_LENGTH	(sizeof (struct block_descriptor))
1047c478bd9Sstevel@tonic-gate #define	MODE_PARAM_LENGTH 	(MODE_HEADER_LENGTH + MODE_BLK_DESC_LENGTH)
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate  * Define a macro to take an address of a mode header to the address
1087c478bd9Sstevel@tonic-gate  * of the nth (0..n) block_descriptor, or NULL if there either aren't any
1097c478bd9Sstevel@tonic-gate  * block descriptors or the nth block descriptor doesn't exist.
1107c478bd9Sstevel@tonic-gate  */
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #define	BLOCK_DESCRIPTOR_ADDR(mhdr, bdnum) \
1137c478bd9Sstevel@tonic-gate 	((mhdr)->bdesc_length && ((unsigned)(bdnum)) < \
1147c478bd9Sstevel@tonic-gate 	((mhdr)->bdesc_length/(sizeof (struct block_descriptor)))) ? \
1157c478bd9Sstevel@tonic-gate 	((struct block_descriptor *)(((ulong_t)(mhdr))+MODE_HEADER_LENGTH+ \
1167c478bd9Sstevel@tonic-gate 	((bdnum) * sizeof (struct block_descriptor)))) : \
1177c478bd9Sstevel@tonic-gate 	((struct block_descriptor *)0)
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * Mode page header. Zero or more Mode Pages follow either the block
1217c478bd9Sstevel@tonic-gate  * descriptors (if any), or the Mode Header.
1227c478bd9Sstevel@tonic-gate  *
1237c478bd9Sstevel@tonic-gate  * The 'ps' bit must be zero for mode select operations.
1247c478bd9Sstevel@tonic-gate  *
1257c478bd9Sstevel@tonic-gate  */
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate struct mode_page {
1287c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
1297c478bd9Sstevel@tonic-gate 	uchar_t	code	:6,	/* page code number */
1307c478bd9Sstevel@tonic-gate 			:1,	/* reserved */
1317c478bd9Sstevel@tonic-gate 		ps	:1;	/* 'Parameter Saveable' bit */
1327c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
1337c478bd9Sstevel@tonic-gate 	uchar_t	ps	:1,	/* 'Parameter Saveable' bit */
1347c478bd9Sstevel@tonic-gate 			:1,	/* reserved */
1357c478bd9Sstevel@tonic-gate 		code	:6;	/* page code number */
1367c478bd9Sstevel@tonic-gate #else
1377c478bd9Sstevel@tonic-gate #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
1387c478bd9Sstevel@tonic-gate #endif	/* _BIT_FIELDS_LTOH */
1397c478bd9Sstevel@tonic-gate 	uchar_t	length;		/* length of bytes to follow */
1407c478bd9Sstevel@tonic-gate 	/*
1417c478bd9Sstevel@tonic-gate 	 * Mode Page specific data follows right after this...
1427c478bd9Sstevel@tonic-gate 	 */
1437c478bd9Sstevel@tonic-gate };
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate /*
1467c478bd9Sstevel@tonic-gate  * Define a macro to retrieve the first mode page. Could be more
1477c478bd9Sstevel@tonic-gate  * general (for multiple mode pages).
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #define	MODE_PAGE_ADDR(mhdr, type)	\
1517c478bd9Sstevel@tonic-gate 	((type *)(((ulong_t)(mhdr))+MODE_HEADER_LENGTH+(mhdr)->bdesc_length))
1527c478bd9Sstevel@tonic-gate 
153f1cc607eSJeffry Molanus /*
154f1cc607eSJeffry Molanus  * Page Control field (bits 7 and 6) follows the following specification:
155f1cc607eSJeffry Molanus  *
156f1cc607eSJeffry Molanus  * 	Value			Meaning
157f1cc607eSJeffry Molanus  * 	----------------------------------------------------------------------
158f1cc607eSJeffry Molanus  * 	00b			current values
159f1cc607eSJeffry Molanus  * 	01b			changeable values
160f1cc607eSJeffry Molanus  * 	10b			default values
161f1cc607eSJeffry Molanus  * 	11b			saved values
162f1cc607eSJeffry Molanus  */
163f1cc607eSJeffry Molanus 
164f1cc607eSJeffry Molanus #define	MODEPAGE_CURRENT	0x00
165f1cc607eSJeffry Molanus #define	MODEPAGE_CHANGEABLE	0x40
166f1cc607eSJeffry Molanus #define	MODEPAGE_DEFAULT	0x80
167f1cc607eSJeffry Molanus #define	MODEPAGE_SAVED		0xC0
168f1cc607eSJeffry Molanus 
1697c478bd9Sstevel@tonic-gate /*
1707c478bd9Sstevel@tonic-gate  * Page codes follow the following specification:
1717c478bd9Sstevel@tonic-gate  *
1727c478bd9Sstevel@tonic-gate  *	Code Value(s)		What
1737c478bd9Sstevel@tonic-gate  *	----------------------------------------------------------------------
1747c478bd9Sstevel@tonic-gate  *	0x00			Vendor Unique (does not require page format)
1757c478bd9Sstevel@tonic-gate  *
1767c478bd9Sstevel@tonic-gate  *	0x02, 0x09, 0x0A	pages for all Device Types
1777c478bd9Sstevel@tonic-gate  *	0x1A, 0x1C
1787c478bd9Sstevel@tonic-gate  *
1797c478bd9Sstevel@tonic-gate  *	0x01, 0x03-0x08,	pages for specific Device Type
1807c478bd9Sstevel@tonic-gate  *	0x0B-0x19, 0x1B,
1817c478bd9Sstevel@tonic-gate  *	0x1D-0x1F
1827c478bd9Sstevel@tonic-gate  *
1837c478bd9Sstevel@tonic-gate  *	0x20-0x3E		Vendor Unique (requires page format)
1847c478bd9Sstevel@tonic-gate  *
1857c478bd9Sstevel@tonic-gate  *	0x3F			Return all pages (valid for Mode Sense only)
1867c478bd9Sstevel@tonic-gate  *
1877c478bd9Sstevel@tonic-gate  */
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate /*
1907c478bd9Sstevel@tonic-gate  * Page codes and page length values (all device types)
1917c478bd9Sstevel@tonic-gate  */
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate #define	MODEPAGE_DISCO_RECO	0x02
194*61dfa509SRick McNeal #define	MODEPAGE_FORMAT		0x03
195*61dfa509SRick McNeal #define	MODEPAGE_GEOMETRY	0x04
1967c478bd9Sstevel@tonic-gate #define	MODEPAGE_CACHING	0x08
1977c478bd9Sstevel@tonic-gate #define	MODEPAGE_PDEVICE	0x09
1987c478bd9Sstevel@tonic-gate #define	MODEPAGE_CTRL_MODE	0x0A
1997c478bd9Sstevel@tonic-gate #define	MODEPAGE_POWER_COND	0x1A
2007c478bd9Sstevel@tonic-gate #define	MODEPAGE_INFO_EXCPT	0x1C
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate #define	MODEPAGE_ALLPAGES	0x3F
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate /*
2057c478bd9Sstevel@tonic-gate  * Mode Select/Sense page structures (for all device types)
2067c478bd9Sstevel@tonic-gate  */
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate  * Disconnect/Reconnect Page
2107c478bd9Sstevel@tonic-gate  */
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate struct mode_disco_reco {
2137c478bd9Sstevel@tonic-gate 	struct	mode_page mode_page;	/* common mode page header */
2147c478bd9Sstevel@tonic-gate 	uchar_t	buffer_full_ratio;	/* write, how full before reconnect? */
2157c478bd9Sstevel@tonic-gate 	uchar_t	buffer_empty_ratio;	/* read, how full before reconnect? */
2167c478bd9Sstevel@tonic-gate 	ushort_t bus_inactivity_limit;	/* how much bus quiet time for BSY- */
2177c478bd9Sstevel@tonic-gate 	ushort_t disconect_time_limit;	/* min to remain disconnected */
2187c478bd9Sstevel@tonic-gate 	ushort_t connect_time_limit;	/* min to remain connected */
2197c478bd9Sstevel@tonic-gate 	ushort_t max_burst_size;	/* max data burst size */
2207c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
2217c478bd9Sstevel@tonic-gate 	uchar_t		dtdc	: 3,	/* data transfer disconenct control */
2227c478bd9Sstevel@tonic-gate 			dimm	: 1,	/* disconnect immediate */
2237c478bd9Sstevel@tonic-gate 			fastat	: 1,	/* fair for status */
2247c478bd9Sstevel@tonic-gate 			fawrt	: 1,	/* fair for write */
2257c478bd9Sstevel@tonic-gate 			fard	: 1,	/* fair for read */
2267c478bd9Sstevel@tonic-gate 			emdp	: 1;	/* enable modify data pointers */
2277c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
2287c478bd9Sstevel@tonic-gate 	uchar_t		emdp	: 1,	/* enable modify data pointers */
2297c478bd9Sstevel@tonic-gate 			fard	: 1,	/* fair for read */
2307c478bd9Sstevel@tonic-gate 			fawrt	: 1,	/* fair for write */
2317c478bd9Sstevel@tonic-gate 			fastat	: 1,	/* fair for status */
2327c478bd9Sstevel@tonic-gate 			dimm	: 1,	/* disconnect immediate */
2337c478bd9Sstevel@tonic-gate 			dtdc	: 3;	/* data transfer disconenct control */
2347c478bd9Sstevel@tonic-gate #else
2357c478bd9Sstevel@tonic-gate #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
2367c478bd9Sstevel@tonic-gate #endif	/* _BIT_FIELDS_LTOH */
2377c478bd9Sstevel@tonic-gate 	uchar_t	reserved;
2387c478bd9Sstevel@tonic-gate 	ushort_t first_burst_sz;	/* first burst size */
2397c478bd9Sstevel@tonic-gate };
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate #define	DTDC_DATADONE	0x01
2427c478bd9Sstevel@tonic-gate 					/*
2437c478bd9Sstevel@tonic-gate 					 * Target may not disconnect once
2447c478bd9Sstevel@tonic-gate 					 * data transfer is started until
2457c478bd9Sstevel@tonic-gate 					 * all data successfully transferred.
2467c478bd9Sstevel@tonic-gate 					 */
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate #define	DTDC_CMDDONE	0x03
2497c478bd9Sstevel@tonic-gate 					/*
2507c478bd9Sstevel@tonic-gate 					 * Target may not disconnect once
2517c478bd9Sstevel@tonic-gate 					 * data transfer is started until
2527c478bd9Sstevel@tonic-gate 					 * command completed.
2537c478bd9Sstevel@tonic-gate 					 */
2547c478bd9Sstevel@tonic-gate /*
2557c478bd9Sstevel@tonic-gate  * Caching Page
2567c478bd9Sstevel@tonic-gate  */
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate struct mode_caching {
2597c478bd9Sstevel@tonic-gate 	struct	mode_page mode_page;	/* common mode page header */
2607c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
2617c478bd9Sstevel@tonic-gate 	uchar_t	rcd		: 1,	/* Read Cache Disable */
2627c478bd9Sstevel@tonic-gate 		mf		: 1,	/* Multiplication Factor */
2637c478bd9Sstevel@tonic-gate 		wce		: 1,	/* Write Cache Enable */
2647c478bd9Sstevel@tonic-gate 				: 5;	/* Reserved */
2657c478bd9Sstevel@tonic-gate 	uchar_t	write_ret_prio	: 4,	/* Write Retention Priority */
2667c478bd9Sstevel@tonic-gate 		dmd_rd_ret_prio	: 4;	/* Demand Read Retention Priority */
2677c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
2687c478bd9Sstevel@tonic-gate 	uchar_t			: 5,	/* Reserved */
2697c478bd9Sstevel@tonic-gate 		wce		: 1,	/* Write Cache Enable */
2707c478bd9Sstevel@tonic-gate 		mf		: 1,	/* Multiplication Factor */
2717c478bd9Sstevel@tonic-gate 		rcd		: 1;	/* Read Cache Disable */
2727c478bd9Sstevel@tonic-gate 	uchar_t	dmd_rd_ret_prio	: 4,	/* Demand Read Retention Priority */
2737c478bd9Sstevel@tonic-gate 		write_ret_prio	: 4;	/* Write Retention Priority */
2747c478bd9Sstevel@tonic-gate #else
2757c478bd9Sstevel@tonic-gate #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
2767c478bd9Sstevel@tonic-gate #endif	/* _BIT_FIELDS_LTOH */
2777c478bd9Sstevel@tonic-gate 	ushort_t pf_dsbl_trans_len;	/* Disable prefetch transfer length */
2787c478bd9Sstevel@tonic-gate 	ushort_t min_prefetch;		/* Minimum Prefetch */
2797c478bd9Sstevel@tonic-gate 	ushort_t max_prefetch;		/* Maximum Prefetch */
2807c478bd9Sstevel@tonic-gate 	ushort_t max_prefetch_ceiling;	/* Maximum Prefetch Ceiling */
2817c478bd9Sstevel@tonic-gate };
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate /*
2847c478bd9Sstevel@tonic-gate  * Peripheral Device Page
2857c478bd9Sstevel@tonic-gate  */
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate struct mode_pdevice {
2887c478bd9Sstevel@tonic-gate 	struct	mode_page mode_page;	/* common mode page header */
2897c478bd9Sstevel@tonic-gate 	ushort_t if_ident;		/* interface identifier */
2907c478bd9Sstevel@tonic-gate 	uchar_t	reserved[4];		/* reserved */
2917c478bd9Sstevel@tonic-gate 	uchar_t	vendor_uniqe[1];	/* vendor unique data */
2927c478bd9Sstevel@tonic-gate };
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate #define	PDEV_SCSI	0x0000		/* scsi interface */
2957c478bd9Sstevel@tonic-gate #define	PDEV_SMD	0x0001		/* SMD interface */
2967c478bd9Sstevel@tonic-gate #define	PDEV_ESDI	0x0002		/* ESDI interface */
2977c478bd9Sstevel@tonic-gate #define	PDEV_IPI2	0x0003		/* IPI-2 interface */
2987c478bd9Sstevel@tonic-gate #define	PDEV_IPI3	0x0004		/* IPI-3 interface */
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate /*
3017c478bd9Sstevel@tonic-gate  * Control Mode Page
3027c478bd9Sstevel@tonic-gate  *
3037c478bd9Sstevel@tonic-gate  * Note:	This structure is incompatible with previous SCSI
3047c478bd9Sstevel@tonic-gate  *		implementations. See <scsi/impl/mode.h> for an
3057c478bd9Sstevel@tonic-gate  *		alternative form of this structure. They can be
3067c478bd9Sstevel@tonic-gate  *		distinguished by the length of data returned
3077c478bd9Sstevel@tonic-gate  *		from a MODE SENSE command.
3087c478bd9Sstevel@tonic-gate  */
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate #define	PAGELENGTH_MODE_CONTROL_SCSI3	0x0A
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate struct mode_control_scsi3 {
3137c478bd9Sstevel@tonic-gate 	struct	mode_page mode_page;	/* common mode page header */
3147c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
3157c478bd9Sstevel@tonic-gate 	uchar_t		rlec	: 1,	/* Report Log Exception bit */
3167c478bd9Sstevel@tonic-gate 			gltsd	: 1,	/* global logging target save disable */
3177c478bd9Sstevel@tonic-gate 			d_sense	: 1,	/* Use descriptor sense data (SPC-3) */
3187c478bd9Sstevel@tonic-gate 				: 5;
3197c478bd9Sstevel@tonic-gate 	uchar_t		qdisable: 1,	/* Queue disable */
3207c478bd9Sstevel@tonic-gate 			que_err	: 1,	/* Queue error */
3217c478bd9Sstevel@tonic-gate 				: 2,
3227c478bd9Sstevel@tonic-gate 			que_mod : 4;    /* Queue algorithm modifier */
3237c478bd9Sstevel@tonic-gate 	uchar_t		eanp	: 1,	/* Enable AEN permission */
3247c478bd9Sstevel@tonic-gate 			uaaenp  : 1,	/* Unit attention AEN permission */
3257c478bd9Sstevel@tonic-gate 			raenp   : 1,	/* Ready AEN permission */
3267c478bd9Sstevel@tonic-gate 				: 1,
3277c478bd9Sstevel@tonic-gate 			bybths	: 1,	/* By both RESET signal */
3287c478bd9Sstevel@tonic-gate 			byprtm	: 1,	/* By port message */
3297c478bd9Sstevel@tonic-gate 			rac	: 1,	/* report a check */
3307c478bd9Sstevel@tonic-gate 			eeca	: 1;	/* enable extended contingent */
3317c478bd9Sstevel@tonic-gate 					/* allegiance (only pre-SCSI-3) */
3327c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
3337c478bd9Sstevel@tonic-gate 	uchar_t			: 5,
3347c478bd9Sstevel@tonic-gate 			d_sense	: 1,	/* Use descriptor sense data (SPC-3) */
3357c478bd9Sstevel@tonic-gate 			gltsd	: 1,	/* global logging target save disable */
3367c478bd9Sstevel@tonic-gate 			rlec	: 1;	/* Report Log Exception bit */
3377c478bd9Sstevel@tonic-gate 	uchar_t		que_mod	: 4,	/* Queue algorithm modifier */
3387c478bd9Sstevel@tonic-gate 				: 2,
3397c478bd9Sstevel@tonic-gate 			que_err	: 1,	/* Queue error */
3407c478bd9Sstevel@tonic-gate 			qdisable: 1;	/* Queue disable */
3417c478bd9Sstevel@tonic-gate 	uchar_t		eeca	: 1,	/* enable extended contingent */
3427c478bd9Sstevel@tonic-gate 					/* allegiance (only pre-SCSI-3) */
3437c478bd9Sstevel@tonic-gate 			rac	: 1,	/* report a check */
3447c478bd9Sstevel@tonic-gate 			byprtm	: 1,	/* By port message */
3457c478bd9Sstevel@tonic-gate 			bybths	: 1,	/* By both RESET signal */
3467c478bd9Sstevel@tonic-gate 				: 1,
3477c478bd9Sstevel@tonic-gate 			raenp   : 1,	/* Ready AEN permission */
3487c478bd9Sstevel@tonic-gate 			uaaenp  : 1,	/* Unit attention AEN permission */
3497c478bd9Sstevel@tonic-gate 			eanp	: 1;	/* Enable AEN permission */
3507c478bd9Sstevel@tonic-gate #else
3517c478bd9Sstevel@tonic-gate #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
3527c478bd9Sstevel@tonic-gate #endif	/* _BIT_FIELDS_LTOH */
3537c478bd9Sstevel@tonic-gate 	uchar_t	reserved;
3547c478bd9Sstevel@tonic-gate 	ushort_t ready_aen_holdoff;	/* Ready AEN holdoff period */
3557c478bd9Sstevel@tonic-gate 	ushort_t busy_timeout;		/* Busy timeout period */
3567c478bd9Sstevel@tonic-gate 	uchar_t	reserved_2[2];
3577c478bd9Sstevel@tonic-gate };
3587c478bd9Sstevel@tonic-gate 
3595c46c6a0Spd #ifdef __lock_lint
3605c46c6a0Spd _NOTE(SCHEME_PROTECTS_DATA("Unshared SCSI payload", \
3615c46c6a0Spd 	mode_control_scsi3))
3625c46c6a0Spd #endif
3635c46c6a0Spd 
3647c478bd9Sstevel@tonic-gate #define	CTRL_QMOD_RESTRICT	0x0
3657c478bd9Sstevel@tonic-gate #define	CTRL_QMOD_UNRESTRICT	0x1
3667c478bd9Sstevel@tonic-gate 
3672c9565cfSls /*
3682c9565cfSls  * Informational Exceptions Control Mode Page
3692c9565cfSls  */
3702c9565cfSls 
3712c9565cfSls #define	PAGELENGTH_INFO_EXCPT	0x0A
3722c9565cfSls 
3732c9565cfSls struct mode_info_excpt_page {
3742c9565cfSls 	struct	mode_page mode_page;	/* common mode page header */
3752c9565cfSls #if defined(_BIT_FIELDS_LTOH)
3762c9565cfSls 	uchar_t		log_err	: 1;	/* log errors */
3772c9565cfSls 	uchar_t			: 1;	/* reserved */
3782c9565cfSls 	uchar_t		test	: 1;	/* create test failure */
3792c9565cfSls 	uchar_t		dexcpt	: 1;	/* disable exception */
3802c9565cfSls 	uchar_t		ewasc	: 1;	/* enable warning */
3812c9565cfSls 	uchar_t		ebf	: 1;	/* enable background function */
3822c9565cfSls 	uchar_t			: 1;	/* reserved */
3832c9565cfSls 	uchar_t		perf	: 1;	/* performance */
3842c9565cfSls 	uchar_t		mrie	: 4;	/* method of reporting info. excpts. */
3852c9565cfSls 	uchar_t			: 4;	/* reserved */
3862c9565cfSls #elif defined(_BIT_FIELDS_HTOL)
3872c9565cfSls 	uchar_t		perf	: 1;	/* performance */
3882c9565cfSls 	uchar_t			: 1;	/* reserved */
3892c9565cfSls 	uchar_t		ebf	: 1;	/* enable background function */
3902c9565cfSls 	uchar_t		ewasc	: 1;	/* enable warning */
3912c9565cfSls 	uchar_t		dexcpt	: 1;	/* disable exception */
3922c9565cfSls 	uchar_t		test	: 1;	/* create test failure */
3932c9565cfSls 	uchar_t			: 1;	/* reserved */
3942c9565cfSls 	uchar_t		log_err	: 1;	/* log errors */
3952c9565cfSls 	uchar_t			: 4;	/* reserved */
3962c9565cfSls 	uchar_t		mrie	: 4;	/* method of reporting info. excpts. */
3972c9565cfSls #else
3982c9565cfSls #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
3992c9565cfSls #endif
4002c9565cfSls 	uchar_t	interval_timer[4];	/* interval timer */
4012c9565cfSls 	uchar_t	report_count[4];	/* report count */
4022c9565cfSls };
4032c9565cfSls 
4042c9565cfSls #define	MRIE_NO_REPORT		0x0
4052c9565cfSls #define	MRIE_ASYNCH		0x1
4062c9565cfSls #define	MRIE_UNIT_ATTN		0x2
4072c9565cfSls #define	MRIE_COND_RECVD_ERR	0x3
4082c9565cfSls #define	MRIE_UNCOND_RECVD_ERR	0x4
4092c9565cfSls #define	MRIE_NO_SENSE		0x5
4102c9565cfSls #define	MRIE_ONLY_ON_REQUEST	0x6
4112c9565cfSls 
4122ee4dfc7SJane Chu struct mode_info_power_cond {
4132ee4dfc7SJane Chu 	struct mode_page mode_page;	/* common mode page header */
4142ee4dfc7SJane Chu 	uchar_t reserved;
4152ee4dfc7SJane Chu #if defined(_BIT_FIELDS_LTOH)
4162ee4dfc7SJane Chu 	uchar_t standby	:1,	/* standby bit */
4172ee4dfc7SJane Chu 		idle	:1,	/* idle bit */
4182ee4dfc7SJane Chu 			:6;	/* reserved */
4192ee4dfc7SJane Chu #elif defined(_BIT_FIELDS_HTOL)
4202ee4dfc7SJane Chu 	uchar_t		:6,	/* reserved */
4212ee4dfc7SJane Chu 		idle	:1,	/* idle bit */
4222ee4dfc7SJane Chu 		standby	:1;	/* standby bit */
4232ee4dfc7SJane Chu #else
4242ee4dfc7SJane Chu #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
4252ee4dfc7SJane Chu #endif
4262ee4dfc7SJane Chu 	uchar_t	idle_cond_timer_high;
4272ee4dfc7SJane Chu 	uchar_t idle_cond_timer_low;
4282ee4dfc7SJane Chu 	uchar_t standby_cond_timer[4];
4292ee4dfc7SJane Chu };
4302ee4dfc7SJane Chu 
4312ee4dfc7SJane Chu struct parameter_control {
4322ee4dfc7SJane Chu #if defined(_BIT_FIELDS_LTOH)
4332ee4dfc7SJane Chu 	uchar_t fmt_link:2,	/* format and link bit */
4342ee4dfc7SJane Chu 		tmc	:2,	/* tmc bit */
4352ee4dfc7SJane Chu 		etc	:1,	/* etc bit */
4362ee4dfc7SJane Chu 		tsd	:1,	/* tsd bit */
4372ee4dfc7SJane Chu 		reserv	:1,	/* obsolete */
4382ee4dfc7SJane Chu 		du	:1;	/* du bit */
4392ee4dfc7SJane Chu #elif defined(_BIT_FIELDS_HTOL)
4402ee4dfc7SJane Chu 	uchar_t	du	:1,	/* du bit */
4412ee4dfc7SJane Chu 		reserv	:1,	/* obsolete */
4422ee4dfc7SJane Chu 		tsd	:1,	/* tsd bit */
4432ee4dfc7SJane Chu 		etc	:1,	/* etc bit */
4442ee4dfc7SJane Chu 		tmc	:2,	/* tmc bit */
4452ee4dfc7SJane Chu 		fmt_link:2;	/* format and link bit */
4462ee4dfc7SJane Chu #else
4472ee4dfc7SJane Chu #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
4482ee4dfc7SJane Chu #endif
4492ee4dfc7SJane Chu };
4502ee4dfc7SJane Chu 
4512ee4dfc7SJane Chu struct start_stop_cycle_counter_log {
4522ee4dfc7SJane Chu #if defined(_BIT_FIELDS_LTOH)
4532ee4dfc7SJane Chu 	uchar_t code	:6,	/* page code bit */
4542ee4dfc7SJane Chu 		spf	:1,	/* spf bit */
4552ee4dfc7SJane Chu 		ds	:1;	/* ds bit */
4562ee4dfc7SJane Chu #elif defined(_BIT_FIELDS_HTOL)
4572ee4dfc7SJane Chu 	uchar_t	ds	:1,	/* ds bit */
4582ee4dfc7SJane Chu 		spf	:1,	/* spf bit */
4592ee4dfc7SJane Chu 		code	:6;	/* page code bit */
4602ee4dfc7SJane Chu #else
4612ee4dfc7SJane Chu #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
4622ee4dfc7SJane Chu #endif
4632ee4dfc7SJane Chu 	uchar_t			sub_page_code;
4642ee4dfc7SJane Chu 	uchar_t			page_len_high;
4652ee4dfc7SJane Chu 	uchar_t			page_len_low;
4662ee4dfc7SJane Chu 
4672ee4dfc7SJane Chu 	uchar_t			manufactor_date_high;
4682ee4dfc7SJane Chu 	uchar_t			manufactor_date_low;
4692ee4dfc7SJane Chu 	struct parameter_control param_1;
4702ee4dfc7SJane Chu 	uchar_t			param_len_1;
4712ee4dfc7SJane Chu 	uchar_t			year_manu[4];
4722ee4dfc7SJane Chu 	uchar_t			week_manu[2];
4732ee4dfc7SJane Chu 
4742ee4dfc7SJane Chu 	uchar_t			account_date_high;
4752ee4dfc7SJane Chu 	uchar_t			account_date_low;
4762ee4dfc7SJane Chu 	struct parameter_control param_2;
4772ee4dfc7SJane Chu 	uchar_t			param_len_2;
4782ee4dfc7SJane Chu 	uchar_t			year_account[4];
4792ee4dfc7SJane Chu 	uchar_t			week_account[2];
4802ee4dfc7SJane Chu 
4812ee4dfc7SJane Chu 	uchar_t			lifetime_code_high;
4822ee4dfc7SJane Chu 	uchar_t			lifetime_code_low;
4832ee4dfc7SJane Chu 	struct parameter_control param_3;
4842ee4dfc7SJane Chu 	uchar_t			param_len_3;
4852ee4dfc7SJane Chu 	uchar_t			cycle_lifetime[4];
4862ee4dfc7SJane Chu 
4872ee4dfc7SJane Chu 	uchar_t			cycle_code_high;
4882ee4dfc7SJane Chu 	uchar_t			cycle_code_low;
4892ee4dfc7SJane Chu 	struct parameter_control param_4;
4902ee4dfc7SJane Chu 	uchar_t			param_len_4;
4912ee4dfc7SJane Chu 	uchar_t			cycle_accumulated[4];
4922ee4dfc7SJane Chu };
4932ee4dfc7SJane Chu 
4942ee4dfc7SJane Chu 
4957c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4967c478bd9Sstevel@tonic-gate }
4977c478bd9Sstevel@tonic-gate #endif
4987c478bd9Sstevel@tonic-gate 
4997c478bd9Sstevel@tonic-gate /*
5007c478bd9Sstevel@tonic-gate  * Include known generic device specific mode definitions and structures
5017c478bd9Sstevel@tonic-gate  */
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate #include <sys/scsi/generic/dad_mode.h>
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate /*
5067c478bd9Sstevel@tonic-gate  * Include implementation specific mode information
5077c478bd9Sstevel@tonic-gate  */
5087c478bd9Sstevel@tonic-gate 
5097c478bd9Sstevel@tonic-gate #include <sys/scsi/impl/mode.h>
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate #endif	/* _SYS_SCSI_GENERIC_MODE_H */
512