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