xref: /illumos-gate/usr/src/uts/common/sys/ib/clients/eoib/fip.h (revision 45ede40b2394db7967e59f19288fae9b62efd4aa)
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 /*
23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _SYS_IB_EOIB_FIP_H
27 #define	_SYS_IB_EOIB_FIP_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/ethernet.h>
34 #include <sys/ib/ib_types.h>
35 
36 /*
37  * Sizes of various objects in FIP headers
38  */
39 #define	FIP_VENDOR_LEN			8
40 #define	FIP_GUID_LEN			8
41 #define	FIP_SYSNAME_LEN			32
42 #define	FIP_PORTNAME_LEN		8
43 #define	FIP_MGID_PREFIX_LEN		5
44 #define	FIP_VNIC_NAME_LEN		16
45 #define	FIP_VHUBID_LEN			3
46 
47 /*
48  * EoIB Pkeys and Qkeys
49  */
50 #define	EIB_ADMIN_PKEY			0xFFFF
51 #define	EIB_FIP_QKEY			0x80020002
52 #define	EIB_DATA_QKEY			0x80020003
53 
54 /*
55  * EoIB Advertise and Solicit MCG GUIDs
56  */
57 #define	EIB_GUID_ADVERTISE_PREFIX	0xFF12E01B00060000
58 #define	EIB_GUID_SOLICIT_PREFIX		0xFF12E01B00070000
59 
60 /*
61  * FIP_Protocol_Version
62  */
63 #define	FIP_PROTO_VERSION		0
64 typedef struct fip_proto_s {
65 	uint8_t		pr_version;
66 	uint8_t		pr_reserved[3];
67 } fip_proto_t;
68 
69 /*
70  * Basic FIP Header: Opcodes and subcodes for EoIB
71  */
72 #define	FIP_OPCODE_EOIB			0xFFF9
73 
74 #define	FIP_SUBCODE_H_SOLICIT		0x1
75 #define	FIP_SUBCODE_G_ADVERTISE		0x2
76 #define	FIP_SUBCODE_H_VNIC_LOGIN	0x3
77 #define	FIP_SUBCODE_G_VNIC_LOGIN_ACK	0x4
78 #define	FIP_SUBCODE_H_VNIC_LOGOUT	0x5
79 #define	FIP_SUBCODE_G_VHUB_UPDATE	0x6
80 #define	FIP_SUBCODE_G_VHUB_TABLE	0x7
81 #define	FIP_SUBCODE_H_KEEP_ALIVE	0x8
82 
83 /*
84  * Basic FIP Header: Flags relevant to EoIB
85  */
86 #define	FIP_BHFLAG_GWAVAIL		0x4
87 #define	FIP_BHFLAG_SLCTMSG		0x2
88 
89 /*
90  * FIP_Basic_Header
91  */
92 #define	FIP_DESC_TYPE_VENDOR_ID		13
93 #define	FIP_DESC_LEN_VENDOR_ID		3
94 typedef struct fip_basic_hdr_s {
95 	uint16_t	hd_opcode;
96 	uint8_t		hd_reserved1;
97 	uint8_t		hd_subcode;
98 	uint16_t	hd_desc_list_len;
99 	uint16_t	hd_flags;
100 	uint8_t		hd_type;
101 	uint8_t		hd_len;
102 	uint8_t		hd_reserved2[2];
103 	uint8_t		hd_vendor_id[FIP_VENDOR_LEN];
104 } fip_basic_hdr_t;
105 
106 #define	FIP_IBA_QPN_MASK		0x00FFFFFF
107 #define	FIP_IBA_PORTID_MASK		0x0FFF
108 #define	FIP_IBA_SL_MASK			0xF000
109 #define	FIP_IBA_SL_SHIFT		12
110 
111 /*
112  * FIP_Descriptor_Infiniband_Address
113  */
114 #define	FIP_DESC_TYPE_IBA		240
115 #define	FIP_DESC_LEN_IBA		7
116 typedef struct fip_desc_iba_s {
117 	uint8_t		ia_type;
118 	uint8_t		ia_len;
119 	uint8_t		ia_reserved[2];
120 	uint8_t		ia_vendor_id[FIP_VENDOR_LEN];
121 	uint32_t	ia_qpn;
122 	uint16_t	ia_sl_portid;
123 	uint16_t	ia_lid;
124 	uint8_t		ia_guid[FIP_GUID_LEN];
125 } fip_desc_iba_t;
126 
127 /*
128  * FIP Solicitation Control Message:
129  *
130  * 	FIP_Protocol_Version
131  * 	FIP_Basic_Header
132  * 	FIP_Descriptor_Infiniband_Address
133  */
134 typedef struct fip_solicit_s {
135 	fip_proto_t	sl_proto_version;
136 	fip_basic_hdr_t	sl_fip_hdr;
137 	fip_desc_iba_t	sl_iba;
138 } fip_solicit_t;
139 
140 /*
141  * FIP_Descriptor_EoIB_Gateway_Information
142  */
143 #define	FIP_DESC_TYPE_EOIB_GW_INFO	241
144 #define	FIP_DESC_LEN_EOIB_GW_INFO	4
145 typedef struct fip_desc_gwinfo_s {
146 	uint8_t		gi_type;
147 	uint8_t		gi_len;
148 	uint8_t		gi_reserved1[2];
149 	uint8_t		gi_vendor_id[FIP_VENDOR_LEN];
150 	uint8_t		gi_flags;
151 	uint8_t		gi_reserved2;
152 	uint16_t	gi_rss_qpn_num_net_vnics;
153 } fip_desc_gwinfo_t;
154 
155 #define	FIP_GWI_HOST_ADMIND_VNICS_MASK	0x80
156 #define	FIP_GWI_NUM_NET_VNICS_MASK	0x0FFF
157 #define	FIP_GWI_RSS_QPN_MASK		0xF000
158 #define	FIP_GWI_RSS_QPN_SHIFT		12
159 
160 /*
161  * FIP_Descriptor_Gateway_Identifier
162  */
163 #define	FIP_DESC_TYPE_GW_ID		248
164 #define	FIP_DESC_LEN_GW_ID		15
165 typedef struct fip_desc_gwid_s {
166 	uint8_t		id_type;
167 	uint8_t		id_len;
168 	uint8_t		id_reserved[2];
169 	uint8_t		id_vendor_id[FIP_VENDOR_LEN];
170 	uint8_t		id_guid[FIP_GUID_LEN];
171 	uint8_t		id_sysname[FIP_SYSNAME_LEN];
172 	uint8_t		id_portname[FIP_PORTNAME_LEN];
173 } fip_desc_gwid_t;
174 
175 /*
176  * FIP_Descriptor_Keep_Alive_Parameters
177  */
178 #define	FIP_DESC_TYPE_KEEP_ALIVE	249
179 #define	FIP_DESC_LEN_KEEP_ALIVE		6
180 typedef struct fip_desc_keepalive_s {
181 	uint8_t		ka_type;
182 	uint8_t		ka_len;
183 	uint8_t		ka_reserved[2];
184 	uint8_t		ka_vendor_id[FIP_VENDOR_LEN];
185 	uint32_t	ka_gw_adv_period;
186 	uint32_t	ka_gw_ka_period;
187 	uint32_t	ka_vnic_ka_period;
188 } fip_desc_keepalive_t;
189 
190 /*
191  * FIP Advertise Control Message:
192  *
193  * 	FIP_Protocol_Version
194  * 	FIP_Basic_Header
195  * 	FIP_Descriptor_Infiniband_Address
196  * 	FIP_Descriptor_EoIB_Gateway_Information
197  *	FIP_Descriptor_Gateway_Identifier
198  *	FIP_Descriptor_Keep_Alive_Parameters
199  */
200 typedef struct fip_advertise_s {
201 	fip_proto_t		ad_proto_version;
202 	fip_basic_hdr_t		ad_fip_header;
203 	fip_desc_iba_t		ad_iba;
204 	fip_desc_gwinfo_t	ad_gwinfo;
205 	fip_desc_gwid_t		ad_gwid;
206 	fip_desc_keepalive_t	ad_keep_alive;
207 } fip_advertise_t;
208 
209 /*
210  * FIP_Descriptor_vNIC_Login
211  */
212 #define	FIP_DESC_TYPE_VNIC_LOGIN	242
213 #define	FIP_DESC_LEN_VNIC_LOGIN		13
214 typedef struct fip_desc_vnic_login_s {
215 	uint8_t			vl_type;
216 	uint8_t			vl_len;
217 	uint8_t			vl_reserved1[2];
218 	uint8_t			vl_vendor_id[FIP_VENDOR_LEN];
219 	uint16_t		vl_mtu;
220 	uint16_t		vl_vnic_id;
221 	uint16_t		vl_flags_vlan;
222 	uint8_t			vl_mac[ETHERADDRL];
223 	uint8_t			vl_gw_mgid_prefix[FIP_MGID_PREFIX_LEN];
224 	uint8_t			vl_reserved2;
225 	uint8_t			vl_flags_rss;
226 	uint8_t			vl_n_mac_mcgid;
227 	uint32_t		vl_syndrome_ctl_qpn;
228 	uint8_t			vl_vnic_name[FIP_VNIC_NAME_LEN];
229 } fip_desc_vnic_login_t;
230 
231 /*
232  * Flags, masks and error codes for FIP_Descriptor_vNIC_Login
233  */
234 #define	FIP_VL_VNIC_ID_MSBIT		0x8000
235 #define	FIP_VL_FLAGS_V			0x8000
236 #define	FIP_VL_FLAGS_M			0x4000
237 #define	FIP_VL_FLAGS_VP			0x2000
238 #define	FIP_VL_FLAGS_H			0x1000
239 #define	FIP_VL_VLAN_MASK		0x0FFF
240 #define	FIP_VL_RSS_MASK			0x10
241 #define	FIP_VL_N_RSS_MCGID_MASK		0x0F
242 #define	FIP_VL_N_MAC_MCGID_MASK		0x3F
243 #define	FIP_VL_CTL_QPN_MASK		0x00FFFFFF
244 
245 #define	FIP_VL_SYN_MASK			0xFF000000
246 #define	FIP_VL_SYN_SHIFT		24
247 
248 #define	FIP_VL_SYN_SUCCESS		0
249 #define	FIP_VL_SYN_REJECTED		1
250 #define	FIP_VL_SYN_GW_NO_RESOURCE	2
251 #define	FIP_VL_SYN_NO_MORE_NWK_ADDRS	3
252 #define	FIP_VL_SYN_UNKNOWN_HOST		4
253 #define	FIP_VL_SYN_UNSUPP_PARAM		5
254 
255 /*
256  * FIP_Descriptor_Partition
257  */
258 #define	FIP_DESC_TYPE_PARTITION		246
259 #define	FIP_DESC_LEN_PARTITION		4
260 typedef struct fip_desc_partition_s {
261 	uint8_t			pn_type;
262 	uint8_t			pn_len;
263 	uint8_t			pn_reserved1[2];
264 	uint8_t			pn_vendor_id[FIP_VENDOR_LEN];
265 	uint8_t			pn_reserved2[2];
266 	uint16_t		pn_pkey;
267 } fip_desc_partition_t;
268 
269 /*
270  * FIP Login Control Message:
271  *
272  * 	FIP_Protocol_Version
273  * 	FIP_Basic_Header
274  * 	FIP_Descriptor_Infiniband_Address
275  * 	FIP_Descriptor_vNIC_Login
276  */
277 typedef struct fip_login_s {
278 	fip_proto_t		lg_proto_version;
279 	fip_basic_hdr_t		lg_fip_header;
280 	fip_desc_iba_t		lg_iba;
281 	fip_desc_vnic_login_t	lg_vnic_login;
282 } fip_login_t;
283 
284 /*
285  * FIP Login ACK Control Message:
286  *
287  * 	FIP_Protocol_Version
288  * 	FIP_Basic_Header
289  * 	FIP_Descriptor_Infiniband_Address
290  * 	FIP_Descriptor_vNIC_Login
291  *	FIP_Descriptor_Partition
292  */
293 typedef struct fip_login_ack_s {
294 	fip_proto_t		ak_proto_version;
295 	fip_basic_hdr_t		ak_fip_header;
296 	fip_desc_iba_t		ak_iba;
297 	fip_desc_vnic_login_t	ak_vnic_login;
298 	fip_desc_partition_t	ak_vhub_partition;
299 } fip_login_ack_t;
300 
301 /*
302  * FIP_Descriptor_vNIC_Identity
303  */
304 #define	FIP_DESC_TYPE_VNIC_IDENTITY	245
305 #define	FIP_DESC_LEN_VNIC_IDENTITY	13
306 typedef struct fip_desc_vnic_identity_s {
307 	uint8_t			vi_type;
308 	uint8_t			vi_len;
309 	uint8_t			vi_reserved1[2];
310 	uint8_t			vi_vendor_id[FIP_VENDOR_LEN];
311 	uint32_t		vi_flags_vhub_id;
312 	uint32_t		vi_tusn;
313 	uint16_t		vi_vnic_id;
314 	uint8_t			vi_mac[ETHERADDRL];
315 	uint8_t			vi_port_guid[FIP_GUID_LEN];
316 	uint8_t			vi_vnic_name[FIP_VNIC_NAME_LEN];
317 } fip_desc_vnic_identity_t;
318 
319 #define	FIP_VI_FLAG_U		0x80000000
320 #define	FIP_VI_FLAG_R		0x40000000
321 #define	FIP_VI_FLAG_VP		0x01000000
322 
323 /*
324  * FIP Keep Alive Control Message:
325  *
326  *	FIP_Protocol_Version
327  *	FIP_Basic_Header
328  *	FIP_Descriptor_vNIC_Identity
329  */
330 typedef struct fip_keep_alive_s {
331 	fip_proto_t			ka_proto_version;
332 	fip_basic_hdr_t			ka_fip_header;
333 	fip_desc_vnic_identity_t	ka_vnic_identity;
334 } fip_keep_alive_t;
335 
336 /*
337  * FIP_vHUB_Table_Entry
338  */
339 typedef struct fip_vhub_table_entry_s {
340 	uint8_t			te_v_rss_type;
341 	uint8_t			te_reserved1;
342 	uint8_t			te_mac[ETHERADDRL];
343 	uint32_t		te_qpn;
344 	uint8_t			te_reserved2;
345 	uint8_t			te_sl;
346 	uint16_t		te_lid;
347 } fip_vhub_table_entry_t;
348 
349 #define	FIP_TE_VALID			0x80
350 #define	FIP_TE_RSS			0x40
351 
352 #define	FIP_TE_TYPE_MASK		0x0F
353 #define	FIP_TE_TYPE_VNIC		0x00
354 #define	FIP_TE_TYPE_GATEWAY		0x01
355 #define	FIP_TE_TYPE_UNICAST_MISS	0x02
356 #define	FIP_TE_TYPE_MULTICAST_ENTRY	0x03
357 #define	FIP_TE_TYPE_VHUB_MULTICAST	0x04
358 
359 #define	FIP_TE_SL_MASK			0x0F
360 #define	FIP_TE_QPN_MASK			0x00FFFFFF
361 
362 #define	FIP_VHUB_TABLE_ENTRY_SZ		(sizeof (fip_vhub_table_entry_t))
363 #define	FIP_VHUB_TABLE_ENTRY_WORDS	(FIP_VHUB_TABLE_ENTRY_SZ >> 2)
364 
365 /*
366  * FIP_Descriptor_vHUB_Update
367  */
368 #define	FIP_DESC_TYPE_VHUB_UPDATE	243
369 #define	FIP_DESC_LEN_VHUB_UPDATE	9
370 typedef struct fip_desc_vhub_update_s {
371 	uint8_t			up_type;
372 	uint8_t			up_len;
373 	uint8_t			up_reserved1[2];
374 	uint8_t			up_vendor_id[FIP_VENDOR_LEN];
375 	uint32_t		up_eport_vp_vhub_id;
376 	uint32_t		up_tusn;
377 	fip_vhub_table_entry_t	up_tbl_entry;
378 } fip_desc_vhub_update_t;
379 
380 #define	FIP_UP_VP_SHIFT			24
381 #define	FIP_UP_VP_MASK			0x1
382 #define	FIP_UP_EPORT_STATE_SHIFT	28
383 #define	FIP_UP_EPORT_STATE_MASK		0x3
384 #define	FIP_UP_VHUB_ID_MASK		0x00FFFFFF
385 
386 #define	FIP_EPORT_DOWN			0x0
387 #define	FIP_EPORT_UP			0x1
388 
389 /*
390  * FIP_Descriptor_vHUB_Table
391  */
392 #define	FIP_DESC_TYPE_VHUB_TABLE	244
393 typedef struct fip_desc_vhub_table_s {
394 	uint8_t			tb_type;
395 	uint8_t			tb_len;
396 	uint8_t			tb_reserved1[2];
397 	uint8_t			tb_vendor_id[FIP_VENDOR_LEN];
398 	uint32_t		tb_flags_vhub_id;
399 	uint32_t		tb_tusn;
400 	uint8_t			tb_hdr;
401 	uint8_t			tb_reserved2;
402 	uint16_t		tb_table_size;
403 	/*
404 	 * FIP_vHUB_Table_Entry
405 	 * FIP_vHUB_Table_Entry
406 	 * .
407 	 * .
408 	 * .
409 	 * uint32_t Checksum
410 	 */
411 } fip_desc_vhub_table_t;
412 
413 #define	FIP_TB_FLAGS_VP_SHIFT		24
414 #define	FIP_TB_FLAGS_VP_MASK		0x1
415 
416 #define	FIP_TB_VHUB_ID_MASK		0x00FFFFFF
417 
418 #define	FIP_TB_HDR_MIDDLE		0x00
419 #define	FIP_TB_HDR_FIRST		0x40
420 #define	FIP_TB_HDR_LAST			0x80
421 #define	FIP_TB_HDR_ONLY			0xC0
422 
423 #define	FIP_DESC_VHUB_TABLE_SZ		(sizeof (fip_desc_vhub_table_t))
424 #define	FIP_DESC_VHUB_TABLE_WORDS	(FIP_DESC_VHUB_TABLE_SZ >> 2)
425 
426 /*
427  * FIP vHUB Table Message:
428  *
429  * 	FIP_Protocol_Version
430  * 	FIP_Basic_Header
431  * 	FIP_Descriptor_vHUB_Table
432  */
433 typedef struct fip_vhub_table_s {
434 	fip_proto_t		vt_proto_version;
435 	fip_basic_hdr_t		vt_fip_header;
436 	fip_desc_vhub_table_t	vt_vhub_table;
437 } fip_vhub_table_t;
438 
439 /*
440  * FIP vHUB Update Message:
441  *
442  * 	FIP_Protocol_Version
443  * 	FIP_Basic_Header
444  * 	FIP_Descriptor_vHUB_Update
445  */
446 typedef struct fip_vhub_update_s {
447 	fip_proto_t		vu_proto_version;
448 	fip_basic_hdr_t		vu_fip_header;
449 	fip_desc_vhub_update_t	vu_vhub_update;
450 } fip_vhub_update_t;
451 
452 /*
453  * Just a generic container to handle either type of VHUB
454  * messages
455  */
456 typedef struct fip_vhub_pkt_s {
457 	fip_proto_t		hb_proto_version;
458 	fip_basic_hdr_t		hb_fip_header;
459 } fip_vhub_pkt_t;
460 
461 #ifdef __cplusplus
462 }
463 #endif
464 
465 #endif	/* _SYS_IB_EOIB_FIP_H */
466