xref: /illumos-gate/usr/src/uts/common/sys/ib/ib_types.h (revision 8e458de0baeb1fee50643403223bc7e909a48464)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_IB_IB_TYPES_H
27 #define	_SYS_IB_IB_TYPES_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * ib_types.h
33  *
34  * Data definitions for all IBTA primitive data types.
35  */
36 #include <sys/types.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 /*
44  * Addressing types
45  *	See Chapter 4 of the IBTA Volume 1 IB specification for more details.
46  */
47 #define	IB_EUI64_COMPANYID_MASK		0x0000000000FFFFFF
48 #define	IB_EUI64_COMPANYID_SHIFT	40
49 #define	IB_EUI64_IDENTIFIER_MASK	0x000000FFFFFFFFFF
50 
51 /* LID Ranges */
52 #define	IB_LID_UC_FIRST			0x0001
53 #define	IB_LID_UC_LAST			0xBFFF
54 #define	IB_LID_MC_FIRST			0xC000
55 #define	IB_LID_MC_LAST			0xFFFE
56 #define	IB_LID_PERMISSIVE		0xFFFF
57 
58 /* Unicast GID & Multicast GID */
59 typedef	uint64_t	ib_guid_t;	/* EUI-64 GUID */
60 typedef	uint64_t	ib_sn_prefix_t;	/* Subnet Prefix */
61 
62 typedef struct ib_ucast_gid_s {
63 	ib_sn_prefix_t	ugid_prefix;	/* GID prefix */
64 	ib_guid_t	ugid_guid;	/* Port GUID */
65 } ib_ucast_gid_t;
66 
67 typedef struct ib_mcast_gid_s {
68 	uint32_t	mcast_gid_prefix; /* flags, scope, and signature */
69 	uint8_t		mcast_gid_bytes[12];
70 } ib_mcast_gid_t;
71 
72 typedef struct ib_gid_s {
73 	union {
74 		ib_ucast_gid_t	ucast_gid;	/* unicast gid */
75 		ib_mcast_gid_t	mcast_gid;	/* multicast gid */
76 	} gid;
77 } ib_gid_t;
78 
79 #define	gid_prefix	gid.ucast_gid.ugid_prefix
80 #define	gid_guid	gid.ucast_gid.ugid_guid
81 
82 #define	mgid_prefix	gid.mcast_gid.mcast_gid_prefix
83 #define	mgid_bytes	gid.mcast_gid.mcast_gid_bytes
84 
85 #define	IB_GID_DEFAULT_PREFIX		0xFE80000000000000
86 #define	IB_GID_SUBNET_LOCAL_PREFIX	IB_GID_DEFAULT_PREFIX
87 #define	IB_GID_SITE_LOCAL_PREFIX	0xFEC0000000000000
88 #define	IB_GID_SITE_LOCAL_SUBNET_MASK	0x000000000000FFFF
89 
90 /* Multicast GID. */
91 #define	IB_MCGID_PREFIX			0xFF000000
92 #define	IB_MCGID_TRANSIENT_FLAG		0x00100000
93 
94 /* Multicast Address Scope. */
95 #define	IB_MC_SCOPE_SUBNET_LOCAL	0x02
96 #define	IB_MC_SCOPE_SITE_LOCAL		0x05
97 #define	IB_MC_SCOPE_ORG_LOCAL		0x08
98 #define	IB_MC_SCOPE_GLOBAL		0x0E
99 
100 /* Multicast Join State. */
101 #define	IB_MC_JSTATE_FULL		0x01	/* Full Member */
102 #define	IB_MC_JSTATE_NON		0x02	/* Non Member */
103 #define	IB_MC_JSTATE_SEND_ONLY_NON	0x04	/* Send Only Non Member */
104 
105 #define	IB_MC_QPN			0xFFFFFF	/* Multicast QPN */
106 
107 /*
108  * IP-on-IB Multicast GIDs
109  *
110  * IPV4 gid_prefix:
111  *   IB_MCGID_IPV4_PREFIX
112  *   IB_MCGID_SCOPE_MASK
113  *   IB_MCGID_IP_PKEY_MASK
114  * IPV4 gid_guid:
115  *   IB_MCGID_IPV4_LOW_GROUP_MASK
116  *
117  * IPV6 gid_prefix:
118  *   IB_MCGID_IPV6_PREFIX
119  *   IB_MCGID_SCOPE_MASK
120  *   IB_MCGID_IP_PKEY_MASK
121  *   IB_MCGID_IPV6_HI_GROUP_MASK
122  * IPV6 gid_guid:
123  *   entire gid_guid holds low part of group ID
124  */
125 #define	IB_MCGID_IPV4_PREFIX		0xFF10401B
126 #define	IB_MCGID_IPV6_PREFIX		0xFF10601B
127 #define	IB_MCGID_SA_PREFIX		0xFF10A01B
128 
129 typedef	uint16_t	ib_lid_t;	/* Port Local ID (LID) */
130 typedef	uint8_t		ib_path_bits_t;	/* From 0 to 7 low order bits of LID */
131 
132 /*
133  * PKeys and QKeys
134  */
135 #define	IB_PKEY_DEFAULT_FULL		0xFFFF
136 #define	IB_PKEY_DEFAULT_LIMITED		0x7FFF
137 #define	IB_PKEY_INVALID_FULL		0x8000
138 #define	IB_PKEY_INVALID_LIMITED		0x0000
139 #define	IB_GSI_QKEY			0x80010000
140 #define	IB_PRIVILEGED_QKEY_BIT		0x80000000
141 
142 typedef	uint16_t	ib_pkey_t;	/* P_Key */
143 typedef	uint32_t	ib_qkey_t;	/* Q_Key */
144 typedef	uint16_t	ib_pkey_cntr_t;
145 typedef	uint16_t	ib_qkey_cntr_t;
146 
147 /*
148  * General IBT types
149  */
150 typedef uint64_t	ib_smkey_t;	/* subnet manager key */
151 
152 typedef	uint16_t	ib_ethertype_t;	/* Ethertype */
153 typedef	uint32_t	ib_qpn_t;	/* 24 bit QP number */
154 typedef	uint32_t	ib_eecn_t;	/* 24 bit EEC number */
155 
156 #define	IB_QPN_MASK	0xFFFFFF
157 
158 typedef	uint32_t	ib_msglen_t;	/* message length */
159 
160 typedef	uint64_t	ib_vaddr_t;	/* registered memory Virtual Address */
161 typedef	uint64_t	ib_memlen_t;	/* registered memory length */
162 
163 typedef	uint64_t	ib_svc_id_t;	/* CM Service ID */
164 
165 #define	IB_SVC_NAME_LEN	64		/* Maximum length of Service Name, */
166 					/* which includes a terminating NULL */
167 #define	IB_SVC_DATA_LEN	64		/* Length of Service Data */
168 
169 /* MTU Size */
170 typedef enum {
171 	IB_MTU_NOT_SPECIFIED	= 0,
172 	IB_MTU_256		= 1,	/* 256 bytes */
173 	IB_MTU_512		= 2,	/* 512 bytes */
174 	IB_MTU_1K		= 3,	/* 1k bytes */
175 	IB_MTU_2K		= 4,	/* 2k bytes */
176 	IB_MTU_4K		= 5	/* 4k bytes */
177 } ib_mtu_t;
178 
179 typedef	uint8_t			ib_time_t;	/* 6 bits of timeout exponent */
180 #define	IB_TIME_EXP_MASK	0x3F		/* time = 4.096us * 2 ^ exp */
181 
182 /*
183  * Infiniband Identifiers, based on Administration Group Number (AGN) codes
184  * there are different types of Service IDs which identifies the group.
185  * The first byte of the Service ID comprises of AGN field and following
186  * specifies the values for AGN field.
187  *
188  *	0x0		- IBTA assigned Ids (WellKnown)
189  *	0x1		- IETF (any category)
190  *	0x2		- Locally assigned Ids with limited cacheability
191  *	0x10 to 0x1f	- External Organizations assigned Ids (Well Known)
192  *	others		- Reserved
193  */
194 #define	IB_SID_MASK		0x00FFFFFFFFFFFFFF
195 #define	IB_SID_AGN_MASK		0xFF00000000000000
196 
197 #define	IB_SID_AGN_IBTA		0x0000000000000000
198 #define	IB_SID_AGN_IETF		0x0100000000000000
199 #define	IB_SID_AGN_LOCAL	0x0200000000000000
200 
201 #define	IB_SID_IPADDR_PREFIX		0x0000000001000000	/* Byte 4 */
202 #define	IB_SID_IPADDR_PREFIX_MASK	0xFFFFFFFFFE000000
203 #define	IB_SID_IPADDR_IPNUM_MASK	0x0000000000FF0000	/* Byte 5 */
204 #define	IB_SID_IPADDR_PORTNUM_MASK	0x000000000000FFFF	/* Byte 6 & 7 */
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* _SYS_IB_IB_TYPES_H */
211