xref: /illumos-gate/usr/src/uts/common/sys/ib/mgt/sm_attr.h (revision a38ddfee9c8c6b6c5a2947ff52fd2338362a4444)
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 2008 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		Reserved2	:3;
451 	uint8_t		SubnetTimeOut	:5;	/* defines subnet prop. dely */
452 	uint8_t		Reserved3	:3;
453 	uint8_t		RespTimeValue	:5;	/* defines resp time to SMPs */
454 	uint8_t		LocalPhyErrors	:4;	/* threshold for errors */
455 	uint8_t		OverrunErrors	:4;	/* threshold for errors */
456 } sm_portinfo_t;
457 
458 #elif defined(_BIT_FIELDS_LTOH)
459 
460 typedef struct sm_portinfo_s {
461 	uint64_t	M_Key;			/* M_key		*/
462 	ib_sn_prefix_t	GidPrefix;		/* Gid prefix		*/
463 	ib_lid_t	LID;			/* base LID of the port	*/
464 	ib_lid_t	MasterSMLID;		/* LID of the master SM	*/
465 	uint32_t	CapabilityMask;		/* Capability Mask	*/
466 	uint16_t	DiagCode;		/* diag code		*/
467 	uint16_t	M_KeyLeasePeriod;	/* M_key lease period	*/
468 	uint8_t		LocalPortNum;		/* port which recvd the MAD */
469 	uint8_t		LinkWidthEnabled;	/* link width(s) enabled */
470 	uint8_t		LinkWidthSupported;	/* widths supported by port  */
471 	uint8_t		LinkWidthActive;	/* Currently active width    */
472 	uint8_t		PortState	:4;	/* port state */
473 	uint8_t		LinkSpeedSupported:4;	/* link speed supported */
474 	uint8_t		LinkDownDefaultState:4;   /* see spec description */
475 	uint8_t		PortPhysicalState:4;	/* port physical state */
476 	uint8_t		LMC		:3;	/* LID mask count */
477 	uint8_t		Reserved	:3;
478 	uint8_t		M_KeyProtectBits:2;	/* M-key protection bits */
479 	uint8_t		LinkSpeedEnabled:4;	/* enabled link speed */
480 	uint8_t		LinkSpeedActive	:4;	/* current active link speed */
481 	uint8_t		MasterSMSL	:4;	/* admin SL of master SM */
482 	uint8_t		NeighborMTU	:4;	/* Active max MTU for port */
483 	uint8_t		InitType	:4;	/* type of init requested */
484 	uint8_t		VLCap		:4;	/* virtual lanes supported */
485 	uint8_t		VLHighLimit;		/* VL high pri limit	*/
486 	uint8_t		VLArbitrationHighCap;	/* max high pri entries in  */
487 						/* VL arbitration table */
488 	uint8_t		VLArbitrationLowCap;	/* max low pri entries  */
489 	uint8_t		MTUCap		:4;	/* max MTU supported */
490 	uint8_t		InitTypeReply	:4;	/* type of init performed */
491 	uint8_t		HOQLife		:5;	/* time pkt can live at HOQ */
492 	uint8_t		VLStallCount	:3;	/* # pkts to enter stall st. */
493 	uint8_t		PartitionChecks	:4;	/* port enforcement knbos */
494 	uint8_t		OperationalVLs	:4;	/* virtual lanes operational */
495 	uint16_t	M_KeyViolations;	/* count of M_key violations */
496 	uint16_t	P_KeyViolations;	/* count of P_key violations */
497 	uint16_t	Q_KeyViolations;	/* count of Q_key violations */
498 	uint8_t		GUIDCap;		/* number of GUIDs supported */
499 	uint8_t		SubnetTimeOut	:5;	/* defines subnet prop. dely */
500 	uint8_t		Reserved2	:3;
501 	uint8_t		RespTimeValue	:5;	/* defines resp time to SMPs */
502 	uint8_t		Reserved3	:3;
503 	uint8_t		OverrunErrors	:4;	/* threshold for errors */
504 	uint8_t		LocalPhyErrors	:4;	/* threshold for errors */
505 } sm_portinfo_t;
506 #else
507 #error	One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
508 #endif /* _BIT_FIELDS_HTOL */
509 
510 /* Defines and Masks that go with PortInfo */
511 #define	SM_CAP_MASK_IS_SM			0x00000002
512 #define	SM_CAP_MASK_IS_NOTICE_SUPPD		0x00000004
513 #define	SM_CAP_MASK_IS_TRAP_SUPPD		0x00000008
514 #define	SM_CAP_MASK_IS_RESET_SUPPD		0x00000010
515 #define	SM_CAP_MASK_IS_APM_SUPPD		0x00000020
516 #define	SM_CAP_MASK_IS_SLMAPP_SUPPD		0x00000040
517 #define	SM_CAP_MASK_IS_NVRAM_MKEY		0x00000080
518 #define	SM_CAP_MASK_IS_NVRAM_PKEY		0x00000100
519 #define	SM_CAP_MASK_IS_LEDINFO_SUPPD		0x00000200
520 #define	SM_CAP_MASK_IS_SM_DISABLED		0x00000400
521 #define	SM_CAP_MASK_IS_SYSIMG_GUID_DISABLED	0x00000800
522 #define	SM_CAP_MASK_IS_PKEY_SW_TRAP_DISABLED	0x00001000
523 #define	SM_CAP_MASK_IS_CM_SUPPD			0x00010000
524 #define	SM_CAP_MASK_IS_SNMP_SUPPD		0x00020000
525 #define	SM_CAP_MASK_IS_DM_SUPPD			0x00080000
526 #define	SM_CAP_MASK_IS_VM_SUPPD			0x00100000
527 #define	SM_CAP_MASK_IS_DR_NOTICE_SUPPD		0x00200000
528 #define	SM_CAP_MASK_IS_CAP_MASK_NOTICE_SUPPD	0x00400000
529 #define	SM_CAP_MASK_IS_BOOT_MGMT_SUPPD		0x00800000
530 
531 /* Standard Encoding of DiagCode Bits 3-0: Table 133 */
532 #define	SM_DIAG_CODE_PORT_READY			0x0
533 #define	SM_DIAG_CODE_PERFORMING_SELF_TEST	0x1
534 #define	SM_DIAG_CODE_INITIALIZING		0x2
535 #define	SM_DIAG_CODE_SOFT_ERROR			0x3
536 #define	SM_DIAG_CODE_HARD_ERROR			0x4
537 
538 #define	SM_LINK_WIDTH_ENABLED_NOP		0x00
539 #define	SM_LINK_WIDTH_ENABLED_1X		0x01
540 #define	SM_LINK_WIDTH_ENABLED_4X		0x02
541 #define	SM_LINK_WIDTH_ENABLED_1X_4X		0x03
542 #define	SM_LINK_WIDTH_ENABLED_12X		0x08
543 #define	SM_LINK_WIDTH_ENABLED_1X_12X		0x09
544 #define	SM_LINK_WIDTH_ENABLED_4X_12X		0x0A
545 #define	SM_LINK_WIDTH_ENABLED_1X_4X_12X		0x0B
546 #define	SM_LINK_WIDTH_ENABLED_SUPPORTED		0xFF
547 
548 #define	SM_LINK_WIDTH_SUPP_1X			0x01
549 #define	SM_LINK_WIDTH_SUPP_1X_4X		0x03
550 #define	SM_LINK_WIDTH_SUPP_1X_4X_12X		0x0B
551 
552 #define	SM_LINK_WIDTH_ACTIVE_1X			0x01
553 #define	SM_LINK_WIDTH_ACTIVE_4X			0x02
554 #define	SM_LINK_WIDTH_ACTIVE_8X			0x04
555 #define	SM_LINK_WIDTH_ACTIVE_12X		0x08
556 
557 #define	SM_LINK_SPEED_SUPP_2_5_GBPS		0x1
558 
559 #define	SM_PORT_STATE_NOP			0x0
560 #define	SM_PORT_STATE_DOWN			0x1
561 #define	SM_PORT_STATE_INITIALIZE		0x2
562 #define	SM_PORT_STATE_ARMED			0x3
563 #define	SM_PORT_STATE_ACTIVE			0x4
564 
565 #define	SM_PORT_PHYS_STATE_NOP			0x0
566 #define	SM_PORT_PHYS_STATE_SLEEP		0x1
567 #define	SM_PORT_PHYS_STATE_POLLING		0x2
568 #define	SM_PORT_PHYS_STATE_DISABLED		0x3
569 #define	SM_PORT_PHYS_STATE_TRAINING		0x4
570 #define	SM_PORT_PHYS_STATE_LINK_UP		0x5
571 #define	SM_PORT_PHYS_STATE_LINK_REC		0x6
572 
573 #define	SM_LINK_DOWN_DEFAULT_NOP		0x0
574 #define	SM_LINK_DOWN_DEFAULT_SLEEP		0x1
575 #define	SM_LINK_DOWN_DEFAULT_POLLING		0x2
576 
577 /* MKey Protection Levels: Table 115 */
578 #define	SM_MKEY_PROT_BITS_ALL_SUCCEED		0x0
579 #define	SM_MKEY_PROT_BITS_GETRESP_RESETS	0x1
580 #define	SM_MKEY_PROT_BITS_SET_FAIL		0x2
581 #define	SM_MKEY_PROT_BITS_SET_FAILX		0x3
582 
583 #define	SM_LINK_SPEED_ACTIVE_2_5_GBPS		0x1
584 #define	SM_LINK_SPEED_ACTIVE_5_GBPS		0x2
585 #define	SM_LINK_SPEED_ACTIVE_10_GBPS		0x4
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