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