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