xref: /illumos-gate/usr/src/uts/common/sys/fc4/fcal.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
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) 1995-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_FC4_FCAL_H
28 #define	_SYS_FC4_FCAL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Fibre Channel Physical and Signaling Interface (FC-PH) definitions.
36  *
37  * NOTE: modifications of this file affect drivers, mpsas models, PLUTO
38  *	firmware, SOC assembly code. Please be communicative.
39  */
40 
41 #define	FC_PH_VERSION	0x06	/* 0x06 means 4.0 ! */
42 #define	MAX_FRAME_SIZE	2112	/* maximum size of frame payload */
43 
44 /*
45  * This is the standard frame header for FC-PH frames.
46  */
47 
48 typedef struct FC2_FRAME_HDR {
49 	uint_t	r_ctl:8,	d_id:24;
50 	uint_t	reserved1:8,	s_id:24;
51 	uint_t	type:8,		f_ctl:24;
52 	uint_t	seq_id:8,	df_ctl:8,	seq_cnt:16;
53 	uint16_t	ox_id, rx_id;
54 	uint32_t	ro;
55 }aFC2_FRAME_HDR, *FC2_FRAME_HDRptr, fc_frame_header_t;
56 
57 #define	WE_ARE_ORIGINATOR(fh)		(fh->f_ctl & F_CTL_XCHG_CONTEXT)
58 #define	UNSOLICITED_FRAME(fh)		(fh->rx_id == 0xffff)
59 #define	FIRST_SEQUENCE(fh)		(fh->f_ctl & F_CTL_FIRST_SEQ)
60 #define	LAST_FRAME_OF_SEQUENCE(fh)	(fh->f_ctl & F_CTL_END_SEQ)
61 #define	LAST_SEQUENCE_OF_EXCHANGE(fh)	(fh->f_ctl & F_CTL_LAST_SEQ)
62 #define	TRANSFER_INITIATIVE(fh)		(fh->f_ctl & F_CTL_SEQ_INITIATIVE)
63 
64 
65 /* legal values for r_ctl */
66 #define	R_CTL_ROUTING		0xf0 /* mask for routing bits */
67 #define	R_CTL_INFO		0x0f /* mask for information bits */
68 
69 #define	R_CTL_DEVICE_DATA	0x00 /* all I/O related frames */
70 #define	R_CTL_EXTENDED_SVC	0x20 /* extended link services (PLOGI) */
71 #define	R_CTL_FC4_SVC		0x30 /* FC-4 link services (FCP_LOGI) */
72 #define	R_CTL_VIDEO_BUFF	0x40 /* not yet defined */
73 #define	R_CTL_BASIC_SVC		0x80 /* basic link services (NOP) */
74 #define	R_CTL_LINK_CTL		0xc0 /* ACKs, etc. */
75 
76 /* legal values for r_ctl: Device Data */
77 #define	R_CTL_UNCATEGORIZED	0x00
78 #define	R_CTL_SOLICITED_DATA	0x01
79 #define	R_CTL_UNSOL_CONTROL	0x02
80 #define	R_CTL_SOLICITED_CONTROL	0x03
81 #define	R_CTL_UNSOL_DATA	0x04
82 #define	R_CTL_XFER_RDY		0x05
83 #define	R_CTL_COMMAND		0x06
84 #define	R_CTL_STATUS		0x07
85 
86 /* legal values for r_ctl: Basic Link Services, type 0 */
87 #define	R_CTL_LS_NOP		0x80
88 #define	R_CTL_LS_ABTS		0x81
89 #define	R_CTL_LS_RMC		0x82
90 #define	R_CTL_LS_BA_ACC		0x84
91 #define	R_CTL_LS_BA_RJT		0x85
92 
93 /* legal values for r_ctl: Extended Link Services, type 1 */
94 #define	R_CTL_ELS_REQ		0x22
95 #define	R_CTL_ELS_RSP		0x23
96 
97 /* legal values for r_ctl: Link Control */
98 #define	R_CTL_ACK_1		0xc0
99 #define	R_CTL_ACK_N		0xc1
100 #define	R_CTL_P_RJT		0xc2
101 #define	R_CTL_F_RJT		0xc3
102 #define	R_CTL_P_BSY		0xc4
103 #define	R_CTL_F_BSY_DF		0xc5
104 #define	R_CTL_F_BSY_LC		0xc6
105 #define	R_CTL_LCR		0xc7
106 
107 /* type field definitions for Link Data frames: */
108 #define	TYPE_BASIC_LS		0x00
109 #define	TYPE_EXTENDED_LS	0x01
110 
111 /* type field definitions for Device Data frames (from FC-PH 4.1): */
112 #define	TYPE_IS8802		0x04
113 #define	TYPE_IS8802_SNAP	0x05
114 #define	TYPE_SCSI_FCP		0x08 /* we use this one */
115 #define	TYPE_SCSI_GPP		0x09
116 #define	TYPE_HIPP_FP		0x0a
117 #define	TYPE_IPI3_MASTER	0x11
118 #define	TYPE_IPI3_SLAVE		0x12
119 #define	TYPE_IPI3_PEER		0x13
120 
121 #define	F_CTL_XCHG_CONTEXT	0x800000 /* 0 if SID is XCHG originator */
122 #define	F_CTL_SEQ_CONTEXT	0x400000 /* 0 if SID is SEQ initiator */
123 #define	F_CTL_FIRST_SEQ		0x200000 /* 1 if first sequence of XCHG */
124 #define	F_CTL_LAST_SEQ		0x100000 /* 1 if last SEQ of XCHG */
125 #define	F_CTL_END_SEQ		0x080000 /* 1 if last frame of a SEQ */
126 #define	F_CTL_END_CONNECT	0x040000 /* always 0 */
127 #define	F_CTL_CHAINED_SEQ	0x020000 /* always 0 */
128 #define	F_CTL_SEQ_INITIATIVE	0x010000 /* when 1 xfrs SEQ initiative */
129 #define	F_CTL_XID_REASSIGNED	0x008000 /* always 0 */
130 #define	F_CTL_INVALIDATE_XID	0x004000 /* always 0 */
131 #define	F_CTL_CONTINUE_SEQ	0x0000C0 /* always 0 */
132 #define	F_CTL_ABORT_SEQ		0x000030 /* always 0 */
133 #define	F_CTL_RO_PRESENT	0x000008 /* 1 if param field == RO */
134 #define	F_CTL_XCHG_REASSEMBLE	0x000004 /* always 0 */
135 #define	F_CTL_FILL_BYTES	0x000003 /* # of fill bytes in this frame */
136 #define	F_CTL_RESERVED		0x003F00
137 #define	F_CTL_ALWAYS_ZERO	(F_CTL_RESERVED | F_CTL_XCHG_REASSEMBLE | \
138 	F_CTL_ABORT_SEQ | F_CTL_CONTINUE_SEQ| F_CTL_INVALIDATE_XID | \
139 	F_CTL_XID_REASSIGNED | F_CTL_CHAINED_SEQ | F_CTL_END_CONNECT)
140 
141 /* Well known addresses ... */
142 #define	FS_GENERAL_MULTICAST	0xfffff7
143 #define	FS_WELL_KNOWN_MULTICAST	0xfffff8
144 #define	FS_HUNT_GROUP		0xfffff9
145 #define	FS_MANAGEMENT_SERVER	0xfffffa
146 #define	FS_TIME_SERVER		0xfffffb
147 #define	FS_NAME_SERVER		0xfffffc
148 #define	FS_FABRIC_CONTROLLER	0xfffffd
149 #define	FS_FABRIC_F_PORT	0xfffffe
150 #define	FS_BROADCAST		0xffffff
151 
152 /* Fabric Busy Reason Codes */
153 #define	FABRIC_BUSY		0x01
154 #define	NPORT_BUSY		0x03
155 
156 /* NPort Busy Reason Codes */
157 #define	PHYSICAL_BUSY		0x01
158 #define	RESOURSE_BUSY		0x03
159 
160 /* Reject Reason Codes */
161 
162 typedef struct FC2_RJT_PARAM {
163 	uchar_t	rjt_action;
164 	uchar_t	rjt_reason;
165 	uchar_t	reserved[2];
166 } aFC2_RJT_PARAM;
167 
168 #define	INVALID_D_ID		0x01
169 #define	INVALID_S_ID		0x02
170 #define	NPORT_NOT_AVAIL_TEMP	0x03
171 #define	NPORT_NOT_AVAIL_PERM	0x04
172 #define	CLASS_NOT_SUPPORTED	0x05
173 #define	DELIMITER_ERROR		0x06
174 #define	TYPE_NOT_SUPPORTED	0x07
175 #define	INVALID_LINK_CONTROL	0x08
176 #define	INVALID_R_CTL		0x09
177 #define	INVALID_F_CTL		0x0a
178 #define	INVALID_OX_ID		0x0b
179 #define	INVALID_RX_ID		0x0c
180 #define	INVALID_SEQ_ID		0x0d
181 #define	INVALID_DF_CTL		0x0e
182 #define	INVALID_SEQ_CNT		0x0f
183 #define	INVALID_PARAMETER	0x10
184 #define	EXCHANGE_ERROR		0x11
185 #define	PROTOCOL_ERROR		0x12
186 #define	INCORRECT_LENGTH	0x13
187 #define	UNEXPECTED_ACK		0x14
188 #define	UNEXPECTED_LINK_RESP	0x15
189 #define	LOGIN_REQUIRED		0x16
190 #define	EXCESSIVE_SEQUENCES	0x17
191 #define	CANT_ESTABLISH_EXCHANGE	0x18
192 #define	SECURITY_NOT_SUPPORTED	0x19
193 
194 /* BA_RJT and LS_RJT reason codes */
195 #define	RJT_INVALID_CMD_CODE	0x01
196 #define	RJT_LOGICAL_ERROR	0x03
197 #define	RJT_LOGICAL_BUSY	0x05
198 #define	RJT_PROTOCOL_ERR	0x07
199 #define	RJT_CANT_PERFORM_RQST	0x09
200 #define	RJT_CMD_NOT_SUPPORTED	0x0b
201 
202 
203 /*
204  * Frame Payloads that the SOC understands
205  * Transfer Ready:
206  */
207 
208 typedef struct Xfer_Rdy {
209 	int32_t	seq_ro;
210 	int32_t	burst_len;
211 	int32_t	reserved;
212 } aXFER_RDY, *XFER_RDYptr;
213 
214 /*
215  * Extended Link Service Payload
216  */
217 
218 /* Arbitrary upper limit for now... */
219 #define	FC_MAX_ELS	(60-4)
220 
221 typedef struct ELS_payload {
222 	union els_cmd_u {
223 	    struct {
224 		uchar_t	ls_command;
225 		uchar_t	reserved[3];
226 	    } c;
227 	    uint32_t i;
228 	} els_cmd;
229 	uchar_t	els_data[FC_MAX_ELS];
230 } els_payload_t;
231 
232 
233 /*
234  * Data segment definition
235  */
236 typedef struct fc_dataseg {
237 	uint32_t	fc_base;	/* Address of buffer. */
238 	uint32_t	fc_count;	/* Length of buffer. */
239 } fc_dataseg_t;
240 
241 #ifdef	__cplusplus
242 }
243 #endif
244 
245 #endif	/* !_SYS_FC4_FCAL_H */
246