xref: /titanic_50/usr/src/uts/common/sys/fibre-channel/impl/fcph.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
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	_SYS_FIBRE_CHANNEL_IMPL_FCPH_H
27 #define	_SYS_FIBRE_CHANNEL_IMPL_FCPH_H
28 
29 
30 #include <sys/note.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
37 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
38 #endif	/* _BIT_FIELDS_LTOH */
39 
40 /* legal values for r_ctl */
41 #define	R_CTL_ROUTING		0xF0 /* mask for routing bits */
42 #define	R_CTL_INFO		0x0F /* mask for information bits */
43 
44 #define	R_CTL_DEVICE_DATA	0x00 /* all I/O related frames */
45 #define	R_CTL_EXTENDED_SVC	0x20 /* extended link services (PLOGI) */
46 #define	R_CTL_FC4_SVC		0x30 /* FC-4 link services (FCP_LOGI) */
47 #define	R_CTL_VIDEO_BUFF	0x40 /* not yet defined */
48 #define	R_CTL_BASIC_SVC		0x80 /* basic link services (NOP) */
49 #define	R_CTL_LINK_CTL		0xC0 /* ACKs, etc. */
50 
51 /* legal values for r_ctl: Device Data */
52 #define	R_CTL_UNCATEGORIZED	0x00
53 #define	R_CTL_SOLICITED_DATA	0x01
54 #define	R_CTL_UNSOL_CONTROL	0x02
55 #define	R_CTL_SOLICITED_CONTROL	0x03
56 #define	R_CTL_UNSOL_DATA	0x04
57 #define	R_CTL_XFER_RDY		0x05
58 #define	R_CTL_COMMAND		0x06
59 #define	R_CTL_STATUS		0x07
60 
61 /* legal values for r_ctl: Basic Link Services, type 0 */
62 #define	R_CTL_LS_NOP		0x80
63 #define	R_CTL_LS_ABTS		0x81
64 #define	R_CTL_LS_RMC		0x82
65 #define	R_CTL_LS_BA_ACC		0x84
66 #define	R_CTL_LS_BA_RJT		0x85
67 
68 /* legal values for r_ctl: Extended Link Services, type 1 */
69 #define	R_CTL_ELS_REQ		0x22
70 #define	R_CTL_ELS_RSP		0x23
71 
72 /* legal values for r_ctl: Link Control */
73 #define	R_CTL_ACK_1		0xC0
74 #define	R_CTL_ACK_N		0xC1
75 #define	R_CTL_P_RJT		0xC2
76 #define	R_CTL_F_RJT		0xC3
77 #define	R_CTL_P_BSY		0xC4
78 #define	R_CTL_F_BSY_DF		0xC5
79 #define	R_CTL_F_BSY_LC		0xC6
80 #define	R_CTL_LCR		0xC7
81 
82 /* type field definitions for Link Data frames: */
83 #define	FC_TYPE_BASIC_LS	0x00
84 #define	FC_TYPE_EXTENDED_LS	0x01
85 
86 /* type field definitions for Device Data frames (from FC-PH 4.1): */
87 #define	FC_TYPE_IS8802		0x04
88 #define	FC_TYPE_IS8802_SNAP	0x05
89 #define	FC_TYPE_SCSI_FCP	0x08
90 #define	FC_TYPE_SCSI_GPP	0x09
91 #define	FC_TYPE_HIPP_FP		0x0a
92 #define	FC_TYPE_IPI3_MASTER	0x11
93 #define	FC_TYPE_IPI3_SLAVE	0x12
94 #define	FC_TYPE_IPI3_PEER	0x13
95 #define	FC_TYPE_FC_SERVICES	0x20
96 
97 #define	F_CTL_XCHG_CONTEXT	0x800000 /* 0 if SID is XCHG originator */
98 #define	F_CTL_SEQ_CONTEXT	0x400000 /* 0 if SID is SEQ initiator */
99 #define	F_CTL_FIRST_SEQ		0x200000 /* 1 if first sequence of XCHG */
100 #define	F_CTL_LAST_SEQ		0x100000 /* 1 if last SEQ of XCHG */
101 #define	F_CTL_END_SEQ		0x080000 /* 1 if last frame of a SEQ */
102 #define	F_CTL_END_CONNECT	0x040000 /* always 0 */
103 #define	F_CTL_CHAINED_SEQ	0x020000 /* always 0 */
104 #define	F_CTL_SEQ_INITIATIVE	0x010000 /* when 1 xfrs SEQ initiative */
105 #define	F_CTL_XID_REASSIGNED	0x008000 /* always 0 */
106 #define	F_CTL_INVALIDATE_XID	0x004000 /* always 0 */
107 #define	F_CTL_CONTINUE_SEQ	0x0000C0 /* always 0 */
108 #define	F_CTL_ABORT_SEQ		0x000030 /* always 0 */
109 #define	F_CTL_RO_PRESENT	0x000008 /* 1 if param field == RO */
110 #define	F_CTL_XCHG_REASSEMBLE	0x000004 /* always 0 */
111 #define	F_CTL_FILL_BYTES	0x000003 /* # of fill bytes in this frame */
112 #define	F_CTL_RESERVED		0x003F00
113 
114 /* values for DF_CTL */
115 #define	DF_CTL_EXT_FR_HDR	0x80
116 #define	DF_CTL_EXP_SEC_HDR	0x40
117 #define	DF_CTL_NET_HDR		0x20
118 #define	DF_CTL_ASSOC_HDR	0x10
119 #define	DF_CTL_RESERVED		0x0C
120 #define	DF_CTL_DEV_HDR_16	0x01
121 #define	DF_CTL_DEV_HDR_32	0x02
122 #define	DF_CTL_DEV_HDR_64	0x03
123 #define	DF_CTL_NO_DEV_HDR	0x00
124 
125 /* Well known addresses ... */
126 #define	NPORT_ID_DOM_CTLR_START	0xFFFC01 /* N_Port IDs for domain controller */
127 #define	NPORT_ID_DOM_CTLR_END	0xFFFCFE
128 
129 #define	FS_GENERAL_MULTICAST	0xFFFFF7
130 #define	FS_WELL_KNOWN_MULTICAST	0xFFFFF8
131 #define	FS_HUNT_GROUP		0xFFFFF9
132 #define	FS_MANAGEMENT_SERVER	0xFFFFFA
133 #define	FS_TIME_SERVER		0xFFFFFB
134 #define	FS_NAME_SERVER		0xFFFFFC
135 #define	FS_FABRIC_CONTROLLER	0xFFFFFD
136 #define	FS_FABRIC_F_PORT	0xFFFFFE
137 #define	FS_BROADCAST		0xFFFFFF
138 
139 #define	FC_WELL_KNOWN_START	0xFFFFF0
140 #define	FC_WELL_KNOWN_END	0xFFFFFF
141 #define	FC_WELL_KNOWN_ADDR(x)	(((x) >= FC_WELL_KNOWN_START &&\
142 				(x) <= FC_WELL_KNOWN_END) || \
143 				((x) >= NPORT_ID_DOM_CTLR_START && \
144 				(x) <= NPORT_ID_DOM_CTLR_END))
145 
146 /*
147  * frame header
148  */
149 typedef struct frame_header {
150 
151 #if defined(_BIT_FIELDS_LTOH)
152 	uint32_t	d_id	: 24,
153 			r_ctl	: 8;
154 	uint32_t	s_id	: 24,
155 			rsvd	: 8;
156 	uint32_t	f_ctl	: 24,
157 			type	: 8;
158 	uint32_t	seq_cnt	: 16,
159 			df_ctl	: 8,
160 			seq_id 	: 8;
161 	uint32_t	rx_id	: 16,
162 			ox_id	: 16;
163 	uint32_t	ro;
164 
165 #else
166 	uint32_t	r_ctl 	: 8,
167 			d_id 	: 24;
168 	uint32_t	rsvd 	: 8,
169 			s_id	: 24;
170 	uint32_t	type	: 8,
171 			f_ctl	: 24;
172 	uint32_t	seq_id	: 8,
173 			df_ctl	: 8,
174 			seq_cnt	: 16;
175 	uint32_t	ox_id	: 16,
176 			rx_id	: 16;
177 	uint32_t	ro;
178 #endif	/* _BIT_FIELDS_LTOH */
179 } fc_frame_hdr_t;
180 
181 #if	!defined(__lint)
182 _NOTE(SCHEME_PROTECTS_DATA("unique per request", frame_header))
183 #endif	/* __lint */
184 
185 #ifdef	__cplusplus
186 }
187 #endif
188 
189 #endif	/* _SYS_FIBRE_CHANNEL_IMPL_FCPH_H */
190