xref: /titanic_44/usr/src/uts/common/sys/scsi/generic/message.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1996,2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SCSI_GENERIC_MESSAGE_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_SCSI_GENERIC_MESSAGE_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate  * Defined Messages For Parallel SCSI.
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate /*
41*7c478bd9Sstevel@tonic-gate  * The SCSI specification defines message codes 0x00, 0x02-0x1F,
42*7c478bd9Sstevel@tonic-gate  * as fixed single byte messages, 0x01 as indicating extended (multi-byte)
43*7c478bd9Sstevel@tonic-gate  * messages, 0x20-0x2F as fixed two byte messages, and 0x80-0xFF
44*7c478bd9Sstevel@tonic-gate  * as IDENTIFY messages.
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #define	MSG_COMMAND_COMPLETE	0x00
48*7c478bd9Sstevel@tonic-gate #define	MSG_SAVE_DATA_PTR	0x02
49*7c478bd9Sstevel@tonic-gate #define	MSG_RESTORE_PTRS	0x03
50*7c478bd9Sstevel@tonic-gate #define	MSG_DISCONNECT		0x04
51*7c478bd9Sstevel@tonic-gate #define	MSG_INITIATOR_ERROR	0x05
52*7c478bd9Sstevel@tonic-gate #define	MSG_ABORT		0x06
53*7c478bd9Sstevel@tonic-gate #define	MSG_REJECT		0x07
54*7c478bd9Sstevel@tonic-gate #define	MSG_NOP			0x08
55*7c478bd9Sstevel@tonic-gate #define	MSG_MSG_PARITY		0x09
56*7c478bd9Sstevel@tonic-gate #define	MSG_LINK_CMPLT		0x0A
57*7c478bd9Sstevel@tonic-gate #define	MSG_LINK_CMPLT_FLAG	0x0B
58*7c478bd9Sstevel@tonic-gate #define	MSG_DEVICE_RESET	0x0C
59*7c478bd9Sstevel@tonic-gate #define	MSG_ABORT_TAG		0x0D
60*7c478bd9Sstevel@tonic-gate #define	MSG_CLEAR_QUEUE		0x0E
61*7c478bd9Sstevel@tonic-gate #define	MSG_INITIATE_RECOVERY	0x0F
62*7c478bd9Sstevel@tonic-gate #define	MSG_RELEASE_RECOVERY	0x10
63*7c478bd9Sstevel@tonic-gate #define	MSG_TERMINATE_PROCESS	0x11
64*7c478bd9Sstevel@tonic-gate #define	MSG_CONTINUE_TASK	0x12
65*7c478bd9Sstevel@tonic-gate #define	MSG_TARGET_TRAN_DIS	0x13
66*7c478bd9Sstevel@tonic-gate #define	MSG_CLEAR_ACA		0x16
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate /*
70*7c478bd9Sstevel@tonic-gate  * Message code 0x01 indicates an extended
71*7c478bd9Sstevel@tonic-gate  * (two or more) byte message. The EXTENDED
72*7c478bd9Sstevel@tonic-gate  * message byte is followed immediately by
73*7c478bd9Sstevel@tonic-gate  * a message length byte and then an extended
74*7c478bd9Sstevel@tonic-gate  * message code byte.
75*7c478bd9Sstevel@tonic-gate  *
76*7c478bd9Sstevel@tonic-gate  * Note: The EXTENDED IDENTIFY message is pre-SCSI-2.
77*7c478bd9Sstevel@tonic-gate  */
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate #define	MSG_EXTENDED		0x01
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate #define	MSG_MODIFY_DATA_PTR	0x00
82*7c478bd9Sstevel@tonic-gate #define	MSG_SYNCHRONOUS		0x01
83*7c478bd9Sstevel@tonic-gate #define	MSG_IDENTIFY_EXTENDED	0x02
84*7c478bd9Sstevel@tonic-gate #define	MSG_WIDE_DATA_XFER	0x03
85*7c478bd9Sstevel@tonic-gate #define	MSG_PARALLEL_PROTOCOL	0x04
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate  * parallel protocol message optional flags
89*7c478bd9Sstevel@tonic-gate  */
90*7c478bd9Sstevel@tonic-gate #define	OPT_IU			0x01
91*7c478bd9Sstevel@tonic-gate #define	OPT_DT			0x02
92*7c478bd9Sstevel@tonic-gate #define	OPT_QAS_REQ		0x04
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate /*
95*7c478bd9Sstevel@tonic-gate  * Message codes 0x20-0x2F are fixed two byte messages.
96*7c478bd9Sstevel@tonic-gate  */
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate #define	MSG_SIMPLE_QTAG		0x20
100*7c478bd9Sstevel@tonic-gate #define	MSG_HEAD_QTAG		0x21
101*7c478bd9Sstevel@tonic-gate #define	MSG_ORDERED_QTAG	0x22
102*7c478bd9Sstevel@tonic-gate #define	MSG_IGNORE_WIDE_RESID	0x23
103*7c478bd9Sstevel@tonic-gate #define	MSG_ACA			0x24
104*7c478bd9Sstevel@tonic-gate #define	MSG_LUN_RESET		0x25
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /*
107*7c478bd9Sstevel@tonic-gate  * Codes 0x80-0xFF are identify messages, indicated
108*7c478bd9Sstevel@tonic-gate  * by the setting of the most significant bit in the
109*7c478bd9Sstevel@tonic-gate  * message (0x80).
110*7c478bd9Sstevel@tonic-gate  */
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate #define	MSG_IDENTIFY		0x80
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate /*
115*7c478bd9Sstevel@tonic-gate  * Initiators will set bit 6 in an Identify message
116*7c478bd9Sstevel@tonic-gate  * to indicate whether or not they can accommodate
117*7c478bd9Sstevel@tonic-gate  * disconnect/reconnect
118*7c478bd9Sstevel@tonic-gate  */
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate #define	INI_CAN_DISCON		0x40
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*
123*7c478bd9Sstevel@tonic-gate  * ..so we can have a compound definition
124*7c478bd9Sstevel@tonic-gate  * for Initiators that can accommodate
125*7c478bd9Sstevel@tonic-gate  * disconnect/reconnect
126*7c478bd9Sstevel@tonic-gate  */
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate #define	MSG_DR_IDENTIFY		(MSG_IDENTIFY|INI_CAN_DISCON)
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate /*
131*7c478bd9Sstevel@tonic-gate  * Note: Following is ONLY applicable to pre-SCSI-3.
132*7c478bd9Sstevel@tonic-gate  *
133*7c478bd9Sstevel@tonic-gate  * Bit 5 of the identify message specifies that, if zero,
134*7c478bd9Sstevel@tonic-gate  * that the IDENTIFY message is directed to a logical unit,
135*7c478bd9Sstevel@tonic-gate  * and if one, that the IDENTIFY message is directed to a
136*7c478bd9Sstevel@tonic-gate  * target routine that does not involve a logical unit.
137*7c478bd9Sstevel@tonic-gate  */
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate #define	MSG_LUNTAR		0x20
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate /*
142*7c478bd9Sstevel@tonic-gate  * Note: Following is ONLY applicable to pre-SCSI-3.
143*7c478bd9Sstevel@tonic-gate  *
144*7c478bd9Sstevel@tonic-gate  * Bits 2-0 identify either the logical unit or the target
145*7c478bd9Sstevel@tonic-gate  * routine number based upon whether MSG_LUNTAR is clear
146*7c478bd9Sstevel@tonic-gate  * or set.
147*7c478bd9Sstevel@tonic-gate  */
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate #define	MSG_LUNRTN		0x07
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate /*
152*7c478bd9Sstevel@tonic-gate  * Note: Following is ONLY applicable to pre-SCSI-3.
153*7c478bd9Sstevel@tonic-gate  *
154*7c478bd9Sstevel@tonic-gate  * Bits 4-3 are reserved and must be zero.
155*7c478bd9Sstevel@tonic-gate  */
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate #define	BAD_IDENTIFY		0x18
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /*
160*7c478bd9Sstevel@tonic-gate  * These macros may be useful to quickly determine the
161*7c478bd9Sstevel@tonic-gate  * length of a message based upon the message code.
162*7c478bd9Sstevel@tonic-gate  */
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate /*
165*7c478bd9Sstevel@tonic-gate  * Note: IS_IDENTIFY_MSG is ONLY applicable to pre-SCSI-3.
166*7c478bd9Sstevel@tonic-gate  *	 For SCSI-3, use IS_IDENTIFY_MSG_SCSI3.
167*7c478bd9Sstevel@tonic-gate  */
168*7c478bd9Sstevel@tonic-gate #define	IS_IDENTIFY_MSG(msg)	\
169*7c478bd9Sstevel@tonic-gate 	(((msg) & MSG_IDENTIFY) && !((msg) & BAD_IDENTIFY))
170*7c478bd9Sstevel@tonic-gate #define	IS_IDENTIFY_MSG_SCSI3(msg)	((msg) & MSG_IDENTIFY)
171*7c478bd9Sstevel@tonic-gate #define	IS_EXTENDED_MSG(msg)	((msg) == MSG_EXTENDED)
172*7c478bd9Sstevel@tonic-gate #define	IS_2BYTE_MSG(msg)	(((msg) & 0xF0) == 0x20)
173*7c478bd9Sstevel@tonic-gate #define	IS_1BYTE_MSG(msg)	(!(IS_EXTENDED_MSG((msg))) && \
174*7c478bd9Sstevel@tonic-gate 	((((msg) & 0xF0) == 0) || IS_IDENTIFY_MSG((msg))))
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
177*7c478bd9Sstevel@tonic-gate }
178*7c478bd9Sstevel@tonic-gate #endif
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_SCSI_GENERIC_MESSAGE_H */
181