xref: /illumos-gate/usr/src/uts/common/sys/fct_defines.h (revision 5422785d352a2bb398daceab3d1898a8aa64d006)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 #ifndef	_FCT_DEFINES_H
26 #define	_FCT_DEFINES_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 typedef	stmf_status_t	fct_status_t;
33 /*
34  * Error codes
35  */
36 #define	FCT_SUCCESS		STMF_SUCCESS
37 #define	FCT_FAILURE		STMF_TARGET_FAILURE
38 #define	FCT_FCA_FAILURE		(FCT_FAILURE | (uint64_t)0x0100000000000000)
39 #define	FCT_BUSY		STMF_BUSY
40 #define	FCT_ABORT_SUCCESS	STMF_ABORT_SUCCESS
41 #define	FCT_ABORTED		STMF_ABORTED
42 #define	FCT_NOT_FOUND		STMF_NOT_FOUND
43 #define	FCT_TIMEOUT		STMF_TIMEOUT
44 
45 #define	FCT_WORKER_STUCK	(FCT_FAILURE | STMF_FSC(1))
46 #define	FCT_ALLOC_FAILURE	(FCT_FAILURE | STMF_FSC(2))
47 #define	FCT_LOCAL_PORT_OFFLINE	(FCT_FAILURE | STMF_FSC(3))
48 #define	FCT_NO_XCHG_RESOURCE	(FCT_FAILURE | STMF_FSC(4))
49 #define	FCT_NOT_LOGGED_IN	(FCT_FAILURE | STMF_FSC(5))
50 #define	FCT_ABTS_RECEIVED	(FCT_FAILURE | STMF_FSC(6))
51 #define	FCT_RPORT_SENT_REJECT	(FCT_FAILURE | STMF_FSC(7))
52 
53 #define	FCT_REJECT_STATUS(reason, expln)	\
54 	(FCT_RPORT_SENT_REJECT | (((uint64_t)(reason)) << 8) | \
55 	    ((uint64_t)(expln)))
56 
57 /*
58  * Event codes
59  */
60 #define	FCT_EVENT_LINK_UP	0x01
61 #define	FCT_EVENT_LINK_DOWN	0x02
62 #define	FCT_EVENT_LINK_RESET	0x03
63 #define	FCT_EVENT_ADAPTER_FATAL	0x04
64 
65 /*
66  * ELS OP codes
67  */
68 #define	ELS_OP_LSRJT		0x01
69 #define	ELS_OP_ACC		0x02
70 #define	ELS_OP_PLOGI		0x03
71 #define	ELS_OP_FLOGI		0x04
72 #define	ELS_OP_LOGO		0x05
73 #define	ELS_OP_ABTX		0x06
74 #define	ELS_OP_RLS		0x0f
75 #define	ELS_OP_ECHO		0x10
76 #define	ELS_OP_REC		0x13
77 #define	ELS_OP_SRR		0x14
78 #define	ELS_OP_PRLI		0x20
79 #define	ELS_OP_PRLO		0x21
80 #define	ELS_OP_SCN		0x22
81 #define	ELS_OP_TPRLO		0x24
82 #define	ELS_OP_PDISC		0x50
83 #define	ELS_OP_ADISC		0x52
84 #define	ELS_OP_RSCN		0x61
85 #define	ELS_OP_SCR		0x62
86 #define	ELS_OP_RNID		0x78
87 
88 /*
89  * BLS replies
90  */
91 #define	BLS_OP_BA_ACC		0x84
92 #define	BLS_OP_BA_RJT		0x85
93 
94 /*
95  * Name Service Command Codes
96  */
97 #define	NS_GA_NXT		0x0100	/* Get All next */
98 #define	NS_GPN_ID		0x0112	/* Get Port Name */
99 #define	NS_GNN_ID		0x0113	/* Get Node Name */
100 #define	NS_GCS_ID		0x0114	/* Get Class Of service */
101 #define	NS_GFT_ID		0x0117	/* Get FC-4 Types */
102 #define	NS_GSPN_ID		0x0118	/* Get Sym Port name */
103 #define	NS_GPT_ID		0x011A	/* Get Port Type */
104 #define	NS_GID_PN		0x0121	/* Get port id for PN */
105 #define	NS_GID_NN		0x0131	/* Get port id for NN */
106 #define	NS_GIP_NN		0x0135	/* Get IP address */
107 #define	NS_GIPA_NN		0x0136	/* Get I.P.A */
108 #define	NS_GSNN_NN		0x0139	/* Get Sym Node name */
109 #define	NS_GNN_IP		0x0153	/* Get Node name for IP */
110 #define	NS_GIPA_IP		0x0156	/* Get I.P.A for IP */
111 #define	NS_GID_FT		0x0171	/* Get port Id for FC-4 type */
112 #define	NS_GID_PT		0x01A1	/* Get port Id for type */
113 #define	NS_RPN_ID		0x0212	/* Reg port name */
114 #define	NS_RNN_ID		0x0213	/* Reg node name */
115 #define	NS_RCS_ID		0x0214	/* Reg C.O.S */
116 #define	NS_RFT_ID		0x0217	/* Reg FC-4 Types */
117 #define	NS_RSPN_ID		0x0218	/* Reg Sym Port name */
118 #define	NS_RPT_ID		0x021A	/* Reg Port Type */
119 #define	NS_RIP_NN		0x0235	/* Reg I.P address */
120 #define	NS_RIPA_NN		0x0236	/* Reg I.P.A */
121 #define	NS_RSNN_NN		0x0239	/* Reg Sym Node name */
122 #define	NS_DA_ID		0x0300	/* De-Register all */
123 
124 #define	CT_OP_RJT		0x8001
125 #define	CT_OP_ACC		0x8002
126 
127 /*
128  * PRLI bits
129  */
130 #define	PRLI_BIT_WRITE_XRDY_DISABLED		0x00000001
131 #define	PRLI_BIT_READ_XRDY_DISABLED		0x00000002
132 #define	PRLI_BIT_TARGET_FUNCTION		0x00000010
133 #define	PRLI_BIT_INITIATOR_FUNCTION		0x00000020
134 #define	PRLI_BIT_DATA_OVERLAY_ALLOWED		0x00000040
135 #define	PRLI_BIT_FCP_CONF_ALLOWED		0x00000080
136 #define	PRLI_BIT_RETRY				0x00000100
137 #define	PRLI_BIT_TASK_RETRY_IDENT_REQUESTED	0x00000200
138 #define	PRLI_BIT_REC_SUPPORT			0x00000400
139 
140 #define	FC_NS_CLASSF		0x01
141 #define	FC_NS_CLASS1		0x02
142 #define	FC_NS_CLASS2		0x04
143 #define	FC_NS_CLASS3		0x08
144 #define	FC_NS_CLASS4		0x10
145 #define	FC_NS_CLASS5		0x20
146 #define	FC_NS_CLASS6		0x40
147 
148 /*
149  * SCR function code
150  */
151 #define	FC_SCR_FABRIC_REGISTRATION	0x01
152 #define	FC_SCR_NPORT_REGISTRATION	0x02
153 #define	FC_SCR_FULL_REGISTRATION	0x03
154 #define	FC_SCR_CLEAR_REGISTRATION	0xFF
155 
156 /*
157  * FCP_CNTL bits
158  */
159 #define	FCP_CNTL_TASK_ATTR(fcp_cntl)	((((uint32_t)(fcp_cntl)) >> 16) & 7)
160 #define	TASK_ATTR_SIMPLE_Q		0
161 #define	TASK_ATTR_HEAD_OF_Q		1
162 #define	TASK_ATTR_ORDERED_Q		2
163 #define	TASK_ATTR_ACA_Q			4
164 #define	TASK_ATTR_UNTAGGED		5
165 #define	FCP_CNTL_IS_TASK_MGMT(fcp_cntl)	(((uint32_t)(fcp_cntl)) & 0xff00)
166 #define	FCP_CNTL_TERMINATE_TASK		0x8000
167 #define	FCP_CNTL_CLEAR_ACA		0x4000
168 #define	FCP_CNTL_TARGET_RESET		0x2000
169 #define	FCP_CNTL_LUN_RESET		0x1000
170 #define	FCP_CNTL_CLEAR_TASK_SET		0x0400
171 #define	FCP_CNTL_ABORT_TASK_SET		0x0200
172 #define	FCP_CNTL_READ_DATA		0x2
173 #define	FCP_CNTL_WRITE_DATA		0x1
174 
175 /*
176  * SCSI STATUS BITS
177  */
178 #define	FCP_BIDI_RESP		0x8000
179 #define	FCP_BIDI_UNDER		0x4000
180 #define	FCP_BIDI_OVER		0x2000
181 #define	FCP_CONF_REQ		0x1000
182 #define	FCP_RESID_UNDER		0x0800
183 #define	FCP_RESID_OVER		0x0400
184 #define	FCP_SNS_LEN_VALID	0x0200
185 #define	FCP_RESP_LEN_VALID	0x0100
186 
187 /*
188  * Well known addresses ...
189  */
190 #define	NPORT_ID_DOM_CTLR_START	0xFFFC01
191 #define	NPORT_ID_DOM_CTLR_END	0xFFFCFE
192 
193 #define	FS_GENERAL_MULTICAST	0xFFFFF7
194 #define	FS_WELL_KNOWN_MULTICAST	0xFFFFF8
195 #define	FS_HUNT_GROUP		0xFFFFF9
196 #define	FS_MANAGEMENT_SERVER	0xFFFFFA
197 #define	FS_TIME_SERVER		0xFFFFFB
198 #define	FS_NAME_SERVER		0xFFFFFC
199 #define	FS_FABRIC_CONTROLLER	0xFFFFFD
200 #define	FS_FABRIC_F_PORT	0xFFFFFE
201 #define	FS_BROADCAST		0xFFFFFF
202 
203 #define	FC_WELL_KNOWN_START	0xFFFFF0
204 #define	FC_WELL_KNOWN_END	0xFFFFFF
205 #define	FC_WELL_KNOWN_ADDR(x)	\
206 	((((x) >= FC_WELL_KNOWN_START) && ((x) <= FC_WELL_KNOWN_END)) ||\
207 	(((x) >= NPORT_ID_DOM_CTLR_START) && ((x) <= NPORT_ID_DOM_CTLR_END)))
208 
209 #define	FC_WWN_LEN		8
210 /*
211  * NB: FC_WWN_BUFLEN should be 64-bit aligned (divisible by 8).
212  */
213 #define	FC_WWN_BUFLEN		(FC_WWN_LEN * 3)
214 #define	FC_WWN_STRLEN		(FC_WWN_BUFLEN - 1)	/* add trailing null */
215 
216 struct fct_cmd;
217 struct fct_local_port;
218 struct fct_els;
219 struct fct_link_info;
220 struct fct_flogi_xchg;
221 struct fct_dbuf_store;
222 
223 #ifdef	__cplusplus
224 }
225 #endif
226 
227 #endif /* _FCT_DEFINES_H */
228