xref: /illumos-gate/usr/src/uts/common/sys/ib/mgt/sm_attr.h (revision 03100a6332bd4edc7a53091fcf7c9a7131bcdaa7)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_IB_MGT_SM_ATTR_H
28 #define	_SYS_IB_MGT_SM_ATTR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * This file contains the definitions of the various attributes specified
34  * in IB spec volume 1, release 1.1, chapter 14.
35  */
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include <sys/ib/ib_types.h>
42 #include <sys/ib/mgt/ib_mad.h>
43 
44 #define	SM_MAX_DR_PATH		64	/* max ports in a DR path */
45 
46 /*
47  * LID routed smp class header
48  */
49 typedef struct sm_lid_class_hdr_s {
50 	uint64_t	M_Key;
51 	uint8_t		Reserved[32];
52 } sm_lid_class_hdr_t;
53 
54 /*
55  * Directed route smp mad header
56  */
57 typedef struct sm_dr_mad_hdr_s {
58 	/* Common MAD Header1: 4 bytes, bytes 0-3 of header */
59 	uint8_t		BaseVersion;	/* version of MAD base format */
60 	uint8_t		MgmtClass;	/* class of operation */
61 	uint8_t		ClassVersion;	/* version of MAD class format */
62 	uint8_t		R_Method;	/* response bit & method to   */
63 					/* perform based on mgmtclass */
64 
65 	uint16_t	D_Status;	/* direction, status unused */
66 	uint8_t		HopPointer;	/* index into Initial/Return Paths */
67 	uint8_t		HopCount;	/* number of directed route hops */
68 
69 
70 	/* Common MAD Header2: 16 bytes, bytes 8-23 of header */
71 	uint64_t	TransactionID;	/* transaction id */
72 	uint16_t	AttributeID;	/* defines class spec. objects */
73 	uint16_t	Reserved;
74 	uint32_t	AttributeModifier; /* further scope to attributes */
75 } sm_dr_mad_hdr_t;
76 
77 /* Direction bit */
78 #define	SM_DR_SMP_D_OUT		0x0000	/* SMP is outbound from SM */
79 #define	SM_DR_SMP_D_IN		0x8000	/* SMP is inbound to SM */
80 #define	SM_DR_SMP_D_MASK	0x8000	/* direction mask */
81 
82 #define	SM_DR_SMP_STATUS_MASK	0x7FFF
83 
84 /*
85  * Direct route smp class header:
86  */
87 typedef struct sm_dr_class_hdr_s {
88 	uint64_t	M_Key;
89 	ib_lid_t	DrSLID;
90 	ib_lid_t	DrDLID;
91 	uint8_t		Reserved[28];
92 } sm_dr_class_hdr_t;
93 
94 typedef struct sm_dr_data_s {
95 	uint8_t		Data[64];
96 	uint8_t		InitialPath[SM_MAX_DR_PATH];
97 	uint8_t		ReturnPath[SM_MAX_DR_PATH];
98 } sm_dr_data_t;
99 
100 /* Traps: Table 118 */
101 #define	SM_GID_IN_SERVICE_TRAP			64
102 #define	SM_GID_OUT_OF_SERVICE_TRAP		65
103 #define	SM_MGID_CREATED_TRAP			66
104 #define	SM_MGID_DESTROYED_TRAP			67
105 #define	SM_LINK_STATE_CHANGED_TRAP		128
106 #define	SM_LINK_INTEGRITY_THRESHOLD_TRAP	129
107 #define	SM_BUFFER_OVERRUN_THRESHOLD_TRAP	130
108 #define	SM_WATCHDOG_TIMER_EXPIRED_TRAP		131
109 #define	SM_CAP_MASK_CHANGED_TRAP		144
110 #define	SM_SYS_IMG_GUID_CHANGED_TRAP		145
111 #define	SM_BAD_MKEY_TRAP			256
112 #define	SM_BAD_PKEY_TRAP			257
113 #define	SM_BAD_QKEY_TRAP			258
114 #define	SM_BAD_SWITCH_PKEY_TRAP			259
115 
116 /*
117  * Notice Data details for various sm traps
118  */
119 /* Traps 64, 65, 66,and 67: Table 119 */
120 typedef struct sm_trap_64_s {
121 	uint8_t		Reserved[6];
122 	ib_gid_t	GIDADDR;		/* global identifier */
123 	uint8_t		Padding[32];
124 } sm_trap_64_t;
125 
126 typedef sm_trap_64_t	sm_trap_65_t;
127 typedef sm_trap_64_t	sm_trap_66_t;
128 typedef sm_trap_64_t	sm_trap_67_t;
129 
130 /* Trap 128: Table 120 */
131 typedef struct sm_trap_128_s {
132 	ib_lid_t	LIDADDR;		/* trap generator's LID */
133 	uint8_t		Padding[52];
134 } sm_trap_128_t;
135 
136 /* Traps 129, 130, and 131: Table 121 */
137 typedef struct sm_trap_129_s {
138 	uint16_t	Reserved;
139 	ib_lid_t	LIDADDR;		/* generator's LID */
140 	uint8_t		PORTNO;			/* generator's port */
141 	uint8_t		Padding[49];
142 } sm_trap_129_t;
143 
144 typedef sm_trap_129_t	sm_trap_130_t;
145 typedef sm_trap_129_t	sm_trap_131_t;
146 
147 /* Trap 144: Table 122 */
148 typedef struct sm_trap_144_s {
149 	uint16_t	Reserved;
150 	ib_lid_t	LIDADDR;		/* generator's LID */
151 	uint16_t	Reserved2;
152 	uint32_t	CAPABILITYMASK;		/* generator's CapMask */
153 	uint8_t		Padding[44];
154 } sm_trap_144_t;
155 
156 /* Trap 145: Table 123 */
157 typedef struct sm_trap_145_s {
158 	uint16_t	Reserved;
159 	ib_lid_t	LIDADDR;
160 	uint16_t	Reserved2;
161 	ib_guid_t	SYSTEMIMAGEGUID;	/* generator's SysImage GUID */
162 	uint8_t		Padding[40];
163 } sm_trap_145_t;
164 
165 /* Trap 256: Table 124 */
166 #if defined(_BIT_FIELDS_HTOL)
167 typedef struct sm_trap_256_s {
168 	uint16_t	Reserved;
169 	ib_lid_t	LIDADDR;		/* generator's LID */
170 	uint16_t	Reserved1;
171 	uint8_t		METHOD;			/* method */
172 	uint8_t		Reserved2;
173 	uint16_t	ATTRIBUTEID;		/* attribute casuing the trap */
174 	uint32_t	ATTRIBUTEMODIFIER;	/* modifier for the attrib */
175 	uint64_t	MKEY;
176 	uint8_t		DRSLID;			/* SLID of SMP causing notice */
177 	uint8_t		DRNotice	:1;	/* notice from a dr SMP */
178 	uint8_t		DRPathTruncated	:1;	/* return path is truncated */
179 	uint8_t		DRHopCount	:6;	/* num bytes in return path */
180 	uint8_t		DRNoticeReturnPath[30];	/* return path from the SMP */
181 } sm_trap_256_t;
182 
183 #elif defined(_BIT_FIELDS_LTOH)
184 
185 typedef struct sm_trap_256_s {
186 	uint16_t	Reserved;
187 	ib_lid_t	LIDADDR;		/* generator's LID */
188 	uint16_t	Reserved1;
189 	uint8_t		METHOD;			/* method */
190 	uint8_t		Reserved2;
191 	uint16_t	ATTRIBUTEID;		/* attribute casuing the trap */
192 	uint32_t	ATTRIBUTEMODIFIER;	/* modifier for the attrib */
193 	uint64_t	MKEY;
194 	uint8_t		DRSLID;			/* SLID of SMP causing notice */
195 	uint8_t		DRHopCount	:6;	/* num bytes in return path */
196 	uint8_t		DRPathTruncated	:1;	/* return path is truncated */
197 	uint8_t		DRNotice	:1;	/* notice from a dr SMP */
198 	uint8_t		DRNoticeReturnPath[30];	/* return path from the SMP */
199 } sm_trap_256_t;
200 #else
201 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
202 #endif /* _BIT_FIELDS_HTOL */
203 
204 /* Traps 257 and 258: Table 125 */
205 #if defined(_BIT_FIELDS_HTOL)
206 typedef struct sm_trap_257_s {
207 	uint16_t	Reserved;
208 	ib_lid_t	LIDADDR1;		/* see spec description */
209 	ib_lid_t	LIDADDR2;
210 	uint32_t	KEY;			/* qkey or pkey */
211 	uint32_t	SL		:4;	/* sl for the trap */
212 	uint32_t	Reserved2	:4;	/* reserved */
213 	uint32_t	QP		:24;	/* queue pair */
214 	uint32_t	Reserved3	:8;
215 	uint32_t	QP2		:24;	/* queue pair */
216 	ib_gid_t	GIDADDR1;		/* see spec description */
217 	ib_gid_t	GIDADDR2;
218 	uint8_t		Padding[4];
219 } sm_trap_257_t;
220 
221 #elif defined(_BIT_FIELDS_LTOH)
222 
223 typedef struct sm_trap_257_s {
224 	uint16_t	Reserved;
225 	ib_lid_t	LIDADDR1;		/* see spec description */
226 	ib_lid_t	LIDADDR2;
227 	uint32_t	KEY;			/* qkey or pkey */
228 	uint32_t	QP		:24;	/* queue pair */
229 	uint32_t	Reserved2	:4;	/* reserved */
230 	uint32_t	SL		:4;	/* sl for the trap */
231 	uint32_t	QP2		:24;	/* queue pair */
232 	uint32_t	Reserved3	:8;
233 	ib_gid_t	GIDADDR1;		/* see spec description */
234 	ib_gid_t	GIDADDR2;
235 	uint8_t		Padding[4];
236 } sm_trap_257_t;
237 #else
238 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
239 #endif /* _BIT_FIELDS_HTOL */
240 
241 typedef	sm_trap_257_t	sm_trap_258_t;
242 
243 /* Trap 259: Table 126 */
244 #if defined(_BIT_FIELDS_HTOL)
245 typedef	struct sm_trap_259_s {
246 	uint16_t	DataValid;		/* validity of optional data */
247 	ib_lid_t	LIDADDR1;		/* see spec description */
248 	ib_lid_t	LIDADDR2;
249 	uint16_t	PKEY;			/* pkey */
250 	uint32_t	SL		:4;	/* service level */
251 	uint32_t	Reserved	:4;
252 	uint32_t	QP1		:24;	/* queue pair */
253 	uint32_t	Reserved8	:8;
254 	uint32_t	QP2		:24;	/* queue pair */
255 	ib_gid_t	GIDADDR1;		/* see spec description */
256 	ib_gid_t	GIDADDR2;
257 	ib_lid_t	SWLIDADDR;		/* lid of switch */
258 	uint8_t		PORTNO;			/* port number */
259 	uint8_t		Padding[3];
260 } sm_trap_259_t;
261 
262 #elif defined(_BIT_FIELDS_LTOH)
263 
264 typedef	struct sm_trap_259_s {
265 	uint16_t	DataValid;		/* validity of optional data */
266 	ib_lid_t	LIDADDR1;		/* see spec description */
267 	ib_lid_t	LIDADDR2;
268 	uint16_t	PKEY;			/* pkey */
269 	uint32_t	QP1		:24;	/* queue pair */
270 	uint32_t	Reserved	:4;
271 	uint32_t	SL		:4;	/* service level */
272 	uint32_t	QP2		:24;	/* queue pair */
273 	uint32_t	Reserved8	:8;
274 	ib_gid_t	GIDADDR1;		/* see spec description */
275 	ib_gid_t	GIDADDR2;
276 	ib_lid_t	SWLIDADDR;		/* lid of switch */
277 	uint8_t		PORTNO;			/* port number */
278 	uint8_t		Padding[3];
279 } sm_trap_259_t;
280 #else
281 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
282 #endif /* _BIT_FIELDS_HTOL */
283 
284 /*
285  * NodeDescription: Table 127
286  * NodeDescription is applicable to all ports of a node.
287  */
288 typedef struct sm_nodedesc_s {
289 	uint8_t		NodeString[64];		/* description string */
290 } sm_nodedesc_t;
291 
292 /*
293  * NodeInfo: Table 128
294  * The value of some NodeInfo components varies by port within a node.
295  */
296 #if defined(_BIT_FIELDS_HTOL)
297 typedef struct sm_nodeinfo_s {
298 	uint8_t		BaseVersion;		/* supported MAD base version */
299 	uint8_t		ClassVersion;		/* support SMP version	*/
300 	uint8_t		NodeType;		/* node type(CA, switch, etc) */
301 	uint8_t		NumPorts;		/* # of phys ports on node    */
302 	ib_guid_t	SystemImageGUID;	/* GUID associating this node */
303 						/* with nodes controlled by   */
304 						/* common supervisory code    */
305 	ib_guid_t	NodeGUID;		/* GUID of the node itself    */
306 	ib_guid_t	PortGUID;		/* GUID of this port */
307 	uint16_t	PartitionCap;		/* # of entries in part. tbl. */
308 	uint16_t	DeviceID;		/* device ID info	*/
309 	uint32_t	Revision;		/* device revision	*/
310 	uint32_t	LocalPortNum	:8;	/* link port # SMP came in on */
311 	uint32_t	VendorID	:24;	/* device vendor, per IEEE */
312 } sm_nodeinfo_t;
313 
314 #elif defined(_BIT_FIELDS_LTOH)
315 
316 typedef struct sm_nodeinfo_s {
317 	uint8_t		BaseVersion;		/* supported MAD base version */
318 	uint8_t		ClassVersion;		/* support SMP version	*/
319 	uint8_t		NodeType;		/* node type(CA, switch, etc) */
320 	uint8_t		NumPorts;		/* # of phys ports on node    */
321 	ib_guid_t	SystemImageGUID;	/* GUID associating this node */
322 						/* with nodes controlled by   */
323 						/* common supervisory code    */
324 	ib_guid_t	NodeGUID;		/* GUID of the node itself    */
325 	ib_guid_t	PortGUID;		/* GUID of this port */
326 	uint16_t	PartitionCap;		/* # of entries in part. tbl. */
327 	uint16_t	DeviceID;		/* device ID info	*/
328 	uint32_t	Revision;		/* device revision	*/
329 	uint32_t	VendorID	:24;	/* device vendor, per IEEE */
330 	uint32_t	LocalPortNum	:8;	/* link port # SMP came in on */
331 } sm_nodeinfo_t;
332 #else
333 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
334 #endif /* _BIT_FIELDS_HTOL */
335 
336 /* Defines and Masks that go with NodeInfo */
337 #define	SM_NODE_TYPE_CA				0x01
338 #define	SM_NODE_TYPE_SWITCH			0x02
339 #define	SM_NODE_TYPE_ROUTER			0x03
340 
341 /* SwitchInfo: Table 129 */
342 #if defined(_BIT_FIELDS_HTOL)
343 typedef struct sm_switchinfo_s {
344 	uint16_t	LinearFDBCap;		/* max # of lin FDB entries */
345 	uint16_t	RandomFDBCap;		/* max # of ran FDB entries */
346 	uint16_t	MulticastFDBCap;	/* max # of mc  FDB entries */
347 	uint16_t	LinearFDBTop;		/* top of the linear FDB */
348 	uint8_t		DefaultPort;		/* port when DLID not in FDB */
349 	uint8_t		DefaultMulticastPrimaryPort; /* mcast port when DLID */
350 						/* not in FDB */
351 	uint8_t		DefaultMulticastNotPrimaryPort;	/* mcast port when */
352 						/* pkts from def port */
353 						/* have DLID not in FDB */
354 	uint8_t		LifeTimeValue	:5;	/* time pkt can live in sw */
355 	uint8_t		PortStateChange :1; 	/* change in port state value */
356 	uint8_t		Reserved	:2;
357 	uint16_t	LIDsPerPort;		/* max # of LID/LMCs per port */
358 	uint16_t	PartitionEnforcementCap; /* max entries in p. enf tbl */
359 	uint8_t		PartitionChecks	:4;	/* switch enforcement knobs */
360 	uint8_t		EnhancedPort0	:1;	/* enhanced port 0 supported */
361 	uint8_t		Reserved2	:3;
362 } sm_switchinfo_t;
363 
364 #elif defined(_BIT_FIELDS_LTOH)
365 
366 typedef struct sm_switchinfo_s {
367 	uint16_t	LinearFDBCap;		/* max # of lin FDB entries */
368 	uint16_t	RandomFDBCap;		/* max # of ran FDB entries */
369 	uint16_t	MulticastFDBCap;	/* max # of mc  FDB entries */
370 	uint16_t	LinearFDBTop;		/* top of the linear FDB */
371 	uint8_t		DefaultPort;		/* port when DLID not in FDB */
372 	uint8_t		DefaultMulticastPrimaryPort; /* mcast port when DLID */
373 						/* not in FDB */
374 	uint8_t		DefaultMulticastNotPrimaryPort;	/* mcast port when */
375 						/* pkts from def port */
376 						/* have DLID not in FDB */
377 	uint8_t		Reserved	:2;
378 	uint8_t		PortStateChange :1; 	/* change in port state value */
379 	uint8_t		LifeTimeValue	:5;	/* time pkt can live in sw */
380 	uint16_t	LIDsPerPort;		/* max # of LID/LMCs per port */
381 	uint16_t	PartitionEnforcementCap; /* max entries in p. enf tbl */
382 	uint8_t		Reserved2	:3;
383 	uint8_t		EnhancedPort0	:1;	/* enhanced port 0 supported */
384 	uint8_t		PartitionChecks	:4;	/* switch enforcement knobs */
385 } sm_switchinfo_t;
386 #else
387 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
388 #endif /* _BIT_FIELDS_HTOL */
389 
390 /* Defines and Masks that go with SwitchInfo */
391 #define	SM_PORT_STATE_CHANGE_CLEAR		0x1
392 #define	SM_SWITCH_PART_ENF_IN			0x8
393 #define	SM_SWITCH_PART_ENF_IN_MASK		0x8
394 #define	SM_SWITCH_PART_ENF_OUT			0x4
395 #define	SM_SWITCH_PART_ENF_OUT_MASK		0x4
396 #define	SM_SWITCH_FILTER_RAW_IN			0x2
397 #define	SM_SWITCH_FILTER_RAW_IN_MASK		0x2
398 #define	SM_SWITCH_FILTER_RAW_OUT		0x1
399 #define	SM_SWITCH_FILTER_RAW_OUT_MASK		0x1
400 
401 /* GUIDInfo: Table 130 */
402 typedef struct sm_guidinfo_s {
403 	ib_guid_t	GUIDBlocks[8];
404 } sm_guidinfo_t;
405 
406 /* defines that go with guid info */
407 #define	SM_GUIDINFO_BLOCK_MAX			31
408 
409 /*
410  * PortInfo: Table 132
411  * PortInfo is applicable to all ports of a node.
412  */
413 #if defined(_BIT_FIELDS_HTOL)
414 typedef struct sm_portinfo_s {
415 	uint64_t	M_Key;			/* M_key		*/
416 	ib_sn_prefix_t	GidPrefix;		/* Gid prefix		*/
417 	ib_lid_t	LID;			/* base LID of the port	*/
418 	ib_lid_t	MasterSMLID;		/* LID of the master SM	*/
419 	uint32_t	CapabilityMask;		/* Capability Mask	*/
420 	uint16_t	DiagCode;		/* diag code		*/
421 	uint16_t	M_KeyLeasePeriod;	/* M_key lease period	*/
422 	uint8_t		LocalPortNum;		/* port which recvd the MAD */
423 	uint8_t		LinkWidthEnabled;	/* link width(s) enabled */
424 	uint8_t		LinkWidthSupported;	/* widths supported by port  */
425 	uint8_t		LinkWidthActive;	/* Currently active width    */
426 	uint8_t		LinkSpeedSupported:4;	/* link speed supported */
427 	uint8_t		PortState	:4;	/* port state */
428 	uint8_t		PortPhysicalState:4;	/* port physical state */
429 	uint8_t		LinkDownDefaultState:4;   /* see spec description */
430 	uint8_t		M_KeyProtectBits:2;	/* M-key protection bits */
431 	uint8_t		Reserved	:3;
432 	uint8_t		LMC		:3;	/* LID mask count */
433 	uint8_t		LinkSpeedActive	:4;	/* current active link speed */
434 	uint8_t		LinkSpeedEnabled:4;	/* enabled link speed */
435 	uint8_t		NeighborMTU	:4;	/* Active max MTU for port */
436 	uint8_t		MasterSMSL	:4;	/* admin SL of master SM */
437 	uint8_t		VLCap		:4;	/* virtual lanes supported */
438 	uint8_t		InitType	:4;	/* type of init requested */
439 	uint8_t		VLHighLimit;		/* VL high pri limit	*/
440 	uint8_t		VLArbitrationHighCap;	/* max high pri entries in  */
441 						/* VL arbitration table */
442 	uint8_t		VLArbitrationLowCap;	/* max low pri entries  */
443 	uint8_t		InitTypeReply	:4;	/* type of init performed */
444 	uint8_t		MTUCap		:4;	/* max MTU supported */
445 	uint8_t		VLStallCount	:3;	/* # pkts to enter stall st. */
446 	uint8_t		HOQLife		:5;	/* time pkt can live at HOQ */
447 	uint8_t		OperationalVLs	:4;	/* virtual lanes operational */
448 	uint8_t		PartitionChecks	:4;	/* port enforcement knbos */
449 	uint16_t	M_KeyViolations;	/* count of M_key violations */
450 	uint16_t	P_KeyViolations;	/* count of P_key violations */
451 	uint16_t	Q_KeyViolations;	/* count of Q_key violations */
452 	uint8_t		GUIDCap;		/* number of GUIDs supported */
453 	uint8_t		Reserved2	:3;
454 	uint8_t		SubnetTimeOut	:5;	/* defines subnet prop. dely */
455 	uint8_t		Reserved3	:3;
456 	uint8_t		RespTimeValue	:5;	/* defines resp time to SMPs */
457 	uint8_t		LocalPhyErrors	:4;	/* threshold for errors */
458 	uint8_t		OverrunErrors	:4;	/* threshold for errors */
459 } sm_portinfo_t;
460 
461 #elif defined(_BIT_FIELDS_LTOH)
462 
463 typedef struct sm_portinfo_s {
464 	uint64_t	M_Key;			/* M_key		*/
465 	ib_sn_prefix_t	GidPrefix;		/* Gid prefix		*/
466 	ib_lid_t	LID;			/* base LID of the port	*/
467 	ib_lid_t	MasterSMLID;		/* LID of the master SM	*/
468 	uint32_t	CapabilityMask;		/* Capability Mask	*/
469 	uint16_t	DiagCode;		/* diag code		*/
470 	uint16_t	M_KeyLeasePeriod;	/* M_key lease period	*/
471 	uint8_t		LocalPortNum;		/* port which recvd the MAD */
472 	uint8_t		LinkWidthEnabled;	/* link width(s) enabled */
473 	uint8_t		LinkWidthSupported;	/* widths supported by port  */
474 	uint8_t		LinkWidthActive;	/* Currently active width    */
475 	uint8_t		PortState	:4;	/* port state */
476 	uint8_t		LinkSpeedSupported:4;	/* link speed supported */
477 	uint8_t		LinkDownDefaultState:4;   /* see spec description */
478 	uint8_t		PortPhysicalState:4;	/* port physical state */
479 	uint8_t		LMC		:3;	/* LID mask count */
480 	uint8_t		Reserved	:3;
481 	uint8_t		M_KeyProtectBits:2;	/* M-key protection bits */
482 	uint8_t		LinkSpeedEnabled:4;	/* enabled link speed */
483 	uint8_t		LinkSpeedActive	:4;	/* current active link speed */
484 	uint8_t		MasterSMSL	:4;	/* admin SL of master SM */
485 	uint8_t		NeighborMTU	:4;	/* Active max MTU for port */
486 	uint8_t		InitType	:4;	/* type of init requested */
487 	uint8_t		VLCap		:4;	/* virtual lanes supported */
488 	uint8_t		VLHighLimit;		/* VL high pri limit	*/
489 	uint8_t		VLArbitrationHighCap;	/* max high pri entries in  */
490 						/* VL arbitration table */
491 	uint8_t		VLArbitrationLowCap;	/* max low pri entries  */
492 	uint8_t		MTUCap		:4;	/* max MTU supported */
493 	uint8_t		InitTypeReply	:4;	/* type of init performed */
494 	uint8_t		HOQLife		:5;	/* time pkt can live at HOQ */
495 	uint8_t		VLStallCount	:3;	/* # pkts to enter stall st. */
496 	uint8_t		PartitionChecks	:4;	/* port enforcement knbos */
497 	uint8_t		OperationalVLs	:4;	/* virtual lanes operational */
498 	uint16_t	M_KeyViolations;	/* count of M_key violations */
499 	uint16_t	P_KeyViolations;	/* count of P_key violations */
500 	uint16_t	Q_KeyViolations;	/* count of Q_key violations */
501 	uint8_t		GUIDCap;		/* number of GUIDs supported */
502 	uint8_t		SubnetTimeOut	:5;	/* defines subnet prop. dely */
503 	uint8_t		Reserved2	:3;
504 	uint8_t		RespTimeValue	:5;	/* defines resp time to SMPs */
505 	uint8_t		Reserved3	:3;
506 	uint8_t		OverrunErrors	:4;	/* threshold for errors */
507 	uint8_t		LocalPhyErrors	:4;	/* threshold for errors */
508 } sm_portinfo_t;
509 #else
510 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
511 #endif /* _BIT_FIELDS_HTOL */
512 
513 /* Defines and Masks that go with PortInfo */
514 #define	SM_CAP_MASK_IS_SM			0x00000002
515 #define	SM_CAP_MASK_IS_NOTICE_SUPPD		0x00000004
516 #define	SM_CAP_MASK_IS_TRAP_SUPPD		0x00000008
517 #define	SM_CAP_MASK_IS_RESET_SUPPD		0x00000010
518 #define	SM_CAP_MASK_IS_APM_SUPPD		0x00000020
519 #define	SM_CAP_MASK_IS_SLMAPP_SUPPD		0x00000040
520 #define	SM_CAP_MASK_IS_NVRAM_MKEY		0x00000080
521 #define	SM_CAP_MASK_IS_NVRAM_PKEY		0x00000100
522 #define	SM_CAP_MASK_IS_LEDINFO_SUPPD		0x00000200
523 #define	SM_CAP_MASK_IS_SM_DISABLED		0x00000400
524 #define	SM_CAP_MASK_IS_SYSIMG_GUID_DISABLED	0x00000800
525 #define	SM_CAP_MASK_IS_PKEY_SW_TRAP_DISABLED	0x00001000
526 #define	SM_CAP_MASK_IS_CM_SUPPD			0x00010000
527 #define	SM_CAP_MASK_IS_SNMP_SUPPD		0x00020000
528 #define	SM_CAP_MASK_IS_DM_SUPPD			0x00080000
529 #define	SM_CAP_MASK_IS_VM_SUPPD			0x00100000
530 #define	SM_CAP_MASK_IS_DR_NOTICE_SUPPD		0x00200000
531 #define	SM_CAP_MASK_IS_CAP_MASK_NOTICE_SUPPD	0x00400000
532 #define	SM_CAP_MASK_IS_BOOT_MGMT_SUPPD		0x00800000
533 
534 /* Standard Encoding of DiagCode Bits 3-0: Table 133 */
535 #define	SM_DIAG_CODE_PORT_READY			0x0
536 #define	SM_DIAG_CODE_PERFORMING_SELF_TEST	0x1
537 #define	SM_DIAG_CODE_INITIALIZING		0x2
538 #define	SM_DIAG_CODE_SOFT_ERROR			0x3
539 #define	SM_DIAG_CODE_HARD_ERROR			0x4
540 
541 #define	SM_LINK_WIDTH_ENABLED_NOP		0x00
542 #define	SM_LINK_WIDTH_ENABLED_1X		0x01
543 #define	SM_LINK_WIDTH_ENABLED_4X		0x02
544 #define	SM_LINK_WIDTH_ENABLED_1X_4X		0x03
545 #define	SM_LINK_WIDTH_ENABLED_12X		0x08
546 #define	SM_LINK_WIDTH_ENABLED_1X_12X		0x09
547 #define	SM_LINK_WIDTH_ENABLED_4X_12X		0x0A
548 #define	SM_LINK_WIDTH_ENABLED_1X_4X_12X		0x0B
549 #define	SM_LINK_WIDTH_ENABLED_SUPPORTED		0xFF
550 
551 #define	SM_LINK_WIDTH_SUPP_1X			0x01
552 #define	SM_LINK_WIDTH_SUPP_1X_4X		0x03
553 #define	SM_LINK_WIDTH_SUPP_1X_4X_12X		0x0B
554 
555 #define	SM_LINK_WIDTH_ACTIVE_1X			0x01
556 #define	SM_LINK_WIDTH_ACTIVE_4X			0x02
557 #define	SM_LINK_WIDTH_ACTIVE_12X		0x08
558 
559 #define	SM_LINK_SPEED_SUPP_2_5_GBPS		0x1
560 
561 #define	SM_PORT_STATE_NOP			0x0
562 #define	SM_PORT_STATE_DOWN			0x1
563 #define	SM_PORT_STATE_INITIALIZE		0x2
564 #define	SM_PORT_STATE_ARMED			0x3
565 #define	SM_PORT_STATE_ACTIVE			0x4
566 
567 #define	SM_PORT_PHYS_STATE_NOP			0x0
568 #define	SM_PORT_PHYS_STATE_SLEEP		0x1
569 #define	SM_PORT_PHYS_STATE_POLLING		0x2
570 #define	SM_PORT_PHYS_STATE_DISABLED		0x3
571 #define	SM_PORT_PHYS_STATE_TRAINING		0x4
572 #define	SM_PORT_PHYS_STATE_LINK_UP		0x5
573 #define	SM_PORT_PHYS_STATE_LINK_REC		0x6
574 
575 #define	SM_LINK_DOWN_DEFAULT_NOP		0x0
576 #define	SM_LINK_DOWN_DEFAULT_SLEEP		0x1
577 #define	SM_LINK_DOWN_DEFAULT_POLLING		0x2
578 
579 /* MKey Protection Levels: Table 115 */
580 #define	SM_MKEY_PROT_BITS_ALL_SUCCEED		0x0
581 #define	SM_MKEY_PROT_BITS_GETRESP_RESETS	0x1
582 #define	SM_MKEY_PROT_BITS_SET_FAIL		0x2
583 #define	SM_MKEY_PROT_BITS_SET_FAILX		0x3
584 
585 #define	SM_LINK_SPEED_ACTIVE_2_5_GBPS		0x1
586 
587 #define	SM_LINK_SPEED_ENABLED_NOP		0x0
588 #define	SM_LINK_SPEED_ENABLED_2_5_GBPS		0x1
589 #define	SM_LINK_SPEED_ENABLED_SUPP_VALUE	0xF
590 
591 #define	SM_NEIGHBOR_MTU_256			0x1
592 #define	SM_NEIGHBOR_MTU_512			0x2
593 #define	SM_NEIGHBOR_MTU_1024			0x3
594 #define	SM_NEIGHBOR_MTU_2048			0x4
595 #define	SM_NEIGHBOR_MTU_4096			0x5
596 
597 #define	SM_VL_CAP_VL0				0x1
598 #define	SM_VL_CAP_VL0_VL1			0x2
599 #define	SM_VL_CAP_VL0_VL3			0x3
600 #define	SM_VL_CAP_VL0_VL7			0x4
601 #define	SM_VL_CAP_VL0_VL14			0x5
602 
603 #define	SM_INIT_TYPE_NO_LOAD			0x1
604 #define	SM_INIT_TYPE_PRESERVE_CONTENT		0x2
605 #define	SM_INIT_TYPE_PRESERVE_PRESENCE		0x4
606 #define	SM_INIT_TYPE_DO_NOT_RESUSCITATE		0x8
607 
608 #define	SM_INIT_TYPE_REPLY_NO_LOAD_REPLY	0x1
609 #define	SM_INIT_TYPE_PRESERVE_CONTENT_REPLY	0x2
610 #define	SM_INIT_TYPE_PRESERVE_PRESENCE_REPLY	0x4
611 
612 #define	SM_MTU_CAP_256				0x1
613 #define	SM_MTU_CAP_512				0x2
614 #define	SM_MTU_CAP_1024				0x3
615 #define	SM_MTU_CAP_2048				0x4
616 #define	SM_MTU_CAP_4096				0x5
617 
618 #define	SM_HOQ_LIFE_INFINITY			19  /* from IB spec 18.2.5.4 */
619 
620 #define	SM_OPERATIONAL_VLS_NOP			0x0
621 #define	SM_OPERATIONAL_VLS_VL0			0x1
622 #define	SM_OPERATIONAL_VLS_VL0_VL1		0x2
623 #define	SM_OPERATIONAL_VLS_VL0_VL3		0x3
624 #define	SM_OPERATIONAL_VLS_VL0_VL7		0x4
625 #define	SM_OPERATIONAL_VLS_VLO_VL14		0x5
626 
627 #define	SM_PART_ENF_IN_BOUND			0x8
628 #define	SM_PART_ENF_OUT_BOUND			0x4
629 #define	SM_FILTER_RAW_IN_BOUND			0x2
630 #define	SM_FILTER_RAW_OUT_BOUND			0x1
631 
632 /* P_Key Table: Table 134 */
633 typedef struct sm_pkey_table_s {
634 	uint16_t P_KeyTableBlocks[32];	/* List of 32 P_Key Block Elements */
635 } sm_pkey_table_t;
636 
637 /* P_Key Block Element: Table 135 */
638 #if defined(_BIT_FIELDS_HTOL)
639 typedef struct sm_pkey_block_element_s {
640 	uint16_t MembershipType	:1;	/* 0 is limited; 1 is full type */
641 	uint16_t P_KeyBase	:15;	/* base value of P_Key */
642 } sm_pkey_block_element_t;
643 
644 #elif defined(_BIT_FIELDS_LTOH)
645 
646 typedef struct sm_pkey_block_element_s {
647 	uint16_t P_KeyBase	:15;	/* base value of P_Key */
648 	uint16_t MembershipType	:1;	/* 0 is limited; 1 is full type */
649 } sm_pkey_block_element_t;
650 #else
651 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
652 #endif /* _BIT_FIELDS_HTOL */
653 
654 /*
655  * SLtoVLMapping Table: Table 136
656  * Each field specifies the VL onto which packets using that SL are dropped.
657  */
658 #if defined(_BIT_FIELDS_HTOL)
659 typedef struct sm_SLtoVL_mapping_table_s {
660 	uint8_t	SL0toVL			:4;
661 	uint8_t	SL1toVL			:4;
662 	uint8_t	SL2toVL			:4;
663 	uint8_t	SL3toVL			:4;
664 	uint8_t	SL4toVL			:4;
665 	uint8_t	SL5toVL			:4;
666 	uint8_t	SL6toVL			:4;
667 	uint8_t	SL7toVL			:4;
668 	uint8_t	SL8toVL			:4;
669 	uint8_t	SL9toVL			:4;
670 	uint8_t	SL10toVL		:4;
671 	uint8_t	SL11toVL		:4;
672 	uint8_t	SL12toVL		:4;
673 	uint8_t	SL13toVL		:4;
674 	uint8_t	SL14toVL		:4;
675 	uint8_t	SL15toVL		:4;
676 } sm_SLtoVL_mapping_table_t;
677 
678 #elif defined(_BIT_FIELDS_LTOH)
679 
680 typedef struct sm_SLtoVL_mapping_table_s {
681 	uint8_t	SL1toVL			:4;
682 	uint8_t	SL0toVL			:4;
683 	uint8_t	SL3toVL			:4;
684 	uint8_t	SL2toVL			:4;
685 	uint8_t	SL5toVL			:4;
686 	uint8_t	SL4toVL			:4;
687 	uint8_t	SL7toVL			:4;
688 	uint8_t	SL6toVL			:4;
689 	uint8_t	SL9toVL			:4;
690 	uint8_t	SL8toVL			:4;
691 	uint8_t	SL11toVL		:4;
692 	uint8_t	SL10toVL		:4;
693 	uint8_t	SL13toVL		:4;
694 	uint8_t	SL12toVL		:4;
695 	uint8_t	SL15toVL		:4;
696 	uint8_t	SL14toVL		:4;
697 } sm_SLtoVL_mapping_table_t;
698 #else
699 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
700 #endif /* _BIT_FIELDS_HTOL */
701 
702 /* VL/Weight Block Element: Table 138 */
703 typedef struct sm_VL_weight_block_s {
704 	uint8_t	Reserved		:4;
705 	uint8_t	VL			:4; /* VL assoc. with this element */
706 	uint8_t	Weight;			   /* weight assoc. with this element */
707 } sm_VL_weight_block_t;
708 
709 /* VLArbitration Table: Table 137 */
710 typedef struct sm_VLarb_table_s {
711 	sm_VL_weight_block_t VLWeightPairs[32];
712 } sm_VLarb_table_t;
713 
714 /* Defines and masks that go with VLArbitrationTable & address modifier */
715 #define	SM_LOW_PRI_VL_ARB_LOWER_32		0x1
716 #define	SM_LOW_PRI_VL_ARB_UPPER_32		0x2
717 #define	SM_HI_PRI_VL_ARB_LOWER_32		0x3
718 #define	SM_HI_PRI_VL_ARB_UPPER_32		0x4
719 
720 /* Defines that go with the linear forwarding table */
721 #define	SM_LFT_BLOCK_MAX			767
722 #define	SM_LFT_PORTS_PER_BLOCK			64
723 
724 /* Linear Forwarding Table: Table 139 */
725 typedef struct sm_linear_forwarding_table_s {
726 	uint8_t	PortBlocks[64];
727 } sm_linear_forwarding_table_t;
728 
729 /* LID/Port Block Element: Table 142 */
730 #if defined(_BIT_FIELDS_HTOL)
731 typedef struct sm_lid_port_block_s {
732 	ib_lid_t	LID;		    /* base LID */
733 	uint8_t		Valid		:1; /* this LID/Port pair is valid */
734 	uint8_t		LMC		:3; /* the LMC of this lid */
735 	uint8_t		Reserved	:4;
736 	uint8_t		Port;		    /* port to forward entries to */
737 } sm_lid_port_block_t;
738 
739 #elif defined(_BIT_FIELDS_LTOH)
740 
741 typedef struct sm_lid_port_block_s {
742 	ib_lid_t	LID;		    /* base LID */
743 	uint8_t		Reserved	:4;
744 	uint8_t		LMC		:3; /* the LMC of this lid */
745 	uint8_t		Valid		:1; /* this LID/Port pair is valid */
746 	uint8_t		Port;		    /* port to forward entries to */
747 } sm_lid_port_block_t;
748 #else
749 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
750 #endif /* _BIT_FIELDS_HTOL */
751 
752 /* Random Forwarding Table: Table 141 */
753 typedef struct sm_random_forwarding_table_s {
754 	sm_lid_port_block_t	LIDPortBlocks[16];
755 } sm_random_forwarding_table_t;
756 
757 /* Multicast Forwarding Table: Table 143 */
758 typedef struct sm_multicast_forwarding_table_s {
759 	uint16_t	PortMaskBlocks[32];
760 } sm_multicast_forwarding_table_t;
761 
762 /*
763  * SMInfo: Table 145
764  * SMInfo struct is applicable to all end ports hosting an SM
765  */
766 #if defined(_BIT_FIELDS_HTOL)
767 typedef struct sm_sminfo_s {
768 	ib_guid_t	GUID;			/* Port GUID hosting the SM */
769 	uint64_t	SM_Key;			/* Key of the SM */
770 	uint32_t	ActCount;		/* heartbeat counter */
771 	uint8_t		Priority	:4;	/* priority */
772 	uint8_t		SMState		:4;	/* SM's state */
773 } sm_sminfo_t;
774 
775 #elif defined(_BIT_FIELDS_LTOH)
776 
777 typedef struct sm_sminfo_s {
778 	ib_guid_t	GUID;			/* Port GUID hosting the SM */
779 	uint64_t	SM_Key;			/* Key of the SM */
780 	uint32_t	ActCount;		/* heartbeat counter */
781 	uint8_t		SMState		:4;	/* SM's state */
782 	uint8_t		Priority	:4;	/* priority */
783 } sm_sminfo_t;
784 
785 #else
786 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
787 #endif /* _BIT_FIELDS_HTOL */
788 
789 /* defines that go with the sminfo structure */
790 
791 /* SMState Defines */
792 #define	SM_SMSTATE_INACTIVE		0
793 #define	SM_SMSTATE_DISCOVERING		1
794 #define	SM_SMSTATE_STANDBY		2
795 #define	SM_SMSTATE_MASTER		3
796 
797 /* SMInfo Control Packets: Table 148 */
798 #define	SM_SMINFO_AM_HANDOVER		1
799 #define	SM_SMINFO_AM_ACKNOWLEDGE	2
800 #define	SM_SMINFO_AM_DISABLE		3
801 #define	SM_SMINFO_AM_STANDBY		4
802 #define	SM_SMINFO_AM_DISCOVER		5
803 
804 /* attribute ID defines */
805 #define	SM_NOTICE_ATTRID		0x02
806 #define	SM_NODEDESC_ATTRID		0x10
807 #define	SM_NODEINFO_ATTRID		0x11
808 #define	SM_SWITCHINFO_ATTRID		0x12
809 #define	SM_GUIDINFO_ATTRID		0x14
810 #define	SM_PORTINFO_ATTRID		0x15
811 #define	SM_PKEY_TABLE_ATTRID		0x16
812 #define	SM_SLTOVLTABLE_ATTRID		0x17
813 #define	SM_VLARBITRATION_ATTRID		0x18
814 #define	SM_LINEARFDB_ATTRID		0x19
815 #define	SM_RANDOMFDB_ATTRID		0x1A
816 #define	SM_MCASTFDB_ATTRID		0x1B
817 #define	SM_SMINFO_ATTRID		0x20
818 #define	SM_VENDORDIAG_ATTRID		0x30
819 #define	SM_LEDINFO_ATTRID		0x31
820 
821 /* VendorDiag: Table 146 */
822 typedef struct sm_vendor_diag_s {
823 	uint16_t	NextIndex;	/* next attr mod to get diag info */
824 	uint8_t		DiagData[62];	/* vendor specific diag info */
825 } sm_vendor_diag_t;
826 
827 /* LedInfo: Table 147 */
828 #if defined(_BIT_FIELDS_HTOL)
829 typedef struct sm_ledinfo_s {
830 	uint32_t	LedMask		:1;	/* 1 for LED on, 0 for off */
831 	uint32_t	Reserved	:31;
832 } sm_ledinfo_t;
833 
834 #elif defined(_BIT_FIELDS_LTOH)
835 
836 typedef struct sm_ledinfo_s {
837 	uint32_t	Reserved	:31;
838 	uint32_t	LedMask		:1;	/* 1 for LED on, 0 for off */
839 } sm_ledinfo_t;
840 
841 #else
842 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
843 #endif /* _BIT_FIELDS_HTOL */
844 
845 /* LED Info Defines */
846 #define	SM_LEDINFO_ON	0x1
847 #define	SM_LEDINFO_OFF	0x0
848 
849 #ifdef __cplusplus
850 }
851 #endif
852 
853 #endif /* _SYS_IB_MGT_SM_ATTR_H */
854