]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ofed/management/opensm/opensm/osm_helper.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ofed / management / opensm / opensm / osm_helper.c
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 /*
37  * Abstract:
38  *    Implementation of opensm helper functions.
39  */
40
41 #if HAVE_CONFIG_H
42 #  include <config.h>
43 #endif                          /* HAVE_CONFIG_H */
44
45 #include <stdlib.h>
46 #include <stdio.h>
47 #include <string.h>
48 #include <arpa/inet.h>
49 #include <sys/socket.h>
50 #include <complib/cl_debug.h>
51 #include <iba/ib_types.h>
52 #include <opensm/osm_helper.h>
53 #include <opensm/osm_log.h>
54
55 #define LINE_LENGTH 256
56
57 #define ARR_SIZE(a) (sizeof(a)/sizeof((a)[0]))
58
59 /* we use two tables - one for queries and one for responses */
60 static const char *const __ib_sa_method_str[] = {
61         "RESERVED",             /* 0 */
62         "SubnAdmGet",           /* 1 */
63         "SubnAdmSet",           /* 2 */
64         "RESERVED",             /* 3 */
65         "RESERVED",             /* 4 */
66         "RESERVED",             /* 5 */
67         "SubnAdmReport",        /* 6 */
68         "RESERVED",             /* 7 */
69         "RESERVED",             /* 8 */
70         "RESERVED",             /* 9 */
71         "RESERVED",             /* A */
72         "RESERVED",             /* B */
73         "RESERVED",             /* C */
74         "RESERVED",             /* D */
75         "RESERVED",             /* E */
76         "RESERVED",             /* F */
77         "RESERVED",             /* 10 */
78         "RESERVED",             /* 11 */
79         "SubnAdmGetTable",      /* 12 */
80         "SubnAdmGetTraceTable", /* 13 */
81         "SubnAdmGetMulti",      /* 14 */
82         "SubnAdmDelete",        /* 15 */
83         "UNKNOWN"               /* 16 */
84 };
85
86 static const char *const __ib_sa_resp_method_str[] = {
87         "RESERVED",             /* 80 */
88         "SubnAdmGetResp",       /* 81 */
89         "RESERVED (SetResp?)",  /* 82 */
90         "RESERVED",             /* 83 */
91         "RESERVED",             /* 84 */
92         "RESERVED",             /* 85 */
93         "SubnAdmReportResp",    /* 86 */
94         "RESERVED",             /* 87 */
95         "RESERVED",             /* 88 */
96         "RESERVED",             /* 89 */
97         "RESERVED",             /* 8A */
98         "RESERVED",             /* 8B */
99         "RESERVED",             /* 8C */
100         "RESERVED",             /* 8D */
101         "RESERVED",             /* 8E */
102         "RESERVED",             /* 8F */
103         "RESERVED",             /* 90 */
104         "RESERVED",             /* 91 */
105         "SubnAdmGetTableResp",  /* 92 */
106         "RESERVED",             /* 93 */
107         "SubnAdmGetMultiResp",  /* 94 */
108         "SubnAdmDeleteResp",    /* 95 */
109         "UNKNOWN"
110 };
111
112 #define OSM_SA_METHOD_STR_UNKNOWN_VAL 0x16
113
114 static const char *const __ib_sm_method_str[] = {
115         "RESERVED0",            /* 0 */
116         "SubnGet",              /* 1 */
117         "SubnSet",              /* 2 */
118         "RESERVED3",            /* 3 */
119         "RESERVED4",            /* 4 */
120         "SubnTrap",             /* 5 */
121         "RESERVED6",            /* 6 */
122         "SubnTrapRepress",      /* 7 */
123         "RESERVED8",            /* 8 */
124         "RESERVED9",            /* 9 */
125         "RESERVEDA",            /* A */
126         "RESERVEDB",            /* B */
127         "RESERVEDC",            /* C */
128         "RESERVEDD",            /* D */
129         "RESERVEDE",            /* E */
130         "RESERVEDF",            /* F */
131         "RESERVED10",           /* 10 */
132         "SubnGetResp",          /* 11 */
133         "RESERVED12",           /* 12 */
134         "RESERVED13",           /* 13 */
135         "RESERVED14",           /* 14 */
136         "RESERVED15",           /* 15 */
137         "RESERVED16",           /* 16 */
138         "RESERVED17",           /* 17 */
139         "RESERVED18",           /* 18 */
140         "RESERVED19",           /* 19 */
141         "RESERVED1A",           /* 1A */
142         "RESERVED1B",           /* 1B */
143         "RESERVED1C",           /* 1C */
144         "RESERVED1D",           /* 1D */
145         "RESERVED1E",           /* 1E */
146         "RESERVED1F",           /* 1F */
147         "UNKNOWN"               /* 20 */
148 };
149
150 #define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x21
151
152 static const char *const __ib_sm_attr_str[] = {
153         "RESERVED",             /* 0 */
154         "ClassPortInfo",        /* 1 */
155         "Notice",               /* 2 */
156         "InformInfo",           /* 3 */
157         "RESERVED",             /* 4 */
158         "RESERVED",             /* 5 */
159         "RESERVED",             /* 6 */
160         "RESERVED",             /* 7 */
161         "RESERVED",             /* 8 */
162         "RESERVED",             /* 9 */
163         "RESERVED",             /* A */
164         "RESERVED",             /* B */
165         "RESERVED",             /* C */
166         "RESERVED",             /* D */
167         "RESERVED",             /* E */
168         "RESERVED",             /* F */
169         "NodeDescription",      /* 10 */
170         "NodeInfo",             /* 11 */
171         "SwitchInfo",           /* 12 */
172         "UNKNOWN",              /* 13 */
173         "GUIDInfo",             /* 14 */
174         "PortInfo",             /* 15 */
175         "P_KeyTable",           /* 16 */
176         "SLtoVLMappingTable",   /* 17 */
177         "VLArbitrationTable",   /* 18 */
178         "LinearForwardingTable",        /* 19 */
179         "RandomForwardingTable",        /* 1A */
180         "MulticastForwardingTable",     /* 1B */
181         "UNKNOWN",              /* 1C */
182         "UNKNOWN",              /* 1D */
183         "UNKNOWN",              /* 1E */
184         "UNKNOWN",              /* 1F */
185         "SMInfo",               /* 20 */
186         "UNKNOWN"               /* 21 - always highest value */
187 };
188
189 #define OSM_SM_ATTR_STR_UNKNOWN_VAL 0x21
190
191 static const char *const __ib_sa_attr_str[] = {
192         "RESERVED",             /* 0 */
193         "ClassPortInfo",        /* 1 */
194         "Notice",               /* 2 */
195         "InformInfo",           /* 3 */
196         "RESERVED",             /* 4 */
197         "RESERVED",             /* 5 */
198         "RESERVED",             /* 6 */
199         "RESERVED",             /* 7 */
200         "RESERVED",             /* 8 */
201         "RESERVED",             /* 9 */
202         "RESERVED",             /* A */
203         "RESERVED",             /* B */
204         "RESERVED",             /* C */
205         "RESERVED",             /* D */
206         "RESERVED",             /* E */
207         "RESERVED",             /* F */
208         "RESERVED",             /* 10 */
209         "NodeRecord",           /* 11 */
210         "PortInfoRecord",       /* 12 */
211         "SLtoVLMappingTableRecord",     /* 13 */
212         "SwitchInfoRecord",     /* 14 */
213         "LinearForwardingTableRecord",  /* 15 */
214         "RandomForwardingTableRecord",  /* 16 */
215         "MulticastForwardingTableRecord",       /* 17 */
216         "SMInfoRecord",         /* 18 */
217         "RESERVED",             /* 19 */
218         "RandomForwardingTable",        /* 1A */
219         "MulticastForwardingTable",     /* 1B */
220         "UNKNOWN",              /* 1C */
221         "UNKNOWN",              /* 1D */
222         "UNKNOWN",              /* 1E */
223         "UNKNOWN",              /* 1F */
224         "LinkRecord",           /* 20 */
225         "UNKNOWN",              /* 21 */
226         "UNKNOWN",              /* 22 */
227         "UNKNOWN",              /* 23 */
228         "UNKNOWN",              /* 24 */
229         "UNKNOWN",              /* 25 */
230         "UNKNOWN",              /* 26 */
231         "UNKNOWN",              /* 27 */
232         "UNKNOWN",              /* 28 */
233         "UNKNOWN",              /* 29 */
234         "UNKNOWN",              /* 2A */
235         "UNKNOWN",              /* 2B */
236         "UNKNOWN",              /* 2C */
237         "UNKNOWN",              /* 2D */
238         "UNKNOWN",              /* 2E */
239         "UNKNOWN",              /* 2F */
240         "GuidInfoRecord",       /* 30 */
241         "ServiceRecord",        /* 31 */
242         "UNKNOWN",              /* 32 */
243         "P_KeyTableRecord",     /* 33 */
244         "UNKNOWN",              /* 34 */
245         "PathRecord",           /* 35 */
246         "VLArbitrationTableRecord",     /* 36 */
247         "UNKNOWN",              /* 37 */
248         "MCMemberRecord",       /* 38 */
249         "TraceRecord",          /* 39 */
250         "MultiPathRecord",      /* 3A */
251         "ServiceAssociationRecord",     /* 3B */
252         "UNKNOWN",              /* 3C */
253         "UNKNOWN",              /* 3D */
254         "UNKNOWN",              /* 3E */
255         "UNKNOWN",              /* 3F */
256         "UNKNOWN",              /* 40 */
257         "UNKNOWN",              /* 41 */
258         "UNKNOWN",              /* 42 */
259         "UNKNOWN",              /* 43 */
260         "UNKNOWN",              /* 44 */
261         "UNKNOWN",              /* 45 */
262         "UNKNOWN",              /* 46 */
263         "UNKNOWN",              /* 47 */
264         "UNKNOWN",              /* 48 */
265         "UNKNOWN",              /* 49 */
266         "UNKNOWN",              /* 4A */
267         "UNKNOWN",              /* 4B */
268         "UNKNOWN",              /* 4C */
269         "UNKNOWN",              /* 4D */
270         "UNKNOWN",              /* 4E */
271         "UNKNOWN",              /* 4F */
272         "UNKNOWN",              /* 50 */
273         "UNKNOWN",              /* 51 */
274         "UNKNOWN",              /* 52 */
275         "UNKNOWN",              /* 53 */
276         "UNKNOWN",              /* 54 */
277         "UNKNOWN",              /* 55 */
278         "UNKNOWN",              /* 56 */
279         "UNKNOWN",              /* 57 */
280         "UNKNOWN",              /* 58 */
281         "UNKNOWN",              /* 59 */
282         "UNKNOWN",              /* 5A */
283         "UNKNOWN",              /* 5B */
284         "UNKNOWN",              /* 5C */
285         "UNKNOWN",              /* 5D */
286         "UNKNOWN",              /* 5E */
287         "UNKNOWN",              /* 5F */
288         "UNKNOWN",              /* 60 */
289         "UNKNOWN",              /* 61 */
290         "UNKNOWN",              /* 62 */
291         "UNKNOWN",              /* 63 */
292         "UNKNOWN",              /* 64 */
293         "UNKNOWN",              /* 65 */
294         "UNKNOWN",              /* 66 */
295         "UNKNOWN",              /* 67 */
296         "UNKNOWN",              /* 68 */
297         "UNKNOWN",              /* 69 */
298         "UNKNOWN",              /* 6A */
299         "UNKNOWN",              /* 6B */
300         "UNKNOWN",              /* 6C */
301         "UNKNOWN",              /* 6D */
302         "UNKNOWN",              /* 6E */
303         "UNKNOWN",              /* 6F */
304         "UNKNOWN",              /* 70 */
305         "UNKNOWN",              /* 71 */
306         "UNKNOWN",              /* 72 */
307         "UNKNOWN",              /* 73 */
308         "UNKNOWN",              /* 74 */
309         "UNKNOWN",              /* 75 */
310         "UNKNOWN",              /* 76 */
311         "UNKNOWN",              /* 77 */
312         "UNKNOWN",              /* 78 */
313         "UNKNOWN",              /* 79 */
314         "UNKNOWN",              /* 7A */
315         "UNKNOWN",              /* 7B */
316         "UNKNOWN",              /* 7C */
317         "UNKNOWN",              /* 7D */
318         "UNKNOWN",              /* 7E */
319         "UNKNOWN",              /* 7F */
320         "UNKNOWN",              /* 80 */
321         "UNKNOWN",              /* 81 */
322         "UNKNOWN",              /* 82 */
323         "UNKNOWN",              /* 83 */
324         "UNKNOWN",              /* 84 */
325         "UNKNOWN",              /* 85 */
326         "UNKNOWN",              /* 86 */
327         "UNKNOWN",              /* 87 */
328         "UNKNOWN",              /* 88 */
329         "UNKNOWN",              /* 89 */
330         "UNKNOWN",              /* 8A */
331         "UNKNOWN",              /* 8B */
332         "UNKNOWN",              /* 8C */
333         "UNKNOWN",              /* 8D */
334         "UNKNOWN",              /* 8E */
335         "UNKNOWN",              /* 8F */
336         "UNKNOWN",              /* 90 */
337         "UNKNOWN",              /* 91 */
338         "UNKNOWN",              /* 92 */
339         "UNKNOWN",              /* 93 */
340         "UNKNOWN",              /* 94 */
341         "UNKNOWN",              /* 95 */
342         "UNKNOWN",              /* 96 */
343         "UNKNOWN",              /* 97 */
344         "UNKNOWN",              /* 98 */
345         "UNKNOWN",              /* 99 */
346         "UNKNOWN",              /* 9A */
347         "UNKNOWN",              /* 9B */
348         "UNKNOWN",              /* 9C */
349         "UNKNOWN",              /* 9D */
350         "UNKNOWN",              /* 9E */
351         "UNKNOWN",              /* 9F */
352         "UNKNOWN",              /* A0 */
353         "UNKNOWN",              /* A1 */
354         "UNKNOWN",              /* A2 */
355         "UNKNOWN",              /* A3 */
356         "UNKNOWN",              /* A4 */
357         "UNKNOWN",              /* A5 */
358         "UNKNOWN",              /* A6 */
359         "UNKNOWN",              /* A7 */
360         "UNKNOWN",              /* A8 */
361         "UNKNOWN",              /* A9 */
362         "UNKNOWN",              /* AA */
363         "UNKNOWN",              /* AB */
364         "UNKNOWN",              /* AC */
365         "UNKNOWN",              /* AD */
366         "UNKNOWN",              /* AE */
367         "UNKNOWN",              /* AF */
368         "UNKNOWN",              /* B0 */
369         "UNKNOWN",              /* B1 */
370         "UNKNOWN",              /* B2 */
371         "UNKNOWN",              /* B3 */
372         "UNKNOWN",              /* B4 */
373         "UNKNOWN",              /* B5 */
374         "UNKNOWN",              /* B6 */
375         "UNKNOWN",              /* B7 */
376         "UNKNOWN",              /* B8 */
377         "UNKNOWN",              /* B9 */
378         "UNKNOWN",              /* BA */
379         "UNKNOWN",              /* BB */
380         "UNKNOWN",              /* BC */
381         "UNKNOWN",              /* BD */
382         "UNKNOWN",              /* BE */
383         "UNKNOWN",              /* BF */
384         "UNKNOWN",              /* C0 */
385         "UNKNOWN",              /* C1 */
386         "UNKNOWN",              /* C2 */
387         "UNKNOWN",              /* C3 */
388         "UNKNOWN",              /* C4 */
389         "UNKNOWN",              /* C5 */
390         "UNKNOWN",              /* C6 */
391         "UNKNOWN",              /* C7 */
392         "UNKNOWN",              /* C8 */
393         "UNKNOWN",              /* C9 */
394         "UNKNOWN",              /* CA */
395         "UNKNOWN",              /* CB */
396         "UNKNOWN",              /* CC */
397         "UNKNOWN",              /* CD */
398         "UNKNOWN",              /* CE */
399         "UNKNOWN",              /* CF */
400         "UNKNOWN",              /* D0 */
401         "UNKNOWN",              /* D1 */
402         "UNKNOWN",              /* D2 */
403         "UNKNOWN",              /* D3 */
404         "UNKNOWN",              /* D4 */
405         "UNKNOWN",              /* D5 */
406         "UNKNOWN",              /* D6 */
407         "UNKNOWN",              /* D7 */
408         "UNKNOWN",              /* D8 */
409         "UNKNOWN",              /* D9 */
410         "UNKNOWN",              /* DA */
411         "UNKNOWN",              /* DB */
412         "UNKNOWN",              /* DC */
413         "UNKNOWN",              /* DD */
414         "UNKNOWN",              /* DE */
415         "UNKNOWN",              /* DF */
416         "UNKNOWN",              /* E0 */
417         "UNKNOWN",              /* E1 */
418         "UNKNOWN",              /* E2 */
419         "UNKNOWN",              /* E3 */
420         "UNKNOWN",              /* E4 */
421         "UNKNOWN",              /* E5 */
422         "UNKNOWN",              /* E6 */
423         "UNKNOWN",              /* E7 */
424         "UNKNOWN",              /* E8 */
425         "UNKNOWN",              /* E9 */
426         "UNKNOWN",              /* EA */
427         "UNKNOWN",              /* EB */
428         "UNKNOWN",              /* EC */
429         "UNKNOWN",              /* ED */
430         "UNKNOWN",              /* EE */
431         "UNKNOWN",              /* EF */
432         "UNKNOWN",              /* F0 */
433         "UNKNOWN",              /* F1 */
434         "UNKNOWN",              /* F2 */
435         "InformInfoRecord",     /* F3 */
436         "UNKNOWN"               /* F4 - always highest value */
437 };
438
439 #define OSM_SA_ATTR_STR_UNKNOWN_VAL 0xF4
440
441 /**********************************************************************
442  **********************************************************************/
443 const char *ib_get_sa_method_str(IN uint8_t method)
444 {
445         if (method & 0x80) {
446                 method = method & 0x7f;
447                 if (method >= OSM_SA_METHOD_STR_UNKNOWN_VAL)
448                         method = OSM_SA_METHOD_STR_UNKNOWN_VAL;
449                 /* it is a response - use the response table */
450                 return (__ib_sa_resp_method_str[method]);
451         } else {
452                 if (method >= OSM_SA_METHOD_STR_UNKNOWN_VAL)
453                         method = OSM_SA_METHOD_STR_UNKNOWN_VAL;
454                 return (__ib_sa_method_str[method]);
455         }
456 }
457
458 /**********************************************************************
459  **********************************************************************/
460 const char *ib_get_sm_method_str(IN uint8_t method)
461 {
462         if (method & 0x80)
463                 method = (method & 0x0F) | 0x10;
464         if (method >= OSM_SM_METHOD_STR_UNKNOWN_VAL)
465                 method = OSM_SM_METHOD_STR_UNKNOWN_VAL;
466         return (__ib_sm_method_str[method]);
467 }
468
469 /**********************************************************************
470  **********************************************************************/
471 const char *ib_get_sm_attr_str(IN ib_net16_t attr)
472 {
473         uint16_t host_attr;
474         host_attr = cl_ntoh16(attr);
475
476         if (host_attr >= OSM_SM_ATTR_STR_UNKNOWN_VAL)
477                 host_attr = OSM_SM_ATTR_STR_UNKNOWN_VAL;
478
479         return (__ib_sm_attr_str[host_attr]);
480 }
481
482 /**********************************************************************
483  **********************************************************************/
484 const char *ib_get_sa_attr_str(IN ib_net16_t attr)
485 {
486         uint16_t host_attr;
487         host_attr = cl_ntoh16(attr);
488
489         if (host_attr >= OSM_SA_ATTR_STR_UNKNOWN_VAL)
490                 host_attr = OSM_SA_ATTR_STR_UNKNOWN_VAL;
491
492         return (__ib_sa_attr_str[host_attr]);
493 }
494
495 /**********************************************************************
496  **********************************************************************/
497 const char *ib_get_trap_str(ib_net16_t trap_num)
498 {
499         switch(cl_ntoh16(trap_num))
500         {
501                 case 64:
502                         return "GID in service";
503                 case 65:
504                         return "GID out of service";
505                 case 66:
506                         return "New mcast group created";
507                 case 67:
508                         return "Mcast group deleted";
509                 case 68:
510                         return "UnPath, Path no longer valid";
511                 case 69:
512                         return "RePath, Path recomputed";
513                 case 128:
514                         return "Link state change";
515                 case 129:
516                         return "Local Link integrity threshold reached";
517                 case 130:
518                         return "Excessive Buffer Overrun Threshold reached";
519                 case 131:
520                         return "Flow Control Update watchdog timer expired";
521                 case 144:
522                         return "CapabilityMask, NodeDescription, Link [Width|Speed] Enabled changed";
523                 case 145:
524                         return "System Image GUID changed";
525                 case 256:
526                         return "Bad M_Key";
527                 case 257:
528                         return "Bad P_Key";
529                 case 258:
530                         return "Bad Q_Key";
531                 case 259:
532                         return "Bad P_Key (switch external port)";
533                 default:
534                         break;
535         }
536         return "Unknown";
537 }
538
539 /**********************************************************************
540  **********************************************************************/
541 static ib_api_status_t
542 dbg_do_line(IN char **pp_local,
543             IN const uint32_t buf_size,
544             IN const char *const p_prefix_str,
545             IN const char *const p_new_str, IN uint32_t * const p_total_len)
546 {
547         char line[LINE_LENGTH];
548         uint32_t len;
549
550         sprintf(line, "%s%s", p_prefix_str, p_new_str);
551         len = (uint32_t) strlen(line);
552         *p_total_len += len;
553         if (*p_total_len + sizeof('\0') > buf_size)
554                 return (IB_INSUFFICIENT_MEMORY);
555
556         strcpy(*pp_local, line);
557         *pp_local += len;
558         return (IB_SUCCESS);
559 }
560
561 /**********************************************************************
562  **********************************************************************/
563 static void
564 dbg_get_capabilities_str(IN char *p_buf,
565                          IN const uint32_t buf_size,
566                          IN const char *const p_prefix_str,
567                          IN const ib_port_info_t * const p_pi)
568 {
569         uint32_t total_len = 0;
570         char *p_local = p_buf;
571
572         strcpy(p_local, "Capability Mask:\n");
573         p_local += strlen(p_local);
574
575         if (p_pi->capability_mask & IB_PORT_CAP_RESV0) {
576                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
577                                 "IB_PORT_CAP_RESV0\n",
578                                 &total_len) != IB_SUCCESS)
579                         return;
580         }
581         if (p_pi->capability_mask & IB_PORT_CAP_IS_SM) {
582                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
583                                 "IB_PORT_CAP_IS_SM\n",
584                                 &total_len) != IB_SUCCESS)
585                         return;
586         }
587         if (p_pi->capability_mask & IB_PORT_CAP_HAS_NOTICE) {
588                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
589                                 "IB_PORT_CAP_HAS_NOTICE\n",
590                                 &total_len) != IB_SUCCESS)
591                         return;
592         }
593         if (p_pi->capability_mask & IB_PORT_CAP_HAS_TRAP) {
594                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
595                                 "IB_PORT_CAP_HAS_TRAP\n",
596                                 &total_len) != IB_SUCCESS)
597                         return;
598         }
599         if (p_pi->capability_mask & IB_PORT_CAP_HAS_IPD) {
600                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
601                                 "IB_PORT_CAP_HAS_IPD\n",
602                                 &total_len) != IB_SUCCESS)
603                         return;
604         }
605         if (p_pi->capability_mask & IB_PORT_CAP_HAS_AUTO_MIG) {
606                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
607                                 "IB_PORT_CAP_HAS_AUTO_MIG\n",
608                                 &total_len) != IB_SUCCESS)
609                         return;
610         }
611         if (p_pi->capability_mask & IB_PORT_CAP_HAS_SL_MAP) {
612                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
613                                 "IB_PORT_CAP_HAS_SL_MAP\n",
614                                 &total_len) != IB_SUCCESS)
615                         return;
616         }
617         if (p_pi->capability_mask & IB_PORT_CAP_HAS_NV_MKEY) {
618                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
619                                 "IB_PORT_CAP_HAS_NV_MKEY\n",
620                                 &total_len) != IB_SUCCESS)
621                         return;
622         }
623         if (p_pi->capability_mask & IB_PORT_CAP_HAS_NV_PKEY) {
624                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
625                                 "IB_PORT_CAP_HAS_NV_PKEY\n",
626                                 &total_len) != IB_SUCCESS)
627                         return;
628         }
629         if (p_pi->capability_mask & IB_PORT_CAP_HAS_LED_INFO) {
630                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
631                                 "IB_PORT_CAP_HAS_LED_INFO\n",
632                                 &total_len) != IB_SUCCESS)
633                         return;
634         }
635         if (p_pi->capability_mask & IB_PORT_CAP_SM_DISAB) {
636                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
637                                 "IB_PORT_CAP_SM_DISAB\n",
638                                 &total_len) != IB_SUCCESS)
639                         return;
640         }
641         if (p_pi->capability_mask & IB_PORT_CAP_HAS_SYS_IMG_GUID) {
642                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
643                                 "IB_PORT_CAP_HAS_SYS_IMG_GUID\n",
644                                 &total_len) != IB_SUCCESS)
645                         return;
646         }
647         if (p_pi->capability_mask & IB_PORT_CAP_HAS_PKEY_SW_EXT_PORT_TRAP) {
648                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
649                                 "IB_PORT_CAP_PKEY_SW_EXT_PORT_TRAP\n",
650                                 &total_len) != IB_SUCCESS)
651                         return;
652         }
653         if (p_pi->capability_mask & IB_PORT_CAP_RESV13) {
654                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
655                                 "IB_PORT_CAP_RESV13\n",
656                                 &total_len) != IB_SUCCESS)
657                         return;
658         }
659         if (p_pi->capability_mask & IB_PORT_CAP_RESV14) {
660                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
661                                 "IB_PORT_CAP_RESV14\n",
662                                 &total_len) != IB_SUCCESS)
663                         return;
664         }
665         if (p_pi->capability_mask & IB_PORT_CAP_RESV15) {
666                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
667                                 "IB_PORT_CAP_RESV15\n",
668                                 &total_len) != IB_SUCCESS)
669                         return;
670         }
671         if (p_pi->capability_mask & IB_PORT_CAP_HAS_COM_MGT) {
672                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
673                                 "IB_PORT_CAP_HAS_COM_MGT\n",
674                                 &total_len) != IB_SUCCESS)
675                         return;
676         }
677         if (p_pi->capability_mask & IB_PORT_CAP_HAS_SNMP) {
678                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
679                                 "IB_PORT_CAP_HAS_SNMP\n",
680                                 &total_len) != IB_SUCCESS)
681                         return;
682         }
683         if (p_pi->capability_mask & IB_PORT_CAP_REINIT) {
684                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
685                                 "IB_PORT_CAP_REINIT\n",
686                                 &total_len) != IB_SUCCESS)
687                         return;
688         }
689         if (p_pi->capability_mask & IB_PORT_CAP_HAS_DEV_MGT) {
690                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
691                                 "IB_PORT_CAP_HAS_DEV_MGT\n",
692                                 &total_len) != IB_SUCCESS)
693                         return;
694         }
695         if (p_pi->capability_mask & IB_PORT_CAP_HAS_VEND_CLS) {
696                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
697                                 "IB_PORT_CAP_HAS_VEND_CLS\n",
698                                 &total_len) != IB_SUCCESS)
699                         return;
700         }
701         if (p_pi->capability_mask & IB_PORT_CAP_HAS_DR_NTC) {
702                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
703                                 "IB_PORT_CAP_HAS_DR_NTC\n",
704                                 &total_len) != IB_SUCCESS)
705                         return;
706         }
707         if (p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_NTC) {
708                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
709                                 "IB_PORT_CAP_HAS_CAP_NTC\n",
710                                 &total_len) != IB_SUCCESS)
711                         return;
712         }
713         if (p_pi->capability_mask & IB_PORT_CAP_HAS_BM) {
714                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
715                                 "IB_PORT_CAP_HAS_BM\n",
716                                 &total_len) != IB_SUCCESS)
717                         return;
718         }
719         if (p_pi->capability_mask & IB_PORT_CAP_HAS_LINK_RT_LATENCY) {
720                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
721                                 "IB_PORT_CAP_HAS_LINK_RT_LATENCY\n",
722                                 &total_len) != IB_SUCCESS)
723                         return;
724         }
725         if (p_pi->capability_mask & IB_PORT_CAP_HAS_CLIENT_REREG) {
726                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
727                                 "IB_PORT_CAP_HAS_CLIENT_REREG\n",
728                                 &total_len) != IB_SUCCESS)
729                         return;
730         }
731         if (p_pi->capability_mask & IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC) {
732                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
733                                 "IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC\n",
734                                 &total_len) != IB_SUCCESS)
735                         return;
736         }
737         if (p_pi->capability_mask & IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL) {
738                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
739                                 "IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL\n",
740                                 &total_len) != IB_SUCCESS)
741                         return;
742         }
743         if (p_pi->capability_mask & IB_PORT_CAP_RESV28) {
744                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
745                                 "IB_PORT_CAP_RESV28\n",
746                                 &total_len) != IB_SUCCESS)
747                         return;
748         }
749         if (p_pi->capability_mask & IB_PORT_CAP_RESV29) {
750                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
751                                 "IB_PORT_CAP_RESV29\n",
752                                 &total_len) != IB_SUCCESS)
753                         return;
754         }
755         if (p_pi->capability_mask & IB_PORT_CAP_RESV30) {
756                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
757                                 "IB_PORT_CAP_RESV30\n",
758                                 &total_len) != IB_SUCCESS)
759                         return;
760         }
761         if (p_pi->capability_mask & IB_PORT_CAP_RESV31) {
762                 if (dbg_do_line(&p_local, buf_size, p_prefix_str,
763                                 "IB_PORT_CAP_RESV31\n",
764                                 &total_len) != IB_SUCCESS)
765                         return;
766         }
767 }
768
769 /**********************************************************************
770  **********************************************************************/
771 void
772 osm_dump_port_info(IN osm_log_t * const p_log,
773                    IN const ib_net64_t node_guid,
774                    IN const ib_net64_t port_guid,
775                    IN const uint8_t port_num,
776                    IN const ib_port_info_t * const p_pi,
777                    IN const osm_log_level_t log_level)
778 {
779         if (osm_log_is_active(p_log, log_level)) {
780                 char buf[BUF_SIZE];
781
782                 osm_log(p_log, log_level,
783                         "PortInfo dump:\n"
784                         "\t\t\t\tport number.............%u\n"
785                         "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
786                         "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
787                         "\t\t\t\tm_key...................0x%016" PRIx64 "\n"
788                         "\t\t\t\tsubnet_prefix...........0x%016" PRIx64 "\n"
789                         "\t\t\t\tbase_lid................%u\n"
790                         "\t\t\t\tmaster_sm_base_lid......%u\n"
791                         "\t\t\t\tcapability_mask.........0x%X\n"
792                         "\t\t\t\tdiag_code...............0x%X\n"
793                         "\t\t\t\tm_key_lease_period......0x%X\n"
794                         "\t\t\t\tlocal_port_num..........%u\n"
795                         "\t\t\t\tlink_width_enabled......0x%X\n"
796                         "\t\t\t\tlink_width_supported....0x%X\n"
797                         "\t\t\t\tlink_width_active.......0x%X\n"
798                         "\t\t\t\tlink_speed_supported....0x%X\n"
799                         "\t\t\t\tport_state..............%s\n"
800                         "\t\t\t\tstate_info2.............0x%X\n"
801                         "\t\t\t\tm_key_protect_bits......0x%X\n"
802                         "\t\t\t\tlmc.....................0x%X\n"
803                         "\t\t\t\tlink_speed..............0x%X\n"
804                         "\t\t\t\tmtu_smsl................0x%X\n"
805                         "\t\t\t\tvl_cap_init_type........0x%X\n"
806                         "\t\t\t\tvl_high_limit...........0x%X\n"
807                         "\t\t\t\tvl_arb_high_cap.........0x%X\n"
808                         "\t\t\t\tvl_arb_low_cap..........0x%X\n"
809                         "\t\t\t\tinit_rep_mtu_cap........0x%X\n"
810                         "\t\t\t\tvl_stall_life...........0x%X\n"
811                         "\t\t\t\tvl_enforce..............0x%X\n"
812                         "\t\t\t\tm_key_violations........0x%X\n"
813                         "\t\t\t\tp_key_violations........0x%X\n"
814                         "\t\t\t\tq_key_violations........0x%X\n"
815                         "\t\t\t\tguid_cap................0x%X\n"
816                         "\t\t\t\tclient_reregister.......0x%X\n"
817                         "\t\t\t\tsubnet_timeout..........0x%X\n"
818                         "\t\t\t\tresp_time_value.........0x%X\n"
819                         "\t\t\t\terror_threshold.........0x%X\n",
820                         port_num,
821                         cl_ntoh64(node_guid),
822                         cl_ntoh64(port_guid),
823                         cl_ntoh64(p_pi->m_key),
824                         cl_ntoh64(p_pi->subnet_prefix),
825                         cl_ntoh16(p_pi->base_lid),
826                         cl_ntoh16(p_pi->master_sm_base_lid),
827                         cl_ntoh32(p_pi->capability_mask),
828                         cl_ntoh16(p_pi->diag_code),
829                         cl_ntoh16(p_pi->m_key_lease_period),
830                         p_pi->local_port_num,
831                         p_pi->link_width_enabled,
832                         p_pi->link_width_supported,
833                         p_pi->link_width_active,
834                         ib_port_info_get_link_speed_sup(p_pi),
835                         ib_get_port_state_str(ib_port_info_get_port_state
836                                               (p_pi)), p_pi->state_info2,
837                         ib_port_info_get_mpb(p_pi), ib_port_info_get_lmc(p_pi),
838                         p_pi->link_speed, p_pi->mtu_smsl, p_pi->vl_cap,
839                         p_pi->vl_high_limit, p_pi->vl_arb_high_cap,
840                         p_pi->vl_arb_low_cap, p_pi->mtu_cap,
841                         p_pi->vl_stall_life, p_pi->vl_enforce,
842                         cl_ntoh16(p_pi->m_key_violations),
843                         cl_ntoh16(p_pi->p_key_violations),
844                         cl_ntoh16(p_pi->q_key_violations), p_pi->guid_cap,
845                         ib_port_info_get_client_rereg(p_pi),
846                         ib_port_info_get_timeout(p_pi), p_pi->resp_time_value,
847                         p_pi->error_threshold);
848
849                 /*  show the capabilities mask */
850                 if (p_pi->capability_mask) {
851                         dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
852                                                  p_pi);
853                         osm_log(p_log, log_level, "%s", buf);
854                 }
855         }
856 }
857
858 /**********************************************************************
859  **********************************************************************/
860 void
861 osm_dump_portinfo_record(IN osm_log_t * const p_log,
862                          IN const ib_portinfo_record_t * const p_pir,
863                          IN const osm_log_level_t log_level)
864 {
865         if (osm_log_is_active(p_log, log_level)) {
866                 char buf[BUF_SIZE];
867                 const ib_port_info_t *const p_pi = &p_pir->port_info;
868
869                 osm_log(p_log, log_level,
870                         "PortInfo Record dump:\n"
871                         "\t\t\t\tRID\n"
872                         "\t\t\t\tEndPortLid..............%u\n"
873                         "\t\t\t\tPortNum.................0x%X\n"
874                         "\t\t\t\tReserved................0x%X\n"
875                         "\t\t\t\tPortInfo dump:\n"
876                         "\t\t\t\tm_key...................0x%016" PRIx64 "\n"
877                         "\t\t\t\tsubnet_prefix...........0x%016" PRIx64 "\n"
878                         "\t\t\t\tbase_lid................%u\n"
879                         "\t\t\t\tmaster_sm_base_lid......%u\n"
880                         "\t\t\t\tcapability_mask.........0x%X\n"
881                         "\t\t\t\tdiag_code...............0x%X\n"
882                         "\t\t\t\tm_key_lease_period......0x%X\n"
883                         "\t\t\t\tlocal_port_num..........%u\n"
884                         "\t\t\t\tlink_width_enabled......0x%X\n"
885                         "\t\t\t\tlink_width_supported....0x%X\n"
886                         "\t\t\t\tlink_width_active.......0x%X\n"
887                         "\t\t\t\tlink_speed_supported....0x%X\n"
888                         "\t\t\t\tport_state..............%s\n"
889                         "\t\t\t\tstate_info2.............0x%X\n"
890                         "\t\t\t\tm_key_protect_bits......0x%X\n"
891                         "\t\t\t\tlmc.....................0x%X\n"
892                         "\t\t\t\tlink_speed..............0x%X\n"
893                         "\t\t\t\tmtu_smsl................0x%X\n"
894                         "\t\t\t\tvl_cap_init_type........0x%X\n"
895                         "\t\t\t\tvl_high_limit...........0x%X\n"
896                         "\t\t\t\tvl_arb_high_cap.........0x%X\n"
897                         "\t\t\t\tvl_arb_low_cap..........0x%X\n"
898                         "\t\t\t\tinit_rep_mtu_cap........0x%X\n"
899                         "\t\t\t\tvl_stall_life...........0x%X\n"
900                         "\t\t\t\tvl_enforce..............0x%X\n"
901                         "\t\t\t\tm_key_violations........0x%X\n"
902                         "\t\t\t\tp_key_violations........0x%X\n"
903                         "\t\t\t\tq_key_violations........0x%X\n"
904                         "\t\t\t\tguid_cap................0x%X\n"
905                         "\t\t\t\tsubnet_timeout..........0x%X\n"
906                         "\t\t\t\tresp_time_value.........0x%X\n"
907                         "\t\t\t\terror_threshold.........0x%X\n",
908                         cl_ntoh16(p_pir->lid),
909                         p_pir->port_num,
910                         p_pir->resv,
911                         cl_ntoh64(p_pi->m_key),
912                         cl_ntoh64(p_pi->subnet_prefix),
913                         cl_ntoh16(p_pi->base_lid),
914                         cl_ntoh16(p_pi->master_sm_base_lid),
915                         cl_ntoh32(p_pi->capability_mask),
916                         cl_ntoh16(p_pi->diag_code),
917                         cl_ntoh16(p_pi->m_key_lease_period),
918                         p_pi->local_port_num,
919                         p_pi->link_width_enabled,
920                         p_pi->link_width_supported,
921                         p_pi->link_width_active,
922                         ib_port_info_get_link_speed_sup(p_pi),
923                         ib_get_port_state_str(ib_port_info_get_port_state
924                                               (p_pi)), p_pi->state_info2,
925                         ib_port_info_get_mpb(p_pi), ib_port_info_get_lmc(p_pi),
926                         p_pi->link_speed, p_pi->mtu_smsl, p_pi->vl_cap,
927                         p_pi->vl_high_limit, p_pi->vl_arb_high_cap,
928                         p_pi->vl_arb_low_cap, p_pi->mtu_cap,
929                         p_pi->vl_stall_life, p_pi->vl_enforce,
930                         cl_ntoh16(p_pi->m_key_violations),
931                         cl_ntoh16(p_pi->p_key_violations),
932                         cl_ntoh16(p_pi->q_key_violations), p_pi->guid_cap,
933                         ib_port_info_get_timeout(p_pi), p_pi->resp_time_value,
934                         p_pi->error_threshold);
935
936                 /*  show the capabilities mask */
937                 if (p_pi->capability_mask) {
938                         dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
939                                                  p_pi);
940                         osm_log(p_log, log_level, "%s", buf);
941                 }
942         }
943 }
944
945 /**********************************************************************
946  **********************************************************************/
947 void
948 osm_dump_guidinfo_record(IN osm_log_t * const p_log,
949                          IN const ib_guidinfo_record_t * const p_gir,
950                          IN const osm_log_level_t log_level)
951 {
952         if (osm_log_is_active(p_log, log_level)) {
953                 const ib_guid_info_t *const p_gi = &p_gir->guid_info;
954
955                 osm_log(p_log, log_level,
956                         "GUIDInfo Record dump:\n"
957                         "\t\t\t\tRID\n"
958                         "\t\t\t\tLid.....................%u\n"
959                         "\t\t\t\tBlockNum................0x%X\n"
960                         "\t\t\t\tReserved................0x%X\n"
961                         "\t\t\t\tGUIDInfo dump:\n"
962                         "\t\t\t\tReserved................0x%X\n"
963                         "\t\t\t\tGUID 0..................0x%016" PRIx64 "\n"
964                         "\t\t\t\tGUID 1..................0x%016" PRIx64 "\n"
965                         "\t\t\t\tGUID 2..................0x%016" PRIx64 "\n"
966                         "\t\t\t\tGUID 3..................0x%016" PRIx64 "\n"
967                         "\t\t\t\tGUID 4..................0x%016" PRIx64 "\n"
968                         "\t\t\t\tGUID 5..................0x%016" PRIx64 "\n"
969                         "\t\t\t\tGUID 6..................0x%016" PRIx64 "\n"
970                         "\t\t\t\tGUID 7..................0x%016" PRIx64 "\n",
971                         cl_ntoh16(p_gir->lid),
972                         p_gir->block_num,
973                         p_gir->resv,
974                         cl_ntoh32(p_gir->reserved),
975                         cl_ntoh64(p_gi->guid[0]),
976                         cl_ntoh64(p_gi->guid[1]),
977                         cl_ntoh64(p_gi->guid[2]),
978                         cl_ntoh64(p_gi->guid[3]),
979                         cl_ntoh64(p_gi->guid[4]),
980                         cl_ntoh64(p_gi->guid[5]),
981                         cl_ntoh64(p_gi->guid[6]), cl_ntoh64(p_gi->guid[7]));
982         }
983 }
984
985 /**********************************************************************
986  **********************************************************************/
987 void
988 osm_dump_node_info(IN osm_log_t * const p_log,
989                    IN const ib_node_info_t * const p_ni,
990                    IN const osm_log_level_t log_level)
991 {
992         if (osm_log_is_active(p_log, log_level)) {
993                 osm_log(p_log, log_level,
994                         "NodeInfo dump:\n"
995                         "\t\t\t\tbase_version............0x%X\n"
996                         "\t\t\t\tclass_version...........0x%X\n"
997                         "\t\t\t\tnode_type...............%s\n"
998                         "\t\t\t\tnum_ports...............%u\n"
999                         "\t\t\t\tsys_guid................0x%016" PRIx64 "\n"
1000                         "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
1001                         "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
1002                         "\t\t\t\tpartition_cap...........0x%X\n"
1003                         "\t\t\t\tdevice_id...............0x%X\n"
1004                         "\t\t\t\trevision................0x%X\n"
1005                         "\t\t\t\tport_num................%u\n"
1006                         "\t\t\t\tvendor_id...............0x%X\n",
1007                         p_ni->base_version,
1008                         p_ni->class_version,
1009                         ib_get_node_type_str(p_ni->node_type),
1010                         p_ni->num_ports,
1011                         cl_ntoh64(p_ni->sys_guid),
1012                         cl_ntoh64(p_ni->node_guid),
1013                         cl_ntoh64(p_ni->port_guid),
1014                         cl_ntoh16(p_ni->partition_cap),
1015                         cl_ntoh16(p_ni->device_id),
1016                         cl_ntoh32(p_ni->revision),
1017                         ib_node_info_get_local_port_num(p_ni),
1018                         cl_ntoh32(ib_node_info_get_vendor_id(p_ni)));
1019         }
1020 }
1021
1022 /**********************************************************************
1023  **********************************************************************/
1024 void
1025 osm_dump_node_record(IN osm_log_t * const p_log,
1026                      IN const ib_node_record_t * const p_nr,
1027                      IN const osm_log_level_t log_level)
1028 {
1029         if (osm_log_is_active(p_log, log_level)) {
1030                 char desc[sizeof(p_nr->node_desc.description) + 1];
1031                 const ib_node_info_t *const p_ni = &p_nr->node_info;
1032
1033                 memcpy(desc, p_nr->node_desc.description,
1034                        sizeof(p_nr->node_desc.description));
1035                 desc[sizeof(desc) - 1] = '\0';
1036                 osm_log(p_log, log_level,
1037                         "Node Record dump:\n"
1038                         "\t\t\t\tRID\n"
1039                         "\t\t\t\tLid.....................%u\n"
1040                         "\t\t\t\tReserved................0x%X\n"
1041                         "\t\t\t\tNodeInfo dump:\n"
1042                         "\t\t\t\tbase_version............0x%X\n"
1043                         "\t\t\t\tclass_version...........0x%X\n"
1044                         "\t\t\t\tnode_type...............%s\n"
1045                         "\t\t\t\tnum_ports...............%u\n"
1046                         "\t\t\t\tsys_guid................0x%016" PRIx64 "\n"
1047                         "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
1048                         "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
1049                         "\t\t\t\tpartition_cap...........0x%X\n"
1050                         "\t\t\t\tdevice_id...............0x%X\n"
1051                         "\t\t\t\trevision................0x%X\n"
1052                         "\t\t\t\tport_num................%u\n"
1053                         "\t\t\t\tvendor_id...............0x%X\n"
1054                         "\t\t\t\tNodeDescription\n"
1055                         "\t\t\t\t%s\n",
1056                         cl_ntoh16(p_nr->lid),
1057                         cl_ntoh16(p_nr->resv),
1058                         p_ni->base_version,
1059                         p_ni->class_version,
1060                         ib_get_node_type_str(p_ni->node_type),
1061                         p_ni->num_ports,
1062                         cl_ntoh64(p_ni->sys_guid),
1063                         cl_ntoh64(p_ni->node_guid),
1064                         cl_ntoh64(p_ni->port_guid),
1065                         cl_ntoh16(p_ni->partition_cap),
1066                         cl_ntoh16(p_ni->device_id),
1067                         cl_ntoh32(p_ni->revision),
1068                         ib_node_info_get_local_port_num(p_ni),
1069                         cl_ntoh32(ib_node_info_get_vendor_id(p_ni)), desc);
1070         }
1071 }
1072
1073 /**********************************************************************
1074  **********************************************************************/
1075 void
1076 osm_dump_path_record(IN osm_log_t * const p_log,
1077                      IN const ib_path_rec_t * const p_pr,
1078                      IN const osm_log_level_t log_level)
1079 {
1080         if (osm_log_is_active(p_log, log_level)) {
1081                 osm_log(p_log, log_level,
1082                         "PathRecord dump:\n"
1083                         "\t\t\t\tservice_id..............0x%016" PRIx64 "\n"
1084                         "\t\t\t\tdgid....................0x%016" PRIx64 " : "
1085                         "0x%016" PRIx64 "\n"
1086                         "\t\t\t\tsgid....................0x%016" PRIx64 " : "
1087                         "0x%016" PRIx64 "\n"
1088                         "\t\t\t\tdlid....................%u\n"
1089                         "\t\t\t\tslid....................%u\n"
1090                         "\t\t\t\thop_flow_raw............0x%X\n"
1091                         "\t\t\t\ttclass..................0x%X\n"
1092                         "\t\t\t\tnum_path_revers.........0x%X\n"
1093                         "\t\t\t\tpkey....................0x%X\n"
1094                         "\t\t\t\tqos_class...............0x%X\n"
1095                         "\t\t\t\tsl......................0x%X\n"
1096                         "\t\t\t\tmtu.....................0x%X\n"
1097                         "\t\t\t\trate....................0x%X\n"
1098                         "\t\t\t\tpkt_life................0x%X\n"
1099                         "\t\t\t\tpreference..............0x%X\n"
1100                         "\t\t\t\tresv2...................0x%X\n"
1101                         "\t\t\t\tresv3...................0x%X\n",
1102                         cl_ntoh64(p_pr->service_id),
1103                         cl_ntoh64(p_pr->dgid.unicast.prefix),
1104                         cl_ntoh64(p_pr->dgid.unicast.interface_id),
1105                         cl_ntoh64(p_pr->sgid.unicast.prefix),
1106                         cl_ntoh64(p_pr->sgid.unicast.interface_id),
1107                         cl_ntoh16(p_pr->dlid),
1108                         cl_ntoh16(p_pr->slid),
1109                         cl_ntoh32(p_pr->hop_flow_raw),
1110                         p_pr->tclass,
1111                         p_pr->num_path,
1112                         cl_ntoh16(p_pr->pkey),
1113                         ib_path_rec_qos_class(p_pr),
1114                         ib_path_rec_sl(p_pr),
1115                         p_pr->mtu,
1116                         p_pr->rate,
1117                         p_pr->pkt_life,
1118                         p_pr->preference,
1119                         *(uint32_t *) & p_pr->resv2,
1120                         *((uint16_t *) & p_pr->resv2 + 2));
1121         }
1122 }
1123
1124 /**********************************************************************
1125  **********************************************************************/
1126 void
1127 osm_dump_multipath_record(IN osm_log_t * const p_log,
1128                           IN const ib_multipath_rec_t * const p_mpr,
1129                           IN const osm_log_level_t log_level)
1130 {
1131         if (osm_log_is_active(p_log, log_level)) {
1132                 char buf_line[1024];
1133                 ib_gid_t const *p_gid = p_mpr->gids;
1134                 int i, n = 0;
1135
1136                 if (p_mpr->sgid_count) {
1137                         for (i = 0; i < p_mpr->sgid_count; i++) {
1138                                 n += sprintf(buf_line + n,
1139                                              "\t\t\t\tsgid%02d.................."
1140                                              "0x%016" PRIx64 " : 0x%016" PRIx64
1141                                              "\n", i + 1,
1142                                              cl_ntoh64(p_gid->unicast.prefix),
1143                                              cl_ntoh64(p_gid->unicast.
1144                                                        interface_id));
1145                                 p_gid++;
1146                         }
1147                 }
1148                 if (p_mpr->dgid_count) {
1149                         for (i = 0; i < p_mpr->dgid_count; i++) {
1150                                 n += sprintf(buf_line + n,
1151                                              "\t\t\t\tdgid%02d.................."
1152                                              "0x%016" PRIx64 " : 0x%016" PRIx64
1153                                              "\n", i + 1,
1154                                              cl_ntoh64(p_gid->unicast.prefix),
1155                                              cl_ntoh64(p_gid->unicast.
1156                                                        interface_id));
1157                                 p_gid++;
1158                         }
1159                 }
1160                 osm_log(p_log, log_level,
1161                         "MultiPath Record dump:\n"
1162                         "\t\t\t\thop_flow_raw............0x%X\n"
1163                         "\t\t\t\ttclass..................0x%X\n"
1164                         "\t\t\t\tnum_path_revers.........0x%X\n"
1165                         "\t\t\t\tpkey....................0x%X\n"
1166                         "\t\t\t\tqos_class...............0x%X\n"
1167                         "\t\t\t\tsl......................0x%X\n"
1168                         "\t\t\t\tmtu.....................0x%X\n"
1169                         "\t\t\t\trate....................0x%X\n"
1170                         "\t\t\t\tpkt_life................0x%X\n"
1171                         "\t\t\t\tindependence............0x%X\n"
1172                         "\t\t\t\tsgid_count..............0x%X\n"
1173                         "\t\t\t\tdgid_count..............0x%X\n"
1174                         "\t\t\t\tservice_id..............0x%016" PRIx64 "\n"
1175                         "%s\n",
1176                         cl_ntoh32(p_mpr->hop_flow_raw),
1177                         p_mpr->tclass,
1178                         p_mpr->num_path,
1179                         cl_ntoh16(p_mpr->pkey),
1180                         ib_multipath_rec_qos_class(p_mpr),
1181                         ib_multipath_rec_sl(p_mpr),
1182                         p_mpr->mtu,
1183                         p_mpr->rate,
1184                         p_mpr->pkt_life,
1185                         p_mpr->independence,
1186                         p_mpr->sgid_count, p_mpr->dgid_count,
1187                         cl_ntoh64(ib_multipath_rec_service_id(p_mpr)),
1188                         buf_line);
1189         }
1190 }
1191
1192 /**********************************************************************
1193  **********************************************************************/
1194 void
1195 osm_dump_mc_record(IN osm_log_t * const p_log,
1196                    IN const ib_member_rec_t * const p_mcmr,
1197                    IN const osm_log_level_t log_level)
1198 {
1199         if (osm_log_is_active(p_log, log_level)) {
1200                 char gid_str[INET6_ADDRSTRLEN];
1201                 char gid_str2[INET6_ADDRSTRLEN];
1202                 osm_log(p_log, log_level,
1203                         "MCMember Record dump:\n"
1204                         "\t\t\t\tMGID....................%s\n"
1205                         "\t\t\t\tPortGid.................%s\n"
1206                         "\t\t\t\tqkey....................0x%X\n"
1207                         "\t\t\t\tmlid....................0x%X\n"
1208                         "\t\t\t\tmtu.....................0x%X\n"
1209                         "\t\t\t\tTClass..................0x%X\n"
1210                         "\t\t\t\tpkey....................0x%X\n"
1211                         "\t\t\t\trate....................0x%X\n"
1212                         "\t\t\t\tpkt_life................0x%X\n"
1213                         "\t\t\t\tSLFlowLabelHopLimit.....0x%X\n"
1214                         "\t\t\t\tScopeState..............0x%X\n"
1215                         "\t\t\t\tProxyJoin...............0x%X\n",
1216                         inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str,
1217                                 sizeof gid_str),
1218                         inet_ntop(AF_INET6, p_mcmr->port_gid.raw, gid_str2,
1219                                 sizeof gid_str2),
1220                         cl_ntoh32(p_mcmr->qkey),
1221                         cl_ntoh16(p_mcmr->mlid),
1222                         p_mcmr->mtu,
1223                         p_mcmr->tclass,
1224                         cl_ntoh16(p_mcmr->pkey),
1225                         p_mcmr->rate,
1226                         p_mcmr->pkt_life,
1227                         cl_ntoh32(p_mcmr->sl_flow_hop),
1228                         p_mcmr->scope_state, p_mcmr->proxy_join);
1229         }
1230 }
1231
1232 /**********************************************************************
1233  **********************************************************************/
1234 void
1235 osm_dump_service_record(IN osm_log_t * const p_log,
1236                         IN const ib_service_record_t * const p_sr,
1237                         IN const osm_log_level_t log_level)
1238 {
1239         if (osm_log_is_active(p_log, log_level)) {
1240                 char gid_str[INET6_ADDRSTRLEN];
1241                 char buf_service_key[35];
1242                 char buf_service_name[65];
1243
1244                 sprintf(buf_service_key,
1245                         "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
1246                         p_sr->service_key[0],
1247                         p_sr->service_key[1],
1248                         p_sr->service_key[2],
1249                         p_sr->service_key[3],
1250                         p_sr->service_key[4],
1251                         p_sr->service_key[5],
1252                         p_sr->service_key[6],
1253                         p_sr->service_key[7],
1254                         p_sr->service_key[8],
1255                         p_sr->service_key[9],
1256                         p_sr->service_key[10],
1257                         p_sr->service_key[11],
1258                         p_sr->service_key[12],
1259                         p_sr->service_key[13],
1260                         p_sr->service_key[14], p_sr->service_key[15]);
1261                 strncpy(buf_service_name, (char *)p_sr->service_name, 64);
1262                 buf_service_name[64] = '\0';
1263
1264                 osm_log(p_log, log_level,
1265                         "Service Record dump:\n"
1266                         "\t\t\t\tServiceID...............0x%016" PRIx64 "\n"
1267                         "\t\t\t\tServiceGID..............%s\n"
1268                         "\t\t\t\tServiceP_Key............0x%X\n"
1269                         "\t\t\t\tServiceLease............0x%X\n"
1270                         "\t\t\t\tServiceKey..............%s\n"
1271                         "\t\t\t\tServiceName.............%s\n"
1272                         "\t\t\t\tServiceData8.1..........0x%X\n"
1273                         "\t\t\t\tServiceData8.2..........0x%X\n"
1274                         "\t\t\t\tServiceData8.3..........0x%X\n"
1275                         "\t\t\t\tServiceData8.4..........0x%X\n"
1276                         "\t\t\t\tServiceData8.5..........0x%X\n"
1277                         "\t\t\t\tServiceData8.6..........0x%X\n"
1278                         "\t\t\t\tServiceData8.7..........0x%X\n"
1279                         "\t\t\t\tServiceData8.8..........0x%X\n"
1280                         "\t\t\t\tServiceData8.9..........0x%X\n"
1281                         "\t\t\t\tServiceData8.10.........0x%X\n"
1282                         "\t\t\t\tServiceData8.11.........0x%X\n"
1283                         "\t\t\t\tServiceData8.12.........0x%X\n"
1284                         "\t\t\t\tServiceData8.13.........0x%X\n"
1285                         "\t\t\t\tServiceData8.14.........0x%X\n"
1286                         "\t\t\t\tServiceData8.15.........0x%X\n"
1287                         "\t\t\t\tServiceData8.16.........0x%X\n"
1288                         "\t\t\t\tServiceData16.1.........0x%X\n"
1289                         "\t\t\t\tServiceData16.2.........0x%X\n"
1290                         "\t\t\t\tServiceData16.3.........0x%X\n"
1291                         "\t\t\t\tServiceData16.4.........0x%X\n"
1292                         "\t\t\t\tServiceData16.5.........0x%X\n"
1293                         "\t\t\t\tServiceData16.6.........0x%X\n"
1294                         "\t\t\t\tServiceData16.7.........0x%X\n"
1295                         "\t\t\t\tServiceData16.8.........0x%X\n"
1296                         "\t\t\t\tServiceData32.1.........0x%X\n"
1297                         "\t\t\t\tServiceData32.2.........0x%X\n"
1298                         "\t\t\t\tServiceData32.3.........0x%X\n"
1299                         "\t\t\t\tServiceData32.4.........0x%X\n"
1300                         "\t\t\t\tServiceData64.1.........0x%016" PRIx64 "\n"
1301                         "\t\t\t\tServiceData64.2.........0x%016" PRIx64 "\n",
1302                         cl_ntoh64(p_sr->service_id),
1303                         inet_ntop(AF_INET6, p_sr->service_gid.raw, gid_str,
1304                                 sizeof gid_str),
1305                         cl_ntoh16(p_sr->service_pkey),
1306                         cl_ntoh32(p_sr->service_lease),
1307                         buf_service_key,
1308                         buf_service_name,
1309                         p_sr->service_data8[0], p_sr->service_data8[1],
1310                         p_sr->service_data8[2], p_sr->service_data8[3],
1311                         p_sr->service_data8[4], p_sr->service_data8[5],
1312                         p_sr->service_data8[6], p_sr->service_data8[7],
1313                         p_sr->service_data8[8], p_sr->service_data8[9],
1314                         p_sr->service_data8[10], p_sr->service_data8[11],
1315                         p_sr->service_data8[12], p_sr->service_data8[13],
1316                         p_sr->service_data8[14], p_sr->service_data8[15],
1317                         cl_ntoh16(p_sr->service_data16[0]),
1318                         cl_ntoh16(p_sr->service_data16[1]),
1319                         cl_ntoh16(p_sr->service_data16[2]),
1320                         cl_ntoh16(p_sr->service_data16[3]),
1321                         cl_ntoh16(p_sr->service_data16[4]),
1322                         cl_ntoh16(p_sr->service_data16[5]),
1323                         cl_ntoh16(p_sr->service_data16[6]),
1324                         cl_ntoh16(p_sr->service_data16[7]),
1325                         cl_ntoh32(p_sr->service_data32[0]),
1326                         cl_ntoh32(p_sr->service_data32[1]),
1327                         cl_ntoh32(p_sr->service_data32[2]),
1328                         cl_ntoh32(p_sr->service_data32[3]),
1329                         cl_ntoh64(p_sr->service_data64[0]),
1330                         cl_ntoh64(p_sr->service_data64[1]));
1331         }
1332 }
1333
1334 /**********************************************************************
1335  **********************************************************************/
1336 void
1337 osm_dump_inform_info(IN osm_log_t * const p_log,
1338                      IN const ib_inform_info_t * const p_ii,
1339                      IN const osm_log_level_t log_level)
1340 {
1341         if (osm_log_is_active(p_log, log_level)) {
1342                 uint32_t qpn;
1343                 uint8_t resp_time_val;
1344
1345                 ib_inform_info_get_qpn_resp_time(p_ii->g_or_v.generic.
1346                                                  qpn_resp_time_val, &qpn,
1347                                                  &resp_time_val);
1348                 if (p_ii->is_generic) {
1349                         osm_log(p_log, log_level,
1350                                 "InformInfo dump:\n"
1351                                 "\t\t\t\tgid.....................0x%016" PRIx64
1352                                 " : 0x%016" PRIx64 "\n"
1353                                 "\t\t\t\tlid_range_begin.........%u\n"
1354                                 "\t\t\t\tlid_range_end...........%u\n"
1355                                 "\t\t\t\tis_generic..............0x%X\n"
1356                                 "\t\t\t\tsubscribe...............0x%X\n"
1357                                 "\t\t\t\ttrap_type...............0x%X\n"
1358                                 "\t\t\t\ttrap_num................%u\n"
1359                                 "\t\t\t\tqpn.....................0x%06X\n"
1360                                 "\t\t\t\tresp_time_val...........0x%X\n"
1361                                 "\t\t\t\tnode_type...............0x%06X\n" "",
1362                                 cl_ntoh64(p_ii->gid.unicast.prefix),
1363                                 cl_ntoh64(p_ii->gid.unicast.interface_id),
1364                                 cl_ntoh16(p_ii->lid_range_begin),
1365                                 cl_ntoh16(p_ii->lid_range_end),
1366                                 p_ii->is_generic, p_ii->subscribe,
1367                                 cl_ntoh16(p_ii->trap_type),
1368                                 cl_ntoh16(p_ii->g_or_v.generic.trap_num),
1369                                 cl_ntoh32(qpn), resp_time_val,
1370                                 cl_ntoh32(ib_inform_info_get_prod_type(p_ii)));
1371                 } else {
1372                         osm_log(p_log, log_level,
1373                                 "InformInfo dump:\n"
1374                                 "\t\t\t\tgid.....................0x%016" PRIx64
1375                                 " : 0x%016" PRIx64 "\n"
1376                                 "\t\t\t\tlid_range_begin.........%u\n"
1377                                 "\t\t\t\tlid_range_end...........%u\n"
1378                                 "\t\t\t\tis_generic..............0x%X\n"
1379                                 "\t\t\t\tsubscribe...............0x%X\n"
1380                                 "\t\t\t\ttrap_type...............0x%X\n"
1381                                 "\t\t\t\tdev_id..................0x%X\n"
1382                                 "\t\t\t\tqpn.....................0x%06X\n"
1383                                 "\t\t\t\tresp_time_val...........0x%X\n"
1384                                 "\t\t\t\tvendor_id...............0x%06X\n" "",
1385                                 cl_ntoh64(p_ii->gid.unicast.prefix),
1386                                 cl_ntoh64(p_ii->gid.unicast.interface_id),
1387                                 cl_ntoh16(p_ii->lid_range_begin),
1388                                 cl_ntoh16(p_ii->lid_range_end),
1389                                 p_ii->is_generic, p_ii->subscribe,
1390                                 cl_ntoh16(p_ii->trap_type),
1391                                 cl_ntoh16(p_ii->g_or_v.vend.dev_id),
1392                                 cl_ntoh32(qpn), resp_time_val,
1393                                 cl_ntoh32(ib_inform_info_get_prod_type(p_ii)));
1394                 }
1395         }
1396 }
1397
1398 /**********************************************************************
1399  **********************************************************************/
1400 void
1401 osm_dump_inform_info_record(IN osm_log_t * const p_log,
1402                             IN const ib_inform_info_record_t * const p_iir,
1403                             IN const osm_log_level_t log_level)
1404 {
1405         if (osm_log_is_active(p_log, log_level)) {
1406                 char gid_str[INET6_ADDRSTRLEN];
1407                 char gid_str2[INET6_ADDRSTRLEN];
1408                 uint32_t qpn;
1409                 uint8_t resp_time_val;
1410
1411                 ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.
1412                                                  generic.qpn_resp_time_val,
1413                                                  &qpn, &resp_time_val);
1414                 if (p_iir->inform_info.is_generic) {
1415                         osm_log(p_log, log_level,
1416                                 "InformInfo Record dump:\n"
1417                                 "\t\t\t\tRID\n"
1418                                 "\t\t\t\tSubscriberGID...........%s\n"
1419                                 "\t\t\t\tSubscriberEnum..........0x%X\n"
1420                                 "\t\t\t\tInformInfo dump:\n"
1421                                 "\t\t\t\tgid.....................%s\n"
1422                                 "\t\t\t\tlid_range_begin.........%u\n"
1423                                 "\t\t\t\tlid_range_end...........%u\n"
1424                                 "\t\t\t\tis_generic..............0x%X\n"
1425                                 "\t\t\t\tsubscribe...............0x%X\n"
1426                                 "\t\t\t\ttrap_type...............0x%X\n"
1427                                 "\t\t\t\ttrap_num................%u\n"
1428                                 "\t\t\t\tqpn.....................0x%06X\n"
1429                                 "\t\t\t\tresp_time_val...........0x%X\n"
1430                                 "\t\t\t\tnode_type...............0x%06X\n" "",
1431                                 inet_ntop(AF_INET6, p_iir->subscriber_gid.raw,
1432                                         gid_str, sizeof gid_str),
1433                                 cl_ntoh16(p_iir->subscriber_enum),
1434                                 inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
1435                                         gid_str2, sizeof gid_str2),
1436                                 cl_ntoh16(p_iir->inform_info.lid_range_begin),
1437                                 cl_ntoh16(p_iir->inform_info.lid_range_end),
1438                                 p_iir->inform_info.is_generic,
1439                                 p_iir->inform_info.subscribe,
1440                                 cl_ntoh16(p_iir->inform_info.trap_type),
1441                                 cl_ntoh16(p_iir->inform_info.g_or_v.generic.
1442                                           trap_num), cl_ntoh32(qpn),
1443                                 resp_time_val,
1444                                 cl_ntoh32(ib_inform_info_get_prod_type
1445                                           (&p_iir->inform_info)));
1446                 } else {
1447                         osm_log(p_log, log_level,
1448                                 "InformInfo Record dump:\n"
1449                                 "\t\t\t\tRID\n"
1450                                 "\t\t\t\tSubscriberGID...........%s\n"
1451                                 "\t\t\t\tSubscriberEnum..........0x%X\n"
1452                                 "\t\t\t\tInformInfo dump:\n"
1453                                 "\t\t\t\tgid.....................%s\n"
1454                                 "\t\t\t\tlid_range_begin.........%u\n"
1455                                 "\t\t\t\tlid_range_end...........%u\n"
1456                                 "\t\t\t\tis_generic..............0x%X\n"
1457                                 "\t\t\t\tsubscribe...............0x%X\n"
1458                                 "\t\t\t\ttrap_type...............0x%X\n"
1459                                 "\t\t\t\tdev_id..................0x%X\n"
1460                                 "\t\t\t\tqpn.....................0x%06X\n"
1461                                 "\t\t\t\tresp_time_val...........0x%X\n"
1462                                 "\t\t\t\tvendor_id...............0x%06X\n" "",
1463                                 inet_ntop(AF_INET6, p_iir->subscriber_gid.raw,
1464                                         gid_str, sizeof gid_str),
1465                                 cl_ntoh16(p_iir->subscriber_enum),
1466                                 inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
1467                                         gid_str2, sizeof gid_str2),
1468                                 cl_ntoh16(p_iir->inform_info.lid_range_begin),
1469                                 cl_ntoh16(p_iir->inform_info.lid_range_end),
1470                                 p_iir->inform_info.is_generic,
1471                                 p_iir->inform_info.subscribe,
1472                                 cl_ntoh16(p_iir->inform_info.trap_type),
1473                                 cl_ntoh16(p_iir->inform_info.g_or_v.vend.
1474                                           dev_id), cl_ntoh32(qpn),
1475                                 resp_time_val,
1476                                 cl_ntoh32(ib_inform_info_get_prod_type
1477                                           (&p_iir->inform_info)));
1478                 }
1479         }
1480 }
1481
1482 /**********************************************************************
1483  **********************************************************************/
1484 void
1485 osm_dump_link_record(IN osm_log_t * const p_log,
1486                      IN const ib_link_record_t * const p_lr,
1487                      IN const osm_log_level_t log_level)
1488 {
1489         if (osm_log_is_active(p_log, log_level)) {
1490                 osm_log(p_log, log_level,
1491                         "Link Record dump:\n"
1492                         "\t\t\t\tfrom_lid................%u\n"
1493                         "\t\t\t\tfrom_port_num...........%u\n"
1494                         "\t\t\t\tto_port_num.............%u\n"
1495                         "\t\t\t\tto_lid..................%u\n",
1496                         cl_ntoh16(p_lr->from_lid),
1497                         p_lr->from_port_num,
1498                         p_lr->to_port_num, cl_ntoh16(p_lr->to_lid));
1499         }
1500 }
1501
1502 /**********************************************************************
1503  **********************************************************************/
1504 void
1505 osm_dump_switch_info(IN osm_log_t * const p_log,
1506                      IN const ib_switch_info_t * const p_si,
1507                      IN const osm_log_level_t log_level)
1508 {
1509         if (osm_log_is_active(p_log, log_level)) {
1510                 osm_log(p_log, OSM_LOG_VERBOSE,
1511                         "SwitchInfo dump:\n"
1512                         "\t\t\t\tlin_cap.................0x%X\n"
1513                         "\t\t\t\trand_cap................0x%X\n"
1514                         "\t\t\t\tmcast_cap...............0x%X\n"
1515                         "\t\t\t\tlin_top.................0x%X\n"
1516                         "\t\t\t\tdef_port................%u\n"
1517                         "\t\t\t\tdef_mcast_pri_port......%u\n"
1518                         "\t\t\t\tdef_mcast_not_port......%u\n"
1519                         "\t\t\t\tlife_state..............0x%X\n"
1520                         "\t\t\t\tlids_per_port...........%u\n"
1521                         "\t\t\t\tpartition_enf_cap.......0x%X\n"
1522                         "\t\t\t\tflags...................0x%X\n",
1523                         cl_ntoh16(p_si->lin_cap),
1524                         cl_ntoh16(p_si->rand_cap),
1525                         cl_ntoh16(p_si->mcast_cap),
1526                         cl_ntoh16(p_si->lin_top),
1527                         p_si->def_port,
1528                         p_si->def_mcast_pri_port,
1529                         p_si->def_mcast_not_port,
1530                         p_si->life_state,
1531                         cl_ntoh16(p_si->lids_per_port),
1532                         cl_ntoh16(p_si->enforce_cap), p_si->flags);
1533         }
1534 }
1535
1536 /**********************************************************************
1537  **********************************************************************/
1538 void
1539 osm_dump_switch_info_record(IN osm_log_t * const p_log,
1540                             IN const ib_switch_info_record_t * const p_sir,
1541                             IN const osm_log_level_t log_level)
1542 {
1543         if (osm_log_is_active(p_log, log_level)) {
1544                 osm_log(p_log, log_level,
1545                         "SwitchInfo Record dump:\n"
1546                         "\t\t\t\tRID\n"
1547                         "\t\t\t\tlid.....................%u\n"
1548                         "\t\t\t\tSwitchInfo dump:\n"
1549                         "\t\t\t\tlin_cap.................0x%X\n"
1550                         "\t\t\t\trand_cap................0x%X\n"
1551                         "\t\t\t\tmcast_cap...............0x%X\n"
1552                         "\t\t\t\tlin_top.................0x%X\n"
1553                         "\t\t\t\tdef_port................%u\n"
1554                         "\t\t\t\tdef_mcast_pri_port......%u\n"
1555                         "\t\t\t\tdef_mcast_not_port......%u\n"
1556                         "\t\t\t\tlife_state..............0x%X\n"
1557                         "\t\t\t\tlids_per_port...........%u\n"
1558                         "\t\t\t\tpartition_enf_cap.......0x%X\n"
1559                         "\t\t\t\tflags...................0x%X\n",
1560                         cl_ntoh16(p_sir->lid),
1561                         cl_ntoh16(p_sir->switch_info.lin_cap),
1562                         cl_ntoh16(p_sir->switch_info.rand_cap),
1563                         cl_ntoh16(p_sir->switch_info.mcast_cap),
1564                         cl_ntoh16(p_sir->switch_info.lin_top),
1565                         p_sir->switch_info.def_port,
1566                         p_sir->switch_info.def_mcast_pri_port,
1567                         p_sir->switch_info.def_mcast_not_port,
1568                         p_sir->switch_info.life_state,
1569                         cl_ntoh16(p_sir->switch_info.lids_per_port),
1570                         cl_ntoh16(p_sir->switch_info.enforce_cap),
1571                         p_sir->switch_info.flags);
1572         }
1573 }
1574
1575 /**********************************************************************
1576  **********************************************************************/
1577 void
1578 osm_dump_pkey_block(IN osm_log_t * const p_log,
1579                     IN uint64_t port_guid,
1580                     IN uint16_t block_num,
1581                     IN uint8_t port_num,
1582                     IN const ib_pkey_table_t * const p_pkey_tbl,
1583                     IN const osm_log_level_t log_level)
1584 {
1585         if (osm_log_is_active(p_log, log_level)) {
1586                 char buf_line[1024];
1587                 int i, n;
1588
1589                 for (i = 0, n = 0; i < 32; i++)
1590                         n += sprintf(buf_line + n, " 0x%04x |",
1591                                      cl_ntoh16(p_pkey_tbl->pkey_entry[i]));
1592
1593                 osm_log(p_log, log_level,
1594                         "P_Key table dump:\n"
1595                         "\t\t\tport_guid...........0x%016" PRIx64 "\n"
1596                         "\t\t\tblock_num...........0x%X\n"
1597                         "\t\t\tport_num............%u\n\tP_Key Table: %s\n",
1598                         cl_ntoh64(port_guid), block_num, port_num, buf_line);
1599         }
1600 }
1601
1602 /**********************************************************************
1603  **********************************************************************/
1604 void
1605 osm_dump_slvl_map_table(IN osm_log_t * const p_log,
1606                         IN uint64_t port_guid,
1607                         IN uint8_t in_port_num,
1608                         IN uint8_t out_port_num,
1609                         IN const ib_slvl_table_t * const p_slvl_tbl,
1610                         IN const osm_log_level_t log_level)
1611 {
1612         if (osm_log_is_active(p_log, log_level)) {
1613                 char buf_line1[1024], buf_line2[1024];
1614                 int n;
1615                 uint8_t i;
1616
1617                 for (i = 0, n = 0; i < 16; i++)
1618                         n += sprintf(buf_line1 + n, " %-2u |", i);
1619                 for (i = 0, n = 0; i < 16; i++)
1620                         n += sprintf(buf_line2 + n, "0x%01X |",
1621                                      ib_slvl_table_get(p_slvl_tbl, i));
1622                 osm_log(p_log, log_level,
1623                         "SLtoVL dump:\n"
1624                         "\t\t\tport_guid............0x%016" PRIx64 "\n"
1625                         "\t\t\tin_port_num..........%u\n"
1626                         "\t\t\tout_port_num.........%u\n\tSL: | %s\n\tVL: | %s\n",
1627                         cl_ntoh64(port_guid),
1628                         in_port_num, out_port_num, buf_line1, buf_line2);
1629         }
1630 }
1631
1632 /**********************************************************************
1633  **********************************************************************/
1634 void
1635 osm_dump_vl_arb_table(IN osm_log_t * const p_log,
1636                       IN uint64_t port_guid,
1637                       IN uint8_t block_num,
1638                       IN uint8_t port_num,
1639                       IN const ib_vl_arb_table_t * const p_vla_tbl,
1640                       IN const osm_log_level_t log_level)
1641 {
1642         if (osm_log_is_active(p_log, log_level)) {
1643                 char buf_line1[1024], buf_line2[1024];
1644                 int i, n;
1645
1646                 for (i = 0, n = 0; i < 32; i++)
1647                         n += sprintf(buf_line1 + n, " 0x%01X |",
1648                                      p_vla_tbl->vl_entry[i].vl);
1649                 for (i = 0, n = 0; i < 32; i++)
1650                         n += sprintf(buf_line2 + n, " 0x%01X |",
1651                                      p_vla_tbl->vl_entry[i].weight);
1652                 osm_log(p_log, log_level,
1653                         "VLArb dump:\n" "\t\t\tport_guid...........0x%016"
1654                         PRIx64 "\n" "\t\t\tblock_num...........0x%X\n"
1655                         "\t\t\tport_num............%u\n\tVL    : | %s\n\tWEIGHT:| %s\n",
1656                         cl_ntoh64(port_guid), block_num, port_num, buf_line1,
1657                         buf_line2);
1658         }
1659 }
1660
1661 /**********************************************************************
1662  **********************************************************************/
1663 void
1664 osm_dump_sm_info(IN osm_log_t * const p_log,
1665                  IN const ib_sm_info_t * const p_smi,
1666                  IN const osm_log_level_t log_level)
1667 {
1668         if (osm_log_is_active(p_log, log_level)) {
1669                 osm_log(p_log, OSM_LOG_DEBUG,
1670                         "SMInfo dump:\n"
1671                         "\t\t\t\tguid....................0x%016" PRIx64 "\n"
1672                         "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
1673                         "\t\t\t\tact_count...............%u\n"
1674                         "\t\t\t\tpriority................%u\n"
1675                         "\t\t\t\tsm_state................%u\n",
1676                         cl_ntoh64(p_smi->guid),
1677                         cl_ntoh64(p_smi->sm_key),
1678                         cl_ntoh32(p_smi->act_count),
1679                         ib_sminfo_get_priority(p_smi),
1680                         ib_sminfo_get_state(p_smi));
1681         }
1682 }
1683
1684 /**********************************************************************
1685  **********************************************************************/
1686 void
1687 osm_dump_sm_info_record(IN osm_log_t * const p_log,
1688                         IN const ib_sminfo_record_t * const p_smir,
1689                         IN const osm_log_level_t log_level)
1690 {
1691         if (osm_log_is_active(p_log, log_level)) {
1692                 osm_log(p_log, OSM_LOG_DEBUG,
1693                         "SMInfo Record dump:\n"
1694                         "\t\t\t\tRID\n"
1695                         "\t\t\t\tLid.....................%u\n"
1696                         "\t\t\t\tReserved................0x%X\n"
1697                         "\t\t\t\tSMInfo dump:\n"
1698                         "\t\t\t\tguid....................0x%016" PRIx64 "\n"
1699                         "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
1700                         "\t\t\t\tact_count...............%u\n"
1701                         "\t\t\t\tpriority................%u\n"
1702                         "\t\t\t\tsm_state................%u\n",
1703                         cl_ntoh16(p_smir->lid),
1704                         cl_ntoh16(p_smir->resv0),
1705                         cl_ntoh64(p_smir->sm_info.guid),
1706                         cl_ntoh64(p_smir->sm_info.sm_key),
1707                         cl_ntoh32(p_smir->sm_info.act_count),
1708                         ib_sminfo_get_priority(&p_smir->sm_info),
1709                         ib_sminfo_get_state(&p_smir->sm_info));
1710         }
1711 }
1712
1713 /**********************************************************************
1714  **********************************************************************/
1715 void
1716 osm_dump_notice(IN osm_log_t * const p_log,
1717                 IN const ib_mad_notice_attr_t * p_ntci,
1718                 IN const osm_log_level_t log_level)
1719 {
1720         if (osm_log_is_active(p_log, log_level)) {
1721                 if (ib_notice_is_generic(p_ntci)) {
1722                         char buff[1024];
1723                         buff[0] = '\0';
1724
1725                         /* immediate data based on the trap */
1726                         switch (cl_ntoh16(p_ntci->g_or_v.generic.trap_num)) {
1727                         case 64:
1728                         case 65:
1729                         case 66:
1730                         case 67:
1731                                 sprintf(buff,
1732                                         "\t\t\t\tsrc_gid..................0x%016"
1733                                         PRIx64 ":0x%016" PRIx64 "\n",
1734                                         cl_ntoh64(p_ntci->data_details.
1735                                                   ntc_64_67.gid.unicast.prefix),
1736                                         cl_ntoh64(p_ntci->data_details.
1737                                                   ntc_64_67.gid.unicast.
1738                                                   interface_id));
1739                                 break;
1740                         case 128:
1741                                 sprintf(buff,
1742                                         "\t\t\t\tsw_lid...................%u\n",
1743                                         cl_ntoh16(p_ntci->data_details.ntc_128.
1744                                                   sw_lid));
1745                                 break;
1746                         case 129:
1747                         case 130:
1748                         case 131:
1749                                 sprintf(buff,
1750                                         "\t\t\t\tlid......................%u\n"
1751                                         "\t\t\t\tport_num.................%u\n",
1752                                         cl_ntoh16(p_ntci->data_details.
1753                                                   ntc_129_131.lid),
1754                                         p_ntci->data_details.ntc_129_131.
1755                                         port_num);
1756                                 break;
1757                         case 144:
1758                                 sprintf(buff,
1759                                         "\t\t\t\tlid......................%u\n"
1760                                         "\t\t\t\tnew_cap_mask.............0x%08x\n",
1761                                         cl_ntoh16(p_ntci->data_details.ntc_144.
1762                                                   lid),
1763                                         cl_ntoh32(p_ntci->data_details.ntc_144.
1764                                                   new_cap_mask));
1765                                 break;
1766                         case 145:
1767                                 sprintf(buff,
1768                                         "\t\t\t\tlid......................%u\n"
1769                                         "\t\t\t\tnew_sys_guid.............0x%016"
1770                                         PRIx64 "\n",
1771                                         cl_ntoh16(p_ntci->data_details.ntc_145.
1772                                                   lid),
1773                                         cl_ntoh64(p_ntci->data_details.ntc_145.
1774                                                   new_sys_guid));
1775                                 break;
1776                         }
1777
1778                         osm_log(p_log, log_level,
1779                                 "Generic Notice dump:\n"
1780                                 "\t\t\t\ttype.....................%u\n"
1781                                 "\t\t\t\tprod_type................%u (%s)\n"
1782                                 "\t\t\t\ttrap_num.................%u\n%s",
1783                                 ib_notice_get_type(p_ntci),
1784                                 cl_ntoh32(ib_notice_get_prod_type(p_ntci)),
1785                                 ib_get_producer_type_str(ib_notice_get_prod_type
1786                                                          (p_ntci)),
1787                                 cl_ntoh16(p_ntci->g_or_v.generic.trap_num),
1788                                 buff);
1789                 } else {
1790                         osm_log(p_log, log_level,
1791                                 "Vendor Notice dump:\n"
1792                                 "\t\t\t\ttype.....................%u\n"
1793                                 "\t\t\t\tvendor...................%u\n"
1794                                 "\t\t\t\tdevice_id................%u\n",
1795                                 cl_ntoh16(ib_notice_get_type(p_ntci)),
1796                                 cl_ntoh32(ib_notice_get_vend_id(p_ntci)),
1797                                 cl_ntoh16(p_ntci->g_or_v.vend.dev_id));
1798                 }
1799         }
1800 }
1801
1802 /**********************************************************************
1803  **********************************************************************/
1804 void
1805 osm_dump_dr_smp(IN osm_log_t * const p_log,
1806                 IN const ib_smp_t * const p_smp,
1807                 IN const osm_log_level_t log_level)
1808 {
1809         if (osm_log_is_active(p_log, log_level)) {
1810                 char buf[BUF_SIZE], line[BUF_SIZE];
1811                 uint32_t i;
1812
1813                 sprintf(buf,
1814                         "SMP dump:\n"
1815                         "\t\t\t\tbase_ver................0x%X\n"
1816                         "\t\t\t\tmgmt_class..............0x%X\n"
1817                         "\t\t\t\tclass_ver...............0x%X\n"
1818                         "\t\t\t\tmethod..................0x%X (%s)\n",
1819                         p_smp->base_ver,
1820                         p_smp->mgmt_class,
1821                         p_smp->class_ver,
1822                         p_smp->method, ib_get_sm_method_str(p_smp->method));
1823
1824                 if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
1825                         sprintf(line,
1826                                 "\t\t\t\tD bit...................0x%X\n"
1827                                 "\t\t\t\tstatus..................0x%X\n",
1828                                 ib_smp_is_d(p_smp), ib_smp_get_status(p_smp));
1829                 } else {
1830                         sprintf(line,
1831                                 "\t\t\t\tstatus..................0x%X\n",
1832                                 cl_ntoh16(p_smp->status));
1833                 }
1834                 strcat(buf, line);
1835
1836                 sprintf(line,
1837                         "\t\t\t\thop_ptr.................0x%X\n"
1838                         "\t\t\t\thop_count...............0x%X\n"
1839                         "\t\t\t\ttrans_id................0x%" PRIx64 "\n"
1840                         "\t\t\t\tattr_id.................0x%X (%s)\n"
1841                         "\t\t\t\tresv....................0x%X\n"
1842                         "\t\t\t\tattr_mod................0x%X\n"
1843                         "\t\t\t\tm_key...................0x%016" PRIx64 "\n",
1844                         p_smp->hop_ptr,
1845                         p_smp->hop_count,
1846                         cl_ntoh64(p_smp->trans_id),
1847                         cl_ntoh16(p_smp->attr_id),
1848                         ib_get_sm_attr_str(p_smp->attr_id),
1849                         cl_ntoh16(p_smp->resv),
1850                         cl_ntoh32(p_smp->attr_mod), cl_ntoh64(p_smp->m_key));
1851                 strcat(buf, line);
1852
1853                 if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
1854                         sprintf(line,
1855                                 "\t\t\t\tdr_slid.................%u\n"
1856                                 "\t\t\t\tdr_dlid.................%u\n",
1857                                 cl_ntoh16(p_smp->dr_slid),
1858                                 cl_ntoh16(p_smp->dr_dlid));
1859                         strcat(buf, line);
1860
1861                         strcat(buf, "\n\t\t\t\tInitial path: ");
1862
1863                         for (i = 0; i <= p_smp->hop_count; i++) {
1864                                 if (i == 0)
1865                                         sprintf(line, "%d",
1866                                                 p_smp->initial_path[i]);
1867                                 else
1868                                         sprintf(line, ",%d",
1869                                                 p_smp->initial_path[i]);
1870                                 strcat(buf, line);
1871                         }
1872
1873                         strcat(buf, "\n\t\t\t\tReturn path:  ");
1874
1875                         for (i = 0; i <= p_smp->hop_count; i++) {
1876                                 if (i == 0)
1877                                         sprintf(line, "%d",
1878                                                 p_smp->return_path[i]);
1879                                 else
1880                                         sprintf(line, ",%d",
1881                                                 p_smp->return_path[i]);
1882                                 strcat(buf, line);
1883                         }
1884
1885                         strcat(buf, "\n\t\t\t\tReserved:     ");
1886
1887                         for (i = 0; i < 7; i++) {
1888                                 sprintf(line, "[%0X]", p_smp->resv1[i]);
1889                                 strcat(buf, line);
1890                         }
1891
1892                         strcat(buf, "\n");
1893
1894                         for (i = 0; i < 64; i += 16) {
1895                                 sprintf(line, "\n\t\t\t\t%02X %02X %02X %02X "
1896                                         "%02X %02X %02X %02X"
1897                                         "   %02X %02X %02X %02X %02X %02X %02X %02X\n",
1898                                         p_smp->data[i],
1899                                         p_smp->data[i + 1],
1900                                         p_smp->data[i + 2],
1901                                         p_smp->data[i + 3],
1902                                         p_smp->data[i + 4],
1903                                         p_smp->data[i + 5],
1904                                         p_smp->data[i + 6],
1905                                         p_smp->data[i + 7],
1906                                         p_smp->data[i + 8],
1907                                         p_smp->data[i + 9],
1908                                         p_smp->data[i + 10],
1909                                         p_smp->data[i + 11],
1910                                         p_smp->data[i + 12],
1911                                         p_smp->data[i + 13],
1912                                         p_smp->data[i + 14],
1913                                         p_smp->data[i + 15]);
1914
1915                                 strcat(buf, line);
1916                         }
1917                 } else {
1918                         /* not a Direct Route so provide source and destination lids */
1919                         strcat(buf, "\t\t\t\tMAD IS LID ROUTED\n");
1920                 }
1921
1922                 osm_log(p_log, log_level, "%s\n", buf);
1923         }
1924 }
1925
1926 /**********************************************************************
1927  **********************************************************************/
1928 void
1929 osm_dump_sa_mad(IN osm_log_t * const p_log,
1930                 IN const ib_sa_mad_t * const p_mad,
1931                 IN const osm_log_level_t log_level)
1932 {
1933         if (osm_log_is_active(p_log, log_level)) {
1934                 char buf[BUF_SIZE];
1935
1936                 /* make sure the mad is valid */
1937                 if (p_mad == NULL) {
1938                         OSM_LOG(p_log, log_level, "NULL MAD POINTER\n");
1939                         return;
1940                 }
1941
1942                 sprintf(buf,
1943                         "SA MAD dump:\n"
1944                         "\t\t\t\tbase_ver................0x%X\n"
1945                         "\t\t\t\tmgmt_class..............0x%X\n"
1946                         "\t\t\t\tclass_ver...............0x%X\n"
1947                         "\t\t\t\tmethod..................0x%X (%s)\n"
1948                         "\t\t\t\tstatus..................0x%X\n"
1949                         "\t\t\t\tresv....................0x%X\n"
1950                         "\t\t\t\ttrans_id................0x%" PRIx64 "\n"
1951                         "\t\t\t\tattr_id.................0x%X (%s)\n"
1952                         "\t\t\t\tresv1...................0x%X\n"
1953                         "\t\t\t\tattr_mod................0x%X\n"
1954                         "\t\t\t\trmpp_version............0x%X\n"
1955                         "\t\t\t\trmpp_type...............0x%X\n"
1956                         "\t\t\t\trmpp_flags..............0x%X\n"
1957                         "\t\t\t\trmpp_status.............0x%X\n"
1958                         "\t\t\t\tseg_num.................0x%X\n"
1959                         "\t\t\t\tpayload_len/new_win.....0x%X\n"
1960                         "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
1961                         "\t\t\t\tattr_offset.............0x%X\n"
1962                         "\t\t\t\tresv2...................0x%X\n"
1963                         "\t\t\t\tcomp_mask...............0x%016" PRIx64 "\n",
1964                         p_mad->base_ver,
1965                         p_mad->mgmt_class,
1966                         p_mad->class_ver,
1967                         p_mad->method, ib_get_sa_method_str(p_mad->method),
1968                         cl_ntoh16(p_mad->status),
1969                         cl_ntoh16(p_mad->resv),
1970                         cl_ntoh64(p_mad->trans_id),
1971                         cl_ntoh16(p_mad->attr_id),
1972                         ib_get_sa_attr_str(p_mad->attr_id),
1973                         cl_ntoh16(p_mad->resv1),
1974                         cl_ntoh32(p_mad->attr_mod),
1975                         p_mad->rmpp_version,
1976                         p_mad->rmpp_type,
1977                         p_mad->rmpp_flags,
1978                         p_mad->rmpp_status,
1979                         cl_ntoh32(p_mad->seg_num),
1980                         cl_ntoh32(p_mad->paylen_newwin),
1981                         cl_ntoh64(p_mad->sm_key),
1982                         cl_ntoh16(p_mad->attr_offset),
1983                         cl_ntoh16(p_mad->resv3), cl_ntoh64(p_mad->comp_mask));
1984
1985                 strcat(buf, "\n");
1986
1987                 osm_log(p_log, log_level, "%s\n", buf);
1988         }
1989 }
1990
1991 /**********************************************************************
1992  **********************************************************************/
1993 void
1994 osm_dump_dr_path(IN osm_log_t * const p_log,
1995                  IN const osm_dr_path_t * const p_path,
1996                  IN const osm_log_level_t log_level)
1997 {
1998         if (osm_log_is_active(p_log, log_level)) {
1999                 char buf[BUF_SIZE], line[BUF_SIZE];
2000                 uint32_t i;
2001
2002                 sprintf(buf, "Directed Path Dump of %u hop path:"
2003                         "\n\t\t\t\tPath = ", p_path->hop_count);
2004
2005                 for (i = 0; i <= p_path->hop_count; i++) {
2006                         if (i == 0)
2007                                 sprintf(line, "%d", p_path->path[i]);
2008                         else
2009                                 sprintf(line, ",%d", p_path->path[i]);
2010                         strcat(buf, line);
2011                 }
2012                 osm_log(p_log, log_level, "%s\n", buf);
2013         }
2014 }
2015
2016 /**********************************************************************
2017  **********************************************************************/
2018 void
2019 osm_dump_smp_dr_path(IN osm_log_t * const p_log,
2020                      IN const ib_smp_t * const p_smp,
2021                      IN const osm_log_level_t log_level)
2022 {
2023         if (osm_log_is_active(p_log, log_level)) {
2024                 char buf[BUF_SIZE], line[BUF_SIZE];
2025                 uint32_t i;
2026
2027                 sprintf(buf, "Received SMP on a %u hop path:"
2028                         "\n\t\t\t\tInitial path = ", p_smp->hop_count);
2029
2030                 for (i = 0; i <= p_smp->hop_count; i++) {
2031                         if (i == 0)
2032                                 sprintf(line, "%d", p_smp->initial_path[i]);
2033                         else
2034                                 sprintf(line, ",%d", p_smp->initial_path[i]);
2035                         strcat(buf, line);
2036                 }
2037
2038                 strcat(buf, "\n\t\t\t\tReturn path  = ");
2039
2040                 for (i = 0; i <= p_smp->hop_count; i++) {
2041                         if (i == 0)
2042                                 sprintf(line, "%d", p_smp->return_path[i]);
2043                         else
2044                                 sprintf(line, ",%d", p_smp->return_path[i]);
2045                         strcat(buf, line);
2046                 }
2047
2048                 osm_log(p_log, log_level, "%s\n", buf);
2049         }
2050 }
2051
2052 static const char *const __osm_sm_signal_str[] = {
2053         "OSM_SIGNAL_NONE",      /* 0 */
2054         "OSM_SIGNAL_SWEEP",     /* 1 */
2055         "OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST", /* 2 */
2056         "OSM_SIGNAL_EXIT_STBY", /* 3 */
2057         "OSM_SIGNAL_PERFMGR_SWEEP",     /* 4 */
2058         "UNKNOWN SIGNAL!!"      /* 5 */
2059 };
2060
2061 /**********************************************************************
2062  **********************************************************************/
2063 const char *osm_get_sm_signal_str(IN osm_signal_t signal)
2064 {
2065         if (signal > OSM_SIGNAL_MAX)
2066                 signal = OSM_SIGNAL_MAX;
2067         return (__osm_sm_signal_str[signal]);
2068 }
2069
2070 /**********************************************************************
2071  **********************************************************************/
2072
2073 static const char *const __osm_disp_msg_str[] = {
2074         "OSM_MSG_NONE",
2075         "OSM_MSG_MAD_NODE_INFO",
2076         "OSM_MSG_MAD_PORT_INFO",
2077         "OSM_MSG_MAD_SWITCH_INFO",
2078         "OSM_MSG_MAD_NODE_DESC",
2079         "OSM_MSG_MAD_NODE_RECORD",
2080         "OSM_MSG_MAD_PORTINFO_RECORD",
2081         "OSM_MSG_MAD_SERVICE_RECORD",
2082         "OSM_MSG_MAD_PATH_RECORD",
2083         "OSM_MSG_MAD_MCMEMBER_RECORD",
2084         "OSM_MSG_MAD_LINK_RECORD",
2085         "OSM_MSG_MAD_SMINFO_RECORD",
2086         "OSM_MSG_MAD_CLASS_PORT_INFO",
2087         "OSM_MSG_MAD_INFORM_INFO",
2088         "OSM_MSG_MAD_LFT_RECORD",
2089         "OSM_MSG_MAD_LFT",
2090         "OSM_MSG_MAD_SM_INFO",
2091         "OSM_MSG_MAD_NOTICE",
2092         "OSM_MSG_LIGHT_SWEEP_FAIL",
2093         "OSM_MSG_MAD_MFT",
2094         "OSM_MSG_MAD_PKEY_TBL_RECORD",
2095         "OSM_MSG_MAD_VL_ARB_RECORD",
2096         "OSM_MSG_MAD_SLVL_TBL_RECORD",
2097         "OSM_MSG_MAD_PKEY",
2098         "OSM_MSG_MAD_VL_ARB",
2099         "OSM_MSG_MAD_SLVL",
2100         "OSM_MSG_MAD_GUIDINFO_RECORD",
2101         "OSM_MSG_MAD_INFORM_INFO_RECORD",
2102 #if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
2103         "OSM_MSG_MAD_MULTIPATH_RECORD",
2104 #endif
2105         "UNKNOWN!!"
2106 };
2107
2108 /**********************************************************************
2109  **********************************************************************/
2110 const char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg)
2111 {
2112         if (msg > OSM_MSG_MAX)
2113                 msg = OSM_MSG_MAX;
2114         return (__osm_disp_msg_str[msg]);
2115 }
2116
2117 static const char *const __osm_port_state_str_fixed_width[] = {
2118         "NOC",
2119         "DWN",
2120         "INI",
2121         "ARM",
2122         "ACT",
2123         "???"
2124 };
2125
2126 /**********************************************************************
2127  **********************************************************************/
2128 const char *osm_get_port_state_str_fixed_width(IN uint8_t port_state)
2129 {
2130         if (port_state > IB_LINK_ACTIVE)
2131                 port_state = IB_LINK_ACTIVE + 1;
2132         return (__osm_port_state_str_fixed_width[port_state]);
2133 }
2134
2135 static const char *const __osm_node_type_str_fixed_width[] = {
2136         "??",
2137         "CA",
2138         "SW",
2139         "RT",
2140 };
2141
2142 /**********************************************************************
2143  **********************************************************************/
2144 const char *osm_get_node_type_str_fixed_width(IN uint8_t node_type)
2145 {
2146         if (node_type > IB_NODE_TYPE_ROUTER)
2147                 node_type = 0;
2148         return (__osm_node_type_str_fixed_width[node_type]);
2149 }
2150
2151 /**********************************************************************
2152  **********************************************************************/
2153 const char *osm_get_manufacturer_str(IN uint64_t const guid_ho)
2154 {
2155         /* note that the max vendor string length is 11 */
2156         static const char *intel_str = "Intel";
2157         static const char *mellanox_str = "Mellanox";
2158         static const char *redswitch_str = "Redswitch";
2159         static const char *silverstorm_str = "SilverStorm";
2160         static const char *topspin_str = "Topspin";
2161         static const char *fujitsu_str = "Fujitsu";
2162         static const char *voltaire_str = "Voltaire";
2163         static const char *yotta_str = "YottaYotta";
2164         static const char *pathscale_str = "PathScale";
2165         static const char *ibm_str = "IBM";
2166         static const char *divergenet_str = "DivergeNet";
2167         static const char *flextronics_str = "Flextronics";
2168         static const char *agilent_str = "Agilent";
2169         static const char *obsidian_str = "Obsidian";
2170         static const char *baymicro_str = "BayMicro";
2171         static const char *lsilogic_str = "LSILogic";
2172         static const char *ddn_str = "DataDirect";
2173         static const char *panta_str = "Panta";
2174         static const char *hp_str = "HP";
2175         static const char *rioworks_str = "Rioworks";
2176         static const char *sun_str = "Sun";
2177         static const char *leafntwks_str = "3LeafNtwks";
2178         static const char *xsigo_str = "Xsigo";
2179         static const char *unknown_str = "Unknown";
2180
2181         switch ((uint32_t) (guid_ho >> (5 * 8))) {
2182         case OSM_VENDOR_ID_INTEL:
2183                 return (intel_str);
2184         case OSM_VENDOR_ID_MELLANOX:
2185                 return (mellanox_str);
2186         case OSM_VENDOR_ID_REDSWITCH:
2187                 return (redswitch_str);
2188         case OSM_VENDOR_ID_SILVERSTORM:
2189                 return (silverstorm_str);
2190         case OSM_VENDOR_ID_TOPSPIN:
2191                 return (topspin_str);
2192         case OSM_VENDOR_ID_FUJITSU:
2193         case OSM_VENDOR_ID_FUJITSU2:
2194                 return (fujitsu_str);
2195         case OSM_VENDOR_ID_VOLTAIRE:
2196                 return (voltaire_str);
2197         case OSM_VENDOR_ID_YOTTAYOTTA:
2198                 return (yotta_str);
2199         case OSM_VENDOR_ID_PATHSCALE:
2200                 return (pathscale_str);
2201         case OSM_VENDOR_ID_IBM:
2202                 return (ibm_str);
2203         case OSM_VENDOR_ID_DIVERGENET:
2204                 return (divergenet_str);
2205         case OSM_VENDOR_ID_FLEXTRONICS:
2206                 return (flextronics_str);
2207         case OSM_VENDOR_ID_AGILENT:
2208                 return (agilent_str);
2209         case OSM_VENDOR_ID_OBSIDIAN:
2210                 return (obsidian_str);
2211         case OSM_VENDOR_ID_BAYMICRO:
2212                 return (baymicro_str);
2213         case OSM_VENDOR_ID_LSILOGIC:
2214                 return (lsilogic_str);
2215         case OSM_VENDOR_ID_DDN:
2216                 return (ddn_str);
2217         case OSM_VENDOR_ID_PANTA:
2218                 return (panta_str);
2219         case OSM_VENDOR_ID_HP:
2220         case OSM_VENDOR_ID_HP2:
2221                 return (hp_str);
2222         case OSM_VENDOR_ID_RIOWORKS:
2223                 return (rioworks_str);
2224         case OSM_VENDOR_ID_SUN:
2225                 return (sun_str);
2226         case OSM_VENDOR_ID_3LEAFNTWKS:
2227                 return (leafntwks_str);
2228         case OSM_VENDOR_ID_XSIGO:
2229                 return (xsigo_str);
2230         default:
2231                 return (unknown_str);
2232         }
2233 }
2234
2235 static const char *const __osm_mtu_str_fixed_width[] = {
2236         "??? ",
2237         "256 ",
2238         "512 ",
2239         "1024",
2240         "2048",
2241         "4096"
2242 };
2243
2244 /**********************************************************************
2245  **********************************************************************/
2246 const char *osm_get_mtu_str(IN uint8_t const mtu)
2247 {
2248         if (mtu > IB_MTU_LEN_4096)
2249                 return (__osm_mtu_str_fixed_width[0]);
2250         else
2251                 return (__osm_mtu_str_fixed_width[mtu]);
2252 }
2253
2254 static const char *const __osm_lwa_str_fixed_width[] = {
2255         "???",
2256         "1x ",
2257         "4x ",
2258         "???",
2259         "8x ",
2260         "???",
2261         "???",
2262         "???",
2263         "12x"
2264 };
2265
2266 /**********************************************************************
2267  **********************************************************************/
2268 const char *osm_get_lwa_str(IN uint8_t const lwa)
2269 {
2270         if (lwa > 8)
2271                 return (__osm_lwa_str_fixed_width[0]);
2272         else
2273                 return (__osm_lwa_str_fixed_width[lwa]);
2274 }
2275
2276 /**********************************************************************
2277  **********************************************************************/
2278 static const char *const __osm_lsa_str_fixed_width[] = {
2279         "???",
2280         "2.5",
2281         "5  ",
2282         "???",
2283         "10 "
2284 };
2285
2286 const char *osm_get_lsa_str(IN uint8_t const lsa)
2287 {
2288         if (lsa > 4)
2289                 return (__osm_lsa_str_fixed_width[0]);
2290         else
2291                 return (__osm_lsa_str_fixed_width[lsa]);
2292 }
2293
2294 /**********************************************************************
2295  **********************************************************************/
2296
2297 static const char *const __osm_sm_mgr_signal_str[] = {
2298         "OSM_SM_SIGNAL_NONE",   /* 0 */
2299         "OSM_SM_SIGNAL_DISCOVERY_COMPLETED",    /* 2 */
2300         "OSM_SM_SIGNAL_POLLING_TIMEOUT",        /* 3 */
2301         "OSM_SM_SIGNAL_DISCOVER",       /* 4 */
2302         "OSM_SM_SIGNAL_DISABLE",        /* 5 */
2303         "OSM_SM_SIGNAL_HANDOVER",       /* 6 */
2304         "OSM_SM_SIGNAL_HANDOVER_SENT",  /* 7 */
2305         "OSM_SM_SIGNAL_ACKNOWLEDGE",    /* 8 */
2306         "OSM_SM_SIGNAL_STANDBY",        /* 9 */
2307         "OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED",   /* 10 */
2308         "OSM_SM_SIGNAL_WAIT_FOR_HANDOVER",      /* 11 */
2309         "UNKNOWN STATE!!"       /* 12 */
2310 };
2311
2312 /**********************************************************************
2313  **********************************************************************/
2314 const char *osm_get_sm_mgr_signal_str(IN osm_sm_signal_t signal)
2315 {
2316         if (signal > OSM_SM_SIGNAL_MAX)
2317                 signal = OSM_SM_SIGNAL_MAX;
2318         return (__osm_sm_mgr_signal_str[signal]);
2319 }
2320
2321 static const char *const __osm_sm_mgr_state_str[] = {
2322         "NOTACTIVE",    /* 0 */
2323         "DISCOVERING",  /* 1 */
2324         "STANDBY",      /* 2 */
2325         "MASTER",       /* 3 */
2326         "UNKNOWN STATE!!"       /* 4 */
2327 };
2328
2329 const char *osm_get_sm_mgr_state_str(IN uint16_t state)
2330 {
2331         return state < ARR_SIZE(__osm_sm_mgr_state_str) ?
2332                 __osm_sm_mgr_state_str[state] :
2333                 __osm_sm_mgr_state_str[ARR_SIZE(__osm_sm_mgr_state_str) - 1];
2334 }