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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_FC_ERROR_H
27 #define	_FC_ERROR_H
28 
29 #include <sys/note.h>
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * If there are a good set of status, reason (may be action, expln)
37  * values, an FC_FAILURE function return code should be enough.
38  * Otherwise pick and choose your favorite from here. Try consulting
39  * the transport programming guide for any help. If that doesn't help,
40  * watch the blue sky.
41  *
42  * Geez, FC_ is already in use in vm/faultcode.h. Hope it won't grow
43  * much. The FC_NOMAP is already a defined Value there. So defining
44  * FC_NOMAP as FC_NO_MAP here. Remember to keep a tab on faultcode.h
45  *
46  */
47 #define	FC_FAILURE		-1	/* general failure */
48 #define	FC_FAILURE_SILENT	-2	/* general failure but fail silently */
49 #define	FC_SUCCESS		0x00	/* successful completion */
50 #define	FC_CAP_ERROR		0x01	/* FCA capability error */
51 #define	FC_CAP_FOUND		0x02	/* FCA capability unsettable */
52 #define	FC_CAP_SETTABLE		0x03	/* FCA capability settable */
53 #define	FC_UNBOUND		0x04	/* unbound stuff */
54 #define	FC_NOMEM		0x05	/* allocation error */
55 #define	FC_BADPACKET		0x06	/* invalid packet specified/supplied */
56 #define	FC_OFFLINE		0x07	/* I/O resource unavailable */
57 #define	FC_OLDPORT		0x08	/* operation on non-loop port */
58 #define	FC_NO_MAP		0x09	/* requested map unavailable */
59 #define	FC_TRANSPORT_ERROR	0x0A	/* unable to transport I/O */
60 #define	FC_ELS_FREJECT		0x0B	/* ELS rejected by a Fabric */
61 #define	FC_ELS_PREJECT		0x0C	/* ELS rejected by an N_port */
62 #define	FC_ELS_BAD		0x0D	/* ELS rejected by FCA/fctl */
63 #define	FC_ELS_MALFORMED	0x0E	/* poorly formed ELS request */
64 #define	FC_TOOMANY		0x0F	/* resource request too large */
65 #define	FC_UB_BADTOKEN		0x10	/* invalid unsolicited buffer token */
66 #define	FC_UB_ERROR		0x11	/* invalid unsol buf request */
67 #define	FC_UB_BUSY		0x12	/* buffer already in use */
68 #define	FC_BADULP		0x15	/* Unknown ulp */
69 #define	FC_BADTYPE		0x16	/* ULP not registered to */
70 					/* handle this FC4 type */
71 #define	FC_UNCLAIMED		0x17	/* request or data not claimed */
72 #define	FC_ULP_SAMEMODULE	0x18	/* module already in use */
73 #define	FC_ULP_SAMETYPE		0x19	/* FC4 module already in use */
74 #define	FC_ABORTED		0x20	/* request aborted */
75 #define	FC_ABORT_FAILED		0x21	/* abort request failed */
76 #define	FC_BADEXCHANGE		0x22	/* exchange doesn�t exist */
77 #define	FC_BADWWN		0x23	/* WWN not recognized */
78 #define	FC_BADDEV		0x24	/* device unrecognized */
79 #define	FC_BADCMD		0x25	/* invalid command issued */
80 #define	FC_BADOBJECT		0x26	/* invalid object requested */
81 #define	FC_BADPORT		0x27	/* invalid port specified */
82 #define	FC_NOTTHISPORT		0x30	/* resource not at this port */
83 #define	FC_PREJECT		0x31	/* reject at remote N_Port */
84 #define	FC_FREJECT		0x32	/* reject at remote Fabric */
85 #define	FC_PBUSY		0x33	/* remote N_Port busy */
86 #define	FC_FBUSY		0x34	/* remote Fabric busy */
87 #define	FC_ALREADY		0x35	/* already logged in */
88 #define	FC_LOGINREQ		0x36	/* login required */
89 #define	FC_RESETFAIL		0x37	/* reset failed */
90 #define	FC_INVALID_REQUEST	0x38	/* request is invalid */
91 #define	FC_OUTOFBOUNDS		0x39	/* port number is out of bounds */
92 #define	FC_TRAN_BUSY		0x40	/* command transport busy */
93 #define	FC_STATEC_BUSY		0x41	/* port driver currently busy */
94 #define	FC_DEVICE_BUSY		0x42	/* transport working on this device */
95 #define	FC_DEVICE_NOT_TGT	0x43    /* try to send command to non target */
96 #define	FC_DEVICE_BUSY_NEW_RSCN	0x44	/* transport has a new(er) RSCN */
97 #define	FC_INVALID_LUN		0x45	/* invalid logical unit number */
98 #define	FC_NPIV_FDISC_FAILED	0x46	/* FDISC command for the port failed */
99 #define	FC_NPIV_FDISC_WWN_INUSE	0x47	/* NPIV WWN is already in used */
100 #define	FC_NPIV_NOT_SUPPORTED	0x48	/* HBA does not support NPIV */
101 #define	FC_NPIV_WRONG_TOPOLOGY	0x49	/* Topology does not support NPIV */
102 
103 
104 
105 /*
106  * pkt state definitions
107  */
108 #define	FC_PKT_SUCCESS		0x01
109 #define	FC_PKT_REMOTE_STOP	0x02
110 #define	FC_PKT_LOCAL_RJT	0x03
111 #define	FC_PKT_NPORT_RJT	0x04
112 #define	FC_PKT_FABRIC_RJT	0x05
113 #define	FC_PKT_LOCAL_BSY	0x06
114 #define	FC_PKT_TRAN_BSY		0x07
115 #define	FC_PKT_NPORT_BSY	0x08
116 #define	FC_PKT_FABRIC_BSY	0x09
117 #define	FC_PKT_LS_RJT		0x0A
118 #define	FC_PKT_BA_RJT		0x0B
119 #define	FC_PKT_TIMEOUT		0x0C
120 #define	FC_PKT_FS_RJT		0x0D
121 #define	FC_PKT_TRAN_ERROR	0x0E
122 #define	FC_PKT_FAILURE		0x0F
123 #define	FC_PKT_PORT_OFFLINE	0x10
124 #define	FC_PKT_ELS_IN_PROGRESS	0x11	/* ELS in progress */
125 
126 /*
127  * pkt_reason for REMOTE_STOP
128  */
129 #define	FC_REASON_ABTS		0x00
130 #define	FC_REASON_ABTX		0x01
131 
132 /*
133  * pkt_reason (except for state = NPORT_RJT, FABRIC_RJT, NPORT_BSY,
134  *     FABRIC_BSY, LS_RJT, BA_RJT, FS_RJT)
135  *
136  * FCA unique error codes can begin after
137  * FC_REASON_FCA_UNIQUE. Each FCA defines its
138  * own set with values greater >= 0x7F
139  */
140 #define	FC_REASON_HW_ERROR		0x01
141 #define	FC_REASON_SEQ_TIMEOUT		0x02
142 #define	FC_REASON_ABORTED		0x03
143 #define	FC_REASON_ABORT_FAILED		0x04
144 #define	FC_REASON_NO_CONNECTION		0x05
145 #define	FC_REASON_XCHG_DROPPED		0x06
146 #define	FC_REASON_ILLEGAL_FRAME		0x07
147 #define	FC_REASON_ILLEGAL_LENGTH	0x08
148 #define	FC_REASON_UNSUPPORTED		0x09
149 #define	FC_REASON_RX_BUF_TIMEOUT	0x0A
150 #define	FC_REASON_FCAL_OPN_FAIL		0x0B
151 #define	FC_REASON_OVERRUN		0x0C
152 #define	FC_REASON_QFULL			0x0D
153 #define	FC_REASON_ILLEGAL_REQ		0x0E
154 #define	FC_REASON_PKT_BUSY		0x0F
155 #define	FC_REASON_OFFLINE		0x11
156 #define	FC_REASON_BAD_XID		0x12
157 #define	FC_REASON_XCHG_BSY		0x13
158 #define	FC_REASON_NOMEM			0x14
159 #define	FC_REASON_BAD_SID		0x15
160 #define	FC_REASON_NO_SEQ_INIT		0x16
161 #define	FC_REASON_DIAG_BUSY		0x17
162 #define	FC_REASON_DMA_ERROR		0x18
163 #define	FC_REASON_CRC_ERROR		0x19
164 #define	FC_REASON_ABORT_TIMEOUT		0x1A
165 #define	FC_REASON_UNDERRUN		0x1B
166 #define	FC_REASON_FCA_UNIQUE		0x7E
167 
168 /*
169  * pkt_reason for FABRIC_RJT and NPORT_RJT
170  *
171  * +--------------------------------------------+
172  * | F_RJT Specific        P_RJT Specific       |
173  * +--------------------------------------------+
174  * | INVALID_D_ID          INVALID_D_ID         |
175  * | INVALID_S_ID          INVALID_S_ID         |
176  * | NPORT_NOT_AVAIL_TEMP                       |
177  * | NPORT_NOT_AVAIL_PERM                       |
178  * | CLASS_NOT_SUPPORTED   CLASS_NOT_SUPPORTED  |
179  * | DELIMITER_ERROR       DELIMITER_ERROR      |
180  * | TYPE_NOT_SUPPORTED    TYPE_NOT_SUPPORTED   |
181  * |                       INVALID_LINK_CONTROL |
182  * |                       INVALID_R_CTL        |
183  * |                       INVALID_F_CTL        |
184  * |                       INVALID_OX_ID        |
185  * |                       INVALID_RX_ID        |
186  * |                       INVALID_SEQ_ID       |
187  * |                       INVALID_DF_CTL       |
188  * |                       INVALID_SEQ_CNT      |
189  * |                       INVALID_PARAMETER    |
190  * |                       EXCHANGE_ERROR       |
191  * | PROTOCOL_ERROR        PROTOCOL_ERROR       |
192  * | INCORRECT_LENGTH      INCORRECT_LENGTH     |
193  * |                       UNEXPECTED_ACK       |
194  * | LOGIN_REQUIRED        LOGIN_REQUIRED       |
195  * |                       EXCESSIVE_SEQUENCES  |
196  * |                       CANT_ESTABLISH_EXCH  |
197  * |                       SECURITY_NOT_SUPP    |
198  * | NO_FABRIC_PATH                             |
199  * | VENDOR_UNIQUE         VENDOR_UNIQUE        |
200  * +--------------------------------------------+
201  *
202  */
203 #define	FC_REASON_INVALID_D_ID			0x01
204 #define	FC_REASON_INVALID_S_ID			0x02
205 #define	FC_REASON_TEMP_UNAVAILABLE		0x03
206 #define	FC_REASON_PERM_UNAVAILABLE		0x04
207 #define	FC_REASON_CLASS_NOT_SUPP		0x05
208 #define	FC_REASON_DELIMTER_USAGE_ERROR		0x06
209 #define	FC_REASON_TYPE_NOT_SUPP			0x07
210 #define	FC_REASON_INVALID_LINK_CTRL		0x08
211 #define	FC_REASON_INVALID_R_CTL			0x09
212 #define	FC_REASON_INVALID_F_CTL			0x0A
213 #define	FC_REASON_INVALID_OX_ID			0x0B
214 #define	FC_REASON_INVALID_RX_ID			0x0C
215 #define	FC_REASON_INVALID_SEQ_ID		0x0D
216 #define	FC_REASON_INVALID_DF_CTL		0x0E
217 #define	FC_REASON_INVALID_SEQ_CNT		0x0F
218 #define	FC_REASON_INVALID_PARAM			0x10
219 #define	FC_REASON_EXCH_ERROR			0x11
220 #define	FC_REASON_PROTOCOL_ERROR		0x12
221 #define	FC_REASON_INCORRECT_LENGTH		0x13
222 #define	FC_REASON_UNEXPECTED_ACK		0x14
223 #define	FC_REASON_UNEXPECTED_LR			0x15
224 #define	FC_REASON_LOGIN_REQUIRED		0x16
225 #define	FC_REASON_EXCESSIVE_SEQS		0x17
226 #define	FC_REASON_EXCH_UNABLE			0x18
227 #define	FC_REASON_ESH_NOT_SUPP			0x19
228 #define	FC_REASON_NO_FABRIC_PATH		0x1A
229 #define	FC_REASON_VENDOR_UNIQUE			0xFF
230 
231 /*
232  * pkt_reason for NPORT_BSY
233  */
234 #define	FC_REASON_PHYSICAL_BUSY			0x01
235 #define	FC_REASON_N_PORT_RESOURCE_BSY	0x03
236 #define	FC_REASON_N_PORT_VENDOR_UNIQUE	0xFF
237 
238 /*
239  * pkt_reason for FABRIC_BSY
240  */
241 #define	FC_REASON_FABRIC_BSY			0x01
242 #define	FC_REASON_N_PORT_BSY			0x03
243 
244 /*
245  * pkt_reason for LS_RJT
246  * pkt_reason for BA_RJT
247  */
248 #define	FC_REASON_INVALID_LA_CODE		0x01
249 #define	FC_REASON_LOGICAL_ERROR			0x03
250 #define	FC_REASON_LOGICAL_BSY			0x05
251 #define	FC_REASON_PROTOCOL_ERROR_RJT		0x07
252 #define	FC_REASON_CMD_UNABLE			0x09
253 #define	FC_REASON_CMD_UNSUPPORTED		0x0B
254 #define	FC_REASON_VU_RJT			0xFF
255 
256 /*
257  * pkt_reason for FS_RJT
258  */
259 #define	FC_REASON_FS_INVALID_CMD		0x01
260 #define	FC_REASON_FS_INVALID_VER		0x02
261 #define	FC_REASON_FS_LOGICAL_ERR		0x03
262 #define	FC_REASON_FS_INVALID_IUSIZE		0x04
263 #define	FC_REASON_FS_LOGICAL_BUSY		0x05
264 #define	FC_REASON_FS_PROTOCOL_ERR		0x07
265 #define	FC_REASON_FS_CMD_UNABLE			0x09
266 #define	FC_REASON_FS_CMD_UNSUPPORTED		0x0B
267 #define	FC_REASON_FS_VENDOR_UNIQUE		0xFF
268 
269 /*
270  * pkt_action for NPORT_BUSY
271  */
272 #define	FC_ACTION_SEQ_TERM_RETRY		0x01
273 #define	FC_ACTION_SEQ_ACTIVE_RETRY		0x02
274 
275 /*
276  * pkt_action codes for NPORT_RJT, FABRIC_RJT
277  * and TIMEOUT
278  */
279 #define	FC_ACTION_RETRYABLE			0x01
280 #define	FC_ACTION_NON_RETRYABLE			0x02
281 
282 /*
283  * pkt_action codes for reason FC_REASON_ABORT_TIMEOUT
284  */
285 #define	FC_ACTION_FREE_PACKET			0x01
286 #define	FC_ACTION_DONT_FREE_PACKET		0x02
287 
288 /*
289  * pkt_expln codes for BA_RJT
290  */
291 #define	FC_EXPLN_NONE				0x00
292 #define	FC_EXPLN_INVALID_OX_RX_ID		0x03
293 #define	FC_EXPLN_SEQ_ABORTED			0x05
294 
295 #ifdef	__cplusplus
296 }
297 #endif
298 
299 #endif	/* _FC_ERROR_H */
300