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