]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ofed/management/opensm/include/iba/ib_types.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ofed / management / opensm / include / iba / ib_types.h
1 /*
2  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
3  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenIB.org BSD license below:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      - Redistributions of source code must retain the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer.
19  *
20  *      - Redistributions in binary form must reproduce the above
21  *        copyright notice, this list of conditions and the following
22  *        disclaimer in the documentation and/or other materials
23  *        provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  *
34  */
35
36 #if !defined(__IB_TYPES_H__)
37 #define __IB_TYPES_H__
38
39 #include <string.h>
40 #include <complib/cl_types.h>
41 #include <complib/cl_byteswap.h>
42
43 #ifdef __cplusplus
44 #  define BEGIN_C_DECLS extern "C" {
45 #  define END_C_DECLS   }
46 #else                           /* !__cplusplus */
47 #  define BEGIN_C_DECLS
48 #  define END_C_DECLS
49 #endif                          /* __cplusplus */
50
51 BEGIN_C_DECLS
52 #if defined( WIN32 ) || defined( _WIN64 )
53 #if defined( EXPORT_AL_SYMBOLS )
54 #define OSM_EXPORT      __declspec(dllexport)
55 #else
56 #define OSM_EXPORT      __declspec(dllimport)
57 #endif
58 #define OSM_API __stdcall
59 #define OSM_CDECL __cdecl
60 #else
61 #define OSM_EXPORT      extern
62 #define OSM_API
63 #define OSM_CDECL
64 #define __ptr64
65 #endif
66 /****h* IBA Base/Constants
67 * NAME
68 *       Constants
69 *
70 * DESCRIPTION
71 *       The following constants are used throughout the IBA code base.
72 *
73 *       Definitions are from the InfiniBand Architecture Specification v1.2
74 *
75 *********/
76 /****d* IBA Base: Constants/MAD_BLOCK_SIZE
77 * NAME
78 *       MAD_BLOCK_SIZE
79 *
80 * DESCRIPTION
81 *       Size of a non-RMPP MAD datagram.
82 *
83 * SOURCE
84 */
85 #define MAD_BLOCK_SIZE                                          256
86 /**********/
87 /****d* IBA Base: Constants/MAD_RMPP_HDR_SIZE
88 * NAME
89 *       MAD_RMPP_HDR_SIZE
90 *
91 * DESCRIPTION
92 *       Size of an RMPP header, including the common MAD header.
93 *
94 * SOURCE
95 */
96 #define MAD_RMPP_HDR_SIZE                                       36
97 /**********/
98 /****d* IBA Base: Constants/MAD_RMPP_DATA_SIZE
99 * NAME
100 *       MAD_RMPP_DATA_SIZE
101 *
102 * DESCRIPTION
103 *       Size of an RMPP transaction data section.
104 *
105 * SOURCE
106 */
107 #define MAD_RMPP_DATA_SIZE              (MAD_BLOCK_SIZE - MAD_RMPP_HDR_SIZE)
108 /**********/
109 /****d* IBA Base: Constants/MAD_BLOCK_GRH_SIZE
110 * NAME
111 *       MAD_BLOCK_GRH_SIZE
112 *
113 * DESCRIPTION
114 *       Size of a MAD datagram, including the GRH.
115 *
116 * SOURCE
117 */
118 #define MAD_BLOCK_GRH_SIZE                                      296
119 /**********/
120 /****d* IBA Base: Constants/IB_LID_PERMISSIVE
121 * NAME
122 *       IB_LID_PERMISSIVE
123 *
124 * DESCRIPTION
125 *       Permissive LID
126 *
127 * SOURCE
128 */
129 #define IB_LID_PERMISSIVE                                       0xFFFF
130 /**********/
131 /****d* IBA Base: Constants/IB_DEFAULT_PKEY
132 * NAME
133 *       IB_DEFAULT_PKEY
134 *
135 * DESCRIPTION
136 *       P_Key value for the default partition.
137 *
138 * SOURCE
139 */
140 #define IB_DEFAULT_PKEY                                         0xFFFF
141 /**********/
142 /****d* IBA Base: Constants/IB_QP1_WELL_KNOWN_Q_KEY
143 * NAME
144 *       IB_QP1_WELL_KNOWN_Q_KEY
145 *
146 * DESCRIPTION
147 *       Well-known Q_Key for QP1 privileged mode access (15.4.2).
148 *
149 * SOURCE
150 */
151 #define IB_QP1_WELL_KNOWN_Q_KEY                         CL_HTON32(0x80010000)
152 /*********/
153 #define IB_QP0                                                          0
154 #define IB_QP1                                                          CL_HTON32(1)
155 #define IB_QP_PRIVILEGED_Q_KEY                          CL_HTON32(0x80000000)
156 /****d* IBA Base: Constants/IB_LID_UCAST_START
157 * NAME
158 *       IB_LID_UCAST_START
159 *
160 * DESCRIPTION
161 *       Lowest valid unicast LID value.
162 *
163 * SOURCE
164 */
165 #define IB_LID_UCAST_START_HO                           0x0001
166 #define IB_LID_UCAST_START                                      (CL_HTON16(IB_LID_UCAST_START_HO))
167 /**********/
168 /****d* IBA Base: Constants/IB_LID_UCAST_END
169 * NAME
170 *       IB_LID_UCAST_END
171 *
172 * DESCRIPTION
173 *       Highest valid unicast LID value.
174 *
175 * SOURCE
176 */
177 #define IB_LID_UCAST_END_HO                                     0xBFFF
178 #define IB_LID_UCAST_END                                        (CL_HTON16(IB_LID_UCAST_END_HO))
179 /**********/
180 /****d* IBA Base: Constants/IB_LID_MCAST_START
181 * NAME
182 *       IB_LID_MCAST_START
183 *
184 * DESCRIPTION
185 *       Lowest valid multicast LID value.
186 *
187 * SOURCE
188 */
189 #define IB_LID_MCAST_START_HO                           0xC000
190 #define IB_LID_MCAST_START                                      (CL_HTON16(IB_LID_MCAST_START_HO))
191 /**********/
192 /****d* IBA Base: Constants/IB_LID_MCAST_END
193 * NAME
194 *       IB_LID_MCAST_END
195 *
196 * DESCRIPTION
197 *       Highest valid multicast LID value.
198 *
199 * SOURCE
200 */
201 #define IB_LID_MCAST_END_HO                                     0xFFFE
202 #define IB_LID_MCAST_END                                        (CL_HTON16(IB_LID_MCAST_END_HO))
203 /**********/
204 /****d* IBA Base: Constants/IB_DEFAULT_SUBNET_PREFIX
205 * NAME
206 *       IB_DEFAULT_SUBNET_PREFIX
207 *
208 * DESCRIPTION
209 *       Default subnet GID prefix.
210 *
211 * SOURCE
212 */
213 #define IB_DEFAULT_SUBNET_PREFIX                        (CL_HTON64(0xFE80000000000000ULL))
214 /**********/
215 /****d* IBA Base: Constants/IB_NODE_NUM_PORTS_MAX
216 * NAME
217 *       IB_NODE_NUM_PORTS_MAX
218 *
219 * DESCRIPTION
220 *       Maximum number of ports in a single node (14.2.5.7).
221 * SOURCE
222 */
223 #define IB_NODE_NUM_PORTS_MAX                           0xFE
224 /**********/
225 /****d* IBA Base: Constants/IB_INVALID_PORT_NUM
226 * NAME
227 *       IB_INVALID_PORT_NUM
228 *
229 * DESCRIPTION
230 *       Value used to indicate an invalid port number (14.2.5.10).
231 *
232 * SOURCE
233 */
234 #define IB_INVALID_PORT_NUM                                     0xFF
235 /*********/
236 /****d* IBA Base: Constants/IB_SUBNET_PATH_HOPS_MAX
237 * NAME
238 *       IB_SUBNET_PATH_HOPS_MAX
239 *
240 * DESCRIPTION
241 *       Maximum number of directed route switch hops in a subnet (14.2.1.2).
242 *
243 * SOURCE
244 */
245 #define IB_SUBNET_PATH_HOPS_MAX                         64
246 /*********/
247 /****d* IBA Base: Constants/IB_HOPLIMIT_MAX
248 * NAME
249 *       IB_HOPLIMIT_MAX
250 *
251 * DESCRIPTION
252 *       Maximum number of router hops allowed.
253 *
254 * SOURCE
255 */
256 #define IB_HOPLIMIT_MAX                                 255
257 /*********/
258 /****d* IBA Base: Constants/IB_MC_SCOPE_*
259 * NAME
260 *       IB_MC_SCOPE_*
261 *
262 * DESCRIPTION
263 *       Scope component definitions from IBA 1.2 (Table 3 p. 146)
264 */
265 #define IB_MC_SCOPE_LINK_LOCAL          0x2
266 #define IB_MC_SCOPE_SITE_LOCAL          0x5
267 #define IB_MC_SCOPE_ORG_LOCAL           0x8
268 #define IB_MC_SCOPE_GLOBAL              0xE
269 /*********/
270 /****d* IBA Base: Constants/IB_PKEY_MAX_BLOCKS
271 * NAME
272 *       IB_PKEY_MAX_BLOCKS
273 *
274 * DESCRIPTION
275 *       Maximum number of PKEY blocks (14.2.5.7).
276 *
277 * SOURCE
278 */
279 #define IB_PKEY_MAX_BLOCKS                                      2048
280 /*********/
281 /****d* IBA Base: Constants/IB_MCAST_MAX_BLOCK_ID
282 * NAME
283 *       IB_MCAST_MAX_BLOCK_ID
284 *
285 * DESCRIPTION
286 *       Maximum number of Multicast port mask blocks
287 *
288 * SOURCE
289 */
290 #define IB_MCAST_MAX_BLOCK_ID                           511
291 /*********/
292 /****d* IBA Base: Constants/IB_MCAST_BLOCK_ID_MASK_HO
293 * NAME
294 *       IB_MCAST_BLOCK_ID_MASK_HO
295 *
296 * DESCRIPTION
297 *       Mask (host order) to recover the Multicast block ID.
298 *
299 * SOURCE
300 */
301 #define IB_MCAST_BLOCK_ID_MASK_HO                       0x000001FF
302 /*********/
303 /****d* IBA Base: Constants/IB_MCAST_BLOCK_SIZE
304 * NAME
305 *       IB_MCAST_BLOCK_SIZE
306 *
307 * DESCRIPTION
308 *       Number of port mask entries in a multicast forwarding table block.
309 *
310 * SOURCE
311 */
312 #define IB_MCAST_BLOCK_SIZE                                     32
313 /*********/
314 /****d* IBA Base: Constants/IB_MCAST_MASK_SIZE
315 * NAME
316 *       IB_MCAST_MASK_SIZE
317 *
318 * DESCRIPTION
319 *       Number of port mask bits in each entry in the multicast forwarding table.
320 *
321 * SOURCE
322 */
323 #define IB_MCAST_MASK_SIZE                                      16
324 /*********/
325 /****d* IBA Base: Constants/IB_MCAST_POSITION_MASK_HO
326 * NAME
327 *       IB_MCAST_POSITION_MASK_HO
328 *
329 * DESCRIPTION
330 *       Mask (host order) to recover the multicast block position.
331 *
332 * SOURCE
333 */
334 #define IB_MCAST_POSITION_MASK_HO                               0xF0000000
335 /*********/
336 /****d* IBA Base: Constants/IB_MCAST_POSITION_MAX
337 * NAME
338 *       IB_MCAST_POSITION_MAX
339 *
340 * DESCRIPTION
341 *       Maximum value for the multicast block position.
342 *
343 * SOURCE
344 */
345 #define IB_MCAST_POSITION_MAX                           0xF
346 /*********/
347 /****d* IBA Base: Constants/IB_MCAST_POSITION_SHIFT
348 * NAME
349 *       IB_MCAST_POSITION_SHIFT
350 *
351 * DESCRIPTION
352 *       Shift value to normalize the multicast block position value.
353 *
354 * SOURCE
355 */
356 #define IB_MCAST_POSITION_SHIFT                         28
357 /*********/
358 /****d* IBA Base: Constants/IB_PKEY_ENTRIES_MAX
359 * NAME
360 *       IB_PKEY_ENTRIES_MAX
361 *
362 * DESCRIPTION
363 *       Maximum number of PKEY entries per port (14.2.5.7).
364 *
365 * SOURCE
366 */
367 #define IB_PKEY_ENTRIES_MAX (IB_PKEY_MAX_BLOCKS * IB_NUM_PKEY_ELEMENTS_IN_BLOCK)
368 /*********/
369 /****d* IBA Base: Constants/IB_PKEY_BASE_MASK
370 * NAME
371 *       IB_PKEY_BASE_MASK
372 *
373 * DESCRIPTION
374 *       Masks for the base P_Key value given a P_Key Entry.
375 *
376 * SOURCE
377 */
378 #define IB_PKEY_BASE_MASK                                       (CL_HTON16(0x7FFF))
379 /*********/
380 /****d* IBA Base: Constants/IB_PKEY_TYPE_MASK
381 * NAME
382 *       IB_PKEY_TYPE_MASK
383 *
384 * DESCRIPTION
385 *       Masks for the P_Key membership type given a P_Key Entry.
386 *
387 * SOURCE
388 */
389 #define IB_PKEY_TYPE_MASK                                       (CL_HTON16(0x8000))
390 /*********/
391 /****d* IBA Base: Constants/IB_DEFAULT_PARTIAL_PKEY
392 * NAME
393 *       IB_DEFAULT_PARTIAL_PKEY
394 *
395 * DESCRIPTION
396 *       0x7FFF in network order
397 *
398 * SOURCE
399 */
400 #define IB_DEFAULT_PARTIAL_PKEY                                (CL_HTON16(0x7FFF))
401 /**********/
402 /****d* IBA Base: Constants/IB_MCLASS_SUBN_LID
403 * NAME
404 *       IB_MCLASS_SUBN_LID
405 *
406 * DESCRIPTION
407 *       Subnet Management Class, Subnet Manager LID routed (13.4.4)
408 *
409 * SOURCE
410 */
411 #define IB_MCLASS_SUBN_LID                                      0x01
412 /**********/
413 /****d* IBA Base: Constants/IB_MCLASS_SUBN_DIR
414 * NAME
415 *       IB_MCLASS_SUBN_DIR
416 *
417 * DESCRIPTION
418 *       Subnet Management Class, Subnet Manager directed route (13.4.4)
419 *
420 * SOURCE
421 */
422 #define IB_MCLASS_SUBN_DIR                                      0x81
423 /**********/
424 /****d* IBA Base: Constants/IB_MCLASS_SUBN_ADM
425 * NAME
426 *       IB_MCLASS_SUBN_ADM
427 *
428 * DESCRIPTION
429 *       Management Class, Subnet Administration (13.4.4)
430 *
431 * SOURCE
432 */
433 #define IB_MCLASS_SUBN_ADM                                      0x03
434 /**********/
435 /****d* IBA Base: Constants/IB_MCLASS_PERF
436 * NAME
437 *       IB_MCLASS_PERF
438 *
439 * DESCRIPTION
440 *       Management Class, Performance Management (13.4.4)
441 *
442 * SOURCE
443 */
444 #define IB_MCLASS_PERF                                          0x04
445 /**********/
446 /****d* IBA Base: Constants/IB_MCLASS_BM
447 * NAME
448 *       IB_MCLASS_BM
449 *
450 * DESCRIPTION
451 *       Management Class, Baseboard Management (13.4.4)
452 *
453 * SOURCE
454 */
455 #define IB_MCLASS_BM                                            0x05
456 /**********/
457 /****d* IBA Base: Constants/IB_MCLASS_DEV_MGMT
458 * NAME
459 *       IB_MCLASS_DEV_MGMT
460 *
461 * DESCRIPTION
462 *       Management Class, Device Management (13.4.4)
463 *
464 * SOURCE
465 */
466 #define IB_MCLASS_DEV_MGMT                                      0x06
467 /**********/
468 /****d* IBA Base: Constants/IB_MCLASS_COMM_MGMT
469 * NAME
470 *       IB_MCLASS_COMM_MGMT
471 *
472 * DESCRIPTION
473 *       Management Class, Communication Management (13.4.4)
474 *
475 * SOURCE
476 */
477 #define IB_MCLASS_COMM_MGMT                                     0x07
478 /**********/
479 /****d* IBA Base: Constants/IB_MCLASS_SNMP
480 * NAME
481 *       IB_MCLASS_SNMP
482 *
483 * DESCRIPTION
484 *       Management Class, SNMP Tunneling (13.4.4)
485 *
486 * SOURCE
487 */
488 #define IB_MCLASS_SNMP                                          0x08
489 /**********/
490 /****d* IBA Base: Constants/IB_MCLASS_VENDOR_LOW_RANGE_MIN
491 * NAME
492 *       IB_MCLASS_VENDOR_LOW_RANGE_MIN
493 *
494 * DESCRIPTION
495 *       Management Class, Vendor Specific Low Range Start
496 *
497 * SOURCE
498 */
499 #define IB_MCLASS_VENDOR_LOW_RANGE_MIN 0x09
500 /**********/
501 /****d* IBA Base: Constants/IB_MCLASS_VENDOR_LOW_RANGE_MAX
502 * NAME
503 *       IB_MCLASS_VENDOR_LOW_RANGE_MAX
504 *
505 * DESCRIPTION
506 *       Management Class, Vendor Specific Low Range End
507 *
508 * SOURCE
509 */
510 #define IB_MCLASS_VENDOR_LOW_RANGE_MAX 0x0f
511 /**********/
512 /****d* IBA Base: Constants/IB_MCLASS_DEV_ADM
513 * NAME
514 *       IB_MCLASS_DEV_ADM
515 *
516 * DESCRIPTION
517 *       Management Class, Device Administration
518 *
519 * SOURCE
520 */
521 #define IB_MCLASS_DEV_ADM 0x10
522 /**********/
523 /****d* IBA Base: Constants/IB_MCLASS_BIS
524 * NAME
525 *       IB_MCLASS_BIS
526 *
527 * DESCRIPTION
528 *       Management Class, BIS
529 *
530 * SOURCE
531 */
532 #define IB_MCLASS_BIS 0x12
533 /**********/
534 /****d* IBA Base: Constants/IB_MCLASS_VENDOR_HIGH_RANGE_MIN
535 * NAME
536 *       IB_MCLASS_VENDOR_HIGH_RANGE_MIN
537 *
538 * DESCRIPTION
539 *       Management Class, Vendor Specific High Range Start
540 *
541 * SOURCE
542 */
543 #define IB_MCLASS_VENDOR_HIGH_RANGE_MIN 0x30
544 /**********/
545 /****d* IBA Base: Constants/IB_MCLASS_VENDOR_HIGH_RANGE_MAX
546 * NAME
547 *       IB_MCLASS_VENDOR_HIGH_RANGE_MAX
548 *
549 * DESCRIPTION
550 *       Management Class, Vendor Specific High Range End
551 *
552 * SOURCE
553 */
554 #define IB_MCLASS_VENDOR_HIGH_RANGE_MAX 0x4f
555 /**********/
556 /****f* IBA Base: Types/ib_class_is_vendor_specific_low
557 * NAME
558 *       ib_class_is_vendor_specific_low
559 *
560 * DESCRIPTION
561 *       Indicates if the Class Code if a vendor specific class from
562 *  the low range
563 *
564 * SYNOPSIS
565 */
566 static inline boolean_t OSM_API
567 ib_class_is_vendor_specific_low(IN const uint8_t class_code)
568 {
569         return ((class_code >= IB_MCLASS_VENDOR_LOW_RANGE_MIN) &&
570                 (class_code <= IB_MCLASS_VENDOR_LOW_RANGE_MAX));
571 }
572
573 /*
574 * PARAMETERS
575 *       class_code
576 *               [in] The Management Datagram Class Code
577 *
578 * RETURN VALUE
579 *       TRUE if the class is in the Low range of Vendor Specific MADs
580 *       FALSE otherwise.
581 *
582 * NOTES
583 *
584 * SEE ALSO
585 * IB_MCLASS_VENDOR_LOW_RANGE_MIN, IB_MCLASS_VENDOR_LOW_RANGE_MAX
586 *********/
587
588 /****f* IBA Base: Types/ib_class_is_vendor_specific_high
589 * NAME
590 *       ib_class_is_vendor_specific_high
591 *
592 * DESCRIPTION
593 *       Indicates if the Class Code if a vendor specific class from
594 *  the high range
595 *
596 * SYNOPSIS
597 */
598 static inline boolean_t OSM_API
599 ib_class_is_vendor_specific_high(IN const uint8_t class_code)
600 {
601         return ((class_code >= IB_MCLASS_VENDOR_HIGH_RANGE_MIN) &&
602                 (class_code <= IB_MCLASS_VENDOR_HIGH_RANGE_MAX));
603 }
604
605 /*
606 * PARAMETERS
607 *       class_code
608 *               [in] The Management Datagram Class Code
609 *
610 * RETURN VALUE
611 *       TRUE if the class is in the High range of Vendor Specific MADs
612 *       FALSE otherwise.
613 *
614 * NOTES
615 *
616 * SEE ALSO
617 * IB_MCLASS_VENDOR_HIGH_RANGE_MIN, IB_MCLASS_VENDOR_HIGH_RANGE_MAX
618 *********/
619
620 /****f* IBA Base: Types/ib_class_is_vendor_specific
621 * NAME
622 *       ib_class_is_vendor_specific
623 *
624 * DESCRIPTION
625 *       Indicates if the Class Code if a vendor specific class
626 *
627 * SYNOPSIS
628 */
629 static inline boolean_t OSM_API
630 ib_class_is_vendor_specific(IN const uint8_t class_code)
631 {
632         return (ib_class_is_vendor_specific_low(class_code) ||
633                 ib_class_is_vendor_specific_high(class_code));
634 }
635
636 /*
637 * PARAMETERS
638 *       class_code
639 *               [in] The Management Datagram Class Code
640 *
641 * RETURN VALUE
642 *       TRUE if the class is a Vendor Specific MAD
643 *       FALSE otherwise.
644 *
645 * NOTES
646 *
647 * SEE ALSO
648 *  ib_class_is_vendor_specific_low, ib_class_is_vendor_specific_high
649 *********/
650
651 /****f* IBA Base: Types/ib_class_is_rmpp
652 * NAME
653 *       ib_class_is_rmpp
654 *
655 * DESCRIPTION
656 *       Indicates if the Class Code supports RMPP
657 *
658 * SYNOPSIS
659 */
660 static inline boolean_t OSM_API ib_class_is_rmpp(IN const uint8_t class_code)
661 {
662         return ((class_code == IB_MCLASS_SUBN_ADM) ||
663                 (class_code == IB_MCLASS_DEV_MGMT) ||
664                 (class_code == IB_MCLASS_DEV_ADM) ||
665                 (class_code == IB_MCLASS_BIS) ||
666                 ib_class_is_vendor_specific_high(class_code));
667 }
668
669 /*
670 * PARAMETERS
671 *       class_code
672 *               [in] The Management Datagram Class Code
673 *
674 * RETURN VALUE
675 *       TRUE if the class supports RMPP
676 *       FALSE otherwise.
677 *
678 * NOTES
679 *
680 *********/
681
682 /*
683  *      MAD methods
684  */
685
686 /****d* IBA Base: Constants/IB_MAX_METHOD
687 * NAME
688 *       IB_MAX_METHOD
689 *
690 * DESCRIPTION
691 *       Total number of methods available to a class, not including the R-bit.
692 *
693 * SOURCE
694 */
695 #define IB_MAX_METHODS                                          128
696 /**********/
697
698 /****d* IBA Base: Constants/IB_MAD_METHOD_RESP_MASK
699 * NAME
700 *       IB_MAD_METHOD_RESP_MASK
701 *
702 * DESCRIPTION
703 *       Response mask to extract 'R' bit from the method field. (13.4.5)
704 *
705 * SOURCE
706 */
707 #define IB_MAD_METHOD_RESP_MASK                         0x80
708 /**********/
709
710 /****d* IBA Base: Constants/IB_MAD_METHOD_GET
711 * NAME
712 *       IB_MAD_METHOD_GET
713 *
714 * DESCRIPTION
715 *       Get() Method (13.4.5)
716 *
717 * SOURCE
718 */
719 #define IB_MAD_METHOD_GET                                       0x01
720 /**********/
721
722 /****d* IBA Base: Constants/IB_MAD_METHOD_SET
723 * NAME
724 *       IB_MAD_METHOD_SET
725 *
726 * DESCRIPTION
727 *       Set() Method (13.4.5)
728 *
729 * SOURCE
730 */
731 #define IB_MAD_METHOD_SET                                       0x02
732 /**********/
733
734 /****d* IBA Base: Constants/IB_MAD_METHOD_GET_RESP
735 * NAME
736 *       IB_MAD_METHOD_GET_RESP
737 *
738 * DESCRIPTION
739 *       GetResp() Method (13.4.5)
740 *
741 * SOURCE
742 */
743 #define IB_MAD_METHOD_GET_RESP                          0x81
744 /**********/
745
746 #define IB_MAD_METHOD_DELETE                            0x15
747
748 /****d* IBA Base: Constants/IB_MAD_METHOD_GETTABLE
749 * NAME
750 *       IB_MAD_METHOD_GETTABLE
751 *
752 * DESCRIPTION
753 *       SubnAdmGetTable() Method (15.2.2)
754 *
755 * SOURCE
756 */
757 #define IB_MAD_METHOD_GETTABLE                          0x12
758 /**********/
759
760 /****d* IBA Base: Constants/IB_MAD_METHOD_GETTABLE_RESP
761 * NAME
762 *       IB_MAD_METHOD_GETTABLE_RESP
763 *
764 * DESCRIPTION
765 *       SubnAdmGetTableResp() Method (15.2.2)
766 *
767 * SOURCE
768 */
769 #define IB_MAD_METHOD_GETTABLE_RESP                     0x92
770
771 /**********/
772
773 #define IB_MAD_METHOD_GETTRACETABLE                     0x13
774 #define IB_MAD_METHOD_GETMULTI                          0x14
775 #define IB_MAD_METHOD_GETMULTI_RESP                     0x94
776
777 /****d* IBA Base: Constants/IB_MAD_METHOD_SEND
778 * NAME
779 *       IB_MAD_METHOD_SEND
780 *
781 * DESCRIPTION
782 *       Send() Method (13.4.5)
783 *
784 * SOURCE
785 */
786 #define IB_MAD_METHOD_SEND                                      0x03
787 /**********/
788
789 /****d* IBA Base: Constants/IB_MAD_METHOD_TRAP
790 * NAME
791 *       IB_MAD_METHOD_TRAP
792 *
793 * DESCRIPTION
794 *       Trap() Method (13.4.5)
795 *
796 * SOURCE
797 */
798 #define IB_MAD_METHOD_TRAP                                      0x05
799 /**********/
800
801 /****d* IBA Base: Constants/IB_MAD_METHOD_REPORT
802 * NAME
803 *       IB_MAD_METHOD_REPORT
804 *
805 * DESCRIPTION
806 *       Report() Method (13.4.5)
807 *
808 * SOURCE
809 */
810 #define IB_MAD_METHOD_REPORT                            0x06
811 /**********/
812
813 /****d* IBA Base: Constants/IB_MAD_METHOD_REPORT_RESP
814 * NAME
815 *       IB_MAD_METHOD_REPORT_RESP
816 *
817 * DESCRIPTION
818 *       ReportResp() Method (13.4.5)
819 *
820 * SOURCE
821 */
822 #define IB_MAD_METHOD_REPORT_RESP                       0x86
823 /**********/
824
825 /****d* IBA Base: Constants/IB_MAD_METHOD_TRAP_REPRESS
826 * NAME
827 *       IB_MAD_METHOD_TRAP_REPRESS
828 *
829 * DESCRIPTION
830 *       TrapRepress() Method (13.4.5)
831 *
832 * SOURCE
833 */
834 #define IB_MAD_METHOD_TRAP_REPRESS                      0x07
835 /**********/
836
837 /****d* IBA Base: Constants/IB_MAD_STATUS_BUSY
838 * NAME
839 *       IB_MAD_STATUS_BUSY
840 *
841 * DESCRIPTION
842 *       Temporarily busy, MAD discarded (13.4.7)
843 *
844 * SOURCE
845 */
846 #define IB_MAD_STATUS_BUSY                              (CL_HTON16(0x0001))
847 /**********/
848
849 /****d* IBA Base: Constants/IB_MAD_STATUS_REDIRECT
850 * NAME
851 *       IB_MAD_STATUS_REDIRECT
852 *
853 * DESCRIPTION
854 *       QP Redirection required (13.4.7)
855 *
856 * SOURCE
857 */
858 #define IB_MAD_STATUS_REDIRECT                          (CL_HTON16(0x0002))
859 /**********/
860
861 /****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_CLASS_VER
862 * NAME
863 *       IB_MAD_STATUS_UNSUP_CLASS_VER
864 *
865 * DESCRIPTION
866 *       Unsupported class version (13.4.7)
867 *
868 * SOURCE
869 */
870 #define IB_MAD_STATUS_UNSUP_CLASS_VER                   (CL_HTON16(0x0004))
871 /**********/
872
873 /****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_METHOD
874 * NAME
875 *       IB_MAD_STATUS_UNSUP_METHOD
876 *
877 * DESCRIPTION
878 *       Unsupported method (13.4.7)
879 *
880 * SOURCE
881 */
882 #define IB_MAD_STATUS_UNSUP_METHOD                      (CL_HTON16(0x0008))
883 /**********/
884
885 /****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_METHOD_ATTR
886 * NAME
887 *       IB_MAD_STATUS_UNSUP_METHOD_ATTR
888 *
889 * DESCRIPTION
890 *       Unsupported method/attribute combination (13.4.7)
891 *
892 * SOURCE
893 */
894 #define IB_MAD_STATUS_UNSUP_METHOD_ATTR                 (CL_HTON16(0x000C))
895 /**********/
896
897 /****d* IBA Base: Constants/IB_MAD_STATUS_INVALID_FIELD
898 * NAME
899 *       IB_MAD_STATUS_INVALID_FIELD
900 *
901 * DESCRIPTION
902 *       Attribute contains one or more invalid fields (13.4.7)
903 *
904 * SOURCE
905 */
906 #define IB_MAD_STATUS_INVALID_FIELD                     (CL_HTON16(0x001C))
907 /**********/
908
909 #define IB_MAD_STATUS_CLASS_MASK                        (CL_HTON16(0xFF00))
910
911 #define IB_SA_MAD_STATUS_SUCCESS                        (CL_HTON16(0x0000))
912 #define IB_SA_MAD_STATUS_NO_RESOURCES                   (CL_HTON16(0x0100))
913 #define IB_SA_MAD_STATUS_REQ_INVALID                    (CL_HTON16(0x0200))
914 #define IB_SA_MAD_STATUS_NO_RECORDS                     (CL_HTON16(0x0300))
915 #define IB_SA_MAD_STATUS_TOO_MANY_RECORDS               (CL_HTON16(0x0400))
916 #define IB_SA_MAD_STATUS_INVALID_GID                    (CL_HTON16(0x0500))
917 #define IB_SA_MAD_STATUS_INSUF_COMPS                    (CL_HTON16(0x0600))
918 #define IB_SA_MAD_STATUS_DENIED                         (CL_HTON16(0x0700))
919 #define IB_SA_MAD_STATUS_PRIO_SUGGESTED                 (CL_HTON16(0x0800))
920
921 #define IB_DM_MAD_STATUS_NO_IOC_RESP                    (CL_HTON16(0x0100))
922 #define IB_DM_MAD_STATUS_NO_SVC_ENTRIES                 (CL_HTON16(0x0200))
923 #define IB_DM_MAD_STATUS_IOC_FAILURE                    (CL_HTON16(0x8000))
924
925 /****d* IBA Base: Constants/IB_MAD_ATTR_CLASS_PORT_INFO
926 * NAME
927 *       IB_MAD_ATTR_CLASS_PORT_INFO
928 *
929 * DESCRIPTION
930 *       ClassPortInfo attribute (13.4.8)
931 *
932 * SOURCE
933 */
934 #define IB_MAD_ATTR_CLASS_PORT_INFO                     (CL_HTON16(0x0001))
935 /**********/
936
937 /****d* IBA Base: Constants/IB_MAD_ATTR_NOTICE
938 * NAME
939 *       IB_MAD_ATTR_NOTICE
940 *
941 * DESCRIPTION
942 *       Notice attribute (13.4.8)
943 *
944 * SOURCE
945 */
946 #define IB_MAD_ATTR_NOTICE                                      (CL_HTON16(0x0002))
947 /**********/
948
949 /****d* IBA Base: Constants/IB_MAD_ATTR_INFORM_INFO
950 * NAME
951 *       IB_MAD_ATTR_INFORM_INFO
952 *
953 * DESCRIPTION
954 *       InformInfo attribute (13.4.8)
955 *
956 * SOURCE
957 */
958 #define IB_MAD_ATTR_INFORM_INFO                         (CL_HTON16(0x0003))
959 /**********/
960
961 /****d* IBA Base: Constants/IB_MAD_ATTR_NODE_DESC
962 * NAME
963 *       IB_MAD_ATTR_NODE_DESC
964 *
965 * DESCRIPTION
966 *       NodeDescription attribute (14.2.5)
967 *
968 * SOURCE
969 */
970 #define IB_MAD_ATTR_NODE_DESC                           (CL_HTON16(0x0010))
971
972 /****d* IBA Base: Constants/IB_MAD_ATTR_PORT_SMPL_CTRL
973 * NAME
974 *       IB_MAD_ATTR_PORT_SMPL_CTRL
975 *
976 * DESCRIPTION
977 *       PortSamplesControl attribute (16.1.3)
978 *
979 * SOURCE
980 */
981 #define IB_MAD_ATTR_PORT_SMPL_CTRL                      (CL_HTON16(0x0010))
982 /**********/
983
984 /****d* IBA Base: Constants/IB_MAD_ATTR_NODE_INFO
985 * NAME
986 *       IB_MAD_ATTR_NODE_INFO
987 *
988 * DESCRIPTION
989 *       NodeInfo attribute (14.2.5)
990 *
991 * SOURCE
992 */
993 #define IB_MAD_ATTR_NODE_INFO                           (CL_HTON16(0x0011))
994 /**********/
995
996 /****d* IBA Base: Constants/IB_MAD_ATTR_PORT_SMPL_RSLT
997 * NAME
998 *       IB_MAD_ATTR_PORT_SMPL_RSLT
999 *
1000 * DESCRIPTION
1001 *       PortSamplesResult attribute (16.1.3)
1002 *
1003 * SOURCE
1004 */
1005 #define IB_MAD_ATTR_PORT_SMPL_RSLT                      (CL_HTON16(0x0011))
1006 /**********/
1007
1008 /****d* IBA Base: Constants/IB_MAD_ATTR_SWITCH_INFO
1009 * NAME
1010 *       IB_MAD_ATTR_SWITCH_INFO
1011 *
1012 * DESCRIPTION
1013 *       SwitchInfo attribute (14.2.5)
1014 *
1015 * SOURCE
1016 */
1017 #define IB_MAD_ATTR_SWITCH_INFO                         (CL_HTON16(0x0012))
1018 /**********/
1019
1020 /****d* IBA Base: Constants/IB_MAD_ATTR_PORT_CNTRS
1021 * NAME
1022 *       IB_MAD_ATTR_PORT_CNTRS
1023 *
1024 * DESCRIPTION
1025 *       PortCounters attribute (16.1.3)
1026 *
1027 * SOURCE
1028 */
1029 #define IB_MAD_ATTR_PORT_CNTRS                          (CL_HTON16(0x0012))
1030 /**********/
1031
1032 /****d* IBA Base: Constants/IB_MAD_ATTR_GUID_INFO
1033 * NAME
1034 *       IB_MAD_ATTR_GUID_INFO
1035 *
1036 * DESCRIPTION
1037 *       GUIDInfo attribute (14.2.5)
1038 *
1039 * SOURCE
1040 */
1041 #define IB_MAD_ATTR_GUID_INFO                           (CL_HTON16(0x0014))
1042 /**********/
1043
1044 /****d* IBA Base: Constants/IB_MAD_ATTR_PORT_INFO
1045 * NAME
1046 *       IB_MAD_ATTR_PORT_INFO
1047 *
1048 * DESCRIPTION
1049 *       PortInfo attribute (14.2.5)
1050 *
1051 * SOURCE
1052 */
1053 #define IB_MAD_ATTR_PORT_INFO                           (CL_HTON16(0x0015))
1054 /**********/
1055
1056 /****d* IBA Base: Constants/IB_MAD_ATTR_P_KEY_TABLE
1057 * NAME
1058 *       IB_MAD_ATTR_P_KEY_TABLE
1059 *
1060 * DESCRIPTION
1061 *       PartitionTable attribute (14.2.5)
1062 *
1063 * SOURCE
1064 */
1065 #define IB_MAD_ATTR_P_KEY_TABLE                         (CL_HTON16(0x0016))
1066 /**********/
1067
1068 /****d* IBA Base: Constants/IB_MAD_ATTR_SLVL_TABLE
1069 * NAME
1070 *       IB_MAD_ATTR_SLVL_TABLE
1071 *
1072 * DESCRIPTION
1073 *       SL VL Mapping Table attribute (14.2.5)
1074 *
1075 * SOURCE
1076 */
1077 #define IB_MAD_ATTR_SLVL_TABLE                          (CL_HTON16(0x0017))
1078 /**********/
1079
1080 /****d* IBA Base: Constants/IB_MAD_ATTR_VL_ARBITRATION
1081 * NAME
1082 *       IB_MAD_ATTR_VL_ARBITRATION
1083 *
1084 * DESCRIPTION
1085 *       VL Arbitration Table attribute (14.2.5)
1086 *
1087 * SOURCE
1088 */
1089 #define IB_MAD_ATTR_VL_ARBITRATION                      (CL_HTON16(0x0018))
1090 /**********/
1091
1092 /****d* IBA Base: Constants/IB_MAD_ATTR_LIN_FWD_TBL
1093 * NAME
1094 *       IB_MAD_ATTR_LIN_FWD_TBL
1095 *
1096 * DESCRIPTION
1097 *       Switch linear forwarding table
1098 *
1099 * SOURCE
1100 */
1101 #define IB_MAD_ATTR_LIN_FWD_TBL                         (CL_HTON16(0x0019))
1102 /**********/
1103
1104 /****d* IBA Base: Constants/IB_MAD_ATTR_RND_FWD_TBL
1105 * NAME
1106 *       IB_MAD_ATTR_RND_FWD_TBL
1107 *
1108 * DESCRIPTION
1109 *       Switch random forwarding table
1110 *
1111 * SOURCE
1112 */
1113 #define IB_MAD_ATTR_RND_FWD_TBL                         (CL_HTON16(0x001A))
1114 /**********/
1115
1116 /****d* IBA Base: Constants/IB_MAD_ATTR_MCAST_FWD_TBL
1117 * NAME
1118 *       IB_MAD_ATTR_MCAST_FWD_TBL
1119 *
1120 * DESCRIPTION
1121 *       Switch multicast forwarding table
1122 *
1123 * SOURCE
1124 */
1125 #define IB_MAD_ATTR_MCAST_FWD_TBL                       (CL_HTON16(0x001B))
1126 /**********/
1127
1128 /****d* IBA Base: Constants/IB_MAD_ATTR_NODE_RECORD
1129 * NAME
1130 *       IB_MAD_ATTR_NODE_RECORD
1131 *
1132 * DESCRIPTION
1133 *       NodeRecord attribute (15.2.5)
1134 *
1135 * SOURCE
1136 */
1137 #define IB_MAD_ATTR_NODE_RECORD                         (CL_HTON16(0x0011))
1138 /**********/
1139
1140 /****d* IBA Base: Constants/IB_MAD_ATTR_PORTINFO_RECORD
1141 * NAME
1142 *       IB_MAD_ATTR_PORTINFO_RECORD
1143 *
1144 * DESCRIPTION
1145 *       PortInfoRecord attribute (15.2.5)
1146 *
1147 * SOURCE
1148 */
1149 #define IB_MAD_ATTR_PORTINFO_RECORD                     (CL_HTON16(0x0012))
1150 /**********/
1151
1152 /****d* IBA Base: Constants/IB_MAD_ATTR_SWITCH_INFO_RECORD
1153 * NAME
1154 *       IB_MAD_ATTR_SWITCH_INFO_RECORD
1155 *
1156 * DESCRIPTION
1157 *       SwitchInfoRecord attribute (15.2.5)
1158 *
1159 * SOURCE
1160 */
1161 #define IB_MAD_ATTR_SWITCH_INFO_RECORD                  (CL_HTON16(0x0014))
1162 /**********/
1163
1164 /****d* IBA Base: Constants/IB_MAD_ATTR_LINK_RECORD
1165 * NAME
1166 *       IB_MAD_ATTR_LINK_RECORD
1167 *
1168 * DESCRIPTION
1169 *       LinkRecord attribute (15.2.5)
1170 *
1171 * SOURCE
1172 */
1173 #define IB_MAD_ATTR_LINK_RECORD                         (CL_HTON16(0x0020))
1174 /**********/
1175
1176 /****d* IBA Base: Constants/IB_MAD_ATTR_SM_INFO
1177 * NAME
1178 *       IB_MAD_ATTR_SM_INFO
1179 *
1180 * DESCRIPTION
1181 *       SMInfo attribute (14.2.5)
1182 *
1183 * SOURCE
1184 */
1185 #define IB_MAD_ATTR_SM_INFO                             (CL_HTON16(0x0020))
1186 /**********/
1187
1188 /****d* IBA Base: Constants/IB_MAD_ATTR_SMINFO_RECORD
1189 * NAME
1190 *       IB_MAD_ATTR_SMINFO_RECORD
1191 *
1192 * DESCRIPTION
1193 *       SMInfoRecord attribute (15.2.5)
1194 *
1195 * SOURCE
1196 */
1197 #define IB_MAD_ATTR_SMINFO_RECORD                       (CL_HTON16(0x0018))
1198 /**********/
1199
1200 /****d* IBA Base: Constants/IB_MAD_ATTR_GUIDINFO_RECORD
1201 * NAME
1202 *       IB_MAD_ATTR_GUIDINFO_RECORD
1203 *
1204 * DESCRIPTION
1205 *       GuidInfoRecord attribute (15.2.5)
1206 *
1207 * SOURCE
1208 */
1209 #define IB_MAD_ATTR_GUIDINFO_RECORD                     (CL_HTON16(0x0030))
1210 /**********/
1211
1212 /****d* IBA Base: Constants/IB_MAD_ATTR_VENDOR_DIAG
1213 * NAME
1214 *       IB_MAD_ATTR_VENDOR_DIAG
1215 *
1216 * DESCRIPTION
1217 *       VendorDiag attribute (14.2.5)
1218 *
1219 * SOURCE
1220 */
1221 #define IB_MAD_ATTR_VENDOR_DIAG                         (CL_HTON16(0x0030))
1222 /**********/
1223
1224 /****d* IBA Base: Constants/IB_MAD_ATTR_LED_INFO
1225 * NAME
1226 *       IB_MAD_ATTR_LED_INFO
1227 *
1228 * DESCRIPTION
1229 *       LedInfo attribute (14.2.5)
1230 *
1231 * SOURCE
1232 */
1233 #define IB_MAD_ATTR_LED_INFO                            (CL_HTON16(0x0031))
1234 /**********/
1235
1236 /****d* IBA Base: Constants/IB_MAD_ATTR_SERVICE_RECORD
1237 * NAME
1238 *       IB_MAD_ATTR_SERVICE_RECORD
1239 *
1240 * DESCRIPTION
1241 *       ServiceRecord attribute (15.2.5)
1242 *
1243 * SOURCE
1244 */
1245 #define IB_MAD_ATTR_SERVICE_RECORD                      (CL_HTON16(0x0031))
1246 /**********/
1247
1248 /****d* IBA Base: Constants/IB_MAD_ATTR_LFT_RECORD
1249 * NAME
1250 *       IB_MAD_ATTR_LFT_RECORD
1251 *
1252 * DESCRIPTION
1253 *       LinearForwardingTableRecord attribute (15.2.5.6)
1254 *
1255 * SOURCE
1256 */
1257 #define IB_MAD_ATTR_LFT_RECORD                          (CL_HTON16(0x0015))
1258 /**********/
1259
1260 /****d* IBA Base: Constants/IB_MAD_ATTR_MFT_RECORD
1261 * NAME
1262 *       IB_MAD_ATTR_MFT_RECORD
1263 *
1264 * DESCRIPTION
1265 *       MulticastForwardingTableRecord attribute (15.2.5.8)
1266 *
1267 * SOURCE
1268 */
1269 #define IB_MAD_ATTR_MFT_RECORD                          (CL_HTON16(0x0017))
1270 /**********/
1271
1272 /****d* IBA Base: Constants/IB_MAD_ATTR_PKEYTBL_RECORD
1273 * NAME
1274 *       IB_MAD_ATTR_PKEYTBL_RECORD
1275 *
1276 * DESCRIPTION
1277 *       PKEY Table Record attribute (15.2.5)
1278 *
1279 * SOURCE
1280 */
1281 #define IB_MAD_ATTR_PKEY_TBL_RECORD                     (CL_HTON16(0x0033))
1282 /**********/
1283
1284 /****d* IBA Base: Constants/IB_MAD_ATTR_PATH_RECORD
1285 * NAME
1286 *       IB_MAD_ATTR_PATH_RECORD
1287 *
1288 * DESCRIPTION
1289 *       PathRecord attribute (15.2.5)
1290 *
1291 * SOURCE
1292 */
1293 #define IB_MAD_ATTR_PATH_RECORD                         (CL_HTON16(0x0035))
1294 /**********/
1295
1296 /****d* IBA Base: Constants/IB_MAD_ATTR_VLARB_RECORD
1297 * NAME
1298 *       IB_MAD_ATTR_VLARB_RECORD
1299 *
1300 * DESCRIPTION
1301 *       VL Arbitration Table Record attribute (15.2.5)
1302 *
1303 * SOURCE
1304 */
1305 #define IB_MAD_ATTR_VLARB_RECORD                        (CL_HTON16(0x0036))
1306 /**********/
1307
1308 /****d* IBA Base: Constants/IB_MAD_ATTR_SLVL_RECORD
1309 * NAME
1310 *       IB_MAD_ATTR_SLVL_RECORD
1311 *
1312 * DESCRIPTION
1313 *       SLtoVL Mapping Table Record attribute (15.2.5)
1314 *
1315 * SOURCE
1316 */
1317 #define IB_MAD_ATTR_SLVL_RECORD                         (CL_HTON16(0x0013))
1318 /**********/
1319
1320 /****d* IBA Base: Constants/IB_MAD_ATTR_MCMEMBER_RECORD
1321 * NAME
1322 *       IB_MAD_ATTR_MCMEMBER_RECORD
1323 *
1324 * DESCRIPTION
1325 *       MCMemberRecord attribute (15.2.5)
1326 *
1327 * SOURCE
1328 */
1329 #define IB_MAD_ATTR_MCMEMBER_RECORD                     (CL_HTON16(0x0038))
1330 /**********/
1331
1332 /****d* IBA Base: Constants/IB_MAD_ATTR_TRACE_RECORD
1333 * NAME
1334 *       IB_MAD_ATTR_TRACE_RECORD
1335 *
1336 * DESCRIPTION
1337 *       TraceRecord attribute (15.2.5)
1338 *
1339 * SOURCE
1340 */
1341 #define IB_MAD_ATTR_TRACE_RECORD                        (CL_HTON16(0x0039))
1342 /**********/
1343
1344 /****d* IBA Base: Constants/IB_MAD_ATTR_MULTIPATH_RECORD
1345 * NAME
1346 *       IB_MAD_ATTR_MULTIPATH_RECORD
1347 *
1348 * DESCRIPTION
1349 *       MultiPathRecord attribute (15.2.5)
1350 *
1351 * SOURCE
1352 */
1353 #define IB_MAD_ATTR_MULTIPATH_RECORD                    (CL_HTON16(0x003A))
1354 /**********/
1355
1356 /****d* IBA Base: Constants/IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
1357 * NAME
1358 *       IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
1359 *
1360 * DESCRIPTION
1361 *       Service Association Record attribute (15.2.5)
1362 *
1363 * SOURCE
1364 */
1365 #define IB_MAD_ATTR_SVC_ASSOCIATION_RECORD              (CL_HTON16(0x003B))
1366 /**********/
1367
1368 /****d* IBA Base: Constants/IB_MAD_ATTR_INFORM_INFO_RECORD
1369 * NAME
1370 *       IB_MAD_ATTR_INFORM_INFO_RECORD
1371 *
1372 * DESCRIPTION
1373 *       InformInfo Record attribute (15.2.5)
1374 *
1375 * SOURCE
1376 */
1377 #define IB_MAD_ATTR_INFORM_INFO_RECORD                  (CL_HTON16(0x00F3))
1378
1379 /****d* IBA Base: Constants/IB_MAD_ATTR_IO_UNIT_INFO
1380 * NAME
1381 *       IB_MAD_ATTR_IO_UNIT_INFO
1382 *
1383 * DESCRIPTION
1384 *       IOUnitInfo attribute (16.3.3)
1385 *
1386 * SOURCE
1387 */
1388 #define IB_MAD_ATTR_IO_UNIT_INFO                        (CL_HTON16(0x0010))
1389 /**********/
1390
1391 /****d* IBA Base: Constants/IB_MAD_ATTR_IO_CONTROLLER_PROFILE
1392 * NAME
1393 *       IB_MAD_ATTR_IO_CONTROLLER_PROFILE
1394 *
1395 * DESCRIPTION
1396 *       IOControllerProfile attribute (16.3.3)
1397 *
1398 * SOURCE
1399 */
1400 #define IB_MAD_ATTR_IO_CONTROLLER_PROFILE       (CL_HTON16(0x0011))
1401 /**********/
1402
1403 /****d* IBA Base: Constants/IB_MAD_ATTR_SERVICE_ENTRIES
1404 * NAME
1405 *       IB_MAD_ATTR_SERVICE_ENTRIES
1406 *
1407 * DESCRIPTION
1408 *       ServiceEntries attribute (16.3.3)
1409 *
1410 * SOURCE
1411 */
1412 #define IB_MAD_ATTR_SERVICE_ENTRIES                     (CL_HTON16(0x0012))
1413 /**********/
1414
1415 /****d* IBA Base: Constants/IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT
1416 * NAME
1417 *       IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT
1418 *
1419 * DESCRIPTION
1420 *       DiagnosticTimeout attribute (16.3.3)
1421 *
1422 * SOURCE
1423 */
1424 #define IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT          (CL_HTON16(0x0020))
1425 /**********/
1426
1427 /****d* IBA Base: Constants/IB_MAD_ATTR_PREPARE_TO_TEST
1428 * NAME
1429 *       IB_MAD_ATTR_PREPARE_TO_TEST
1430 *
1431 * DESCRIPTION
1432 *       PrepareToTest attribute (16.3.3)
1433 *
1434 * SOURCE
1435 */
1436 #define IB_MAD_ATTR_PREPARE_TO_TEST                     (CL_HTON16(0x0021))
1437 /**********/
1438
1439 /****d* IBA Base: Constants/IB_MAD_ATTR_TEST_DEVICE_ONCE
1440 * NAME
1441 *       IB_MAD_ATTR_TEST_DEVICE_ONCE
1442 *
1443 * DESCRIPTION
1444 *       TestDeviceOnce attribute (16.3.3)
1445 *
1446 * SOURCE
1447 */
1448 #define IB_MAD_ATTR_TEST_DEVICE_ONCE            (CL_HTON16(0x0022))
1449 /**********/
1450
1451 /****d* IBA Base: Constants/IB_MAD_ATTR_TEST_DEVICE_LOOP
1452 * NAME
1453 *       IB_MAD_ATTR_TEST_DEVICE_LOOP
1454 *
1455 * DESCRIPTION
1456 *       TestDeviceLoop attribute (16.3.3)
1457 *
1458 * SOURCE
1459 */
1460 #define IB_MAD_ATTR_TEST_DEVICE_LOOP            (CL_HTON16(0x0023))
1461 /**********/
1462
1463 /****d* IBA Base: Constants/IB_MAD_ATTR_DIAG_CODE
1464 * NAME
1465 *       IB_MAD_ATTR_DIAG_CODE
1466 *
1467 * DESCRIPTION
1468 *       DiagCode attribute (16.3.3)
1469 *
1470 * SOURCE
1471 */
1472 #define IB_MAD_ATTR_DIAG_CODE                           (CL_HTON16(0x0024))
1473 /**********/
1474
1475 /****d* IBA Base: Constants/IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
1476 * NAME
1477 *       IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
1478 *
1479 * DESCRIPTION
1480 *       Service Association Record attribute (15.2.5)
1481 *
1482 * SOURCE
1483 */
1484 #define IB_MAD_ATTR_SVC_ASSOCIATION_RECORD      (CL_HTON16(0x003B))
1485 /**********/
1486
1487 /****d* IBA Base: Constants/IB_NODE_TYPE_CA
1488 * NAME
1489 *       IB_NODE_TYPE_CA
1490 *
1491 * DESCRIPTION
1492 *       Encoded generic node type used in MAD attributes (13.4.8.2)
1493 *
1494 * SOURCE
1495 */
1496 #define IB_NODE_TYPE_CA                                         0x01
1497 /**********/
1498
1499 /****d* IBA Base: Constants/IB_NODE_TYPE_SWITCH
1500 * NAME
1501 *       IB_NODE_TYPE_SWITCH
1502 *
1503 * DESCRIPTION
1504 *       Encoded generic node type used in MAD attributes (13.4.8.2)
1505 *
1506 * SOURCE
1507 */
1508 #define IB_NODE_TYPE_SWITCH                                     0x02
1509 /**********/
1510
1511 /****d* IBA Base: Constants/IB_NODE_TYPE_ROUTER
1512 * NAME
1513 *       IB_NODE_TYPE_ROUTER
1514 *
1515 * DESCRIPTION
1516 *       Encoded generic node type used in MAD attributes (13.4.8.2)
1517 *
1518 * SOURCE
1519 */
1520 #define IB_NODE_TYPE_ROUTER                                     0x03
1521 /**********/
1522
1523 /****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_CA
1524 * NAME
1525 *       IB_NOTICE_PRODUCER_TYPE_CA
1526 *
1527 * DESCRIPTION
1528 *       Encoded generic producer type used in Notice attribute (13.4.8.2)
1529 *
1530 * SOURCE
1531 */
1532 #define IB_NOTICE_PRODUCER_TYPE_CA                      (CL_HTON32(0x000001))
1533 /**********/
1534
1535 /****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_SWITCH
1536 * NAME
1537 *       IB_NOTICE_PRODUCER_TYPE_SWITCH
1538 *
1539 * DESCRIPTION
1540 *       Encoded generic producer type used in Notice attribute (13.4.8.2)
1541 *
1542 * SOURCE
1543 */
1544 #define IB_NOTICE_PRODUCER_TYPE_SWITCH                  (CL_HTON32(0x000002))
1545 /**********/
1546
1547 /****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_ROUTER
1548 * NAME
1549 *       IB_NOTICE_PRODUCER_TYPE_ROUTER
1550 *
1551 * DESCRIPTION
1552 *       Encoded generic producer type used in Notice attribute (13.4.8.2)
1553 *
1554 * SOURCE
1555 */
1556 #define IB_NOTICE_PRODUCER_TYPE_ROUTER                  (CL_HTON32(0x000003))
1557 /**********/
1558
1559 /****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_CLASS_MGR
1560 * NAME
1561 *       IB_NOTICE_PRODUCER_TYPE_CLASS_MGR
1562 *
1563 * DESCRIPTION
1564 *       Encoded generic producer type used in Notice attribute (13.4.8.2)
1565 *
1566 * SOURCE
1567 */
1568 #define IB_NOTICE_PRODUCER_TYPE_CLASS_MGR                       (CL_HTON32(0x000004))
1569 /**********/
1570
1571 /****d* IBA Base: Constants/IB_MTU_LEN_TYPE
1572 * NAME
1573 *       IB_MTU_LEN_TYPE
1574 *
1575 * DESCRIPTION
1576 *       Encoded path MTU.
1577 *               1: 256
1578 *               2: 512
1579 *               3: 1024
1580 *               4: 2048
1581 *               5: 4096
1582 *               others: reserved
1583 *
1584 * SOURCE
1585 */
1586 #define IB_MTU_LEN_256                                                  1
1587 #define IB_MTU_LEN_512                                                  2
1588 #define IB_MTU_LEN_1024                                                 3
1589 #define IB_MTU_LEN_2048                                                 4
1590 #define IB_MTU_LEN_4096                                                 5
1591
1592 #define IB_MIN_MTU    IB_MTU_LEN_256
1593 #define IB_MAX_MTU    IB_MTU_LEN_4096
1594
1595 /**********/
1596
1597 /****d* IBA Base: Constants/IB_PATH_SELECTOR_TYPE
1598 * NAME
1599 *       IB_PATH_SELECTOR_TYPE
1600 *
1601 * DESCRIPTION
1602 *       Path selector.
1603 *               0: greater than specified
1604 *               1: less than specified
1605 *               2: exactly the specified
1606 *               3: largest available
1607 *
1608 * SOURCE
1609 */
1610 #define IB_PATH_SELECTOR_GREATER_THAN           0
1611 #define IB_PATH_SELECTOR_LESS_THAN              1
1612 #define IB_PATH_SELECTOR_EXACTLY                2
1613 #define IB_PATH_SELECTOR_LARGEST                3
1614 /**********/
1615
1616 /****d* IBA Base: Constants/IB_SMINFO_STATE_NOTACTIVE
1617 * NAME
1618 *       IB_SMINFO_STATE_NOTACTIVE
1619 *
1620 * DESCRIPTION
1621 *       Encoded state value used in the SMInfo attribute.
1622 *
1623 * SOURCE
1624 */
1625 #define IB_SMINFO_STATE_NOTACTIVE                       0
1626 /**********/
1627
1628 /****d* IBA Base: Constants/IB_SMINFO_STATE_DISCOVERING
1629 * NAME
1630 *       IB_SMINFO_STATE_DISCOVERING
1631 *
1632 * DESCRIPTION
1633 *       Encoded state value used in the SMInfo attribute.
1634 *
1635 * SOURCE
1636 */
1637 #define IB_SMINFO_STATE_DISCOVERING                     1
1638 /**********/
1639
1640 /****d* IBA Base: Constants/IB_SMINFO_STATE_STANDBY
1641 * NAME
1642 *       IB_SMINFO_STATE_STANDBY
1643 *
1644 * DESCRIPTION
1645 *       Encoded state value used in the SMInfo attribute.
1646 *
1647 * SOURCE
1648 */
1649 #define IB_SMINFO_STATE_STANDBY                         2
1650 /**********/
1651
1652 /****d* IBA Base: Constants/IB_SMINFO_STATE_MASTER
1653 * NAME
1654 *       IB_SMINFO_STATE_MASTER
1655 *
1656 * DESCRIPTION
1657 *       Encoded state value used in the SMInfo attribute.
1658 *
1659 * SOURCE
1660 */
1661 #define IB_SMINFO_STATE_MASTER                          3
1662 /**********/
1663
1664 /****d* IBA Base: Constants/IB_PATH_REC_SL_MASK
1665 * NAME
1666 *       IB_PATH_REC_SL_MASK
1667 *
1668 * DESCRIPTION
1669 *       Mask for the sl field for path record
1670 *
1671 * SOURCE
1672 */
1673 #define IB_PATH_REC_SL_MASK                             0x000F
1674
1675 /****d* IBA Base: Constants/IB_MULTIPATH_REC_SL_MASK
1676 * NAME
1677 *       IB_MILTIPATH_REC_SL_MASK
1678 *
1679 * DESCRIPTION
1680 *       Mask for the sl field for MultiPath record
1681 *
1682 * SOURCE
1683 */
1684 #define IB_MULTIPATH_REC_SL_MASK                        0x000F
1685
1686 /****d* IBA Base: Constants/IB_PATH_REC_QOS_CLASS_MASK
1687 * NAME
1688 *       IB_PATH_REC_QOS_CLASS_MASK
1689 *
1690 * DESCRIPTION
1691 *       Mask for the QoS class field for path record
1692 *
1693 * SOURCE
1694 */
1695 #define IB_PATH_REC_QOS_CLASS_MASK                      0xFFF0
1696
1697 /****d* IBA Base: Constants/IB_MULTIPATH_REC_QOS_CLASS_MASK
1698 * NAME
1699 *       IB_MULTIPATH_REC_QOS_CLASS_MASK
1700 *
1701 * DESCRIPTION
1702 *       Mask for the QoS class field for MultiPath record
1703 *
1704 * SOURCE
1705 */
1706 #define IB_MULTIPATH_REC_QOS_CLASS_MASK                 0xFFF0
1707
1708 /****d* IBA Base: Constants/IB_PATH_REC_SELECTOR_MASK
1709 * NAME
1710 *       IB_PATH_REC_SELECTOR_MASK
1711 *
1712 * DESCRIPTION
1713 *       Mask for the selector field for path record MTU, rate,
1714 *       and packet lifetime.
1715 *
1716 * SOURCE
1717 */
1718 #define IB_PATH_REC_SELECTOR_MASK                       0xC0
1719
1720 /****d* IBA Base: Constants/IB_MULTIPATH_REC_SELECTOR_MASK
1721 * NAME
1722 *       IB_MULTIPATH_REC_SELECTOR_MASK
1723 *
1724 * DESCRIPTION
1725 *       Mask for the selector field for multipath record MTU, rate,
1726 *       and packet lifetime.
1727 *
1728 * SOURCE
1729 */
1730 #define IB_MULTIPATH_REC_SELECTOR_MASK                       0xC0
1731 /**********/
1732
1733 /****d* IBA Base: Constants/IB_PATH_REC_BASE_MASK
1734 * NAME
1735 *       IB_PATH_REC_BASE_MASK
1736 *
1737 * DESCRIPTION
1738 *       Mask for the base value field for path record MTU, rate,
1739 *       and packet lifetime.
1740 *
1741 * SOURCE
1742 */
1743 #define IB_PATH_REC_BASE_MASK                           0x3F
1744 /**********/
1745
1746 /****d* IBA Base: Constants/IB_MULTIPATH_REC_BASE_MASK
1747 * NAME
1748 *       IB_MULTIPATH_REC_BASE_MASK
1749 *
1750 * DESCRIPTION
1751 *       Mask for the base value field for multipath record MTU, rate,
1752 *       and packet lifetime.
1753 *
1754 * SOURCE
1755 */
1756 #define IB_MULTIPATH_REC_BASE_MASK                      0x3F
1757 /**********/
1758
1759 /****h* IBA Base/Type Definitions
1760 * NAME
1761 *       Type Definitions
1762 *
1763 * DESCRIPTION
1764 *       Definitions are from the InfiniBand Architecture Specification v1.2
1765 *
1766 *********/
1767
1768 /****d* IBA Base: Types/ib_net16_t
1769 * NAME
1770 *       ib_net16_t
1771 *
1772 * DESCRIPTION
1773 *       Defines the network ordered type for 16-bit values.
1774 *
1775 * SOURCE
1776 */
1777 typedef uint16_t ib_net16_t;
1778 /**********/
1779
1780 /****d* IBA Base: Types/ib_net32_t
1781 * NAME
1782 *       ib_net32_t
1783 *
1784 * DESCRIPTION
1785 *       Defines the network ordered type for 32-bit values.
1786 *
1787 * SOURCE
1788 */
1789 typedef uint32_t ib_net32_t;
1790 /**********/
1791
1792 /****d* IBA Base: Types/ib_net64_t
1793 * NAME
1794 *       ib_net64_t
1795 *
1796 * DESCRIPTION
1797 *       Defines the network ordered type for 64-bit values.
1798 *
1799 * SOURCE
1800 */
1801 typedef uint64_t ib_net64_t;
1802 /**********/
1803
1804 /****d* IBA Base: Types/ib_gid_prefix_t
1805 * NAME
1806 *       ib_gid_prefix_t
1807 *
1808 * DESCRIPTION
1809 *
1810 * SOURCE
1811 */
1812 typedef ib_net64_t ib_gid_prefix_t;
1813 /**********/
1814
1815 /****d* IBA Base: Constants/ib_link_states_t
1816 * NAME
1817 *       ib_link_states_t
1818 *
1819 * DESCRIPTION
1820 *       Defines the link states of a port.
1821 *
1822 * SOURCE
1823 */
1824 #define IB_LINK_NO_CHANGE 0
1825 #define IB_LINK_DOWN      1
1826 #define IB_LINK_INIT      2
1827 #define IB_LINK_ARMED     3
1828 #define IB_LINK_ACTIVE    4
1829 #define IB_LINK_ACT_DEFER 5
1830 /**********/
1831
1832 static const char *const __ib_node_type_str[] = {
1833         "UNKNOWN",
1834         "Channel Adapter",
1835         "Switch",
1836         "Router"
1837 };
1838
1839 /****f* IBA Base: Types/ib_get_node_type_str
1840 * NAME
1841 *       ib_get_node_type_str
1842 *
1843 * DESCRIPTION
1844 *       Returns a string for the specified node type.
1845 *       14.2.5.3 NodeInfo
1846 *
1847 * SYNOPSIS
1848 */
1849 static inline const char *OSM_API ib_get_node_type_str(IN uint8_t node_type)
1850 {
1851         if (node_type > IB_NODE_TYPE_ROUTER)
1852                 node_type = 0;
1853         return (__ib_node_type_str[node_type]);
1854 }
1855
1856 /*
1857 * PARAMETERS
1858 *       node_type
1859 *               [in] Encoded node type as returned in the NodeInfo attribute.
1860
1861 * RETURN VALUES
1862 *       Pointer to the node type string.
1863 *
1864 * NOTES
1865 *
1866 * SEE ALSO
1867 * ib_node_info_t
1868 *********/
1869
1870 static const char *const __ib_producer_type_str[] = {
1871         "UNKNOWN",
1872         "Channel Adapter",
1873         "Switch",
1874         "Router",
1875         "Class Manager"
1876 };
1877
1878 /****f* IBA Base: Types/ib_get_producer_type_str
1879 * NAME
1880 *       ib_get_producer_type_str
1881 *
1882 * DESCRIPTION
1883 *       Returns a string for the specified producer type
1884 *       13.4.8.2 Notice
1885 *       13.4.8.3 InformInfo
1886 *
1887 * SYNOPSIS
1888 */
1889 static inline const char *OSM_API
1890 ib_get_producer_type_str(IN ib_net32_t producer_type)
1891 {
1892         if (cl_ntoh32(producer_type) >
1893             CL_NTOH32(IB_NOTICE_PRODUCER_TYPE_CLASS_MGR))
1894                 producer_type = 0;
1895         return (__ib_producer_type_str[cl_ntoh32(producer_type)]);
1896 }
1897
1898 /*
1899 * PARAMETERS
1900 *       producer_type
1901 *               [in] Encoded producer type from the Notice attribute
1902
1903 * RETURN VALUES
1904 *       Pointer to the producer type string.
1905 *
1906 * NOTES
1907 *
1908 * SEE ALSO
1909 * ib_notice_get_prod_type
1910 *********/
1911
1912 static const char *const __ib_port_state_str[] = {
1913         "No State Change (NOP)",
1914         "DOWN",
1915         "INIT",
1916         "ARMED",
1917         "ACTIVE",
1918         "ACTDEFER",
1919         "UNKNOWN"
1920 };
1921
1922 /****f* IBA Base: Types/ib_get_port_state_str
1923 * NAME
1924 *       ib_get_port_state_str
1925 *
1926 * DESCRIPTION
1927 *       Returns a string for the specified port state.
1928 *
1929 * SYNOPSIS
1930 */
1931 static inline const char *OSM_API ib_get_port_state_str(IN uint8_t port_state)
1932 {
1933         if (port_state > IB_LINK_ACTIVE)
1934                 port_state = IB_LINK_ACTIVE + 1;
1935         return (__ib_port_state_str[port_state]);
1936 }
1937
1938 /*
1939 * PARAMETERS
1940 *       port_state
1941 *               [in] Encoded port state as returned in the PortInfo attribute.
1942
1943 * RETURN VALUES
1944 *       Pointer to the port state string.
1945 *
1946 * NOTES
1947 *
1948 * SEE ALSO
1949 * ib_port_info_t
1950 *********/
1951
1952 /****f* IBA Base: Types/ib_get_port_state_from_str
1953 * NAME
1954 *       ib_get_port_state_from_str
1955 *
1956 * DESCRIPTION
1957 *       Returns a string for the specified port state.
1958 *
1959 * SYNOPSIS
1960 */
1961 static inline uint8_t OSM_API
1962 ib_get_port_state_from_str(IN char *p_port_state_str)
1963 {
1964         if (!strncmp(p_port_state_str, "No State Change (NOP)", 12))
1965                 return (0);
1966         else if (!strncmp(p_port_state_str, "DOWN", 4))
1967                 return (1);
1968         else if (!strncmp(p_port_state_str, "INIT", 4))
1969                 return (2);
1970         else if (!strncmp(p_port_state_str, "ARMED", 5))
1971                 return (3);
1972         else if (!strncmp(p_port_state_str, "ACTIVE", 6))
1973                 return (4);
1974         else if (!strncmp(p_port_state_str, "ACTDEFER", 8))
1975                 return (5);
1976         return (6);
1977 }
1978
1979 /*
1980 * PARAMETERS
1981 *       p_port_state_str
1982 *               [in] A string matching one returned by ib_get_port_state_str
1983 *
1984 * RETURN VALUES
1985 *       The appropriate code.
1986 *
1987 * NOTES
1988 *
1989 * SEE ALSO
1990 *       ib_port_info_t
1991 *********/
1992
1993 /****d* IBA Base: Constants/Join States
1994 * NAME
1995 *       Join States
1996 *
1997 * DESCRIPTION
1998 *       Defines the join state flags for multicast group management.
1999 *
2000 * SOURCE
2001 */
2002 #define IB_JOIN_STATE_FULL              1
2003 #define IB_JOIN_STATE_NON               2
2004 #define IB_JOIN_STATE_SEND_ONLY         4
2005 /**********/
2006
2007 /****f* IBA Base: Types/ib_pkey_get_base
2008 * NAME
2009 *       ib_pkey_get_base
2010 *
2011 * DESCRIPTION
2012 *       Returns the base P_Key value with the membership bit stripped.
2013 *
2014 * SYNOPSIS
2015 */
2016 static inline ib_net16_t OSM_API ib_pkey_get_base(IN const ib_net16_t pkey)
2017 {
2018         return ((ib_net16_t) (pkey & IB_PKEY_BASE_MASK));
2019 }
2020
2021 /*
2022 * PARAMETERS
2023 *       pkey
2024 *               [in] P_Key value
2025 *
2026 * RETURN VALUE
2027 *       Returns the base P_Key value with the membership bit stripped.
2028 *
2029 * NOTES
2030 *
2031 * SEE ALSO
2032 *********/
2033
2034 /****f* IBA Base: Types/ib_pkey_is_full_member
2035 * NAME
2036 *       ib_pkey_is_full_member
2037 *
2038 * DESCRIPTION
2039 *       Indicates if the port is a full member of the parition.
2040 *
2041 * SYNOPSIS
2042 */
2043 static inline boolean_t OSM_API ib_pkey_is_full_member(IN const ib_net16_t pkey)
2044 {
2045         return ((pkey & IB_PKEY_TYPE_MASK) == IB_PKEY_TYPE_MASK);
2046 }
2047
2048 /*
2049 * PARAMETERS
2050 *       pkey
2051 *               [in] P_Key value
2052 *
2053 * RETURN VALUE
2054 *       TRUE if the port is a full member of the partition.
2055 *       FALSE otherwise.
2056 *
2057 * NOTES
2058 *
2059 * SEE ALSO
2060 * ib_pkey_get_base, ib_net16_t
2061 *********/
2062
2063 /****f* IBA Base: Types/ib_pkey_is_invalid
2064 * NAME
2065 *       ib_pkey_is_invalid
2066 *
2067 * DESCRIPTION
2068 *       Returns TRUE if the given P_Key is an invalid P_Key
2069 *  C10-116: the CI shall regard a P_Key as invalid if its low-order
2070 *           15 bits are all zero...
2071 *
2072 * SYNOPSIS
2073 */
2074 static inline boolean_t OSM_API ib_pkey_is_invalid(IN const ib_net16_t pkey)
2075 {
2076         if (ib_pkey_get_base(pkey) == 0x0000)
2077                 return TRUE;
2078
2079         return FALSE;
2080 }
2081
2082 /*
2083 * PARAMETERS
2084 *       pkey
2085 *               [in] P_Key value
2086 *
2087 * RETURN VALUE
2088 *       Returns the base P_Key value with the membership bit stripped.
2089 *
2090 * NOTES
2091 *
2092 * SEE ALSO
2093 *********/
2094
2095 /****d* IBA Base: Types/ib_gid_t
2096 * NAME
2097 *       ib_gid_t
2098 *
2099 * DESCRIPTION
2100 *
2101 * SYNOPSIS
2102 */
2103 #include <complib/cl_packon.h>
2104 typedef union _ib_gid {
2105         uint8_t raw[16];
2106         struct _ib_gid_unicast {
2107                 ib_gid_prefix_t prefix;
2108                 ib_net64_t interface_id;
2109
2110         } PACK_SUFFIX unicast;
2111
2112         struct _ib_gid_multicast {
2113                 uint8_t header[2];
2114                 uint8_t raw_group_id[14];
2115
2116         } PACK_SUFFIX multicast;
2117
2118 } PACK_SUFFIX ib_gid_t;
2119 #include <complib/cl_packoff.h>
2120 /*
2121 * FIELDS
2122 *       raw
2123 *               GID represented as an unformated byte array.
2124 *
2125 *       unicast
2126 *               Typical unicast representation with subnet prefix and
2127 *               port GUID.
2128 *
2129 *       multicast
2130 *               Representation for multicast use.
2131 *
2132 * SEE ALSO
2133 *********/
2134
2135 /****f* IBA Base: Types/ib_gid_is_multicast
2136 * NAME
2137 *       ib_gid_is_multicast
2138 *
2139 * DESCRIPTION
2140 *       Returns a boolean indicating whether a GID is a multicast GID.
2141 *
2142 * SYNOPSIS
2143 */
2144 static inline boolean_t OSM_API ib_gid_is_multicast(IN const ib_gid_t * p_gid)
2145 {
2146         return (p_gid->raw[0] == 0xFF);
2147 }
2148
2149 /****f* IBA Base: Types/ib_gid_get_scope
2150 * NAME
2151 *       ib_gid_get_scope
2152 *
2153 * DESCRIPTION
2154 *       Returns scope of (assumed) multicast GID.
2155 *
2156 * SYNOPSIS
2157 */
2158 static inline uint8_t OSM_API ib_mgid_get_scope(IN const ib_gid_t * p_gid)
2159 {
2160         return (p_gid->raw[1] & 0x0F);
2161 }
2162
2163 /****f* IBA Base: Types/ib_gid_set_scope
2164 * NAME
2165 *       ib_gid_set_scope
2166 *
2167 * DESCRIPTION
2168 *       Sets scope of (assumed) multicast GID.
2169 *
2170 * SYNOPSIS
2171 */
2172 static inline void OSM_API
2173 ib_mgid_set_scope(IN ib_gid_t * const p_gid, IN const uint8_t scope)
2174 {
2175         p_gid->raw[1] &= 0xF0;
2176         p_gid->raw[1] |= scope & 0x0F;
2177 }
2178
2179 /****f* IBA Base: Types/ib_gid_set_default
2180 * NAME
2181 *       ib_gid_set_default
2182 *
2183 * DESCRIPTION
2184 *       Sets a GID to the default value.
2185 *
2186 * SYNOPSIS
2187 */
2188 static inline void OSM_API
2189 ib_gid_set_default(IN ib_gid_t * const p_gid, IN const ib_net64_t interface_id)
2190 {
2191         p_gid->unicast.prefix = IB_DEFAULT_SUBNET_PREFIX;
2192         p_gid->unicast.interface_id = interface_id;
2193 }
2194
2195 /*
2196 * PARAMETERS
2197 *       p_gid
2198 *               [in] Pointer to the GID object.
2199 *
2200 *       interface_id
2201 *               [in] Manufacturer assigned EUI64 value of a port.
2202 *
2203 * RETURN VALUES
2204 *       None.
2205 *
2206 * NOTES
2207 *
2208 * SEE ALSO
2209 *       ib_gid_t
2210 *********/
2211
2212 /****f* IBA Base: Types/ib_gid_get_subnet_prefix
2213 * NAME
2214 *       ib_gid_get_subnet_prefix
2215 *
2216 * DESCRIPTION
2217 *       Gets the subnet prefix from a GID.
2218 *
2219 * SYNOPSIS
2220 */
2221 static inline ib_net64_t OSM_API
2222 ib_gid_get_subnet_prefix(IN const ib_gid_t * const p_gid)
2223 {
2224         return (p_gid->unicast.prefix);
2225 }
2226
2227 /*
2228 * PARAMETERS
2229 *       p_gid
2230 *               [in] Pointer to the GID object.
2231 *
2232 * RETURN VALUES
2233 *       64-bit subnet prefix value.
2234 *
2235 * NOTES
2236 *
2237 * SEE ALSO
2238 *       ib_gid_t
2239 *********/
2240
2241 /****f* IBA Base: Types/ib_gid_is_link_local
2242 * NAME
2243 *       ib_gid_is_link_local
2244 *
2245 * DESCRIPTION
2246 *       Returns TRUE if the unicast GID scoping indicates link local,
2247 *       FALSE otherwise.
2248 *
2249 * SYNOPSIS
2250 */
2251 static inline boolean_t OSM_API
2252 ib_gid_is_link_local(IN const ib_gid_t * const p_gid)
2253 {
2254         return ((ib_gid_get_subnet_prefix(p_gid) &
2255                  CL_HTON64(0xFFC0000000000000ULL)) == IB_DEFAULT_SUBNET_PREFIX);
2256 }
2257
2258 /*
2259 * PARAMETERS
2260 *       p_gid
2261 *               [in] Pointer to the GID object.
2262 *
2263 * RETURN VALUES
2264 *       Returns TRUE if the unicast GID scoping indicates link local,
2265 *       FALSE otherwise.
2266 *
2267 * NOTES
2268 *
2269 * SEE ALSO
2270 *       ib_gid_t
2271 *********/
2272
2273 /****f* IBA Base: Types/ib_gid_is_site_local
2274 * NAME
2275 *       ib_gid_is_site_local
2276 *
2277 * DESCRIPTION
2278 *       Returns TRUE if the unicast GID scoping indicates site local,
2279 *       FALSE otherwise.
2280 *
2281 * SYNOPSIS
2282 */
2283 static inline boolean_t OSM_API
2284 ib_gid_is_site_local(IN const ib_gid_t * const p_gid)
2285 {
2286         return ((ib_gid_get_subnet_prefix(p_gid) &
2287                  CL_HTON64(0xFFFFFFFFFFFF0000ULL)) ==
2288                 CL_HTON64(0xFEC0000000000000ULL));
2289 }
2290
2291 /*
2292 * PARAMETERS
2293 *       p_gid
2294 *               [in] Pointer to the GID object.
2295 *
2296 * RETURN VALUES
2297 *       Returns TRUE if the unicast GID scoping indicates site local,
2298 *       FALSE otherwise.
2299 *
2300 * NOTES
2301 *
2302 * SEE ALSO
2303 *       ib_gid_t
2304 *********/
2305
2306 /****f* IBA Base: Types/ib_gid_get_guid
2307 * NAME
2308 *       ib_gid_get_guid
2309 *
2310 * DESCRIPTION
2311 *       Gets the guid from a GID.
2312 *
2313 * SYNOPSIS
2314 */
2315 static inline ib_net64_t OSM_API
2316 ib_gid_get_guid(IN const ib_gid_t * const p_gid)
2317 {
2318         return (p_gid->unicast.interface_id);
2319 }
2320
2321 /*
2322 * PARAMETERS
2323 *       p_gid
2324 *               [in] Pointer to the GID object.
2325 *
2326 * RETURN VALUES
2327 *       64-bit GUID value.
2328 *
2329 * NOTES
2330 *
2331 * SEE ALSO
2332 *       ib_gid_t
2333 *********/
2334
2335 /****s* IBA Base: Types/ib_path_rec_t
2336 * NAME
2337 *       ib_path_rec_t
2338 *
2339 * DESCRIPTION
2340 *       Path records encapsulate the properties of a given
2341 *       route between two end-points on a subnet.
2342 *
2343 * SYNOPSIS
2344 */
2345 #include <complib/cl_packon.h>
2346 typedef struct _ib_path_rec {
2347         ib_net64_t service_id;
2348         ib_gid_t dgid;
2349         ib_gid_t sgid;
2350         ib_net16_t dlid;
2351         ib_net16_t slid;
2352         ib_net32_t hop_flow_raw;
2353         uint8_t tclass;
2354         uint8_t num_path;
2355         ib_net16_t pkey;
2356         ib_net16_t qos_class_sl;
2357         uint8_t mtu;
2358         uint8_t rate;
2359         uint8_t pkt_life;
2360         uint8_t preference;
2361         uint8_t resv2[6];
2362
2363 } PACK_SUFFIX ib_path_rec_t;
2364 #include <complib/cl_packoff.h>
2365 /*
2366 * FIELDS
2367 *       service_id
2368 *               Service ID for QoS.
2369 *
2370 *       dgid
2371 *               GID of destination port.
2372 *
2373 *       sgid
2374 *               GID of source port.
2375 *
2376 *       dlid
2377 *               LID of destination port.
2378 *
2379 *       slid
2380 *               LID of source port.
2381 *
2382 *       hop_flow_raw
2383 *               Global routing parameters: hop count, flow label and raw bit.
2384 *
2385 *       tclass
2386 *               Another global routing parameter.
2387 *
2388 *       num_path
2389 *     Reversible path - 1 bit to say if path is reversible.
2390 *               num_path [6:0] In queries, maximum number of paths to return.
2391 *               In responses, undefined.
2392 *
2393 *       pkey
2394 *               Partition key (P_Key) to use on this path.
2395 *
2396 *       qos_class_sl
2397 *               QoS class and service level to use on this path.
2398 *
2399 *       mtu
2400 *               MTU and MTU selector fields to use on this path
2401 *
2402 *       rate
2403 *               Rate and rate selector fields to use on this path.
2404 *
2405 *       pkt_life
2406 *               Packet lifetime
2407 *
2408 *       preference
2409 *               Indicates the relative merit of this path versus other path
2410 *               records returned from the SA.  Lower numbers are better.
2411 *
2412 *       resv2
2413 *               Reserved bytes.
2414 * SEE ALSO
2415 *********/
2416
2417 /* Path Record Component Masks */
2418 #define  IB_PR_COMPMASK_SERVICEID_MSB     (CL_HTON64(((uint64_t)1)<<0))
2419 #define  IB_PR_COMPMASK_SERVICEID_LSB     (CL_HTON64(((uint64_t)1)<<1))
2420 #define  IB_PR_COMPMASK_DGID              (CL_HTON64(((uint64_t)1)<<2))
2421 #define  IB_PR_COMPMASK_SGID              (CL_HTON64(((uint64_t)1)<<3))
2422 #define  IB_PR_COMPMASK_DLID              (CL_HTON64(((uint64_t)1)<<4))
2423 #define  IB_PR_COMPMASK_SLID              (CL_HTON64(((uint64_t)1)<<5))
2424 #define  IB_PR_COMPMASK_RAWTRAFFIC        (CL_HTON64(((uint64_t)1)<<6))
2425 #define  IB_PR_COMPMASK_RESV0             (CL_HTON64(((uint64_t)1)<<7))
2426 #define  IB_PR_COMPMASK_FLOWLABEL         (CL_HTON64(((uint64_t)1)<<8))
2427 #define  IB_PR_COMPMASK_HOPLIMIT          (CL_HTON64(((uint64_t)1)<<9))
2428 #define  IB_PR_COMPMASK_TCLASS            (CL_HTON64(((uint64_t)1)<<10))
2429 #define  IB_PR_COMPMASK_REVERSIBLE        (CL_HTON64(((uint64_t)1)<<11))
2430 #define  IB_PR_COMPMASK_NUMBPATH          (CL_HTON64(((uint64_t)1)<<12))
2431 #define  IB_PR_COMPMASK_PKEY              (CL_HTON64(((uint64_t)1)<<13))
2432 #define  IB_PR_COMPMASK_QOS_CLASS         (CL_HTON64(((uint64_t)1)<<14))
2433 #define  IB_PR_COMPMASK_SL                (CL_HTON64(((uint64_t)1)<<15))
2434 #define  IB_PR_COMPMASK_MTUSELEC          (CL_HTON64(((uint64_t)1)<<16))
2435 #define  IB_PR_COMPMASK_MTU               (CL_HTON64(((uint64_t)1)<<17))
2436 #define  IB_PR_COMPMASK_RATESELEC         (CL_HTON64(((uint64_t)1)<<18))
2437 #define  IB_PR_COMPMASK_RATE              (CL_HTON64(((uint64_t)1)<<19))
2438 #define  IB_PR_COMPMASK_PKTLIFETIMESELEC  (CL_HTON64(((uint64_t)1)<<20))
2439 #define  IB_PR_COMPMASK_PKTLIFETIME       (CL_HTON64(((uint64_t)1)<<21))
2440
2441 /* Link Record Component Masks */
2442 #define IB_LR_COMPMASK_FROM_LID           (CL_HTON64(((uint64_t)1)<<0))
2443 #define IB_LR_COMPMASK_FROM_PORT          (CL_HTON64(((uint64_t)1)<<1))
2444 #define IB_LR_COMPMASK_TO_PORT            (CL_HTON64(((uint64_t)1)<<2))
2445 #define IB_LR_COMPMASK_TO_LID             (CL_HTON64(((uint64_t)1)<<3))
2446
2447 /* VL Arbitration Record Masks */
2448 #define IB_VLA_COMPMASK_LID               (CL_HTON64(((uint64_t)1)<<0))
2449 #define IB_VLA_COMPMASK_OUT_PORT          (CL_HTON64(((uint64_t)1)<<1))
2450 #define IB_VLA_COMPMASK_BLOCK             (CL_HTON64(((uint64_t)1)<<2))
2451
2452 /* SLtoVL Mapping Record Masks */
2453 #define IB_SLVL_COMPMASK_LID              (CL_HTON64(((uint64_t)1)<<0))
2454 #define IB_SLVL_COMPMASK_IN_PORT          (CL_HTON64(((uint64_t)1)<<1))
2455 #define IB_SLVL_COMPMASK_OUT_PORT         (CL_HTON64(((uint64_t)1)<<2))
2456
2457 /* P_Key Table Record Masks */
2458 #define IB_PKEY_COMPMASK_LID              (CL_HTON64(((uint64_t)1)<<0))
2459 #define IB_PKEY_COMPMASK_BLOCK            (CL_HTON64(((uint64_t)1)<<1))
2460 #define IB_PKEY_COMPMASK_PORT             (CL_HTON64(((uint64_t)1)<<2))
2461
2462 /* Switch Info Record Masks */
2463 #define IB_SWIR_COMPMASK_LID              (CL_HTON64(((uint64_t)1)<<0))
2464 #define IB_SWIR_COMPMASK_RESERVED1        (CL_HTON64(((uint64_t)1)<<1))
2465
2466 /* LFT Record Masks */
2467 #define IB_LFTR_COMPMASK_LID              (CL_HTON64(((uint64_t)1)<<0))
2468 #define IB_LFTR_COMPMASK_BLOCK            (CL_HTON64(((uint64_t)1)<<1))
2469
2470 /* MFT Record Masks */
2471 #define IB_MFTR_COMPMASK_LID              (CL_HTON64(((uint64_t)1)<<0))
2472 #define IB_MFTR_COMPMASK_POSITION         (CL_HTON64(((uint64_t)1)<<1))
2473 #define IB_MFTR_COMPMASK_RESERVED1        (CL_HTON64(((uint64_t)1)<<2))
2474 #define IB_MFTR_COMPMASK_BLOCK            (CL_HTON64(((uint64_t)1)<<3))
2475 #define IB_MFTR_COMPMASK_RESERVED2        (CL_HTON64(((uint64_t)1)<<4))
2476
2477 /* NodeInfo Record Masks */
2478 #define IB_NR_COMPMASK_LID                (CL_HTON64(((uint64_t)1)<<0))
2479 #define IB_NR_COMPMASK_RESERVED1          (CL_HTON64(((uint64_t)1)<<1))
2480 #define IB_NR_COMPMASK_BASEVERSION        (CL_HTON64(((uint64_t)1)<<2))
2481 #define IB_NR_COMPMASK_CLASSVERSION       (CL_HTON64(((uint64_t)1)<<3))
2482 #define IB_NR_COMPMASK_NODETYPE           (CL_HTON64(((uint64_t)1)<<4))
2483 #define IB_NR_COMPMASK_NUMPORTS           (CL_HTON64(((uint64_t)1)<<5))
2484 #define IB_NR_COMPMASK_SYSIMAGEGUID       (CL_HTON64(((uint64_t)1)<<6))
2485 #define IB_NR_COMPMASK_NODEGUID           (CL_HTON64(((uint64_t)1)<<7))
2486 #define IB_NR_COMPMASK_PORTGUID           (CL_HTON64(((uint64_t)1)<<8))
2487 #define IB_NR_COMPMASK_PARTCAP            (CL_HTON64(((uint64_t)1)<<9))
2488 #define IB_NR_COMPMASK_DEVID              (CL_HTON64(((uint64_t)1)<<10))
2489 #define IB_NR_COMPMASK_REV                (CL_HTON64(((uint64_t)1)<<11))
2490 #define IB_NR_COMPMASK_PORTNUM            (CL_HTON64(((uint64_t)1)<<12))
2491 #define IB_NR_COMPMASK_VENDID             (CL_HTON64(((uint64_t)1)<<13))
2492 #define IB_NR_COMPMASK_NODEDESC           (CL_HTON64(((uint64_t)1)<<14))
2493
2494 /* Service Record Component Masks Sec 15.2.5.14 Ver 1.1*/
2495 #define IB_SR_COMPMASK_SID                (CL_HTON64(((uint64_t)1)<<0))
2496 #define IB_SR_COMPMASK_SGID               (CL_HTON64(((uint64_t)1)<<1))
2497 #define IB_SR_COMPMASK_SPKEY              (CL_HTON64(((uint64_t)1)<<2))
2498 #define IB_SR_COMPMASK_RES1               (CL_HTON64(((uint64_t)1)<<3))
2499 #define IB_SR_COMPMASK_SLEASE             (CL_HTON64(((uint64_t)1)<<4))
2500 #define IB_SR_COMPMASK_SKEY               (CL_HTON64(((uint64_t)1)<<5))
2501 #define IB_SR_COMPMASK_SNAME              (CL_HTON64(((uint64_t)1)<<6))
2502 #define IB_SR_COMPMASK_SDATA8_0           (CL_HTON64(((uint64_t)1)<<7))
2503 #define IB_SR_COMPMASK_SDATA8_1           (CL_HTON64(((uint64_t)1)<<8))
2504 #define IB_SR_COMPMASK_SDATA8_2           (CL_HTON64(((uint64_t)1)<<9))
2505 #define IB_SR_COMPMASK_SDATA8_3           (CL_HTON64(((uint64_t)1)<<10))
2506 #define IB_SR_COMPMASK_SDATA8_4           (CL_HTON64(((uint64_t)1)<<11))
2507 #define IB_SR_COMPMASK_SDATA8_5           (CL_HTON64(((uint64_t)1)<<12))
2508 #define IB_SR_COMPMASK_SDATA8_6           (CL_HTON64(((uint64_t)1)<<13))
2509 #define IB_SR_COMPMASK_SDATA8_7           (CL_HTON64(((uint64_t)1)<<14))
2510 #define IB_SR_COMPMASK_SDATA8_8           (CL_HTON64(((uint64_t)1)<<15))
2511 #define IB_SR_COMPMASK_SDATA8_9           (CL_HTON64(((uint64_t)1)<<16))
2512 #define IB_SR_COMPMASK_SDATA8_10       (CL_HTON64(((uint64_t)1)<<17))
2513 #define IB_SR_COMPMASK_SDATA8_11       (CL_HTON64(((uint64_t)1)<<18))
2514 #define IB_SR_COMPMASK_SDATA8_12       (CL_HTON64(((uint64_t)1)<<19))
2515 #define IB_SR_COMPMASK_SDATA8_13       (CL_HTON64(((uint64_t)1)<<20))
2516 #define IB_SR_COMPMASK_SDATA8_14       (CL_HTON64(((uint64_t)1)<<21))
2517 #define IB_SR_COMPMASK_SDATA8_15       (CL_HTON64(((uint64_t)1)<<22))
2518 #define IB_SR_COMPMASK_SDATA16_0       (CL_HTON64(((uint64_t)1)<<23))
2519 #define IB_SR_COMPMASK_SDATA16_1       (CL_HTON64(((uint64_t)1)<<24))
2520 #define IB_SR_COMPMASK_SDATA16_2       (CL_HTON64(((uint64_t)1)<<25))
2521 #define IB_SR_COMPMASK_SDATA16_3       (CL_HTON64(((uint64_t)1)<<26))
2522 #define IB_SR_COMPMASK_SDATA16_4       (CL_HTON64(((uint64_t)1)<<27))
2523 #define IB_SR_COMPMASK_SDATA16_5       (CL_HTON64(((uint64_t)1)<<28))
2524 #define IB_SR_COMPMASK_SDATA16_6       (CL_HTON64(((uint64_t)1)<<29))
2525 #define IB_SR_COMPMASK_SDATA16_7       (CL_HTON64(((uint64_t)1)<<30))
2526 #define IB_SR_COMPMASK_SDATA32_0       (CL_HTON64(((uint64_t)1)<<31))
2527 #define IB_SR_COMPMASK_SDATA32_1       (CL_HTON64(((uint64_t)1)<<32))
2528 #define IB_SR_COMPMASK_SDATA32_2       (CL_HTON64(((uint64_t)1)<<33))
2529 #define IB_SR_COMPMASK_SDATA32_3       (CL_HTON64(((uint64_t)1)<<34))
2530 #define IB_SR_COMPMASK_SDATA64_0       (CL_HTON64(((uint64_t)1)<<35))
2531 #define IB_SR_COMPMASK_SDATA64_1       (CL_HTON64(((uint64_t)1)<<36))
2532
2533 /* Port Info Record Component Masks */
2534 #define IB_PIR_COMPMASK_LID              (CL_HTON64(((uint64_t)1)<<0))
2535 #define IB_PIR_COMPMASK_PORTNUM          (CL_HTON64(((uint64_t)1)<<1))
2536 #define IB_PIR_COMPMASK_RESV1            (CL_HTON64(((uint64_t)1)<<2))
2537 #define IB_PIR_COMPMASK_MKEY             (CL_HTON64(((uint64_t)1)<<3))
2538 #define IB_PIR_COMPMASK_GIDPRE           (CL_HTON64(((uint64_t)1)<<4))
2539 #define IB_PIR_COMPMASK_BASELID          (CL_HTON64(((uint64_t)1)<<5))
2540 #define IB_PIR_COMPMASK_SMLID            (CL_HTON64(((uint64_t)1)<<6))
2541 #define IB_PIR_COMPMASK_CAPMASK          (CL_HTON64(((uint64_t)1)<<7))
2542 #define IB_PIR_COMPMASK_DIAGCODE         (CL_HTON64(((uint64_t)1)<<8))
2543 #define IB_PIR_COMPMASK_MKEYLEASEPRD     (CL_HTON64(((uint64_t)1)<<9))
2544 #define IB_PIR_COMPMASK_LOCALPORTNUM     (CL_HTON64(((uint64_t)1)<<10))
2545 #define IB_PIR_COMPMASK_LINKWIDTHENABLED (CL_HTON64(((uint64_t)1)<<11))
2546 #define IB_PIR_COMPMASK_LNKWIDTHSUPPORT  (CL_HTON64(((uint64_t)1)<<12))
2547 #define IB_PIR_COMPMASK_LNKWIDTHACTIVE   (CL_HTON64(((uint64_t)1)<<13))
2548 #define IB_PIR_COMPMASK_LNKSPEEDSUPPORT  (CL_HTON64(((uint64_t)1)<<14))
2549 #define IB_PIR_COMPMASK_PORTSTATE        (CL_HTON64(((uint64_t)1)<<15))
2550 #define IB_PIR_COMPMASK_PORTPHYSTATE     (CL_HTON64(((uint64_t)1)<<16))
2551 #define IB_PIR_COMPMASK_LINKDWNDFLTSTATE (CL_HTON64(((uint64_t)1)<<17))
2552 #define IB_PIR_COMPMASK_MKEYPROTBITS     (CL_HTON64(((uint64_t)1)<<18))
2553 #define IB_PIR_COMPMASK_RESV2            (CL_HTON64(((uint64_t)1)<<19))
2554 #define IB_PIR_COMPMASK_LMC              (CL_HTON64(((uint64_t)1)<<20))
2555 #define IB_PIR_COMPMASK_LINKSPEEDACTIVE  (CL_HTON64(((uint64_t)1)<<21))
2556 #define IB_PIR_COMPMASK_LINKSPEEDENABLE  (CL_HTON64(((uint64_t)1)<<22))
2557 #define IB_PIR_COMPMASK_NEIGHBORMTU      (CL_HTON64(((uint64_t)1)<<23))
2558 #define IB_PIR_COMPMASK_MASTERSMSL       (CL_HTON64(((uint64_t)1)<<24))
2559 #define IB_PIR_COMPMASK_VLCAP            (CL_HTON64(((uint64_t)1)<<25))
2560 #define IB_PIR_COMPMASK_INITTYPE         (CL_HTON64(((uint64_t)1)<<26))
2561 #define IB_PIR_COMPMASK_VLHIGHLIMIT      (CL_HTON64(((uint64_t)1)<<27))
2562 #define IB_PIR_COMPMASK_VLARBHIGHCAP     (CL_HTON64(((uint64_t)1)<<28))
2563 #define IB_PIR_COMPMASK_VLARBLOWCAP      (CL_HTON64(((uint64_t)1)<<29))
2564 #define IB_PIR_COMPMASK_INITTYPEREPLY    (CL_HTON64(((uint64_t)1)<<30))
2565 #define IB_PIR_COMPMASK_MTUCAP           (CL_HTON64(((uint64_t)1)<<31))
2566 #define IB_PIR_COMPMASK_VLSTALLCNT       (CL_HTON64(((uint64_t)1)<<32))
2567 #define IB_PIR_COMPMASK_HOQLIFE          (CL_HTON64(((uint64_t)1)<<33))
2568 #define IB_PIR_COMPMASK_OPVLS            (CL_HTON64(((uint64_t)1)<<34))
2569 #define IB_PIR_COMPMASK_PARENFIN         (CL_HTON64(((uint64_t)1)<<35))
2570 #define IB_PIR_COMPMASK_PARENFOUT        (CL_HTON64(((uint64_t)1)<<36))
2571 #define IB_PIR_COMPMASK_FILTERRAWIN      (CL_HTON64(((uint64_t)1)<<37))
2572 #define IB_PIR_COMPMASK_FILTERRAWOUT     (CL_HTON64(((uint64_t)1)<<38))
2573 #define IB_PIR_COMPMASK_MKEYVIO          (CL_HTON64(((uint64_t)1)<<39))
2574 #define IB_PIR_COMPMASK_PKEYVIO          (CL_HTON64(((uint64_t)1)<<40))
2575 #define IB_PIR_COMPMASK_QKEYVIO          (CL_HTON64(((uint64_t)1)<<41))
2576 #define IB_PIR_COMPMASK_GUIDCAP          (CL_HTON64(((uint64_t)1)<<42))
2577 #define IB_PIR_COMPMASK_RESV3            (CL_HTON64(((uint64_t)1)<<43))
2578 #define IB_PIR_COMPMASK_SUBNTO           (CL_HTON64(((uint64_t)1)<<44))
2579 #define IB_PIR_COMPMASK_RESV4            (CL_HTON64(((uint64_t)1)<<45))
2580 #define IB_PIR_COMPMASK_RESPTIME         (CL_HTON64(((uint64_t)1)<<46))
2581 #define IB_PIR_COMPMASK_LOCALPHYERR      (CL_HTON64(((uint64_t)1)<<47))
2582 #define IB_PIR_COMPMASK_OVERRUNERR       (CL_HTON64(((uint64_t)1)<<48))
2583
2584 /* Multicast Member Record Component Masks */
2585 #define IB_MCR_COMPMASK_GID         (CL_HTON64(((uint64_t)1)<<0))
2586 #define IB_MCR_COMPMASK_MGID        (CL_HTON64(((uint64_t)1)<<0))
2587 #define IB_MCR_COMPMASK_PORT_GID    (CL_HTON64(((uint64_t)1)<<1))
2588 #define IB_MCR_COMPMASK_QKEY        (CL_HTON64(((uint64_t)1)<<2))
2589 #define IB_MCR_COMPMASK_MLID        (CL_HTON64(((uint64_t)1)<<3))
2590 #define IB_MCR_COMPMASK_MTU_SEL     (CL_HTON64(((uint64_t)1)<<4))
2591 #define IB_MCR_COMPMASK_MTU         (CL_HTON64(((uint64_t)1)<<5))
2592 #define IB_MCR_COMPMASK_TCLASS      (CL_HTON64(((uint64_t)1)<<6))
2593 #define IB_MCR_COMPMASK_PKEY        (CL_HTON64(((uint64_t)1)<<7))
2594 #define IB_MCR_COMPMASK_RATE_SEL    (CL_HTON64(((uint64_t)1)<<8))
2595 #define IB_MCR_COMPMASK_RATE        (CL_HTON64(((uint64_t)1)<<9))
2596 #define IB_MCR_COMPMASK_LIFE_SEL    (CL_HTON64(((uint64_t)1)<<10))
2597 #define IB_MCR_COMPMASK_LIFE        (CL_HTON64(((uint64_t)1)<<11))
2598 #define IB_MCR_COMPMASK_SL          (CL_HTON64(((uint64_t)1)<<12))
2599 #define IB_MCR_COMPMASK_FLOW        (CL_HTON64(((uint64_t)1)<<13))
2600 #define IB_MCR_COMPMASK_HOP         (CL_HTON64(((uint64_t)1)<<14))
2601 #define IB_MCR_COMPMASK_SCOPE       (CL_HTON64(((uint64_t)1)<<15))
2602 #define IB_MCR_COMPMASK_JOIN_STATE  (CL_HTON64(((uint64_t)1)<<16))
2603 #define IB_MCR_COMPMASK_PROXY       (CL_HTON64(((uint64_t)1)<<17))
2604
2605 /* GUID Info Record Component Masks */
2606 #define IB_GIR_COMPMASK_LID             (CL_HTON64(((uint64_t)1)<<0))
2607 #define IB_GIR_COMPMASK_BLOCKNUM        (CL_HTON64(((uint64_t)1)<<1))
2608 #define IB_GIR_COMPMASK_RESV1           (CL_HTON64(((uint64_t)1)<<2))
2609 #define IB_GIR_COMPMASK_RESV2           (CL_HTON64(((uint64_t)1)<<3))
2610 #define IB_GIR_COMPMASK_GID0            (CL_HTON64(((uint64_t)1)<<4))
2611 #define IB_GIR_COMPMASK_GID1            (CL_HTON64(((uint64_t)1)<<5))
2612 #define IB_GIR_COMPMASK_GID2            (CL_HTON64(((uint64_t)1)<<6))
2613 #define IB_GIR_COMPMASK_GID3            (CL_HTON64(((uint64_t)1)<<7))
2614 #define IB_GIR_COMPMASK_GID4            (CL_HTON64(((uint64_t)1)<<8))
2615 #define IB_GIR_COMPMASK_GID5            (CL_HTON64(((uint64_t)1)<<9))
2616 #define IB_GIR_COMPMASK_GID6            (CL_HTON64(((uint64_t)1)<<10))
2617 #define IB_GIR_COMPMASK_GID7            (CL_HTON64(((uint64_t)1)<<11))
2618
2619 /* MultiPath Record Component Masks */
2620 #define IB_MPR_COMPMASK_RAWTRAFFIC      (CL_HTON64(((uint64_t)1)<<0))
2621 #define IB_MPR_COMPMASK_RESV0           (CL_HTON64(((uint64_t)1)<<1))
2622 #define IB_MPR_COMPMASK_FLOWLABEL       (CL_HTON64(((uint64_t)1)<<2))
2623 #define IB_MPR_COMPMASK_HOPLIMIT        (CL_HTON64(((uint64_t)1)<<3))
2624 #define IB_MPR_COMPMASK_TCLASS          (CL_HTON64(((uint64_t)1)<<4))
2625 #define IB_MPR_COMPMASK_REVERSIBLE      (CL_HTON64(((uint64_t)1)<<5))
2626 #define IB_MPR_COMPMASK_NUMBPATH        (CL_HTON64(((uint64_t)1)<<6))
2627 #define IB_MPR_COMPMASK_PKEY            (CL_HTON64(((uint64_t)1)<<7))
2628 #define IB_MPR_COMPMASK_QOS_CLASS       (CL_HTON64(((uint64_t)1)<<8))
2629 #define IB_MPR_COMPMASK_SL              (CL_HTON64(((uint64_t)1)<<9))
2630 #define IB_MPR_COMPMASK_MTUSELEC        (CL_HTON64(((uint64_t)1)<<10))
2631 #define IB_MPR_COMPMASK_MTU             (CL_HTON64(((uint64_t)1)<<11))
2632 #define IB_MPR_COMPMASK_RATESELEC       (CL_HTON64(((uint64_t)1)<<12))
2633 #define IB_MPR_COMPMASK_RATE            (CL_HTON64(((uint64_t)1)<<13))
2634 #define IB_MPR_COMPMASK_PKTLIFETIMESELEC (CL_HTON64(((uint64_t)1)<<14))
2635 #define IB_MPR_COMPMASK_PKTLIFETIME     (CL_HTON64(((uint64_t)1)<<15))
2636 #define IB_MPR_COMPMASK_SERVICEID_MSB   (CL_HTON64(((uint64_t)1)<<16))
2637 #define IB_MPR_COMPMASK_INDEPSELEC      (CL_HTON64(((uint64_t)1)<<17))
2638 #define IB_MPR_COMPMASK_RESV3           (CL_HTON64(((uint64_t)1)<<18))
2639 #define IB_MPR_COMPMASK_SGIDCOUNT       (CL_HTON64(((uint64_t)1)<<19))
2640 #define IB_MPR_COMPMASK_DGIDCOUNT       (CL_HTON64(((uint64_t)1)<<20))
2641 #define IB_MPR_COMPMASK_SERVICEID_LSB   (CL_HTON64(((uint64_t)1)<<21))
2642
2643 /* SMInfo Record Component Masks */
2644 #define IB_SMIR_COMPMASK_LID            (CL_HTON64(((uint64_t)1)<<0))
2645 #define IB_SMIR_COMPMASK_RESV0          (CL_HTON64(((uint64_t)1)<<1))
2646 #define IB_SMIR_COMPMASK_GUID           (CL_HTON64(((uint64_t)1)<<2))
2647 #define IB_SMIR_COMPMASK_SMKEY          (CL_HTON64(((uint64_t)1)<<3))
2648 #define IB_SMIR_COMPMASK_ACTCOUNT       (CL_HTON64(((uint64_t)1)<<4))
2649 #define IB_SMIR_COMPMASK_PRIORITY       (CL_HTON64(((uint64_t)1)<<5))
2650 #define IB_SMIR_COMPMASK_SMSTATE        (CL_HTON64(((uint64_t)1)<<6))
2651
2652 /* InformInfo Record Component Masks */
2653 #define IB_IIR_COMPMASK_SUBSCRIBERGID   (CL_HTON64(((uint64_t)1)<<0))
2654 #define IB_IIR_COMPMASK_ENUM            (CL_HTON64(((uint64_t)1)<<1))
2655 #define IB_IIR_COMPMASK_RESV0           (CL_HTON64(((uint64_t)1)<<2))
2656 #define IB_IIR_COMPMASK_GID             (CL_HTON64(((uint64_t)1)<<3))
2657 #define IB_IIR_COMPMASK_LIDRANGEBEGIN   (CL_HTON64(((uint64_t)1)<<4))
2658 #define IB_IIR_COMPMASK_LIDRANGEEND     (CL_HTON64(((uint64_t)1)<<5))
2659 #define IB_IIR_COMPMASK_RESV1           (CL_HTON64(((uint64_t)1)<<6))
2660 #define IB_IIR_COMPMASK_ISGENERIC       (CL_HTON64(((uint64_t)1)<<7))
2661 #define IB_IIR_COMPMASK_SUBSCRIBE       (CL_HTON64(((uint64_t)1)<<8))
2662 #define IB_IIR_COMPMASK_TYPE            (CL_HTON64(((uint64_t)1)<<9))
2663 #define IB_IIR_COMPMASK_TRAPNUMB        (CL_HTON64(((uint64_t)1)<<10))
2664 #define IB_IIR_COMPMASK_DEVICEID        (CL_HTON64(((uint64_t)1)<<10))
2665 #define IB_IIR_COMPMASK_QPN             (CL_HTON64(((uint64_t)1)<<11))
2666 #define IB_IIR_COMPMASK_RESV2           (CL_HTON64(((uint64_t)1)<<12))
2667 #define IB_IIR_COMPMASK_RESPTIME        (CL_HTON64(((uint64_t)1)<<13))
2668 #define IB_IIR_COMPMASK_RESV3           (CL_HTON64(((uint64_t)1)<<14))
2669 #define IB_IIR_COMPMASK_PRODTYPE        (CL_HTON64(((uint64_t)1)<<15))
2670 #define IB_IIR_COMPMASK_VENDID          (CL_HTON64(((uint64_t)1)<<15))
2671
2672 /****f* IBA Base: Types/ib_path_rec_init_local
2673 * NAME
2674 *       ib_path_rec_init_local
2675 *
2676 * DESCRIPTION
2677 *       Initializes a subnet local path record.
2678 *
2679 * SYNOPSIS
2680 */
2681 static inline void OSM_API
2682 ib_path_rec_init_local(IN ib_path_rec_t * const p_rec,
2683                        IN ib_gid_t * const p_dgid,
2684                        IN ib_gid_t * const p_sgid,
2685                        IN ib_net16_t dlid,
2686                        IN ib_net16_t slid,
2687                        IN uint8_t num_path,
2688                        IN ib_net16_t pkey,
2689                        IN uint8_t sl,
2690                        IN uint16_t qos_class,
2691                        IN uint8_t mtu_selector,
2692                        IN uint8_t mtu,
2693                        IN uint8_t rate_selector,
2694                        IN uint8_t rate,
2695                        IN uint8_t pkt_life_selector,
2696                        IN uint8_t pkt_life, IN uint8_t preference)
2697 {
2698         p_rec->dgid = *p_dgid;
2699         p_rec->sgid = *p_sgid;
2700         p_rec->dlid = dlid;
2701         p_rec->slid = slid;
2702         p_rec->num_path = num_path;
2703         p_rec->pkey = pkey;
2704         p_rec->qos_class_sl = cl_hton16((sl & IB_PATH_REC_SL_MASK) |
2705                                         (qos_class << 4));
2706         p_rec->mtu = (uint8_t) ((mtu & IB_PATH_REC_BASE_MASK) |
2707                                 (uint8_t) (mtu_selector << 6));
2708         p_rec->rate = (uint8_t) ((rate & IB_PATH_REC_BASE_MASK) |
2709                                  (uint8_t) (rate_selector << 6));
2710         p_rec->pkt_life = (uint8_t) ((pkt_life & IB_PATH_REC_BASE_MASK) |
2711                                      (uint8_t) (pkt_life_selector << 6));
2712         p_rec->preference = preference;
2713
2714         /* Clear global routing fields for local path records */
2715         p_rec->hop_flow_raw = 0;
2716         p_rec->tclass = 0;
2717         p_rec->service_id = 0;
2718
2719         *((uint32_t *) p_rec->resv2) = 0;
2720         *((uint16_t *) p_rec->resv2 + 2) = 0;
2721 }
2722
2723 /*
2724 * PARAMETERS
2725 *       p_rec
2726 *               [in] Pointer to the path record object.
2727 *
2728 *       dgid
2729 *               [in] GID of destination port.
2730 *
2731 *       sgid
2732 *               [in] GID of source port.
2733 *
2734 *       dlid
2735 *               [in] LID of destination port.
2736 *
2737 *       slid
2738 *               [in] LID of source port.
2739 *
2740 *       num_path
2741 *     [in] Reversible path - 1 bit to say if path is reversible.
2742 *               num_path [6:0] In queries, maximum number of paths to return.
2743 *               In responses, undefined.
2744 *
2745 *       pkey
2746 *               [in] Partition key (P_Key) to use on this path.
2747 *
2748 *       qos_class
2749 *               [in] QoS class to use on this path.  Lower 12-bits are valid.
2750 *
2751 *       sl
2752 *               [in] Service level to use on this path.  Lower 4-bits are valid.
2753 *
2754 *       mtu_selector
2755 *               [in] Encoded MTU selector value to use on this path
2756 *
2757 *       mtu
2758 *               [in] Encoded MTU to use on this path
2759 *
2760 *       rate_selector
2761 *               [in] Encoded rate selector value to use on this path.
2762 *
2763 *       rate
2764 *               [in] Encoded rate to use on this path.
2765 *
2766 *       pkt_life_selector
2767 *               [in] Encoded Packet selector value lifetime for this path.
2768 *
2769 *       pkt_life
2770 *               [in] Encoded Packet lifetime for this path.
2771 *
2772 *       preference
2773 *               [in] Indicates the relative merit of this path versus other path
2774 *               records returned from the SA.  Lower numbers are better.
2775 *
2776 * RETURN VALUES
2777 *       None.
2778 *
2779 * NOTES
2780 *
2781 * SEE ALSO
2782 *       ib_gid_t
2783 *********/
2784
2785 /****f* IBA Base: Types/ib_path_rec_num_path
2786 * NAME
2787 *       ib_path_rec_num_path
2788 *
2789 * DESCRIPTION
2790 *       Get max number of paths to return.
2791 *
2792 * SYNOPSIS
2793 */
2794 static inline uint8_t OSM_API
2795 ib_path_rec_num_path(IN const ib_path_rec_t * const p_rec)
2796 {
2797         return (p_rec->num_path & 0x7F);
2798 }
2799
2800 /*
2801 * PARAMETERS
2802 *       p_rec
2803 *               [in] Pointer to the path record object.
2804 *
2805 * RETURN VALUES
2806 *       Maximum number of paths to return for each unique SGID_DGID combination.
2807 *
2808 * NOTES
2809 *
2810 * SEE ALSO
2811 *       ib_path_rec_t
2812 *********/
2813
2814 /****f* IBA Base: Types/ib_path_rec_set_sl
2815 * NAME
2816 *       ib_path_rec_set_sl
2817 *
2818 * DESCRIPTION
2819 *       Set path service level.
2820 *
2821 * SYNOPSIS
2822 */
2823 static inline void OSM_API
2824 ib_path_rec_set_sl(IN ib_path_rec_t * const p_rec, IN const uint8_t sl)
2825 {
2826         p_rec->qos_class_sl =
2827             (p_rec->qos_class_sl & CL_HTON16(IB_PATH_REC_QOS_CLASS_MASK)) |
2828             cl_hton16(sl & IB_PATH_REC_SL_MASK);
2829 }
2830
2831 /*
2832 * PARAMETERS
2833 *       p_rec
2834 *               [in] Pointer to the path record object.
2835 *
2836 *       sl
2837 *               [in] Service level to set.
2838 *
2839 * RETURN VALUES
2840 *       None
2841 *
2842 * NOTES
2843 *
2844 * SEE ALSO
2845 *       ib_path_rec_t
2846 *********/
2847
2848 /****f* IBA Base: Types/ib_path_rec_sl
2849 * NAME
2850 *       ib_path_rec_sl
2851 *
2852 * DESCRIPTION
2853 *       Get path service level.
2854 *
2855 * SYNOPSIS
2856 */
2857 static inline uint8_t OSM_API
2858 ib_path_rec_sl(IN const ib_path_rec_t * const p_rec)
2859 {
2860         return (uint8_t)(cl_ntoh16(p_rec->qos_class_sl) & IB_PATH_REC_SL_MASK);
2861 }
2862
2863 /*
2864 * PARAMETERS
2865 *       p_rec
2866 *               [in] Pointer to the path record object.
2867 *
2868 * RETURN VALUES
2869 *       SL.
2870 *
2871 * NOTES
2872 *
2873 * SEE ALSO
2874 *       ib_path_rec_t
2875 *********/
2876
2877 /****f* IBA Base: Types/ib_path_rec_set_qos_class
2878 * NAME
2879 *       ib_path_rec_set_qos_class
2880 *
2881 * DESCRIPTION
2882 *       Set path QoS class.
2883 *
2884 * SYNOPSIS
2885 */
2886 static inline void OSM_API
2887 ib_path_rec_set_qos_class(IN ib_path_rec_t * const p_rec,
2888                           IN const uint16_t qos_class)
2889 {
2890         p_rec->qos_class_sl =
2891             (p_rec->qos_class_sl & CL_HTON16(IB_PATH_REC_SL_MASK)) |
2892             cl_hton16(qos_class << 4);
2893 }
2894
2895 /*
2896 * PARAMETERS
2897 *       p_rec
2898 *               [in] Pointer to the path record object.
2899 *
2900 *       qos_class
2901 *               [in] QoS class to set.
2902 *
2903 * RETURN VALUES
2904 *       None
2905 *
2906 * NOTES
2907 *
2908 * SEE ALSO
2909 *       ib_path_rec_t
2910 *********/
2911
2912 /****f* IBA Base: Types/ib_path_rec_qos_class
2913 * NAME
2914 *       ib_path_rec_qos_class
2915 *
2916 * DESCRIPTION
2917 *       Get QoS class.
2918 *
2919 * SYNOPSIS
2920 */
2921 static inline uint16_t OSM_API
2922 ib_path_rec_qos_class(IN const ib_path_rec_t * const p_rec)
2923 {
2924         return (cl_ntoh16(p_rec->qos_class_sl) >> 4);
2925 }
2926
2927 /*
2928 * PARAMETERS
2929 *       p_rec
2930 *               [in] Pointer to the path record object.
2931 *
2932 * RETURN VALUES
2933 *       QoS class of the path record.
2934 *
2935 * NOTES
2936 *
2937 * SEE ALSO
2938 *       ib_path_rec_t
2939 *********/
2940
2941 /****f* IBA Base: Types/ib_path_rec_mtu
2942 * NAME
2943 *       ib_path_rec_mtu
2944 *
2945 * DESCRIPTION
2946 *       Get encoded path MTU.
2947 *
2948 * SYNOPSIS
2949 */
2950 static inline uint8_t OSM_API
2951 ib_path_rec_mtu(IN const ib_path_rec_t * const p_rec)
2952 {
2953         return ((uint8_t) (p_rec->mtu & IB_PATH_REC_BASE_MASK));
2954 }
2955
2956 /*
2957 * PARAMETERS
2958 *       p_rec
2959 *               [in] Pointer to the path record object.
2960 *
2961 * RETURN VALUES
2962 *       Encoded path MTU.
2963 *               1: 256
2964 *               2: 512
2965 *               3: 1024
2966 *               4: 2048
2967 *               5: 4096
2968 *               others: reserved
2969 *
2970 * NOTES
2971 *
2972 * SEE ALSO
2973 *       ib_path_rec_t
2974 *********/
2975
2976 /****f* IBA Base: Types/ib_path_rec_mtu_sel
2977 * NAME
2978 *       ib_path_rec_mtu_sel
2979 *
2980 * DESCRIPTION
2981 *       Get encoded path MTU selector.
2982 *
2983 * SYNOPSIS
2984 */
2985 static inline uint8_t OSM_API
2986 ib_path_rec_mtu_sel(IN const ib_path_rec_t * const p_rec)
2987 {
2988         return ((uint8_t) ((p_rec->mtu & IB_PATH_REC_SELECTOR_MASK) >> 6));
2989 }
2990
2991 /*
2992 * PARAMETERS
2993 *       p_rec
2994 *               [in] Pointer to the path record object.
2995 *
2996 * RETURN VALUES
2997 *       Encoded path MTU selector value (for queries).
2998 *               0: greater than MTU specified
2999 *               1: less than MTU specified
3000 *               2: exactly the MTU specified
3001 *               3: largest MTU available
3002 *
3003 * NOTES
3004 *
3005 * SEE ALSO
3006 *       ib_path_rec_t
3007 *********/
3008
3009 /****f* IBA Base: Types/ib_path_rec_rate
3010 * NAME
3011 *       ib_path_rec_rate
3012 *
3013 * DESCRIPTION
3014 *       Get encoded path rate.
3015 *
3016 * SYNOPSIS
3017 */
3018 static inline uint8_t OSM_API
3019 ib_path_rec_rate(IN const ib_path_rec_t * const p_rec)
3020 {
3021         return ((uint8_t) (p_rec->rate & IB_PATH_REC_BASE_MASK));
3022 }
3023
3024 /*
3025 * PARAMETERS
3026 *       p_rec
3027 *               [in] Pointer to the path record object.
3028 *
3029 * RETURN VALUES
3030 *       Encoded path rate.
3031 *               2: 2.5 Gb/sec.
3032 *               3: 10 Gb/sec.
3033 *               4: 30 Gb/sec.
3034 *               5: 5 Gb/sec.
3035 *               6: 20 Gb/sec.
3036 *               7: 40 Gb/sec.
3037 *               8: 60 Gb/sec.
3038 *               9: 80 Gb/sec.
3039 *               10: 120 Gb/sec.
3040 *               others: reserved
3041 *
3042 * NOTES
3043 *
3044 * SEE ALSO
3045 *       ib_path_rec_t
3046 *********/
3047
3048 /****f* IBA Base: Types/ib_path_rec_rate_sel
3049 * NAME
3050 *       ib_path_rec_rate_sel
3051 *
3052 * DESCRIPTION
3053 *       Get encoded path rate selector.
3054 *
3055 * SYNOPSIS
3056 */
3057 static inline uint8_t OSM_API
3058 ib_path_rec_rate_sel(IN const ib_path_rec_t * const p_rec)
3059 {
3060         return ((uint8_t) ((p_rec->rate & IB_PATH_REC_SELECTOR_MASK) >> 6));
3061 }
3062
3063 /*
3064 * PARAMETERS
3065 *       p_rec
3066 *               [in] Pointer to the path record object.
3067 *
3068 * RETURN VALUES
3069 *       Encoded path rate selector value (for queries).
3070 *               0: greater than rate specified
3071 *               1: less than rate specified
3072 *               2: exactly the rate specified
3073 *               3: largest rate available
3074 *
3075 * NOTES
3076 *
3077 * SEE ALSO
3078 *       ib_path_rec_t
3079 *********/
3080
3081 /****f* IBA Base: Types/ib_path_rec_pkt_life
3082 * NAME
3083 *       ib_path_rec_pkt_life
3084 *
3085 * DESCRIPTION
3086 *       Get encoded path pkt_life.
3087 *
3088 * SYNOPSIS
3089 */
3090 static inline uint8_t OSM_API
3091 ib_path_rec_pkt_life(IN const ib_path_rec_t * const p_rec)
3092 {
3093         return ((uint8_t) (p_rec->pkt_life & IB_PATH_REC_BASE_MASK));
3094 }
3095
3096 /*
3097 * PARAMETERS
3098 *       p_rec
3099 *               [in] Pointer to the path record object.
3100 *
3101 * RETURN VALUES
3102 *       Encoded path pkt_life = 4.096 usec * 2 ** PacketLifeTime.
3103 *
3104 * NOTES
3105 *
3106 * SEE ALSO
3107 *       ib_path_rec_t
3108 *********/
3109
3110 /****f* IBA Base: Types/ib_path_rec_pkt_life_sel
3111 * NAME
3112 *       ib_path_rec_pkt_life_sel
3113 *
3114 * DESCRIPTION
3115 *       Get encoded path pkt_lifetime selector.
3116 *
3117 * SYNOPSIS
3118 */
3119 static inline uint8_t OSM_API
3120 ib_path_rec_pkt_life_sel(IN const ib_path_rec_t * const p_rec)
3121 {
3122         return ((uint8_t) ((p_rec->pkt_life & IB_PATH_REC_SELECTOR_MASK) >> 6));
3123 }
3124
3125 /*
3126 * PARAMETERS
3127 *       p_rec
3128 *               [in] Pointer to the path record object.
3129 *
3130 * RETURN VALUES
3131 *       Encoded path pkt_lifetime selector value (for queries).
3132 *               0: greater than rate specified
3133 *               1: less than rate specified
3134 *               2: exactly the rate specified
3135 *               3: smallest packet lifetime available
3136 *
3137 * NOTES
3138 *
3139 * SEE ALSO
3140 *       ib_path_rec_t
3141 *********/
3142
3143 /****f* IBA Base: Types/ib_path_rec_flow_lbl
3144 * NAME
3145 *       ib_path_rec_flow_lbl
3146 *
3147 * DESCRIPTION
3148 *       Get flow label.
3149 *
3150 * SYNOPSIS
3151 */
3152 static inline uint32_t OSM_API
3153 ib_path_rec_flow_lbl(IN const ib_path_rec_t * const p_rec)
3154 {
3155         return (((cl_ntoh32(p_rec->hop_flow_raw) >> 8) & 0x000FFFFF));
3156 }
3157
3158 /*
3159 * PARAMETERS
3160 *       p_rec
3161 *               [in] Pointer to the path record object.
3162 *
3163 * RETURN VALUES
3164 *       Flow label of the path record.
3165 *
3166 * NOTES
3167 *
3168 * SEE ALSO
3169 *       ib_path_rec_t
3170 *********/
3171
3172 /****f* IBA Base: Types/ib_path_rec_hop_limit
3173 * NAME
3174 *       ib_path_rec_hop_limit
3175 *
3176 * DESCRIPTION
3177 *       Get hop limit.
3178 *
3179 * SYNOPSIS
3180 */
3181 static inline uint8_t OSM_API
3182 ib_path_rec_hop_limit(IN const ib_path_rec_t * const p_rec)
3183 {
3184         return ((uint8_t) (cl_ntoh32(p_rec->hop_flow_raw) & 0x000000FF));
3185 }
3186
3187 /*
3188 * PARAMETERS
3189 *       p_rec
3190 *               [in] Pointer to the path record object.
3191 *
3192 * RETURN VALUES
3193 *       Hop limit of the path record.
3194 *
3195 * NOTES
3196 *
3197 * SEE ALSO
3198 *       ib_path_rec_t
3199 *********/
3200
3201 /****s* IBA Base: Constants/IB_CLASS_CAP_TRAP
3202 * NAME
3203 *       IB_CLASS_CAP_TRAP
3204 *
3205 * DESCRIPTION
3206 *       ClassPortInfo CapabilityMask bits.  This bit will be set
3207 *       if the class supports Trap() MADs (13.4.8.1).
3208 *
3209 * SEE ALSO
3210 *       ib_class_port_info_t, IB_CLASS_CAP_GETSET
3211 *
3212 * SOURCE
3213 */
3214 #define IB_CLASS_CAP_TRAP                                       0x0001
3215 /*********/
3216
3217 /****s* IBA Base: Constants/IB_CLASS_CAP_GETSET
3218 * NAME
3219 *       IB_CLASS_CAP_GETSET
3220 *
3221 * DESCRIPTION
3222 *       ClassPortInfo CapabilityMask bits.  This bit will be set
3223 *       if the class supports Get(Notice) and Set(Notice) MADs (13.4.8.1).
3224 *
3225 * SEE ALSO
3226 *       ib_class_port_info_t, IB_CLASS_CAP_TRAP
3227 *
3228 * SOURCE
3229 */
3230 #define IB_CLASS_CAP_GETSET                                     0x0002
3231 /*********/
3232
3233 /****s* IBA Base: Constants/IB_CLASS_RESP_TIME_MASK
3234 * NAME
3235 *       IB_CLASS_RESP_TIME_MASK
3236 *
3237 * DESCRIPTION
3238 *       Mask bits to extract the reponse time value from the
3239 *       resp_time_val field of ib_class_port_info_t.
3240 *
3241 * SEE ALSO
3242 *       ib_class_port_info_t
3243 *
3244 * SOURCE
3245 */
3246 #define IB_CLASS_RESP_TIME_MASK                         0x1F
3247 /*********/
3248
3249 /****s* IBA Base: Types/ib_class_port_info_t
3250 * NAME
3251 *       ib_class_port_info_t
3252 *
3253 * DESCRIPTION
3254 *       IBA defined ClassPortInfo attribute (13.4.8.1)
3255 *       route between two end-points on a subnet.
3256 *
3257 * SYNOPSIS
3258 */
3259 #include <complib/cl_packon.h>
3260 typedef struct _ib_class_port_info {
3261         uint8_t base_ver;
3262         uint8_t class_ver;
3263         ib_net16_t cap_mask;
3264         ib_net32_t cap_mask2_resp_time;
3265         ib_gid_t redir_gid;
3266         ib_net32_t redir_tc_sl_fl;
3267         ib_net16_t redir_lid;
3268         ib_net16_t redir_pkey;
3269         ib_net32_t redir_qp;
3270         ib_net32_t redir_qkey;
3271         ib_gid_t trap_gid;
3272         ib_net32_t trap_tc_sl_fl;
3273         ib_net16_t trap_lid;
3274         ib_net16_t trap_pkey;
3275         ib_net32_t trap_hop_qp;
3276         ib_net32_t trap_qkey;
3277
3278 } PACK_SUFFIX ib_class_port_info_t;
3279 #include <complib/cl_packoff.h>
3280 /*
3281 * FIELDS
3282 *       base_ver
3283 *               Maximum supported MAD Base Version.
3284 *
3285 *       class_ver
3286 *               Maximum supported management class version.
3287 *
3288 *       cap_mask
3289 *               Supported capabilities of this management class.
3290 *
3291 *       cap_mask2_resp_time
3292 *               Maximum expected response time and additional
3293 *               supported capabilities of this management class.
3294 *
3295 *       redr_gid
3296 *               GID to use for redirection, or zero
3297 *
3298 *       recdir_tc_sl_fl
3299 *               Traffic class, service level and flow label the requester
3300 *               should use if the service is redirected.
3301 *
3302 *       redir_lid
3303 *               LID used for redirection, or zero
3304 *
3305 *       redir_pkey
3306 *               P_Key used for redirection
3307 *
3308 *       redir_qp
3309 *               QP number used for redirection
3310 *
3311 *       redir_qkey
3312 *               Q_Key associated with the redirected QP.  This shall be the
3313 *               well known Q_Key value.
3314 *
3315 *       trap_gid
3316 *               GID value used for trap messages from this service.
3317 *
3318 *       trap_tc_sl_fl
3319 *               Traffic class, service level and flow label used for
3320 *               trap messages originated by this service.
3321 *
3322 *       trap_lid
3323 *               LID used for trap messages, or zero
3324 *
3325 *       trap_pkey
3326 *               P_Key used for trap messages
3327 *
3328 *       trap_hop_qp
3329 *               Hop limit (upper 8 bits) and QP number used for trap messages
3330 *
3331 *       trap_qkey
3332 *               Q_Key associated with the trap messages QP.
3333 *
3334 * SEE ALSO
3335 *       IB_CLASS_CAP_GETSET, IB_CLASS_CAP_TRAP
3336 *
3337 *********/
3338
3339 /****f* IBA Base: Types/ib_class_set_resp_time_val
3340 * NAME
3341 *       ib_class_set_resp_time_val
3342 *
3343 * DESCRIPTION
3344 *       Set maximum expected response time.
3345 *
3346 * SYNOPSIS
3347 */
3348 static inline void OSM_API
3349 ib_class_set_resp_time_val(IN ib_class_port_info_t * const p_cpi,
3350                            IN const uint8_t val)
3351 {
3352         p_cpi->cap_mask2_resp_time =
3353             (p_cpi->cap_mask2_resp_time & CL_HTON32(~IB_CLASS_RESP_TIME_MASK)) |
3354             cl_hton32(val & IB_CLASS_RESP_TIME_MASK);
3355 }
3356
3357 /*
3358 * PARAMETERS
3359 *       p_cpi
3360 *               [in] Pointer to the class port info object.
3361 *
3362 *       val
3363 *               [in] Response time value to set.
3364 *
3365 * RETURN VALUES
3366 *       None
3367 *
3368 * NOTES
3369 *
3370 * SEE ALSO
3371 *       ib_class_port_info_t
3372 *********/
3373
3374 /****f* IBA Base: Types/ib_class_resp_time_val
3375 * NAME
3376 *       ib_class_resp_time_val
3377 *
3378 * DESCRIPTION
3379 *       Get response time value.
3380 *
3381 * SYNOPSIS
3382 */
3383 static inline uint8_t OSM_API
3384 ib_class_resp_time_val(IN ib_class_port_info_t * const p_cpi)
3385 {
3386         return (uint8_t)(cl_ntoh32(p_cpi->cap_mask2_resp_time) &
3387                          IB_CLASS_RESP_TIME_MASK);
3388 }
3389
3390 /*
3391 * PARAMETERS
3392 *       p_cpi
3393 *               [in] Pointer to the class port info object.
3394 *
3395 * RETURN VALUES
3396 *       Response time value.
3397 *
3398 * NOTES
3399 *
3400 * SEE ALSO
3401 *       ib_class_port_info_t
3402 *********/
3403
3404 /****f* IBA Base: Types/ib_class_set_cap_mask2
3405 * NAME
3406 *       ib_class_set_cap_mask2
3407 *
3408 * DESCRIPTION
3409 *       Set ClassPortInfo:CapabilityMask2.
3410 *
3411 * SYNOPSIS
3412 */
3413 static inline void OSM_API
3414 ib_class_set_cap_mask2(IN ib_class_port_info_t * const p_cpi,
3415                        IN const uint32_t cap_mask2)
3416 {
3417         p_cpi->cap_mask2_resp_time = (p_cpi->cap_mask2_resp_time &
3418                 CL_HTON32(IB_CLASS_RESP_TIME_MASK)) |
3419                 cl_hton32(cap_mask2 << 5);
3420 }
3421
3422 /*
3423 * PARAMETERS
3424 *       p_cpi
3425 *               [in] Pointer to the class port info object.
3426 *
3427 *       cap_mask2
3428 *               [in] CapabilityMask2 value to set.
3429 *
3430 * RETURN VALUES
3431 *       None
3432 *
3433 * NOTES
3434 *
3435 * SEE ALSO
3436 *       ib_class_port_info_t
3437 *********/
3438
3439 /****f* IBA Base: Types/ib_class_cap_mask2
3440 * NAME
3441 *       ib_class_cap_mask2
3442 *
3443 * DESCRIPTION
3444 *       Get ClassPortInfo:CapabilityMask2.
3445 *
3446 * SYNOPSIS
3447 */
3448 static inline uint32_t OSM_API
3449 ib_class_cap_mask2(IN const ib_class_port_info_t * const p_cpi)
3450 {
3451         return (cl_ntoh32(p_cpi->cap_mask2_resp_time) >> 5);
3452 }
3453
3454 /*
3455 * PARAMETERS
3456 *       p_cpi
3457 *               [in] Pointer to the class port info object.
3458 *
3459 * RETURN VALUES
3460 *       CapabilityMask2 of the ClassPortInfo.
3461 *
3462 * NOTES
3463 *
3464 * SEE ALSO
3465 *       ib_class_port_info_t
3466 *********/
3467
3468 /****s* IBA Base: Types/ib_sm_info_t
3469 * NAME
3470 *       ib_sm_info_t
3471 *
3472 * DESCRIPTION
3473 *       SMInfo structure (14.2.5.13).
3474 *
3475 * SYNOPSIS
3476 */
3477 #include <complib/cl_packon.h>
3478 typedef struct _ib_sm_info {
3479         ib_net64_t guid;
3480         ib_net64_t sm_key;
3481         ib_net32_t act_count;
3482         uint8_t pri_state;
3483
3484 } PACK_SUFFIX ib_sm_info_t;
3485 #include <complib/cl_packoff.h>
3486 /*
3487 * FIELDS
3488 *       guid
3489 *               Port GUID for this SM.
3490 *
3491 *       sm_key
3492 *               SM_Key of this SM.
3493 *
3494 *       act_count
3495 *               Activity counter used as a heartbeat.
3496 *
3497 *       pri_state
3498 *               Priority and State information
3499 *
3500 * SEE ALSO
3501 *********/
3502
3503 /****f* IBA Base: Types/ib_sminfo_get_priority
3504 * NAME
3505 *       ib_sminfo_get_priority
3506 *
3507 * DESCRIPTION
3508 *       Returns the priority value.
3509 *
3510 * SYNOPSIS
3511 */
3512 static inline uint8_t OSM_API
3513 ib_sminfo_get_priority(IN const ib_sm_info_t * const p_smi)
3514 {
3515         return ((uint8_t) ((p_smi->pri_state & 0xF0) >> 4));
3516 }
3517
3518 /*
3519 * PARAMETERS
3520 *       p_smi
3521 *               [in] Pointer to the SMInfo Attribute.
3522 *
3523 * RETURN VALUES
3524 *       Returns the priority value.
3525 *
3526 * NOTES
3527 *
3528 * SEE ALSO
3529 *********/
3530
3531 /****f* IBA Base: Types/ib_sminfo_get_state
3532 * NAME
3533 *       ib_sminfo_get_state
3534 *
3535 * DESCRIPTION
3536 *       Returns the state value.
3537 *
3538 * SYNOPSIS
3539 */
3540 static inline uint8_t OSM_API
3541 ib_sminfo_get_state(IN const ib_sm_info_t * const p_smi)
3542 {
3543         return ((uint8_t) (p_smi->pri_state & 0x0F));
3544 }
3545
3546 /*
3547 * PARAMETERS
3548 *       p_smi
3549 *               [in] Pointer to the SMInfo Attribute.
3550 *
3551 * RETURN VALUES
3552 *       Returns the state value.
3553 *
3554 * NOTES
3555 *
3556 * SEE ALSO
3557 *********/
3558
3559 /****s* IBA Base: Types/ib_mad_t
3560 * NAME
3561 *       ib_mad_t
3562 *
3563 * DESCRIPTION
3564 *       IBA defined MAD header (13.4.3)
3565 *
3566 * SYNOPSIS
3567 */
3568 #include <complib/cl_packon.h>
3569 typedef struct _ib_mad {
3570         uint8_t base_ver;
3571         uint8_t mgmt_class;
3572         uint8_t class_ver;
3573         uint8_t method;
3574         ib_net16_t status;
3575         ib_net16_t class_spec;
3576         ib_net64_t trans_id;
3577         ib_net16_t attr_id;
3578         ib_net16_t resv;
3579         ib_net32_t attr_mod;
3580 } PACK_SUFFIX ib_mad_t;
3581 #include <complib/cl_packoff.h>
3582 /*
3583 * FIELDS
3584 *       base_ver
3585 *               MAD base format.
3586 *
3587 *       mgmt_class
3588 *               Class of operation.
3589 *
3590 *       class_ver
3591 *               Version of MAD class-specific format.
3592 *
3593 *       method
3594 *               Method to perform, including 'R' bit.
3595 *
3596 *       status
3597 *               Status of operation.
3598 *
3599 *       class_spec
3600 *               Reserved for subnet management.
3601 *
3602 *       trans_id
3603 *               Transaction ID.
3604 *
3605 *       attr_id
3606 *               Attribute ID.
3607 *
3608 *       resv
3609 *               Reserved field.
3610 *
3611 *       attr_mod
3612 *               Attribute modifier.
3613 *
3614 * SEE ALSO
3615 *********/
3616
3617 /****s* IBA Base: Types/ib_rmpp_mad_t
3618 * NAME
3619 *       ib_rmpp_mad_t
3620 *
3621 * DESCRIPTION
3622 *       IBA defined MAD RMPP header (13.6.2.1)
3623 *
3624 * SYNOPSIS
3625 */
3626 #include <complib/cl_packon.h>
3627 typedef struct _ib_rmpp_mad {
3628         ib_mad_t common_hdr;
3629
3630         uint8_t rmpp_version;
3631         uint8_t rmpp_type;
3632         uint8_t rmpp_flags;
3633         uint8_t rmpp_status;
3634
3635         ib_net32_t seg_num;
3636         ib_net32_t paylen_newwin;
3637
3638 } PACK_SUFFIX ib_rmpp_mad_t;
3639 #include <complib/cl_packoff.h>
3640 /*
3641 * SEE ALSO
3642 *       ib_mad_t
3643 *********/
3644
3645 /****f* IBA Base: Types/ib_mad_init_new
3646 * NAME
3647 *       ib_mad_init_new
3648 *
3649 * DESCRIPTION
3650 *       Initializes a MAD common header.
3651 *
3652 * SYNOPSIS
3653 */
3654 static inline void OSM_API
3655 ib_mad_init_new(IN ib_mad_t * const p_mad,
3656                 IN const uint8_t mgmt_class,
3657                 IN const uint8_t class_ver,
3658                 IN const uint8_t method,
3659                 IN const ib_net64_t trans_id,
3660                 IN const ib_net16_t attr_id, IN const ib_net32_t attr_mod)
3661 {
3662         CL_ASSERT(p_mad);
3663         p_mad->base_ver = 1;
3664         p_mad->mgmt_class = mgmt_class;
3665         p_mad->class_ver = class_ver;
3666         p_mad->method = method;
3667         p_mad->status = 0;
3668         p_mad->class_spec = 0;
3669         p_mad->trans_id = trans_id;
3670         p_mad->attr_id = attr_id;
3671         p_mad->resv = 0;
3672         p_mad->attr_mod = attr_mod;
3673 }
3674
3675 /*
3676 * PARAMETERS
3677 *       p_mad
3678 *               [in] Pointer to the MAD common header.
3679 *
3680 *       mgmt_class
3681 *               [in] Class of operation.
3682 *
3683 *       class_ver
3684 *               [in] Version of MAD class-specific format.
3685 *
3686 *       method
3687 *               [in] Method to perform, including 'R' bit.
3688 *
3689 *       trans_Id
3690 *               [in] Transaction ID.
3691 *
3692 *       attr_id
3693 *               [in] Attribute ID.
3694 *
3695 *       attr_mod
3696 *               [in] Attribute modifier.
3697 *
3698 * RETURN VALUES
3699 *       None.
3700 *
3701 * NOTES
3702 *
3703 * SEE ALSO
3704 *       ib_mad_t
3705 *********/
3706
3707 /****f* IBA Base: Types/ib_mad_init_response
3708 * NAME
3709 *       ib_mad_init_response
3710 *
3711 * DESCRIPTION
3712 *       Initializes a MAD common header as a response.
3713 *
3714 * SYNOPSIS
3715 */
3716 static inline void OSM_API
3717 ib_mad_init_response(IN const ib_mad_t * const p_req_mad,
3718                      IN ib_mad_t * const p_mad, IN const ib_net16_t status)
3719 {
3720         CL_ASSERT(p_req_mad);
3721         CL_ASSERT(p_mad);
3722         *p_mad = *p_req_mad;
3723         p_mad->status = status;
3724         if (p_mad->method == IB_MAD_METHOD_SET)
3725                 p_mad->method = IB_MAD_METHOD_GET;
3726         p_mad->method |= IB_MAD_METHOD_RESP_MASK;
3727 }
3728
3729 /*
3730 * PARAMETERS
3731 *       p_req_mad
3732 *               [in] Pointer to the MAD common header in the original request MAD.
3733 *
3734 *       p_mad
3735 *               [in] Pointer to the MAD common header to initialize.
3736 *
3737 *       status
3738 *               [in] MAD Status value to return;
3739 *
3740 * RETURN VALUES
3741 *       None.
3742 *
3743 * NOTES
3744 *       p_req_mad and p_mad may point to the same MAD.
3745 *
3746 * SEE ALSO
3747 *       ib_mad_t
3748 *********/
3749
3750 /****f* IBA Base: Types/ib_mad_is_response
3751 * NAME
3752 *       ib_mad_is_response
3753 *
3754 * DESCRIPTION
3755 *       Returns TRUE if the MAD is a response ('R' bit set),
3756 *       FALSE otherwise.
3757 *
3758 * SYNOPSIS
3759 */
3760 static inline boolean_t OSM_API
3761 ib_mad_is_response(IN const ib_mad_t * const p_mad)
3762 {
3763         CL_ASSERT(p_mad);
3764         return ((p_mad->method & IB_MAD_METHOD_RESP_MASK) ==
3765                 IB_MAD_METHOD_RESP_MASK);
3766 }
3767
3768 /*
3769 * PARAMETERS
3770 *       p_mad
3771 *               [in] Pointer to the MAD.
3772 *
3773 * RETURN VALUES
3774 *       Returns TRUE if the MAD is a response ('R' bit set),
3775 *       FALSE otherwise.
3776 *
3777 * NOTES
3778 *
3779 * SEE ALSO
3780 *       ib_mad_t
3781 *********/
3782
3783 #define IB_RMPP_TYPE_DATA               1
3784 #define IB_RMPP_TYPE_ACK                2
3785 #define IB_RMPP_TYPE_STOP               3
3786 #define IB_RMPP_TYPE_ABORT              4
3787
3788 #define IB_RMPP_NO_RESP_TIME            0x1F
3789 #define IB_RMPP_FLAG_ACTIVE             0x01
3790 #define IB_RMPP_FLAG_FIRST              0x02
3791 #define IB_RMPP_FLAG_LAST               0x04
3792
3793 #define IB_RMPP_STATUS_SUCCESS          0
3794 #define IB_RMPP_STATUS_RESX             1       /* resources exhausted */
3795 #define IB_RMPP_STATUS_T2L              118     /* time too long */
3796 #define IB_RMPP_STATUS_BAD_LEN          119     /* incon. last and payload len */
3797 #define IB_RMPP_STATUS_BAD_SEG          120     /* incon. first and segment no */
3798 #define IB_RMPP_STATUS_BADT             121     /* bad rmpp type */
3799 #define IB_RMPP_STATUS_W2S              122     /* newwindowlast too small */
3800 #define IB_RMPP_STATUS_S2B              123     /* segment no too big */
3801 #define IB_RMPP_STATUS_BAD_STATUS       124     /* illegal status */
3802 #define IB_RMPP_STATUS_UNV              125     /* unsupported version */
3803 #define IB_RMPP_STATUS_TMR              126     /* too many retries */
3804 #define IB_RMPP_STATUS_UNSPEC           127     /* unspecified */
3805
3806 /****f* IBA Base: Types/ib_rmpp_is_flag_set
3807 * NAME
3808 *       ib_rmpp_is_flag_set
3809 *
3810 * DESCRIPTION
3811 *       Returns TRUE if the MAD has the given RMPP flag set.
3812 *
3813 * SYNOPSIS
3814 */
3815 static inline boolean_t OSM_API
3816 ib_rmpp_is_flag_set(IN const ib_rmpp_mad_t * const p_rmpp_mad,
3817                     IN const uint8_t flag)
3818 {
3819         CL_ASSERT(p_rmpp_mad);
3820         return ((p_rmpp_mad->rmpp_flags & flag) == flag);
3821 }
3822
3823 /*
3824 * PARAMETERS
3825 *       ib_rmpp_mad_t
3826 *               [in] Pointer to a MAD with an RMPP header.
3827 *
3828 *       flag
3829 *               [in] The RMPP flag being examined.
3830 *
3831 * RETURN VALUES
3832 *       Returns TRUE if the MAD has the given RMPP flag set.
3833 *
3834 * NOTES
3835 *
3836 * SEE ALSO
3837 *       ib_mad_t, ib_rmpp_mad_t
3838 *********/
3839
3840 static inline void OSM_API
3841 ib_rmpp_set_resp_time(IN ib_rmpp_mad_t * const p_rmpp_mad,
3842                       IN const uint8_t resp_time)
3843 {
3844         CL_ASSERT(p_rmpp_mad);
3845         p_rmpp_mad->rmpp_flags |= (resp_time << 3);
3846 }
3847
3848 static inline uint8_t OSM_API
3849 ib_rmpp_get_resp_time(IN const ib_rmpp_mad_t * const p_rmpp_mad)
3850 {
3851         CL_ASSERT(p_rmpp_mad);
3852         return ((uint8_t) (p_rmpp_mad->rmpp_flags >> 3));
3853 }
3854
3855 /****d* IBA Base: Constants/IB_SMP_DIRECTION
3856 * NAME
3857 *       IB_SMP_DIRECTION
3858 *
3859 * DESCRIPTION
3860 *       The Direction bit for directed route SMPs.
3861 *
3862 * SOURCE
3863 */
3864 #define IB_SMP_DIRECTION_HO             0x8000
3865 #define IB_SMP_DIRECTION                (CL_HTON16(IB_SMP_DIRECTION_HO))
3866 /**********/
3867
3868 /****d* IBA Base: Constants/IB_SMP_STATUS_MASK
3869 * NAME
3870 *       IB_SMP_STATUS_MASK
3871 *
3872 * DESCRIPTION
3873 *       Mask value for extracting status from a directed route SMP.
3874 *
3875 * SOURCE
3876 */
3877 #define IB_SMP_STATUS_MASK_HO           0x7FFF
3878 #define IB_SMP_STATUS_MASK              (CL_HTON16(IB_SMP_STATUS_MASK_HO))
3879 /**********/
3880
3881 /****s* IBA Base: Types/ib_smp_t
3882 * NAME
3883 *       ib_smp_t
3884 *
3885 * DESCRIPTION
3886 *       IBA defined SMP. (14.2.1.2)
3887 *
3888 * SYNOPSIS
3889 */
3890 #define IB_SMP_DATA_SIZE 64
3891 #include <complib/cl_packon.h>
3892 typedef struct _ib_smp {
3893         uint8_t base_ver;
3894         uint8_t mgmt_class;
3895         uint8_t class_ver;
3896         uint8_t method;
3897         ib_net16_t status;
3898         uint8_t hop_ptr;
3899         uint8_t hop_count;
3900         ib_net64_t trans_id;
3901         ib_net16_t attr_id;
3902         ib_net16_t resv;
3903         ib_net32_t attr_mod;
3904         ib_net64_t m_key;
3905         ib_net16_t dr_slid;
3906         ib_net16_t dr_dlid;
3907         uint32_t resv1[7];
3908         uint8_t data[IB_SMP_DATA_SIZE];
3909         uint8_t initial_path[IB_SUBNET_PATH_HOPS_MAX];
3910         uint8_t return_path[IB_SUBNET_PATH_HOPS_MAX];
3911
3912 } PACK_SUFFIX ib_smp_t;
3913 #include <complib/cl_packoff.h>
3914 /*
3915 * FIELDS
3916 *       base_ver
3917 *               MAD base format.
3918 *
3919 *       mgmt_class
3920 *               Class of operation.
3921 *
3922 *       class_ver
3923 *               Version of MAD class-specific format.
3924 *
3925 *       method
3926 *               Method to perform, including 'R' bit.
3927 *
3928 *       status
3929 *               Status of operation.
3930 *
3931 *       hop_ptr
3932 *               Hop pointer for directed route MADs.
3933 *
3934 *       hop_count
3935 *               Hop count for directed route MADs.
3936 *
3937 *       trans_Id
3938 *               Transaction ID.
3939 *
3940 *       attr_id
3941 *               Attribute ID.
3942 *
3943 *       resv
3944 *               Reserved field.
3945 *
3946 *       attr_mod
3947 *               Attribute modifier.
3948 *
3949 *       m_key
3950 *               Management key value.
3951 *
3952 *       dr_slid
3953 *               Directed route source LID.
3954 *
3955 *       dr_dlid
3956 *               Directed route destination LID.
3957 *
3958 *       resv0
3959 *               Reserved for 64 byte alignment.
3960 *
3961 *       data
3962 *               MAD data payload.
3963 *
3964 *       initial_path
3965 *               Outbound port list.
3966 *
3967 *       return_path
3968 *               Inbound port list.
3969 *
3970 * SEE ALSO
3971 *********/
3972
3973 /****f* IBA Base: Types/ib_smp_get_status
3974 * NAME
3975 *       ib_smp_get_status
3976 *
3977 * DESCRIPTION
3978 *       Returns the SMP status value in network order.
3979 *
3980 * SYNOPSIS
3981 */
3982 static inline ib_net16_t OSM_API
3983 ib_smp_get_status(IN const ib_smp_t * const p_smp)
3984 {
3985         return ((ib_net16_t) (p_smp->status & IB_SMP_STATUS_MASK));
3986 }
3987
3988 /*
3989 * PARAMETERS
3990 *       p_smp
3991 *               [in] Pointer to the SMP packet.
3992 *
3993 * RETURN VALUES
3994 *       Returns the SMP status value in network order.
3995 *
3996 * NOTES
3997 *
3998 * SEE ALSO
3999 *       ib_smp_t
4000 *********/
4001
4002 /****f* IBA Base: Types/ib_smp_is_response
4003 * NAME
4004 *       ib_smp_is_response
4005 *
4006 * DESCRIPTION
4007 *       Returns TRUE if the SMP is a response MAD, FALSE otherwise.
4008 *
4009 * SYNOPSIS
4010 */
4011 static inline boolean_t OSM_API
4012 ib_smp_is_response(IN const ib_smp_t * const p_smp)
4013 {
4014         return (ib_mad_is_response((const ib_mad_t *)p_smp));
4015 }
4016
4017 /*
4018 * PARAMETERS
4019 *       p_smp
4020 *               [in] Pointer to the SMP packet.
4021 *
4022 * RETURN VALUES
4023 *       Returns TRUE if the SMP is a response MAD, FALSE otherwise.
4024 *
4025 * NOTES
4026 *
4027 * SEE ALSO
4028 *       ib_smp_t
4029 *********/
4030
4031 /****f* IBA Base: Types/ib_smp_is_d
4032 * NAME
4033 *       ib_smp_is_d
4034 *
4035 * DESCRIPTION
4036 *       Returns TRUE if the SMP 'D' (direction) bit is set.
4037 *
4038 * SYNOPSIS
4039 */
4040 static inline boolean_t OSM_API ib_smp_is_d(IN const ib_smp_t * const p_smp)
4041 {
4042         return ((p_smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION);
4043 }
4044
4045 /*
4046 * PARAMETERS
4047 *       p_smp
4048 *               [in] Pointer to the SMP packet.
4049 *
4050 * RETURN VALUES
4051 *       Returns TRUE if the SMP 'D' (direction) bit is set.
4052 *
4053 * NOTES
4054 *
4055 * SEE ALSO
4056 *       ib_smp_t
4057 *********/
4058
4059 /****f* IBA Base: Types/ib_smp_init_new
4060 * NAME
4061 *       ib_smp_init_new
4062 *
4063 * DESCRIPTION
4064 *       Initializes a MAD common header.
4065 *
4066 * TODO
4067 *       This is too big for inlining, but leave it here for now
4068 *       since there is not yet another convient spot.
4069 *
4070 * SYNOPSIS
4071 */
4072 static inline void OSM_API
4073 ib_smp_init_new(IN ib_smp_t * const p_smp,
4074                 IN const uint8_t method,
4075                 IN const ib_net64_t trans_id,
4076                 IN const ib_net16_t attr_id,
4077                 IN const ib_net32_t attr_mod,
4078                 IN const uint8_t hop_count,
4079                 IN const ib_net64_t m_key,
4080                 IN const uint8_t * path_out,
4081                 IN const ib_net16_t dr_slid, IN const ib_net16_t dr_dlid)
4082 {
4083         CL_ASSERT(p_smp);
4084         CL_ASSERT(hop_count < IB_SUBNET_PATH_HOPS_MAX);
4085         p_smp->base_ver = 1;
4086         p_smp->mgmt_class = IB_MCLASS_SUBN_DIR;
4087         p_smp->class_ver = 1;
4088         p_smp->method = method;
4089         p_smp->status = 0;
4090         p_smp->hop_ptr = 0;
4091         p_smp->hop_count = hop_count;
4092         p_smp->trans_id = trans_id;
4093         p_smp->attr_id = attr_id;
4094         p_smp->resv = 0;
4095         p_smp->attr_mod = attr_mod;
4096         p_smp->m_key = m_key;
4097         p_smp->dr_slid = dr_slid;
4098         p_smp->dr_dlid = dr_dlid;
4099
4100         memset(p_smp->resv1, 0,
4101                sizeof(p_smp->resv1) +
4102                sizeof(p_smp->data) +
4103                sizeof(p_smp->initial_path) + sizeof(p_smp->return_path));
4104
4105         /* copy the path */
4106         memcpy(&p_smp->initial_path, path_out, sizeof(p_smp->initial_path));
4107 }
4108
4109 /*
4110 * PARAMETERS
4111 *       p_smp
4112 *               [in] Pointer to the SMP packet.
4113 *
4114 *       method
4115 *               [in] Method to perform, including 'R' bit.
4116 *
4117 *       trans_Id
4118 *               [in] Transaction ID.
4119 *
4120 *       attr_id
4121 *               [in] Attribute ID.
4122 *
4123 *       attr_mod
4124 *               [in] Attribute modifier.
4125 *
4126 *       hop_count
4127 *               [in] Number of hops in the path.
4128 *
4129 *       m_key
4130 *               [in] Management key for this SMP.
4131 *
4132 *       path_out
4133 *               [in] Port array for outbound path.
4134 *
4135 *
4136 * RETURN VALUES
4137 *       None.
4138 *
4139 * NOTES
4140 *       Payload area is initialized to zero.
4141 *
4142 *
4143 * SEE ALSO
4144 *       ib_mad_t
4145 *********/
4146
4147 /****f* IBA Base: Types/ib_smp_get_payload_ptr
4148 * NAME
4149 *       ib_smp_get_payload_ptr
4150 *
4151 * DESCRIPTION
4152 *       Gets a pointer to the SMP payload area.
4153 *
4154 * SYNOPSIS
4155 */
4156 static inline void *OSM_API
4157 ib_smp_get_payload_ptr(IN const ib_smp_t * const p_smp)
4158 {
4159         return ((void *)p_smp->data);
4160 }
4161
4162 /*
4163 * PARAMETERS
4164 *       p_smp
4165 *               [in] Pointer to the SMP packet.
4166 *
4167 * RETURN VALUES
4168 *       Pointer to SMP payload area.
4169 *
4170 * NOTES
4171 *
4172 * SEE ALSO
4173 *       ib_mad_t
4174 *********/
4175
4176 /****s* IBA Base: Types/ib_node_info_t
4177 * NAME
4178 *       ib_node_info_t
4179 *
4180 * DESCRIPTION
4181 *       IBA defined NodeInfo. (14.2.5.3)
4182 *
4183 * SYNOPSIS
4184 */
4185 #include <complib/cl_packon.h>
4186 typedef struct _ib_node_info {
4187         uint8_t base_version;
4188         uint8_t class_version;
4189         uint8_t node_type;
4190         uint8_t num_ports;
4191         ib_net64_t sys_guid;
4192         ib_net64_t node_guid;
4193         ib_net64_t port_guid;
4194         ib_net16_t partition_cap;
4195         ib_net16_t device_id;
4196         ib_net32_t revision;
4197         ib_net32_t port_num_vendor_id;
4198
4199 } PACK_SUFFIX ib_node_info_t;
4200 #include <complib/cl_packoff.h>
4201 /************/
4202
4203 /****s* IBA Base: Types/ib_sa_mad_t
4204 * NAME
4205 *       ib_sa_mad_t
4206 *
4207 * DESCRIPTION
4208 *       IBA defined SA MAD format. (15.2.1)
4209 *
4210 * SYNOPSIS
4211 */
4212 #define IB_SA_DATA_SIZE 200
4213
4214 #include <complib/cl_packon.h>
4215 typedef struct _ib_sa_mad {
4216         uint8_t base_ver;
4217         uint8_t mgmt_class;
4218         uint8_t class_ver;
4219         uint8_t method;
4220         ib_net16_t status;
4221         ib_net16_t resv;
4222         ib_net64_t trans_id;
4223         ib_net16_t attr_id;
4224         ib_net16_t resv1;
4225         ib_net32_t attr_mod;
4226
4227         uint8_t rmpp_version;
4228         uint8_t rmpp_type;
4229         uint8_t rmpp_flags;
4230         uint8_t rmpp_status;
4231
4232         ib_net32_t seg_num;
4233         ib_net32_t paylen_newwin;
4234
4235         ib_net64_t sm_key;
4236
4237         ib_net16_t attr_offset;
4238         ib_net16_t resv3;
4239
4240         ib_net64_t comp_mask;
4241
4242         uint8_t data[IB_SA_DATA_SIZE];
4243 } PACK_SUFFIX ib_sa_mad_t;
4244 #include <complib/cl_packoff.h>
4245 /**********/
4246 #define IB_SA_MAD_HDR_SIZE (sizeof(ib_sa_mad_t) - IB_SA_DATA_SIZE)
4247
4248 static inline uint32_t OSM_API ib_get_attr_size(IN const ib_net16_t attr_offset)
4249 {
4250         return (((uint32_t) cl_ntoh16(attr_offset)) << 3);
4251 }
4252
4253 static inline ib_net16_t OSM_API ib_get_attr_offset(IN const uint32_t attr_size)
4254 {
4255         return (cl_hton16((uint16_t) (attr_size >> 3)));
4256 }
4257
4258 /****f* IBA Base: Types/ib_sa_mad_get_payload_ptr
4259 * NAME
4260 *       ib_sa_mad_get_payload_ptr
4261 *
4262 * DESCRIPTION
4263 *       Gets a pointer to the SA MAD's payload area.
4264 *
4265 * SYNOPSIS
4266 */
4267 static inline void *OSM_API
4268 ib_sa_mad_get_payload_ptr(IN const ib_sa_mad_t * const p_sa_mad)
4269 {
4270         return ((void *)p_sa_mad->data);
4271 }
4272
4273 /*
4274 * PARAMETERS
4275 *       p_sa_mad
4276 *               [in] Pointer to the SA MAD packet.
4277 *
4278 * RETURN VALUES
4279 *       Pointer to SA MAD payload area.
4280 *
4281 * NOTES
4282 *
4283 * SEE ALSO
4284 *       ib_mad_t
4285 *********/
4286
4287 #define IB_NODE_INFO_PORT_NUM_MASK              (CL_HTON32(0xFF000000))
4288 #define IB_NODE_INFO_VEND_ID_MASK               (CL_HTON32(0x00FFFFFF))
4289 #if CPU_LE
4290 #define IB_NODE_INFO_PORT_NUM_SHIFT 0
4291 #else
4292 #define IB_NODE_INFO_PORT_NUM_SHIFT 24
4293 #endif
4294
4295 /****f* IBA Base: Types/ib_node_info_get_local_port_num
4296 * NAME
4297 *       ib_node_info_get_local_port_num
4298 *
4299 * DESCRIPTION
4300 *       Gets a the local port number from the NodeInfo attribute.
4301 *
4302 * SYNOPSIS
4303 */
4304 static inline uint8_t OSM_API
4305 ib_node_info_get_local_port_num(IN const ib_node_info_t * const p_ni)
4306 {
4307         return ((uint8_t) ((p_ni->port_num_vendor_id &
4308                             IB_NODE_INFO_PORT_NUM_MASK)
4309                            >> IB_NODE_INFO_PORT_NUM_SHIFT));
4310 }
4311
4312 /*
4313 * PARAMETERS
4314 *       p_ni
4315 *               [in] Pointer to a NodeInfo attribute.
4316 *
4317 * RETURN VALUES
4318 *       Local port number that returned the attribute.
4319 *
4320 * NOTES
4321 *
4322 * SEE ALSO
4323 *       ib_node_info_t
4324 *********/
4325
4326 /****f* IBA Base: Types/ib_node_info_get_vendor_id
4327 * NAME
4328 *       ib_node_info_get_vendor_id
4329 *
4330 * DESCRIPTION
4331 *       Gets the VendorID from the NodeInfo attribute.
4332 *
4333 * SYNOPSIS
4334 */
4335 static inline ib_net32_t OSM_API
4336 ib_node_info_get_vendor_id(IN const ib_node_info_t * const p_ni)
4337 {
4338         return ((ib_net32_t) (p_ni->port_num_vendor_id &
4339                               IB_NODE_INFO_VEND_ID_MASK));
4340 }
4341
4342 /*
4343 * PARAMETERS
4344 *       p_ni
4345 *               [in] Pointer to a NodeInfo attribute.
4346 *
4347 * RETURN VALUES
4348 *       VendorID that returned the attribute.
4349 *
4350 * NOTES
4351 *
4352 * SEE ALSO
4353 *       ib_node_info_t
4354 *********/
4355
4356 #define IB_NODE_DESCRIPTION_SIZE 64
4357
4358 #include <complib/cl_packon.h>
4359 typedef struct _ib_node_desc {
4360         // Node String is an array of UTF-8 character that
4361         // describes the node in text format
4362         // Note that this string is NOT NULL TERMINATED!
4363         uint8_t description[IB_NODE_DESCRIPTION_SIZE];
4364
4365 } PACK_SUFFIX ib_node_desc_t;
4366 #include <complib/cl_packoff.h>
4367
4368 #include <complib/cl_packon.h>
4369 typedef struct _ib_node_record_t {
4370         ib_net16_t lid;
4371         ib_net16_t resv;
4372         ib_node_info_t node_info;
4373         ib_node_desc_t node_desc;
4374         uint8_t pad[4];
4375
4376 } PACK_SUFFIX ib_node_record_t;
4377 #include <complib/cl_packoff.h>
4378
4379 /****s* IBA Base: Types/ib_port_info_t
4380 * NAME
4381 *       ib_port_info_t
4382 *
4383 * DESCRIPTION
4384 *       IBA defined PortInfo. (14.2.5.6)
4385 *
4386 * SYNOPSIS
4387 */
4388 #include <complib/cl_packon.h>
4389 typedef struct _ib_port_info {
4390         ib_net64_t m_key;
4391         ib_net64_t subnet_prefix;
4392         ib_net16_t base_lid;
4393         ib_net16_t master_sm_base_lid;
4394         ib_net32_t capability_mask;
4395         ib_net16_t diag_code;
4396         ib_net16_t m_key_lease_period;
4397         uint8_t local_port_num;
4398         uint8_t link_width_enabled;
4399         uint8_t link_width_supported;
4400         uint8_t link_width_active;
4401         uint8_t state_info1;    /* LinkSpeedSupported and PortState */
4402         uint8_t state_info2;    /* PortPhysState and LinkDownDefaultState */
4403         uint8_t mkey_lmc;
4404         uint8_t link_speed;     /* LinkSpeedEnabled and LinkSpeedActive */
4405         uint8_t mtu_smsl;
4406         uint8_t vl_cap;         /* VLCap and InitType */
4407         uint8_t vl_high_limit;
4408         uint8_t vl_arb_high_cap;
4409         uint8_t vl_arb_low_cap;
4410         uint8_t mtu_cap;
4411         uint8_t vl_stall_life;
4412         uint8_t vl_enforce;
4413         ib_net16_t m_key_violations;
4414         ib_net16_t p_key_violations;
4415         ib_net16_t q_key_violations;
4416         uint8_t guid_cap;
4417         uint8_t subnet_timeout; /* cli_rereg(1b), resrv(
4418                                    2b), timeout(5b) */
4419         uint8_t resp_time_value;
4420         uint8_t error_threshold;
4421
4422 } PACK_SUFFIX ib_port_info_t;
4423 #include <complib/cl_packoff.h>
4424 /************/
4425
4426 #define IB_PORT_STATE_MASK                      0x0F
4427 #define IB_PORT_LMC_MASK                        0x07
4428 #define IB_PORT_LMC_MAX                         0x07
4429 #define IB_PORT_MPB_MASK                        0xC0
4430 #define IB_PORT_MPB_SHIFT                       6
4431 #define IB_PORT_LINK_SPEED_SHIFT                4
4432 #define IB_PORT_LINK_SPEED_SUPPORTED_MASK       0xF0
4433 #define IB_PORT_LINK_SPEED_ACTIVE_MASK          0xF0
4434 #define IB_PORT_LINK_SPEED_ENABLED_MASK         0x0F
4435 #define IB_PORT_PHYS_STATE_MASK                 0xF0
4436 #define IB_PORT_PHYS_STATE_SHIFT                4
4437 #define IB_PORT_PHYS_STATE_NO_CHANGE            0
4438 #define IB_PORT_PHYS_STATE_SLEEP                1
4439 #define IB_PORT_PHYS_STATE_POLLING              2
4440 #define IB_PORT_PHYS_STATE_DISABLED             3
4441 #define IB_PORT_PHYS_STATE_PORTCONFTRAIN        4
4442 #define IB_PORT_PHYS_STATE_LINKUP               5
4443 #define IB_PORT_PHYS_STATE_LINKERRRECOVER       6
4444 #define IB_PORT_PHYS_STATE_PHYTEST              7
4445 #define IB_PORT_LNKDWNDFTSTATE_MASK             0x0F
4446
4447 #define IB_PORT_CAP_RESV0         (CL_HTON32(0x00000001))
4448 #define IB_PORT_CAP_IS_SM         (CL_HTON32(0x00000002))
4449 #define IB_PORT_CAP_HAS_NOTICE    (CL_HTON32(0x00000004))
4450 #define IB_PORT_CAP_HAS_TRAP      (CL_HTON32(0x00000008))
4451 #define IB_PORT_CAP_HAS_IPD       (CL_HTON32(0x00000010))
4452 #define IB_PORT_CAP_HAS_AUTO_MIG  (CL_HTON32(0x00000020))
4453 #define IB_PORT_CAP_HAS_SL_MAP    (CL_HTON32(0x00000040))
4454 #define IB_PORT_CAP_HAS_NV_MKEY   (CL_HTON32(0x00000080))
4455 #define IB_PORT_CAP_HAS_NV_PKEY   (CL_HTON32(0x00000100))
4456 #define IB_PORT_CAP_HAS_LED_INFO  (CL_HTON32(0x00000200))
4457 #define IB_PORT_CAP_SM_DISAB      (CL_HTON32(0x00000400))
4458 #define IB_PORT_CAP_HAS_SYS_IMG_GUID  (CL_HTON32(0x00000800))
4459 #define IB_PORT_CAP_HAS_PKEY_SW_EXT_PORT_TRAP (CL_HTON32(0x00001000))
4460 #define IB_PORT_CAP_RESV13        (CL_HTON32(0x00002000))
4461 #define IB_PORT_CAP_RESV14        (CL_HTON32(0x00004000))
4462 #define IB_PORT_CAP_RESV15        (CL_HTON32(0x00008000))
4463 #define IB_PORT_CAP_HAS_COM_MGT   (CL_HTON32(0x00010000))
4464 #define IB_PORT_CAP_HAS_SNMP      (CL_HTON32(0x00020000))
4465 #define IB_PORT_CAP_REINIT        (CL_HTON32(0x00040000))
4466 #define IB_PORT_CAP_HAS_DEV_MGT   (CL_HTON32(0x00080000))
4467 #define IB_PORT_CAP_HAS_VEND_CLS  (CL_HTON32(0x00100000))
4468 #define IB_PORT_CAP_HAS_DR_NTC    (CL_HTON32(0x00200000))
4469 #define IB_PORT_CAP_HAS_CAP_NTC   (CL_HTON32(0x00400000))
4470 #define IB_PORT_CAP_HAS_BM        (CL_HTON32(0x00800000))
4471 #define IB_PORT_CAP_HAS_LINK_RT_LATENCY (CL_HTON32(0x01000000))
4472 #define IB_PORT_CAP_HAS_CLIENT_REREG (CL_HTON32(0x02000000))
4473 #define IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC (CL_HTON32(0x04000000))
4474 #define IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL (CL_HTON32(0x08000000))
4475 #define IB_PORT_CAP_RESV28        (CL_HTON32(0x10000000))
4476 #define IB_PORT_CAP_RESV29        (CL_HTON32(0x20000000))
4477 #define IB_PORT_CAP_RESV30        (CL_HTON32(0x40000000))
4478 #define IB_PORT_CAP_RESV31        (CL_HTON32(0x80000000))
4479
4480 /****f* IBA Base: Types/ib_port_info_get_port_state
4481 * NAME
4482 *       ib_port_info_get_port_state
4483 *
4484 * DESCRIPTION
4485 *       Returns the port state.
4486 *
4487 * SYNOPSIS
4488 */
4489 static inline uint8_t OSM_API
4490 ib_port_info_get_port_state(IN const ib_port_info_t * const p_pi)
4491 {
4492         return ((uint8_t) (p_pi->state_info1 & IB_PORT_STATE_MASK));
4493 }
4494
4495 /*
4496 * PARAMETERS
4497 *       p_pi
4498 *               [in] Pointer to a PortInfo attribute.
4499 *
4500 * RETURN VALUES
4501 *       Port state.
4502 *
4503 * NOTES
4504 *
4505 * SEE ALSO
4506 *********/
4507
4508 /****f* IBA Base: Types/ib_port_info_set_port_state
4509 * NAME
4510 *       ib_port_info_set_port_state
4511 *
4512 * DESCRIPTION
4513 *       Sets the port state.
4514 *
4515 * SYNOPSIS
4516 */
4517 static inline void OSM_API
4518 ib_port_info_set_port_state(IN ib_port_info_t * const p_pi,
4519                             IN const uint8_t port_state)
4520 {
4521         p_pi->state_info1 = (uint8_t) ((p_pi->state_info1 & 0xF0) | port_state);
4522 }
4523
4524 /*
4525 * PARAMETERS
4526 *       p_pi
4527 *               [in] Pointer to a PortInfo attribute.
4528 *
4529 *       port_state
4530 *               [in] Port state value to set.
4531 *
4532 * RETURN VALUES
4533 *       None.
4534 *
4535 * NOTES
4536 *
4537 * SEE ALSO
4538 *********/
4539
4540 /****f* IBA Base: Types/ib_port_info_get_vl_cap
4541 * NAME
4542 *       ib_port_info_get_vl_cap
4543 *
4544 * DESCRIPTION
4545 *       Gets the VL Capability of a port.
4546 *
4547 * SYNOPSIS
4548 */
4549 static inline uint8_t OSM_API
4550 ib_port_info_get_vl_cap(IN const ib_port_info_t * const p_pi)
4551 {
4552         return ((p_pi->vl_cap >> 4) & 0x0F);
4553 }
4554
4555 /*
4556 * PARAMETERS
4557 *       p_pi
4558 *               [in] Pointer to a PortInfo attribute.
4559 *
4560 * RETURN VALUES
4561 *       VL_CAP field
4562 *
4563 * NOTES
4564 *
4565 * SEE ALSO
4566 *********/
4567
4568 /****f* IBA Base: Types/ib_port_info_get_init_type
4569 * NAME
4570 *       ib_port_info_get_init_type
4571 *
4572 * DESCRIPTION
4573 *       Gets the init type of a port.
4574 *
4575 * SYNOPSIS
4576 */
4577 static inline uint8_t OSM_API
4578 ib_port_info_get_init_type(IN const ib_port_info_t * const p_pi)
4579 {
4580         return (uint8_t) (p_pi->vl_cap & 0x0F);
4581 }
4582
4583 /*
4584 * PARAMETERS
4585 *       p_pi
4586 *               [in] Pointer to a PortInfo attribute.
4587 *
4588 * RETURN VALUES
4589 *       InitType field
4590 *
4591 * NOTES
4592 *
4593 * SEE ALSO
4594 *********/
4595
4596 /****f* IBA Base: Types/ib_port_info_get_op_vls
4597 * NAME
4598 *       ib_port_info_get_op_vls
4599 *
4600 * DESCRIPTION
4601 *       Gets the operational VLs on a port.
4602 *
4603 * SYNOPSIS
4604 */
4605 static inline uint8_t OSM_API
4606 ib_port_info_get_op_vls(IN const ib_port_info_t * const p_pi)
4607 {
4608         return ((p_pi->vl_enforce >> 4) & 0x0F);
4609 }
4610
4611 /*
4612 * PARAMETERS
4613 *       p_pi
4614 *               [in] Pointer to a PortInfo attribute.
4615 *
4616 * RETURN VALUES
4617 *       OP_VLS field
4618 *
4619 * NOTES
4620 *
4621 * SEE ALSO
4622 *********/
4623
4624 /****f* IBA Base: Types/ib_port_info_set_op_vls
4625 * NAME
4626 *       ib_port_info_set_op_vls
4627 *
4628 * DESCRIPTION
4629 *       Sets the operational VLs on a port.
4630 *
4631 * SYNOPSIS
4632 */
4633 static inline void OSM_API
4634 ib_port_info_set_op_vls(IN ib_port_info_t * const p_pi, IN const uint8_t op_vls)
4635 {
4636         p_pi->vl_enforce =
4637             (uint8_t) ((p_pi->vl_enforce & 0x0F) | (op_vls << 4));
4638 }
4639
4640 /*
4641 * PARAMETERS
4642 *       p_pi
4643 *               [in] Pointer to a PortInfo attribute.
4644 *
4645 *       op_vls
4646 *               [in] Encoded operation VLs value.
4647 *
4648 * RETURN VALUES
4649 *       None.
4650 *
4651 * NOTES
4652 *
4653 * SEE ALSO
4654 *********/
4655
4656 /****f* IBA Base: Types/ib_port_info_set_state_no_change
4657 * NAME
4658 *       ib_port_info_set_state_no_change
4659 *
4660 * DESCRIPTION
4661 *       Sets the port state fields to the value for "no change".
4662 *
4663 * SYNOPSIS
4664 */
4665 static inline void OSM_API
4666 ib_port_info_set_state_no_change(IN ib_port_info_t * const p_pi)
4667 {
4668         ib_port_info_set_port_state(p_pi, IB_LINK_NO_CHANGE);
4669         p_pi->state_info2 = 0;
4670 }
4671
4672 /*
4673 * PARAMETERS
4674 *       p_pi
4675 *               [in] Pointer to a PortInfo attribute.
4676 *
4677 * RETURN VALUES
4678 *       None.
4679 *
4680 * NOTES
4681 *
4682 * SEE ALSO
4683 *********/
4684
4685 /****f* IBA Base: Types/ib_port_info_get_link_speed_sup
4686 * NAME
4687 *       ib_port_info_get_link_speed_sup
4688 *
4689 * DESCRIPTION
4690 *       Returns the encoded value for the link speed supported.
4691 *
4692 * SYNOPSIS
4693 */
4694 static inline uint8_t OSM_API
4695 ib_port_info_get_link_speed_sup(IN const ib_port_info_t * const p_pi)
4696 {
4697         return ((uint8_t) ((p_pi->state_info1 &
4698                             IB_PORT_LINK_SPEED_SUPPORTED_MASK) >>
4699                            IB_PORT_LINK_SPEED_SHIFT));
4700 }
4701
4702 /*
4703 * PARAMETERS
4704 *       p_pi
4705 *               [in] Pointer to a PortInfo attribute.
4706 *
4707 * RETURN VALUES
4708 *       Returns the encoded value for the link speed supported.
4709 *
4710 * NOTES
4711 *
4712 * SEE ALSO
4713 *********/
4714
4715 /****f* IBA Base: Types/ib_port_info_set_link_speed_sup
4716 * NAME
4717 *       ib_port_info_set_link_speed_sup
4718 *
4719 * DESCRIPTION
4720 *       Given an integer of the supported link speed supported.
4721 *       Set the appropriate bits in state_info1
4722 *
4723 * SYNOPSIS
4724 */
4725 static inline void OSM_API
4726 ib_port_info_set_link_speed_sup(IN uint8_t const speed,
4727                                 IN ib_port_info_t * p_pi)
4728 {
4729         p_pi->state_info1 =
4730             (~IB_PORT_LINK_SPEED_SUPPORTED_MASK & p_pi->state_info1) |
4731             (IB_PORT_LINK_SPEED_SUPPORTED_MASK &
4732              (speed << IB_PORT_LINK_SPEED_SHIFT));
4733 }
4734
4735 /*
4736 * PARAMETERS
4737 *       speed
4738 *               [in] Supported Speeds Code.
4739 *
4740 *       p_pi
4741 *               [in] Pointer to a PortInfo attribute.
4742 *
4743 * RETURN VALUES
4744 *       This function does not return a value.
4745 *
4746 * NOTES
4747 *
4748 * SEE ALSO
4749 *********/
4750
4751 /****f* IBA Base: Types/ib_port_info_get_port_phys_state
4752 * NAME
4753 *       ib_port_info_get_port_phys_state
4754 *
4755 * DESCRIPTION
4756 *       Returns the encoded value for the port physical state.
4757 *
4758 * SYNOPSIS
4759 */
4760 static inline uint8_t OSM_API
4761 ib_port_info_get_port_phys_state(IN const ib_port_info_t * const p_pi)
4762 {
4763         return ((uint8_t) ((p_pi->state_info2 &
4764                             IB_PORT_PHYS_STATE_MASK) >>
4765                            IB_PORT_PHYS_STATE_SHIFT));
4766 }
4767
4768 /*
4769 * PARAMETERS
4770 *       p_pi
4771 *               [in] Pointer to a PortInfo attribute.
4772 *
4773 * RETURN VALUES
4774 *       Returns the encoded value for the port physical state.
4775 *
4776 * NOTES
4777 *
4778 * SEE ALSO
4779 *********/
4780
4781 /****f* IBA Base: Types/ib_port_info_set_port_phys_state
4782 * NAME
4783 *       ib_port_info_set_port_phys_state
4784 *
4785 * DESCRIPTION
4786 *       Given an integer of the port physical state,
4787 *       Set the appropriate bits in state_info2
4788 *
4789 * SYNOPSIS
4790 */
4791 static inline void OSM_API
4792 ib_port_info_set_port_phys_state(IN uint8_t const phys_state,
4793                                  IN ib_port_info_t * p_pi)
4794 {
4795         p_pi->state_info2 =
4796             (~IB_PORT_PHYS_STATE_MASK & p_pi->state_info2) |
4797             (IB_PORT_PHYS_STATE_MASK &
4798              (phys_state << IB_PORT_PHYS_STATE_SHIFT));
4799 }
4800
4801 /*
4802 * PARAMETERS
4803 *       phys_state
4804 *               [in] port physical state.
4805 *
4806 *       p_pi
4807 *               [in] Pointer to a PortInfo attribute.
4808 *
4809 * RETURN VALUES
4810 *       This function does not return a value.
4811 *
4812 * NOTES
4813 *
4814 * SEE ALSO
4815 *********/
4816
4817 /****f* IBA Base: Types/ib_port_info_get_link_down_def_state
4818 * NAME
4819 *       ib_port_info_get_link_down_def_state
4820 *
4821 * DESCRIPTION
4822 *       Returns the link down default state.
4823 *
4824 * SYNOPSIS
4825 */
4826 static inline uint8_t OSM_API
4827 ib_port_info_get_link_down_def_state(IN const ib_port_info_t * const p_pi)
4828 {
4829         return ((uint8_t) (p_pi->state_info2 & IB_PORT_LNKDWNDFTSTATE_MASK));
4830 }
4831
4832 /*
4833 * PARAMETERS
4834 *       p_pi
4835 *               [in] Pointer to a PortInfo attribute.
4836 *
4837 * RETURN VALUES
4838 *       link down default state of the port.
4839 *
4840 * NOTES
4841 *
4842 * SEE ALSO
4843 *********/
4844
4845 /****f* IBA Base: Types/ib_port_info_set_link_down_def_state
4846 * NAME
4847 *       ib_port_info_set_link_down_def_state
4848 *
4849 * DESCRIPTION
4850 *       Sets the link down default state of the port.
4851 *
4852 * SYNOPSIS
4853 */
4854 static inline void OSM_API
4855 ib_port_info_set_link_down_def_state(IN ib_port_info_t * const p_pi,
4856                                      IN const uint8_t link_dwn_state)
4857 {
4858         p_pi->state_info2 =
4859             (uint8_t) ((p_pi->state_info2 & 0xF0) | link_dwn_state);
4860 }
4861
4862 /*
4863 * PARAMETERS
4864 *       p_pi
4865 *               [in] Pointer to a PortInfo attribute.
4866 *
4867 *       link_dwn_state
4868 *               [in] Link down default state of the port.
4869 *
4870 * RETURN VALUES
4871 *       None.
4872 *
4873 * NOTES
4874 *
4875 * SEE ALSO
4876 *********/
4877
4878 /****f* IBA Base: Types/ib_port_info_get_link_speed_active
4879 * NAME
4880 *       ib_port_info_get_link_speed_active
4881 *
4882 * DESCRIPTION
4883 *       Returns the Link Speed Active value assigned to this port.
4884 *
4885 * SYNOPSIS
4886 */
4887 static inline uint8_t OSM_API
4888 ib_port_info_get_link_speed_active(IN const ib_port_info_t * const p_pi)
4889 {
4890         return ((uint8_t) ((p_pi->link_speed &
4891                             IB_PORT_LINK_SPEED_ACTIVE_MASK) >>
4892                            IB_PORT_LINK_SPEED_SHIFT));
4893 }
4894
4895 /*
4896 * PARAMETERS
4897 *       p_pi
4898 *               [in] Pointer to a PortInfo attribute.
4899 *
4900 * RETURN VALUES
4901 *       Returns the link speed active value assigned to this port.
4902 *
4903 * NOTES
4904 *
4905 * SEE ALSO
4906 *********/
4907
4908 #define IB_LINK_WIDTH_ACTIVE_1X                 1
4909 #define IB_LINK_WIDTH_ACTIVE_4X                 2
4910 #define IB_LINK_WIDTH_ACTIVE_8X                 4
4911 #define IB_LINK_WIDTH_ACTIVE_12X                8
4912 #define IB_LINK_SPEED_ACTIVE_2_5                1
4913 #define IB_LINK_SPEED_ACTIVE_5                  2
4914 #define IB_LINK_SPEED_ACTIVE_10                 4
4915
4916 /* following v1 ver1.2 p901 */
4917 #define IB_PATH_RECORD_RATE_2_5_GBS             2
4918 #define IB_PATH_RECORD_RATE_10_GBS              3
4919 #define IB_PATH_RECORD_RATE_30_GBS              4
4920 #define IB_PATH_RECORD_RATE_5_GBS               5
4921 #define IB_PATH_RECORD_RATE_20_GBS              6
4922 #define IB_PATH_RECORD_RATE_40_GBS              7
4923 #define IB_PATH_RECORD_RATE_60_GBS              8
4924 #define IB_PATH_RECORD_RATE_80_GBS              9
4925 #define IB_PATH_RECORD_RATE_120_GBS             10
4926
4927 #define IB_MIN_RATE    IB_PATH_RECORD_RATE_2_5_GBS
4928 #define IB_MAX_RATE    IB_PATH_RECORD_RATE_120_GBS
4929
4930 /****f* IBA Base: Types/ib_port_info_compute_rate
4931 * NAME
4932 *       ib_port_info_compute_rate
4933 *
4934 * DESCRIPTION
4935 *       Returns the encoded value for the path rate.
4936 *
4937 * SYNOPSIS
4938 */
4939 static inline uint8_t OSM_API
4940 ib_port_info_compute_rate(IN const ib_port_info_t * const p_pi)
4941 {
4942         uint8_t rate = 0;
4943
4944         switch (ib_port_info_get_link_speed_active(p_pi)) {
4945         case IB_LINK_SPEED_ACTIVE_2_5:
4946                 switch (p_pi->link_width_active) {
4947                 case IB_LINK_WIDTH_ACTIVE_1X:
4948                         rate = IB_PATH_RECORD_RATE_2_5_GBS;
4949                         break;
4950
4951                 case IB_LINK_WIDTH_ACTIVE_4X:
4952                         rate = IB_PATH_RECORD_RATE_10_GBS;
4953                         break;
4954
4955                 case IB_LINK_WIDTH_ACTIVE_8X:
4956                         rate = IB_PATH_RECORD_RATE_20_GBS;
4957                         break;
4958
4959                 case IB_LINK_WIDTH_ACTIVE_12X:
4960                         rate = IB_PATH_RECORD_RATE_30_GBS;
4961                         break;
4962
4963                 default:
4964                         rate = IB_PATH_RECORD_RATE_2_5_GBS;
4965                         break;
4966                 }
4967                 break;
4968         case IB_LINK_SPEED_ACTIVE_5:
4969                 switch (p_pi->link_width_active) {
4970                 case IB_LINK_WIDTH_ACTIVE_1X:
4971                         rate = IB_PATH_RECORD_RATE_5_GBS;
4972                         break;
4973
4974                 case IB_LINK_WIDTH_ACTIVE_4X:
4975                         rate = IB_PATH_RECORD_RATE_20_GBS;
4976                         break;
4977
4978                 case IB_LINK_WIDTH_ACTIVE_8X:
4979                         rate = IB_PATH_RECORD_RATE_40_GBS;
4980                         break;
4981
4982                 case IB_LINK_WIDTH_ACTIVE_12X:
4983                         rate = IB_PATH_RECORD_RATE_60_GBS;
4984                         break;
4985
4986                 default:
4987                         rate = IB_PATH_RECORD_RATE_5_GBS;
4988                         break;
4989                 }
4990                 break;
4991         case IB_LINK_SPEED_ACTIVE_10:
4992                 switch (p_pi->link_width_active) {
4993                 case IB_LINK_WIDTH_ACTIVE_1X:
4994                         rate = IB_PATH_RECORD_RATE_10_GBS;
4995                         break;
4996
4997                 case IB_LINK_WIDTH_ACTIVE_4X:
4998                         rate = IB_PATH_RECORD_RATE_40_GBS;
4999                         break;
5000
5001                 case IB_LINK_WIDTH_ACTIVE_8X:
5002                         rate = IB_PATH_RECORD_RATE_80_GBS;
5003                         break;
5004
5005                 case IB_LINK_WIDTH_ACTIVE_12X:
5006                         rate = IB_PATH_RECORD_RATE_120_GBS;
5007                         break;
5008
5009                 default:
5010                         rate = IB_PATH_RECORD_RATE_10_GBS;
5011                         break;
5012                 }
5013                 break;
5014         default:
5015                 rate = IB_PATH_RECORD_RATE_2_5_GBS;
5016                 break;
5017         }
5018
5019         return rate;
5020 }
5021
5022 /*
5023 * PARAMETERS
5024 *       p_pi
5025 *               [in] Pointer to a PortInfo attribute.
5026 *
5027 * RETURN VALUES
5028 *       Returns the encoded value for the link speed supported.
5029 *
5030 * NOTES
5031 *
5032 * SEE ALSO
5033 *********/
5034
5035 /****f* IBA Base: Types/ib_path_get_ipd
5036 * NAME
5037 *       ib_path_get_ipd
5038 *
5039 * DESCRIPTION
5040 *       Returns the encoded value for the inter packet delay.
5041 *
5042 * SYNOPSIS
5043 */
5044 static inline uint8_t OSM_API
5045 ib_path_get_ipd(IN uint8_t local_link_width_supported, IN uint8_t path_rec_rate)
5046 {
5047         uint8_t ipd = 0;
5048
5049         switch (local_link_width_supported) {
5050                 /* link_width_supported = 1: 1x */
5051         case 1:
5052                 break;
5053
5054                 /* link_width_supported = 3: 1x or 4x */
5055         case 3:
5056                 switch (path_rec_rate & 0x3F) {
5057                 case IB_PATH_RECORD_RATE_2_5_GBS:
5058                         ipd = 3;
5059                         break;
5060                 default:
5061                         break;
5062                 }
5063                 break;
5064
5065                 /* link_width_supported = 11: 1x or 4x or 12x */
5066         case 11:
5067                 switch (path_rec_rate & 0x3F) {
5068                 case IB_PATH_RECORD_RATE_2_5_GBS:
5069                         ipd = 11;
5070                         break;
5071                 case IB_PATH_RECORD_RATE_10_GBS:
5072                         ipd = 2;
5073                         break;
5074                 default:
5075                         break;
5076                 }
5077                 break;
5078
5079         default:
5080                 break;
5081         }
5082
5083         return ipd;
5084 }
5085
5086 /*
5087 * PARAMETERS
5088 *       local_link_width_supported
5089 *               [in] link with supported for this port
5090 *
5091 *       path_rec_rate
5092 *               [in] rate field of the path record
5093 *
5094 * RETURN VALUES
5095 *       Returns the ipd
5096 *
5097 * NOTES
5098 *
5099 * SEE ALSO
5100 *********/
5101
5102 /****f* IBA Base: Types/ib_port_info_get_mtu_cap
5103 * NAME
5104 *       ib_port_info_get_mtu_cap
5105 *
5106 * DESCRIPTION
5107 *       Returns the encoded value for the maximum MTU supported by this port.
5108 *
5109 * SYNOPSIS
5110 */
5111 static inline uint8_t OSM_API
5112 ib_port_info_get_mtu_cap(IN const ib_port_info_t * const p_pi)
5113 {
5114         return ((uint8_t) (p_pi->mtu_cap & 0x0F));
5115 }
5116
5117 /*
5118 * PARAMETERS
5119 *       p_pi
5120 *               [in] Pointer to a PortInfo attribute.
5121 *
5122 * RETURN VALUES
5123 *       Returns the encooded value for the maximum MTU supported by this port.
5124 *
5125 * NOTES
5126 *
5127 * SEE ALSO
5128 *********/
5129
5130 /****f* IBA Base: Types/ib_port_info_get_neighbor_mtu
5131 * NAME
5132 *       ib_port_info_get_neighbor_mtu
5133 *
5134 * DESCRIPTION
5135 *       Returns the encoded value for the neighbor MTU supported by this port.
5136 *
5137 * SYNOPSIS
5138 */
5139 static inline uint8_t OSM_API
5140 ib_port_info_get_neighbor_mtu(IN const ib_port_info_t * const p_pi)
5141 {
5142         return ((uint8_t) ((p_pi->mtu_smsl & 0xF0) >> 4));
5143 }
5144
5145 /*
5146 * PARAMETERS
5147 *       p_pi
5148 *               [in] Pointer to a PortInfo attribute.
5149 *
5150 * RETURN VALUES
5151 *       Returns the encoded value for the neighbor MTU at this port.
5152 *
5153 * NOTES
5154 *
5155 * SEE ALSO
5156 *********/
5157
5158 /****f* IBA Base: Types/ib_port_info_set_neighbor_mtu
5159 * NAME
5160 *       ib_port_info_set_neighbor_mtu
5161 *
5162 * DESCRIPTION
5163 *       Sets the Neighbor MTU value in the PortInfo attribute.
5164 *
5165 * SYNOPSIS
5166 */
5167 static inline void OSM_API
5168 ib_port_info_set_neighbor_mtu(IN ib_port_info_t * const p_pi,
5169                               IN const uint8_t mtu)
5170 {
5171         CL_ASSERT(mtu <= 5);
5172         CL_ASSERT(mtu != 0);
5173         p_pi->mtu_smsl = (uint8_t) ((p_pi->mtu_smsl & 0x0F) | (mtu << 4));
5174 }
5175
5176 /*
5177 * PARAMETERS
5178 *       p_pi
5179 *               [in] Pointer to a PortInfo attribute.
5180 *
5181 *       mtu
5182 *               [in] Encoded MTU value to set
5183 *
5184 * RETURN VALUES
5185 *       None.
5186 *
5187 * NOTES
5188 *
5189 * SEE ALSO
5190 *********/
5191
5192 /****f* IBA Base: Types/ib_port_info_get_master_smsl
5193 * NAME
5194 *       ib_port_info_get_master_smsl
5195 *
5196 * DESCRIPTION
5197 *       Returns the encoded value for the Master SMSL at this port.
5198 *
5199 * SYNOPSIS
5200 */
5201 static inline uint8_t OSM_API
5202 ib_port_info_get_master_smsl(IN const ib_port_info_t * const p_pi)
5203 {
5204         return (uint8_t) (p_pi->mtu_smsl & 0x0F);
5205 }
5206
5207 /*
5208 * PARAMETERS
5209 *       p_pi
5210 *               [in] Pointer to a PortInfo attribute.
5211 *
5212 * RETURN VALUES
5213 *       Returns the encoded value for the Master SMSL at this port.
5214 *
5215 * NOTES
5216 *
5217 * SEE ALSO
5218 *********/
5219
5220 /****f* IBA Base: Types/ib_port_info_set_master_smsl
5221 * NAME
5222 *       ib_port_info_set_master_smsl
5223 *
5224 * DESCRIPTION
5225 *       Sets the Master SMSL value in the PortInfo attribute.
5226 *
5227 * SYNOPSIS
5228 */
5229 static inline void OSM_API
5230 ib_port_info_set_master_smsl(IN ib_port_info_t * const p_pi,
5231                              IN const uint8_t smsl)
5232 {
5233         p_pi->mtu_smsl = (uint8_t) ((p_pi->mtu_smsl & 0xF0) | smsl);
5234 }
5235
5236 /*
5237 * PARAMETERS
5238 *       p_pi
5239 *               [in] Pointer to a PortInfo attribute.
5240 *
5241 *       mtu
5242 *               [in] Encoded Master SMSL value to set
5243 *
5244 * RETURN VALUES
5245 *       None.
5246 *
5247 * NOTES
5248 *
5249 * SEE ALSO
5250 *********/
5251
5252 /****f* IBA Base: Types/ib_port_info_set_timeout
5253 * NAME
5254 *       ib_port_info_set_timeout
5255 *
5256 * DESCRIPTION
5257 *       Sets the encoded subnet timeout value in the PortInfo attribute.
5258 *
5259 * SYNOPSIS
5260 */
5261 static inline void OSM_API
5262 ib_port_info_set_timeout(IN ib_port_info_t * const p_pi,
5263                          IN const uint8_t timeout)
5264 {
5265         CL_ASSERT(timeout <= 0x1F);
5266         p_pi->subnet_timeout =
5267             (uint8_t) ((p_pi->subnet_timeout & 0x80) | (timeout & 0x1F));
5268 }
5269
5270 /*
5271 * PARAMETERS
5272 *       p_pi
5273 *               [in] Pointer to a PortInfo attribute.
5274 *
5275 *       timeout
5276 *               [in] Encoded timeout value to set
5277 *
5278 * RETURN VALUES
5279 *       None.
5280 *
5281 * NOTES
5282 *
5283 * SEE ALSO
5284 *********/
5285
5286 /****f* IBA Base: Types/ib_port_info_set_client_rereg
5287 * NAME
5288 *       ib_port_info_set_client_rereg
5289 *
5290 * DESCRIPTION
5291 *       Sets the encoded client reregistration bit value in the PortInfo attribute.
5292 *
5293 * SYNOPSIS
5294 */
5295 static inline void OSM_API
5296 ib_port_info_set_client_rereg(IN ib_port_info_t * const p_pi,
5297                               IN const uint8_t client_rereg)
5298 {
5299         CL_ASSERT(client_rereg <= 0x1);
5300         p_pi->subnet_timeout =
5301             (uint8_t) ((p_pi->
5302                         subnet_timeout & 0x1F) | ((client_rereg << 7) & 0x80));
5303 }
5304
5305 /*
5306 * PARAMETERS
5307 *       p_pi
5308 *               [in] Pointer to a PortInfo attribute.
5309 *
5310 *       client_rereg
5311 *               [in] Client reregistration value to set (either 1 or 0).
5312 *
5313 * RETURN VALUES
5314 *       None.
5315 *
5316 * NOTES
5317 *
5318 * SEE ALSO
5319 *********/
5320
5321 /****f* IBA Base: Types/ib_port_info_get_timeout
5322 * NAME
5323 *       ib_port_info_get_timeout
5324 *
5325 * DESCRIPTION
5326 *       Gets the encoded subnet timeout value in the PortInfo attribute.
5327 *
5328 * SYNOPSIS
5329 */
5330 static inline uint8_t OSM_API
5331 ib_port_info_get_timeout(IN ib_port_info_t const *p_pi)
5332 {
5333         return (p_pi->subnet_timeout & 0x1F);
5334 }
5335
5336 /*
5337 * PARAMETERS
5338 *       p_pi
5339 *               [in] Pointer to a PortInfo attribute.
5340 *
5341 * RETURN VALUES
5342 *       The encoded timeout value
5343 *
5344 * NOTES
5345 *
5346 * SEE ALSO
5347 *********/
5348
5349 /****f* IBA Base: Types/ib_port_info_get_client_rereg
5350 * NAME
5351 *       ib_port_info_get_client_rereg
5352 *
5353 * DESCRIPTION
5354 *       Gets the encoded client reregistration bit value in the PortInfo attribute.
5355 *
5356 * SYNOPSIS
5357 */
5358 static inline uint8_t OSM_API
5359 ib_port_info_get_client_rereg(IN ib_port_info_t const *p_pi)
5360 {
5361         return ((p_pi->subnet_timeout & 0x80) >> 7);
5362 }
5363
5364 /*
5365 * PARAMETERS
5366 *       p_pi
5367 *               [in] Pointer to a PortInfo attribute.
5368 *
5369 * RETURN VALUES
5370 *       Client reregistration value (either 1 or 0).
5371 *
5372 * NOTES
5373 *
5374 * SEE ALSO
5375 *********/
5376
5377 /****f* IBA Base: Types/ib_port_info_set_hoq_lifetime
5378 * NAME
5379 *       ib_port_info_set_hoq_lifetime
5380 *
5381 * DESCRIPTION
5382 *       Sets the Head of Queue Lifetime for which a packet can live in the head
5383 *  of VL queue
5384 *
5385 * SYNOPSIS
5386 */
5387 static inline void OSM_API
5388 ib_port_info_set_hoq_lifetime(IN ib_port_info_t * const p_pi,
5389                               IN const uint8_t hoq_life)
5390 {
5391         p_pi->vl_stall_life = (uint8_t) ((hoq_life & 0x1f) |
5392                                          (p_pi->vl_stall_life & 0xe0));
5393 }
5394
5395 /*
5396 * PARAMETERS
5397 *       p_pi
5398 *               [in] Pointer to a PortInfo attribute.
5399 *
5400 *       hoq_life
5401 *               [in] Encoded lifetime value to set
5402 *
5403 * RETURN VALUES
5404 *       None.
5405 *
5406 * NOTES
5407 *
5408 * SEE ALSO
5409 *********/
5410
5411 /****f* IBA Base: Types/ib_port_info_get_hoq_lifetime
5412 * NAME
5413 *       ib_port_info_get_hoq_lifetime
5414 *
5415 * DESCRIPTION
5416 *       Gets the Head of Queue Lifetime for which a packet can live in the head
5417 *  of VL queue
5418 *
5419 * SYNOPSIS
5420 */
5421 static inline uint8_t OSM_API
5422 ib_port_info_get_hoq_lifetime(IN const ib_port_info_t * const p_pi)
5423 {
5424         return ((uint8_t) (p_pi->vl_stall_life & 0x1f));
5425 }
5426
5427 /*
5428 * PARAMETERS
5429 *       p_pi
5430 *               [in] Pointer to a PortInfo attribute.
5431 *
5432 * RETURN VALUES
5433 *     Encoded lifetime value
5434 *
5435 * NOTES
5436 *
5437 * SEE ALSO
5438 *********/
5439
5440 /****f* IBA Base: Types/ib_port_info_set_vl_stall_count
5441 * NAME
5442 *       ib_port_info_set_vl_stall_count
5443 *
5444 * DESCRIPTION
5445 *       Sets the VL Stall Count which define the number of contiguous
5446 *  HLL (hoq) drops that will put the VL into stalled mode.
5447 *
5448 * SYNOPSIS
5449 */
5450 static inline void OSM_API
5451 ib_port_info_set_vl_stall_count(IN ib_port_info_t * const p_pi,
5452                                 IN const uint8_t vl_stall_count)
5453 {
5454         p_pi->vl_stall_life = (uint8_t) ((p_pi->vl_stall_life & 0x1f) |
5455                                          ((vl_stall_count << 5) & 0xe0));
5456 }
5457
5458 /*
5459 * PARAMETERS
5460 *       p_pi
5461 *               [in] Pointer to a PortInfo attribute.
5462 *
5463 *       vl_stall_count
5464 *               [in] value to set
5465 *
5466 * RETURN VALUES
5467 *       None.
5468 *
5469 * NOTES
5470 *
5471 * SEE ALSO
5472 *********/
5473
5474 /****f* IBA Base: Types/ib_port_info_get_vl_stall_count
5475 * NAME
5476 *       ib_port_info_get_vl_stall_count
5477 *
5478 * DESCRIPTION
5479 *       Gets the VL Stall Count which define the number of contiguous
5480 *  HLL (hoq) drops that will put the VL into stalled mode
5481 *
5482 * SYNOPSIS
5483 */
5484 static inline uint8_t OSM_API
5485 ib_port_info_get_vl_stall_count(IN const ib_port_info_t * const p_pi)
5486 {
5487         return ((uint8_t) (p_pi->vl_stall_life & 0xe0) >> 5);
5488 }
5489
5490 /*
5491 * PARAMETERS
5492 *       p_pi
5493 *               [in] Pointer to a PortInfo attribute.
5494 *
5495 * RETURN VALUES
5496 *     vl stall count
5497 *
5498 * NOTES
5499 *
5500 * SEE ALSO
5501 *********/
5502
5503 /****f* IBA Base: Types/ib_port_info_get_lmc
5504 * NAME
5505 *       ib_port_info_get_lmc
5506 *
5507 * DESCRIPTION
5508 *       Returns the LMC value assigned to this port.
5509 *
5510 * SYNOPSIS
5511 */
5512 static inline uint8_t OSM_API
5513 ib_port_info_get_lmc(IN const ib_port_info_t * const p_pi)
5514 {
5515         return ((uint8_t) (p_pi->mkey_lmc & IB_PORT_LMC_MASK));
5516 }
5517
5518 /*
5519 * PARAMETERS
5520 *       p_pi
5521 *               [in] Pointer to a PortInfo attribute.
5522 *
5523 * RETURN VALUES
5524 *       Returns the LMC value assigned to this port.
5525 *
5526 * NOTES
5527 *
5528 * SEE ALSO
5529 *********/
5530
5531 /****f* IBA Base: Types/ib_port_info_set_lmc
5532 * NAME
5533 *       ib_port_info_set_lmc
5534 *
5535 * DESCRIPTION
5536 *       Sets the LMC value in the PortInfo attribute.
5537 *
5538 * SYNOPSIS
5539 */
5540 static inline void OSM_API
5541 ib_port_info_set_lmc(IN ib_port_info_t * const p_pi, IN const uint8_t lmc)
5542 {
5543         CL_ASSERT(lmc <= IB_PORT_LMC_MAX);
5544         p_pi->mkey_lmc = (uint8_t) ((p_pi->mkey_lmc & 0xF8) | lmc);
5545 }
5546
5547 /*
5548 * PARAMETERS
5549 *       p_pi
5550 *               [in] Pointer to a PortInfo attribute.
5551 *
5552 *       lmc
5553 *               [in] LMC value to set, must be less than 7.
5554 *
5555 * RETURN VALUES
5556 *       None.
5557 *
5558 * NOTES
5559 *
5560 * SEE ALSO
5561 *********/
5562
5563 /****f* IBA Base: Types/ib_port_info_get_link_speed_enabled
5564 * NAME
5565 *       ib_port_info_get_link_speed_enabled
5566 *
5567 * DESCRIPTION
5568 *       Returns the link speed enabled value assigned to this port.
5569 *
5570 * SYNOPSIS
5571 */
5572 static inline uint8_t OSM_API
5573 ib_port_info_get_link_speed_enabled(IN const ib_port_info_t * const p_pi)
5574 {
5575         return ((uint8_t) (p_pi->link_speed & IB_PORT_LINK_SPEED_ENABLED_MASK));
5576 }
5577
5578 /*
5579 * PARAMETERS
5580 *       p_pi
5581 *               [in] Pointer to a PortInfo attribute.
5582 *
5583 * RETURN VALUES
5584 *       Port state.
5585 *
5586 * NOTES
5587 *
5588 * SEE ALSO
5589 *********/
5590
5591 /****f* IBA Base: Types/ib_port_info_set_link_speed_enabled
5592 * NAME
5593 *       ib_port_info_set_link_speed_enabled
5594 *
5595 * DESCRIPTION
5596 *       Sets the link speed enabled value in the PortInfo attribute.
5597 *
5598 * SYNOPSIS
5599 */
5600 static inline void OSM_API
5601 ib_port_info_set_link_speed_enabled(IN ib_port_info_t * const p_pi,
5602                                     IN const uint8_t link_speed_enabled)
5603 {
5604         p_pi->link_speed =
5605             (uint8_t) ((p_pi->link_speed & 0xF0) | link_speed_enabled);
5606 }
5607
5608 /*
5609 * PARAMETERS
5610 *       p_pi
5611 *               [in] Pointer to a PortInfo attribute.
5612 *
5613 *       link_speed_enabled
5614 *               [in] link speed enabled value to set.
5615 *
5616 * RETURN VALUES
5617 *       None.
5618 *
5619 * NOTES
5620 *
5621 * SEE ALSO
5622 *********/
5623
5624 /****f* IBA Base: Types/ib_port_info_get_mpb
5625 * NAME
5626 *       ib_port_info_get_mpb
5627 *
5628 * DESCRIPTION
5629 *       Returns the M_Key protect bits assigned to this port.
5630 *
5631 * SYNOPSIS
5632 */
5633 static inline uint8_t OSM_API
5634 ib_port_info_get_mpb(IN const ib_port_info_t * const p_pi)
5635 {
5636         return ((uint8_t) ((p_pi->mkey_lmc & IB_PORT_MPB_MASK) >>
5637                            IB_PORT_MPB_SHIFT));
5638 }
5639
5640 /*
5641 * PARAMETERS
5642 *       p_ni
5643 *               [in] Pointer to a PortInfo attribute.
5644 *
5645 * RETURN VALUES
5646 *       Returns the M_Key protect bits assigned to this port.
5647 *
5648 * NOTES
5649 *
5650 * SEE ALSO
5651 *********/
5652
5653 /****f* IBA Base: Types/ib_port_info_set_mpb
5654 * NAME
5655 *       ib_port_info_set_mpb
5656 *
5657 * DESCRIPTION
5658 *       Set the M_Key protect bits of this port.
5659 *
5660 * SYNOPSIS
5661 */
5662 static inline void OSM_API
5663 ib_port_info_set_mpb(IN ib_port_info_t * p_pi, IN uint8_t mpb)
5664 {
5665         p_pi->mkey_lmc =
5666             (~IB_PORT_MPB_MASK & p_pi->mkey_lmc) |
5667             (IB_PORT_MPB_MASK & (mpb << IB_PORT_MPB_SHIFT));
5668 }
5669
5670 /*
5671 * PARAMETERS
5672 *       mpb
5673 *               [in] M_Key protect bits
5674 *       p_ni
5675 *               [in] Pointer to a PortInfo attribute.
5676 *
5677 * RETURN VALUES
5678 *
5679 * NOTES
5680 *
5681 * SEE ALSO
5682 *********/
5683
5684 /****f* IBA Base: Types/ib_port_info_get_local_phy_err_thd
5685 * NAME
5686 *       ib_port_info_get_local_phy_err_thd
5687 *
5688 * DESCRIPTION
5689 *       Returns the Phy Link Threshold
5690 *
5691 * SYNOPSIS
5692 */
5693 static inline uint8_t OSM_API
5694 ib_port_info_get_local_phy_err_thd(IN const ib_port_info_t * const p_pi)
5695 {
5696         return (uint8_t) ((p_pi->error_threshold & 0xF0) >> 4);
5697 }
5698
5699 /*
5700 * PARAMETERS
5701 *       p_pi
5702 *               [in] Pointer to a PortInfo attribute.
5703 *
5704 * RETURN VALUES
5705 *       Returns the Phy Link error threshold assigned to this port.
5706 *
5707 * NOTES
5708 *
5709 * SEE ALSO
5710 *********/
5711
5712 /****f* IBA Base: Types/ib_port_info_get_overrun_err_thd
5713 * NAME
5714 *       ib_port_info_get_local_overrun_err_thd
5715 *
5716 * DESCRIPTION
5717 *       Returns the Credits Overrun Errors Threshold
5718 *
5719 * SYNOPSIS
5720 */
5721 static inline uint8_t OSM_API
5722 ib_port_info_get_overrun_err_thd(IN const ib_port_info_t * const p_pi)
5723 {
5724         return (uint8_t) (p_pi->error_threshold & 0x0F);
5725 }
5726
5727 /*
5728 * PARAMETERS
5729 *       p_pi
5730 *               [in] Pointer to a PortInfo attribute.
5731 *
5732 * RETURN VALUES
5733 *       Returns the Credits Overrun errors threshold assigned to this port.
5734 *
5735 * NOTES
5736 *
5737 * SEE ALSO
5738 *********/
5739
5740 /****f* IBA Base: Types/ib_port_info_set_phy_and_overrun_err_thd
5741 * NAME
5742 *       ib_port_info_set_phy_and_overrun_err_thd
5743 *
5744 * DESCRIPTION
5745 *       Sets the Phy Link and Credits Overrun Errors Threshold
5746 *
5747 * SYNOPSIS
5748 */
5749 static inline void OSM_API
5750 ib_port_info_set_phy_and_overrun_err_thd(IN ib_port_info_t * const p_pi,
5751                                          IN uint8_t phy_threshold,
5752                                          IN uint8_t overrun_threshold)
5753 {
5754         p_pi->error_threshold =
5755             (uint8_t) (((phy_threshold & 0x0F) << 4) |
5756                        (overrun_threshold & 0x0F));
5757 }
5758
5759 /*
5760 * PARAMETERS
5761 *       p_pi
5762 *               [in] Pointer to a PortInfo attribute.
5763 *
5764 *       phy_threshold
5765 *               [in] Physical Link Errors Threshold above which Trap 129 is generated
5766 *
5767 *  overrun_threshold
5768 *     [in] Credits overrun Errors Threshold above which Trap 129 is generated
5769 *
5770 * RETURN VALUES
5771 *       None.
5772 *
5773 * NOTES
5774 *
5775 * SEE ALSO
5776 *********/
5777
5778 typedef uint8_t ib_svc_name_t[64];
5779
5780 #include <complib/cl_packon.h>
5781 typedef struct _ib_service_record {
5782         ib_net64_t service_id;
5783         ib_gid_t service_gid;
5784         ib_net16_t service_pkey;
5785         ib_net16_t resv;
5786         ib_net32_t service_lease;
5787         uint8_t service_key[16];
5788         ib_svc_name_t service_name;
5789         uint8_t service_data8[16];
5790         ib_net16_t service_data16[8];
5791         ib_net32_t service_data32[4];
5792         ib_net64_t service_data64[2];
5793
5794 } PACK_SUFFIX ib_service_record_t;
5795 #include <complib/cl_packoff.h>
5796
5797 #include <complib/cl_packon.h>
5798 typedef struct _ib_portinfo_record {
5799         ib_net16_t lid;
5800         uint8_t port_num;
5801         uint8_t resv;
5802         ib_port_info_t port_info;
5803         uint8_t pad[6];
5804
5805 } PACK_SUFFIX ib_portinfo_record_t;
5806 #include <complib/cl_packoff.h>
5807
5808 #include <complib/cl_packon.h>
5809 typedef struct _ib_link_record {
5810         ib_net16_t from_lid;
5811         uint8_t from_port_num;
5812         uint8_t to_port_num;
5813         ib_net16_t to_lid;
5814         uint8_t pad[2];
5815
5816 } PACK_SUFFIX ib_link_record_t;
5817 #include <complib/cl_packoff.h>
5818
5819 #include <complib/cl_packon.h>
5820 typedef struct _ib_sminfo_record {
5821         ib_net16_t lid;
5822         uint16_t resv0;
5823         ib_sm_info_t sm_info;
5824         uint8_t pad[7];
5825
5826 } PACK_SUFFIX ib_sminfo_record_t;
5827 #include <complib/cl_packoff.h>
5828
5829 /****s* IBA Base: Types/ib_lft_record_t
5830 * NAME
5831 *       ib_lft_record_t
5832 *
5833 * DESCRIPTION
5834 *       IBA defined LinearForwardingTableRecord (15.2.5.6)
5835 *
5836 * SYNOPSIS
5837 */
5838 #include <complib/cl_packon.h>
5839 typedef struct _ib_lft_record {
5840         ib_net16_t lid;
5841         ib_net16_t block_num;
5842         uint32_t resv0;
5843         uint8_t lft[64];
5844 } PACK_SUFFIX ib_lft_record_t;
5845 #include <complib/cl_packoff.h>
5846 /************/
5847
5848 /****s* IBA Base: Types/ib_mft_record_t
5849 * NAME
5850 *       ib_mft_record_t
5851 *
5852 * DESCRIPTION
5853 *       IBA defined MulticastForwardingTableRecord (15.2.5.8)
5854 *
5855 * SYNOPSIS
5856 */
5857 #include <complib/cl_packon.h>
5858 typedef struct _ib_mft_record {
5859         ib_net16_t lid;
5860         ib_net16_t position_block_num;
5861         uint32_t resv0;
5862         ib_net16_t mft[IB_MCAST_BLOCK_SIZE];
5863 } PACK_SUFFIX ib_mft_record_t;
5864 #include <complib/cl_packoff.h>
5865 /************/
5866
5867 /****s* IBA Base: Types/ib_switch_info_t
5868 * NAME
5869 *       ib_switch_info_t
5870 *
5871 * DESCRIPTION
5872 *       IBA defined SwitchInfo. (14.2.5.4)
5873 *
5874 * SYNOPSIS
5875 */
5876 #include <complib/cl_packon.h>
5877 typedef struct _ib_switch_info {
5878         ib_net16_t lin_cap;
5879         ib_net16_t rand_cap;
5880         ib_net16_t mcast_cap;
5881         ib_net16_t lin_top;
5882         uint8_t def_port;
5883         uint8_t def_mcast_pri_port;
5884         uint8_t def_mcast_not_port;
5885         uint8_t life_state;
5886         ib_net16_t lids_per_port;
5887         ib_net16_t enforce_cap;
5888         uint8_t flags;
5889
5890 } PACK_SUFFIX ib_switch_info_t;
5891 #include <complib/cl_packoff.h>
5892 /************/
5893
5894 #include <complib/cl_packon.h>
5895 typedef struct _ib_switch_info_record {
5896         ib_net16_t lid;
5897         uint16_t resv0;
5898         ib_switch_info_t switch_info;
5899         uint8_t pad[3];
5900
5901 } PACK_SUFFIX ib_switch_info_record_t;
5902 #include <complib/cl_packoff.h>
5903
5904 #define IB_SWITCH_PSC 0x04
5905
5906 /****f* IBA Base: Types/ib_switch_info_get_state_change
5907 * NAME
5908 *       ib_switch_info_get_state_change
5909 *
5910 * DESCRIPTION
5911 *       Returns the value of the state change flag.
5912 *
5913 * SYNOPSIS
5914 */
5915 static inline boolean_t OSM_API
5916 ib_switch_info_get_state_change(IN const ib_switch_info_t * const p_si)
5917 {
5918         return ((p_si->life_state & IB_SWITCH_PSC) == IB_SWITCH_PSC);
5919 }
5920
5921 /*
5922 * PARAMETERS
5923 *       p_si
5924 *               [in] Pointer to a SwitchInfo attribute.
5925 *
5926 * RETURN VALUES
5927 *       Returns the value of the state change flag.
5928 *
5929 * NOTES
5930 *
5931 * SEE ALSO
5932 *********/
5933
5934 /****f* IBA Base: Types/ib_switch_info_clear_state_change
5935 * NAME
5936 *       ib_switch_info_clear_state_change
5937 *
5938 * DESCRIPTION
5939 *       Clears the switch's state change bit.
5940 *
5941 * SYNOPSIS
5942 */
5943 static inline void OSM_API
5944 ib_switch_info_clear_state_change(IN ib_switch_info_t * const p_si)
5945 {
5946         p_si->life_state = (uint8_t) (p_si->life_state & 0xFB);
5947 }
5948
5949 /*
5950 * PARAMETERS
5951 *       p_ni
5952 *               [in] Pointer to a PortInfo attribute.
5953 *
5954 * RETURN VALUES
5955 *       Returns the LMC value assigned to this port.
5956 *
5957 * NOTES
5958 *
5959 * SEE ALSO
5960 *********/
5961
5962 /****f* IBA Base: Types/ib_switch_info_is_enhanced_port0
5963 * NAME
5964 *       ib_switch_info_is_enhanced_port0
5965 *
5966 * DESCRIPTION
5967 *       Returns TRUE if the enhancedPort0 bit is on (meaning the switch
5968 *  port zero supports enhanced functions).
5969 *  Returns FALSE otherwise.
5970 *
5971 * SYNOPSIS
5972 */
5973 static inline boolean_t OSM_API
5974 ib_switch_info_is_enhanced_port0(IN const ib_switch_info_t * const p_si)
5975 {
5976         return ((p_si->flags & 0x08) == 0x08);
5977 }
5978
5979 /*
5980 * PARAMETERS
5981 *       p_si
5982 *               [in] Pointer to a SwitchInfo attribute.
5983 *
5984 * RETURN VALUES
5985 *       Returns TRUE if the switch supports enhanced port 0. FALSE otherwise.
5986 *
5987 * NOTES
5988 *
5989 * SEE ALSO
5990 *********/
5991
5992 /****s* IBA Base: Types/ib_guid_info_t
5993 * NAME
5994 *       ib_guid_info_t
5995 *
5996 * DESCRIPTION
5997 *       IBA defined GuidInfo. (14.2.5.5)
5998 *
5999 * SYNOPSIS
6000 */
6001 #define GUID_TABLE_MAX_ENTRIES          8
6002
6003 #include <complib/cl_packon.h>
6004 typedef struct _ib_guid_info {
6005         ib_net64_t guid[GUID_TABLE_MAX_ENTRIES];
6006
6007 } PACK_SUFFIX ib_guid_info_t;
6008 #include <complib/cl_packoff.h>
6009 /************/
6010
6011 #include <complib/cl_packon.h>
6012 typedef struct _ib_guidinfo_record {
6013         ib_net16_t lid;
6014         uint8_t block_num;
6015         uint8_t resv;
6016         uint32_t reserved;
6017         ib_guid_info_t guid_info;
6018 } PACK_SUFFIX ib_guidinfo_record_t;
6019 #include <complib/cl_packoff.h>
6020
6021 #define IB_MULTIPATH_MAX_GIDS 11        /* Support max that can fit into first MAD (for now) */
6022
6023 #include <complib/cl_packon.h>
6024 typedef struct _ib_multipath_rec_t {
6025         ib_net32_t hop_flow_raw;
6026         uint8_t tclass;
6027         uint8_t num_path;
6028         ib_net16_t pkey;
6029         ib_net16_t qos_class_sl;
6030         uint8_t mtu;
6031         uint8_t rate;
6032         uint8_t pkt_life;
6033         uint8_t service_id_8msb;
6034         uint8_t independence;   /* formerly resv2 */
6035         uint8_t sgid_count;
6036         uint8_t dgid_count;
6037         uint8_t service_id_56lsb[7];
6038         ib_gid_t gids[IB_MULTIPATH_MAX_GIDS];
6039 } PACK_SUFFIX ib_multipath_rec_t;
6040 #include <complib/cl_packoff.h>
6041 /*
6042 * FIELDS
6043 *       hop_flow_raw
6044 *               Global routing parameters: hop count, flow label and raw bit.
6045 *
6046 *       tclass
6047 *               Another global routing parameter.
6048 *
6049 *       num_path
6050 *     Reversible path - 1 bit to say if path is reversible.
6051 *               num_path [6:0] In queries, maximum number of paths to return.
6052 *               In responses, undefined.
6053 *
6054 *       pkey
6055 *               Partition key (P_Key) to use on this path.
6056 *
6057 *       qos_class_sl
6058 *               QoS class and service level to use on this path.
6059 *
6060 *       mtu
6061 *               MTU and MTU selector fields to use on this path
6062 *       rate
6063 *               Rate and rate selector fields to use on this path.
6064 *
6065 *       pkt_life
6066 *               Packet lifetime
6067 *
6068 *       service_id_8msb
6069 *               8 most significant bits of Service ID
6070 *
6071 *       service_id_56lsb
6072 *               56 least significant bits of Service ID
6073 *
6074 *       preference
6075 *               Indicates the relative merit of this path versus other path
6076 *               records returned from the SA.  Lower numbers are better.
6077 *
6078 * SEE ALSO
6079 *********/
6080
6081 /****f* IBA Base: Types/ib_multipath_rec_num_path
6082 * NAME
6083 *       ib_multipath_rec_num_path
6084 *
6085 * DESCRIPTION
6086 *       Get max number of paths to return.
6087 *
6088 * SYNOPSIS
6089 */
6090 static inline uint8_t OSM_API
6091 ib_multipath_rec_num_path(IN const ib_multipath_rec_t * const p_rec)
6092 {
6093         return (p_rec->num_path & 0x7F);
6094 }
6095
6096 /*
6097 * PARAMETERS
6098 *       p_rec
6099 *               [in] Pointer to the multipath record object.
6100 *
6101 * RETURN VALUES
6102 *       Maximum number of paths to return for each unique SGID_DGID combination.
6103 *
6104 * NOTES
6105 *
6106 * SEE ALSO
6107 *       ib_multipath_rec_t
6108 *********/
6109
6110 /****f* IBA Base: Types/ib_multipath_rec_set_sl
6111 * NAME
6112 *       ib_multipath_rec_set_sl
6113 *
6114 * DESCRIPTION
6115 *       Set path service level.
6116 *
6117 * SYNOPSIS
6118 */
6119 static inline void      OSM_API
6120 ib_multipath_rec_set_sl(
6121         IN ib_multipath_rec_t* const p_rec,
6122         IN const uint8_t sl )
6123 {
6124         p_rec->qos_class_sl =
6125                 (p_rec->qos_class_sl & CL_HTON16(IB_MULTIPATH_REC_QOS_CLASS_MASK)) |
6126                         cl_hton16(sl & IB_MULTIPATH_REC_SL_MASK);
6127 }
6128 /*
6129 * PARAMETERS
6130 *       p_rec
6131 *               [in] Pointer to the MultiPath record object.
6132 *
6133 *       sl
6134 *               [in] Service level to set.
6135 *
6136 * RETURN VALUES
6137 *       None
6138 *
6139 * NOTES
6140 *
6141 * SEE ALSO
6142 *       ib_multipath_rec_t
6143 *********/
6144
6145 /****f* IBA Base: Types/ib_multipath_rec_sl
6146 * NAME
6147 *       ib_multipath_rec_sl
6148 *
6149 * DESCRIPTION
6150 *       Get multipath service level.
6151 *
6152 * SYNOPSIS
6153 */
6154 static inline uint8_t OSM_API
6155 ib_multipath_rec_sl(IN const ib_multipath_rec_t * const p_rec)
6156 {
6157         return ((uint8_t) ((cl_ntoh16(p_rec->qos_class_sl)) & IB_MULTIPATH_REC_SL_MASK));
6158 }
6159
6160 /*
6161 * PARAMETERS
6162 *       p_rec
6163 *               [in] Pointer to the multipath record object.
6164 *
6165 * RETURN VALUES
6166 *       SL.
6167 *
6168 * NOTES
6169 *
6170 * SEE ALSO
6171 *       ib_multipath_rec_t
6172 *********/
6173
6174 /****f* IBA Base: Types/ib_multipath_rec_set_qos_class
6175 * NAME
6176 *       ib_multipath_rec_set_qos_class
6177 *
6178 * DESCRIPTION
6179 *       Set path QoS class.
6180 *
6181 * SYNOPSIS
6182 */
6183 static inline void      OSM_API
6184 ib_multipath_rec_set_qos_class(
6185         IN ib_multipath_rec_t* const p_rec,
6186         IN const uint16_t qos_class )
6187 {
6188         p_rec->qos_class_sl =
6189                 (p_rec->qos_class_sl & CL_HTON16(IB_MULTIPATH_REC_SL_MASK)) |
6190                         cl_hton16(qos_class << 4);
6191 }
6192 /*
6193 * PARAMETERS
6194 *       p_rec
6195 *               [in] Pointer to the MultiPath record object.
6196 *
6197 *       qos_class
6198 *               [in] QoS class to set.
6199 *
6200 * RETURN VALUES
6201 *       None
6202 *
6203 * NOTES
6204 *
6205 * SEE ALSO
6206 *       ib_multipath_rec_t
6207 *********/
6208
6209 /****f* IBA Base: Types/ib_multipath_rec_qos_class
6210 * NAME
6211 *       ib_multipath_rec_qos_class
6212 *
6213 * DESCRIPTION
6214 *       Get QoS class.
6215 *
6216 * SYNOPSIS
6217 */
6218 static inline uint16_t  OSM_API
6219 ib_multipath_rec_qos_class(
6220         IN      const   ib_multipath_rec_t* const       p_rec )
6221 {
6222         return (cl_ntoh16( p_rec->qos_class_sl ) >> 4);
6223 }
6224 /*
6225 * PARAMETERS
6226 *       p_rec
6227 *               [in] Pointer to the MultiPath record object.
6228 *
6229 * RETURN VALUES
6230 *       QoS class of the MultiPath record.
6231 *
6232 * NOTES
6233 *
6234 * SEE ALSO
6235 *       ib_multipath_rec_t
6236 *********/
6237
6238 /****f* IBA Base: Types/ib_multipath_rec_mtu
6239 * NAME
6240 *       ib_multipath_rec_mtu
6241 *
6242 * DESCRIPTION
6243 *       Get encoded path MTU.
6244 *
6245 * SYNOPSIS
6246 */
6247 static inline uint8_t OSM_API
6248 ib_multipath_rec_mtu(IN const ib_multipath_rec_t * const p_rec)
6249 {
6250         return ((uint8_t) (p_rec->mtu & IB_MULTIPATH_REC_BASE_MASK));
6251 }
6252
6253 /*
6254 * PARAMETERS
6255 *       p_rec
6256 *               [in] Pointer to the multipath record object.
6257 *
6258 * RETURN VALUES
6259 *       Encoded path MTU.
6260 *               1: 256
6261 *               2: 512
6262 *               3: 1024
6263 *               4: 2048
6264 *               5: 4096
6265 *               others: reserved
6266 *
6267 * NOTES
6268 *
6269 * SEE ALSO
6270 *       ib_multipath_rec_t
6271 *********/
6272
6273 /****f* IBA Base: Types/ib_multipath_rec_mtu_sel
6274 * NAME
6275 *       ib_multipath_rec_mtu_sel
6276 *
6277 * DESCRIPTION
6278 *       Get encoded multipath MTU selector.
6279 *
6280 * SYNOPSIS
6281 */
6282 static inline uint8_t OSM_API
6283 ib_multipath_rec_mtu_sel(IN const ib_multipath_rec_t * const p_rec)
6284 {
6285         return ((uint8_t) ((p_rec->mtu & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
6286 }
6287
6288 /*
6289 * PARAMETERS
6290 *       p_rec
6291 *               [in] Pointer to the multipath record object.
6292 *
6293 * RETURN VALUES
6294 *       Encoded path MTU selector value (for queries).
6295 *               0: greater than MTU specified
6296 *               1: less than MTU specified
6297 *               2: exactly the MTU specified
6298 *               3: largest MTU available
6299 *
6300 * NOTES
6301 *
6302 * SEE ALSO
6303 *       ib_multipath_rec_t
6304 *********/
6305
6306 /****f* IBA Base: Types/ib_multipath_rec_rate
6307 * NAME
6308 *       ib_multipath_rec_rate
6309 *
6310 * DESCRIPTION
6311 *       Get encoded multipath rate.
6312 *
6313 * SYNOPSIS
6314 */
6315 static inline uint8_t OSM_API
6316 ib_multipath_rec_rate(IN const ib_multipath_rec_t * const p_rec)
6317 {
6318         return ((uint8_t) (p_rec->rate & IB_MULTIPATH_REC_BASE_MASK));
6319 }
6320
6321 /*
6322 * PARAMETERS
6323 *       p_rec
6324 *               [in] Pointer to the multipath record object.
6325 *
6326 * RETURN VALUES
6327 *       Encoded multipath rate.
6328 *               2: 2.5 Gb/sec.
6329 *               3: 10 Gb/sec.
6330 *               4: 30 Gb/sec.
6331 *               others: reserved
6332 *
6333 * NOTES
6334 *
6335 * SEE ALSO
6336 *       ib_multipath_rec_t
6337 *********/
6338
6339 /****f* IBA Base: Types/ib_multipath_rec_rate_sel
6340 * NAME
6341 *       ib_multipath_rec_rate_sel
6342 *
6343 * DESCRIPTION
6344 *       Get encoded multipath rate selector.
6345 *
6346 * SYNOPSIS
6347 */
6348 static inline uint8_t OSM_API
6349 ib_multipath_rec_rate_sel(IN const ib_multipath_rec_t * const p_rec)
6350 {
6351         return ((uint8_t)
6352                 ((p_rec->rate & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
6353 }
6354
6355 /*
6356 * PARAMETERS
6357 *       p_rec
6358 *               [in] Pointer to the multipath record object.
6359 *
6360 * RETURN VALUES
6361 *       Encoded path rate selector value (for queries).
6362 *               0: greater than rate specified
6363 *               1: less than rate specified
6364 *               2: exactly the rate specified
6365 *               3: largest rate available
6366 *
6367 * NOTES
6368 *
6369 * SEE ALSO
6370 *       ib_multipath_rec_t
6371 *********/
6372
6373 /****f* IBA Base: Types/ib_multipath_rec_pkt_life
6374 * NAME
6375 *       ib_multipath_rec_pkt_life
6376 *
6377 * DESCRIPTION
6378 *       Get encoded multipath pkt_life.
6379 *
6380 * SYNOPSIS
6381 */
6382 static inline uint8_t OSM_API
6383 ib_multipath_rec_pkt_life(IN const ib_multipath_rec_t * const p_rec)
6384 {
6385         return ((uint8_t) (p_rec->pkt_life & IB_MULTIPATH_REC_BASE_MASK));
6386 }
6387
6388 /*
6389 * PARAMETERS
6390 *       p_rec
6391 *               [in] Pointer to the multipath record object.
6392 *
6393 * RETURN VALUES
6394 *       Encoded multipath pkt_life = 4.096 usec * 2 ** PacketLifeTime.
6395 *
6396 * NOTES
6397 *
6398 * SEE ALSO
6399 *       ib_multipath_rec_t
6400 *********/
6401
6402 /****f* IBA Base: Types/ib_multipath_rec_pkt_life_sel
6403 * NAME
6404 *       ib_multipath_rec_pkt_life_sel
6405 *
6406 * DESCRIPTION
6407 *       Get encoded multipath pkt_lifetime selector.
6408 *
6409 * SYNOPSIS
6410 */
6411 static inline uint8_t OSM_API
6412 ib_multipath_rec_pkt_life_sel(IN const ib_multipath_rec_t * const p_rec)
6413 {
6414         return ((uint8_t)
6415                 ((p_rec->pkt_life & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
6416 }
6417
6418 /*
6419 * PARAMETERS
6420 *       p_rec
6421 *               [in] Pointer to the multipath record object.
6422 *
6423 * RETURN VALUES
6424 *       Encoded path pkt_lifetime selector value (for queries).
6425 *               0: greater than rate specified
6426 *               1: less than rate specified
6427 *               2: exactly the rate specified
6428 *               3: smallest packet lifetime available
6429 *
6430 * NOTES
6431 *
6432 * SEE ALSO
6433 *       ib_multipath_rec_t
6434 *********/
6435
6436 /****f* IBA Base: Types/ib_multipath_rec_service_id
6437 * NAME
6438 *       ib_multipath_rec_service_id
6439 *
6440 * DESCRIPTION
6441 *       Get multipath service id.
6442 *
6443 * SYNOPSIS
6444 */
6445 static inline ib_net64_t OSM_API
6446 ib_multipath_rec_service_id(IN const ib_multipath_rec_t * const p_rec)
6447 {
6448         union {
6449                 ib_net64_t sid;
6450                 uint8_t sid_arr[8];
6451         } sid_union;
6452         sid_union.sid_arr[0] = p_rec->service_id_8msb;
6453         memcpy(&sid_union.sid_arr[1], p_rec->service_id_56lsb, 7);
6454         return sid_union.sid;
6455 }
6456
6457 /*
6458 * PARAMETERS
6459 *       p_rec
6460 *               [in] Pointer to the multipath record object.
6461 *
6462 * RETURN VALUES
6463 *       Service ID
6464 *
6465 * NOTES
6466 *
6467 * SEE ALSO
6468 *       ib_multipath_rec_t
6469 *********/
6470
6471 #define IB_NUM_PKEY_ELEMENTS_IN_BLOCK           32
6472 /****s* IBA Base: Types/ib_pkey_table_t
6473 * NAME
6474 *       ib_pkey_table_t
6475 *
6476 * DESCRIPTION
6477 *       IBA defined PKey table. (14.2.5.7)
6478 *
6479 * SYNOPSIS
6480 */
6481
6482 #include <complib/cl_packon.h>
6483 typedef struct _ib_pkey_table {
6484         ib_net16_t pkey_entry[IB_NUM_PKEY_ELEMENTS_IN_BLOCK];
6485
6486 } PACK_SUFFIX ib_pkey_table_t;
6487 #include <complib/cl_packoff.h>
6488 /************/
6489
6490 /****s* IBA Base: Types/ib_pkey_table_record_t
6491 * NAME
6492 *       ib_pkey_table_record_t
6493 *
6494 * DESCRIPTION
6495 *       IBA defined P_Key Table Record for SA Query. (15.2.5.11)
6496 *
6497 * SYNOPSIS
6498 */
6499 #include <complib/cl_packon.h>
6500 typedef struct _ib_pkey_table_record {
6501         ib_net16_t lid;         // for CA: lid of port, for switch lid of port 0
6502         uint16_t block_num;
6503         uint8_t port_num;       // for switch: port number, for CA: reserved
6504         uint8_t reserved1;
6505         uint16_t reserved2;
6506         ib_pkey_table_t pkey_tbl;
6507
6508 } PACK_SUFFIX ib_pkey_table_record_t;
6509 #include <complib/cl_packoff.h>
6510 /************/
6511
6512 #define IB_DROP_VL 15
6513 #define IB_MAX_NUM_VLS 16
6514 /****s* IBA Base: Types/ib_slvl_table_t
6515 * NAME
6516 *       ib_slvl_table_t
6517 *
6518 * DESCRIPTION
6519 *       IBA defined SL2VL Mapping Table Attribute. (14.2.5.8)
6520 *
6521 * SYNOPSIS
6522 */
6523 #include <complib/cl_packon.h>
6524 typedef struct _ib_slvl_table {
6525         uint8_t raw_vl_by_sl[IB_MAX_NUM_VLS / 2];
6526 } PACK_SUFFIX ib_slvl_table_t;
6527 #include <complib/cl_packoff.h>
6528 /************/
6529
6530 /****s* IBA Base: Types/ib_slvl_table_record_t
6531 * NAME
6532 *       ib_slvl_table_record_t
6533 *
6534 * DESCRIPTION
6535 *       IBA defined SL to VL Mapping Table Record for SA Query. (15.2.5.4)
6536 *
6537 * SYNOPSIS
6538 */
6539 #include <complib/cl_packon.h>
6540 typedef struct _ib_slvl_table_record {
6541         ib_net16_t lid;         // for CA: lid of port, for switch lid of port 0
6542         uint8_t in_port_num;    // reserved for CAs
6543         uint8_t out_port_num;   // reserved for CAs
6544         uint32_t resv;
6545         ib_slvl_table_t slvl_tbl;
6546
6547 } PACK_SUFFIX ib_slvl_table_record_t;
6548 #include <complib/cl_packoff.h>
6549 /************/
6550
6551 /****f* IBA Base: Types/ib_slvl_table_set
6552 * NAME
6553 *       ib_slvl_table_set
6554 *
6555 * DESCRIPTION
6556 *       Set slvl table entry.
6557 *
6558 * SYNOPSIS
6559 */
6560 static inline void OSM_API
6561 ib_slvl_table_set(IN ib_slvl_table_t * p_slvl_tbl,
6562                   IN uint8_t sl_index, IN uint8_t vl)
6563 {
6564         uint8_t idx = sl_index / 2;
6565         CL_ASSERT(vl <= 15);
6566         CL_ASSERT(sl_index <= 15);
6567
6568         if (sl_index % 2) {
6569                 /* this is an odd sl. Need to update the ls bits */
6570                 p_slvl_tbl->raw_vl_by_sl[idx] =
6571                     (p_slvl_tbl->raw_vl_by_sl[idx] & 0xF0) | vl;
6572         } else {
6573                 /* this is an even sl. Need to update the ms bits */
6574                 p_slvl_tbl->raw_vl_by_sl[idx] =
6575                     (vl << 4) | (p_slvl_tbl->raw_vl_by_sl[idx] & 0x0F);
6576         }
6577 }
6578
6579 /*
6580 * PARAMETERS
6581 *       p_slvl_tbl
6582 *               [in] pointer to ib_slvl_table_t object.
6583 *
6584 *       sl_index
6585 *               [in] the sl index in the table to be updated.
6586 *
6587 *       vl
6588 *               [in] the vl value to update for that sl.
6589 *
6590 * RETURN VALUES
6591 *       None
6592 *
6593 * NOTES
6594 *
6595 * SEE ALSO
6596 *       ib_slvl_table_t
6597 *********/
6598
6599 /****f* IBA Base: Types/ib_slvl_table_get
6600 * NAME
6601 *       ib_slvl_table_get
6602 *
6603 * DESCRIPTION
6604 *       Get slvl table entry.
6605 *
6606 * SYNOPSIS
6607 */
6608 static inline uint8_t OSM_API
6609 ib_slvl_table_get(IN const ib_slvl_table_t * p_slvl_tbl, IN uint8_t sl_index)
6610 {
6611         uint8_t idx = sl_index / 2;
6612         CL_ASSERT(sl_index <= 15);
6613
6614         if (sl_index % 2) {
6615                 /* this is an odd sl. Need to return the ls bits. */
6616                 return (p_slvl_tbl->raw_vl_by_sl[idx] & 0x0F);
6617         } else {
6618                 /* this is an even sl. Need to return the ms bits. */
6619                 return ((p_slvl_tbl->raw_vl_by_sl[idx] & 0xF0) >> 4);
6620         }
6621 }
6622
6623 /*
6624 * PARAMETERS
6625 *       p_slvl_tbl
6626 *               [in] pointer to ib_slvl_table_t object.
6627 *
6628 *       sl_index
6629 *               [in] the sl index in the table whose value should be returned.
6630 *
6631 * RETURN VALUES
6632 *       vl for the requested sl_index.
6633 *
6634 * NOTES
6635 *
6636 * SEE ALSO
6637 *       ib_slvl_table_t
6638 *********/
6639
6640 /****s* IBA Base: Types/ib_vl_arb_element_t
6641 * NAME
6642 *       ib_vl_arb_element_t
6643 *
6644 * DESCRIPTION
6645 *       IBA defined VL Arbitration Table Element. (14.2.5.9)
6646 *
6647 * SYNOPSIS
6648 */
6649 #include <complib/cl_packon.h>
6650 typedef struct _ib_vl_arb_element {
6651         uint8_t vl;
6652         uint8_t weight;
6653 } PACK_SUFFIX ib_vl_arb_element_t;
6654 #include <complib/cl_packoff.h>
6655 /************/
6656
6657 #define IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK 32
6658
6659 /****s* IBA Base: Types/ib_vl_arb_table_t
6660 * NAME
6661 *       ib_vl_arb_table_t
6662 *
6663 * DESCRIPTION
6664 *       IBA defined VL Arbitration Table. (14.2.5.9)
6665 *
6666 * SYNOPSIS
6667 */
6668 #include <complib/cl_packon.h>
6669 typedef struct _ib_vl_arb_table {
6670         ib_vl_arb_element_t vl_entry[IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK];
6671 } PACK_SUFFIX ib_vl_arb_table_t;
6672 #include <complib/cl_packoff.h>
6673 /************/
6674
6675 /****s* IBA Base: Types/ib_vl_arb_table_record_t
6676 * NAME
6677 *       ib_vl_arb_table_record_t
6678 *
6679 * DESCRIPTION
6680 *       IBA defined VL Arbitration Table Record for SA Query. (15.2.5.9)
6681 *
6682 * SYNOPSIS
6683 */
6684 #include <complib/cl_packon.h>
6685 typedef struct _ib_vl_arb_table_record {
6686         ib_net16_t lid;         // for CA: lid of port, for switch lid of port 0
6687         uint8_t port_num;
6688         uint8_t block_num;
6689         uint32_t reserved;
6690         ib_vl_arb_table_t vl_arb_tbl;
6691 } PACK_SUFFIX ib_vl_arb_table_record_t;
6692 #include <complib/cl_packoff.h>
6693 /************/
6694
6695 /*
6696  *      Global route header information received with unreliable datagram messages
6697  */
6698 #include <complib/cl_packon.h>
6699 typedef struct _ib_grh {
6700         ib_net32_t ver_class_flow;
6701         ib_net16_t resv1;
6702         uint8_t resv2;
6703         uint8_t hop_limit;
6704         ib_gid_t src_gid;
6705         ib_gid_t dest_gid;
6706 } PACK_SUFFIX ib_grh_t;
6707 #include <complib/cl_packoff.h>
6708
6709 /****f* IBA Base: Types/ib_grh_get_ver_class_flow
6710 * NAME
6711 *       ib_grh_get_ver_class_flow
6712 *
6713 * DESCRIPTION
6714 *       Get encoded version, traffic class and flow label in grh
6715 *
6716 * SYNOPSIS
6717 */
6718 static inline void OSM_API
6719 ib_grh_get_ver_class_flow(IN const ib_net32_t ver_class_flow,
6720                           OUT uint8_t * const p_ver,
6721                           OUT uint8_t * const p_tclass,
6722                           OUT uint32_t * const p_flow_lbl)
6723 {
6724         ib_net32_t tmp_ver_class_flow;
6725
6726         if (p_ver)
6727                 *p_ver = (uint8_t) (ver_class_flow & 0x0f);
6728
6729         tmp_ver_class_flow = ver_class_flow >> 4;
6730
6731         if (p_tclass)
6732                 *p_tclass = (uint8_t) (tmp_ver_class_flow & 0xff);
6733
6734         tmp_ver_class_flow = tmp_ver_class_flow >> 8;
6735
6736         if (p_flow_lbl)
6737                 *p_flow_lbl = tmp_ver_class_flow & 0xfffff;
6738 }
6739
6740 /*
6741 * PARAMETERS
6742 *       ver_class_flow
6743 *               [in] the version, traffic class and flow label info.
6744 *
6745 * RETURN VALUES
6746 *       p_ver
6747 *               [out] pointer to the version info.
6748 *
6749 *       p_tclass
6750 *               [out] pointer to the traffic class info.
6751 *
6752 *       p_flow_lbl
6753 *               [out] pointer to the flow label info
6754 *
6755 * NOTES
6756 *
6757 * SEE ALSO
6758 *       ib_grh_t
6759 *********/
6760
6761 /****f* IBA Base: Types/ib_grh_set_ver_class_flow
6762 * NAME
6763 *       ib_grh_set_ver_class_flow
6764 *
6765 * DESCRIPTION
6766 *       Set encoded version, traffic class and flow label in grh
6767 *
6768 * SYNOPSIS
6769 */
6770 static inline ib_net32_t OSM_API
6771 ib_grh_set_ver_class_flow(IN const uint8_t ver,
6772                           IN const uint8_t tclass, IN const uint32_t flow_lbl)
6773 {
6774         ib_net32_t ver_class_flow;
6775
6776         ver_class_flow = flow_lbl;
6777         ver_class_flow = ver_class_flow << 8;
6778         ver_class_flow = ver_class_flow | tclass;
6779         ver_class_flow = ver_class_flow << 4;
6780         ver_class_flow = ver_class_flow | ver;
6781         return (ver_class_flow);
6782 }
6783
6784 /*
6785 * PARAMETERS
6786 *       ver
6787 *               [in] the version info.
6788 *
6789 *       tclass
6790 *               [in] the traffic class info.
6791 *
6792 *       flow_lbl
6793 *               [in] the flow label info
6794 *
6795 * RETURN VALUES
6796 *       ver_class_flow
6797 *               [out] the version, traffic class and flow label info.
6798 *
6799 * NOTES
6800 *
6801 * SEE ALSO
6802 *       ib_grh_t
6803 *********/
6804
6805 /****s* IBA Base: Types/ib_member_rec_t
6806 * NAME
6807 *       ib_member_rec_t
6808 *
6809 * DESCRIPTION
6810 *       Multicast member record, used to create, join, and leave multicast
6811 *       groups.
6812 *
6813 * SYNOPSIS
6814 */
6815 #include <complib/cl_packon.h>
6816 typedef struct _ib_member_rec {
6817         ib_gid_t mgid;
6818         ib_gid_t port_gid;
6819         ib_net32_t qkey;
6820         ib_net16_t mlid;
6821         uint8_t mtu;
6822         uint8_t tclass;
6823         ib_net16_t pkey;
6824         uint8_t rate;
6825         uint8_t pkt_life;
6826         ib_net32_t sl_flow_hop;
6827         uint8_t scope_state;
6828         uint8_t proxy_join:1;
6829         uint8_t reserved[2];
6830         uint8_t pad[4];
6831
6832 } PACK_SUFFIX ib_member_rec_t;
6833 #include <complib/cl_packoff.h>
6834 /*
6835 * FIELDS
6836 *       mgid
6837 *               Multicast GID address for this multicast group.
6838 *
6839 *       port_gid
6840 *               Valid GID of the endpoint joining this multicast group.
6841 *
6842 *       qkey
6843 *               Q_Key to be sued by this multicast group.
6844 *
6845 *       mlid
6846 *               Multicast LID for this multicast group.
6847 *
6848 *       mtu
6849 *               MTU and MTU selector fields to use on this path
6850 *
6851 *       tclass
6852 *               Another global routing parameter.
6853 *
6854 *       pkey
6855 *               Partition key (P_Key) to use for this member.
6856 *
6857 *       rate
6858 *               Rate and rate selector fields to use on this path.
6859 *
6860 *       pkt_life
6861 *               Packet lifetime
6862 *
6863 *       sl_flow_hop
6864 *               Global routing parameters: service level, hop count, and flow label.
6865 *
6866 *       scope_state
6867 *               MGID scope and JoinState of multicast request.
6868 *
6869 *       proxy_join
6870 *               Enables others in the Partition to proxy add/remove from the group
6871 *
6872 * SEE ALSO
6873 *********/
6874
6875 /****f* IBA Base: Types/ib_member_get_sl_flow_hop
6876 * NAME
6877 *       ib_member_get_sl_flow_hop
6878 *
6879 * DESCRIPTION
6880 *       Get encoded sl, flow label, and hop limit
6881 *
6882 * SYNOPSIS
6883 */
6884 static inline void OSM_API
6885 ib_member_get_sl_flow_hop(IN const ib_net32_t sl_flow_hop,
6886                           OUT uint8_t * const p_sl,
6887                           OUT uint32_t * const p_flow_lbl,
6888                           OUT uint8_t * const p_hop)
6889 {
6890         uint32_t tmp;
6891
6892         tmp = cl_ntoh32(sl_flow_hop);
6893         if (p_hop)
6894                 *p_hop = (uint8_t) tmp;
6895         tmp >>= 8;
6896
6897         if (p_flow_lbl)
6898                 *p_flow_lbl = (uint32_t) (tmp & 0xfffff);
6899         tmp >>= 20;
6900
6901         if (p_sl)
6902                 *p_sl = (uint8_t) tmp;
6903 }
6904
6905 /*
6906 * PARAMETERS
6907 *       sl_flow_hop
6908 *               [in] the sl, flow label, and hop limit of MC Group
6909 *
6910 * RETURN VALUES
6911 *       p_sl
6912 *               [out] pointer to the service level
6913 *
6914 *       p_flow_lbl
6915 *               [out] pointer to the flow label info
6916 *
6917 *       p_hop
6918 *               [out] pointer to the hop count limit.
6919 *
6920 * NOTES
6921 *
6922 * SEE ALSO
6923 *       ib_member_rec_t
6924 *********/
6925
6926 /****f* IBA Base: Types/ib_member_set_sl_flow_hop
6927 * NAME
6928 *       ib_member_set_sl_flow_hop
6929 *
6930 * DESCRIPTION
6931 *       Set encoded sl, flow label, and hop limit
6932 *
6933 * SYNOPSIS
6934 */
6935 static inline ib_net32_t OSM_API
6936 ib_member_set_sl_flow_hop(IN const uint8_t sl,
6937                           IN const uint32_t flow_label,
6938                           IN const uint8_t hop_limit)
6939 {
6940         uint32_t tmp;
6941
6942         tmp = (sl << 28) | ((flow_label & 0xfffff) << 8) | hop_limit;
6943         return cl_hton32(tmp);
6944 }
6945
6946 /*
6947 * PARAMETERS
6948 *       sl
6949 *               [in] the service level.
6950 *
6951 *       flow_lbl
6952 *               [in] the flow label info
6953 *
6954 *       hop_limit
6955 *               [in] the hop limit.
6956 *
6957 * RETURN VALUES
6958 *       sl_flow_hop
6959 *               [out] the encoded sl, flow label, and hop limit
6960 *
6961 * NOTES
6962 *
6963 * SEE ALSO
6964 *       ib_member_rec_t
6965 *********/
6966
6967 /****f* IBA Base: Types/ib_member_get_scope_state
6968 * NAME
6969 *       ib_member_get_scope_state
6970 *
6971 * DESCRIPTION
6972 *       Get encoded MGID scope and JoinState
6973 *
6974 * SYNOPSIS
6975 */
6976 static inline void OSM_API
6977 ib_member_get_scope_state(IN const uint8_t scope_state,
6978                           OUT uint8_t * const p_scope,
6979                           OUT uint8_t * const p_state)
6980 {
6981         uint8_t tmp_scope_state;
6982
6983         if (p_state)
6984                 *p_state = (uint8_t) (scope_state & 0x0f);
6985
6986         tmp_scope_state = scope_state >> 4;
6987
6988         if (p_scope)
6989                 *p_scope = (uint8_t) (tmp_scope_state & 0x0f);
6990
6991 }
6992
6993 /*
6994 * PARAMETERS
6995 *       scope_state
6996 *               [in] the scope and state
6997 *
6998 * RETURN VALUES
6999 *       p_scope
7000 *               [out] pointer to the MGID scope
7001 *
7002 *       p_state
7003 *               [out] pointer to the join state
7004 *
7005 * NOTES
7006 *
7007 * SEE ALSO
7008 *       ib_member_rec_t
7009 *********/
7010
7011 /****f* IBA Base: Types/ib_member_set_scope_state
7012 * NAME
7013 *       ib_member_set_scope_state
7014 *
7015 * DESCRIPTION
7016 *       Set encoded version, MGID scope and JoinState
7017 *
7018 * SYNOPSIS
7019 */
7020 static inline uint8_t OSM_API
7021 ib_member_set_scope_state(IN const uint8_t scope, IN const uint8_t state)
7022 {
7023         uint8_t scope_state;
7024
7025         scope_state = scope;
7026         scope_state = scope_state << 4;
7027         scope_state = scope_state | state;
7028         return (scope_state);
7029 }
7030
7031 /*
7032 * PARAMETERS
7033 *       scope
7034 *               [in] the MGID scope
7035 *
7036 *       state
7037 *               [in] the JoinState
7038 *
7039 * RETURN VALUES
7040 *       scope_state
7041 *               [out] the encoded one
7042 *
7043 * NOTES
7044 *
7045 * SEE ALSO
7046 *       ib_member_rec_t
7047 *********/
7048
7049 /****f* IBA Base: Types/ib_member_set_join_state
7050 * NAME
7051 *       ib_member_set_join_state
7052 *
7053 * DESCRIPTION
7054 *       Set JoinState
7055 *
7056 * SYNOPSIS
7057 */
7058 static inline void OSM_API
7059 ib_member_set_join_state(IN OUT ib_member_rec_t * p_mc_rec,
7060                          IN const uint8_t state)
7061 {
7062         /* keep the scope as it is */
7063         p_mc_rec->scope_state = (p_mc_rec->scope_state & 0xF0) | (0x0f & state);
7064 }
7065
7066 /*
7067 * PARAMETERS
7068 *       p_mc_rec
7069 *               [in] pointer to the member record
7070 *
7071 *       state
7072 *               [in] the JoinState
7073 *
7074 * RETURN VALUES
7075 *       NONE
7076 *
7077 * NOTES
7078 *
7079 * SEE ALSO
7080 *       ib_member_rec_t
7081 *********/
7082
7083 /*
7084  * Join State Codes:
7085  */
7086 #define IB_MC_REC_STATE_FULL_MEMBER 0x01
7087 #define IB_MC_REC_STATE_NON_MEMBER 0x02
7088 #define IB_MC_REC_STATE_SEND_ONLY_NON_MEMBER 0x04
7089
7090 /*
7091  *      Generic MAD notice types
7092  */
7093 #define IB_NOTICE_TYPE_FATAL                            0x00
7094 #define IB_NOTICE_TYPE_URGENT                           0x01
7095 #define IB_NOTICE_TYPE_SECURITY                         0x02
7096 #define IB_NOTICE_TYPE_SUBN_MGMT                        0x03
7097 #define IB_NOTICE_TYPE_INFO                             0x04
7098 #define IB_NOTICE_TYPE_EMPTY                            0x7F
7099
7100 #include <complib/cl_packon.h>
7101 typedef struct _ib_mad_notice_attr      // Total Size calc  Accumulated
7102 {
7103         uint8_t generic_type;   // 1                1
7104
7105         union _notice_g_or_v {
7106                 struct _notice_generic  // 5                6
7107                 {
7108                         uint8_t prod_type_msb;
7109                         ib_net16_t prod_type_lsb;
7110                         ib_net16_t trap_num;
7111                 } PACK_SUFFIX generic;
7112
7113                 struct _notice_vend {
7114                         uint8_t vend_id_msb;
7115                         ib_net16_t vend_id_lsb;
7116                         ib_net16_t dev_id;
7117                 } PACK_SUFFIX vend;
7118         } g_or_v;
7119
7120         ib_net16_t issuer_lid;  // 2                 8
7121         ib_net16_t toggle_count;        // 2                 10
7122
7123         union _data_details     // 54                64
7124         {
7125                 struct _raw_data {
7126                         uint8_t details[54];
7127                 } PACK_SUFFIX raw_data;
7128
7129                 struct _ntc_64_67 {
7130                         uint8_t res[6];
7131                         ib_gid_t gid;   // the Node or Multicast Group that came in/out
7132                 } PACK_SUFFIX ntc_64_67;
7133
7134                 struct _ntc_128 {
7135                         ib_net16_t sw_lid;      // the sw lid of which link state changed
7136                 } PACK_SUFFIX ntc_128;
7137
7138                 struct _ntc_129_131 {
7139                         ib_net16_t pad;
7140                         ib_net16_t lid; // lid and port number of the violation
7141                         uint8_t port_num;
7142                 } PACK_SUFFIX ntc_129_131;
7143
7144                 struct _ntc_144 {
7145                         ib_net16_t pad1;
7146                         ib_net16_t lid;             // lid where change occured
7147                         uint8_t    pad2;            // reserved
7148                         uint8_t    local_changes;   // 7b reserved 1b local changes
7149                         ib_net32_t new_cap_mask;    // new capability mask
7150                         ib_net16_t change_flgs;     // 13b reserved 3b change flags
7151                 } PACK_SUFFIX ntc_144;
7152
7153                 struct _ntc_145 {
7154                         ib_net16_t pad1;
7155                         ib_net16_t lid; // lid where sys guid changed
7156                         ib_net16_t pad2;
7157                         ib_net64_t new_sys_guid;        // new system image guid
7158                 } PACK_SUFFIX ntc_145;
7159
7160                 struct _ntc_256 {       // total: 54
7161                         ib_net16_t pad1;        // 2
7162                         ib_net16_t lid; // 2
7163                         ib_net16_t dr_slid;     // 2
7164                         uint8_t method; // 1
7165                         uint8_t pad2;   // 1
7166                         ib_net16_t attr_id;     // 2
7167                         ib_net32_t attr_mod;    // 4
7168                         ib_net64_t mkey;        // 8
7169                         uint8_t pad3;   // 1
7170                         uint8_t dr_trunc_hop;   // 1
7171                         uint8_t dr_rtn_path[30];        // 30
7172                 } PACK_SUFFIX ntc_256;
7173
7174                 struct _ntc_257_258     // violation of p/q_key // 49
7175                 {
7176                         ib_net16_t pad1;        // 2
7177                         ib_net16_t lid1;        // 2
7178                         ib_net16_t lid2;        // 2
7179                         ib_net32_t key; // 2
7180                         uint8_t sl;     // 1
7181                         ib_net32_t qp1; // 4
7182                         ib_net32_t qp2; // 4
7183                         ib_gid_t gid1;  // 16
7184                         ib_gid_t gid2;  // 16
7185                 } PACK_SUFFIX ntc_257_258;
7186
7187                 struct _ntc_259 // pkey violation from switch 51
7188                 {
7189                         ib_net16_t data_valid;  // 2
7190                         ib_net16_t lid1;        // 2
7191                         ib_net16_t lid2;        // 2
7192                         ib_net16_t pkey;        // 2
7193                         ib_net32_t sl_qp1; // 4b sl, 4b pad, 24b qp1
7194                         ib_net32_t qp2; // 8b pad, 24b qp2
7195                         ib_gid_t gid1;  // 16
7196                         ib_gid_t gid2;  // 16
7197                         ib_net16_t sw_lid;      // 2
7198                         uint8_t port_no;        // 1
7199                 } PACK_SUFFIX ntc_259;
7200
7201         } data_details;
7202
7203         ib_gid_t issuer_gid;    // 16          80
7204
7205 } PACK_SUFFIX ib_mad_notice_attr_t;
7206 #include <complib/cl_packoff.h>
7207
7208 /**
7209  * Trap 259 masks
7210  */
7211 #define TRAP_259_MASK_SL (CL_HTON32(0xF0000000))
7212 #define TRAP_259_MASK_QP (CL_HTON32(0x00FFFFFF))
7213
7214 /**
7215  * Trap 144 masks
7216  */
7217 #define TRAP_144_MASK_OTHER_LOCAL_CHANGES      0x01
7218 #define TRAP_144_MASK_SM_PRIORITY_CHANGE       (CL_HTON16(0x0008))
7219 #define TRAP_144_MASK_LINK_SPEED_ENABLE_CHANGE (CL_HTON16(0x0004))
7220 #define TRAP_144_MASK_LINK_WIDTH_ENABLE_CHANGE (CL_HTON16(0x0002))
7221 #define TRAP_144_MASK_NODE_DESCRIPTION_CHANGE  (CL_HTON16(0x0001))
7222
7223 /****f* IBA Base: Types/ib_notice_is_generic
7224 * NAME
7225 *       ib_notice_is_generic
7226 *
7227 * DESCRIPTION
7228 *       Check if the notice is generic
7229 *
7230 * SYNOPSIS
7231 */
7232 static inline boolean_t OSM_API
7233 ib_notice_is_generic(IN const ib_mad_notice_attr_t * p_ntc)
7234 {
7235         return (p_ntc->generic_type & 0x80);
7236 }
7237
7238 /*
7239 * PARAMETERS
7240 *       p_ntc
7241 *               [in] Pointer to  the notice MAD attribute
7242 *
7243 * RETURN VALUES
7244 *       TRUE if mad is generic
7245 *
7246 * SEE ALSO
7247 *       ib_mad_notice_attr_t
7248 *********/
7249
7250 /****f* IBA Base: Types/ib_notice_get_type
7251 * NAME
7252 *       ib_notice_get_type
7253 *
7254 * DESCRIPTION
7255 *       Get the notice type
7256 *
7257 * SYNOPSIS
7258 */
7259 static inline uint8_t OSM_API
7260 ib_notice_get_type(IN const ib_mad_notice_attr_t * p_ntc)
7261 {
7262         return p_ntc->generic_type & 0x7f;
7263 }
7264
7265 /*
7266 * PARAMETERS
7267 *       p_ntc
7268 *               [in] Pointer to  the notice MAD attribute
7269 *
7270 * RETURN VALUES
7271 *       TRUE if mad is generic
7272 *
7273 * SEE ALSO
7274 *       ib_mad_notice_attr_t
7275 *********/
7276
7277 /****f* IBA Base: Types/ib_notice_get_prod_type
7278 * NAME
7279 *       ib_notice_get_prod_type
7280 *
7281 * DESCRIPTION
7282 *       Get the notice Producer Type of Generic Notice
7283 *
7284 * SYNOPSIS
7285 */
7286 static inline ib_net32_t OSM_API
7287 ib_notice_get_prod_type(IN const ib_mad_notice_attr_t * p_ntc)
7288 {
7289         uint32_t pt;
7290
7291         pt = cl_ntoh16(p_ntc->g_or_v.generic.prod_type_lsb) |
7292             (p_ntc->g_or_v.generic.prod_type_msb << 16);
7293         return cl_hton32(pt);
7294 }
7295
7296 /*
7297 * PARAMETERS
7298 *       p_ntc
7299 *               [in] Pointer to the notice MAD attribute
7300 *
7301 * RETURN VALUES
7302 *       The producer type
7303 *
7304 * SEE ALSO
7305 *       ib_mad_notice_attr_t
7306 *********/
7307
7308 /****f* IBA Base: Types/ib_notice_set_prod_type
7309 * NAME
7310 *       ib_notice_set_prod_type
7311 *
7312 * DESCRIPTION
7313 *       Set the notice Producer Type of Generic Notice
7314 *
7315 * SYNOPSIS
7316 */
7317 static inline void OSM_API
7318 ib_notice_set_prod_type(IN ib_mad_notice_attr_t * p_ntc,
7319                         IN ib_net32_t prod_type_val)
7320 {
7321         uint32_t ptv = cl_ntoh32(prod_type_val);
7322         p_ntc->g_or_v.generic.prod_type_lsb =
7323             cl_hton16((uint16_t) (ptv & 0x0000ffff));
7324         p_ntc->g_or_v.generic.prod_type_msb =
7325             (uint8_t) ((ptv & 0x00ff0000) >> 16);
7326 }
7327
7328 /*
7329 * PARAMETERS
7330 *       p_ntc
7331 *               [in] Pointer to the notice MAD attribute
7332 *
7333 *  prod_type
7334 *     [in] The producer Type code
7335 *
7336 * RETURN VALUES
7337 *       None
7338 *
7339 * SEE ALSO
7340 *       ib_mad_notice_attr_t
7341 *********/
7342
7343 /****f* IBA Base: Types/ib_notice_set_prod_type_ho
7344 * NAME
7345 *       ib_notice_set_prod_type_ho
7346 *
7347 * DESCRIPTION
7348 *       Set the notice Producer Type of Generic Notice given Host Order
7349 *
7350 * SYNOPSIS
7351 */
7352 static inline void OSM_API
7353 ib_notice_set_prod_type_ho(IN ib_mad_notice_attr_t * p_ntc,
7354                            IN uint32_t prod_type_val_ho)
7355 {
7356         p_ntc->g_or_v.generic.prod_type_lsb =
7357             cl_hton16((uint16_t) (prod_type_val_ho & 0x0000ffff));
7358         p_ntc->g_or_v.generic.prod_type_msb =
7359             (uint8_t) ((prod_type_val_ho & 0x00ff0000) >> 16);
7360 }
7361
7362 /*
7363 * PARAMETERS
7364 *       p_ntc
7365 *               [in] Pointer to the notice MAD attribute
7366 *
7367 *       prod_type
7368 *               [in] The producer Type code in host order
7369 *
7370 * RETURN VALUES
7371 *       None
7372 *
7373 * SEE ALSO
7374 *       ib_mad_notice_attr_t
7375 *********/
7376
7377 /****f* IBA Base: Types/ib_notice_get_vend_id
7378 * NAME
7379 *       ib_notice_get_vend_id
7380 *
7381 * DESCRIPTION
7382 *       Get the Vendor Id of Vendor type Notice
7383 *
7384 * SYNOPSIS
7385 */
7386 static inline ib_net32_t OSM_API
7387 ib_notice_get_vend_id(IN const ib_mad_notice_attr_t * p_ntc)
7388 {
7389         uint32_t vi;
7390
7391         vi = cl_ntoh16(p_ntc->g_or_v.vend.vend_id_lsb) |
7392             (p_ntc->g_or_v.vend.vend_id_msb << 16);
7393         return cl_hton32(vi);
7394 }
7395
7396 /*
7397 * PARAMETERS
7398 *       p_ntc
7399 *               [in] Pointer to the notice MAD attribute
7400 *
7401 * RETURN VALUES
7402 *       The Vendor Id of Vendor type Notice
7403 *
7404 * SEE ALSO
7405 *       ib_mad_notice_attr_t
7406 *********/
7407
7408 /****f* IBA Base: Types/ib_notice_set_vend_id
7409 * NAME
7410 *       ib_notice_set_vend_id
7411 *
7412 * DESCRIPTION
7413 *       Set the notice Producer Type of Generic Notice
7414 *
7415 * SYNOPSIS
7416 */
7417 static inline void OSM_API
7418 ib_notice_set_vend_id(IN ib_mad_notice_attr_t * p_ntc, IN ib_net32_t vend_id)
7419 {
7420         uint32_t vi = cl_ntoh32(vend_id);
7421         p_ntc->g_or_v.vend.vend_id_lsb =
7422             cl_hton16((uint16_t) (vi & 0x0000ffff));
7423         p_ntc->g_or_v.vend.vend_id_msb = (uint8_t) ((vi & 0x00ff0000) >> 16);
7424 }
7425
7426 /*
7427 * PARAMETERS
7428 *       p_ntc
7429 *               [in] Pointer to the notice MAD attribute
7430 *
7431 *       vend_id
7432 *               [in] The producer Type code
7433 *
7434 * RETURN VALUES
7435 *       None
7436 *
7437 * SEE ALSO
7438 *       ib_mad_notice_attr_t
7439 *********/
7440
7441 /****f* IBA Base: Types/ib_notice_set_vend_id_ho
7442 * NAME
7443 *       ib_notice_set_vend_id_ho
7444 *
7445 * DESCRIPTION
7446 *       Set the notice Producer Type of Generic Notice given a host order value
7447 *
7448 * SYNOPSIS
7449 */
7450 static inline void OSM_API
7451 ib_notice_set_vend_id_ho(IN ib_mad_notice_attr_t * p_ntc,
7452                          IN uint32_t vend_id_ho)
7453 {
7454         p_ntc->g_or_v.vend.vend_id_lsb =
7455             cl_hton16((uint16_t) (vend_id_ho & 0x0000ffff));
7456         p_ntc->g_or_v.vend.vend_id_msb =
7457             (uint8_t) ((vend_id_ho & 0x00ff0000) >> 16);
7458 }
7459
7460 /*
7461 * PARAMETERS
7462 *       p_ntc
7463 *               [in] Pointer to the notice MAD attribute
7464 *
7465 *       vend_id_ho
7466 *               [in] The producer Type code in host order
7467 *
7468 * RETURN VALUES
7469 *       None
7470 *
7471 * SEE ALSO
7472 *       ib_mad_notice_attr_t
7473 *********/
7474
7475 #include <complib/cl_packon.h>
7476 typedef struct _ib_inform_info {
7477         ib_gid_t gid;
7478         ib_net16_t lid_range_begin;
7479         ib_net16_t lid_range_end;
7480         ib_net16_t reserved1;
7481         uint8_t is_generic;
7482         uint8_t subscribe;
7483         ib_net16_t trap_type;
7484         union _inform_g_or_v {
7485                 struct _inform_generic {
7486                         ib_net16_t trap_num;
7487                         ib_net32_t qpn_resp_time_val;
7488                         uint8_t reserved2;
7489                         uint8_t node_type_msb;
7490                         ib_net16_t node_type_lsb;
7491                 } PACK_SUFFIX generic;
7492
7493                 struct _inform_vend {
7494                         ib_net16_t dev_id;
7495                         ib_net32_t qpn_resp_time_val;
7496                         uint8_t reserved2;
7497                         uint8_t vendor_id_msb;
7498                         ib_net16_t vendor_id_lsb;
7499                 } PACK_SUFFIX vend;
7500
7501         } PACK_SUFFIX g_or_v;
7502
7503 } PACK_SUFFIX ib_inform_info_t;
7504 #include <complib/cl_packoff.h>
7505
7506 /****f* IBA Base: Types/ib_inform_info_get_qpn_resp_time
7507 * NAME
7508 *       ib_inform_info_get_qpn_resp_time
7509 *
7510 * DESCRIPTION
7511 *       Get QPN of the inform info
7512 *
7513 * SYNOPSIS
7514 */
7515 static inline void OSM_API
7516 ib_inform_info_get_qpn_resp_time(IN const ib_net32_t qpn_resp_time_val,
7517                                  OUT ib_net32_t * const p_qpn,
7518                                  OUT uint8_t * const p_resp_time_val)
7519 {
7520         uint32_t tmp = cl_ntoh32(qpn_resp_time_val);
7521
7522         if (p_qpn)
7523                 *p_qpn = cl_hton32((tmp & 0xffffff00) >> 8);
7524
7525         if (p_resp_time_val)
7526                 *p_resp_time_val = (uint8_t) (tmp & 0x0000001f);
7527 }
7528
7529 /*
7530 * PARAMETERS
7531 *       qpn_resp_time_val
7532 *               [in] the  qpn and resp time val from the mad
7533 *
7534 * RETURN VALUES
7535 *       p_qpn
7536 *               [out] pointer to the qpn
7537 *
7538 *       p_state
7539 *               [out] pointer to the resp time val
7540 *
7541 * NOTES
7542 *
7543 * SEE ALSO
7544 *       ib_inform_info_t
7545 *********/
7546
7547 /****f* IBA Base: Types/ib_inform_info_set_qpn
7548 * NAME
7549 *       ib_inform_info_set_qpn
7550 *
7551 * DESCRIPTION
7552 *       Set the QPN of the inform info
7553 *
7554 * SYNOPSIS
7555 */
7556 static inline void OSM_API
7557 ib_inform_info_set_qpn(IN ib_inform_info_t * p_ii, IN ib_net32_t const qpn)
7558 {
7559         uint32_t tmp = cl_ntoh32(p_ii->g_or_v.generic.qpn_resp_time_val);
7560
7561         p_ii->g_or_v.generic.qpn_resp_time_val =
7562             cl_hton32((tmp & 0x000000ff) | ((cl_ntoh32(qpn) << 8) & 0xffffff00)
7563             );
7564 }
7565
7566 /*
7567 * PARAMETERS
7568 *
7569 * NOTES
7570 *
7571 * SEE ALSO
7572 *       ib_inform_info_t
7573 *********/
7574
7575 /****f* IBA Base: Types/ib_inform_info_get_prod_type
7576 * NAME
7577 *       ib_inform_info_get_prod_type
7578 *
7579 * DESCRIPTION
7580 *       Get Producer Type of the Inform Info
7581 *       13.4.8.3 InformInfo
7582 *
7583 * SYNOPSIS
7584 */
7585 static inline ib_net32_t OSM_API
7586 ib_inform_info_get_prod_type(IN const ib_inform_info_t * p_inf)
7587 {
7588         uint32_t nt;
7589
7590         nt = cl_ntoh16(p_inf->g_or_v.generic.node_type_lsb) |
7591             (p_inf->g_or_v.generic.node_type_msb << 16);
7592         return cl_hton32(nt);
7593 }
7594
7595 /*
7596 * PARAMETERS
7597 *       p_inf
7598 *               [in] pointer to an inform info
7599 *
7600 * RETURN VALUES
7601 *     The producer type
7602 *
7603 * NOTES
7604 *
7605 * SEE ALSO
7606 *       ib_inform_info_t
7607 *********/
7608
7609 /****f* IBA Base: Types/ib_inform_info_get_vend_id
7610 * NAME
7611 *       ib_inform_info_get_vend_id
7612 *
7613 * DESCRIPTION
7614 *       Get Node Type of the Inform Info
7615 *
7616 * SYNOPSIS
7617 */
7618 static inline ib_net32_t OSM_API
7619 ib_inform_info_get_vend_id(IN const ib_inform_info_t * p_inf)
7620 {
7621         uint32_t vi;
7622
7623         vi = cl_ntoh16(p_inf->g_or_v.vend.vendor_id_lsb) |
7624             (p_inf->g_or_v.vend.vendor_id_msb << 16);
7625         return cl_hton32(vi);
7626 }
7627
7628 /*
7629 * PARAMETERS
7630 *       p_inf
7631 *               [in] pointer to an inform info
7632 *
7633 * RETURN VALUES
7634 *     The node type
7635 *
7636 * NOTES
7637 *
7638 * SEE ALSO
7639 *       ib_inform_info_t
7640 *********/
7641
7642 /****s* IBA Base: Types/ib_inform_info_record_t
7643 * NAME
7644 *       ib_inform_info_record_t
7645 *
7646 * DESCRIPTION
7647 *       IBA defined InformInfo Record. (15.2.5.12)
7648 *
7649 * SYNOPSIS
7650 */
7651 #include <complib/cl_packon.h>
7652 typedef struct _ib_inform_info_record {
7653         ib_gid_t subscriber_gid;
7654         ib_net16_t subscriber_enum;
7655         uint8_t reserved[6];
7656         ib_inform_info_t inform_info;
7657         uint8_t pad[4];
7658 } PACK_SUFFIX ib_inform_info_record_t;
7659 #include <complib/cl_packoff.h>
7660
7661 /****s* IBA Base: Types/ib_perfmgt_mad_t
7662 * NAME
7663 *       ib_perfmgt_mad_t
7664 *
7665 * DESCRIPTION
7666 *       IBA defined Perf Management MAD (16.3.1)
7667 *
7668 * SYNOPSIS
7669 */
7670 #include <complib/cl_packon.h>
7671 typedef struct _ib_perfmgt_mad {
7672         ib_mad_t header;
7673         uint8_t resv[40];
7674
7675 #define IB_PM_DATA_SIZE         192
7676         uint8_t data[IB_PM_DATA_SIZE];
7677
7678 } PACK_SUFFIX ib_perfmgt_mad_t;
7679 #include <complib/cl_packoff.h>
7680 /*
7681 * FIELDS
7682 *       header
7683 *               Common MAD header.
7684 *
7685 *       resv
7686 *               Reserved.
7687 *
7688 *       data
7689 *               Performance Management payload.  The structure and content of this field
7690 *               depends upon the method, attr_id, and attr_mod fields in the header.
7691 *
7692 * SEE ALSO
7693 * ib_mad_t
7694 *********/
7695
7696 /****s* IBA Base: Types/ib_port_counters
7697 * NAME
7698 *       ib_port_counters_t
7699 *
7700 * DESCRIPTION
7701 *       IBA defined PortCounters Attribute. (16.1.3.5)
7702 *
7703 * SYNOPSIS
7704 */
7705 #include <complib/cl_packon.h>
7706 typedef struct _ib_port_counters {
7707         uint8_t reserved;
7708         uint8_t port_select;
7709         ib_net16_t counter_select;
7710         ib_net16_t symbol_err_cnt;
7711         uint8_t link_err_recover;
7712         uint8_t link_downed;
7713         ib_net16_t rcv_err;
7714         ib_net16_t rcv_rem_phys_err;
7715         ib_net16_t rcv_switch_relay_err;
7716         ib_net16_t xmit_discards;
7717         uint8_t xmit_constraint_err;
7718         uint8_t rcv_constraint_err;
7719         uint8_t res1;
7720         uint8_t link_int_buffer_overrun;
7721         ib_net16_t res2;
7722         ib_net16_t vl15_dropped;
7723         ib_net32_t xmit_data;
7724         ib_net32_t rcv_data;
7725         ib_net32_t xmit_pkts;
7726         ib_net32_t rcv_pkts;
7727 } PACK_SUFFIX ib_port_counters_t;
7728 #include <complib/cl_packoff.h>
7729
7730 #define PC_LINK_INT(integ_buf_over) ((integ_buf_over & 0xF0) >> 4)
7731 #define PC_BUF_OVERRUN(integ_buf_over) (integ_buf_over & 0x0F)
7732
7733 /****s* IBA Base: Types/ib_port_counters_ext
7734 * NAME
7735 *       ib_port_counters_ext_t
7736 *
7737 * DESCRIPTION
7738 *       IBA defined PortCounters Extended Attribute. (16.1.4.11)
7739 *
7740 * SYNOPSIS
7741 */
7742 #include <complib/cl_packon.h>
7743 typedef struct _ib_port_counters_ext {
7744         uint8_t reserved;
7745         uint8_t port_select;
7746         ib_net16_t counter_select;
7747         ib_net32_t reserved2;
7748         ib_net64_t xmit_data;
7749         ib_net64_t rcv_data;
7750         ib_net64_t xmit_pkts;
7751         ib_net64_t rcv_pkts;
7752         ib_net64_t unicast_xmit_pkts;
7753         ib_net64_t unicast_rcv_pkts;
7754         ib_net64_t multicast_xmit_pkts;
7755         ib_net64_t multicast_rcv_pkts;
7756 } PACK_SUFFIX ib_port_counters_ext_t;
7757 #include <complib/cl_packoff.h>
7758
7759 /****s* IBA Base: Types/ib_port_samples_control
7760 * NAME
7761 *       ib_port_samples_control_t
7762 *
7763 * DESCRIPTION
7764 *       IBA defined PortSamplesControl Attribute. (16.1.3.2)
7765 *
7766 * SYNOPSIS
7767 */
7768 #include <complib/cl_packon.h>
7769 typedef struct _ib_port_samples_control {
7770         uint8_t op_code;
7771         uint8_t port_select;
7772         uint8_t tick;
7773         uint8_t counter_width;  /* 5 bits res : 3bits counter_width */
7774         ib_net32_t counter_mask;        /* 2 bits res : 3 bits counter_mask : 27 bits counter_masks_1to9 */
7775         ib_net16_t counter_mask_10to14; /* 1 bits res : 15 bits counter_masks_10to14 */
7776         uint8_t sample_mech;
7777         uint8_t sample_status;  /* 6 bits res : 2 bits sample_status */
7778         ib_net64_t option_mask;
7779         ib_net64_t vendor_mask;
7780         ib_net32_t sample_start;
7781         ib_net32_t sample_interval;
7782         ib_net16_t tag;
7783         ib_net16_t counter_select0;
7784         ib_net16_t counter_select1;
7785         ib_net16_t counter_select2;
7786         ib_net16_t counter_select3;
7787         ib_net16_t counter_select4;
7788         ib_net16_t counter_select5;
7789         ib_net16_t counter_select6;
7790         ib_net16_t counter_select7;
7791         ib_net16_t counter_select8;
7792         ib_net16_t counter_select9;
7793         ib_net16_t counter_select10;
7794         ib_net16_t counter_select11;
7795         ib_net16_t counter_select12;
7796         ib_net16_t counter_select13;
7797         ib_net16_t counter_select14;
7798 } PACK_SUFFIX ib_port_samples_control_t;
7799 #include <complib/cl_packoff.h>
7800
7801 /****d* IBA Base: Types/CounterSelect values
7802 * NAME
7803 *       Counter select values
7804 *
7805 * DESCRIPTION
7806 *       Mandatory counter select values (16.1.3.3)
7807 *
7808 * SYNOPSIS
7809 */
7810 #define IB_CS_PORT_XMIT_DATA (CL_HTON16(0x0001))
7811 #define IB_CS_PORT_RCV_DATA  (CL_HTON16(0x0002))
7812 #define IB_CS_PORT_XMIT_PKTS (CL_HTON16(0x0003))
7813 #define IB_CS_PORT_RCV_PKTS  (CL_HTON16(0x0004))
7814 #define IB_CS_PORT_XMIT_WAIT (CL_HTON16(0x0005))
7815
7816 /****s* IBA Base: Types/ib_port_samples_result
7817 * NAME
7818 *       ib_port_samples_result_t
7819 *
7820 * DESCRIPTION
7821 *       IBA defined PortSamplesControl Attribute. (16.1.3.2)
7822 *
7823 * SYNOPSIS
7824 */
7825 #include <complib/cl_packon.h>
7826 typedef struct _ib_port_samples_result {
7827         ib_net16_t tag;
7828         ib_net16_t sample_status;       /* 14 bits res : 2 bits sample_status */
7829         ib_net32_t counter0;
7830         ib_net32_t counter1;
7831         ib_net32_t counter2;
7832         ib_net32_t counter3;
7833         ib_net32_t counter4;
7834         ib_net32_t counter5;
7835         ib_net32_t counter6;
7836         ib_net32_t counter7;
7837         ib_net32_t counter8;
7838         ib_net32_t counter9;
7839         ib_net32_t counter10;
7840         ib_net32_t counter11;
7841         ib_net32_t counter12;
7842         ib_net32_t counter13;
7843         ib_net32_t counter14;
7844 } PACK_SUFFIX ib_port_samples_result_t;
7845 #include <complib/cl_packoff.h>
7846
7847 /****d* IBA Base: Types/DM_SVC_NAME
7848 * NAME
7849 *       DM_SVC_NAME
7850 *
7851 * DESCRIPTION
7852 *       IBA defined Device Management service name (16.3)
7853 *
7854 * SYNOPSIS
7855 */
7856 #define DM_SVC_NAME                             "DeviceManager.IBTA"
7857 /*
7858 * SEE ALSO
7859 *********/
7860
7861 /****s* IBA Base: Types/ib_dm_mad_t
7862 * NAME
7863 *       ib_dm_mad_t
7864 *
7865 * DESCRIPTION
7866 *       IBA defined Device Management MAD (16.3.1)
7867 *
7868 * SYNOPSIS
7869 */
7870 #include <complib/cl_packon.h>
7871 typedef struct _ib_dm_mad {
7872         ib_mad_t header;
7873         uint8_t resv[40];
7874
7875 #define IB_DM_DATA_SIZE         192
7876         uint8_t data[IB_DM_DATA_SIZE];
7877
7878 } PACK_SUFFIX ib_dm_mad_t;
7879 #include <complib/cl_packoff.h>
7880 /*
7881 * FIELDS
7882 *       header
7883 *               Common MAD header.
7884 *
7885 *       resv
7886 *               Reserved.
7887 *
7888 *       data
7889 *               Device Management payload.  The structure and content of this field
7890 *               depend upon the method, attr_id, and attr_mod fields in the header.
7891 *
7892 * SEE ALSO
7893 * ib_mad_t
7894 *********/
7895
7896 /****s* IBA Base: Types/ib_iou_info_t
7897 * NAME
7898 *       ib_iou_info_t
7899 *
7900 * DESCRIPTION
7901 *       IBA defined IO Unit information structure (16.3.3.3)
7902 *
7903 * SYNOPSIS
7904 */
7905 #include <complib/cl_packon.h>
7906 typedef struct _ib_iou_info {
7907         ib_net16_t change_id;
7908         uint8_t max_controllers;
7909         uint8_t diag_rom;
7910
7911 #define IB_DM_CTRL_LIST_SIZE    128
7912
7913         uint8_t controller_list[IB_DM_CTRL_LIST_SIZE];
7914 #define IOC_NOT_INSTALLED               0x0
7915 #define IOC_INSTALLED                   0x1
7916 //              Reserved values                         0x02-0xE
7917 #define SLOT_DOES_NOT_EXIST             0xF
7918
7919 } PACK_SUFFIX ib_iou_info_t;
7920 #include <complib/cl_packoff.h>
7921 /*
7922 * FIELDS
7923 *       change_id
7924 *               Value incremented, with rollover, by any change to the controller_list.
7925 *
7926 *       max_controllers
7927 *               Number of slots in controller_list.
7928 *
7929 *       diag_rom
7930 *               A byte containing two fields: DiagDeviceID and OptionROM.
7931 *               These fields may be read using the ib_iou_info_diag_dev_id
7932 *               and ib_iou_info_option_rom functions.
7933 *
7934 *       controller_list
7935 *               A series of 4-bit nibbles, with each nibble representing a slot
7936 *               in the IO Unit.  Individual nibbles may be read using the
7937 *               ioc_at_slot function.
7938 *
7939 * SEE ALSO
7940 * ib_dm_mad_t, ib_iou_info_diag_dev_id, ib_iou_info_option_rom, ioc_at_slot
7941 *********/
7942
7943 /****f* IBA Base: Types/ib_iou_info_diag_dev_id
7944 * NAME
7945 *       ib_iou_info_diag_dev_id
7946 *
7947 * DESCRIPTION
7948 *       Returns the DiagDeviceID.
7949 *
7950 * SYNOPSIS
7951 */
7952 static inline uint8_t OSM_API
7953 ib_iou_info_diag_dev_id(IN const ib_iou_info_t * const p_iou_info)
7954 {
7955         return ((uint8_t) (p_iou_info->diag_rom >> 6 & 1));
7956 }
7957
7958 /*
7959 * PARAMETERS
7960 *       p_iou_info
7961 *               [in] Pointer to the IO Unit information structure.
7962 *
7963 * RETURN VALUES
7964 *       DiagDeviceID field of the IO Unit information.
7965 *
7966 * NOTES
7967 *
7968 * SEE ALSO
7969 *       ib_iou_info_t
7970 *********/
7971
7972 /****f* IBA Base: Types/ib_iou_info_option_rom
7973 * NAME
7974 *       ib_iou_info_option_rom
7975 *
7976 * DESCRIPTION
7977 *       Returns the OptionROM.
7978 *
7979 * SYNOPSIS
7980 */
7981 static inline uint8_t OSM_API
7982 ib_iou_info_option_rom(IN const ib_iou_info_t * const p_iou_info)
7983 {
7984         return ((uint8_t) (p_iou_info->diag_rom >> 7));
7985 }
7986
7987 /*
7988 * PARAMETERS
7989 *       p_iou_info
7990 *               [in] Pointer to the IO Unit information structure.
7991 *
7992 * RETURN VALUES
7993 *       OptionROM field of the IO Unit information.
7994 *
7995 * NOTES
7996 *
7997 * SEE ALSO
7998 *       ib_iou_info_t
7999 *********/
8000
8001 /****f* IBA Base: Types/ioc_at_slot
8002 * NAME
8003 *       ioc_at_slot
8004 *
8005 * DESCRIPTION
8006 *       Returns the IOC value at the specified slot.
8007 *
8008 * SYNOPSIS
8009 */
8010 static inline uint8_t OSM_API
8011 ioc_at_slot(IN const ib_iou_info_t * const p_iou_info, IN uint8_t slot)
8012 {
8013         if (slot >= IB_DM_CTRL_LIST_SIZE)
8014                 return SLOT_DOES_NOT_EXIST;
8015         else
8016                 return (int8_t)
8017                     ((slot % 2) ?
8018                      ((p_iou_info->controller_list[slot / 2] & 0xf0) >> 4) :
8019                      (p_iou_info->controller_list[slot / 2] & 0x0f));
8020 }
8021
8022 /*
8023 * PARAMETERS
8024 *       p_iou_info
8025 *               [in] Pointer to the IO Unit information structure.
8026 *
8027 *       slot
8028 *               [in] Pointer to the IO Unit information structure.
8029 *
8030 * RETURN VALUES
8031 *       OptionROM field of the IO Unit information.
8032 *
8033 * NOTES
8034 *
8035 * SEE ALSO
8036 *       ib_iou_info_t
8037 *********/
8038
8039 /****s* IBA Base: Types/ib_ioc_profile_t
8040 * NAME
8041 *       ib_ioc_profile_t
8042 *
8043 * DESCRIPTION
8044 *       IBA defined IO Controller profile structure (16.3.3.4)
8045 *
8046 * SYNOPSIS
8047 */
8048 #include <complib/cl_packon.h>
8049 typedef struct _ib_ioc_profile {
8050         ib_net64_t ioc_guid;
8051
8052         ib_net32_t vend_id;
8053
8054         ib_net32_t dev_id;
8055         ib_net16_t dev_ver;
8056         ib_net16_t resv2;
8057
8058         ib_net32_t subsys_vend_id;
8059         ib_net32_t subsys_id;
8060
8061         ib_net16_t io_class;
8062         ib_net16_t io_subclass;
8063         ib_net16_t protocol;
8064         ib_net16_t protocol_ver;
8065
8066         ib_net32_t resv3;
8067         ib_net16_t send_msg_depth;
8068         uint8_t resv4;
8069         uint8_t rdma_read_depth;
8070         ib_net32_t send_msg_size;
8071         ib_net32_t rdma_size;
8072
8073         uint8_t ctrl_ops_cap;
8074 #define CTRL_OPS_CAP_ST         0x01
8075 #define CTRL_OPS_CAP_SF         0x02
8076 #define CTRL_OPS_CAP_RT         0x04
8077 #define CTRL_OPS_CAP_RF         0x08
8078 #define CTRL_OPS_CAP_WT         0x10
8079 #define CTRL_OPS_CAP_WF         0x20
8080 #define CTRL_OPS_CAP_AT         0x40
8081 #define CTRL_OPS_CAP_AF         0x80
8082
8083         uint8_t resv5;
8084
8085         uint8_t num_svc_entries;
8086 #define MAX_NUM_SVC_ENTRIES     0xff
8087
8088         uint8_t resv6[9];
8089
8090 #define CTRL_ID_STRING_LEN      64
8091         char id_string[CTRL_ID_STRING_LEN];
8092
8093 } PACK_SUFFIX ib_ioc_profile_t;
8094 #include <complib/cl_packoff.h>
8095 /*
8096 * FIELDS
8097 *       ioc_guid
8098 *               An EUI-64 GUID used to uniquely identify the IO controller.
8099 *
8100 *       vend_id
8101 *               IO controller vendor ID, IEEE format.
8102 *
8103 *       dev_id
8104 *               A number assigned by the vendor to identify the type of controller.
8105 *
8106 *       dev_ver
8107 *               A number assigned by the vendor to identify the divice version.
8108 *
8109 *       subsys_vend_id
8110 *               ID of the vendor of the enclosure, if any, in which the IO controller
8111 *               resides in IEEE format; otherwise zero.
8112 *
8113 *       subsys_id
8114 *               A number identifying the subsystem where the controller resides.
8115 *
8116 *       io_class
8117 *               0x0000 - 0xfffe = reserved for IO classes encompased by InfiniBand
8118 *               Architecture.  0xffff = Vendor specific.
8119 *
8120 *       io_subclass
8121 *               0x0000 - 0xfffe = reserved for IO subclasses encompased by InfiniBand
8122 *               Architecture.  0xffff = Vendor specific.  This shall be set to 0xfff
8123 *               if the io_class component is 0xffff.
8124 *
8125 *       protocol
8126 *               0x0000 - 0xfffe = reserved for IO subclasses encompased by InfiniBand
8127 *               Architecture.  0xffff = Vendor specific.  This shall be set to 0xfff
8128 *               if the io_class component is 0xffff.
8129 *
8130 *       protocol_ver
8131 *               Protocol specific.
8132 *
8133 *       send_msg_depth
8134 *               Maximum depth of the send message queue.
8135 *
8136 *       rdma_read_depth
8137 *               Maximum depth of the per-channel RDMA read queue.
8138 *
8139 *       send_msg_size
8140 *               Maximum size of send messages.
8141 *
8142 *       ctrl_ops_cap
8143 *               Supported operation types of this IO controller.  A bit set to one
8144 *               for affirmation of supported capability.
8145 *
8146 *       num_svc_entries
8147 *               Number of entries in the service entries table.
8148 *
8149 *       id_string
8150 *               UTF-8 encoded string for identifying the controller to an operator.
8151 *
8152 * SEE ALSO
8153 * ib_dm_mad_t
8154 *********/
8155
8156 static inline uint32_t OSM_API
8157 ib_ioc_profile_get_vend_id(IN const ib_ioc_profile_t * const p_ioc_profile)
8158 {
8159         return (cl_ntoh32(p_ioc_profile->vend_id) >> 8);
8160 }
8161
8162 static inline void OSM_API
8163 ib_ioc_profile_set_vend_id(IN ib_ioc_profile_t * const p_ioc_profile,
8164                            IN const uint32_t vend_id)
8165 {
8166         p_ioc_profile->vend_id = (cl_hton32(vend_id) << 8);
8167 }
8168
8169 /****s* IBA Base: Types/ib_svc_entry_t
8170 * NAME
8171 *       ib_svc_entry_t
8172 *
8173 * DESCRIPTION
8174 *       IBA defined IO Controller service entry structure (16.3.3.5)
8175 *
8176 * SYNOPSIS
8177 */
8178 #include <complib/cl_packon.h>
8179 typedef struct _ib_svc_entry {
8180 #define MAX_SVC_ENTRY_NAME_LEN          40
8181         char name[MAX_SVC_ENTRY_NAME_LEN];
8182
8183         ib_net64_t id;
8184
8185 } PACK_SUFFIX ib_svc_entry_t;
8186 #include <complib/cl_packoff.h>
8187 /*
8188 * FIELDS
8189 *       name
8190 *               UTF-8 encoded, null-terminated name of the service.
8191 *
8192 *       id
8193 *               An identifier of the associated Service.
8194 *
8195 * SEE ALSO
8196 * ib_svc_entries_t
8197 *********/
8198
8199 /****s* IBA Base: Types/ib_svc_entries_t
8200 * NAME
8201 *       ib_svc_entries_t
8202 *
8203 * DESCRIPTION
8204 *       IBA defined IO Controller service entry array (16.3.3.5)
8205 *
8206 * SYNOPSIS
8207 */
8208 #include <complib/cl_packon.h>
8209 typedef struct _ib_svc_entries {
8210 #define SVC_ENTRY_COUNT                 4
8211         ib_svc_entry_t service_entry[SVC_ENTRY_COUNT];
8212
8213 } PACK_SUFFIX ib_svc_entries_t;
8214 #include <complib/cl_packoff.h>
8215 /*
8216 * FIELDS
8217 *       service_entry
8218 *               An array of IO controller service entries.
8219 *
8220 * SEE ALSO
8221 * ib_dm_mad_t, ib_svc_entry_t
8222 *********/
8223
8224 static inline void OSM_API
8225 ib_dm_get_slot_lo_hi(IN const ib_net32_t slot_lo_hi,
8226                      OUT uint8_t * const p_slot,
8227                      OUT uint8_t * const p_lo, OUT uint8_t * const p_hi)
8228 {
8229         ib_net32_t tmp_slot_lo_hi = CL_NTOH32(slot_lo_hi);
8230
8231         if (p_slot)
8232                 *p_slot = (uint8_t) ((tmp_slot_lo_hi >> 16) & 0x0f);
8233
8234         if (p_hi)
8235                 *p_hi = (uint8_t) ((tmp_slot_lo_hi >> 8) & 0xff);
8236
8237         if (p_lo)
8238                 *p_lo = (uint8_t) ((tmp_slot_lo_hi >> 0) & 0xff);
8239 }
8240
8241 /*
8242  *      IBA defined information describing an I/O controller
8243  */
8244 #include <complib/cl_packon.h>
8245 typedef struct _ib_ioc_info {
8246         ib_net64_t module_guid;
8247         ib_net64_t iou_guid;
8248         ib_ioc_profile_t ioc_profile;
8249         ib_net64_t access_key;
8250         uint16_t initiators_conf;
8251         uint8_t resv[38];
8252
8253 } PACK_SUFFIX ib_ioc_info_t;
8254 #include <complib/cl_packoff.h>
8255
8256 /*
8257  *      The following definitions are shared between the Access Layer and VPD
8258  */
8259 typedef struct _ib_ca *__ptr64 ib_ca_handle_t;
8260 typedef struct _ib_pd *__ptr64 ib_pd_handle_t;
8261 typedef struct _ib_rdd *__ptr64 ib_rdd_handle_t;
8262 typedef struct _ib_mr *__ptr64 ib_mr_handle_t;
8263 typedef struct _ib_mw *__ptr64 ib_mw_handle_t;
8264 typedef struct _ib_qp *__ptr64 ib_qp_handle_t;
8265 typedef struct _ib_eec *__ptr64 ib_eec_handle_t;
8266 typedef struct _ib_cq *__ptr64 ib_cq_handle_t;
8267 typedef struct _ib_av *__ptr64 ib_av_handle_t;
8268 typedef struct _ib_mcast *__ptr64 ib_mcast_handle_t;
8269
8270 /* Currently for windows branch, use the extended version of ib special verbs struct
8271         in order to be compliant with Infinicon ib_types; later we'll change it to support
8272         OpenSM ib_types.h */
8273
8274 #ifndef WIN32
8275 /****d* Access Layer/ib_api_status_t
8276 * NAME
8277 *       ib_api_status_t
8278 *
8279 * DESCRIPTION
8280 *       Function return codes indicating the success or failure of an API call.
8281 *       Note that success is indicated by the return value IB_SUCCESS, which
8282 *       is always zero.
8283 *
8284 * NOTES
8285 *       IB_VERBS_PROCESSING_DONE is used by UVP library to terminate a verbs call
8286 *       in the pre-ioctl step itself.
8287 *
8288 * SYNOPSIS
8289 */
8290 typedef enum _ib_api_status_t {
8291         IB_SUCCESS,
8292         IB_INSUFFICIENT_RESOURCES,
8293         IB_INSUFFICIENT_MEMORY,
8294         IB_INVALID_PARAMETER,
8295         IB_INVALID_SETTING,
8296         IB_NOT_FOUND,
8297         IB_TIMEOUT,
8298         IB_CANCELED,
8299         IB_INTERRUPTED,
8300         IB_INVALID_PERMISSION,
8301         IB_UNSUPPORTED,
8302         IB_OVERFLOW,
8303         IB_MAX_MCAST_QPS_REACHED,
8304         IB_INVALID_QP_STATE,
8305         IB_INVALID_EEC_STATE,
8306         IB_INVALID_APM_STATE,
8307         IB_INVALID_PORT_STATE,
8308         IB_INVALID_STATE,
8309         IB_RESOURCE_BUSY,
8310         IB_INVALID_PKEY,
8311         IB_INVALID_LKEY,
8312         IB_INVALID_RKEY,
8313         IB_INVALID_MAX_WRS,
8314         IB_INVALID_MAX_SGE,
8315         IB_INVALID_CQ_SIZE,
8316         IB_INVALID_SERVICE_TYPE,
8317         IB_INVALID_GID,
8318         IB_INVALID_LID,
8319         IB_INVALID_GUID,
8320         IB_INVALID_CA_HANDLE,
8321         IB_INVALID_AV_HANDLE,
8322         IB_INVALID_CQ_HANDLE,
8323         IB_INVALID_EEC_HANDLE,
8324         IB_INVALID_QP_HANDLE,
8325         IB_INVALID_PD_HANDLE,
8326         IB_INVALID_MR_HANDLE,
8327         IB_INVALID_MW_HANDLE,
8328         IB_INVALID_RDD_HANDLE,
8329         IB_INVALID_MCAST_HANDLE,
8330         IB_INVALID_CALLBACK,
8331         IB_INVALID_AL_HANDLE,   /* InfiniBand Access Layer */
8332         IB_INVALID_HANDLE,      /* InfiniBand Access Layer */
8333         IB_ERROR,               /* InfiniBand Access Layer */
8334         IB_REMOTE_ERROR,        /* Infiniband Access Layer */
8335         IB_VERBS_PROCESSING_DONE,       /* See Notes above         */
8336         IB_INVALID_WR_TYPE,
8337         IB_QP_IN_TIMEWAIT,
8338         IB_EE_IN_TIMEWAIT,
8339         IB_INVALID_PORT,
8340         IB_NOT_DONE,
8341         IB_UNKNOWN_ERROR        /* ALWAYS LAST ENUM VALUE! */
8342 } ib_api_status_t;
8343 /*****/
8344
8345 OSM_EXPORT const char *ib_error_str[];
8346
8347 /****f* IBA Base: Types/ib_get_err_str
8348 * NAME
8349 *       ib_get_err_str
8350 *
8351 * DESCRIPTION
8352 *       Returns a string for the specified status value.
8353 *
8354 * SYNOPSIS
8355 */
8356 static inline const char *OSM_API ib_get_err_str(IN ib_api_status_t status)
8357 {
8358         if (status > IB_UNKNOWN_ERROR)
8359                 status = IB_UNKNOWN_ERROR;
8360         return (ib_error_str[status]);
8361 }
8362
8363 /*
8364 * PARAMETERS
8365 *       status
8366 *               [in] status value
8367 *
8368 * RETURN VALUES
8369 *       Pointer to the status description string.
8370 *
8371 * NOTES
8372 *
8373 * SEE ALSO
8374 *********/
8375
8376 /****d* Verbs/ib_async_event_t
8377 * NAME
8378 *       ib_async_event_t -- Async event types
8379 *
8380 * DESCRIPTION
8381 *       This type indicates the reason the async callback was called.
8382 *       The context in the ib_event_rec_t indicates the resource context
8383 *       that associated with the callback.  For example, for IB_AE_CQ_ERROR
8384 *       the context provided during the ib_create_cq is returned in the event.
8385 *
8386 * SYNOPSIS
8387 */
8388 typedef enum _ib_async_event_t {
8389         IB_AE_SQ_ERROR = 1,
8390         IB_AE_SQ_DRAINED,
8391         IB_AE_RQ_ERROR,
8392         IB_AE_CQ_ERROR,
8393         IB_AE_QP_FATAL,
8394         IB_AE_QP_COMM,
8395         IB_AE_QP_APM,
8396         IB_AE_EEC_FATAL,
8397         IB_AE_EEC_COMM,
8398         IB_AE_EEC_APM,
8399         IB_AE_LOCAL_FATAL,
8400         IB_AE_PKEY_TRAP,
8401         IB_AE_QKEY_TRAP,
8402         IB_AE_MKEY_TRAP,
8403         IB_AE_PORT_TRAP,
8404         IB_AE_SYSIMG_GUID_TRAP,
8405         IB_AE_BUF_OVERRUN,
8406         IB_AE_LINK_INTEGRITY,
8407         IB_AE_FLOW_CTRL_ERROR,
8408         IB_AE_BKEY_TRAP,
8409         IB_AE_QP_APM_ERROR,
8410         IB_AE_EEC_APM_ERROR,
8411         IB_AE_WQ_REQ_ERROR,
8412         IB_AE_WQ_ACCESS_ERROR,
8413         IB_AE_PORT_ACTIVE,
8414         IB_AE_PORT_DOWN,
8415         IB_AE_UNKNOWN           /* ALWAYS LAST ENUM VALUE */
8416 } ib_async_event_t;
8417 /*
8418 * VALUES
8419 *       IB_AE_SQ_ERROR
8420 *               An error occurred when accessing the send queue of the QP or EEC.
8421 *               This event is optional.
8422 *
8423 *       IB_AE_SQ_DRAINED
8424 *               The send queue of the specified QP has completed the outstanding
8425 *               messages in progress when the state change was requested and, if
8426 *               applicable, has received all acknowledgements for those messages.
8427 *
8428 *       IB_AE_RQ_ERROR
8429 *               An error occurred when accessing the receive queue of the QP or EEC.
8430 *               This event is optional.
8431 *
8432 *       IB_AE_CQ_ERROR
8433 *               An error occurred when writing an entry to the CQ.
8434 *
8435 *       IB_AE_QP_FATAL
8436 *               A catastrophic error occurred while accessing or processing the
8437 *               work queue that prevents reporting of completions.
8438 *
8439 *       IB_AE_QP_COMM
8440 *               The first packet has arrived for the receive work queue where the
8441 *               QP is still in the RTR state.
8442 *
8443 *       IB_AE_QP_APM
8444 *               If alternate path migration is supported, this event indicates that
8445 *               the QP connection has migrated to the alternate path.
8446 *
8447 *       IB_AE_EEC_FATAL
8448 *               If reliable datagram service is supported, this event indicates that
8449 *               a catastrophic error occurred while accessing or processing the EEC
8450 *               that prevents reporting of completions.
8451 *
8452 *       IB_AE_EEC_COMM
8453 *               If reliable datagram service is supported, this event indicates that
8454 *               the first packet has arrived for the receive work queue where the
8455 *               EEC is still in the RTR state.
8456 *
8457 *       IB_AE_EEC_APM
8458 *               If reliable datagram service and alternate path migration is supported,
8459 *               this event indicates that the EEC connection has migrated to the
8460 *               alternate path.
8461 *
8462 *       IB_AE_LOCAL_FATAL
8463 *               A catastrophic HCA error occurred which cannot be attributed to any
8464 *               resource; behavior is indeterminate.
8465 *
8466 *       IB_AE_PKEY_TRAP
8467 *               A PKEY violation was detected.  This event is optional.
8468 *
8469 *       IB_AE_QKEY_TRAP
8470 *               A QKEY violation was detected.  This event is optional.
8471 *
8472 *       IB_AE_MKEY_TRAP
8473 *               An MKEY violation was detected.  This event is optional.
8474 *
8475 *       IB_AE_PORT_TRAP
8476 *               A port capability change was detected.  This event is optional.
8477 *
8478 *       IB_AE_SYSIMG_GUID_TRAP
8479 *               If the system image GUID is supported, this event indicates that the
8480 *               system image GUID of this HCA has been changed.  This event is
8481 *               optional.
8482 *
8483 *       IB_AE_BUF_OVERRUN
8484 *               The number of consecutive flow control update periods with at least
8485 *               one overrun error in each period has exceeded the threshold specified
8486 *               in the port info attributes.  This event is optional.
8487 *
8488 *       IB_AE_LINK_INTEGRITY
8489 *               The detection of excessively frequent local physical errors has
8490 *               exceeded the threshold specified in the port info attributes.  This
8491 *               event is optional.
8492 *
8493 *       IB_AE_FLOW_CTRL_ERROR
8494 *               An HCA watchdog timer monitoring the arrival of flow control updates
8495 *               has expired without receiving an update.  This event is optional.
8496 *
8497 *       IB_AE_BKEY_TRAP
8498 *               An BKEY violation was detected.  This event is optional.
8499 *
8500 *       IB_AE_QP_APM_ERROR
8501 *               If alternate path migration is supported, this event indicates that
8502 *               an incoming path migration request to this QP was not accepted.
8503 *
8504 *       IB_AE_EEC_APM_ERROR
8505 *               If reliable datagram service and alternate path migration is supported,
8506 *               this event indicates that an incoming path migration request to this
8507 *               EEC was not accepted.
8508 *
8509 *       IB_AE_WQ_REQ_ERROR
8510 *               An OpCode violation was detected at the responder.
8511 *
8512 *       IB_AE_WQ_ACCESS_ERROR
8513 *               An access violation was detected at the responder.
8514 *
8515 *       IB_AE_PORT_ACTIVE
8516 *               If the port active event is supported, this event is generated
8517 *               when the link becomes active: IB_LINK_ACTIVE.
8518 *
8519 *       IB_AE_PORT_DOWN
8520 *               The link is declared unavailable: IB_LINK_INIT, IB_LINK_ARMED,
8521 *               IB_LINK_DOWN.
8522 *
8523 *       IB_AE_UNKNOWN
8524 *               An unknown error occurred which cannot be attributed to any
8525 *               resource; behavior is indeterminate.
8526 *
8527 *****/
8528
8529 OSM_EXPORT const char *ib_async_event_str[];
8530
8531 /****f* IBA Base: Types/ib_get_async_event_str
8532 * NAME
8533 *       ib_get_async_event_str
8534 *
8535 * DESCRIPTION
8536 *       Returns a string for the specified asynchronous event.
8537 *
8538 * SYNOPSIS
8539 */
8540 static inline const char *OSM_API
8541 ib_get_async_event_str(IN ib_async_event_t event)
8542 {
8543         if (event > IB_AE_UNKNOWN)
8544                 event = IB_AE_UNKNOWN;
8545         return (ib_async_event_str[event]);
8546 }
8547
8548 /*
8549 * PARAMETERS
8550 *       event
8551 *               [in] event value
8552 *
8553 * RETURN VALUES
8554 *       Pointer to the asynchronous event description string.
8555 *
8556 * NOTES
8557 *
8558 * SEE ALSO
8559 *********/
8560
8561 /****s* Verbs/ib_event_rec_t
8562 * NAME
8563 *       ib_event_rec_t -- Async event notification record
8564 *
8565 * DESCRIPTION
8566 *       When an async event callback is made, this structure is passed to indicate
8567 *       the type of event, the source of event that caused it, and the context
8568 *       associated with this event.
8569 *
8570 *       context -- Context of the resource that caused the event.
8571 *               -- ca_context if this is a port/adapter event.
8572 *               -- qp_context if the source is a QP event
8573 *               -- cq_context if the source is a CQ event.
8574 *               -- ee_context if the source is an EE event.
8575 *
8576 * SYNOPSIS
8577 */
8578 typedef struct _ib_event_rec {
8579         void *context;
8580         ib_async_event_t type;
8581
8582         /* HCA vendor specific event information. */
8583         uint64_t vendor_specific;
8584
8585         /* The following structures are valid only for trap types. */
8586         union _trap {
8587                 struct {
8588                         uint16_t lid;
8589                         ib_net64_t port_guid;
8590                         uint8_t port_num;
8591
8592                         /*
8593                          * The following structure is valid only for
8594                          * P_KEY, Q_KEY, and M_KEY violation traps.
8595                          */
8596                         struct {
8597                                 uint8_t sl;
8598                                 uint16_t src_lid;
8599                                 uint16_t dest_lid;
8600                                 union _key {
8601                                         uint16_t pkey;
8602                                         uint32_t qkey;
8603                                         uint64_t mkey;
8604                                 } key;
8605                                 uint32_t src_qp;
8606                                 uint32_t dest_qp;
8607                                 ib_gid_t src_gid;
8608                                 ib_gid_t dest_gid;
8609
8610                         } violation;
8611
8612                 } info;
8613
8614                 ib_net64_t sysimg_guid;
8615
8616         } trap;
8617
8618 } ib_event_rec_t;
8619 /*******/
8620
8621 /****d* Access Layer/ib_atomic_t
8622 * NAME
8623 *       ib_atomic_t
8624 *
8625 * DESCRIPTION
8626 *       Indicates atomicity levels supported by an adapter.
8627 *
8628 * SYNOPSIS
8629 */
8630 typedef enum _ib_atomic_t {
8631         IB_ATOMIC_NONE,
8632         IB_ATOMIC_LOCAL,
8633         IB_ATOMIC_GLOBAL
8634 } ib_atomic_t;
8635 /*
8636 * VALUES
8637 *       IB_ATOMIC_NONE
8638 *               Atomic operations not supported.
8639 *
8640 *       IB_ATOMIC_LOCAL
8641 *               Atomic operations guaranteed between QPs of a single CA.
8642 *
8643 *       IB_ATOMIC_GLOBAL
8644 *               Atomic operations are guaranteed between CA and any other entity
8645 *               in the system.
8646 *****/
8647
8648 /****s* Access Layer/ib_port_cap_t
8649 * NAME
8650 *       ib_port_cap_t
8651 *
8652 * DESCRIPTION
8653 *       Indicates which management agents are currently available on the specified
8654 *       port.
8655 *
8656 * SYNOPSIS
8657 */
8658 typedef struct _ib_port_cap {
8659         boolean_t cm;
8660         boolean_t snmp;
8661         boolean_t dev_mgmt;
8662         boolean_t vend;
8663         boolean_t sm;
8664         boolean_t sm_disable;
8665         boolean_t qkey_ctr;
8666         boolean_t pkey_ctr;
8667         boolean_t notice;
8668         boolean_t trap;
8669         boolean_t apm;
8670         boolean_t slmap;
8671         boolean_t pkey_nvram;
8672         boolean_t mkey_nvram;
8673         boolean_t sysguid;
8674         boolean_t dr_notice;
8675         boolean_t boot_mgmt;
8676         boolean_t capm_notice;
8677         boolean_t reinit;
8678         boolean_t ledinfo;
8679         boolean_t port_active;
8680
8681 } ib_port_cap_t;
8682 /*****/
8683
8684 /****d* Access Layer/ib_init_type_t
8685 * NAME
8686 *       ib_init_type_t
8687 *
8688 * DESCRIPTION
8689 *       If supported by the HCA, the type of initialization requested by
8690 *       this port before SM moves it to the active or armed state.  If the
8691 *       SM implements reinitialization, it shall set these bits to indicate
8692 *       the type of initialization performed prior to activating the port.
8693 *       Otherwise, these bits shall be set to 0.
8694 *
8695 * SYNOPSIS
8696 */
8697 typedef uint8_t ib_init_type_t;
8698 #define IB_INIT_TYPE_NO_LOAD                    0x01
8699 #define IB_INIT_TYPE_PRESERVE_CONTENT           0x02
8700 #define IB_INIT_TYPE_PRESERVE_PRESENCE          0x04
8701 #define IB_INIT_TYPE_DO_NOT_RESUSCITATE         0x08
8702 /*****/
8703
8704 /****s* Access Layer/ib_port_attr_mod_t
8705 * NAME
8706 *       ib_port_attr_mod_t
8707 *
8708 * DESCRIPTION
8709 *       Port attributes that may be modified.
8710 *
8711 * SYNOPSIS
8712 */
8713 typedef struct _ib_port_attr_mod {
8714         ib_port_cap_t cap;
8715         uint16_t pkey_ctr;
8716         uint16_t qkey_ctr;
8717
8718         ib_init_type_t init_type;
8719         ib_net64_t system_image_guid;
8720
8721 } ib_port_attr_mod_t;
8722 /*
8723 * SEE ALSO
8724 *       ib_port_cap_t
8725 *****/
8726
8727 /****s* Access Layer/ib_port_attr_t
8728 * NAME
8729 *       ib_port_attr_t
8730 *
8731 * DESCRIPTION
8732 *       Information about a port on a given channel adapter.
8733 *
8734 * SYNOPSIS
8735 */
8736 typedef struct _ib_port_attr {
8737         ib_net64_t port_guid;
8738         uint8_t port_num;
8739         uint8_t mtu;
8740         uint64_t max_msg_size;
8741         ib_net16_t lid;
8742         uint8_t lmc;
8743
8744         /*
8745          * LinkWidthSupported as defined in PortInfo.  Required to calculate
8746          * inter-packet delay (a.k.a. static rate).
8747          */
8748         uint8_t link_width_supported;
8749
8750         uint16_t max_vls;
8751
8752         ib_net16_t sm_lid;
8753         uint8_t sm_sl;
8754         uint8_t link_state;
8755
8756         ib_init_type_t init_type_reply; /* Optional */
8757
8758         /*
8759          * subnet_timeout:
8760          * The maximum expected subnet propagation delay to reach any port on
8761          * the subnet.  This value also determines the rate at which traps can
8762          * be generated from this node.
8763          *
8764          * timeout = 4.096 microseconds * 2^subnet_timeout
8765          */
8766         uint8_t subnet_timeout;
8767
8768         ib_port_cap_t cap;
8769         uint16_t pkey_ctr;
8770         uint16_t qkey_ctr;
8771
8772         uint16_t num_gids;
8773         uint16_t num_pkeys;
8774         /*
8775          * Pointers at the end of the structure to allow doing a simple
8776          * memory comparison of contents up to the first pointer.
8777          */
8778         ib_gid_t *p_gid_table;
8779         ib_net16_t *p_pkey_table;
8780
8781 } ib_port_attr_t;
8782 /*
8783 * SEE ALSO
8784 *       uint8_t, ib_port_cap_t, ib_link_states_t
8785 *****/
8786
8787 /****s* Access Layer/ib_ca_attr_t
8788 * NAME
8789 *       ib_ca_attr_t
8790 *
8791 * DESCRIPTION
8792 *       Information about a channel adapter.
8793 *
8794 * SYNOPSIS
8795 */
8796 typedef struct _ib_ca_attr {
8797         ib_net64_t ca_guid;
8798
8799         uint32_t vend_id;
8800         uint16_t dev_id;
8801         uint16_t revision;
8802         uint64_t fw_ver;
8803
8804         /*
8805          * Total size of the ca attributes in bytes
8806          */
8807         uint32_t size;
8808         uint32_t max_qps;
8809         uint32_t max_wrs;
8810
8811         uint32_t max_sges;
8812         uint32_t max_rd_sges;
8813
8814         uint32_t max_cqs;
8815         uint32_t max_cqes;
8816
8817         uint32_t max_pds;
8818
8819         uint32_t init_regions;
8820         uint64_t init_region_size;
8821
8822         uint32_t init_windows;
8823         uint32_t max_addr_handles;
8824
8825         uint32_t max_partitions;
8826
8827         ib_atomic_t atomicity;
8828
8829         uint8_t max_qp_resp_res;
8830         uint8_t max_eec_resp_res;
8831         uint8_t max_resp_res;
8832
8833         uint8_t max_qp_init_depth;
8834         uint8_t max_eec_init_depth;
8835
8836         uint32_t max_eecs;
8837         uint32_t max_rdds;
8838
8839         uint32_t max_ipv6_qps;
8840         uint32_t max_ether_qps;
8841
8842         uint32_t max_mcast_grps;
8843         uint32_t max_mcast_qps;
8844         uint32_t max_qps_per_mcast_grp;
8845         uint32_t max_fmr;
8846         uint32_t max_map_per_fmr;
8847
8848         /*
8849          * local_ack_delay:
8850          * Specifies the maximum time interval between the local CA receiving
8851          * a message and the transmission of the associated ACK or NAK.
8852          *
8853          * timeout = 4.096 microseconds * 2^local_ack_delay
8854          */
8855         uint8_t local_ack_delay;
8856
8857         boolean_t bad_pkey_ctr_support;
8858         boolean_t bad_qkey_ctr_support;
8859         boolean_t raw_mcast_support;
8860         boolean_t apm_support;
8861         boolean_t av_port_check;
8862         boolean_t change_primary_port;
8863         boolean_t modify_wr_depth;
8864         boolean_t current_qp_state_support;
8865         boolean_t shutdown_port_capability;
8866         boolean_t init_type_support;
8867         boolean_t port_active_event_support;
8868         boolean_t system_image_guid_support;
8869         boolean_t hw_agents;
8870
8871         ib_net64_t system_image_guid;
8872
8873         uint32_t num_page_sizes;
8874         uint8_t num_ports;
8875
8876         uint32_t *p_page_size;
8877         ib_port_attr_t *p_port_attr;
8878
8879 } ib_ca_attr_t;
8880 /*
8881 * FIELDS
8882 *       ca_guid
8883 *               GUID for this adapter.
8884 *
8885 *       vend_id
8886 *               IEEE vendor ID for this adapter
8887 *
8888 *       dev_id
8889 *               Device ID of this adapter. (typically from PCI device ID)
8890 *
8891 *       revision
8892 *               Revision ID of this adapter
8893 *
8894 *       fw_ver
8895 *               Device Firmware version.
8896 *
8897 *       size
8898 *               Total size in bytes for the HCA attributes.  This size includes total
8899 *               size required for all the variable members of the structure.  If a
8900 *               vendor requires to pass vendor specific fields beyond this structure,
8901 *               the HCA vendor can choose to report a larger size.  If a vendor is
8902 *               reporting extended vendor specific features, they should also provide
8903 *               appropriate access functions to aid with the required interpretation.
8904 *
8905 *       max_qps
8906 *               Maximum number of QP's supported by this HCA.
8907 *
8908 *       max_wrs
8909 *               Maximum number of work requests supported by this HCA.
8910 *
8911 *       max_sges
8912 *               Maximum number of scatter gather elements supported per work request.
8913 *
8914 *       max_rd_sges
8915 *               Maximum number of scatter gather elements supported for READ work
8916 *               requests for a Reliable Datagram QP.  This value must be zero if RD
8917 *               service is not supported.
8918 *
8919 *       max_cqs
8920 *               Maximum number of Completion Queues supported.
8921 *
8922 *       max_cqes
8923 *               Maximum number of CQ elements supported per CQ.
8924 *
8925 *       max_pds
8926 *               Maximum number of protection domains supported.
8927 *
8928 *       init_regions
8929 *               Initial number of memory regions supported.  These are only informative
8930 *               values.  HCA vendors can extended and grow these limits on demand.
8931 *
8932 *       init_region_size
8933 *               Initial limit on the size of the registered memory region.
8934 *
8935 *       init_windows
8936 *               Initial number of window entries supported.
8937 *
8938 *       max_addr_handles
8939 *               Maximum number of address handles supported.
8940 *
8941 *       max_partitions
8942 *               Maximum number of partitions supported.
8943 *
8944 *       atomicity
8945 *               Indicates level of atomic operations supported by this HCA.
8946 *
8947 *       max_qp_resp_res
8948 *       max_eec_resp_res
8949 *               Maximum limit on number of responder resources for incoming RDMA
8950 *               operations, on QPs and EEC's respectively.
8951 *
8952 *       max_resp_res
8953 *               Maximum number of responder resources per HCA, with this HCA used as
8954 *               the target.
8955 *
8956 *       max_qp_init_depth
8957 *       max_eec_init_depth
8958 *               Maximimum initiator depth per QP or EEC for initiating RDMA reads and
8959 *               atomic operations.
8960 *
8961 *       max_eecs
8962 *               Maximimum number of EEC's supported by the HCA.
8963 *
8964 *       max_rdds
8965 *               Maximum number of Reliable datagram domains supported.
8966 *
8967 *       max_ipv6_qps
8968 *       max_ether_qps
8969 *               Maximum number of IPV6 and raw ether QP's supported by this HCA.
8970 *
8971 *       max_mcast_grps
8972 *               Maximum number of multicast groups supported.
8973 *
8974 *       max_mcast_qps
8975 *               Maximum number of QP's that can support multicast operations.
8976 *
8977 *       max_qps_per_mcast_grp
8978 *               Maximum number of multicast QP's per multicast group.
8979 *
8980 *       local_ack_delay
8981 *               Specifies the maximum time interval between the local CA receiving
8982 *               a message and the transmission of the associated ACK or NAK.
8983 *               timeout = 4.096 microseconds * 2^local_ack_delay
8984 *
8985 *       bad_pkey_ctr_support
8986 *       bad_qkey_ctr_support
8987 *               Indicates support for the bad pkey and qkey counters.
8988 *
8989 *       raw_mcast_support
8990 *               Indicates support for raw packet multicast.
8991 *
8992 *       apm_support
8993 *               Indicates support for Automatic Path Migration.
8994 *
8995 *       av_port_check
8996 *               Indicates ability to check port number in address handles.
8997 *
8998 *       change_primary_port
8999 *               Indicates ability to change primary port for a QP or EEC during a
9000 *               SQD->RTS transition.
9001 *
9002 *       modify_wr_depth
9003 *               Indicates ability to modify QP depth during a modify QP operation.
9004 *               Check the verb specification for permitted states.
9005 *
9006 *       current_qp_state_support
9007 *               Indicates ability of the HCA to support the current QP state modifier
9008 *               during a modify QP operation.
9009 *
9010 *       shutdown_port_capability
9011 *               Shutdown port capability support indicator.
9012 *
9013 *       init_type_support
9014 *               Indicates init_type_reply and ability to set init_type is supported.
9015 *
9016 *       port_active_event_support
9017 *               Port active event support indicator.
9018 *
9019 *       system_image_guid_support
9020 *               System image GUID support indicator.
9021 *
9022 *       hw_agents
9023 *               Indicates SMA is implemented in HW.
9024 *
9025 *       system_image_guid
9026 *               Optional system image GUID.  This field is valid only if the
9027 *               system_image_guid_support flag is set.
9028 *
9029 *       num_page_sizes
9030 *               Indicates support for different page sizes supported by the HCA.
9031 *               The variable size array can be obtained from p_page_size.
9032 *
9033 *       num_ports
9034 *               Number of physical ports supported on this HCA.
9035 *
9036 *       p_page_size
9037 *               Array holding different page size supported.
9038 *
9039 *       p_port_attr
9040 *               Array holding port attributes.
9041 *
9042 * NOTES
9043 *       This structure contains the attributes of a channel adapter.  Users must
9044 *       call ib_copy_ca_attr to copy the contents of this structure to a new
9045 *       memory region.
9046 *
9047 * SEE ALSO
9048 *       ib_port_attr_t, ib_atomic_t, ib_copy_ca_attr
9049 *****/
9050
9051 /****f* Access layer/ib_copy_ca_attr
9052 * NAME
9053 *       ib_copy_ca_attr
9054 *
9055 * DESCRIPTION
9056 *       Copies CA attributes.
9057 *
9058 * SYNOPSIS
9059 */
9060 ib_ca_attr_t *ib_copy_ca_attr(IN ib_ca_attr_t * const p_dest,
9061                               IN const ib_ca_attr_t * const p_src);
9062 /*
9063 * PARAMETERS
9064 *       p_dest
9065 *               Pointer to the buffer that is the destination of the copy.
9066 *
9067 *       p_src
9068 *               Pointer to the CA attributes to copy.
9069 *
9070 * RETURN VALUE
9071 *       Pointer to the copied CA attributes.
9072 *
9073 * NOTES
9074 *       The buffer pointed to by the p_dest parameter must be at least the size
9075 *       specified in the size field of the buffer pointed to by p_src.
9076 *
9077 * SEE ALSO
9078 *       ib_ca_attr_t, ib_dup_ca_attr, ib_free_ca_attr
9079 *****/
9080
9081 /****s* Access Layer/ib_av_attr_t
9082 * NAME
9083 *       ib_av_attr_t
9084 *
9085 * DESCRIPTION
9086 *       IBA address vector.
9087 *
9088 * SYNOPSIS
9089 */
9090 typedef struct _ib_av_attr {
9091         uint8_t port_num;
9092
9093         uint8_t sl;
9094         ib_net16_t dlid;
9095
9096         boolean_t grh_valid;
9097         ib_grh_t grh;
9098         uint8_t static_rate;
9099         uint8_t path_bits;
9100
9101         struct _av_conn {
9102                 uint8_t path_mtu;
9103                 uint8_t local_ack_timeout;
9104                 uint8_t seq_err_retry_cnt;
9105                 uint8_t rnr_retry_cnt;
9106
9107         } conn;
9108
9109 } ib_av_attr_t;
9110 /*
9111 * SEE ALSO
9112 *       ib_gid_t
9113 *****/
9114
9115 /****d* Access Layer/ib_qp_type_t
9116 * NAME
9117 *       ib_qp_type_t
9118 *
9119 * DESCRIPTION
9120 *       Indicates the type of queue pair being created.
9121 *
9122 * SYNOPSIS
9123 */
9124 typedef enum _ib_qp_type {
9125         IB_QPT_RELIABLE_CONN = 0,       /* Matches CM REQ transport type */
9126         IB_QPT_UNRELIABLE_CONN = 1,     /* Matches CM REQ transport type */
9127         IB_QPT_RELIABLE_DGRM = 2,       /* Matches CM REQ transport type */
9128         IB_QPT_UNRELIABLE_DGRM,
9129         IB_QPT_QP0,
9130         IB_QPT_QP1,
9131         IB_QPT_RAW_IPV6,
9132         IB_QPT_RAW_ETHER,
9133         IB_QPT_MAD,             /* InfiniBand Access Layer */
9134         IB_QPT_QP0_ALIAS,       /* InfiniBand Access Layer */
9135         IB_QPT_QP1_ALIAS        /* InfiniBand Access Layer */
9136 } ib_qp_type_t;
9137 /*
9138 * VALUES
9139 *       IB_QPT_RELIABLE_CONN
9140 *               Reliable, connected queue pair.
9141 *
9142 *       IB_QPT_UNRELIABLE_CONN
9143 *               Unreliable, connected queue pair.
9144 *
9145 *       IB_QPT_RELIABLE_DGRM
9146 *               Reliable, datagram queue pair.
9147 *
9148 *       IB_QPT_UNRELIABLE_DGRM
9149 *               Unreliable, datagram queue pair.
9150 *
9151 *       IB_QPT_QP0
9152 *               Queue pair 0.
9153 *
9154 *       IB_QPT_QP1
9155 *               Queue pair 1.
9156 *
9157 *       IB_QPT_RAW_DGRM
9158 *               Raw datagram queue pair.
9159 *
9160 *       IB_QPT_RAW_IPV6
9161 *               Raw IP version 6 queue pair.
9162 *
9163 *       IB_QPT_RAW_ETHER
9164 *               Raw Ethernet queue pair.
9165 *
9166 *       IB_QPT_MAD
9167 *               Unreliable, datagram queue pair that will send and receive management
9168 *               datagrams with assistance from the access layer.
9169 *
9170 *       IB_QPT_QP0_ALIAS
9171 *               Alias to queue pair 0.  Aliased QPs can only be created on an aliased
9172 *               protection domain.
9173 *
9174 *       IB_QPT_QP1_ALIAS
9175 *               Alias to queue pair 1.  Aliased QPs can only be created on an aliased
9176 *               protection domain.
9177 *****/
9178
9179 /****d* Access Layer/ib_access_t
9180 * NAME
9181 *       ib_access_t
9182 *
9183 * DESCRIPTION
9184 *       Indicates the type of access is permitted on resources such as QPs,
9185 *       memory regions and memory windows.
9186 *
9187 * SYNOPSIS
9188 */
9189 typedef uint32_t ib_access_t;
9190 #define IB_AC_RDMA_READ                         0x00000001
9191 #define IB_AC_RDMA_WRITE                        0x00000002
9192 #define IB_AC_ATOMIC                            0x00000004
9193 #define IB_AC_LOCAL_WRITE                       0x00000008
9194 #define IB_AC_MW_BIND                           0x00000010
9195 /*
9196 * NOTES
9197 *       Users may combine access rights using a bit-wise or operation to specify
9198 *       additional access.  For example: IB_AC_RDMA_READ | IB_AC_RDMA_WRITE grants
9199 *       RDMA read and write access.
9200 *****/
9201
9202 /****d* Access Layer/ib_qp_state_t
9203 * NAME
9204 *       ib_qp_state_t
9205 *
9206 * DESCRIPTION
9207 *       Indicates or sets the state of a queue pair.  The current state of a queue
9208 *       pair is returned through the ib_qp_query call and set via the
9209 *       ib_qp_modify call.
9210 *
9211 * SYNOPSIS
9212 */
9213 typedef uint32_t ib_qp_state_t;
9214 #define IB_QPS_RESET                            0x00000001
9215 #define IB_QPS_INIT                             0x00000002
9216 #define IB_QPS_RTR                              0x00000004
9217 #define IB_QPS_RTS                              0x00000008
9218 #define IB_QPS_SQD                              0x00000010
9219 #define IB_QPS_SQD_DRAINING                     0x00000030
9220 #define IB_QPS_SQD_DRAINED                      0x00000050
9221 #define IB_QPS_SQERR                            0x00000080
9222 #define IB_QPS_ERROR                            0x00000100
9223 #define IB_QPS_TIME_WAIT                        0xDEAD0000      /* InfiniBand Access Layer */
9224 /*****/
9225
9226 /****d* Access Layer/ib_apm_state_t
9227 * NAME
9228 *       ib_apm_state_t
9229 *
9230 * DESCRIPTION
9231 *       The current automatic path migration state of a queue pair
9232 *
9233 * SYNOPSIS
9234 */
9235 typedef enum _ib_apm_state {
9236         IB_APM_MIGRATED = 1,
9237         IB_APM_REARM,
9238         IB_APM_ARMED
9239 } ib_apm_state_t;
9240 /*****/
9241
9242 /****s* Access Layer/ib_qp_create_t
9243 * NAME
9244 *       ib_qp_create_t
9245 *
9246 * DESCRIPTION
9247 *       Attributes used to initialize a queue pair at creation time.
9248 *
9249 * SYNOPSIS
9250 */
9251 typedef struct _ib_qp_create {
9252         ib_qp_type_t qp_type;
9253
9254         ib_rdd_handle_t h_rdd;
9255
9256         uint32_t sq_depth;
9257         uint32_t rq_depth;
9258         uint32_t sq_sge;
9259         uint32_t rq_sge;
9260
9261         ib_cq_handle_t h_sq_cq;
9262         ib_cq_handle_t h_rq_cq;
9263
9264         boolean_t sq_signaled;
9265
9266 } ib_qp_create_t;
9267 /*
9268 * FIELDS
9269 *       type
9270 *               Specifies the type of queue pair to create.
9271 *
9272 *       h_rdd
9273 *               A handle to a reliable datagram domain to associate with the queue
9274 *               pair.  This field is ignored if the queue pair is not a reliable
9275 *               datagram type queue pair.
9276 *
9277 *       sq_depth
9278 *               Indicates the requested maximum number of work requests that may be
9279 *               outstanding on the queue pair's send queue.  This value must be less
9280 *               than or equal to the maximum reported by the channel adapter associated
9281 *               with the queue pair.
9282 *
9283 *       rq_depth
9284 *               Indicates the requested maximum number of work requests that may be
9285 *               outstanding on the queue pair's receive queue.  This value must be less
9286 *               than or equal to the maximum reported by the channel adapter associated
9287 *               with the queue pair.
9288 *
9289 *       sq_sge
9290 *               Indicates the maximum number scatter-gather elements that may be
9291 *               given in a send work request.  This value must be less
9292 *               than or equal to the maximum reported by the channel adapter associated
9293 *               with the queue pair.
9294 *
9295 *       rq_sge
9296 *               Indicates the maximum number scatter-gather elements that may be
9297 *               given in a receive work request.  This value must be less
9298 *               than or equal to the maximum reported by the channel adapter associated
9299 *               with the queue pair.
9300 *
9301 *       h_sq_cq
9302 *               A handle to the completion queue that will be used to report send work
9303 *               request completions.  This handle must be NULL if the type is
9304 *               IB_QPT_MAD, IB_QPT_QP0_ALIAS, or IB_QPT_QP1_ALIAS.
9305 *
9306 *       h_rq_cq
9307 *               A handle to the completion queue that will be used to report receive
9308 *               work request completions.  This handle must be NULL if the type is
9309 *               IB_QPT_MAD, IB_QPT_QP0_ALIAS, or IB_QPT_QP1_ALIAS.
9310 *
9311 *       sq_signaled
9312 *               A flag that is used to indicate whether the queue pair will signal
9313 *               an event upon completion of a send work request.  If set to
9314 *               TRUE, send work requests will always generate a completion
9315 *               event.  If set to FALSE, a completion event will only be
9316 *               generated if the send_opt field of the send work request has the
9317 *               IB_SEND_OPT_SIGNALED flag set.
9318 *
9319 * SEE ALSO
9320 *       ib_qp_type_t, ib_qp_attr_t
9321 *****/
9322
9323 /****s* Access Layer/ib_qp_attr_t
9324 * NAME
9325 *       ib_qp_attr_t
9326 *
9327 * DESCRIPTION
9328 *       Queue pair attributes returned through ib_query_qp.
9329 *
9330 * SYNOPSIS
9331 */
9332 typedef struct _ib_qp_attr {
9333         ib_pd_handle_t h_pd;
9334         ib_qp_type_t qp_type;
9335         ib_access_t access_ctrl;
9336         uint16_t pkey_index;
9337
9338         uint32_t sq_depth;
9339         uint32_t rq_depth;
9340         uint32_t sq_sge;
9341         uint32_t rq_sge;
9342         uint8_t init_depth;
9343         uint8_t resp_res;
9344
9345         ib_cq_handle_t h_sq_cq;
9346         ib_cq_handle_t h_rq_cq;
9347         ib_rdd_handle_t h_rdd;
9348
9349         boolean_t sq_signaled;
9350
9351         ib_qp_state_t state;
9352         ib_net32_t num;
9353         ib_net32_t dest_num;
9354         ib_net32_t qkey;
9355
9356         ib_net32_t sq_psn;
9357         ib_net32_t rq_psn;
9358
9359         uint8_t primary_port;
9360         uint8_t alternate_port;
9361         ib_av_attr_t primary_av;
9362         ib_av_attr_t alternate_av;
9363         ib_apm_state_t apm_state;
9364
9365 } ib_qp_attr_t;
9366 /*
9367 * FIELDS
9368 *       h_pd
9369 *               This is a handle to a protection domain associated with the queue
9370 *               pair, or NULL if the queue pair is type IB_QPT_RELIABLE_DGRM.
9371 *
9372 * NOTES
9373 *       Other fields are defined by the Infiniband specification.
9374 *
9375 * SEE ALSO
9376 *       ib_qp_type_t, ib_access_t, ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
9377 *****/
9378
9379 /****d* Access Layer/ib_qp_opts_t
9380 * NAME
9381 *       ib_qp_opts_t
9382 *
9383 * DESCRIPTION
9384 *       Optional fields supplied in the modify QP operation.
9385 *
9386 * SYNOPSIS
9387 */
9388 typedef uint32_t ib_qp_opts_t;
9389 #define IB_MOD_QP_ALTERNATE_AV                  0x00000001
9390 #define IB_MOD_QP_PKEY                          0x00000002
9391 #define IB_MOD_QP_APM_STATE                     0x00000004
9392 #define IB_MOD_QP_PRIMARY_AV                    0x00000008
9393 #define IB_MOD_QP_RNR_NAK_TIMEOUT               0x00000010
9394 #define IB_MOD_QP_RESP_RES                      0x00000020
9395 #define IB_MOD_QP_INIT_DEPTH                    0x00000040
9396 #define IB_MOD_QP_PRIMARY_PORT                  0x00000080
9397 #define IB_MOD_QP_ACCESS_CTRL                   0x00000100
9398 #define IB_MOD_QP_QKEY                          0x00000200
9399 #define IB_MOD_QP_SQ_DEPTH                      0x00000400
9400 #define IB_MOD_QP_RQ_DEPTH                      0x00000800
9401 #define IB_MOD_QP_CURRENT_STATE                 0x00001000
9402 #define IB_MOD_QP_RETRY_CNT                     0x00002000
9403 #define IB_MOD_QP_LOCAL_ACK_TIMEOUT             0x00004000
9404 #define IB_MOD_QP_RNR_RETRY_CNT                 0x00008000
9405 /*
9406 * SEE ALSO
9407 *       ib_qp_mod_t
9408 *****/
9409
9410 /****s* Access Layer/ib_qp_mod_t
9411 * NAME
9412 *       ib_qp_mod_t
9413 *
9414 * DESCRIPTION
9415 *       Information needed to change the state of a queue pair through the
9416 *       ib_modify_qp call.
9417 *
9418 * SYNOPSIS
9419 */
9420 typedef struct _ib_qp_mod {
9421         ib_qp_state_t req_state;
9422
9423         union _qp_state {
9424                 struct _qp_reset {
9425                         /*
9426                          * Time, in milliseconds, that the QP needs to spend in
9427                          * the time wait state before being reused.
9428                          */
9429                         uint32_t timewait;
9430
9431                 } reset;
9432
9433                 struct _qp_init {
9434                         ib_qp_opts_t opts;
9435                         uint8_t primary_port;
9436                         ib_net32_t qkey;
9437                         uint16_t pkey_index;
9438                         ib_access_t access_ctrl;
9439
9440                 } init;
9441
9442                 struct _qp_rtr {
9443                         ib_net32_t rq_psn;
9444                         ib_net32_t dest_qp;
9445                         ib_av_attr_t primary_av;
9446                         uint8_t resp_res;
9447
9448                         ib_qp_opts_t opts;
9449                         ib_av_attr_t alternate_av;
9450                         ib_net32_t qkey;
9451                         uint16_t pkey_index;
9452                         ib_access_t access_ctrl;
9453                         uint32_t sq_depth;
9454                         uint32_t rq_depth;
9455                         uint8_t rnr_nak_timeout;
9456
9457                 } rtr;
9458
9459                 struct _qp_rts {
9460                         ib_net32_t sq_psn;
9461                         uint8_t retry_cnt;
9462                         uint8_t rnr_retry_cnt;
9463                         uint8_t rnr_nak_timeout;
9464                         uint8_t local_ack_timeout;
9465                         uint8_t init_depth;
9466
9467                         ib_qp_opts_t opts;
9468                         ib_qp_state_t current_state;
9469                         ib_net32_t qkey;
9470                         ib_access_t access_ctrl;
9471                         uint8_t resp_res;
9472
9473                         ib_av_attr_t primary_av;
9474                         ib_av_attr_t alternate_av;
9475
9476                         uint32_t sq_depth;
9477                         uint32_t rq_depth;
9478
9479                         ib_apm_state_t apm_state;
9480                         uint8_t primary_port;
9481                         uint16_t pkey_index;
9482
9483                 } rts;
9484
9485                 struct _qp_sqd {
9486                         boolean_t sqd_event;
9487
9488                 } sqd;
9489
9490         } state;
9491
9492 } ib_qp_mod_t;
9493 /*
9494 * SEE ALSO
9495 *       ib_qp_state_t, ib_access_t, ib_av_attr_t, ib_apm_state_t
9496 *****/
9497
9498 /****s* Access Layer/ib_eec_attr_t
9499 * NAME
9500 *       ib_eec_attr_t
9501 *
9502 * DESCRIPTION
9503 *       Information about an end-to-end context.
9504 *
9505 * SYNOPSIS
9506 */
9507 typedef struct _ib_eec_attr {
9508         ib_qp_state_t state;
9509         ib_rdd_handle_t h_rdd;
9510         ib_net32_t local_eecn;
9511
9512         ib_net32_t sq_psn;
9513         ib_net32_t rq_psn;
9514         uint8_t primary_port;
9515         uint16_t pkey_index;
9516         uint32_t resp_res;
9517         ib_net32_t remote_eecn;
9518         uint32_t init_depth;
9519         uint32_t dest_num;      // ??? What is this?
9520         ib_av_attr_t primary_av;
9521         ib_av_attr_t alternate_av;
9522         ib_apm_state_t apm_state;
9523
9524 } ib_eec_attr_t;
9525 /*
9526 * SEE ALSO
9527 *       ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
9528 *****/
9529
9530 /****d* Access Layer/ib_eec_opts_t
9531 * NAME
9532 *       ib_eec_opts_t
9533 *
9534 * DESCRIPTION
9535 *       Optional fields supplied in the modify EEC operation.
9536 *
9537 * SYNOPSIS
9538 */
9539 typedef uint32_t ib_eec_opts_t;
9540 #define IB_MOD_EEC_ALTERNATE_AV                 0x00000001
9541 #define IB_MOD_EEC_PKEY                         0x00000002
9542 #define IB_MOD_EEC_APM_STATE                    0x00000004
9543 #define IB_MOD_EEC_PRIMARY_AV                   0x00000008
9544 #define IB_MOD_EEC_RNR                          0x00000010
9545 #define IB_MOD_EEC_RESP_RES                     0x00000020
9546 #define IB_MOD_EEC_OUTSTANDING                  0x00000040
9547 #define IB_MOD_EEC_PRIMARY_PORT                 0x00000080
9548 /*
9549 * NOTES
9550 *
9551 *
9552 *****/
9553
9554 /****s* Access Layer/ib_eec_mod_t
9555 * NAME
9556 *       ib_eec_mod_t
9557 *
9558 * DESCRIPTION
9559 *       Information needed to change the state of an end-to-end context through
9560 *       the ib_modify_eec function.
9561 *
9562 * SYNOPSIS
9563 */
9564 typedef struct _ib_eec_mod {
9565         ib_qp_state_t req_state;
9566
9567         union _eec_state {
9568                 struct _eec_init {
9569                         uint8_t primary_port;
9570                         uint16_t pkey_index;
9571
9572                 } init;
9573
9574                 struct _eec_rtr {
9575                         ib_net32_t rq_psn;
9576                         ib_net32_t remote_eecn;
9577                         ib_av_attr_t primary_av;
9578                         uint8_t resp_res;
9579
9580                         ib_eec_opts_t opts;
9581                         ib_av_attr_t alternate_av;
9582                         uint16_t pkey_index;
9583
9584                 } rtr;
9585
9586                 struct _eec_rts {
9587                         ib_net32_t sq_psn;
9588                         uint8_t retry_cnt;
9589                         uint8_t rnr_retry_cnt;
9590                         uint8_t local_ack_timeout;
9591                         uint8_t init_depth;
9592
9593                         ib_eec_opts_t opts;
9594                         ib_av_attr_t alternate_av;
9595                         ib_apm_state_t apm_state;
9596
9597                         ib_av_attr_t primary_av;
9598                         uint16_t pkey_index;
9599                         uint8_t primary_port;
9600
9601                 } rts;
9602
9603                 struct _eec_sqd {
9604                         boolean_t sqd_event;
9605
9606                 } sqd;
9607
9608         } state;
9609
9610 } ib_eec_mod_t;
9611 /*
9612 * SEE ALSO
9613 *       ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
9614 *****/
9615
9616 /****d* Access Layer/ib_wr_type_t
9617 * NAME
9618 *       ib_wr_type_t
9619 *
9620 * DESCRIPTION
9621 *       Identifies the type of work request posted to a queue pair.
9622 *
9623 * SYNOPSIS
9624 */
9625 typedef enum _ib_wr_type_t {
9626         WR_SEND = 1,
9627         WR_RDMA_WRITE,
9628         WR_RDMA_READ,
9629         WR_COMPARE_SWAP,
9630         WR_FETCH_ADD
9631 } ib_wr_type_t;
9632 /*****/
9633
9634 /****s* Access Layer/ib_local_ds_t
9635 * NAME
9636 *       ib_local_ds_t
9637 *
9638 * DESCRIPTION
9639 *       Local data segment information referenced by send and receive work
9640 *       requests.  This is used to specify local data buffers used as part of a
9641 *       work request.
9642 *
9643 * SYNOPSIS
9644 */
9645 typedef struct _ib_local_ds {
9646         void *vaddr;
9647         uint32_t length;
9648         uint32_t lkey;
9649
9650 } ib_local_ds_t;
9651 /*****/
9652
9653 /****d* Access Layer/ib_send_opt_t
9654 * NAME
9655 *       ib_send_opt_t
9656 *
9657 * DESCRIPTION
9658 *       Optional flags used when posting send work requests.  These flags
9659 *       indicate specific processing for the send operation.
9660 *
9661 * SYNOPSIS
9662 */
9663 typedef uint32_t ib_send_opt_t;
9664 #define IB_SEND_OPT_IMMEDIATE           0x00000001
9665 #define IB_SEND_OPT_FENCE               0x00000002
9666 #define IB_SEND_OPT_SIGNALED            0x00000004
9667 #define IB_SEND_OPT_SOLICITED           0x00000008
9668 #define IB_SEND_OPT_INLINE              0x00000010
9669 #define IB_SEND_OPT_LOCAL               0x00000020
9670 #define IB_SEND_OPT_VEND_MASK           0xFFFF0000
9671 /*
9672 * VALUES
9673 *       The following flags determine the behavior of a work request when
9674 *       posted to the send side.
9675 *
9676 *       IB_SEND_OPT_IMMEDIATE
9677 *               Send immediate data with the given request.
9678 *
9679 *       IB_SEND_OPT_FENCE
9680 *               The operation is fenced.  Complete all pending send operations
9681 *               before processing this request.
9682 *
9683 *       IB_SEND_OPT_SIGNALED
9684 *               If the queue pair is configured for signaled completion, then
9685 *               generate a completion queue entry when this request completes.
9686 *
9687 *       IB_SEND_OPT_SOLICITED
9688 *               Set the solicited bit on the last packet of this request.
9689 *
9690 *       IB_SEND_OPT_INLINE
9691 *               Indicates that the requested send data should be copied into a VPD
9692 *               owned data buffer.  This flag permits the user to issue send operations
9693 *               without first needing to register the buffer(s) associated with the
9694 *               send operation.  Verb providers that support this operation may place
9695 *               vendor specific restrictions on the size of send operation that may
9696 *               be performed as inline.
9697 *
9698 *
9699 *  IB_SEND_OPT_LOCAL
9700 *     Indicates that a sent MAD request should be given to the local VPD for
9701 *     processing.  MADs sent using this option are not placed on the wire.
9702 *     This send option is only valid for MAD send operations.
9703 *
9704 *
9705 *       IB_SEND_OPT_VEND_MASK
9706 *               This mask indicates bits reserved in the send options that may be used
9707 *               by the verbs provider to indicate vendor specific options.  Bits set
9708 *               in this area of the send options are ignored by the Access Layer, but
9709 *               may have specific meaning to the underlying VPD.
9710 *
9711 *****/
9712
9713 /****s* Access Layer/ib_send_wr_t
9714 * NAME
9715 *       ib_send_wr_t
9716 *
9717 * DESCRIPTION
9718 *       Information used to submit a work request to the send queue of a queue
9719 *       pair.
9720 *
9721 * SYNOPSIS
9722 */
9723 typedef struct _ib_send_wr {
9724         struct _ib_send_wr *p_next;
9725         uint64_t wr_id;
9726         ib_wr_type_t wr_type;
9727         ib_send_opt_t send_opt;
9728         uint32_t num_ds;
9729         ib_local_ds_t *ds_array;
9730         ib_net32_t immediate_data;
9731
9732         union _send_dgrm {
9733                 struct _send_ud {
9734                         ib_net32_t remote_qp;
9735                         ib_net32_t remote_qkey;
9736                         ib_av_handle_t h_av;
9737
9738                 } ud;
9739
9740                 struct _send_rd {
9741                         ib_net32_t remote_qp;
9742                         ib_net32_t remote_qkey;
9743                         ib_net32_t eecn;
9744
9745                 } rd;
9746
9747                 struct _send_raw_ether {
9748                         ib_net16_t dest_lid;
9749                         uint8_t path_bits;
9750                         uint8_t sl;
9751                         uint8_t max_static_rate;
9752                         ib_net16_t ether_type;
9753
9754                 } raw_ether;
9755
9756                 struct _send_raw_ipv6 {
9757                         ib_net16_t dest_lid;
9758                         uint8_t path_bits;
9759                         uint8_t sl;
9760                         uint8_t max_static_rate;
9761
9762                 } raw_ipv6;
9763
9764         } dgrm;
9765
9766         struct _send_remote_ops {
9767                 uint64_t vaddr;
9768                 uint32_t rkey;
9769
9770                 ib_net64_t atomic1;
9771                 ib_net64_t atomic2;
9772
9773         } remote_ops;
9774
9775 } ib_send_wr_t;
9776 /*
9777 * FIELDS
9778 *       p_next
9779 *               A pointer used to chain work requests together.  This permits multiple
9780 *               work requests to be posted to a queue pair through a single function
9781 *               call.  This value is set to NULL to mark the end of the chain.
9782 *
9783 *       wr_id
9784 *               A 64-bit work request identifier that is returned to the consumer
9785 *               as part of the work completion.
9786 *
9787 *       wr_type
9788 *               The type of work request being submitted to the send queue.
9789 *
9790 *       send_opt
9791 *               Optional send control parameters.
9792 *
9793 *       num_ds
9794 *               Number of local data segments specified by this work request.
9795 *
9796 *       ds_array
9797 *               A reference to an array of local data segments used by the send
9798 *               operation.
9799 *
9800 *       immediate_data
9801 *               32-bit field sent as part of a message send or RDMA write operation.
9802 *               This field is only valid if the send_opt flag IB_SEND_OPT_IMMEDIATE
9803 *               has been set.
9804 *
9805 *       dgrm.ud.remote_qp
9806 *               Identifies the destination queue pair of an unreliable datagram send
9807 *               operation.
9808 *
9809 *       dgrm.ud.remote_qkey
9810 *               The qkey for the destination queue pair.
9811 *
9812 *       dgrm.ud.h_av
9813 *               An address vector that specifies the path information used to route
9814 *               the outbound datagram to the destination queue pair.
9815 *
9816 *       dgrm.rd.remote_qp
9817 *               Identifies the destination queue pair of a reliable datagram send
9818 *               operation.
9819 *
9820 *       dgrm.rd.remote_qkey
9821 *               The qkey for the destination queue pair.
9822 *
9823 *       dgrm.rd.eecn
9824 *               The local end-to-end context number to use with the reliable datagram
9825 *               send operation.
9826 *
9827 *       dgrm.raw_ether.dest_lid
9828 *               The destination LID that will receive this raw ether send.
9829 *
9830 *       dgrm.raw_ether.path_bits
9831 *               path bits...
9832 *
9833 *       dgrm.raw_ether.sl
9834 *               service level...
9835 *
9836 *       dgrm.raw_ether.max_static_rate
9837 *               static rate...
9838 *
9839 *       dgrm.raw_ether.ether_type
9840 *               ether type...
9841 *
9842 *       dgrm.raw_ipv6.dest_lid
9843 *               The destination LID that will receive this raw ether send.
9844 *
9845 *       dgrm.raw_ipv6.path_bits
9846 *               path bits...
9847 *
9848 *       dgrm.raw_ipv6.sl
9849 *               service level...
9850 *
9851 *       dgrm.raw_ipv6.max_static_rate
9852 *               static rate...
9853 *
9854 *       remote_ops.vaddr
9855 *               The registered virtual memory address of the remote memory to access
9856 *               with an RDMA or atomic operation.
9857 *
9858 *       remote_ops.rkey
9859 *               The rkey associated with the specified remote vaddr. This data must
9860 *               be presented exactly as obtained from the remote node. No swapping
9861 *               of data must be performed.
9862 *
9863 *       atomic1
9864 *               The first operand for an atomic operation.
9865 *
9866 *       atomic2
9867 *               The second operand for an atomic operation.
9868 *
9869 * NOTES
9870 *       The format of data sent over the fabric is user-defined and is considered
9871 *       opaque to the access layer.  The sole exception to this are MADs posted
9872 *       to a MAD QP service.  MADs are expected to match the format defined by
9873 *       the Infiniband specification and must be in network-byte order when posted
9874 *       to the MAD QP service.
9875 *
9876 * SEE ALSO
9877 *       ib_wr_type_t, ib_local_ds_t, ib_send_opt_t
9878 *****/
9879
9880 /****s* Access Layer/ib_recv_wr_t
9881 * NAME
9882 *       ib_recv_wr_t
9883 *
9884 * DESCRIPTION
9885 *       Information used to submit a work request to the receive queue of a queue
9886 *       pair.
9887 *
9888 * SYNOPSIS
9889 */
9890 typedef struct _ib_recv_wr {
9891         struct _ib_recv_wr *p_next;
9892         uint64_t wr_id;
9893         uint32_t num_ds;
9894         ib_local_ds_t *ds_array;
9895 } ib_recv_wr_t;
9896 /*
9897 * FIELDS
9898 *       p_next
9899 *               A pointer used to chain work requests together.  This permits multiple
9900 *               work requests to be posted to a queue pair through a single function
9901 *               call.  This value is set to NULL to mark the end of the chain.
9902 *
9903 *       wr_id
9904 *               A 64-bit work request identifier that is returned to the consumer
9905 *               as part of the work completion.
9906 *
9907 *       num_ds
9908 *               Number of local data segments specified by this work request.
9909 *
9910 *       ds_array
9911 *               A reference to an array of local data segments used by the send
9912 *               operation.
9913 *
9914 * SEE ALSO
9915 *       ib_local_ds_t
9916 *****/
9917
9918 /****s* Access Layer/ib_bind_wr_t
9919 * NAME
9920 *       ib_bind_wr_t
9921 *
9922 * DESCRIPTION
9923 *       Information used to submit a memory window bind work request to the send
9924 *       queue of a queue pair.
9925 *
9926 * SYNOPSIS
9927 */
9928 typedef struct _ib_bind_wr {
9929         uint64_t wr_id;
9930         ib_send_opt_t send_opt;
9931
9932         ib_mr_handle_t h_mr;
9933         ib_access_t access_ctrl;
9934         uint32_t current_rkey;
9935
9936         ib_local_ds_t local_ds;
9937
9938 } ib_bind_wr_t;
9939 /*
9940 * FIELDS
9941 *       wr_id
9942 *               A 64-bit work request identifier that is returned to the consumer
9943 *               as part of the work completion.
9944 *
9945 *       send_opt
9946 *               Optional send control parameters.
9947 *
9948 *       h_mr
9949 *               Handle to the memory region to which this window is being bound.
9950 *
9951 *       access_ctrl
9952 *               Access rights for this memory window.
9953 *
9954 *       current_rkey
9955 *               The current rkey assigned to this window for remote access.
9956 *
9957 *       local_ds
9958 *               A reference to a local data segment used by the bind operation.
9959 *
9960 * SEE ALSO
9961 *       ib_send_opt_t, ib_access_t, ib_local_ds_t
9962 *****/
9963
9964 /****d* Access Layer/ib_wc_status_t
9965 * NAME
9966 *       ib_wc_status_t
9967 *
9968 * DESCRIPTION
9969 *       Indicates the status of a completed work request.  These VALUES are
9970 *       returned to the user when retrieving completions.  Note that success is
9971 *       identified as IB_WCS_SUCCESS, which is always zero.
9972 *
9973 * SYNOPSIS
9974 */
9975 typedef enum _ib_wc_status_t {
9976         IB_WCS_SUCCESS,
9977         IB_WCS_LOCAL_LEN_ERR,
9978         IB_WCS_LOCAL_OP_ERR,
9979         IB_WCS_LOCAL_EEC_OP_ERR,
9980         IB_WCS_LOCAL_PROTECTION_ERR,
9981         IB_WCS_WR_FLUSHED_ERR,
9982         IB_WCS_MEM_WINDOW_BIND_ERR,
9983         IB_WCS_REM_ACCESS_ERR,
9984         IB_WCS_REM_OP_ERR,
9985         IB_WCS_RNR_RETRY_ERR,
9986         IB_WCS_TIMEOUT_RETRY_ERR,
9987         IB_WCS_REM_INVALID_REQ_ERR,
9988         IB_WCS_REM_INVALID_RD_REQ_ERR,
9989         IB_WCS_INVALID_EECN,
9990         IB_WCS_INVALID_EEC_STATE,
9991         IB_WCS_UNMATCHED_RESPONSE,      /* InfiniBand Access Layer */
9992         IB_WCS_CANCELED,        /* InfiniBand Access Layer */
9993         IB_WCS_UNKNOWN          /* Must be last. */
9994 } ib_wc_status_t;
9995 /*
9996 * VALUES
9997 *       IB_WCS_SUCCESS
9998 *               Work request completed successfully.
9999 *
10000 *       IB_WCS_MAD
10001 *               The completed work request was associated with a managmenet datagram
10002 *               that requires post processing.  The MAD will be returned to the user
10003 *               through a callback once all post processing has completed.
10004 *
10005 *       IB_WCS_LOCAL_LEN_ERR
10006 *               Generated for a work request posted to the send queue when the
10007 *               total of the data segment lengths exceeds the message length of the
10008 *               channel.  Generated for a work request posted to the receive queue when
10009 *               the total of the data segment lengths is too small for a
10010 *               valid incoming message.
10011 *
10012 *       IB_WCS_LOCAL_OP_ERR
10013 *               An internal QP consistency error was generated while processing this
10014 *               work request.  This may indicate that the QP was in an incorrect state
10015 *               for the requested operation.
10016 *
10017 *       IB_WCS_LOCAL_EEC_OP_ERR
10018 *               An internal EEC consistency error was generated while processing
10019 *               this work request.  This may indicate that the EEC was in an incorrect
10020 *               state for the requested operation.
10021 *
10022 *       IB_WCS_LOCAL_PROTECTION_ERR
10023 *               The data segments of the locally posted work request did not refer to
10024 *               a valid memory region.  The memory may not have been properly
10025 *               registered for the requested operation.
10026 *
10027 *       IB_WCS_WR_FLUSHED_ERR
10028 *               The work request was flushed from the QP before being completed.
10029 *
10030 *       IB_WCS_MEM_WINDOW_BIND_ERR
10031 *               A memory window bind operation failed due to insufficient access
10032 *               rights.
10033 *
10034 *       IB_WCS_REM_ACCESS_ERR,
10035 *               A protection error was detected at the remote node for a RDMA or atomic
10036 *               operation.
10037 *
10038 *       IB_WCS_REM_OP_ERR,
10039 *               The operation could not be successfully completed at the remote node.
10040 *               This may indicate that the remote QP was in an invalid state or
10041 *               contained an invalid work request.
10042 *
10043 *       IB_WCS_RNR_RETRY_ERR,
10044 *               The RNR retry count was exceeded while trying to send this message.
10045 *
10046 *       IB_WCS_TIMEOUT_RETRY_ERR
10047 *               The local transport timeout counter expired while trying to send this
10048 *               message.
10049 *
10050 *       IB_WCS_REM_INVALID_REQ_ERR,
10051 *               The remote node detected an invalid message on the channel.  This error
10052 *               is usually a result of one of the following:
10053 *                       - The operation was not supported on receive queue.
10054 *                       - There was insufficient buffers to receive a new RDMA request.
10055 *                       - There was insufficient buffers to receive a new atomic operation.
10056 *                       - An RDMA request was larger than 2^31 bytes.
10057 *
10058 *       IB_WCS_REM_INVALID_RD_REQ_ERR,
10059 *               Responder detected an invalid RD message.  This may be the result of an
10060 *               invalid qkey or an RDD mismatch.
10061 *
10062 *       IB_WCS_INVALID_EECN
10063 *               An invalid EE context number was detected.
10064 *
10065 *       IB_WCS_INVALID_EEC_STATE
10066 *               The EEC was in an invalid state for the specified request.
10067 *
10068 *       IB_WCS_UNMATCHED_RESPONSE
10069 *               A response MAD was received for which there was no matching send.  The
10070 *               send operation may have been canceled by the user or may have timed
10071 *               out.
10072 *
10073 *       IB_WCS_CANCELED
10074 *               The completed work request was canceled by the user.
10075 *****/
10076
10077 OSM_EXPORT const char *ib_wc_status_str[];
10078
10079 /****f* IBA Base: Types/ib_get_wc_status_str
10080 * NAME
10081 *       ib_get_wc_status_str
10082 *
10083 * DESCRIPTION
10084 *       Returns a string for the specified work completion status.
10085 *
10086 * SYNOPSIS
10087 */
10088 static inline const char *OSM_API
10089 ib_get_wc_status_str(IN ib_wc_status_t wc_status)
10090 {
10091         if (wc_status > IB_WCS_UNKNOWN)
10092                 wc_status = IB_WCS_UNKNOWN;
10093         return (ib_wc_status_str[wc_status]);
10094 }
10095
10096 /*
10097 * PARAMETERS
10098 *       wc_status
10099 *               [in] work completion status value
10100 *
10101 * RETURN VALUES
10102 *       Pointer to the work completion status description string.
10103 *
10104 * NOTES
10105 *
10106 * SEE ALSO
10107 *********/
10108
10109 /****d* Access Layer/ib_wc_type_t
10110 * NAME
10111 *       ib_wc_type_t
10112 *
10113 * DESCRIPTION
10114 *       Indicates the type of work completion.
10115 *
10116 * SYNOPSIS
10117 */
10118 typedef enum _ib_wc_type_t {
10119         IB_WC_SEND,
10120         IB_WC_RDMA_WRITE,
10121         IB_WC_RECV,
10122         IB_WC_RDMA_READ,
10123         IB_WC_MW_BIND,
10124         IB_WC_FETCH_ADD,
10125         IB_WC_COMPARE_SWAP,
10126         IB_WC_RECV_RDMA_WRITE
10127 } ib_wc_type_t;
10128 /*****/
10129
10130 /****d* Access Layer/ib_recv_opt_t
10131 * NAME
10132 *       ib_recv_opt_t
10133 *
10134 * DESCRIPTION
10135 *       Indicates optional fields valid in a receive work completion.
10136 *
10137 * SYNOPSIS
10138 */
10139 typedef uint32_t ib_recv_opt_t;
10140 #define IB_RECV_OPT_IMMEDIATE           0x00000001
10141 #define IB_RECV_OPT_FORWARD             0x00000002
10142 #define IB_RECV_OPT_GRH_VALID           0x00000004
10143 #define IB_RECV_OPT_VEND_MASK           0xFFFF0000
10144 /*
10145 * VALUES
10146 *       IB_RECV_OPT_IMMEDIATE
10147 *               Indicates that immediate data is valid for this work completion.
10148 *
10149 *       IB_RECV_OPT_FORWARD
10150 *               Indicates that the received trap should be forwarded to the SM.
10151 *
10152 *       IB_RECV_OPT_GRH_VALID
10153 *               Indicates presence of the global route header. When set, the
10154 *               first 40 bytes received are the GRH.
10155 *
10156 *       IB_RECV_OPT_VEND_MASK
10157 *               This mask indicates bits reserved in the receive options that may be
10158 *               used by the verbs provider to indicate vendor specific options.  Bits
10159 *               set in this area of the receive options are ignored by the Access Layer,
10160 *               but may have specific meaning to the underlying VPD.
10161 *****/
10162
10163 /****s* Access Layer/ib_wc_t
10164 * NAME
10165 *       ib_wc_t
10166 *
10167 * DESCRIPTION
10168 *       Work completion information.
10169 *
10170 * SYNOPSIS
10171 */
10172 typedef struct _ib_wc {
10173         struct _ib_wc *p_next;
10174         uint64_t wr_id;
10175         ib_wc_type_t wc_type;
10176
10177         uint32_t length;
10178         ib_wc_status_t status;
10179         uint64_t vendor_specific;
10180
10181         union _wc_recv {
10182                 struct _wc_conn {
10183                         ib_recv_opt_t recv_opt;
10184                         ib_net32_t immediate_data;
10185
10186                 } conn;
10187
10188                 struct _wc_ud {
10189                         ib_recv_opt_t recv_opt;
10190                         ib_net32_t immediate_data;
10191                         ib_net32_t remote_qp;
10192                         uint16_t pkey_index;
10193                         ib_net16_t remote_lid;
10194                         uint8_t remote_sl;
10195                         uint8_t path_bits;
10196
10197                 } ud;
10198
10199                 struct _wc_rd {
10200                         ib_net32_t remote_eecn;
10201                         ib_net32_t remote_qp;
10202                         ib_net16_t remote_lid;
10203                         uint8_t remote_sl;
10204                         uint32_t free_cnt;
10205
10206                 } rd;
10207
10208                 struct _wc_raw_ipv6 {
10209                         ib_net16_t remote_lid;
10210                         uint8_t remote_sl;
10211                         uint8_t path_bits;
10212
10213                 } raw_ipv6;
10214
10215                 struct _wc_raw_ether {
10216                         ib_net16_t remote_lid;
10217                         uint8_t remote_sl;
10218                         uint8_t path_bits;
10219                         ib_net16_t ether_type;
10220
10221                 } raw_ether;
10222
10223         } recv;
10224
10225 } ib_wc_t;
10226 /*
10227 * FIELDS
10228 *       p_next
10229 *               A pointer used to chain work completions.  This permits multiple
10230 *               work completions to be retrieved from a completion queue through a
10231 *               single function call.  This value is set to NULL to mark the end of
10232 *               the chain.
10233 *
10234 *       wr_id
10235 *               The 64-bit work request identifier that was specified when posting the
10236 *               work request.
10237 *
10238 *       wc_type
10239 *               Indicates the type of work completion.
10240 *
10241 *
10242 *       length
10243 *               The total length of the data sent or received with the work request.
10244 *
10245 *       status
10246 *               The result of the work request.
10247 *
10248 *       vendor_specific
10249 *               HCA vendor specific information returned as part of the completion.
10250 *
10251 *       recv.conn.recv_opt
10252 *               Indicates optional fields valid as part of a work request that
10253 *               completed on a connected (reliable or unreliable) queue pair.
10254 *
10255 *       recv.conn.immediate_data
10256 *               32-bit field received as part of an inbound message on a connected
10257 *               queue pair.  This field is only valid if the recv_opt flag
10258 *               IB_RECV_OPT_IMMEDIATE has been set.
10259 *
10260 *       recv.ud.recv_opt
10261 *               Indicates optional fields valid as part of a work request that
10262 *               completed on an unreliable datagram queue pair.
10263 *
10264 *       recv.ud.immediate_data
10265 *               32-bit field received as part of an inbound message on a unreliable
10266 *               datagram queue pair.  This field is only valid if the recv_opt flag
10267 *               IB_RECV_OPT_IMMEDIATE has been set.
10268 *
10269 *       recv.ud.remote_qp
10270 *               Identifies the source queue pair of a received datagram.
10271 *
10272 *       recv.ud.pkey_index
10273 *               The pkey index for the source queue pair. This is valid only for
10274 *               GSI type QP's.
10275 *
10276 *       recv.ud.remote_lid
10277 *               The source LID of the received datagram.
10278 *
10279 *       recv.ud.remote_sl
10280 *               The service level used by the source of the received datagram.
10281 *
10282 *       recv.ud.path_bits
10283 *               path bits...
10284 *
10285 *       recv.rd.remote_eecn
10286 *               The remote end-to-end context number that sent the received message.
10287 *
10288 *       recv.rd.remote_qp
10289 *               Identifies the source queue pair of a received message.
10290 *
10291 *       recv.rd.remote_lid
10292 *               The source LID of the received message.
10293 *
10294 *       recv.rd.remote_sl
10295 *               The service level used by the source of the received message.
10296 *
10297 *       recv.rd.free_cnt
10298 *               The number of available entries in the completion queue.  Reliable
10299 *               datagrams may complete out of order, so this field may be used to
10300 *               determine the number of additional completions that may occur.
10301 *
10302 *       recv.raw_ipv6.remote_lid
10303 *               The source LID of the received message.
10304 *
10305 *       recv.raw_ipv6.remote_sl
10306 *               The service level used by the source of the received message.
10307 *
10308 *       recv.raw_ipv6.path_bits
10309 *               path bits...
10310 *
10311 *       recv.raw_ether.remote_lid
10312 *               The source LID of the received message.
10313 *
10314 *       recv.raw_ether.remote_sl
10315 *               The service level used by the source of the received message.
10316 *
10317 *       recv.raw_ether.path_bits
10318 *               path bits...
10319 *
10320 *       recv.raw_ether.ether_type
10321 *               ether type...
10322 * NOTES
10323 *       When the work request completes with error, the only values that the
10324 *       consumer can depend on are the wr_id field, and the status of the
10325 *       operation.
10326 *
10327 *       If the consumer is using the same CQ for completions from more than
10328 *       one type of QP (i.e Reliable Connected, Datagram etc), then the consumer
10329 *       must have additional information to decide what fields of the union are
10330 *       valid.
10331 * SEE ALSO
10332 *       ib_wc_type_t, ib_qp_type_t, ib_wc_status_t, ib_recv_opt_t
10333 *****/
10334
10335 /****s* Access Layer/ib_mr_create_t
10336 * NAME
10337 *       ib_mr_create_t
10338 *
10339 * DESCRIPTION
10340 *       Information required to create a registered memory region.
10341 *
10342 * SYNOPSIS
10343 */
10344 typedef struct _ib_mr_create {
10345         void *vaddr;
10346         uint64_t length;
10347         ib_access_t access_ctrl;
10348 } ib_mr_create_t;
10349 /*
10350 * FIELDS
10351 *       vaddr
10352 *               Starting virtual address of the region being registered.
10353 *
10354 *       length
10355 *               Length of the buffer to register.
10356 *
10357 *       access_ctrl
10358 *               Access rights of the registered region.
10359 *
10360 * SEE ALSO
10361 *       ib_access_t
10362 *****/
10363
10364 /****s* Access Layer/ib_phys_create_t
10365 * NAME
10366 *       ib_phys_create_t
10367 *
10368 * DESCRIPTION
10369 *       Information required to create a physical memory region.
10370 *
10371 * SYNOPSIS
10372 */
10373 typedef struct _ib_phys_create {
10374         uint64_t length;
10375         uint32_t num_bufs;
10376         uint64_t *buf_array;
10377         uint32_t buf_offset;
10378         uint32_t page_size;
10379         ib_access_t access_ctrl;
10380 } ib_phys_create_t;
10381 /*
10382 *       length
10383 *               The length of the memory region in bytes.
10384 *
10385 *       num_bufs
10386 *               Number of buffers listed in the specified buffer array.
10387 *
10388 *       buf_array
10389 *               An array of physical buffers to be registered as a single memory
10390 *               region.
10391 *
10392 *       buf_offset
10393 *               The offset into the first physical page of the specified memory
10394 *               region to start the virtual address.
10395 *
10396 *       page_size
10397 *               The physical page size of the memory being registered.
10398 *
10399 *       access_ctrl
10400 *               Access rights of the registered region.
10401 *
10402 * SEE ALSO
10403 *       ib_access_t
10404 *****/
10405
10406 /****s* Access Layer/ib_mr_attr_t
10407 * NAME
10408 *       ib_mr_attr_t
10409 *
10410 * DESCRIPTION
10411 *       Attributes of a registered memory region.
10412 *
10413 * SYNOPSIS
10414 */
10415 typedef struct _ib_mr_attr {
10416         ib_pd_handle_t h_pd;
10417         void *local_lb;
10418         void *local_ub;
10419         void *remote_lb;
10420         void *remote_ub;
10421         ib_access_t access_ctrl;
10422         uint32_t lkey;
10423         uint32_t rkey;
10424 } ib_mr_attr_t;
10425 /*
10426 * DESCRIPTION
10427 *       h_pd
10428 *               Handle to the protection domain for this memory region.
10429 *
10430 *       local_lb
10431 *               The virtual address of the lower bound of protection for local
10432 *               memory access.
10433 *
10434 *       local_ub
10435 *               The virtual address of the upper bound of protection for local
10436 *               memory access.
10437 *
10438 *       remote_lb
10439 *               The virtual address of the lower bound of protection for remote
10440 *               memory access.
10441 *
10442 *       remote_ub
10443 *               The virtual address of the upper bound of protection for remote
10444 *               memory access.
10445 *
10446 *       access_ctrl
10447 *               Access rights for the specified memory region.
10448 *
10449 *       lkey
10450 *               The lkey associated with this memory region.
10451 *
10452 *       rkey
10453 *               The rkey associated with this memory region.
10454 *
10455 * NOTES
10456 *       The remote_lb, remote_ub, and rkey are only valid if remote memory access
10457 *       is enabled for this memory region.
10458 *
10459 * SEE ALSO
10460 *       ib_access_t
10461 *****/
10462
10463 /****d* Access Layer/ib_ca_mod_t
10464 * NAME
10465 *       ib_ca_mod_t -- Modify port attributes and error counters
10466 *
10467 * DESCRIPTION
10468 *       Specifies modifications to the port attributes of a channel adapter.
10469 *
10470 * SYNOPSIS
10471 */
10472 typedef uint32_t ib_ca_mod_t;
10473 #define IB_CA_MOD_IS_CM_SUPPORTED               0x00000001
10474 #define IB_CA_MOD_IS_SNMP_SUPPORTED             0x00000002
10475 #define IB_CA_MOD_IS_DEV_MGMT_SUPPORTED         0x00000004
10476 #define IB_CA_MOD_IS_VEND_SUPPORTED             0x00000008
10477 #define IB_CA_MOD_IS_SM                         0x00000010
10478 #define IB_CA_MOD_IS_SM_DISABLED                0x00000020
10479 #define IB_CA_MOD_QKEY_CTR                      0x00000040
10480 #define IB_CA_MOD_PKEY_CTR                      0x00000080
10481 #define IB_CA_MOD_IS_NOTICE_SUPPORTED           0x00000100
10482 #define IB_CA_MOD_IS_TRAP_SUPPORTED             0x00000200
10483 #define IB_CA_MOD_IS_APM_SUPPORTED              0x00000400
10484 #define IB_CA_MOD_IS_SLMAP_SUPPORTED            0x00000800
10485 #define IB_CA_MOD_IS_PKEY_NVRAM_SUPPORTED       0x00001000
10486 #define IB_CA_MOD_IS_MKEY_NVRAM_SUPPORTED       0x00002000
10487 #define IB_CA_MOD_IS_SYSGUID_SUPPORTED          0x00004000
10488 #define IB_CA_MOD_IS_DR_NOTICE_SUPPORTED        0x00008000
10489 #define IB_CA_MOD_IS_BOOT_MGMT_SUPPORTED        0x00010000
10490 #define IB_CA_MOD_IS_CAPM_NOTICE_SUPPORTED      0x00020000
10491 #define IB_CA_MOD_IS_REINIT_SUPORTED            0x00040000
10492 #define IB_CA_MOD_IS_LEDINFO_SUPPORTED          0x00080000
10493 #define IB_CA_MOD_SHUTDOWN_PORT                 0x00100000
10494 #define IB_CA_MOD_INIT_TYPE_VALUE               0x00200000
10495 #define IB_CA_MOD_SYSTEM_IMAGE_GUID             0x00400000
10496 /*
10497 * VALUES
10498 *       IB_CA_MOD_IS_CM_SUPPORTED
10499 *               Indicates if there is a communication manager accessible through
10500 *               the port.
10501 *
10502 *       IB_CA_MOD_IS_SNMP_SUPPORTED
10503 *               Indicates if there is an SNMP agent accessible through the port.
10504 *
10505 *       IB_CA_MOD_IS_DEV_MGMT_SUPPORTED
10506 *               Indicates if there is a device management agent accessible
10507 *               through the port.
10508 *
10509 *       IB_CA_MOD_IS_VEND_SUPPORTED
10510 *               Indicates if there is a vendor supported agent accessible
10511 *               through the port.
10512 *
10513 *       IB_CA_MOD_IS_SM
10514 *               Indicates if there is a subnet manager accessible through
10515 *               the port.
10516 *
10517 *       IB_CA_MOD_IS_SM_DISABLED
10518 *               Indicates if the port has been disabled for configuration by the
10519 *               subnet manager.
10520 *
10521 *       IB_CA_MOD_QKEY_CTR
10522 *               Used to reset the qkey violation counter associated with the
10523 *               port.
10524 *
10525 *       IB_CA_MOD_PKEY_CTR
10526 *               Used to reset the pkey violation counter associated with the
10527 *               port.
10528 *
10529 *       IB_CA_MOD_IS_NOTICE_SUPPORTED
10530 *               Indicates that this CA supports ability to generate Notices for
10531 *               Port State changes. (only applicable to switches)
10532 *
10533 *       IB_CA_MOD_IS_TRAP_SUPPORTED
10534 *               Indicates that this management port supports ability to generate
10535 *               trap messages. (only applicable to switches)
10536 *
10537 *       IB_CA_MOD_IS_APM_SUPPORTED
10538 *               Indicates that this port is capable of performing Automatic
10539 *               Path Migration.
10540 *
10541 *       IB_CA_MOD_IS_SLMAP_SUPPORTED
10542 *               Indicates this port supports SLMAP capability.
10543 *
10544 *       IB_CA_MOD_IS_PKEY_NVRAM_SUPPORTED
10545 *               Indicates that PKEY is supported in NVRAM
10546 *
10547 *       IB_CA_MOD_IS_MKEY_NVRAM_SUPPORTED
10548 *               Indicates that MKEY is supported in NVRAM
10549 *
10550 *       IB_CA_MOD_IS_SYSGUID_SUPPORTED
10551 *               Indicates System Image GUID support.
10552 *
10553 *       IB_CA_MOD_IS_DR_NOTICE_SUPPORTED
10554 *               Indicate support for generating Direct Routed Notices
10555 *
10556 *       IB_CA_MOD_IS_BOOT_MGMT_SUPPORTED
10557 *               Indicates support for Boot Management
10558 *
10559 *       IB_CA_MOD_IS_CAPM_NOTICE_SUPPORTED
10560 *               Indicates capability to generate notices for changes to CAPMASK
10561 *
10562 *       IB_CA_MOD_IS_REINIT_SUPORTED
10563 *               Indicates type of node init supported. Refer to Chapter 14 for
10564 *               Initialization actions.
10565 *
10566 *       IB_CA_MOD_IS_LEDINFO_SUPPORTED
10567 *               Indicates support for LED info.
10568 *
10569 *       IB_CA_MOD_SHUTDOWN_PORT
10570 *               Used to modify the port active indicator.
10571 *
10572 *       IB_CA_MOD_INIT_TYPE_VALUE
10573 *               Used to modify the init_type value for the port.
10574 *
10575 *       IB_CA_MOD_SYSTEM_IMAGE_GUID
10576 *               Used to modify the system image GUID for the port.
10577 *****/
10578
10579 /****d* Access Layer/ib_mr_mod_t
10580 * NAME
10581 *       ib_mr_mod_t
10582 *
10583 * DESCRIPTION
10584 *       Mask used to specify which attributes of a registered memory region are
10585 *       being modified.
10586 *
10587 * SYNOPSIS
10588 */
10589 typedef uint32_t ib_mr_mod_t;
10590 #define IB_MR_MOD_ADDR                                  0x00000001
10591 #define IB_MR_MOD_PD                                    0x00000002
10592 #define IB_MR_MOD_ACCESS                                0x00000004
10593 /*
10594 * PARAMETERS
10595 *       IB_MEM_MOD_ADDR
10596 *               The address of the memory region is being modified.
10597 *
10598 *       IB_MEM_MOD_PD
10599 *               The protection domain associated with the memory region is being
10600 *               modified.
10601 *
10602 *       IB_MEM_MOD_ACCESS
10603 *               The access rights the memory region are being modified.
10604 *****/
10605
10606 /****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_HANDOVER
10607 * NAME
10608 *       IB_SMINFO_ATTR_MOD_HANDOVER
10609 *
10610 * DESCRIPTION
10611 *       Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
10612 *
10613 * SOURCE
10614 */
10615 #define IB_SMINFO_ATTR_MOD_HANDOVER             (CL_HTON32(0x000001))
10616 /**********/
10617
10618 /****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_ACKNOWLEDGE
10619 * NAME
10620 *       IB_SMINFO_ATTR_MOD_ACKNOWLEDGE
10621 *
10622 * DESCRIPTION
10623 *       Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
10624 *
10625 * SOURCE
10626 */
10627 #define IB_SMINFO_ATTR_MOD_ACKNOWLEDGE          (CL_HTON32(0x000002))
10628 /**********/
10629
10630 /****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_DISABLE
10631 * NAME
10632 *       IB_SMINFO_ATTR_MOD_DISABLE
10633 *
10634 * DESCRIPTION
10635 *       Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
10636 *
10637 * SOURCE
10638 */
10639 #define IB_SMINFO_ATTR_MOD_DISABLE                      (CL_HTON32(0x000003))
10640 /**********/
10641
10642 /****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_STANDBY
10643 * NAME
10644 *       IB_SMINFO_ATTR_MOD_STANDBY
10645 *
10646 * DESCRIPTION
10647 *       Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
10648 *
10649 * SOURCE
10650 */
10651 #define IB_SMINFO_ATTR_MOD_STANDBY                      (CL_HTON32(0x000004))
10652 /**********/
10653
10654 /****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_DISCOVER
10655 * NAME
10656 *       IB_SMINFO_ATTR_MOD_DISCOVER
10657 *
10658 * DESCRIPTION
10659 *       Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
10660 *
10661 * SOURCE
10662 */
10663 #define IB_SMINFO_ATTR_MOD_DISCOVER                     (CL_HTON32(0x000005))
10664 /**********/
10665
10666 /****s* Access Layer/ib_ci_op_t
10667 * NAME
10668 *       ib_ci_op_t
10669 *
10670 * DESCRIPTION
10671 *       A structure used for vendor specific CA interface communication.
10672 *
10673 * SYNOPSIS
10674 */
10675 typedef struct _ib_ci_op {
10676         IN uint32_t command;
10677         IN OUT void *p_buf OPTIONAL;
10678         IN uint32_t buf_size;
10679         IN OUT uint32_t num_bytes_ret;
10680         IN OUT int32_t status;
10681
10682 } ib_ci_op_t;
10683 /*
10684 * FIELDS
10685 *       command
10686 *               A command code that is understood by the verbs provider.
10687 *
10688 *       p_buf
10689 *               A reference to a buffer containing vendor specific data.  The verbs
10690 *               provider must not access pointers in the p_buf between user-mode and
10691 *               kernel-mode.  Any pointers embedded in the p_buf are invalidated by
10692 *               the user-mode/kernel-mode transition.
10693 *
10694 *       buf_size
10695 *               The size of the buffer in bytes.
10696 *
10697 *       num_bytes_ret
10698 *               The size in bytes of the vendor specific data returned in the buffer.
10699 *               This field is set by the verbs provider.  The verbs provider should
10700 *               verify that the buffer size is sufficient to hold the data being
10701 *               returned.
10702 *
10703 *       status
10704 *               The completion status from the verbs provider.  This field should be
10705 *               initialize to indicate an error to allow detection and cleanup in
10706 *               case a communication error occurs between user-mode and kernel-mode.
10707 *
10708 * NOTES
10709 *       This structure is provided to allow the exchange of vendor specific
10710 *       data between the originator and the verbs provider.  Users of this
10711 *       structure are expected to know the format of data in the p_buf based
10712 *       on the structure command field or the usage context.
10713 *****/
10714
10715 END_C_DECLS
10716 #endif                          /* ndef WIN32 */
10717 #if defined( __WIN__ )
10718 #include <iba/ib_types_extended.h>
10719 #endif
10720 #endif                          /* __IB_TYPES_H__ */