1321936Shselasky/*
2321936Shselasky * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
3321936Shselasky * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
4321936Shselasky * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5321936Shselasky * Copyright (c) 2009 HNR Consulting. All rights reserved.
6321936Shselasky * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
7321936Shselasky *
8321936Shselasky * This software is available to you under a choice of one of two
9321936Shselasky * licenses.  You may choose to be licensed under the terms of the GNU
10321936Shselasky * General Public License (GPL) Version 2, available from the file
11321936Shselasky * COPYING in the main directory of this source tree, or the
12321936Shselasky * OpenIB.org BSD license below:
13321936Shselasky *
14321936Shselasky *     Redistribution and use in source and binary forms, with or
15321936Shselasky *     without modification, are permitted provided that the following
16321936Shselasky *     conditions are met:
17321936Shselasky *
18321936Shselasky *      - Redistributions of source code must retain the above
19321936Shselasky *        copyright notice, this list of conditions and the following
20321936Shselasky *        disclaimer.
21321936Shselasky *
22321936Shselasky *      - Redistributions in binary form must reproduce the above
23321936Shselasky *        copyright notice, this list of conditions and the following
24321936Shselasky *        disclaimer in the documentation and/or other materials
25321936Shselasky *        provided with the distribution.
26321936Shselasky *
27321936Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28321936Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29321936Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30321936Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31321936Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32321936Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33321936Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34321936Shselasky * SOFTWARE.
35321936Shselasky *
36321936Shselasky */
37321936Shselasky
38321936Shselasky/*
39321936Shselasky * Abstract:
40321936Shselasky *    Implementation of opensm helper functions.
41321936Shselasky */
42321936Shselasky
43321936Shselasky#if HAVE_CONFIG_H
44321936Shselasky#  include <config.h>
45321936Shselasky#endif				/* HAVE_CONFIG_H */
46321936Shselasky
47321936Shselasky#include <stdlib.h>
48321936Shselasky#include <stdio.h>
49321936Shselasky#include <string.h>
50321936Shselasky#include <arpa/inet.h>
51321936Shselasky#include <sys/socket.h>
52321936Shselasky#include <complib/cl_debug.h>
53321936Shselasky#include <iba/ib_types.h>
54321936Shselasky#include <opensm/osm_file_ids.h>
55321936Shselasky#define FILE_ID OSM_FILE_HELPER_C
56321936Shselasky#include <opensm/osm_helper.h>
57321936Shselasky#include <opensm/osm_log.h>
58321936Shselasky
59321936Shselasky#define LINE_LENGTH 256
60321936Shselasky
61321936Shselasky#define ARR_SIZE(a) (sizeof(a)/sizeof((a)[0]))
62321936Shselasky
63321936Shselasky/* we use two tables - one for queries and one for responses */
64321936Shselaskystatic const char *ib_sa_method_str[] = {
65321936Shselasky	"RESERVED",		/* 0 */
66321936Shselasky	"SubnAdmGet",		/* 1 */
67321936Shselasky	"SubnAdmSet",		/* 2 */
68321936Shselasky	"RESERVED",		/* 3 */
69321936Shselasky	"RESERVED",		/* 4 */
70321936Shselasky	"RESERVED",		/* 5 */
71321936Shselasky	"SubnAdmReport",	/* 6 */
72321936Shselasky	"RESERVED",		/* 7 */
73321936Shselasky	"RESERVED",		/* 8 */
74321936Shselasky	"RESERVED",		/* 9 */
75321936Shselasky	"RESERVED",		/* A */
76321936Shselasky	"RESERVED",		/* B */
77321936Shselasky	"RESERVED",		/* C */
78321936Shselasky	"RESERVED",		/* D */
79321936Shselasky	"RESERVED",		/* E */
80321936Shselasky	"RESERVED",		/* F */
81321936Shselasky	"RESERVED",		/* 10 */
82321936Shselasky	"RESERVED",		/* 11 */
83321936Shselasky	"SubnAdmGetTable",	/* 12 */
84321936Shselasky	"SubnAdmGetTraceTable",	/* 13 */
85321936Shselasky	"SubnAdmGetMulti",	/* 14 */
86321936Shselasky	"SubnAdmDelete",	/* 15 */
87321936Shselasky	"UNKNOWN"		/* 16 */
88321936Shselasky};
89321936Shselasky
90321936Shselasky#define OSM_SA_METHOD_STR_UNKNOWN_VAL (ARR_SIZE(ib_sa_method_str) - 1)
91321936Shselasky
92321936Shselaskystatic const char *ib_sa_resp_method_str[] = {
93321936Shselasky	"RESERVED",		/* 80 */
94321936Shselasky	"SubnAdmGetResp",	/* 81 */
95321936Shselasky	"RESERVED (SetResp?)",	/* 82 */
96321936Shselasky	"RESERVED",		/* 83 */
97321936Shselasky	"RESERVED",		/* 84 */
98321936Shselasky	"RESERVED",		/* 85 */
99321936Shselasky	"SubnAdmReportResp",	/* 86 */
100321936Shselasky	"RESERVED",		/* 87 */
101321936Shselasky	"RESERVED",		/* 88 */
102321936Shselasky	"RESERVED",		/* 89 */
103321936Shselasky	"RESERVED",		/* 8A */
104321936Shselasky	"RESERVED",		/* 8B */
105321936Shselasky	"RESERVED",		/* 8C */
106321936Shselasky	"RESERVED",		/* 8D */
107321936Shselasky	"RESERVED",		/* 8E */
108321936Shselasky	"RESERVED",		/* 8F */
109321936Shselasky	"RESERVED",		/* 90 */
110321936Shselasky	"RESERVED",		/* 91 */
111321936Shselasky	"SubnAdmGetTableResp",	/* 92 */
112321936Shselasky	"RESERVED",		/* 93 */
113321936Shselasky	"SubnAdmGetMultiResp",	/* 94 */
114321936Shselasky	"SubnAdmDeleteResp",	/* 95 */
115321936Shselasky	"UNKNOWN"
116321936Shselasky};
117321936Shselasky
118321936Shselaskystatic const char *ib_sm_method_str[] = {
119321936Shselasky	"RESERVED0",		/* 0 */
120321936Shselasky	"SubnGet",		/* 1 */
121321936Shselasky	"SubnSet",		/* 2 */
122321936Shselasky	"RESERVED3",		/* 3 */
123321936Shselasky	"RESERVED4",		/* 4 */
124321936Shselasky	"SubnTrap",		/* 5 */
125321936Shselasky	"RESERVED6",		/* 6 */
126321936Shselasky	"SubnTrapRepress",	/* 7 */
127321936Shselasky	"RESERVED8",		/* 8 */
128321936Shselasky	"RESERVED9",		/* 9 */
129321936Shselasky	"RESERVEDA",		/* A */
130321936Shselasky	"RESERVEDB",		/* B */
131321936Shselasky	"RESERVEDC",		/* C */
132321936Shselasky	"RESERVEDD",		/* D */
133321936Shselasky	"RESERVEDE",		/* E */
134321936Shselasky	"RESERVEDF",		/* F */
135321936Shselasky	"RESERVED10",		/* 10 */
136321936Shselasky	"SubnGetResp",		/* 11 */
137321936Shselasky	"RESERVED12",		/* 12 */
138321936Shselasky	"RESERVED13",		/* 13 */
139321936Shselasky	"RESERVED14",		/* 14 */
140321936Shselasky	"RESERVED15",		/* 15 */
141321936Shselasky	"RESERVED16",		/* 16 */
142321936Shselasky	"RESERVED17",		/* 17 */
143321936Shselasky	"RESERVED18",		/* 18 */
144321936Shselasky	"RESERVED19",		/* 19 */
145321936Shselasky	"RESERVED1A",		/* 1A */
146321936Shselasky	"RESERVED1B",		/* 1B */
147321936Shselasky	"RESERVED1C",		/* 1C */
148321936Shselasky	"RESERVED1D",		/* 1D */
149321936Shselasky	"RESERVED1E",		/* 1E */
150321936Shselasky	"RESERVED1F",		/* 1F */
151321936Shselasky	"UNKNOWN"		/* 20 */
152321936Shselasky};
153321936Shselasky
154321936Shselasky#define OSM_SM_METHOD_STR_UNKNOWN_VAL (ARR_SIZE(ib_sm_method_str) - 1)
155321936Shselasky
156321936Shselaskystatic const char *ib_sm_attr_str[] = {
157321936Shselasky	"RESERVED",		/* 0 */
158321936Shselasky	"ClassPortInfo",	/* 1 */
159321936Shselasky	"Notice",		/* 2 */
160321936Shselasky	"InformInfo",		/* 3 */
161321936Shselasky	"RESERVED",		/* 4 */
162321936Shselasky	"RESERVED",		/* 5 */
163321936Shselasky	"RESERVED",		/* 6 */
164321936Shselasky	"RESERVED",		/* 7 */
165321936Shselasky	"RESERVED",		/* 8 */
166321936Shselasky	"RESERVED",		/* 9 */
167321936Shselasky	"RESERVED",		/* A */
168321936Shselasky	"RESERVED",		/* B */
169321936Shselasky	"RESERVED",		/* C */
170321936Shselasky	"RESERVED",		/* D */
171321936Shselasky	"RESERVED",		/* E */
172321936Shselasky	"RESERVED",		/* F */
173321936Shselasky	"NodeDescription",	/* 10 */
174321936Shselasky	"NodeInfo",		/* 11 */
175321936Shselasky	"SwitchInfo",		/* 12 */
176321936Shselasky	"UNKNOWN",		/* 13 */
177321936Shselasky	"GUIDInfo",		/* 14 */
178321936Shselasky	"PortInfo",		/* 15 */
179321936Shselasky	"P_KeyTable",		/* 16 */
180321936Shselasky	"SLtoVLMappingTable",	/* 17 */
181321936Shselasky	"VLArbitrationTable",	/* 18 */
182321936Shselasky	"LinearForwardingTable",	/* 19 */
183321936Shselasky	"RandomForwardingTable",	/* 1A */
184321936Shselasky	"MulticastForwardingTable",	/* 1B */
185321936Shselasky	"UNKNOWN",		/* 1C */
186321936Shselasky	"UNKNOWN",		/* 1D */
187321936Shselasky	"UNKNOWN",		/* 1E */
188321936Shselasky	"UNKNOWN",		/* 1F */
189321936Shselasky	"SMInfo",		/* 20 */
190321936Shselasky	"UNKNOWN"		/* 21 - always highest value */
191321936Shselasky};
192321936Shselasky
193321936Shselasky#define OSM_SM_ATTR_STR_UNKNOWN_VAL (ARR_SIZE(ib_sm_attr_str) - 1)
194321936Shselasky
195321936Shselaskystatic const char *ib_sa_attr_str[] = {
196321936Shselasky	"RESERVED",		/* 0 */
197321936Shselasky	"ClassPortInfo",	/* 1 */
198321936Shselasky	"Notice",		/* 2 */
199321936Shselasky	"InformInfo",		/* 3 */
200321936Shselasky	"RESERVED",		/* 4 */
201321936Shselasky	"RESERVED",		/* 5 */
202321936Shselasky	"RESERVED",		/* 6 */
203321936Shselasky	"RESERVED",		/* 7 */
204321936Shselasky	"RESERVED",		/* 8 */
205321936Shselasky	"RESERVED",		/* 9 */
206321936Shselasky	"RESERVED",		/* A */
207321936Shselasky	"RESERVED",		/* B */
208321936Shselasky	"RESERVED",		/* C */
209321936Shselasky	"RESERVED",		/* D */
210321936Shselasky	"RESERVED",		/* E */
211321936Shselasky	"RESERVED",		/* F */
212321936Shselasky	"RESERVED",		/* 10 */
213321936Shselasky	"NodeRecord",		/* 11 */
214321936Shselasky	"PortInfoRecord",	/* 12 */
215321936Shselasky	"SLtoVLMappingTableRecord",	/* 13 */
216321936Shselasky	"SwitchInfoRecord",	/* 14 */
217321936Shselasky	"LinearForwardingTableRecord",	/* 15 */
218321936Shselasky	"RandomForwardingTableRecord",	/* 16 */
219321936Shselasky	"MulticastForwardingTableRecord",	/* 17 */
220321936Shselasky	"SMInfoRecord",		/* 18 */
221321936Shselasky	"RESERVED",		/* 19 */
222321936Shselasky	"RandomForwardingTable",	/* 1A */
223321936Shselasky	"MulticastForwardingTable",	/* 1B */
224321936Shselasky	"UNKNOWN",		/* 1C */
225321936Shselasky	"UNKNOWN",		/* 1D */
226321936Shselasky	"UNKNOWN",		/* 1E */
227321936Shselasky	"UNKNOWN",		/* 1F */
228321936Shselasky	"LinkRecord",		/* 20 */
229321936Shselasky	"UNKNOWN",		/* 21 */
230321936Shselasky	"UNKNOWN",		/* 22 */
231321936Shselasky	"UNKNOWN",		/* 23 */
232321936Shselasky	"UNKNOWN",		/* 24 */
233321936Shselasky	"UNKNOWN",		/* 25 */
234321936Shselasky	"UNKNOWN",		/* 26 */
235321936Shselasky	"UNKNOWN",		/* 27 */
236321936Shselasky	"UNKNOWN",		/* 28 */
237321936Shselasky	"UNKNOWN",		/* 29 */
238321936Shselasky	"UNKNOWN",		/* 2A */
239321936Shselasky	"UNKNOWN",		/* 2B */
240321936Shselasky	"UNKNOWN",		/* 2C */
241321936Shselasky	"UNKNOWN",		/* 2D */
242321936Shselasky	"UNKNOWN",		/* 2E */
243321936Shselasky	"UNKNOWN",		/* 2F */
244321936Shselasky	"GuidInfoRecord",	/* 30 */
245321936Shselasky	"ServiceRecord",	/* 31 */
246321936Shselasky	"UNKNOWN",		/* 32 */
247321936Shselasky	"P_KeyTableRecord",	/* 33 */
248321936Shselasky	"UNKNOWN",		/* 34 */
249321936Shselasky	"PathRecord",		/* 35 */
250321936Shselasky	"VLArbitrationTableRecord",	/* 36 */
251321936Shselasky	"UNKNOWN",		/* 37 */
252321936Shselasky	"MCMemberRecord",	/* 38 */
253321936Shselasky	"TraceRecord",		/* 39 */
254321936Shselasky	"MultiPathRecord",	/* 3A */
255321936Shselasky	"ServiceAssociationRecord",	/* 3B */
256321936Shselasky	"UNKNOWN",		/* 3C */
257321936Shselasky	"UNKNOWN",		/* 3D */
258321936Shselasky	"UNKNOWN",		/* 3E */
259321936Shselasky	"UNKNOWN",		/* 3F */
260321936Shselasky	"UNKNOWN",		/* 40 */
261321936Shselasky	"UNKNOWN",		/* 41 */
262321936Shselasky	"UNKNOWN",		/* 42 */
263321936Shselasky	"UNKNOWN",		/* 43 */
264321936Shselasky	"UNKNOWN",		/* 44 */
265321936Shselasky	"UNKNOWN",		/* 45 */
266321936Shselasky	"UNKNOWN",		/* 46 */
267321936Shselasky	"UNKNOWN",		/* 47 */
268321936Shselasky	"UNKNOWN",		/* 48 */
269321936Shselasky	"UNKNOWN",		/* 49 */
270321936Shselasky	"UNKNOWN",		/* 4A */
271321936Shselasky	"UNKNOWN",		/* 4B */
272321936Shselasky	"UNKNOWN",		/* 4C */
273321936Shselasky	"UNKNOWN",		/* 4D */
274321936Shselasky	"UNKNOWN",		/* 4E */
275321936Shselasky	"UNKNOWN",		/* 4F */
276321936Shselasky	"UNKNOWN",		/* 50 */
277321936Shselasky	"UNKNOWN",		/* 51 */
278321936Shselasky	"UNKNOWN",		/* 52 */
279321936Shselasky	"UNKNOWN",		/* 53 */
280321936Shselasky	"UNKNOWN",		/* 54 */
281321936Shselasky	"UNKNOWN",		/* 55 */
282321936Shselasky	"UNKNOWN",		/* 56 */
283321936Shselasky	"UNKNOWN",		/* 57 */
284321936Shselasky	"UNKNOWN",		/* 58 */
285321936Shselasky	"UNKNOWN",		/* 59 */
286321936Shselasky	"UNKNOWN",		/* 5A */
287321936Shselasky	"UNKNOWN",		/* 5B */
288321936Shselasky	"UNKNOWN",		/* 5C */
289321936Shselasky	"UNKNOWN",		/* 5D */
290321936Shselasky	"UNKNOWN",		/* 5E */
291321936Shselasky	"UNKNOWN",		/* 5F */
292321936Shselasky	"UNKNOWN",		/* 60 */
293321936Shselasky	"UNKNOWN",		/* 61 */
294321936Shselasky	"UNKNOWN",		/* 62 */
295321936Shselasky	"UNKNOWN",		/* 63 */
296321936Shselasky	"UNKNOWN",		/* 64 */
297321936Shselasky	"UNKNOWN",		/* 65 */
298321936Shselasky	"UNKNOWN",		/* 66 */
299321936Shselasky	"UNKNOWN",		/* 67 */
300321936Shselasky	"UNKNOWN",		/* 68 */
301321936Shselasky	"UNKNOWN",		/* 69 */
302321936Shselasky	"UNKNOWN",		/* 6A */
303321936Shselasky	"UNKNOWN",		/* 6B */
304321936Shselasky	"UNKNOWN",		/* 6C */
305321936Shselasky	"UNKNOWN",		/* 6D */
306321936Shselasky	"UNKNOWN",		/* 6E */
307321936Shselasky	"UNKNOWN",		/* 6F */
308321936Shselasky	"UNKNOWN",		/* 70 */
309321936Shselasky	"UNKNOWN",		/* 71 */
310321936Shselasky	"UNKNOWN",		/* 72 */
311321936Shselasky	"UNKNOWN",		/* 73 */
312321936Shselasky	"UNKNOWN",		/* 74 */
313321936Shselasky	"UNKNOWN",		/* 75 */
314321936Shselasky	"UNKNOWN",		/* 76 */
315321936Shselasky	"UNKNOWN",		/* 77 */
316321936Shselasky	"UNKNOWN",		/* 78 */
317321936Shselasky	"UNKNOWN",		/* 79 */
318321936Shselasky	"UNKNOWN",		/* 7A */
319321936Shselasky	"UNKNOWN",		/* 7B */
320321936Shselasky	"UNKNOWN",		/* 7C */
321321936Shselasky	"UNKNOWN",		/* 7D */
322321936Shselasky	"UNKNOWN",		/* 7E */
323321936Shselasky	"UNKNOWN",		/* 7F */
324321936Shselasky	"UNKNOWN",		/* 80 */
325321936Shselasky	"UNKNOWN",		/* 81 */
326321936Shselasky	"UNKNOWN",		/* 82 */
327321936Shselasky	"UNKNOWN",		/* 83 */
328321936Shselasky	"UNKNOWN",		/* 84 */
329321936Shselasky	"UNKNOWN",		/* 85 */
330321936Shselasky	"UNKNOWN",		/* 86 */
331321936Shselasky	"UNKNOWN",		/* 87 */
332321936Shselasky	"UNKNOWN",		/* 88 */
333321936Shselasky	"UNKNOWN",		/* 89 */
334321936Shselasky	"UNKNOWN",		/* 8A */
335321936Shselasky	"UNKNOWN",		/* 8B */
336321936Shselasky	"UNKNOWN",		/* 8C */
337321936Shselasky	"UNKNOWN",		/* 8D */
338321936Shselasky	"UNKNOWN",		/* 8E */
339321936Shselasky	"UNKNOWN",		/* 8F */
340321936Shselasky	"UNKNOWN",		/* 90 */
341321936Shselasky	"UNKNOWN",		/* 91 */
342321936Shselasky	"UNKNOWN",		/* 92 */
343321936Shselasky	"UNKNOWN",		/* 93 */
344321936Shselasky	"UNKNOWN",		/* 94 */
345321936Shselasky	"UNKNOWN",		/* 95 */
346321936Shselasky	"UNKNOWN",		/* 96 */
347321936Shselasky	"UNKNOWN",		/* 97 */
348321936Shselasky	"UNKNOWN",		/* 98 */
349321936Shselasky	"UNKNOWN",		/* 99 */
350321936Shselasky	"UNKNOWN",		/* 9A */
351321936Shselasky	"UNKNOWN",		/* 9B */
352321936Shselasky	"UNKNOWN",		/* 9C */
353321936Shselasky	"UNKNOWN",		/* 9D */
354321936Shselasky	"UNKNOWN",		/* 9E */
355321936Shselasky	"UNKNOWN",		/* 9F */
356321936Shselasky	"UNKNOWN",		/* A0 */
357321936Shselasky	"UNKNOWN",		/* A1 */
358321936Shselasky	"UNKNOWN",		/* A2 */
359321936Shselasky	"UNKNOWN",		/* A3 */
360321936Shselasky	"UNKNOWN",		/* A4 */
361321936Shselasky	"UNKNOWN",		/* A5 */
362321936Shselasky	"UNKNOWN",		/* A6 */
363321936Shselasky	"UNKNOWN",		/* A7 */
364321936Shselasky	"UNKNOWN",		/* A8 */
365321936Shselasky	"UNKNOWN",		/* A9 */
366321936Shselasky	"UNKNOWN",		/* AA */
367321936Shselasky	"UNKNOWN",		/* AB */
368321936Shselasky	"UNKNOWN",		/* AC */
369321936Shselasky	"UNKNOWN",		/* AD */
370321936Shselasky	"UNKNOWN",		/* AE */
371321936Shselasky	"UNKNOWN",		/* AF */
372321936Shselasky	"UNKNOWN",		/* B0 */
373321936Shselasky	"UNKNOWN",		/* B1 */
374321936Shselasky	"UNKNOWN",		/* B2 */
375321936Shselasky	"UNKNOWN",		/* B3 */
376321936Shselasky	"UNKNOWN",		/* B4 */
377321936Shselasky	"UNKNOWN",		/* B5 */
378321936Shselasky	"UNKNOWN",		/* B6 */
379321936Shselasky	"UNKNOWN",		/* B7 */
380321936Shselasky	"UNKNOWN",		/* B8 */
381321936Shselasky	"UNKNOWN",		/* B9 */
382321936Shselasky	"UNKNOWN",		/* BA */
383321936Shselasky	"UNKNOWN",		/* BB */
384321936Shselasky	"UNKNOWN",		/* BC */
385321936Shselasky	"UNKNOWN",		/* BD */
386321936Shselasky	"UNKNOWN",		/* BE */
387321936Shselasky	"UNKNOWN",		/* BF */
388321936Shselasky	"UNKNOWN",		/* C0 */
389321936Shselasky	"UNKNOWN",		/* C1 */
390321936Shselasky	"UNKNOWN",		/* C2 */
391321936Shselasky	"UNKNOWN",		/* C3 */
392321936Shselasky	"UNKNOWN",		/* C4 */
393321936Shselasky	"UNKNOWN",		/* C5 */
394321936Shselasky	"UNKNOWN",		/* C6 */
395321936Shselasky	"UNKNOWN",		/* C7 */
396321936Shselasky	"UNKNOWN",		/* C8 */
397321936Shselasky	"UNKNOWN",		/* C9 */
398321936Shselasky	"UNKNOWN",		/* CA */
399321936Shselasky	"UNKNOWN",		/* CB */
400321936Shselasky	"UNKNOWN",		/* CC */
401321936Shselasky	"UNKNOWN",		/* CD */
402321936Shselasky	"UNKNOWN",		/* CE */
403321936Shselasky	"UNKNOWN",		/* CF */
404321936Shselasky	"UNKNOWN",		/* D0 */
405321936Shselasky	"UNKNOWN",		/* D1 */
406321936Shselasky	"UNKNOWN",		/* D2 */
407321936Shselasky	"UNKNOWN",		/* D3 */
408321936Shselasky	"UNKNOWN",		/* D4 */
409321936Shselasky	"UNKNOWN",		/* D5 */
410321936Shselasky	"UNKNOWN",		/* D6 */
411321936Shselasky	"UNKNOWN",		/* D7 */
412321936Shselasky	"UNKNOWN",		/* D8 */
413321936Shselasky	"UNKNOWN",		/* D9 */
414321936Shselasky	"UNKNOWN",		/* DA */
415321936Shselasky	"UNKNOWN",		/* DB */
416321936Shselasky	"UNKNOWN",		/* DC */
417321936Shselasky	"UNKNOWN",		/* DD */
418321936Shselasky	"UNKNOWN",		/* DE */
419321936Shselasky	"UNKNOWN",		/* DF */
420321936Shselasky	"UNKNOWN",		/* E0 */
421321936Shselasky	"UNKNOWN",		/* E1 */
422321936Shselasky	"UNKNOWN",		/* E2 */
423321936Shselasky	"UNKNOWN",		/* E3 */
424321936Shselasky	"UNKNOWN",		/* E4 */
425321936Shselasky	"UNKNOWN",		/* E5 */
426321936Shselasky	"UNKNOWN",		/* E6 */
427321936Shselasky	"UNKNOWN",		/* E7 */
428321936Shselasky	"UNKNOWN",		/* E8 */
429321936Shselasky	"UNKNOWN",		/* E9 */
430321936Shselasky	"UNKNOWN",		/* EA */
431321936Shselasky	"UNKNOWN",		/* EB */
432321936Shselasky	"UNKNOWN",		/* EC */
433321936Shselasky	"UNKNOWN",		/* ED */
434321936Shselasky	"UNKNOWN",		/* EE */
435321936Shselasky	"UNKNOWN",		/* EF */
436321936Shselasky	"UNKNOWN",		/* F0 */
437321936Shselasky	"UNKNOWN",		/* F1 */
438321936Shselasky	"UNKNOWN",		/* F2 */
439321936Shselasky	"InformInfoRecord",	/* F3 */
440321936Shselasky	"UNKNOWN"		/* F4 - always highest value */
441321936Shselasky};
442321936Shselasky
443321936Shselasky#define OSM_SA_ATTR_STR_UNKNOWN_VAL (ARR_SIZE(ib_sa_attr_str) - 1)
444321936Shselasky
445321936Shselaskystatic int ordered_rates[] = {
446321936Shselasky	0, 0,	/*  0, 1 - reserved */
447321936Shselasky	1,	/*  2 - 2.5 Gbps */
448321936Shselasky	3,	/*  3 - 10  Gbps */
449321936Shselasky	6,	/*  4 - 30  Gbps */
450321936Shselasky	2,	/*  5 - 5   Gbps */
451321936Shselasky	5,	/*  6 - 20  Gbps */
452321936Shselasky	9,	/*  7 - 40  Gbps */
453321936Shselasky	10,	/*  8 - 60  Gbps */
454321936Shselasky	13,	/*  9 - 80  Gbps */
455321936Shselasky	14,	/* 10 - 120 Gbps */
456321936Shselasky	4,	/* 11 -  14 Gbps (17 Gbps equiv) */
457321936Shselasky	12,	/* 12 -  56 Gbps (68 Gbps equiv) */
458321936Shselasky	16,	/* 13 - 112 Gbps (136 Gbps equiv) */
459321936Shselasky	17,	/* 14 - 168 Gbps (204 Gbps equiv) */
460321936Shselasky	7,	/* 15 -  25 Gbps (31.25 Gbps equiv) */
461321936Shselasky	15,	/* 16 - 100 Gbps (125 Gbps equiv) */
462321936Shselasky	18,	/* 17 - 200 Gbps (250 Gbps equiv) */
463321936Shselasky	19,	/* 18 - 300 Gbps (375 Gbps equiv) */
464321936Shselasky	8,	/* 19 -  28 Gbps (35 Gbps equiv) */
465321936Shselasky	11,	/* 20 -  50 Gbps (62.5 Gbps equiv) */
466321936Shselasky};
467321936Shselasky
468321936Shselaskyint sprint_uint8_arr(char *buf, size_t size,
469321936Shselasky		     const uint8_t * arr, size_t len)
470321936Shselasky{
471321936Shselasky	int n;
472321936Shselasky	unsigned int i;
473321936Shselasky	for (i = 0, n = 0; i < len; i++) {
474321936Shselasky		n += snprintf(buf + n, size - n, "%s%u", i == 0 ? "" : ",",
475321936Shselasky			      arr[i]);
476321936Shselasky		if (n >= size)
477321936Shselasky			break;
478321936Shselasky	}
479321936Shselasky	return n;
480321936Shselasky}
481321936Shselasky
482321936Shselaskyconst char *ib_get_sa_method_str(IN uint8_t method)
483321936Shselasky{
484321936Shselasky	if (method & 0x80) {
485321936Shselasky		method = method & 0x7f;
486321936Shselasky		if (method > OSM_SA_METHOD_STR_UNKNOWN_VAL)
487321936Shselasky			method = OSM_SA_METHOD_STR_UNKNOWN_VAL;
488321936Shselasky		/* it is a response - use the response table */
489321936Shselasky		return ib_sa_resp_method_str[method];
490321936Shselasky	} else {
491321936Shselasky		if (method > OSM_SA_METHOD_STR_UNKNOWN_VAL)
492321936Shselasky			method = OSM_SA_METHOD_STR_UNKNOWN_VAL;
493321936Shselasky		return ib_sa_method_str[method];
494321936Shselasky	}
495321936Shselasky}
496321936Shselasky
497321936Shselaskyconst char *ib_get_sm_method_str(IN uint8_t method)
498321936Shselasky{
499321936Shselasky	if (method & 0x80)
500321936Shselasky		method = (method & 0x0F) | 0x10;
501321936Shselasky	if (method > OSM_SM_METHOD_STR_UNKNOWN_VAL)
502321936Shselasky		method = OSM_SM_METHOD_STR_UNKNOWN_VAL;
503321936Shselasky	return ib_sm_method_str[method];
504321936Shselasky}
505321936Shselasky
506321936Shselaskyconst char *ib_get_sm_attr_str(IN ib_net16_t attr)
507321936Shselasky{
508321936Shselasky	uint16_t host_attr = cl_ntoh16(attr);
509321936Shselasky
510321936Shselasky	if (attr == IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO)
511321936Shselasky		return "MLNXExtendedPortInfo";
512321936Shselasky
513321936Shselasky	if (host_attr > OSM_SM_ATTR_STR_UNKNOWN_VAL)
514321936Shselasky		host_attr = OSM_SM_ATTR_STR_UNKNOWN_VAL;
515321936Shselasky
516321936Shselasky	return ib_sm_attr_str[host_attr];
517321936Shselasky}
518321936Shselasky
519321936Shselaskyconst char *ib_get_sa_attr_str(IN ib_net16_t attr)
520321936Shselasky{
521321936Shselasky	uint16_t host_attr = cl_ntoh16(attr);
522321936Shselasky
523321936Shselasky	if (host_attr > OSM_SA_ATTR_STR_UNKNOWN_VAL)
524321936Shselasky		host_attr = OSM_SA_ATTR_STR_UNKNOWN_VAL;
525321936Shselasky
526321936Shselasky	return ib_sa_attr_str[host_attr];
527321936Shselasky}
528321936Shselasky
529321936Shselaskyconst char *ib_get_trap_str(ib_net16_t trap_num)
530321936Shselasky{
531321936Shselasky	switch (cl_ntoh16(trap_num)) {
532321936Shselasky	case SM_GID_IN_SERVICE_TRAP:	/* 64 */
533321936Shselasky		return "GID in service";
534321936Shselasky	case SM_GID_OUT_OF_SERVICE_TRAP: /* 65 */
535321936Shselasky		return "GID out of service";
536321936Shselasky	case SM_MGID_CREATED_TRAP:	/* 66 */
537321936Shselasky		return "New mcast group created";
538321936Shselasky	case SM_MGID_DESTROYED_TRAP:	/* 67 */
539321936Shselasky		return "Mcast group deleted";
540321936Shselasky	case SM_UNPATH_TRAP:		/* 68 */
541321936Shselasky		return "UnPath, Path no longer valid";
542321936Shselasky	case SM_REPATH_TRAP:		/* 69 */
543321936Shselasky		return "RePath, Path recomputed";
544321936Shselasky	case SM_LINK_STATE_CHANGED_TRAP: /* 128 */
545321936Shselasky		return "Link state change";
546321936Shselasky	case SM_LINK_INTEGRITY_THRESHOLD_TRAP: /* 129 */
547321936Shselasky		return "Local Link integrity threshold reached";
548321936Shselasky	case SM_BUFFER_OVERRUN_THRESHOLD_TRAP: /* 130 */
549321936Shselasky		return "Excessive Buffer Overrun Threshold reached";
550321936Shselasky	case SM_WATCHDOG_TIMER_EXPIRED_TRAP:   /* 131 */
551321936Shselasky		return "Flow Control Update watchdog timer expired";
552321936Shselasky	case SM_LOCAL_CHANGES_TRAP:	/* 144 */
553321936Shselasky		return
554321936Shselasky		    "CapabilityMask, NodeDescription, Link [Width|Speed] Enabled, SM priority changed";
555321936Shselasky	case SM_SYS_IMG_GUID_CHANGED_TRAP: /* 145 */
556321936Shselasky		return "System Image GUID changed";
557321936Shselasky	case SM_BAD_MKEY_TRAP:		/* 256 */
558321936Shselasky		return "Bad M_Key";
559321936Shselasky	case SM_BAD_PKEY_TRAP:		/* 257 */
560321936Shselasky		return "Bad P_Key";
561321936Shselasky	case SM_BAD_QKEY_TRAP:		/* 258 */
562321936Shselasky		return "Bad Q_Key";
563321936Shselasky	case SM_BAD_SWITCH_PKEY_TRAP:	/* 259 */
564321936Shselasky		return "Bad P_Key (switch external port)";
565321936Shselasky	default:
566321936Shselasky		break;
567321936Shselasky	}
568321936Shselasky	return "Unknown";
569321936Shselasky}
570321936Shselasky
571321936Shselaskyconst ib_gid_t ib_zero_gid = { {0} };
572321936Shselasky
573321936Shselaskystatic ib_api_status_t dbg_do_line(IN char **pp_local, IN uint32_t buf_size,
574321936Shselasky				   IN const char *p_prefix_str,
575321936Shselasky				   IN const char *p_new_str,
576321936Shselasky				   IN uint32_t * p_total_len)
577321936Shselasky{
578321936Shselasky	char line[LINE_LENGTH];
579321936Shselasky	uint32_t len;
580321936Shselasky
581321936Shselasky	sprintf(line, "%s%s", p_prefix_str, p_new_str);
582321936Shselasky	len = (uint32_t) strlen(line);
583321936Shselasky	*p_total_len += len;
584321936Shselasky	if (*p_total_len + sizeof('\0') > buf_size)
585321936Shselasky		return IB_INSUFFICIENT_MEMORY;
586321936Shselasky
587321936Shselasky	strcpy(*pp_local, line);
588321936Shselasky	*pp_local += len;
589321936Shselasky	return IB_SUCCESS;
590321936Shselasky}
591321936Shselasky
592321936Shselaskystatic void dbg_get_capabilities_str(IN char *p_buf, IN uint32_t buf_size,
593321936Shselasky				     IN const char *p_prefix_str,
594321936Shselasky				     IN const ib_port_info_t * p_pi)
595321936Shselasky{
596321936Shselasky	uint32_t total_len = 0;
597321936Shselasky	char *p_local = p_buf;
598321936Shselasky
599321936Shselasky	strcpy(p_local, "Capability Mask:\n");
600321936Shselasky	p_local += strlen(p_local);
601321936Shselasky
602321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_RESV0) {
603321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
604321936Shselasky				"IB_PORT_CAP_RESV0\n",
605321936Shselasky				&total_len) != IB_SUCCESS)
606321936Shselasky			return;
607321936Shselasky	}
608321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_IS_SM) {
609321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
610321936Shselasky				"IB_PORT_CAP_IS_SM\n",
611321936Shselasky				&total_len) != IB_SUCCESS)
612321936Shselasky			return;
613321936Shselasky	}
614321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_NOTICE) {
615321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
616321936Shselasky				"IB_PORT_CAP_HAS_NOTICE\n",
617321936Shselasky				&total_len) != IB_SUCCESS)
618321936Shselasky			return;
619321936Shselasky	}
620321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_TRAP) {
621321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
622321936Shselasky				"IB_PORT_CAP_HAS_TRAP\n",
623321936Shselasky				&total_len) != IB_SUCCESS)
624321936Shselasky			return;
625321936Shselasky	}
626321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_IPD) {
627321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
628321936Shselasky				"IB_PORT_CAP_HAS_IPD\n",
629321936Shselasky				&total_len) != IB_SUCCESS)
630321936Shselasky			return;
631321936Shselasky	}
632321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_AUTO_MIG) {
633321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
634321936Shselasky				"IB_PORT_CAP_HAS_AUTO_MIG\n",
635321936Shselasky				&total_len) != IB_SUCCESS)
636321936Shselasky			return;
637321936Shselasky	}
638321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_SL_MAP) {
639321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
640321936Shselasky				"IB_PORT_CAP_HAS_SL_MAP\n",
641321936Shselasky				&total_len) != IB_SUCCESS)
642321936Shselasky			return;
643321936Shselasky	}
644321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_NV_MKEY) {
645321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
646321936Shselasky				"IB_PORT_CAP_HAS_NV_MKEY\n",
647321936Shselasky				&total_len) != IB_SUCCESS)
648321936Shselasky			return;
649321936Shselasky	}
650321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_NV_PKEY) {
651321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
652321936Shselasky				"IB_PORT_CAP_HAS_NV_PKEY\n",
653321936Shselasky				&total_len) != IB_SUCCESS)
654321936Shselasky			return;
655321936Shselasky	}
656321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_LED_INFO) {
657321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
658321936Shselasky				"IB_PORT_CAP_HAS_LED_INFO\n",
659321936Shselasky				&total_len) != IB_SUCCESS)
660321936Shselasky			return;
661321936Shselasky	}
662321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_SM_DISAB) {
663321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
664321936Shselasky				"IB_PORT_CAP_SM_DISAB\n",
665321936Shselasky				&total_len) != IB_SUCCESS)
666321936Shselasky			return;
667321936Shselasky	}
668321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_SYS_IMG_GUID) {
669321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
670321936Shselasky				"IB_PORT_CAP_HAS_SYS_IMG_GUID\n",
671321936Shselasky				&total_len) != IB_SUCCESS)
672321936Shselasky			return;
673321936Shselasky	}
674321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_PKEY_SW_EXT_PORT_TRAP) {
675321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
676321936Shselasky				"IB_PORT_CAP_PKEY_SW_EXT_PORT_TRAP\n",
677321936Shselasky				&total_len) != IB_SUCCESS)
678321936Shselasky			return;
679321936Shselasky	}
680321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_CABLE_INFO) {
681321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
682321936Shselasky				"IB_PORT_CAP_HAS_CABLE_INFO\n",
683321936Shselasky				&total_len) != IB_SUCCESS)
684321936Shselasky			return;
685321936Shselasky	}
686321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) {
687321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
688321936Shselasky				"IB_PORT_CAP_HAS_EXT_SPEEDS\n",
689321936Shselasky				&total_len) != IB_SUCCESS)
690321936Shselasky			return;
691321936Shselasky	}
692321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) {
693321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
694321936Shselasky				"IB_PORT_CAP_HAS_CAP_MASK2\n",
695321936Shselasky				&total_len) != IB_SUCCESS)
696321936Shselasky			return;
697321936Shselasky	}
698321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_COM_MGT) {
699321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
700321936Shselasky				"IB_PORT_CAP_HAS_COM_MGT\n",
701321936Shselasky				&total_len) != IB_SUCCESS)
702321936Shselasky			return;
703321936Shselasky	}
704321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_SNMP) {
705321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
706321936Shselasky				"IB_PORT_CAP_HAS_SNMP\n",
707321936Shselasky				&total_len) != IB_SUCCESS)
708321936Shselasky			return;
709321936Shselasky	}
710321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_REINIT) {
711321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
712321936Shselasky				"IB_PORT_CAP_REINIT\n",
713321936Shselasky				&total_len) != IB_SUCCESS)
714321936Shselasky			return;
715321936Shselasky	}
716321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_DEV_MGT) {
717321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
718321936Shselasky				"IB_PORT_CAP_HAS_DEV_MGT\n",
719321936Shselasky				&total_len) != IB_SUCCESS)
720321936Shselasky			return;
721321936Shselasky	}
722321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_VEND_CLS) {
723321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
724321936Shselasky				"IB_PORT_CAP_HAS_VEND_CLS\n",
725321936Shselasky				&total_len) != IB_SUCCESS)
726321936Shselasky			return;
727321936Shselasky	}
728321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_DR_NTC) {
729321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
730321936Shselasky				"IB_PORT_CAP_HAS_DR_NTC\n",
731321936Shselasky				&total_len) != IB_SUCCESS)
732321936Shselasky			return;
733321936Shselasky	}
734321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_NTC) {
735321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
736321936Shselasky				"IB_PORT_CAP_HAS_CAP_NTC\n",
737321936Shselasky				&total_len) != IB_SUCCESS)
738321936Shselasky			return;
739321936Shselasky	}
740321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_BM) {
741321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
742321936Shselasky				"IB_PORT_CAP_HAS_BM\n",
743321936Shselasky				&total_len) != IB_SUCCESS)
744321936Shselasky			return;
745321936Shselasky	}
746321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_LINK_RT_LATENCY) {
747321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
748321936Shselasky				"IB_PORT_CAP_HAS_LINK_RT_LATENCY\n",
749321936Shselasky				&total_len) != IB_SUCCESS)
750321936Shselasky			return;
751321936Shselasky	}
752321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_CLIENT_REREG) {
753321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
754321936Shselasky				"IB_PORT_CAP_HAS_CLIENT_REREG\n",
755321936Shselasky				&total_len) != IB_SUCCESS)
756321936Shselasky			return;
757321936Shselasky	}
758321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC) {
759321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
760321936Shselasky				"IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC\n",
761321936Shselasky				&total_len) != IB_SUCCESS)
762321936Shselasky			return;
763321936Shselasky	}
764321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL) {
765321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
766321936Shselasky				"IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL\n",
767321936Shselasky				&total_len) != IB_SUCCESS)
768321936Shselasky			return;
769321936Shselasky	}
770321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_VEND_MADS) {
771321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
772321936Shselasky				"IB_PORT_CAP_HAS_VEND_MADS\n",
773321936Shselasky				&total_len) != IB_SUCCESS)
774321936Shselasky			return;
775321936Shselasky	}
776321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_MCAST_PKEY_TRAP_SUPPRESS) {
777321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
778321936Shselasky				"IB_PORT_CAP_HAS_MCAST_PKEY_TRAP_SUPPRESS\n",
779321936Shselasky				&total_len) != IB_SUCCESS)
780321936Shselasky			return;
781321936Shselasky	}
782321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_MCAST_FDB_TOP) {
783321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
784321936Shselasky				"IB_PORT_CAP_HAS_MCAST_FDB_TOP\n",
785321936Shselasky				&total_len) != IB_SUCCESS)
786321936Shselasky			return;
787321936Shselasky	}
788321936Shselasky	if (p_pi->capability_mask & IB_PORT_CAP_HAS_HIER_INFO) {
789321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
790321936Shselasky				"IB_PORT_CAP_HAS_HIER_INFO\n",
791321936Shselasky				&total_len) != IB_SUCCESS)
792321936Shselasky			return;
793321936Shselasky	}
794321936Shselasky}
795321936Shselasky
796321936Shselaskystatic void dbg_get_capabilities2_str(IN char *p_buf, IN uint32_t buf_size,
797321936Shselasky				      IN const char *p_prefix_str,
798321936Shselasky				      IN const ib_port_info_t * p_pi)
799321936Shselasky{
800321936Shselasky	uint32_t total_len = 0;
801321936Shselasky	char *p_local = p_buf;
802321936Shselasky
803321936Shselasky	strcpy(p_local, "Capability Mask2:\n");
804321936Shselasky	p_local += strlen(p_local);
805321936Shselasky
806321936Shselasky	if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_SET_NODE_DESC_SUPPORTED) {
807321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
808321936Shselasky				"IB_PORT_CAP2_IS_SET_NODE_DESC_SUPPORTED\n",
809321936Shselasky				&total_len) != IB_SUCCESS)
810321936Shselasky			return;
811321936Shselasky	}
812321936Shselasky	if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED) {
813321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
814321936Shselasky				"IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED\n",
815321936Shselasky				&total_len) != IB_SUCCESS)
816321936Shselasky			return;
817321936Shselasky	}
818321936Shselasky	if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_VIRT_SUPPORTED) {
819321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
820321936Shselasky				"IB_PORT_CAP2_IS_VIRT_SUPPORTED\n",
821321936Shselasky				&total_len) != IB_SUCCESS)
822321936Shselasky			return;
823321936Shselasky	}
824321936Shselasky	if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_SWITCH_PORT_STATE_TBL_SUPP) {
825321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
826321936Shselasky				"IB_PORT_CAP2_IS_SWITCH_PORT_STATE_TBL_SUPP\n",
827321936Shselasky				&total_len) != IB_SUCCESS)
828321936Shselasky			return;
829321936Shselasky	}
830321936Shselasky	if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_LINK_WIDTH_2X_SUPPORTED) {
831321936Shselasky		if (dbg_do_line(&p_local, buf_size, p_prefix_str,
832321936Shselasky				"IB_PORT_CAP2_IS_LINK_WIDTH_2X_SUPPORTED\n",
833321936Shselasky				&total_len) != IB_SUCCESS)
834321936Shselasky			return;
835321936Shselasky	}
836321936Shselasky}
837321936Shselasky
838321936Shselaskystatic void osm_dump_port_info_to_buf(IN ib_net64_t node_guid,
839321936Shselasky				      IN ib_net64_t port_guid,
840321936Shselasky				      IN uint8_t port_num,
841321936Shselasky				      IN const ib_port_info_t * p_pi,
842321936Shselasky				      OUT char * buf)
843321936Shselasky{
844321936Shselasky	if (!buf || !p_pi)
845321936Shselasky		return;
846321936Shselasky	else {
847321936Shselasky		sprintf(buf,
848321936Shselasky			"PortInfo dump:\n"
849321936Shselasky			"\t\t\t\tport number..............%u\n"
850321936Shselasky			"\t\t\t\tnode_guid................0x%016" PRIx64 "\n"
851321936Shselasky			"\t\t\t\tport_guid................0x%016" PRIx64 "\n"
852321936Shselasky			"\t\t\t\tm_key....................0x%016" PRIx64 "\n"
853321936Shselasky			"\t\t\t\tsubnet_prefix............0x%016" PRIx64 "\n"
854321936Shselasky			"\t\t\t\tbase_lid.................%u\n"
855321936Shselasky			"\t\t\t\tmaster_sm_base_lid.......%u\n"
856321936Shselasky			"\t\t\t\tcapability_mask..........0x%X\n"
857321936Shselasky			"\t\t\t\tdiag_code................0x%X\n"
858321936Shselasky			"\t\t\t\tm_key_lease_period.......0x%X\n"
859321936Shselasky			"\t\t\t\tlocal_port_num...........%u\n"
860321936Shselasky			"\t\t\t\tlink_width_enabled.......0x%X\n"
861321936Shselasky			"\t\t\t\tlink_width_supported.....0x%X\n"
862321936Shselasky			"\t\t\t\tlink_width_active........0x%X\n"
863321936Shselasky			"\t\t\t\tlink_speed_supported.....0x%X\n"
864321936Shselasky			"\t\t\t\tport_state...............%s\n"
865321936Shselasky			"\t\t\t\tstate_info2..............0x%X\n"
866321936Shselasky			"\t\t\t\tm_key_protect_bits.......0x%X\n"
867321936Shselasky			"\t\t\t\tlmc......................0x%X\n"
868321936Shselasky			"\t\t\t\tlink_speed...............0x%X\n"
869321936Shselasky			"\t\t\t\tmtu_smsl.................0x%X\n"
870321936Shselasky			"\t\t\t\tvl_cap_init_type.........0x%X\n"
871321936Shselasky			"\t\t\t\tvl_high_limit............0x%X\n"
872321936Shselasky			"\t\t\t\tvl_arb_high_cap..........0x%X\n"
873321936Shselasky			"\t\t\t\tvl_arb_low_cap...........0x%X\n"
874321936Shselasky			"\t\t\t\tinit_rep_mtu_cap.........0x%X\n"
875321936Shselasky			"\t\t\t\tvl_stall_life............0x%X\n"
876321936Shselasky			"\t\t\t\tvl_enforce...............0x%X\n"
877321936Shselasky			"\t\t\t\tm_key_violations.........0x%X\n"
878321936Shselasky			"\t\t\t\tp_key_violations.........0x%X\n"
879321936Shselasky			"\t\t\t\tq_key_violations.........0x%X\n"
880321936Shselasky			"\t\t\t\tguid_cap.................0x%X\n"
881321936Shselasky			"\t\t\t\tclient_reregister........0x%X\n"
882321936Shselasky			"\t\t\t\tmcast_pkey_trap_suppr....0x%X\n"
883321936Shselasky			"\t\t\t\tsubnet_timeout...........0x%X\n"
884321936Shselasky			"\t\t\t\tresp_time_value..........0x%X\n"
885321936Shselasky			"\t\t\t\terror_threshold..........0x%X\n"
886321936Shselasky			"\t\t\t\tmax_credit_hint..........0x%X\n"
887321936Shselasky			"\t\t\t\tlink_round_trip_latency..0x%X\n"
888321936Shselasky			"\t\t\t\tcapability_mask2.........0x%X\n"
889321936Shselasky			"\t\t\t\tlink_speed_ext_active....0x%X\n"
890321936Shselasky			"\t\t\t\tlink_speed_ext_supported.0x%X\n"
891321936Shselasky			"\t\t\t\tlink_speed_ext_enabled...0x%X\n",
892321936Shselasky			port_num, cl_ntoh64(node_guid), cl_ntoh64(port_guid),
893321936Shselasky			cl_ntoh64(p_pi->m_key), cl_ntoh64(p_pi->subnet_prefix),
894321936Shselasky			cl_ntoh16(p_pi->base_lid),
895321936Shselasky			cl_ntoh16(p_pi->master_sm_base_lid),
896321936Shselasky			cl_ntoh32(p_pi->capability_mask),
897321936Shselasky			cl_ntoh16(p_pi->diag_code),
898321936Shselasky			cl_ntoh16(p_pi->m_key_lease_period),
899321936Shselasky			p_pi->local_port_num, p_pi->link_width_enabled,
900321936Shselasky			p_pi->link_width_supported, p_pi->link_width_active,
901321936Shselasky			ib_port_info_get_link_speed_sup(p_pi),
902321936Shselasky			ib_get_port_state_str(ib_port_info_get_port_state
903321936Shselasky					      (p_pi)), p_pi->state_info2,
904321936Shselasky			ib_port_info_get_mpb(p_pi), ib_port_info_get_lmc(p_pi),
905321936Shselasky			p_pi->link_speed, p_pi->mtu_smsl, p_pi->vl_cap,
906321936Shselasky			p_pi->vl_high_limit, p_pi->vl_arb_high_cap,
907321936Shselasky			p_pi->vl_arb_low_cap, p_pi->mtu_cap,
908321936Shselasky			p_pi->vl_stall_life, p_pi->vl_enforce,
909321936Shselasky			cl_ntoh16(p_pi->m_key_violations),
910321936Shselasky			cl_ntoh16(p_pi->p_key_violations),
911321936Shselasky			cl_ntoh16(p_pi->q_key_violations), p_pi->guid_cap,
912321936Shselasky			ib_port_info_get_client_rereg(p_pi),
913321936Shselasky			ib_port_info_get_mcast_pkey_trap_suppress(p_pi),
914321936Shselasky			ib_port_info_get_timeout(p_pi),
915321936Shselasky			ib_port_info_get_resp_time_value(p_pi),
916321936Shselasky			p_pi->error_threshold, cl_ntoh16(p_pi->max_credit_hint),
917321936Shselasky			cl_ntoh32(p_pi->link_rt_latency),
918321936Shselasky			cl_ntoh16(p_pi->capability_mask2),
919321936Shselasky			ib_port_info_get_link_speed_ext_active(p_pi),
920321936Shselasky			ib_port_info_get_link_speed_ext_sup(p_pi),
921321936Shselasky			p_pi->link_speed_ext_enabled);
922321936Shselasky	}
923321936Shselasky}
924321936Shselasky
925321936Shselaskyvoid osm_dump_port_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
926321936Shselasky			IN ib_net64_t port_guid, IN uint8_t port_num,
927321936Shselasky			IN const ib_port_info_t * p_pi,
928321936Shselasky			IN osm_log_level_t log_level)
929321936Shselasky{
930321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
931321936Shselasky		char buf[BUF_SIZE];
932321936Shselasky
933321936Shselasky		osm_dump_port_info_to_buf(node_guid, port_guid,
934321936Shselasky					  port_num, p_pi, buf);
935321936Shselasky
936321936Shselasky		osm_log(p_log, log_level, "%s", buf);
937321936Shselasky
938321936Shselasky		/*  show the capabilities masks */
939321936Shselasky		if (p_pi->capability_mask) {
940321936Shselasky			dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
941321936Shselasky						 p_pi);
942321936Shselasky			osm_log(p_log, log_level, "%s", buf);
943321936Shselasky		}
944321936Shselasky		if ((p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) &&
945321936Shselasky		    p_pi->capability_mask2) {
946321936Shselasky			dbg_get_capabilities2_str(buf, BUF_SIZE, "\t\t\t\t",
947321936Shselasky						  p_pi);
948321936Shselasky			osm_log(p_log, log_level, "%s", buf);
949321936Shselasky		}
950321936Shselasky	}
951321936Shselasky}
952321936Shselasky
953321936Shselaskyvoid osm_dump_port_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
954321936Shselasky			   IN ib_net64_t port_guid, IN uint8_t port_num,
955321936Shselasky			   IN const ib_port_info_t * p_pi, IN const int file_id,
956321936Shselasky			   IN osm_log_level_t log_level)
957321936Shselasky{
958321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
959321936Shselasky		char buf[BUF_SIZE];
960321936Shselasky
961321936Shselasky		osm_dump_port_info_to_buf(node_guid, port_guid,
962321936Shselasky					  port_num, p_pi, buf);
963321936Shselasky
964321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
965321936Shselasky
966321936Shselasky		/*  show the capabilities masks */
967321936Shselasky		if (p_pi->capability_mask) {
968321936Shselasky			dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
969321936Shselasky						 p_pi);
970321936Shselasky			osm_log_v2(p_log, log_level, file_id, "%s", buf);
971321936Shselasky		}
972321936Shselasky		if ((p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) &&
973321936Shselasky		    p_pi->capability_mask2) {
974321936Shselasky			dbg_get_capabilities2_str(buf, BUF_SIZE, "\t\t\t\t",
975321936Shselasky						  p_pi);
976321936Shselasky			osm_log(p_log, log_level, "%s", buf);
977321936Shselasky		}
978321936Shselasky	}
979321936Shselasky}
980321936Shselasky
981321936Shselaskystatic void osm_dump_mlnx_ext_port_info_to_buf(IN ib_net64_t node_guid,
982321936Shselasky					       IN ib_net64_t port_guid, IN uint8_t port_num,
983321936Shselasky					       IN const ib_mlnx_ext_port_info_t * p_pi,
984321936Shselasky					       OUT char * buf)
985321936Shselasky{
986321936Shselasky	if (!buf || !p_pi)
987321936Shselasky		return;
988321936Shselasky	else {
989321936Shselasky		sprintf(buf,
990321936Shselasky                        "MLNX ExtendedPortInfo dump:\n"
991321936Shselasky                        "\t\t\t\tport number..............%u\n"
992321936Shselasky                        "\t\t\t\tnode_guid................0x%016" PRIx64 "\n"
993321936Shselasky                        "\t\t\t\tport_guid................0x%016" PRIx64 "\n"
994321936Shselasky                        "\t\t\t\tStateChangeEnable........0x%X\n"
995321936Shselasky                        "\t\t\t\tLinkSpeedSupported.......0x%X\n"
996321936Shselasky                        "\t\t\t\tLinkSpeedEnabled.........0x%X\n"
997321936Shselasky                        "\t\t\t\tLinkSpeedActive..........0x%X\n",
998321936Shselasky                        port_num, cl_ntoh64(node_guid), cl_ntoh64(port_guid),
999321936Shselasky                        p_pi->state_change_enable, p_pi->link_speed_supported,
1000321936Shselasky                        p_pi->link_speed_enabled, p_pi->link_speed_active);
1001321936Shselasky	}
1002321936Shselasky}
1003321936Shselasky
1004321936Shselaskyvoid osm_dump_mlnx_ext_port_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
1005321936Shselasky				 IN ib_net64_t port_guid, IN uint8_t port_num,
1006321936Shselasky				 IN const ib_mlnx_ext_port_info_t * p_pi,
1007321936Shselasky				 IN osm_log_level_t log_level)
1008321936Shselasky{
1009321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1010321936Shselasky		char buf[BUF_SIZE];
1011321936Shselasky
1012321936Shselasky		osm_dump_mlnx_ext_port_info_to_buf(node_guid, port_guid,
1013321936Shselasky						   port_num, p_pi, buf);
1014321936Shselasky
1015321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1016321936Shselasky	}
1017321936Shselasky}
1018321936Shselasky
1019321936Shselaskyvoid osm_dump_mlnx_ext_port_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
1020321936Shselasky				    IN ib_net64_t port_guid, IN uint8_t port_num,
1021321936Shselasky				    IN const ib_mlnx_ext_port_info_t * p_pi,
1022321936Shselasky				    IN const int file_id, IN osm_log_level_t log_level)
1023321936Shselasky{
1024321936Shselasky        if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1025321936Shselasky                char buf[BUF_SIZE];
1026321936Shselasky
1027321936Shselasky		osm_dump_mlnx_ext_port_info_to_buf(node_guid, port_guid,
1028321936Shselasky						   port_num, p_pi, buf);
1029321936Shselasky
1030321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1031321936Shselasky        }
1032321936Shselasky}
1033321936Shselasky
1034321936Shselaskystatic void osm_dump_portinfo_record_to_buf(IN const ib_portinfo_record_t * p_pir,
1035321936Shselasky					    OUT char * buf)
1036321936Shselasky{
1037321936Shselasky	if (!buf || !p_pir)
1038321936Shselasky		return;
1039321936Shselasky	else {
1040321936Shselasky		const ib_port_info_t *p_pi = &p_pir->port_info;
1041321936Shselasky
1042321936Shselasky		sprintf(buf,
1043321936Shselasky			"PortInfo Record dump:\n"
1044321936Shselasky			"\t\t\t\tRID\n"
1045321936Shselasky			"\t\t\t\tEndPortLid...............%u\n"
1046321936Shselasky			"\t\t\t\tPortNum..................%u\n"
1047321936Shselasky			"\t\t\t\tOptions..................0x%X\n"
1048321936Shselasky			"\t\t\t\tPortInfo dump:\n"
1049321936Shselasky			"\t\t\t\tm_key....................0x%016" PRIx64 "\n"
1050321936Shselasky			"\t\t\t\tsubnet_prefix............0x%016" PRIx64 "\n"
1051321936Shselasky			"\t\t\t\tbase_lid.................%u\n"
1052321936Shselasky			"\t\t\t\tmaster_sm_base_lid.......%u\n"
1053321936Shselasky			"\t\t\t\tcapability_mask..........0x%X\n"
1054321936Shselasky			"\t\t\t\tdiag_code................0x%X\n"
1055321936Shselasky			"\t\t\t\tm_key_lease_period.......0x%X\n"
1056321936Shselasky			"\t\t\t\tlocal_port_num...........%u\n"
1057321936Shselasky			"\t\t\t\tlink_width_enabled.......0x%X\n"
1058321936Shselasky			"\t\t\t\tlink_width_supported.....0x%X\n"
1059321936Shselasky			"\t\t\t\tlink_width_active........0x%X\n"
1060321936Shselasky			"\t\t\t\tlink_speed_supported.....0x%X\n"
1061321936Shselasky			"\t\t\t\tport_state...............%s\n"
1062321936Shselasky			"\t\t\t\tstate_info2..............0x%X\n"
1063321936Shselasky			"\t\t\t\tm_key_protect_bits.......0x%X\n"
1064321936Shselasky			"\t\t\t\tlmc......................0x%X\n"
1065321936Shselasky			"\t\t\t\tlink_speed...............0x%X\n"
1066321936Shselasky			"\t\t\t\tmtu_smsl.................0x%X\n"
1067321936Shselasky			"\t\t\t\tvl_cap_init_type.........0x%X\n"
1068321936Shselasky			"\t\t\t\tvl_high_limit............0x%X\n"
1069321936Shselasky			"\t\t\t\tvl_arb_high_cap..........0x%X\n"
1070321936Shselasky			"\t\t\t\tvl_arb_low_cap...........0x%X\n"
1071321936Shselasky			"\t\t\t\tinit_rep_mtu_cap.........0x%X\n"
1072321936Shselasky			"\t\t\t\tvl_stall_life............0x%X\n"
1073321936Shselasky			"\t\t\t\tvl_enforce...............0x%X\n"
1074321936Shselasky			"\t\t\t\tm_key_violations.........0x%X\n"
1075321936Shselasky			"\t\t\t\tp_key_violations.........0x%X\n"
1076321936Shselasky			"\t\t\t\tq_key_violations.........0x%X\n"
1077321936Shselasky			"\t\t\t\tguid_cap.................0x%X\n"
1078321936Shselasky			"\t\t\t\tclient_reregister........0x%X\n"
1079321936Shselasky			"\t\t\t\tmcast_pkey_trap_suppr....0x%X\n"
1080321936Shselasky			"\t\t\t\tsubnet_timeout...........0x%X\n"
1081321936Shselasky			"\t\t\t\tresp_time_value..........0x%X\n"
1082321936Shselasky			"\t\t\t\terror_threshold..........0x%X\n"
1083321936Shselasky			"\t\t\t\tmax_credit_hint..........0x%X\n"
1084321936Shselasky			"\t\t\t\tlink_round_trip_latency..0x%X\n"
1085321936Shselasky			"\t\t\t\tcapability_mask2.........0x%X\n"
1086321936Shselasky			"\t\t\t\tlink_speed_ext_active....0x%X\n"
1087321936Shselasky			"\t\t\t\tlink_speed_ext_supported.0x%X\n"
1088321936Shselasky			"\t\t\t\tlink_speed_ext_enabled...0x%X\n",
1089321936Shselasky			cl_ntoh16(p_pir->lid), p_pir->port_num, p_pir->options,
1090321936Shselasky			cl_ntoh64(p_pi->m_key), cl_ntoh64(p_pi->subnet_prefix),
1091321936Shselasky			cl_ntoh16(p_pi->base_lid),
1092321936Shselasky			cl_ntoh16(p_pi->master_sm_base_lid),
1093321936Shselasky			cl_ntoh32(p_pi->capability_mask),
1094321936Shselasky			cl_ntoh16(p_pi->diag_code),
1095321936Shselasky			cl_ntoh16(p_pi->m_key_lease_period),
1096321936Shselasky			p_pi->local_port_num, p_pi->link_width_enabled,
1097321936Shselasky			p_pi->link_width_supported, p_pi->link_width_active,
1098321936Shselasky			ib_port_info_get_link_speed_sup(p_pi),
1099321936Shselasky			ib_get_port_state_str(ib_port_info_get_port_state
1100321936Shselasky					      (p_pi)), p_pi->state_info2,
1101321936Shselasky			ib_port_info_get_mpb(p_pi), ib_port_info_get_lmc(p_pi),
1102321936Shselasky			p_pi->link_speed, p_pi->mtu_smsl, p_pi->vl_cap,
1103321936Shselasky			p_pi->vl_high_limit, p_pi->vl_arb_high_cap,
1104321936Shselasky			p_pi->vl_arb_low_cap, p_pi->mtu_cap,
1105321936Shselasky			p_pi->vl_stall_life, p_pi->vl_enforce,
1106321936Shselasky			cl_ntoh16(p_pi->m_key_violations),
1107321936Shselasky			cl_ntoh16(p_pi->p_key_violations),
1108321936Shselasky			cl_ntoh16(p_pi->q_key_violations), p_pi->guid_cap,
1109321936Shselasky			ib_port_info_get_client_rereg(p_pi),
1110321936Shselasky			ib_port_info_get_mcast_pkey_trap_suppress(p_pi),
1111321936Shselasky			ib_port_info_get_timeout(p_pi),
1112321936Shselasky			ib_port_info_get_resp_time_value(p_pi),
1113321936Shselasky			p_pi->error_threshold, cl_ntoh16(p_pi->max_credit_hint),
1114321936Shselasky			cl_ntoh32(p_pi->link_rt_latency),
1115321936Shselasky			cl_ntoh16(p_pi->capability_mask2),
1116321936Shselasky			ib_port_info_get_link_speed_ext_active(p_pi),
1117321936Shselasky			ib_port_info_get_link_speed_ext_sup(p_pi),
1118321936Shselasky			p_pi->link_speed_ext_enabled);
1119321936Shselasky	}
1120321936Shselasky}
1121321936Shselasky
1122321936Shselaskyvoid osm_dump_portinfo_record(IN osm_log_t * p_log,
1123321936Shselasky			      IN const ib_portinfo_record_t * p_pir,
1124321936Shselasky			      IN osm_log_level_t log_level)
1125321936Shselasky{
1126321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1127321936Shselasky		char buf[BUF_SIZE];
1128321936Shselasky		const ib_port_info_t *p_pi = &p_pir->port_info;
1129321936Shselasky
1130321936Shselasky		osm_dump_portinfo_record_to_buf(p_pir, buf);
1131321936Shselasky
1132321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1133321936Shselasky
1134321936Shselasky		/*  show the capabilities masks */
1135321936Shselasky		if (p_pi->capability_mask) {
1136321936Shselasky			dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
1137321936Shselasky						 p_pi);
1138321936Shselasky			osm_log(p_log, log_level, "%s", buf);
1139321936Shselasky		}
1140321936Shselasky		if ((p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) &&
1141321936Shselasky		    p_pi->capability_mask2) {
1142321936Shselasky			dbg_get_capabilities2_str(buf, BUF_SIZE, "\t\t\t\t",
1143321936Shselasky						  p_pi);
1144321936Shselasky			osm_log(p_log, log_level, "%s", buf);
1145321936Shselasky		}
1146321936Shselasky	}
1147321936Shselasky}
1148321936Shselasky
1149321936Shselaskyvoid osm_dump_portinfo_record_v2(IN osm_log_t * p_log,
1150321936Shselasky				 IN const ib_portinfo_record_t * p_pir,
1151321936Shselasky				 IN const int file_id,
1152321936Shselasky				 IN osm_log_level_t log_level)
1153321936Shselasky{
1154321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1155321936Shselasky		char buf[BUF_SIZE];
1156321936Shselasky		const ib_port_info_t *p_pi = &p_pir->port_info;
1157321936Shselasky
1158321936Shselasky		osm_dump_portinfo_record_to_buf(p_pir, buf);
1159321936Shselasky
1160321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1161321936Shselasky
1162321936Shselasky		/*  show the capabilities masks */
1163321936Shselasky		if (p_pi->capability_mask) {
1164321936Shselasky			dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
1165321936Shselasky						 p_pi);
1166321936Shselasky			osm_log_v2(p_log, log_level, file_id, "%s", buf);
1167321936Shselasky		}
1168321936Shselasky		if ((p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) &&
1169321936Shselasky		    p_pi->capability_mask2) {
1170321936Shselasky			dbg_get_capabilities2_str(buf, BUF_SIZE, "\t\t\t\t",
1171321936Shselasky						  p_pi);
1172321936Shselasky			osm_log(p_log, log_level, "%s", buf);
1173321936Shselasky		}
1174321936Shselasky	}
1175321936Shselasky}
1176321936Shselasky
1177321936Shselaskystatic void osm_dump_guid_info_to_buf(IN ib_net64_t node_guid,
1178321936Shselasky				      IN ib_net64_t port_guid,
1179321936Shselasky				      IN uint8_t block_num,
1180321936Shselasky				      IN const ib_guid_info_t * p_gi,
1181321936Shselasky				      OUT char * buf)
1182321936Shselasky{
1183321936Shselasky	if (!buf || !p_gi)
1184321936Shselasky		return;
1185321936Shselasky	else {
1186321936Shselasky		sprintf(buf,
1187321936Shselasky			"GUIDInfo dump:\n"
1188321936Shselasky			"\t\t\t\tblock number............%u\n"
1189321936Shselasky			"\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
1190321936Shselasky			"\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
1191321936Shselasky			"\t\t\t\tGUID 0..................0x%016" PRIx64 "\n"
1192321936Shselasky			"\t\t\t\tGUID 1..................0x%016" PRIx64 "\n"
1193321936Shselasky			"\t\t\t\tGUID 2..................0x%016" PRIx64 "\n"
1194321936Shselasky			"\t\t\t\tGUID 3..................0x%016" PRIx64 "\n"
1195321936Shselasky			"\t\t\t\tGUID 4..................0x%016" PRIx64 "\n"
1196321936Shselasky			"\t\t\t\tGUID 5..................0x%016" PRIx64 "\n"
1197321936Shselasky			"\t\t\t\tGUID 6..................0x%016" PRIx64 "\n"
1198321936Shselasky			"\t\t\t\tGUID 7..................0x%016" PRIx64 "\n",
1199321936Shselasky			block_num, cl_ntoh64(node_guid), cl_ntoh64(port_guid),
1200321936Shselasky			cl_ntoh64(p_gi->guid[0]), cl_ntoh64(p_gi->guid[1]),
1201321936Shselasky			cl_ntoh64(p_gi->guid[2]), cl_ntoh64(p_gi->guid[3]),
1202321936Shselasky			cl_ntoh64(p_gi->guid[4]), cl_ntoh64(p_gi->guid[5]),
1203321936Shselasky			cl_ntoh64(p_gi->guid[6]), cl_ntoh64(p_gi->guid[7]));
1204321936Shselasky	}
1205321936Shselasky}
1206321936Shselasky
1207321936Shselaskyvoid osm_dump_guid_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
1208321936Shselasky			IN ib_net64_t port_guid, IN uint8_t block_num,
1209321936Shselasky			IN const ib_guid_info_t * p_gi,
1210321936Shselasky			IN osm_log_level_t log_level)
1211321936Shselasky{
1212321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1213321936Shselasky		char buf[BUF_SIZE];
1214321936Shselasky
1215321936Shselasky		osm_dump_guid_info_to_buf(node_guid, port_guid,
1216321936Shselasky					  block_num, p_gi, buf);
1217321936Shselasky
1218321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1219321936Shselasky	}
1220321936Shselasky}
1221321936Shselasky
1222321936Shselaskyvoid osm_dump_guid_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
1223321936Shselasky			   IN ib_net64_t port_guid, IN uint8_t block_num,
1224321936Shselasky			   IN const ib_guid_info_t * p_gi,
1225321936Shselasky			   IN const int file_id,
1226321936Shselasky			   IN osm_log_level_t log_level)
1227321936Shselasky{
1228321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1229321936Shselasky		char buf[BUF_SIZE];
1230321936Shselasky
1231321936Shselasky		osm_dump_guid_info_to_buf(node_guid, port_guid,
1232321936Shselasky					  block_num, p_gi, buf);
1233321936Shselasky
1234321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1235321936Shselasky	}
1236321936Shselasky}
1237321936Shselasky
1238321936Shselaskystatic void osm_dump_guidinfo_record_to_buf(IN const ib_guidinfo_record_t * p_gir,
1239321936Shselasky					    OUT char * buf)
1240321936Shselasky{
1241321936Shselasky	if (!buf || !p_gir)
1242321936Shselasky		return;
1243321936Shselasky	else {
1244321936Shselasky		const ib_guid_info_t *p_gi = &p_gir->guid_info;
1245321936Shselasky
1246321936Shselasky		sprintf(buf,
1247321936Shselasky			"GUIDInfo Record dump:\n"
1248321936Shselasky			"\t\t\t\tRID\n"
1249321936Shselasky			"\t\t\t\tLid.....................%u\n"
1250321936Shselasky			"\t\t\t\tBlockNum................0x%X\n"
1251321936Shselasky			"\t\t\t\tReserved................0x%X\n"
1252321936Shselasky			"\t\t\t\tGUIDInfo dump:\n"
1253321936Shselasky			"\t\t\t\tReserved................0x%X\n"
1254321936Shselasky			"\t\t\t\tGUID 0..................0x%016" PRIx64 "\n"
1255321936Shselasky			"\t\t\t\tGUID 1..................0x%016" PRIx64 "\n"
1256321936Shselasky			"\t\t\t\tGUID 2..................0x%016" PRIx64 "\n"
1257321936Shselasky			"\t\t\t\tGUID 3..................0x%016" PRIx64 "\n"
1258321936Shselasky			"\t\t\t\tGUID 4..................0x%016" PRIx64 "\n"
1259321936Shselasky			"\t\t\t\tGUID 5..................0x%016" PRIx64 "\n"
1260321936Shselasky			"\t\t\t\tGUID 6..................0x%016" PRIx64 "\n"
1261321936Shselasky			"\t\t\t\tGUID 7..................0x%016" PRIx64 "\n",
1262321936Shselasky			cl_ntoh16(p_gir->lid), p_gir->block_num, p_gir->resv,
1263321936Shselasky			cl_ntoh32(p_gir->reserved),
1264321936Shselasky			cl_ntoh64(p_gi->guid[0]), cl_ntoh64(p_gi->guid[1]),
1265321936Shselasky			cl_ntoh64(p_gi->guid[2]), cl_ntoh64(p_gi->guid[3]),
1266321936Shselasky			cl_ntoh64(p_gi->guid[4]), cl_ntoh64(p_gi->guid[5]),
1267321936Shselasky			cl_ntoh64(p_gi->guid[6]), cl_ntoh64(p_gi->guid[7]));
1268321936Shselasky	}
1269321936Shselasky}
1270321936Shselaskyvoid osm_dump_guidinfo_record(IN osm_log_t * p_log,
1271321936Shselasky			      IN const ib_guidinfo_record_t * p_gir,
1272321936Shselasky			      IN osm_log_level_t log_level)
1273321936Shselasky{
1274321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1275321936Shselasky		char buf[BUF_SIZE];
1276321936Shselasky
1277321936Shselasky		osm_dump_guidinfo_record_to_buf(p_gir, buf);
1278321936Shselasky
1279321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1280321936Shselasky	}
1281321936Shselasky}
1282321936Shselasky
1283321936Shselaskyvoid osm_dump_guidinfo_record_v2(IN osm_log_t * p_log,
1284321936Shselasky				 IN const ib_guidinfo_record_t * p_gir,
1285321936Shselasky				 IN const int file_id,
1286321936Shselasky				 IN osm_log_level_t log_level)
1287321936Shselasky{
1288321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1289321936Shselasky		char buf[BUF_SIZE];
1290321936Shselasky
1291321936Shselasky		osm_dump_guidinfo_record_to_buf(p_gir, buf);
1292321936Shselasky
1293321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1294321936Shselasky	}
1295321936Shselasky}
1296321936Shselasky
1297321936Shselaskystatic void osm_dump_node_info_to_buf(IN const ib_node_info_t * p_ni,
1298321936Shselasky				      OUT char * buf)
1299321936Shselasky{
1300321936Shselasky	if (!buf || !p_ni)
1301321936Shselasky		return;
1302321936Shselasky	else {
1303321936Shselasky		sprintf(buf,
1304321936Shselasky			"NodeInfo dump:\n"
1305321936Shselasky			"\t\t\t\tbase_version............0x%X\n"
1306321936Shselasky			"\t\t\t\tclass_version...........0x%X\n"
1307321936Shselasky			"\t\t\t\tnode_type...............%s\n"
1308321936Shselasky			"\t\t\t\tnum_ports...............%u\n"
1309321936Shselasky			"\t\t\t\tsys_guid................0x%016" PRIx64 "\n"
1310321936Shselasky			"\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
1311321936Shselasky			"\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
1312321936Shselasky			"\t\t\t\tpartition_cap...........0x%X\n"
1313321936Shselasky			"\t\t\t\tdevice_id...............0x%X\n"
1314321936Shselasky			"\t\t\t\trevision................0x%X\n"
1315321936Shselasky			"\t\t\t\tport_num................%u\n"
1316321936Shselasky			"\t\t\t\tvendor_id...............0x%X\n",
1317321936Shselasky			p_ni->base_version, p_ni->class_version,
1318321936Shselasky			ib_get_node_type_str(p_ni->node_type), p_ni->num_ports,
1319321936Shselasky			cl_ntoh64(p_ni->sys_guid), cl_ntoh64(p_ni->node_guid),
1320321936Shselasky			cl_ntoh64(p_ni->port_guid),
1321321936Shselasky			cl_ntoh16(p_ni->partition_cap),
1322321936Shselasky			cl_ntoh16(p_ni->device_id), cl_ntoh32(p_ni->revision),
1323321936Shselasky			ib_node_info_get_local_port_num(p_ni),
1324321936Shselasky			cl_ntoh32(ib_node_info_get_vendor_id(p_ni)));
1325321936Shselasky	}
1326321936Shselasky}
1327321936Shselasky
1328321936Shselaskyvoid osm_dump_node_info(IN osm_log_t * p_log, IN const ib_node_info_t * p_ni,
1329321936Shselasky			IN osm_log_level_t log_level)
1330321936Shselasky{
1331321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1332321936Shselasky		char buf[BUF_SIZE];
1333321936Shselasky
1334321936Shselasky		osm_dump_node_info_to_buf(p_ni, buf);
1335321936Shselasky
1336321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1337321936Shselasky	}
1338321936Shselasky}
1339321936Shselasky
1340321936Shselaskyvoid osm_dump_node_info_v2(IN osm_log_t * p_log, IN const ib_node_info_t * p_ni,
1341321936Shselasky			   IN const int file_id, IN osm_log_level_t log_level)
1342321936Shselasky{
1343321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1344321936Shselasky		char buf[BUF_SIZE];
1345321936Shselasky
1346321936Shselasky		osm_dump_node_info_to_buf(p_ni, buf);
1347321936Shselasky
1348321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1349321936Shselasky	}
1350321936Shselasky}
1351321936Shselasky
1352321936Shselaskystatic void osm_dump_node_record_to_buf(IN const ib_node_record_t * p_nr,
1353321936Shselasky					OUT char * buf)
1354321936Shselasky{
1355321936Shselasky	if (!buf || !p_nr)
1356321936Shselasky		return;
1357321936Shselasky	else {
1358321936Shselasky		char desc[sizeof(p_nr->node_desc.description) + 1];
1359321936Shselasky		const ib_node_info_t *p_ni = &p_nr->node_info;
1360321936Shselasky
1361321936Shselasky		memcpy(desc, p_nr->node_desc.description,
1362321936Shselasky		       sizeof(p_nr->node_desc.description));
1363321936Shselasky		desc[sizeof(desc) - 1] = '\0';
1364321936Shselasky		sprintf(buf,
1365321936Shselasky			"Node Record dump:\n"
1366321936Shselasky			"\t\t\t\tRID\n"
1367321936Shselasky			"\t\t\t\tLid.....................%u\n"
1368321936Shselasky			"\t\t\t\tReserved................0x%X\n"
1369321936Shselasky			"\t\t\t\tNodeInfo dump:\n"
1370321936Shselasky			"\t\t\t\tbase_version............0x%X\n"
1371321936Shselasky			"\t\t\t\tclass_version...........0x%X\n"
1372321936Shselasky			"\t\t\t\tnode_type...............%s\n"
1373321936Shselasky			"\t\t\t\tnum_ports...............%u\n"
1374321936Shselasky			"\t\t\t\tsys_guid................0x%016" PRIx64 "\n"
1375321936Shselasky			"\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
1376321936Shselasky			"\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
1377321936Shselasky			"\t\t\t\tpartition_cap...........0x%X\n"
1378321936Shselasky			"\t\t\t\tdevice_id...............0x%X\n"
1379321936Shselasky			"\t\t\t\trevision................0x%X\n"
1380321936Shselasky			"\t\t\t\tport_num................%u\n"
1381321936Shselasky			"\t\t\t\tvendor_id...............0x%X\n"
1382321936Shselasky			"\t\t\t\tNodeDescription\n"
1383321936Shselasky			"\t\t\t\t%s\n",
1384321936Shselasky			cl_ntoh16(p_nr->lid), cl_ntoh16(p_nr->resv),
1385321936Shselasky			p_ni->base_version, p_ni->class_version,
1386321936Shselasky			ib_get_node_type_str(p_ni->node_type), p_ni->num_ports,
1387321936Shselasky			cl_ntoh64(p_ni->sys_guid), cl_ntoh64(p_ni->node_guid),
1388321936Shselasky			cl_ntoh64(p_ni->port_guid),
1389321936Shselasky			cl_ntoh16(p_ni->partition_cap),
1390321936Shselasky			cl_ntoh16(p_ni->device_id), cl_ntoh32(p_ni->revision),
1391321936Shselasky			ib_node_info_get_local_port_num(p_ni),
1392321936Shselasky			cl_ntoh32(ib_node_info_get_vendor_id(p_ni)), desc);
1393321936Shselasky	}
1394321936Shselasky}
1395321936Shselasky
1396321936Shselaskyvoid osm_dump_node_record(IN osm_log_t * p_log,
1397321936Shselasky			  IN const ib_node_record_t * p_nr,
1398321936Shselasky			  IN osm_log_level_t log_level)
1399321936Shselasky{
1400321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1401321936Shselasky		char buf[BUF_SIZE];
1402321936Shselasky
1403321936Shselasky		osm_dump_node_record_to_buf(p_nr, buf);
1404321936Shselasky
1405321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1406321936Shselasky	}
1407321936Shselasky}
1408321936Shselasky
1409321936Shselaskyvoid osm_dump_node_record_v2(IN osm_log_t * p_log,
1410321936Shselasky			     IN const ib_node_record_t * p_nr,
1411321936Shselasky			     IN const int file_id,
1412321936Shselasky			     IN osm_log_level_t log_level)
1413321936Shselasky{
1414321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1415321936Shselasky		char buf[BUF_SIZE];
1416321936Shselasky
1417321936Shselasky		osm_dump_node_record_to_buf(p_nr, buf);
1418321936Shselasky
1419321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1420321936Shselasky	}
1421321936Shselasky}
1422321936Shselasky
1423321936Shselaskystatic void osm_dump_path_record_to_buf(IN const ib_path_rec_t * p_pr,
1424321936Shselasky					OUT char * buf)
1425321936Shselasky{
1426321936Shselasky	if (!buf || !p_pr)
1427321936Shselasky		return;
1428321936Shselasky	else {
1429321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
1430321936Shselasky		char gid_str2[INET6_ADDRSTRLEN];
1431321936Shselasky
1432321936Shselasky		sprintf(buf,
1433321936Shselasky			"PathRecord dump:\n"
1434321936Shselasky			"\t\t\t\tservice_id..............0x%016" PRIx64 "\n"
1435321936Shselasky			"\t\t\t\tdgid....................%s\n"
1436321936Shselasky			"\t\t\t\tsgid....................%s\n"
1437321936Shselasky			"\t\t\t\tdlid....................%u\n"
1438321936Shselasky			"\t\t\t\tslid....................%u\n"
1439321936Shselasky			"\t\t\t\thop_flow_raw............0x%X\n"
1440321936Shselasky			"\t\t\t\ttclass..................0x%X\n"
1441321936Shselasky			"\t\t\t\tnum_path_revers.........0x%X\n"
1442321936Shselasky			"\t\t\t\tpkey....................0x%X\n"
1443321936Shselasky			"\t\t\t\tqos_class...............0x%X\n"
1444321936Shselasky			"\t\t\t\tsl......................0x%X\n"
1445321936Shselasky			"\t\t\t\tmtu.....................0x%X\n"
1446321936Shselasky			"\t\t\t\trate....................0x%X\n"
1447321936Shselasky			"\t\t\t\tpkt_life................0x%X\n"
1448321936Shselasky			"\t\t\t\tpreference..............0x%X\n"
1449321936Shselasky			"\t\t\t\tresv2...................0x%02X%02X%02X%02X%02X%02X\n",
1450321936Shselasky			cl_ntoh64(p_pr->service_id),
1451321936Shselasky			inet_ntop(AF_INET6, p_pr->dgid.raw, gid_str,
1452321936Shselasky				  sizeof gid_str),
1453321936Shselasky			inet_ntop(AF_INET6, p_pr->sgid.raw, gid_str2,
1454321936Shselasky				  sizeof gid_str2),
1455321936Shselasky			cl_ntoh16(p_pr->dlid), cl_ntoh16(p_pr->slid),
1456321936Shselasky			cl_ntoh32(p_pr->hop_flow_raw), p_pr->tclass,
1457321936Shselasky			p_pr->num_path, cl_ntoh16(p_pr->pkey),
1458321936Shselasky			ib_path_rec_qos_class(p_pr), ib_path_rec_sl(p_pr),
1459321936Shselasky			p_pr->mtu, p_pr->rate, p_pr->pkt_life, p_pr->preference,
1460321936Shselasky			p_pr->resv2[0], p_pr->resv2[1], p_pr->resv2[2],
1461321936Shselasky			p_pr->resv2[3], p_pr->resv2[4], p_pr->resv2[5]);
1462321936Shselasky	}
1463321936Shselasky}
1464321936Shselasky
1465321936Shselaskyvoid osm_dump_path_record(IN osm_log_t * p_log, IN const ib_path_rec_t * p_pr,
1466321936Shselasky			  IN osm_log_level_t log_level)
1467321936Shselasky{
1468321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1469321936Shselasky		char buf[BUF_SIZE];
1470321936Shselasky
1471321936Shselasky		osm_dump_path_record_to_buf(p_pr, buf);
1472321936Shselasky
1473321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1474321936Shselasky	}
1475321936Shselasky}
1476321936Shselasky
1477321936Shselaskyvoid osm_dump_path_record_v2(IN osm_log_t * p_log, IN const ib_path_rec_t * p_pr,
1478321936Shselasky			     IN const int file_id, IN osm_log_level_t log_level)
1479321936Shselasky{
1480321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1481321936Shselasky		char buf[BUF_SIZE];
1482321936Shselasky
1483321936Shselasky		osm_dump_path_record_to_buf(p_pr, buf);
1484321936Shselasky
1485321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1486321936Shselasky	}
1487321936Shselasky}
1488321936Shselasky
1489321936Shselaskystatic void osm_dump_multipath_record_to_buf(IN const ib_multipath_rec_t * p_mpr,
1490321936Shselasky					     OUT char * buf)
1491321936Shselasky{
1492321936Shselasky	if (!buf || !p_mpr)
1493321936Shselasky		return;
1494321936Shselasky	else {
1495321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
1496321936Shselasky		char buf_line[1024];
1497321936Shselasky		ib_gid_t const *p_gid = p_mpr->gids;
1498321936Shselasky		int i, n = 0;
1499321936Shselasky
1500321936Shselasky		if (p_mpr->sgid_count) {
1501321936Shselasky			for (i = 0; i < p_mpr->sgid_count; i++) {
1502321936Shselasky				n += sprintf(buf_line + n,
1503321936Shselasky					     "\t\t\t\tsgid%02d.................."
1504321936Shselasky					     "%s\n", i + 1,
1505321936Shselasky					     inet_ntop(AF_INET6, p_gid->raw,
1506321936Shselasky						       gid_str,
1507321936Shselasky						       sizeof gid_str));
1508321936Shselasky				p_gid++;
1509321936Shselasky			}
1510321936Shselasky		}
1511321936Shselasky		if (p_mpr->dgid_count) {
1512321936Shselasky			for (i = 0; i < p_mpr->dgid_count; i++) {
1513321936Shselasky				n += sprintf(buf_line + n,
1514321936Shselasky					     "\t\t\t\tdgid%02d.................."
1515321936Shselasky					     "%s\n", i + 1,
1516321936Shselasky					     inet_ntop(AF_INET6, p_gid->raw,
1517321936Shselasky						       gid_str,
1518321936Shselasky						       sizeof gid_str));
1519321936Shselasky				p_gid++;
1520321936Shselasky			}
1521321936Shselasky		}
1522321936Shselasky		sprintf(buf,
1523321936Shselasky			"MultiPath Record dump:\n"
1524321936Shselasky			"\t\t\t\thop_flow_raw............0x%X\n"
1525321936Shselasky			"\t\t\t\ttclass..................0x%X\n"
1526321936Shselasky			"\t\t\t\tnum_path_revers.........0x%X\n"
1527321936Shselasky			"\t\t\t\tpkey....................0x%X\n"
1528321936Shselasky			"\t\t\t\tqos_class...............0x%X\n"
1529321936Shselasky			"\t\t\t\tsl......................0x%X\n"
1530321936Shselasky			"\t\t\t\tmtu.....................0x%X\n"
1531321936Shselasky			"\t\t\t\trate....................0x%X\n"
1532321936Shselasky			"\t\t\t\tpkt_life................0x%X\n"
1533321936Shselasky			"\t\t\t\tindependence............0x%X\n"
1534321936Shselasky			"\t\t\t\tsgid_count..............0x%X\n"
1535321936Shselasky			"\t\t\t\tdgid_count..............0x%X\n"
1536321936Shselasky			"\t\t\t\tservice_id..............0x%016" PRIx64 "\n"
1537321936Shselasky			"%s\n",
1538321936Shselasky			cl_ntoh32(p_mpr->hop_flow_raw), p_mpr->tclass,
1539321936Shselasky			p_mpr->num_path, cl_ntoh16(p_mpr->pkey),
1540321936Shselasky			ib_multipath_rec_qos_class(p_mpr),
1541321936Shselasky			ib_multipath_rec_sl(p_mpr), p_mpr->mtu, p_mpr->rate,
1542321936Shselasky			p_mpr->pkt_life, p_mpr->independence,
1543321936Shselasky			p_mpr->sgid_count, p_mpr->dgid_count,
1544321936Shselasky			cl_ntoh64(ib_multipath_rec_service_id(p_mpr)),
1545321936Shselasky			buf_line);
1546321936Shselasky	}
1547321936Shselasky}
1548321936Shselasky
1549321936Shselaskyvoid osm_dump_multipath_record(IN osm_log_t * p_log,
1550321936Shselasky			       IN const ib_multipath_rec_t * p_mpr,
1551321936Shselasky			       IN osm_log_level_t log_level)
1552321936Shselasky{
1553321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1554321936Shselasky		char buf[BUF_SIZE];
1555321936Shselasky
1556321936Shselasky		osm_dump_multipath_record_to_buf(p_mpr, buf);
1557321936Shselasky
1558321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1559321936Shselasky	}
1560321936Shselasky}
1561321936Shselasky
1562321936Shselaskyvoid osm_dump_multipath_record_v2(IN osm_log_t * p_log,
1563321936Shselasky				  IN const ib_multipath_rec_t * p_mpr,
1564321936Shselasky				  IN const int file_id,
1565321936Shselasky				  IN osm_log_level_t log_level)
1566321936Shselasky{
1567321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1568321936Shselasky		char buf[BUF_SIZE];
1569321936Shselasky
1570321936Shselasky		osm_dump_multipath_record_to_buf(p_mpr, buf);
1571321936Shselasky
1572321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1573321936Shselasky	}
1574321936Shselasky}
1575321936Shselasky
1576321936Shselaskystatic void osm_dump_mc_record_to_buf(IN const ib_member_rec_t * p_mcmr,
1577321936Shselasky				      OUT char * buf)
1578321936Shselasky{
1579321936Shselasky	if(!buf || !p_mcmr)
1580321936Shselasky		return;
1581321936Shselasky	else {
1582321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
1583321936Shselasky		char gid_str2[INET6_ADDRSTRLEN];
1584321936Shselasky
1585321936Shselasky		sprintf(buf,
1586321936Shselasky			"MCMember Record dump:\n"
1587321936Shselasky			"\t\t\t\tMGID....................%s\n"
1588321936Shselasky			"\t\t\t\tPortGid.................%s\n"
1589321936Shselasky			"\t\t\t\tqkey....................0x%X\n"
1590321936Shselasky			"\t\t\t\tmlid....................0x%X\n"
1591321936Shselasky			"\t\t\t\tmtu.....................0x%X\n"
1592321936Shselasky			"\t\t\t\tTClass..................0x%X\n"
1593321936Shselasky			"\t\t\t\tpkey....................0x%X\n"
1594321936Shselasky			"\t\t\t\trate....................0x%X\n"
1595321936Shselasky			"\t\t\t\tpkt_life................0x%X\n"
1596321936Shselasky			"\t\t\t\tSLFlowLabelHopLimit.....0x%X\n"
1597321936Shselasky			"\t\t\t\tScopeState..............0x%X\n"
1598321936Shselasky			"\t\t\t\tProxyJoin...............0x%X\n",
1599321936Shselasky			inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str,
1600321936Shselasky				  sizeof gid_str),
1601321936Shselasky			inet_ntop(AF_INET6, p_mcmr->port_gid.raw, gid_str2,
1602321936Shselasky				  sizeof gid_str2),
1603321936Shselasky			cl_ntoh32(p_mcmr->qkey), cl_ntoh16(p_mcmr->mlid),
1604321936Shselasky			p_mcmr->mtu, p_mcmr->tclass, cl_ntoh16(p_mcmr->pkey),
1605321936Shselasky			p_mcmr->rate, p_mcmr->pkt_life,
1606321936Shselasky			cl_ntoh32(p_mcmr->sl_flow_hop),
1607321936Shselasky			p_mcmr->scope_state, p_mcmr->proxy_join);
1608321936Shselasky	}
1609321936Shselasky}
1610321936Shselasky
1611321936Shselaskyvoid osm_dump_mc_record(IN osm_log_t * p_log, IN const ib_member_rec_t * p_mcmr,
1612321936Shselasky			IN osm_log_level_t log_level)
1613321936Shselasky{
1614321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1615321936Shselasky		char buf[BUF_SIZE];
1616321936Shselasky
1617321936Shselasky		osm_dump_mc_record_to_buf(p_mcmr, buf);
1618321936Shselasky
1619321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1620321936Shselasky	}
1621321936Shselasky}
1622321936Shselasky
1623321936Shselaskyvoid osm_dump_mc_record_v2(IN osm_log_t * p_log, IN const ib_member_rec_t * p_mcmr,
1624321936Shselasky			   IN const int file_id, IN osm_log_level_t log_level)
1625321936Shselasky{
1626321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1627321936Shselasky		char buf[BUF_SIZE];
1628321936Shselasky
1629321936Shselasky		osm_dump_mc_record_to_buf(p_mcmr, buf);
1630321936Shselasky
1631321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1632321936Shselasky	}
1633321936Shselasky}
1634321936Shselasky
1635321936Shselaskystatic void osm_dump_service_record_to_buf(IN const ib_service_record_t * p_sr,
1636321936Shselasky					   OUT char * buf)
1637321936Shselasky{
1638321936Shselasky	if (!buf || !p_sr)
1639321936Shselasky		return;
1640321936Shselasky	else {
1641321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
1642321936Shselasky		char buf_service_key[35];
1643321936Shselasky		char buf_service_name[65];
1644321936Shselasky
1645321936Shselasky		sprintf(buf_service_key,
1646321936Shselasky			"0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
1647321936Shselasky			p_sr->service_key[0], p_sr->service_key[1],
1648321936Shselasky			p_sr->service_key[2], p_sr->service_key[3],
1649321936Shselasky			p_sr->service_key[4], p_sr->service_key[5],
1650321936Shselasky			p_sr->service_key[6], p_sr->service_key[7],
1651321936Shselasky			p_sr->service_key[8], p_sr->service_key[9],
1652321936Shselasky			p_sr->service_key[10], p_sr->service_key[11],
1653321936Shselasky			p_sr->service_key[12], p_sr->service_key[13],
1654321936Shselasky			p_sr->service_key[14], p_sr->service_key[15]);
1655321936Shselasky		strncpy(buf_service_name, (char *)p_sr->service_name, 64);
1656321936Shselasky		buf_service_name[64] = '\0';
1657321936Shselasky
1658321936Shselasky		sprintf(buf,
1659321936Shselasky			"Service Record dump:\n"
1660321936Shselasky			"\t\t\t\tServiceID...............0x%016" PRIx64 "\n"
1661321936Shselasky			"\t\t\t\tServiceGID..............%s\n"
1662321936Shselasky			"\t\t\t\tServiceP_Key............0x%X\n"
1663321936Shselasky			"\t\t\t\tServiceLease............0x%X\n"
1664321936Shselasky			"\t\t\t\tServiceKey..............%s\n"
1665321936Shselasky			"\t\t\t\tServiceName.............%s\n"
1666321936Shselasky			"\t\t\t\tServiceData8.1..........0x%X\n"
1667321936Shselasky			"\t\t\t\tServiceData8.2..........0x%X\n"
1668321936Shselasky			"\t\t\t\tServiceData8.3..........0x%X\n"
1669321936Shselasky			"\t\t\t\tServiceData8.4..........0x%X\n"
1670321936Shselasky			"\t\t\t\tServiceData8.5..........0x%X\n"
1671321936Shselasky			"\t\t\t\tServiceData8.6..........0x%X\n"
1672321936Shselasky			"\t\t\t\tServiceData8.7..........0x%X\n"
1673321936Shselasky			"\t\t\t\tServiceData8.8..........0x%X\n"
1674321936Shselasky			"\t\t\t\tServiceData8.9..........0x%X\n"
1675321936Shselasky			"\t\t\t\tServiceData8.10.........0x%X\n"
1676321936Shselasky			"\t\t\t\tServiceData8.11.........0x%X\n"
1677321936Shselasky			"\t\t\t\tServiceData8.12.........0x%X\n"
1678321936Shselasky			"\t\t\t\tServiceData8.13.........0x%X\n"
1679321936Shselasky			"\t\t\t\tServiceData8.14.........0x%X\n"
1680321936Shselasky			"\t\t\t\tServiceData8.15.........0x%X\n"
1681321936Shselasky			"\t\t\t\tServiceData8.16.........0x%X\n"
1682321936Shselasky			"\t\t\t\tServiceData16.1.........0x%X\n"
1683321936Shselasky			"\t\t\t\tServiceData16.2.........0x%X\n"
1684321936Shselasky			"\t\t\t\tServiceData16.3.........0x%X\n"
1685321936Shselasky			"\t\t\t\tServiceData16.4.........0x%X\n"
1686321936Shselasky			"\t\t\t\tServiceData16.5.........0x%X\n"
1687321936Shselasky			"\t\t\t\tServiceData16.6.........0x%X\n"
1688321936Shselasky			"\t\t\t\tServiceData16.7.........0x%X\n"
1689321936Shselasky			"\t\t\t\tServiceData16.8.........0x%X\n"
1690321936Shselasky			"\t\t\t\tServiceData32.1.........0x%X\n"
1691321936Shselasky			"\t\t\t\tServiceData32.2.........0x%X\n"
1692321936Shselasky			"\t\t\t\tServiceData32.3.........0x%X\n"
1693321936Shselasky			"\t\t\t\tServiceData32.4.........0x%X\n"
1694321936Shselasky			"\t\t\t\tServiceData64.1.........0x%016" PRIx64 "\n"
1695321936Shselasky			"\t\t\t\tServiceData64.2.........0x%016" PRIx64 "\n",
1696321936Shselasky			cl_ntoh64(p_sr->service_id),
1697321936Shselasky			inet_ntop(AF_INET6, p_sr->service_gid.raw, gid_str,
1698321936Shselasky				  sizeof gid_str),
1699321936Shselasky			cl_ntoh16(p_sr->service_pkey),
1700321936Shselasky			cl_ntoh32(p_sr->service_lease),
1701321936Shselasky			buf_service_key, buf_service_name,
1702321936Shselasky			p_sr->service_data8[0], p_sr->service_data8[1],
1703321936Shselasky			p_sr->service_data8[2], p_sr->service_data8[3],
1704321936Shselasky			p_sr->service_data8[4], p_sr->service_data8[5],
1705321936Shselasky			p_sr->service_data8[6], p_sr->service_data8[7],
1706321936Shselasky			p_sr->service_data8[8], p_sr->service_data8[9],
1707321936Shselasky			p_sr->service_data8[10], p_sr->service_data8[11],
1708321936Shselasky			p_sr->service_data8[12], p_sr->service_data8[13],
1709321936Shselasky			p_sr->service_data8[14], p_sr->service_data8[15],
1710321936Shselasky			cl_ntoh16(p_sr->service_data16[0]),
1711321936Shselasky			cl_ntoh16(p_sr->service_data16[1]),
1712321936Shselasky			cl_ntoh16(p_sr->service_data16[2]),
1713321936Shselasky			cl_ntoh16(p_sr->service_data16[3]),
1714321936Shselasky			cl_ntoh16(p_sr->service_data16[4]),
1715321936Shselasky			cl_ntoh16(p_sr->service_data16[5]),
1716321936Shselasky			cl_ntoh16(p_sr->service_data16[6]),
1717321936Shselasky			cl_ntoh16(p_sr->service_data16[7]),
1718321936Shselasky			cl_ntoh32(p_sr->service_data32[0]),
1719321936Shselasky			cl_ntoh32(p_sr->service_data32[1]),
1720321936Shselasky			cl_ntoh32(p_sr->service_data32[2]),
1721321936Shselasky			cl_ntoh32(p_sr->service_data32[3]),
1722321936Shselasky			cl_ntoh64(p_sr->service_data64[0]),
1723321936Shselasky			cl_ntoh64(p_sr->service_data64[1]));
1724321936Shselasky	}
1725321936Shselasky}
1726321936Shselasky
1727321936Shselaskyvoid osm_dump_service_record(IN osm_log_t * p_log,
1728321936Shselasky			     IN const ib_service_record_t * p_sr,
1729321936Shselasky			     IN osm_log_level_t log_level)
1730321936Shselasky{
1731321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1732321936Shselasky		char buf[BUF_SIZE];
1733321936Shselasky
1734321936Shselasky		osm_dump_service_record_to_buf(p_sr, buf);
1735321936Shselasky
1736321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1737321936Shselasky	}
1738321936Shselasky}
1739321936Shselasky
1740321936Shselaskyvoid osm_dump_service_record_v2(IN osm_log_t * p_log,
1741321936Shselasky				IN const ib_service_record_t * p_sr,
1742321936Shselasky				IN const int file_id,
1743321936Shselasky				IN osm_log_level_t log_level)
1744321936Shselasky{
1745321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1746321936Shselasky		char buf[BUF_SIZE];
1747321936Shselasky
1748321936Shselasky		osm_dump_service_record_to_buf(p_sr, buf);
1749321936Shselasky
1750321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1751321936Shselasky	}
1752321936Shselasky}
1753321936Shselasky
1754321936Shselaskystatic void osm_dump_inform_info_to_buf_generic(IN const ib_inform_info_t * p_ii,
1755321936Shselasky						OUT char * buf)
1756321936Shselasky{
1757321936Shselasky	if (!buf || !p_ii)
1758321936Shselasky		return;
1759321936Shselasky	else {
1760321936Shselasky		uint32_t qpn;
1761321936Shselasky		uint8_t resp_time_val;
1762321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
1763321936Shselasky
1764321936Shselasky		ib_inform_info_get_qpn_resp_time(p_ii->g_or_v.generic.
1765321936Shselasky						 qpn_resp_time_val, &qpn,
1766321936Shselasky						 &resp_time_val);
1767321936Shselasky		sprintf(buf,
1768321936Shselasky			"InformInfo dump:\n"
1769321936Shselasky			"\t\t\t\tgid.....................%s\n"
1770321936Shselasky			"\t\t\t\tlid_range_begin.........%u\n"
1771321936Shselasky			"\t\t\t\tlid_range_end...........%u\n"
1772321936Shselasky			"\t\t\t\tis_generic..............0x%X\n"
1773321936Shselasky			"\t\t\t\tsubscribe...............0x%X\n"
1774321936Shselasky			"\t\t\t\ttrap_type...............0x%X\n"
1775321936Shselasky			"\t\t\t\ttrap_num................%u\n"
1776321936Shselasky			"\t\t\t\tqpn.....................0x%06X\n"
1777321936Shselasky			"\t\t\t\tresp_time_val...........0x%X\n"
1778321936Shselasky			"\t\t\t\tnode_type...............0x%06X\n" "",
1779321936Shselasky			inet_ntop(AF_INET6, p_ii->gid.raw, gid_str,
1780321936Shselasky				  sizeof gid_str),
1781321936Shselasky			cl_ntoh16(p_ii->lid_range_begin),
1782321936Shselasky			cl_ntoh16(p_ii->lid_range_end),
1783321936Shselasky			p_ii->is_generic, p_ii->subscribe,
1784321936Shselasky			cl_ntoh16(p_ii->trap_type),
1785321936Shselasky			cl_ntoh16(p_ii->g_or_v.generic.trap_num),
1786321936Shselasky			cl_ntoh32(qpn), resp_time_val,
1787321936Shselasky			cl_ntoh32(ib_inform_info_get_prod_type(p_ii)));
1788321936Shselasky	}
1789321936Shselasky}
1790321936Shselasky
1791321936Shselaskystatic void osm_dump_inform_info_to_buf(IN const ib_inform_info_t * p_ii,
1792321936Shselasky					OUT char * buf)
1793321936Shselasky{
1794321936Shselasky	if (!buf || !p_ii)
1795321936Shselasky		return;
1796321936Shselasky	else {
1797321936Shselasky		uint32_t qpn;
1798321936Shselasky		uint8_t resp_time_val;
1799321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
1800321936Shselasky
1801321936Shselasky		ib_inform_info_get_qpn_resp_time(p_ii->g_or_v.generic.
1802321936Shselasky						 qpn_resp_time_val, &qpn,
1803321936Shselasky						 &resp_time_val);
1804321936Shselasky		sprintf(buf,
1805321936Shselasky			"InformInfo dump:\n"
1806321936Shselasky			"\t\t\t\tgid.....................%s\n"
1807321936Shselasky			"\t\t\t\tlid_range_begin.........%u\n"
1808321936Shselasky			"\t\t\t\tlid_range_end...........%u\n"
1809321936Shselasky			"\t\t\t\tis_generic..............0x%X\n"
1810321936Shselasky			"\t\t\t\tsubscribe...............0x%X\n"
1811321936Shselasky			"\t\t\t\ttrap_type...............0x%X\n"
1812321936Shselasky			"\t\t\t\tdev_id..................0x%X\n"
1813321936Shselasky			"\t\t\t\tqpn.....................0x%06X\n"
1814321936Shselasky			"\t\t\t\tresp_time_val...........0x%X\n"
1815321936Shselasky			"\t\t\t\tvendor_id...............0x%06X\n" "",
1816321936Shselasky			inet_ntop(AF_INET6, p_ii->gid.raw, gid_str,
1817321936Shselasky				  sizeof gid_str),
1818321936Shselasky			cl_ntoh16(p_ii->lid_range_begin),
1819321936Shselasky			cl_ntoh16(p_ii->lid_range_end),
1820321936Shselasky			p_ii->is_generic, p_ii->subscribe,
1821321936Shselasky			cl_ntoh16(p_ii->trap_type),
1822321936Shselasky			cl_ntoh16(p_ii->g_or_v.vend.dev_id),
1823321936Shselasky			cl_ntoh32(qpn), resp_time_val,
1824321936Shselasky			cl_ntoh32(ib_inform_info_get_prod_type(p_ii)));
1825321936Shselasky	}
1826321936Shselasky}
1827321936Shselasky
1828321936Shselaskyvoid osm_dump_inform_info(IN osm_log_t * p_log,
1829321936Shselasky			  IN const ib_inform_info_t * p_ii,
1830321936Shselasky			  IN osm_log_level_t log_level)
1831321936Shselasky{
1832321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1833321936Shselasky		char buf[BUF_SIZE];
1834321936Shselasky
1835321936Shselasky		if (p_ii->is_generic)
1836321936Shselasky			osm_dump_inform_info_to_buf_generic(p_ii, buf);
1837321936Shselasky		else
1838321936Shselasky			osm_dump_inform_info_to_buf(p_ii, buf);
1839321936Shselasky
1840321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1841321936Shselasky	}
1842321936Shselasky}
1843321936Shselasky
1844321936Shselaskyvoid osm_dump_inform_info_v2(IN osm_log_t * p_log,
1845321936Shselasky			     IN const ib_inform_info_t * p_ii,
1846321936Shselasky			     IN const int file_id,
1847321936Shselasky			     IN osm_log_level_t log_level)
1848321936Shselasky{
1849321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1850321936Shselasky		char buf[BUF_SIZE];
1851321936Shselasky
1852321936Shselasky		if (p_ii->is_generic)
1853321936Shselasky			osm_dump_inform_info_to_buf_generic(p_ii, buf);
1854321936Shselasky		else
1855321936Shselasky			osm_dump_inform_info_to_buf(p_ii, buf);
1856321936Shselasky
1857321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1858321936Shselasky	}
1859321936Shselasky}
1860321936Shselasky
1861321936Shselaskystatic void osm_dump_inform_info_record_to_buf_generic(IN const ib_inform_info_record_t * p_iir,
1862321936Shselasky						       OUT char * buf)
1863321936Shselasky{
1864321936Shselasky	if (!buf || p_iir)
1865321936Shselasky		return;
1866321936Shselasky	else {
1867321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
1868321936Shselasky		char gid_str2[INET6_ADDRSTRLEN];
1869321936Shselasky		uint32_t qpn;
1870321936Shselasky		uint8_t resp_time_val;
1871321936Shselasky
1872321936Shselasky		ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.
1873321936Shselasky						 generic.qpn_resp_time_val,
1874321936Shselasky						 &qpn, &resp_time_val);
1875321936Shselasky		sprintf(buf,
1876321936Shselasky			"InformInfo Record dump:\n"
1877321936Shselasky			"\t\t\t\tRID\n"
1878321936Shselasky			"\t\t\t\tSubscriberGID...........%s\n"
1879321936Shselasky			"\t\t\t\tSubscriberEnum..........0x%X\n"
1880321936Shselasky			"\t\t\t\tInformInfo dump:\n"
1881321936Shselasky			"\t\t\t\tgid.....................%s\n"
1882321936Shselasky			"\t\t\t\tlid_range_begin.........%u\n"
1883321936Shselasky			"\t\t\t\tlid_range_end...........%u\n"
1884321936Shselasky			"\t\t\t\tis_generic..............0x%X\n"
1885321936Shselasky			"\t\t\t\tsubscribe...............0x%X\n"
1886321936Shselasky			"\t\t\t\ttrap_type...............0x%X\n"
1887321936Shselasky			"\t\t\t\ttrap_num................%u\n"
1888321936Shselasky			"\t\t\t\tqpn.....................0x%06X\n"
1889321936Shselasky			"\t\t\t\tresp_time_val...........0x%X\n"
1890321936Shselasky			"\t\t\t\tnode_type...............0x%06X\n" "",
1891321936Shselasky			inet_ntop(AF_INET6, p_iir->subscriber_gid.raw,
1892321936Shselasky				  gid_str, sizeof gid_str),
1893321936Shselasky			cl_ntoh16(p_iir->subscriber_enum),
1894321936Shselasky			inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
1895321936Shselasky				  gid_str2, sizeof gid_str2),
1896321936Shselasky			cl_ntoh16(p_iir->inform_info.lid_range_begin),
1897321936Shselasky			cl_ntoh16(p_iir->inform_info.lid_range_end),
1898321936Shselasky			p_iir->inform_info.is_generic,
1899321936Shselasky			p_iir->inform_info.subscribe,
1900321936Shselasky			cl_ntoh16(p_iir->inform_info.trap_type),
1901321936Shselasky			cl_ntoh16(p_iir->inform_info.g_or_v.generic.
1902321936Shselasky				  trap_num), cl_ntoh32(qpn),
1903321936Shselasky			resp_time_val,
1904321936Shselasky			cl_ntoh32(ib_inform_info_get_prod_type
1905321936Shselasky				  (&p_iir->inform_info)));
1906321936Shselasky	}
1907321936Shselasky}
1908321936Shselasky
1909321936Shselaskystatic void osm_dump_inform_info_record_to_buf(IN const ib_inform_info_record_t * p_iir,
1910321936Shselasky					       OUT char * buf)
1911321936Shselasky{
1912321936Shselasky	if(!buf || p_iir)
1913321936Shselasky		return;
1914321936Shselasky	else {
1915321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
1916321936Shselasky		char gid_str2[INET6_ADDRSTRLEN];
1917321936Shselasky		uint32_t qpn;
1918321936Shselasky		uint8_t resp_time_val;
1919321936Shselasky
1920321936Shselasky		ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.
1921321936Shselasky						 generic.qpn_resp_time_val,
1922321936Shselasky						 &qpn, &resp_time_val);
1923321936Shselasky		sprintf(buf,
1924321936Shselasky			"InformInfo Record dump:\n"
1925321936Shselasky			"\t\t\t\tRID\n"
1926321936Shselasky			"\t\t\t\tSubscriberGID...........%s\n"
1927321936Shselasky			"\t\t\t\tSubscriberEnum..........0x%X\n"
1928321936Shselasky			"\t\t\t\tInformInfo dump:\n"
1929321936Shselasky			"\t\t\t\tgid.....................%s\n"
1930321936Shselasky			"\t\t\t\tlid_range_begin.........%u\n"
1931321936Shselasky			"\t\t\t\tlid_range_end...........%u\n"
1932321936Shselasky			"\t\t\t\tis_generic..............0x%X\n"
1933321936Shselasky			"\t\t\t\tsubscribe...............0x%X\n"
1934321936Shselasky			"\t\t\t\ttrap_type...............0x%X\n"
1935321936Shselasky			"\t\t\t\tdev_id..................0x%X\n"
1936321936Shselasky			"\t\t\t\tqpn.....................0x%06X\n"
1937321936Shselasky			"\t\t\t\tresp_time_val...........0x%X\n"
1938321936Shselasky			"\t\t\t\tvendor_id...............0x%06X\n" "",
1939321936Shselasky			inet_ntop(AF_INET6, p_iir->subscriber_gid.raw,
1940321936Shselasky				  gid_str, sizeof gid_str),
1941321936Shselasky			cl_ntoh16(p_iir->subscriber_enum),
1942321936Shselasky			inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
1943321936Shselasky				  gid_str2, sizeof gid_str2),
1944321936Shselasky			cl_ntoh16(p_iir->inform_info.lid_range_begin),
1945321936Shselasky			cl_ntoh16(p_iir->inform_info.lid_range_end),
1946321936Shselasky			p_iir->inform_info.is_generic,
1947321936Shselasky			p_iir->inform_info.subscribe,
1948321936Shselasky			cl_ntoh16(p_iir->inform_info.trap_type),
1949321936Shselasky			cl_ntoh16(p_iir->inform_info.g_or_v.vend.
1950321936Shselasky				  dev_id), cl_ntoh32(qpn),
1951321936Shselasky			resp_time_val,
1952321936Shselasky			cl_ntoh32(ib_inform_info_get_prod_type
1953321936Shselasky				  (&p_iir->inform_info)));
1954321936Shselasky	}
1955321936Shselasky}
1956321936Shselasky
1957321936Shselaskyvoid osm_dump_inform_info_record(IN osm_log_t * p_log,
1958321936Shselasky				 IN const ib_inform_info_record_t * p_iir,
1959321936Shselasky				 IN osm_log_level_t log_level)
1960321936Shselasky{
1961321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
1962321936Shselasky		char buf[BUF_SIZE];
1963321936Shselasky
1964321936Shselasky		if (p_iir->inform_info.is_generic)
1965321936Shselasky			osm_dump_inform_info_record_to_buf_generic(p_iir, buf);
1966321936Shselasky		else
1967321936Shselasky			osm_dump_inform_info_record_to_buf(p_iir, buf);
1968321936Shselasky
1969321936Shselasky		osm_log(p_log, log_level, "%s", buf);
1970321936Shselasky	}
1971321936Shselasky}
1972321936Shselasky
1973321936Shselaskyvoid osm_dump_inform_info_record_v2(IN osm_log_t * p_log,
1974321936Shselasky				    IN const ib_inform_info_record_t * p_iir,
1975321936Shselasky				    IN const int file_id,
1976321936Shselasky				    IN osm_log_level_t log_level)
1977321936Shselasky{
1978321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
1979321936Shselasky		char buf[BUF_SIZE];
1980321936Shselasky
1981321936Shselasky		if (p_iir->inform_info.is_generic)
1982321936Shselasky			osm_dump_inform_info_record_to_buf_generic(p_iir, buf);
1983321936Shselasky		else
1984321936Shselasky			osm_dump_inform_info_record_to_buf(p_iir, buf);
1985321936Shselasky
1986321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
1987321936Shselasky	}
1988321936Shselasky}
1989321936Shselasky
1990321936Shselaskystatic void osm_dump_link_record_to_buf(IN const ib_link_record_t * p_lr,
1991321936Shselasky					OUT char * buf)
1992321936Shselasky{
1993321936Shselasky	if (!buf || !p_lr)
1994321936Shselasky		return;
1995321936Shselasky	else {
1996321936Shselasky		sprintf(buf,
1997321936Shselasky			"Link Record dump:\n"
1998321936Shselasky			"\t\t\t\tfrom_lid................%u\n"
1999321936Shselasky			"\t\t\t\tfrom_port_num...........%u\n"
2000321936Shselasky			"\t\t\t\tto_port_num.............%u\n"
2001321936Shselasky			"\t\t\t\tto_lid..................%u\n",
2002321936Shselasky			cl_ntoh16(p_lr->from_lid),
2003321936Shselasky			p_lr->from_port_num,
2004321936Shselasky			p_lr->to_port_num, cl_ntoh16(p_lr->to_lid));
2005321936Shselasky	}
2006321936Shselasky}
2007321936Shselasky
2008321936Shselaskyvoid osm_dump_link_record(IN osm_log_t * p_log,
2009321936Shselasky			  IN const ib_link_record_t * p_lr,
2010321936Shselasky			  IN osm_log_level_t log_level)
2011321936Shselasky{
2012321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2013321936Shselasky		char buf[BUF_SIZE];
2014321936Shselasky
2015321936Shselasky		osm_dump_link_record_to_buf(p_lr, buf);
2016321936Shselasky
2017321936Shselasky		osm_log(p_log, log_level, "%s", buf);
2018321936Shselasky	}
2019321936Shselasky}
2020321936Shselasky
2021321936Shselaskyvoid osm_dump_link_record_v2(IN osm_log_t * p_log,
2022321936Shselasky			     IN const ib_link_record_t * p_lr,
2023321936Shselasky			     IN const int file_id,
2024321936Shselasky			     IN osm_log_level_t log_level)
2025321936Shselasky{
2026321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2027321936Shselasky		char buf[BUF_SIZE];
2028321936Shselasky
2029321936Shselasky		osm_dump_link_record_to_buf(p_lr, buf);
2030321936Shselasky
2031321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
2032321936Shselasky	}
2033321936Shselasky}
2034321936Shselasky
2035321936Shselaskystatic void osm_dump_switch_info_to_buf(IN const ib_switch_info_t * p_si,
2036321936Shselasky					OUT char * buf)
2037321936Shselasky{
2038321936Shselasky	if (!buf || !p_si)
2039321936Shselasky		return;
2040321936Shselasky	else {
2041321936Shselasky		sprintf(buf,
2042321936Shselasky			"SwitchInfo dump:\n"
2043321936Shselasky			"\t\t\t\tlin_cap.................0x%X\n"
2044321936Shselasky			"\t\t\t\trand_cap................0x%X\n"
2045321936Shselasky			"\t\t\t\tmcast_cap...............0x%X\n"
2046321936Shselasky			"\t\t\t\tlin_top.................0x%X\n"
2047321936Shselasky			"\t\t\t\tdef_port................%u\n"
2048321936Shselasky			"\t\t\t\tdef_mcast_pri_port......%u\n"
2049321936Shselasky			"\t\t\t\tdef_mcast_not_port......%u\n"
2050321936Shselasky			"\t\t\t\tlife_state..............0x%X\n"
2051321936Shselasky			"\t\t\t\tlids_per_port...........%u\n"
2052321936Shselasky			"\t\t\t\tpartition_enf_cap.......0x%X\n"
2053321936Shselasky			"\t\t\t\tflags...................0x%X\n"
2054321936Shselasky			"\t\t\t\tmcast_top...............0x%X\n",
2055321936Shselasky			cl_ntoh16(p_si->lin_cap), cl_ntoh16(p_si->rand_cap),
2056321936Shselasky			cl_ntoh16(p_si->mcast_cap), cl_ntoh16(p_si->lin_top),
2057321936Shselasky			p_si->def_port, p_si->def_mcast_pri_port,
2058321936Shselasky			p_si->def_mcast_not_port, p_si->life_state,
2059321936Shselasky			cl_ntoh16(p_si->lids_per_port),
2060321936Shselasky			cl_ntoh16(p_si->enforce_cap), p_si->flags,
2061321936Shselasky			cl_ntoh16(p_si->mcast_top));
2062321936Shselasky	}
2063321936Shselasky}
2064321936Shselasky
2065321936Shselaskyvoid osm_dump_switch_info(IN osm_log_t * p_log,
2066321936Shselasky			  IN const ib_switch_info_t * p_si,
2067321936Shselasky			  IN osm_log_level_t log_level)
2068321936Shselasky{
2069321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2070321936Shselasky		char buf[BUF_SIZE];
2071321936Shselasky
2072321936Shselasky		osm_dump_switch_info_to_buf(p_si, buf);
2073321936Shselasky
2074321936Shselasky		osm_log(p_log, OSM_LOG_VERBOSE, "%s", buf);
2075321936Shselasky	}
2076321936Shselasky}
2077321936Shselasky
2078321936Shselaskyvoid osm_dump_switch_info_v2(IN osm_log_t * p_log,
2079321936Shselasky			     IN const ib_switch_info_t * p_si,
2080321936Shselasky			     IN const int file_id,
2081321936Shselasky			     IN osm_log_level_t log_level)
2082321936Shselasky{
2083321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2084321936Shselasky		char buf[BUF_SIZE];
2085321936Shselasky
2086321936Shselasky		osm_dump_switch_info_to_buf(p_si, buf);
2087321936Shselasky
2088321936Shselasky		osm_log_v2(p_log, OSM_LOG_VERBOSE, file_id, "%s", buf);
2089321936Shselasky	}
2090321936Shselasky}
2091321936Shselasky
2092321936Shselaskystatic void osm_dump_switch_info_record_to_buf(IN const ib_switch_info_record_t * p_sir,
2093321936Shselasky					       OUT char * buf)
2094321936Shselasky{
2095321936Shselasky	if (!buf || !p_sir)
2096321936Shselasky		return;
2097321936Shselasky	else {
2098321936Shselasky		sprintf(buf,
2099321936Shselasky			"SwitchInfo Record dump:\n"
2100321936Shselasky			"\t\t\t\tRID\n"
2101321936Shselasky			"\t\t\t\tlid.....................%u\n"
2102321936Shselasky			"\t\t\t\tSwitchInfo dump:\n"
2103321936Shselasky			"\t\t\t\tlin_cap.................0x%X\n"
2104321936Shselasky			"\t\t\t\trand_cap................0x%X\n"
2105321936Shselasky			"\t\t\t\tmcast_cap...............0x%X\n"
2106321936Shselasky			"\t\t\t\tlin_top.................0x%X\n"
2107321936Shselasky			"\t\t\t\tdef_port................%u\n"
2108321936Shselasky			"\t\t\t\tdef_mcast_pri_port......%u\n"
2109321936Shselasky			"\t\t\t\tdef_mcast_not_port......%u\n"
2110321936Shselasky			"\t\t\t\tlife_state..............0x%X\n"
2111321936Shselasky			"\t\t\t\tlids_per_port...........%u\n"
2112321936Shselasky			"\t\t\t\tpartition_enf_cap.......0x%X\n"
2113321936Shselasky			"\t\t\t\tflags...................0x%X\n",
2114321936Shselasky			cl_ntoh16(p_sir->lid),
2115321936Shselasky			cl_ntoh16(p_sir->switch_info.lin_cap),
2116321936Shselasky			cl_ntoh16(p_sir->switch_info.rand_cap),
2117321936Shselasky			cl_ntoh16(p_sir->switch_info.mcast_cap),
2118321936Shselasky			cl_ntoh16(p_sir->switch_info.lin_top),
2119321936Shselasky			p_sir->switch_info.def_port,
2120321936Shselasky			p_sir->switch_info.def_mcast_pri_port,
2121321936Shselasky			p_sir->switch_info.def_mcast_not_port,
2122321936Shselasky			p_sir->switch_info.life_state,
2123321936Shselasky			cl_ntoh16(p_sir->switch_info.lids_per_port),
2124321936Shselasky			cl_ntoh16(p_sir->switch_info.enforce_cap),
2125321936Shselasky			p_sir->switch_info.flags);
2126321936Shselasky	}
2127321936Shselasky}
2128321936Shselasky
2129321936Shselaskyvoid osm_dump_switch_info_record(IN osm_log_t * p_log,
2130321936Shselasky				 IN const ib_switch_info_record_t * p_sir,
2131321936Shselasky				 IN osm_log_level_t log_level)
2132321936Shselasky{
2133321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2134321936Shselasky		char buf[BUF_SIZE];
2135321936Shselasky
2136321936Shselasky		osm_dump_switch_info_record_to_buf(p_sir, buf);
2137321936Shselasky
2138321936Shselasky		osm_log(p_log, log_level, "%s", buf);
2139321936Shselasky	}
2140321936Shselasky}
2141321936Shselasky
2142321936Shselaskyvoid osm_dump_switch_info_record_v2(IN osm_log_t * p_log,
2143321936Shselasky				    IN const ib_switch_info_record_t * p_sir,
2144321936Shselasky				    IN const int file_id,
2145321936Shselasky				    IN osm_log_level_t log_level)
2146321936Shselasky{
2147321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2148321936Shselasky		char buf[BUF_SIZE];
2149321936Shselasky
2150321936Shselasky		osm_dump_switch_info_record_to_buf(p_sir, buf);
2151321936Shselasky
2152321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
2153321936Shselasky	}
2154321936Shselasky}
2155321936Shselasky
2156321936Shselaskystatic void osm_dump_pkey_block_to_buf(IN uint64_t port_guid,
2157321936Shselasky				       IN uint16_t block_num,
2158321936Shselasky				       IN uint8_t port_num,
2159321936Shselasky				       IN const ib_pkey_table_t * p_pkey_tbl,
2160321936Shselasky				       OUT char * buf)
2161321936Shselasky{
2162321936Shselasky	if (!buf || !p_pkey_tbl)
2163321936Shselasky		return;
2164321936Shselasky	else {
2165321936Shselasky		char buf_line[1024];
2166321936Shselasky		int i, n;
2167321936Shselasky
2168321936Shselasky		for (i = 0, n = 0; i < 32; i++)
2169321936Shselasky			n += sprintf(buf_line + n, " 0x%04x |",
2170321936Shselasky				     cl_ntoh16(p_pkey_tbl->pkey_entry[i]));
2171321936Shselasky
2172321936Shselasky		sprintf(buf,
2173321936Shselasky			"P_Key table dump:\n"
2174321936Shselasky			"\t\t\tport_guid...........0x%016" PRIx64 "\n"
2175321936Shselasky			"\t\t\tblock_num...........0x%X\n"
2176321936Shselasky			"\t\t\tport_num............%u\n\tP_Key Table: %s\n",
2177321936Shselasky			cl_ntoh64(port_guid), block_num, port_num, buf_line);
2178321936Shselasky	}
2179321936Shselasky}
2180321936Shselasky
2181321936Shselaskyvoid osm_dump_pkey_block(IN osm_log_t * p_log, IN uint64_t port_guid,
2182321936Shselasky			 IN uint16_t block_num, IN uint8_t port_num,
2183321936Shselasky			 IN const ib_pkey_table_t * p_pkey_tbl,
2184321936Shselasky			 IN osm_log_level_t log_level)
2185321936Shselasky{
2186321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2187321936Shselasky		char buf[BUF_SIZE];
2188321936Shselasky
2189321936Shselasky		osm_dump_pkey_block_to_buf(port_guid, block_num, port_num,
2190321936Shselasky					   p_pkey_tbl, buf);
2191321936Shselasky
2192321936Shselasky		osm_log(p_log, log_level, "%s", buf);
2193321936Shselasky	}
2194321936Shselasky}
2195321936Shselasky
2196321936Shselaskyvoid osm_dump_pkey_block_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
2197321936Shselasky			    IN uint16_t block_num, IN uint8_t port_num,
2198321936Shselasky			    IN const ib_pkey_table_t * p_pkey_tbl,
2199321936Shselasky			    IN const int file_id,
2200321936Shselasky			    IN osm_log_level_t log_level)
2201321936Shselasky{
2202321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2203321936Shselasky		char buf[BUF_SIZE];
2204321936Shselasky
2205321936Shselasky		osm_dump_pkey_block_to_buf(port_guid, block_num,
2206321936Shselasky					   port_num, p_pkey_tbl, buf);
2207321936Shselasky
2208321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
2209321936Shselasky	}
2210321936Shselasky}
2211321936Shselasky
2212321936Shselaskystatic void osm_dump_slvl_map_table_to_buf(IN uint64_t port_guid,
2213321936Shselasky					   IN uint8_t in_port_num,
2214321936Shselasky					   IN uint8_t out_port_num,
2215321936Shselasky					   IN const ib_slvl_table_t * p_slvl_tbl,
2216321936Shselasky					   OUT char * buf)
2217321936Shselasky{
2218321936Shselasky	if (!buf || !p_slvl_tbl)
2219321936Shselasky		return;
2220321936Shselasky	else {
2221321936Shselasky		char buf_line1[1024], buf_line2[1024];
2222321936Shselasky		int n;
2223321936Shselasky		uint8_t i;
2224321936Shselasky
2225321936Shselasky		for (i = 0, n = 0; i < 16; i++)
2226321936Shselasky			n += sprintf(buf_line1 + n, " %-2u |", i);
2227321936Shselasky		for (i = 0, n = 0; i < 16; i++)
2228321936Shselasky			n += sprintf(buf_line2 + n, "0x%01X |",
2229321936Shselasky				     ib_slvl_table_get(p_slvl_tbl, i));
2230321936Shselasky		sprintf(buf,
2231321936Shselasky			"SLtoVL dump:\n"
2232321936Shselasky			"\t\t\tport_guid............0x%016" PRIx64 "\n"
2233321936Shselasky			"\t\t\tin_port_num..........%u\n"
2234321936Shselasky			"\t\t\tout_port_num.........%u\n\tSL: | %s\n\tVL: | %s\n",
2235321936Shselasky			cl_ntoh64(port_guid), in_port_num, out_port_num,
2236321936Shselasky			buf_line1, buf_line2);
2237321936Shselasky	}
2238321936Shselasky}
2239321936Shselasky
2240321936Shselaskyvoid osm_dump_slvl_map_table(IN osm_log_t * p_log, IN uint64_t port_guid,
2241321936Shselasky			     IN uint8_t in_port_num, IN uint8_t out_port_num,
2242321936Shselasky			     IN const ib_slvl_table_t * p_slvl_tbl,
2243321936Shselasky			     IN osm_log_level_t log_level)
2244321936Shselasky{
2245321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2246321936Shselasky		char buf[BUF_SIZE];
2247321936Shselasky
2248321936Shselasky		osm_dump_slvl_map_table_to_buf(port_guid, in_port_num,
2249321936Shselasky					       out_port_num, p_slvl_tbl, buf);
2250321936Shselasky
2251321936Shselasky		osm_log(p_log, log_level, "%s", buf);
2252321936Shselasky	}
2253321936Shselasky}
2254321936Shselasky
2255321936Shselaskyvoid osm_dump_slvl_map_table_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
2256321936Shselasky				IN uint8_t in_port_num, IN uint8_t out_port_num,
2257321936Shselasky				IN const ib_slvl_table_t * p_slvl_tbl,
2258321936Shselasky				IN const int file_id,
2259321936Shselasky				IN osm_log_level_t log_level)
2260321936Shselasky{
2261321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2262321936Shselasky		char buf[BUF_SIZE];
2263321936Shselasky
2264321936Shselasky		osm_dump_slvl_map_table_to_buf(port_guid, in_port_num,
2265321936Shselasky					       out_port_num, p_slvl_tbl, buf);
2266321936Shselasky
2267321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
2268321936Shselasky	}
2269321936Shselasky}
2270321936Shselasky
2271321936Shselaskystatic void osm_dump_vl_arb_table_to_buf(IN uint64_t port_guid,
2272321936Shselasky					 IN uint8_t block_num,
2273321936Shselasky					 IN uint8_t port_num,
2274321936Shselasky					 IN const ib_vl_arb_table_t * p_vla_tbl,
2275321936Shselasky					 OUT char * buf)
2276321936Shselasky{
2277321936Shselasky	if (!buf || !p_vla_tbl)
2278321936Shselasky		return;
2279321936Shselasky	else {
2280321936Shselasky		char buf_line1[1024], buf_line2[1024];
2281321936Shselasky		int i, n;
2282321936Shselasky
2283321936Shselasky		for (i = 0, n = 0; i < 32; i++)
2284321936Shselasky			n += sprintf(buf_line1 + n, " 0x%01X |",
2285321936Shselasky				     p_vla_tbl->vl_entry[i].vl);
2286321936Shselasky		for (i = 0, n = 0; i < 32; i++)
2287321936Shselasky			n += sprintf(buf_line2 + n, " 0x%01X |",
2288321936Shselasky				     p_vla_tbl->vl_entry[i].weight);
2289321936Shselasky		sprintf(buf,
2290321936Shselasky			"VLArb dump:\n" "\t\t\tport_guid...........0x%016"
2291321936Shselasky			PRIx64 "\n" "\t\t\tblock_num...........0x%X\n"
2292321936Shselasky			"\t\t\tport_num............%u\n\tVL    : | %s\n\tWEIGHT:| %s\n",
2293321936Shselasky			cl_ntoh64(port_guid), block_num, port_num, buf_line1,
2294321936Shselasky			buf_line2);
2295321936Shselasky	}
2296321936Shselasky}
2297321936Shselasky
2298321936Shselaskyvoid osm_dump_vl_arb_table(IN osm_log_t * p_log, IN uint64_t port_guid,
2299321936Shselasky			   IN uint8_t block_num, IN uint8_t port_num,
2300321936Shselasky			   IN const ib_vl_arb_table_t * p_vla_tbl,
2301321936Shselasky			   IN osm_log_level_t log_level)
2302321936Shselasky{
2303321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2304321936Shselasky		char buf[BUF_SIZE];
2305321936Shselasky
2306321936Shselasky		osm_dump_vl_arb_table_to_buf(port_guid, block_num,
2307321936Shselasky					     port_num, p_vla_tbl, buf);
2308321936Shselasky
2309321936Shselasky		osm_log(p_log, log_level, "%s", buf);
2310321936Shselasky	}
2311321936Shselasky}
2312321936Shselasky
2313321936Shselaskyvoid osm_dump_vl_arb_table_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
2314321936Shselasky			      IN uint8_t block_num, IN uint8_t port_num,
2315321936Shselasky			      IN const ib_vl_arb_table_t * p_vla_tbl,
2316321936Shselasky			      IN const int file_id,
2317321936Shselasky			      IN osm_log_level_t log_level)
2318321936Shselasky{
2319321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2320321936Shselasky		char buf[BUF_SIZE];
2321321936Shselasky
2322321936Shselasky		osm_dump_vl_arb_table_to_buf(port_guid, block_num,
2323321936Shselasky					     port_num, p_vla_tbl, buf);
2324321936Shselasky
2325321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
2326321936Shselasky	}
2327321936Shselasky}
2328321936Shselasky
2329321936Shselaskystatic void osm_dump_sm_info_to_buf(IN const ib_sm_info_t * p_smi,
2330321936Shselasky				    OUT char * buf)
2331321936Shselasky{
2332321936Shselasky	if (!buf || !p_smi)
2333321936Shselasky		return;
2334321936Shselasky	else {
2335321936Shselasky		sprintf(buf,
2336321936Shselasky			"SMInfo dump:\n"
2337321936Shselasky			"\t\t\t\tguid....................0x%016" PRIx64 "\n"
2338321936Shselasky			"\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
2339321936Shselasky			"\t\t\t\tact_count...............%u\n"
2340321936Shselasky			"\t\t\t\tpriority................%u\n"
2341321936Shselasky			"\t\t\t\tsm_state................%u\n",
2342321936Shselasky			cl_ntoh64(p_smi->guid), cl_ntoh64(p_smi->sm_key),
2343321936Shselasky			cl_ntoh32(p_smi->act_count),
2344321936Shselasky			ib_sminfo_get_priority(p_smi),
2345321936Shselasky			ib_sminfo_get_state(p_smi));
2346321936Shselasky	}
2347321936Shselasky}
2348321936Shselasky
2349321936Shselaskyvoid osm_dump_sm_info(IN osm_log_t * p_log, IN const ib_sm_info_t * p_smi,
2350321936Shselasky		      IN osm_log_level_t log_level)
2351321936Shselasky{
2352321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2353321936Shselasky		char buf[BUF_SIZE];
2354321936Shselasky
2355321936Shselasky		osm_dump_sm_info_to_buf(p_smi, buf);
2356321936Shselasky
2357321936Shselasky		osm_log(p_log, OSM_LOG_DEBUG, "%s", buf);
2358321936Shselasky	}
2359321936Shselasky}
2360321936Shselasky
2361321936Shselaskyvoid osm_dump_sm_info_v2(IN osm_log_t * p_log, IN const ib_sm_info_t * p_smi,
2362321936Shselasky			 IN const int file_id, IN osm_log_level_t log_level)
2363321936Shselasky{
2364321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2365321936Shselasky		char buf[BUF_SIZE];
2366321936Shselasky
2367321936Shselasky		osm_dump_sm_info_to_buf(p_smi, buf);
2368321936Shselasky
2369321936Shselasky		osm_log_v2(p_log, OSM_LOG_DEBUG, file_id, "%s", buf);
2370321936Shselasky	}
2371321936Shselasky}
2372321936Shselasky
2373321936Shselaskystatic void osm_dump_sm_info_record_to_buf(IN const ib_sminfo_record_t * p_smir,
2374321936Shselasky					   OUT char * buf)
2375321936Shselasky{
2376321936Shselasky	if (!buf || !p_smir)
2377321936Shselasky		return;
2378321936Shselasky	else {
2379321936Shselasky		sprintf(buf,
2380321936Shselasky			"SMInfo Record dump:\n"
2381321936Shselasky			"\t\t\t\tRID\n"
2382321936Shselasky			"\t\t\t\tLid.....................%u\n"
2383321936Shselasky			"\t\t\t\tReserved................0x%X\n"
2384321936Shselasky			"\t\t\t\tSMInfo dump:\n"
2385321936Shselasky			"\t\t\t\tguid....................0x%016" PRIx64 "\n"
2386321936Shselasky			"\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
2387321936Shselasky			"\t\t\t\tact_count...............%u\n"
2388321936Shselasky			"\t\t\t\tpriority................%u\n"
2389321936Shselasky			"\t\t\t\tsm_state................%u\n",
2390321936Shselasky			cl_ntoh16(p_smir->lid), cl_ntoh16(p_smir->resv0),
2391321936Shselasky			cl_ntoh64(p_smir->sm_info.guid),
2392321936Shselasky			cl_ntoh64(p_smir->sm_info.sm_key),
2393321936Shselasky			cl_ntoh32(p_smir->sm_info.act_count),
2394321936Shselasky			ib_sminfo_get_priority(&p_smir->sm_info),
2395321936Shselasky			ib_sminfo_get_state(&p_smir->sm_info));
2396321936Shselasky	}
2397321936Shselasky}
2398321936Shselasky
2399321936Shselaskyvoid osm_dump_sm_info_record(IN osm_log_t * p_log,
2400321936Shselasky			     IN const ib_sminfo_record_t * p_smir,
2401321936Shselasky			     IN osm_log_level_t log_level)
2402321936Shselasky{
2403321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2404321936Shselasky		char buf[BUF_SIZE];
2405321936Shselasky
2406321936Shselasky		osm_dump_sm_info_record_to_buf(p_smir, buf);
2407321936Shselasky
2408321936Shselasky		osm_log(p_log, OSM_LOG_DEBUG, "%s", buf);
2409321936Shselasky	}
2410321936Shselasky}
2411321936Shselasky
2412321936Shselaskyvoid osm_dump_sm_info_record_v2(IN osm_log_t * p_log,
2413321936Shselasky				IN const ib_sminfo_record_t * p_smir,
2414321936Shselasky				IN const int file_id,
2415321936Shselasky				IN osm_log_level_t log_level)
2416321936Shselasky{
2417321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2418321936Shselasky		char buf[BUF_SIZE];
2419321936Shselasky
2420321936Shselasky		osm_dump_sm_info_record_to_buf(p_smir, buf);
2421321936Shselasky
2422321936Shselasky		osm_log_v2(p_log, OSM_LOG_DEBUG, file_id, "%s", buf);
2423321936Shselasky	}
2424321936Shselasky}
2425321936Shselasky
2426321936Shselaskystatic void osm_dump_notice_to_buf_generic(IN const ib_mad_notice_attr_t * p_ntci,
2427321936Shselasky					   OUT char * log_buf)
2428321936Shselasky{
2429321936Shselasky	if (!log_buf || !p_ntci)
2430321936Shselasky		return;
2431321936Shselasky	else {
2432321936Shselasky		char gid_str[INET6_ADDRSTRLEN];
2433321936Shselasky		char gid_str2[INET6_ADDRSTRLEN];
2434321936Shselasky		char buff[1024];
2435321936Shselasky		int n;
2436321936Shselasky
2437321936Shselasky		buff[0] = '\0';
2438321936Shselasky
2439321936Shselasky		/* immediate data based on the trap */
2440321936Shselasky		switch (cl_ntoh16(p_ntci->g_or_v.generic.trap_num)) {
2441321936Shselasky		case SM_GID_IN_SERVICE_TRAP:	/* 64 */
2442321936Shselasky		case SM_GID_OUT_OF_SERVICE_TRAP: /* 65 */
2443321936Shselasky		case SM_MGID_CREATED_TRAP:	/* 66 */
2444321936Shselasky		case SM_MGID_DESTROYED_TRAP:	/* 67 */
2445321936Shselasky			sprintf(buff,
2446321936Shselasky				"\t\t\t\tsrc_gid..................%s\n",
2447321936Shselasky				inet_ntop(AF_INET6, p_ntci->data_details.
2448321936Shselasky					  ntc_64_67.gid.raw, gid_str,
2449321936Shselasky					  sizeof gid_str));
2450321936Shselasky			break;
2451321936Shselasky		case SM_LINK_STATE_CHANGED_TRAP: /* 128 */
2452321936Shselasky			sprintf(buff,
2453321936Shselasky				"\t\t\t\tsw_lid...................%u\n",
2454321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_128.sw_lid));
2455321936Shselasky			break;
2456321936Shselasky		case SM_LINK_INTEGRITY_THRESHOLD_TRAP: /* 129 */
2457321936Shselasky		case SM_BUFFER_OVERRUN_THRESHOLD_TRAP: /* 130 */
2458321936Shselasky		case SM_WATCHDOG_TIMER_EXPIRED_TRAP:   /* 131 */
2459321936Shselasky			sprintf(buff,
2460321936Shselasky				"\t\t\t\tlid......................%u\n"
2461321936Shselasky				"\t\t\t\tport_num.................%u\n",
2462321936Shselasky				cl_ntoh16(p_ntci->data_details.
2463321936Shselasky					  ntc_129_131.lid),
2464321936Shselasky				p_ntci->data_details.ntc_129_131.port_num);
2465321936Shselasky			break;
2466321936Shselasky		case SM_LOCAL_CHANGES_TRAP:	/* 144 */
2467321936Shselasky			sprintf(buff,
2468321936Shselasky				"\t\t\t\tlid......................%u\n"
2469321936Shselasky				"\t\t\t\tlocal_changes............%u\n"
2470321936Shselasky				"\t\t\t\tnew_cap_mask.............0x%08x\n"
2471321936Shselasky				"\t\t\t\tchange_flags.............0x%x\n"
2472321936Shselasky				"\t\t\t\tcap_mask2................0x%x\n",
2473321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_144.lid),
2474321936Shselasky				p_ntci->data_details.ntc_144.local_changes,
2475321936Shselasky				cl_ntoh32(p_ntci->data_details.ntc_144.
2476321936Shselasky					  new_cap_mask),
2477321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_144.
2478321936Shselasky					  change_flgs),
2479321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_144.
2480321936Shselasky					  cap_mask2));
2481321936Shselasky			break;
2482321936Shselasky		case SM_SYS_IMG_GUID_CHANGED_TRAP: /* 145 */
2483321936Shselasky			sprintf(buff,
2484321936Shselasky				"\t\t\t\tlid......................%u\n"
2485321936Shselasky				"\t\t\t\tnew_sys_guid.............0x%016"
2486321936Shselasky				PRIx64 "\n",
2487321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_145.
2488321936Shselasky					  lid),
2489321936Shselasky				cl_ntoh64(p_ntci->data_details.ntc_145.
2490321936Shselasky					  new_sys_guid));
2491321936Shselasky			break;
2492321936Shselasky		case SM_BAD_MKEY_TRAP:	/* 256 */
2493321936Shselasky			n = sprintf(buff,
2494321936Shselasky				    "\t\t\t\tlid......................%u\n"
2495321936Shselasky				    "\t\t\t\tdrslid...................%u\n"
2496321936Shselasky				    "\t\t\t\tmethod...................0x%x\n"
2497321936Shselasky				    "\t\t\t\tattr_id..................0x%x\n"
2498321936Shselasky				    "\t\t\t\tattr_mod.................0x%x\n"
2499321936Shselasky				    "\t\t\t\tm_key....................0x%016"
2500321936Shselasky				    PRIx64 "\n"
2501321936Shselasky				    "\t\t\t\tdr_notice................%d\n"
2502321936Shselasky				    "\t\t\t\tdr_path_truncated........%d\n"
2503321936Shselasky				    "\t\t\t\tdr_hop_count.............%u\n",
2504321936Shselasky				    cl_ntoh16(p_ntci->data_details.ntc_256.lid),
2505321936Shselasky				    cl_ntoh16(p_ntci->data_details.ntc_256.
2506321936Shselasky					      dr_slid),
2507321936Shselasky				    p_ntci->data_details.ntc_256.method,
2508321936Shselasky				    cl_ntoh16(p_ntci->data_details.ntc_256.
2509321936Shselasky					      attr_id),
2510321936Shselasky				    cl_ntoh32(p_ntci->data_details.ntc_256.
2511321936Shselasky					      attr_mod),
2512321936Shselasky				    cl_ntoh64(p_ntci->data_details.ntc_256.
2513321936Shselasky					      mkey),
2514321936Shselasky				    p_ntci->data_details.ntc_256.
2515321936Shselasky				    dr_trunc_hop >> 7,
2516321936Shselasky				    p_ntci->data_details.ntc_256.
2517321936Shselasky				    dr_trunc_hop >> 6,
2518321936Shselasky				    p_ntci->data_details.ntc_256.
2519321936Shselasky				    dr_trunc_hop & 0x3f);
2520321936Shselasky			n += snprintf(buff + n, sizeof(buff) - n,
2521321936Shselasky				      "Directed Path Dump of %u hop path:"
2522321936Shselasky				      "\n\t\t\t\tPath = ",
2523321936Shselasky				      p_ntci->data_details.ntc_256.
2524321936Shselasky				      dr_trunc_hop & 0x3f);
2525321936Shselasky			n += sprint_uint8_arr(buff + n, sizeof(buff) - n,
2526321936Shselasky					      p_ntci->data_details.ntc_256.
2527321936Shselasky					      dr_rtn_path,
2528321936Shselasky					      (p_ntci->data_details.ntc_256.
2529321936Shselasky					       dr_trunc_hop & 0x3f) + 1);
2530321936Shselasky			if (n >= sizeof(buff)) {
2531321936Shselasky				n = sizeof(buff) - 2;
2532321936Shselasky				break;
2533321936Shselasky			}
2534321936Shselasky			snprintf(buff + n, sizeof(buff) - n, "\n");
2535321936Shselasky			break;
2536321936Shselasky		case SM_BAD_PKEY_TRAP:	/* 257 */
2537321936Shselasky		case SM_BAD_QKEY_TRAP:	/* 258 */
2538321936Shselasky			sprintf(buff,
2539321936Shselasky				"\t\t\t\tlid1.....................%u\n"
2540321936Shselasky				"\t\t\t\tlid2.....................%u\n"
2541321936Shselasky				"\t\t\t\tkey......................0x%x\n"
2542321936Shselasky				"\t\t\t\tsl.......................%d\n"
2543321936Shselasky				"\t\t\t\tqp1......................0x%x\n"
2544321936Shselasky				"\t\t\t\tqp2......................0x%x\n"
2545321936Shselasky				"\t\t\t\tgid1.....................%s\n"
2546321936Shselasky				"\t\t\t\tgid2.....................%s\n",
2547321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_257_258.
2548321936Shselasky					  lid1),
2549321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_257_258.
2550321936Shselasky					  lid2),
2551321936Shselasky				cl_ntoh32(p_ntci->data_details.ntc_257_258.key),
2552321936Shselasky				cl_ntoh32(p_ntci->data_details.ntc_257_258.
2553321936Shselasky					  qp1) >> 28,
2554321936Shselasky				cl_ntoh32(p_ntci->data_details.ntc_257_258.
2555321936Shselasky					  qp1) & 0xffffff,
2556321936Shselasky				cl_ntoh32(p_ntci->data_details.ntc_257_258.
2557321936Shselasky					  qp2) & 0xffffff,
2558321936Shselasky				inet_ntop(AF_INET6, p_ntci->data_details.
2559321936Shselasky					  ntc_257_258.gid1.raw, gid_str,
2560321936Shselasky					  sizeof gid_str),
2561321936Shselasky				inet_ntop(AF_INET6, p_ntci->data_details.
2562321936Shselasky					  ntc_257_258.gid2.raw, gid_str2,
2563321936Shselasky					  sizeof gid_str2));
2564321936Shselasky			break;
2565321936Shselasky		case SM_BAD_SWITCH_PKEY_TRAP:	/* 259 */
2566321936Shselasky			sprintf(buff,
2567321936Shselasky				"\t\t\t\tdata_valid...............0x%x\n"
2568321936Shselasky				"\t\t\t\tlid1.....................%u\n"
2569321936Shselasky				"\t\t\t\tlid2.....................%u\n"
2570321936Shselasky				"\t\t\t\tpkey.....................0x%x\n"
2571321936Shselasky				"\t\t\t\tsl.......................%d\n"
2572321936Shselasky				"\t\t\t\tqp1......................0x%x\n"
2573321936Shselasky				"\t\t\t\tqp2......................0x%x\n"
2574321936Shselasky				"\t\t\t\tgid1.....................%s\n"
2575321936Shselasky				"\t\t\t\tgid2.....................%s\n"
2576321936Shselasky				"\t\t\t\tsw_lid...................%u\n"
2577321936Shselasky				"\t\t\t\tport_no..................%u\n",
2578321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_259.
2579321936Shselasky					  data_valid),
2580321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_259.lid1),
2581321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_259.lid2),
2582321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_259.pkey),
2583321936Shselasky				cl_ntoh32(p_ntci->data_details.ntc_259.
2584321936Shselasky					  sl_qp1) >> 24,
2585321936Shselasky				cl_ntoh32(p_ntci->data_details.ntc_259.
2586321936Shselasky					  sl_qp1) & 0xffffff,
2587321936Shselasky				cl_ntoh32(p_ntci->data_details.ntc_259.qp2),
2588321936Shselasky				inet_ntop(AF_INET6, p_ntci->data_details.
2589321936Shselasky					  ntc_259.gid1.raw, gid_str,
2590321936Shselasky					  sizeof gid_str),
2591321936Shselasky				inet_ntop(AF_INET6, p_ntci->data_details.
2592321936Shselasky					  ntc_259.gid2.raw, gid_str2,
2593321936Shselasky					  sizeof gid_str2),
2594321936Shselasky				cl_ntoh16(p_ntci->data_details.ntc_259.sw_lid),
2595321936Shselasky				p_ntci->data_details.ntc_259.port_no);
2596321936Shselasky			break;
2597321936Shselasky		}
2598321936Shselasky
2599321936Shselasky		sprintf(log_buf,
2600321936Shselasky			"Generic Notice dump:\n"
2601321936Shselasky			"\t\t\t\ttype.....................%u\n"
2602321936Shselasky			"\t\t\t\tprod_type................%u (%s)\n"
2603321936Shselasky			"\t\t\t\ttrap_num.................%u\n%s",
2604321936Shselasky			ib_notice_get_type(p_ntci),
2605321936Shselasky			cl_ntoh32(ib_notice_get_prod_type(p_ntci)),
2606321936Shselasky			ib_get_producer_type_str(ib_notice_get_prod_type
2607321936Shselasky						 (p_ntci)),
2608321936Shselasky			cl_ntoh16(p_ntci->g_or_v.generic.trap_num), buff);
2609321936Shselasky	}
2610321936Shselasky}
2611321936Shselasky
2612321936Shselaskystatic void osm_dump_notice_to_buf(IN const ib_mad_notice_attr_t * p_ntci,
2613321936Shselasky				   OUT char * buf)
2614321936Shselasky{
2615321936Shselasky	if (!buf || !p_ntci)
2616321936Shselasky		return;
2617321936Shselasky	else {
2618321936Shselasky		sprintf(buf,
2619321936Shselasky			"Vendor Notice dump:\n"
2620321936Shselasky			"\t\t\t\ttype.....................%u\n"
2621321936Shselasky			"\t\t\t\tvendor...................%u\n"
2622321936Shselasky			"\t\t\t\tdevice_id................%u\n",
2623321936Shselasky			cl_ntoh16(ib_notice_get_type(p_ntci)),
2624321936Shselasky			cl_ntoh32(ib_notice_get_vend_id(p_ntci)),
2625321936Shselasky			cl_ntoh16(p_ntci->g_or_v.vend.dev_id));
2626321936Shselasky	}
2627321936Shselasky}
2628321936Shselasky
2629321936Shselaskyvoid osm_dump_notice(IN osm_log_t * p_log,
2630321936Shselasky		     IN const ib_mad_notice_attr_t * p_ntci,
2631321936Shselasky		     IN osm_log_level_t log_level)
2632321936Shselasky{
2633321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2634321936Shselasky		char buf[BUF_SIZE];
2635321936Shselasky
2636321936Shselasky		if (ib_notice_is_generic(p_ntci))
2637321936Shselasky			osm_dump_notice_to_buf_generic(p_ntci, buf);
2638321936Shselasky		else
2639321936Shselasky			osm_dump_notice_to_buf(p_ntci, buf);
2640321936Shselasky
2641321936Shselasky		osm_log(p_log, log_level, "%s", buf);
2642321936Shselasky	}
2643321936Shselasky}
2644321936Shselasky
2645321936Shselaskyvoid osm_dump_notice_v2(IN osm_log_t * p_log,
2646321936Shselasky			IN const ib_mad_notice_attr_t * p_ntci,
2647321936Shselasky			IN const int file_id, IN osm_log_level_t log_level)
2648321936Shselasky{
2649321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2650321936Shselasky		char buf[BUF_SIZE];
2651321936Shselasky
2652321936Shselasky		if (ib_notice_is_generic(p_ntci))
2653321936Shselasky			osm_dump_notice_to_buf_generic(p_ntci, buf);
2654321936Shselasky		else
2655321936Shselasky			osm_dump_notice_to_buf(p_ntci, buf);
2656321936Shselasky
2657321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
2658321936Shselasky	}
2659321936Shselasky}
2660321936Shselasky
2661321936Shselaskystatic void osm_dump_dr_smp_to_buf(IN const ib_smp_t * p_smp, OUT char * buf,
2662321936Shselasky				   IN size_t buf_size)
2663321936Shselasky{
2664321936Shselasky	if (!buf || !p_smp)
2665321936Shselasky		return;
2666321936Shselasky	else {
2667321936Shselasky		unsigned n;
2668321936Shselasky
2669321936Shselasky		n = sprintf(buf,
2670321936Shselasky			    "SMP dump:\n"
2671321936Shselasky			    "\t\t\t\tbase_ver................0x%X\n"
2672321936Shselasky			    "\t\t\t\tmgmt_class..............0x%X\n"
2673321936Shselasky			    "\t\t\t\tclass_ver...............0x%X\n"
2674321936Shselasky			    "\t\t\t\tmethod..................0x%X (%s)\n",
2675321936Shselasky			    p_smp->base_ver, p_smp->mgmt_class,
2676321936Shselasky			    p_smp->class_ver, p_smp->method,
2677321936Shselasky			    ib_get_sm_method_str(p_smp->method));
2678321936Shselasky
2679321936Shselasky		if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
2680321936Shselasky			n += snprintf(buf + n, buf_size - n,
2681321936Shselasky				      "\t\t\t\tD bit...................0x%X\n"
2682321936Shselasky				      "\t\t\t\tstatus..................0x%X\n",
2683321936Shselasky				      ib_smp_is_d(p_smp),
2684321936Shselasky				      cl_ntoh16(ib_smp_get_status(p_smp)));
2685321936Shselasky		} else {
2686321936Shselasky			n += snprintf(buf + n, buf_size - n,
2687321936Shselasky				      "\t\t\t\tstatus..................0x%X\n",
2688321936Shselasky				      cl_ntoh16(p_smp->status));
2689321936Shselasky		}
2690321936Shselasky
2691321936Shselasky		n += snprintf(buf + n, buf_size - n,
2692321936Shselasky			      "\t\t\t\thop_ptr.................0x%X\n"
2693321936Shselasky			      "\t\t\t\thop_count...............0x%X\n"
2694321936Shselasky			      "\t\t\t\ttrans_id................0x%" PRIx64 "\n"
2695321936Shselasky			      "\t\t\t\tattr_id.................0x%X (%s)\n"
2696321936Shselasky			      "\t\t\t\tresv....................0x%X\n"
2697321936Shselasky			      "\t\t\t\tattr_mod................0x%X\n"
2698321936Shselasky			      "\t\t\t\tm_key...................0x%016" PRIx64
2699321936Shselasky			      "\n", p_smp->hop_ptr, p_smp->hop_count,
2700321936Shselasky			      cl_ntoh64(p_smp->trans_id),
2701321936Shselasky			      cl_ntoh16(p_smp->attr_id),
2702321936Shselasky			      ib_get_sm_attr_str(p_smp->attr_id),
2703321936Shselasky			      cl_ntoh16(p_smp->resv),
2704321936Shselasky			      cl_ntoh32(p_smp->attr_mod),
2705321936Shselasky			      cl_ntoh64(p_smp->m_key));
2706321936Shselasky
2707321936Shselasky		if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
2708321936Shselasky			uint32_t i;
2709321936Shselasky			n += snprintf(buf + n, buf_size - n,
2710321936Shselasky				      "\t\t\t\tdr_slid.................%u\n"
2711321936Shselasky				      "\t\t\t\tdr_dlid.................%u\n",
2712321936Shselasky				      cl_ntoh16(p_smp->dr_slid),
2713321936Shselasky				      cl_ntoh16(p_smp->dr_dlid));
2714321936Shselasky
2715321936Shselasky			n += snprintf(buf + n, buf_size - n,
2716321936Shselasky				      "\n\t\t\t\tInitial path: ");
2717321936Shselasky			n += sprint_uint8_arr(buf + n, buf_size - n,
2718321936Shselasky					      p_smp->initial_path,
2719321936Shselasky					      p_smp->hop_count + 1);
2720321936Shselasky
2721321936Shselasky			n += snprintf(buf + n, buf_size - n,
2722321936Shselasky				      "\n\t\t\t\tReturn path:  ");
2723321936Shselasky			n += sprint_uint8_arr(buf + n, buf_size - n,
2724321936Shselasky					      p_smp->return_path,
2725321936Shselasky					      p_smp->hop_count + 1);
2726321936Shselasky
2727321936Shselasky			n += snprintf(buf + n, buf_size - n,
2728321936Shselasky				      "\n\t\t\t\tReserved:     ");
2729321936Shselasky			for (i = 0; i < 7; i++) {
2730321936Shselasky				n += snprintf(buf + n, buf_size - n,
2731321936Shselasky					      "[%0X]", p_smp->resv1[i]);
2732321936Shselasky			}
2733321936Shselasky			n += snprintf(buf + n, buf_size - n, "\n");
2734321936Shselasky
2735321936Shselasky			for (i = 0; i < 64; i += 16) {
2736321936Shselasky				n += snprintf(buf + n, buf_size - n,
2737321936Shselasky					      "\n\t\t\t\t%02X %02X %02X %02X "
2738321936Shselasky					      "%02X %02X %02X %02X"
2739321936Shselasky					      "   %02X %02X %02X %02X %02X %02X %02X %02X\n",
2740321936Shselasky					      p_smp->data[i],
2741321936Shselasky					      p_smp->data[i + 1],
2742321936Shselasky					      p_smp->data[i + 2],
2743321936Shselasky					      p_smp->data[i + 3],
2744321936Shselasky					      p_smp->data[i + 4],
2745321936Shselasky					      p_smp->data[i + 5],
2746321936Shselasky					      p_smp->data[i + 6],
2747321936Shselasky					      p_smp->data[i + 7],
2748321936Shselasky					      p_smp->data[i + 8],
2749321936Shselasky					      p_smp->data[i + 9],
2750321936Shselasky					      p_smp->data[i + 10],
2751321936Shselasky					      p_smp->data[i + 11],
2752321936Shselasky					      p_smp->data[i + 12],
2753321936Shselasky					      p_smp->data[i + 13],
2754321936Shselasky					      p_smp->data[i + 14],
2755321936Shselasky					      p_smp->data[i + 15]);
2756321936Shselasky			}
2757321936Shselasky		} else {
2758321936Shselasky			/* not a Direct Route so provide source and destination lids */
2759321936Shselasky			n += snprintf(buf + n, buf_size - n,
2760321936Shselasky				      "\t\t\t\tMAD IS LID ROUTED\n");
2761321936Shselasky		}
2762321936Shselasky	}
2763321936Shselasky}
2764321936Shselasky
2765321936Shselaskyvoid osm_dump_dr_smp(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
2766321936Shselasky		     IN osm_log_level_t log_level)
2767321936Shselasky{
2768321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2769321936Shselasky		char buf[BUF_SIZE];
2770321936Shselasky
2771321936Shselasky		osm_dump_dr_smp_to_buf(p_smp, buf, BUF_SIZE);
2772321936Shselasky
2773321936Shselasky		osm_log(p_log, log_level, "%s", buf);
2774321936Shselasky	}
2775321936Shselasky}
2776321936Shselasky
2777321936Shselaskyvoid osm_dump_dr_smp_v2(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
2778321936Shselasky			IN const int file_id, IN osm_log_level_t log_level)
2779321936Shselasky{
2780321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2781321936Shselasky		char buf[BUF_SIZE];
2782321936Shselasky
2783321936Shselasky		osm_dump_dr_smp_to_buf(p_smp, buf, BUF_SIZE);
2784321936Shselasky
2785321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
2786321936Shselasky	}
2787321936Shselasky}
2788321936Shselasky
2789321936Shselaskystatic void osm_dump_sa_mad_to_buf(IN const ib_sa_mad_t * p_mad, OUT char * buf)
2790321936Shselasky{
2791321936Shselasky	if (!buf || !p_mad)
2792321936Shselasky		return;
2793321936Shselasky	else {
2794321936Shselasky		/* make sure the mad is valid */
2795321936Shselasky		if (p_mad == NULL) {
2796321936Shselasky			sprintf(buf, "NULL MAD POINTER\n");
2797321936Shselasky			return;
2798321936Shselasky		}
2799321936Shselasky
2800321936Shselasky		sprintf(buf,
2801321936Shselasky			"SA MAD dump:\n"
2802321936Shselasky			"\t\t\t\tbase_ver................0x%X\n"
2803321936Shselasky			"\t\t\t\tmgmt_class..............0x%X\n"
2804321936Shselasky			"\t\t\t\tclass_ver...............0x%X\n"
2805321936Shselasky			"\t\t\t\tmethod..................0x%X (%s)\n"
2806321936Shselasky			"\t\t\t\tstatus..................0x%X\n"
2807321936Shselasky			"\t\t\t\tresv....................0x%X\n"
2808321936Shselasky			"\t\t\t\ttrans_id................0x%" PRIx64 "\n"
2809321936Shselasky			"\t\t\t\tattr_id.................0x%X (%s)\n"
2810321936Shselasky			"\t\t\t\tresv1...................0x%X\n"
2811321936Shselasky			"\t\t\t\tattr_mod................0x%X\n"
2812321936Shselasky			"\t\t\t\trmpp_version............0x%X\n"
2813321936Shselasky			"\t\t\t\trmpp_type...............0x%X\n"
2814321936Shselasky			"\t\t\t\trmpp_flags..............0x%X\n"
2815321936Shselasky			"\t\t\t\trmpp_status.............0x%X\n"
2816321936Shselasky			"\t\t\t\tseg_num.................0x%X\n"
2817321936Shselasky			"\t\t\t\tpayload_len/new_win.....0x%X\n"
2818321936Shselasky			"\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
2819321936Shselasky			"\t\t\t\tattr_offset.............0x%X\n"
2820321936Shselasky			"\t\t\t\tresv2...................0x%X\n"
2821321936Shselasky			"\t\t\t\tcomp_mask...............0x%016" PRIx64 "\n",
2822321936Shselasky			p_mad->base_ver, p_mad->mgmt_class, p_mad->class_ver,
2823321936Shselasky			p_mad->method, ib_get_sa_method_str(p_mad->method),
2824321936Shselasky			cl_ntoh16(p_mad->status), cl_ntoh16(p_mad->resv),
2825321936Shselasky			cl_ntoh64(p_mad->trans_id), cl_ntoh16(p_mad->attr_id),
2826321936Shselasky			ib_get_sa_attr_str(p_mad->attr_id),
2827321936Shselasky			cl_ntoh16(p_mad->resv1), cl_ntoh32(p_mad->attr_mod),
2828321936Shselasky			p_mad->rmpp_version, p_mad->rmpp_type,
2829321936Shselasky			p_mad->rmpp_flags, p_mad->rmpp_status,
2830321936Shselasky			cl_ntoh32(p_mad->seg_num),
2831321936Shselasky			cl_ntoh32(p_mad->paylen_newwin),
2832321936Shselasky			cl_ntoh64(p_mad->sm_key), cl_ntoh16(p_mad->attr_offset),
2833321936Shselasky			cl_ntoh16(p_mad->resv3), cl_ntoh64(p_mad->comp_mask));
2834321936Shselasky
2835321936Shselasky		strcat(buf, "\n");
2836321936Shselasky	}
2837321936Shselasky}
2838321936Shselasky
2839321936Shselaskyvoid osm_dump_sa_mad(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_mad,
2840321936Shselasky		     IN osm_log_level_t log_level)
2841321936Shselasky{
2842321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2843321936Shselasky		char buf[BUF_SIZE];
2844321936Shselasky
2845321936Shselasky		osm_dump_sa_mad_to_buf(p_mad, buf);
2846321936Shselasky
2847321936Shselasky		osm_log(p_log, log_level, "%s\n", buf);
2848321936Shselasky	}
2849321936Shselasky}
2850321936Shselasky
2851321936Shselaskyvoid osm_dump_sa_mad_v2(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_mad,
2852321936Shselasky			IN const int file_id, IN osm_log_level_t log_level)
2853321936Shselasky{
2854321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2855321936Shselasky		char buf[BUF_SIZE];
2856321936Shselasky
2857321936Shselasky		osm_dump_sa_mad_to_buf(p_mad, buf);
2858321936Shselasky
2859321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s", buf);
2860321936Shselasky	}
2861321936Shselasky}
2862321936Shselasky
2863321936Shselaskystatic void osm_dump_dr_path_to_buf(IN const osm_dr_path_t * p_path,
2864321936Shselasky				    OUT char * buf, IN size_t buf_size)
2865321936Shselasky{
2866321936Shselasky	if (!buf || !p_path)
2867321936Shselasky		return;
2868321936Shselasky	else {
2869321936Shselasky		unsigned n = 0;
2870321936Shselasky
2871321936Shselasky		n = sprintf(buf, "Directed Path Dump of %u hop path: "
2872321936Shselasky			    "Path = ", p_path->hop_count);
2873321936Shselasky
2874321936Shselasky		sprint_uint8_arr(buf + n, buf_size - n, p_path->path,
2875321936Shselasky				 p_path->hop_count + 1);
2876321936Shselasky	}
2877321936Shselasky}
2878321936Shselasky
2879321936Shselaskyvoid osm_dump_dr_path(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path,
2880321936Shselasky		      IN osm_log_level_t log_level)
2881321936Shselasky{
2882321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2883321936Shselasky		char buf[BUF_SIZE];
2884321936Shselasky
2885321936Shselasky		osm_dump_dr_path_to_buf(p_path, buf, BUF_SIZE);
2886321936Shselasky
2887321936Shselasky		osm_log(p_log, log_level, "%s\n", buf);
2888321936Shselasky	}
2889321936Shselasky}
2890321936Shselasky
2891321936Shselaskyvoid osm_dump_dr_path_v2(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path,
2892321936Shselasky			 IN const int file_id, IN osm_log_level_t log_level)
2893321936Shselasky{
2894321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2895321936Shselasky		char buf[BUF_SIZE];
2896321936Shselasky
2897321936Shselasky		osm_dump_dr_path_to_buf(p_path, buf, BUF_SIZE);
2898321936Shselasky
2899321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s\n", buf);
2900321936Shselasky	}
2901321936Shselasky}
2902321936Shselasky
2903321936Shselaskystatic void osm_dump_smp_dr_path_to_buf(IN const ib_smp_t * p_smp,
2904321936Shselasky					OUT char * buf, IN size_t buf_size)
2905321936Shselasky{
2906321936Shselasky	if (!buf || !p_smp)
2907321936Shselasky		return;
2908321936Shselasky	else {
2909321936Shselasky		unsigned n;
2910321936Shselasky
2911321936Shselasky		n = sprintf(buf, "Received SMP on a %u hop path: "
2912321936Shselasky			    "Initial path = ", p_smp->hop_count);
2913321936Shselasky		n += sprint_uint8_arr(buf + n, buf_size - n,
2914321936Shselasky				      p_smp->initial_path,
2915321936Shselasky				      p_smp->hop_count + 1);
2916321936Shselasky
2917321936Shselasky		n += snprintf(buf + n, buf_size - n, ", Return path  = ");
2918321936Shselasky		n += sprint_uint8_arr(buf + n, buf_size - n,
2919321936Shselasky				      p_smp->return_path, p_smp->hop_count + 1);
2920321936Shselasky	}
2921321936Shselasky}
2922321936Shselasky
2923321936Shselaskyvoid osm_dump_smp_dr_path(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
2924321936Shselasky			  IN osm_log_level_t log_level)
2925321936Shselasky{
2926321936Shselasky	if (osm_log_is_active(p_log, log_level)) {
2927321936Shselasky		char buf[BUF_SIZE];
2928321936Shselasky
2929321936Shselasky		osm_dump_smp_dr_path_to_buf(p_smp, buf, BUF_SIZE);
2930321936Shselasky
2931321936Shselasky		osm_log(p_log, log_level, "%s\n", buf);
2932321936Shselasky	}
2933321936Shselasky}
2934321936Shselasky
2935321936Shselaskyvoid osm_dump_smp_dr_path_v2(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
2936321936Shselasky			     IN const int file_id, IN osm_log_level_t log_level)
2937321936Shselasky{
2938321936Shselasky	if (osm_log_is_active_v2(p_log, log_level, file_id)) {
2939321936Shselasky		char buf[BUF_SIZE];
2940321936Shselasky
2941321936Shselasky		osm_dump_smp_dr_path_to_buf(p_smp, buf, BUF_SIZE);
2942321936Shselasky
2943321936Shselasky		osm_log_v2(p_log, log_level, file_id, "%s\n", buf);
2944321936Shselasky	}
2945321936Shselasky}
2946321936Shselasky
2947321936Shselaskyvoid osm_dump_dr_path_as_buf(IN size_t max_len,
2948321936Shselasky			     IN const osm_dr_path_t * p_path,
2949321936Shselasky			     OUT char* buf)
2950321936Shselasky{
2951321936Shselasky	sprint_uint8_arr(buf, max_len, p_path->path, p_path->hop_count + 1);
2952321936Shselasky}
2953321936Shselasky
2954321936Shselaskystatic const char *sm_signal_str[] = {
2955321936Shselasky	"OSM_SIGNAL_NONE",	/* 0 */
2956321936Shselasky	"OSM_SIGNAL_SWEEP",	/* 1 */
2957321936Shselasky	"OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST",	/* 2 */
2958321936Shselasky	"OSM_SIGNAL_PERFMGR_SWEEP",	/* 3 */
2959321936Shselasky	"OSM_SIGNAL_GUID_PROCESS_REQUEST",	/* 4 */
2960321936Shselasky	"UNKNOWN SIGNAL!!"	/* 5 */
2961321936Shselasky};
2962321936Shselasky
2963321936Shselaskyconst char *osm_get_sm_signal_str(IN osm_signal_t signal)
2964321936Shselasky{
2965321936Shselasky	if (signal > OSM_SIGNAL_MAX)
2966321936Shselasky		signal = OSM_SIGNAL_MAX;
2967321936Shselasky	return sm_signal_str[signal];
2968321936Shselasky}
2969321936Shselasky
2970321936Shselaskystatic const char *disp_msg_str[] = {
2971321936Shselasky	"OSM_MSG_NONE",
2972321936Shselasky	"OSM_MSG_MAD_NODE_INFO",
2973321936Shselasky	"OSM_MSG_MAD_PORT_INFO",
2974321936Shselasky	"OSM_MSG_MAD_SWITCH_INFO",
2975321936Shselasky	"OSM_MSG_MAD_GUID_INFO",
2976321936Shselasky	"OSM_MSG_MAD_NODE_DESC",
2977321936Shselasky	"OSM_MSG_MAD_NODE_RECORD",
2978321936Shselasky	"OSM_MSG_MAD_PORTINFO_RECORD",
2979321936Shselasky	"OSM_MSG_MAD_SERVICE_RECORD",
2980321936Shselasky	"OSM_MSG_MAD_PATH_RECORD",
2981321936Shselasky	"OSM_MSG_MAD_MCMEMBER_RECORD",
2982321936Shselasky	"OSM_MSG_MAD_LINK_RECORD",
2983321936Shselasky	"OSM_MSG_MAD_SMINFO_RECORD",
2984321936Shselasky	"OSM_MSG_MAD_CLASS_PORT_INFO",
2985321936Shselasky	"OSM_MSG_MAD_INFORM_INFO",
2986321936Shselasky	"OSM_MSG_MAD_LFT_RECORD",
2987321936Shselasky	"OSM_MSG_MAD_LFT",
2988321936Shselasky	"OSM_MSG_MAD_SM_INFO",
2989321936Shselasky	"OSM_MSG_MAD_NOTICE",
2990321936Shselasky	"OSM_MSG_LIGHT_SWEEP_FAIL",
2991321936Shselasky	"OSM_MSG_MAD_MFT",
2992321936Shselasky	"OSM_MSG_MAD_PKEY_TBL_RECORD",
2993321936Shselasky	"OSM_MSG_MAD_VL_ARB_RECORD",
2994321936Shselasky	"OSM_MSG_MAD_SLVL_TBL_RECORD",
2995321936Shselasky	"OSM_MSG_MAD_PKEY",
2996321936Shselasky	"OSM_MSG_MAD_VL_ARB",
2997321936Shselasky	"OSM_MSG_MAD_SLVL",
2998321936Shselasky	"OSM_MSG_MAD_GUIDINFO_RECORD",
2999321936Shselasky	"OSM_MSG_MAD_INFORM_INFO_RECORD",
3000321936Shselasky	"OSM_MSG_MAD_SWITCH_INFO_RECORD",
3001321936Shselasky	"OSM_MSG_MAD_MFT_RECORD",
3002321936Shselasky#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
3003321936Shselasky	"OSM_MSG_MAD_MULTIPATH_RECORD",
3004321936Shselasky#endif
3005321936Shselasky	"OSM_MSG_MAD_PORT_COUNTERS",
3006321936Shselasky	"OSM_MSG_MAD_MLNX_EXT_PORT_INFO",
3007321936Shselasky	"UNKNOWN!!"
3008321936Shselasky};
3009321936Shselasky
3010321936Shselaskyconst char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg)
3011321936Shselasky{
3012321936Shselasky	if (msg >= OSM_MSG_MAX)
3013321936Shselasky		msg = OSM_MSG_MAX-1;
3014321936Shselasky	return disp_msg_str[msg];
3015321936Shselasky}
3016321936Shselasky
3017321936Shselaskystatic const char *port_state_str_fixed_width[] = {
3018321936Shselasky	"NOC",
3019321936Shselasky	"DWN",
3020321936Shselasky	"INI",
3021321936Shselasky	"ARM",
3022321936Shselasky	"ACT",
3023321936Shselasky	"???"
3024321936Shselasky};
3025321936Shselasky
3026321936Shselaskyconst char *osm_get_port_state_str_fixed_width(IN uint8_t port_state)
3027321936Shselasky{
3028321936Shselasky	if (port_state > IB_LINK_ACTIVE)
3029321936Shselasky		port_state = IB_LINK_ACTIVE + 1;
3030321936Shselasky	return port_state_str_fixed_width[port_state];
3031321936Shselasky}
3032321936Shselasky
3033321936Shselaskystatic const char *node_type_str_fixed_width[] = {
3034321936Shselasky	"??",
3035321936Shselasky	"CA",
3036321936Shselasky	"SW",
3037321936Shselasky	"RT",
3038321936Shselasky};
3039321936Shselasky
3040321936Shselaskyconst char *osm_get_node_type_str_fixed_width(IN uint8_t node_type)
3041321936Shselasky{
3042321936Shselasky	if (node_type > IB_NODE_TYPE_ROUTER)
3043321936Shselasky		node_type = 0;
3044321936Shselasky	return node_type_str_fixed_width[node_type];
3045321936Shselasky}
3046321936Shselasky
3047321936Shselaskyconst char *osm_get_manufacturer_str(IN uint64_t guid_ho)
3048321936Shselasky{
3049321936Shselasky	/* note that the max vendor string length is 11 */
3050321936Shselasky	static const char *intel_str = "Intel";
3051321936Shselasky	static const char *mellanox_str = "Mellanox";
3052321936Shselasky	static const char *redswitch_str = "Redswitch";
3053321936Shselasky	static const char *silverstorm_str = "SilverStorm";
3054321936Shselasky	static const char *topspin_str = "Topspin";
3055321936Shselasky	static const char *fujitsu_str = "Fujitsu";
3056321936Shselasky	static const char *voltaire_str = "Voltaire";
3057321936Shselasky	static const char *yotta_str = "YottaYotta";
3058321936Shselasky	static const char *pathscale_str = "PathScale";
3059321936Shselasky	static const char *ibm_str = "IBM";
3060321936Shselasky	static const char *divergenet_str = "DivergeNet";
3061321936Shselasky	static const char *flextronics_str = "Flextronics";
3062321936Shselasky	static const char *agilent_str = "Agilent";
3063321936Shselasky	static const char *obsidian_str = "Obsidian";
3064321936Shselasky	static const char *baymicro_str = "BayMicro";
3065321936Shselasky	static const char *lsilogic_str = "LSILogic";
3066321936Shselasky	static const char *ddn_str = "DataDirect";
3067321936Shselasky	static const char *panta_str = "Panta";
3068321936Shselasky	static const char *hp_str = "HP";
3069321936Shselasky	static const char *rioworks_str = "Rioworks";
3070321936Shselasky	static const char *sun_str = "Sun";
3071321936Shselasky	static const char *leafntwks_str = "3LeafNtwks";
3072321936Shselasky	static const char *xsigo_str = "Xsigo";
3073321936Shselasky	static const char *dell_str = "Dell";
3074321936Shselasky	static const char *supermicro_str = "SuperMicro";
3075321936Shselasky	static const char *openib_str = "OpenIB";
3076321936Shselasky	static const char *unknown_str = "Unknown";
3077321936Shselasky	static const char *bull_str = "Bull";
3078321936Shselasky
3079321936Shselasky	switch ((uint32_t) (guid_ho >> (5 * 8))) {
3080321936Shselasky	case OSM_VENDOR_ID_INTEL:
3081321936Shselasky		return intel_str;
3082321936Shselasky	case OSM_VENDOR_ID_MELLANOX:
3083321936Shselasky	case OSM_VENDOR_ID_MELLANOX2:
3084321936Shselasky	case OSM_VENDOR_ID_MELLANOX3:
3085321936Shselasky	case OSM_VENDOR_ID_MELLANOX4:
3086321936Shselasky	case OSM_VENDOR_ID_MELLANOX5:
3087321936Shselasky		return mellanox_str;
3088321936Shselasky	case OSM_VENDOR_ID_REDSWITCH:
3089321936Shselasky		return redswitch_str;
3090321936Shselasky	case OSM_VENDOR_ID_SILVERSTORM:
3091321936Shselasky		return silverstorm_str;
3092321936Shselasky	case OSM_VENDOR_ID_TOPSPIN:
3093321936Shselasky		return topspin_str;
3094321936Shselasky	case OSM_VENDOR_ID_FUJITSU:
3095321936Shselasky	case OSM_VENDOR_ID_FUJITSU2:
3096321936Shselasky		return fujitsu_str;
3097321936Shselasky	case OSM_VENDOR_ID_VOLTAIRE:
3098321936Shselasky		return voltaire_str;
3099321936Shselasky	case OSM_VENDOR_ID_YOTTAYOTTA:
3100321936Shselasky		return yotta_str;
3101321936Shselasky	case OSM_VENDOR_ID_PATHSCALE:
3102321936Shselasky		return pathscale_str;
3103321936Shselasky	case OSM_VENDOR_ID_IBM:
3104321936Shselasky	case OSM_VENDOR_ID_IBM2:
3105321936Shselasky		return ibm_str;
3106321936Shselasky	case OSM_VENDOR_ID_DIVERGENET:
3107321936Shselasky		return divergenet_str;
3108321936Shselasky	case OSM_VENDOR_ID_FLEXTRONICS:
3109321936Shselasky		return flextronics_str;
3110321936Shselasky	case OSM_VENDOR_ID_AGILENT:
3111321936Shselasky		return agilent_str;
3112321936Shselasky	case OSM_VENDOR_ID_OBSIDIAN:
3113321936Shselasky		return obsidian_str;
3114321936Shselasky	case OSM_VENDOR_ID_BAYMICRO:
3115321936Shselasky		return baymicro_str;
3116321936Shselasky	case OSM_VENDOR_ID_LSILOGIC:
3117321936Shselasky		return lsilogic_str;
3118321936Shselasky	case OSM_VENDOR_ID_DDN:
3119321936Shselasky		return ddn_str;
3120321936Shselasky	case OSM_VENDOR_ID_PANTA:
3121321936Shselasky		return panta_str;
3122321936Shselasky	case OSM_VENDOR_ID_HP:
3123321936Shselasky	case OSM_VENDOR_ID_HP2:
3124321936Shselasky	case OSM_VENDOR_ID_HP3:
3125321936Shselasky	case OSM_VENDOR_ID_HP4:
3126321936Shselasky		return hp_str;
3127321936Shselasky	case OSM_VENDOR_ID_RIOWORKS:
3128321936Shselasky		return rioworks_str;
3129321936Shselasky	case OSM_VENDOR_ID_SUN:
3130321936Shselasky	case OSM_VENDOR_ID_SUN2:
3131321936Shselasky		return sun_str;
3132321936Shselasky	case OSM_VENDOR_ID_3LEAFNTWKS:
3133321936Shselasky		return leafntwks_str;
3134321936Shselasky	case OSM_VENDOR_ID_XSIGO:
3135321936Shselasky		return xsigo_str;
3136321936Shselasky	case OSM_VENDOR_ID_DELL:
3137321936Shselasky		return dell_str;
3138321936Shselasky	case OSM_VENDOR_ID_SUPERMICRO:
3139321936Shselasky		return supermicro_str;
3140321936Shselasky	case OSM_VENDOR_ID_OPENIB:
3141321936Shselasky		return openib_str;
3142321936Shselasky	case OSM_VENDOR_ID_BULL:
3143321936Shselasky		return bull_str;
3144321936Shselasky	default:
3145321936Shselasky		return unknown_str;
3146321936Shselasky	}
3147321936Shselasky}
3148321936Shselasky
3149321936Shselaskystatic const char *mtu_str_fixed_width[] = {
3150321936Shselasky	"??? ",
3151321936Shselasky	"256 ",
3152321936Shselasky	"512 ",
3153321936Shselasky	"1024",
3154321936Shselasky	"2048",
3155321936Shselasky	"4096"
3156321936Shselasky};
3157321936Shselasky
3158321936Shselaskyconst char *osm_get_mtu_str(IN uint8_t mtu)
3159321936Shselasky{
3160321936Shselasky	if (mtu > IB_MTU_LEN_4096)
3161321936Shselasky		return mtu_str_fixed_width[0];
3162321936Shselasky	else
3163321936Shselasky		return mtu_str_fixed_width[mtu];
3164321936Shselasky}
3165321936Shselasky
3166321936Shselaskystatic const char *lwa_str_fixed_width[] = {
3167321936Shselasky	"???",
3168321936Shselasky	"1x ",
3169321936Shselasky	"4x ",
3170321936Shselasky	"???",
3171321936Shselasky	"8x ",
3172321936Shselasky	"???",
3173321936Shselasky	"???",
3174321936Shselasky	"???",
3175321936Shselasky	"12x",
3176321936Shselasky	"???",
3177321936Shselasky	"???",
3178321936Shselasky	"???",
3179321936Shselasky	"???",
3180321936Shselasky	"???",
3181321936Shselasky	"???",
3182321936Shselasky	"???",
3183321936Shselasky	"2x "
3184321936Shselasky};
3185321936Shselasky
3186321936Shselaskyconst char *osm_get_lwa_str(IN uint8_t lwa)
3187321936Shselasky{
3188321936Shselasky	if (lwa > 16)
3189321936Shselasky		return lwa_str_fixed_width[0];
3190321936Shselasky	else
3191321936Shselasky		return lwa_str_fixed_width[lwa];
3192321936Shselasky}
3193321936Shselasky
3194321936Shselaskystatic const char *lsa_str_fixed_width[] = {
3195321936Shselasky	"Ext ",
3196321936Shselasky	"2.5 ",
3197321936Shselasky	"5   ",
3198321936Shselasky	"????",
3199321936Shselasky	"10  "
3200321936Shselasky};
3201321936Shselasky
3202321936Shselaskystatic const char *lsea_str_fixed_width[] = {
3203321936Shselasky	"Std ",
3204321936Shselasky	"14  ",
3205321936Shselasky	"25  "
3206321936Shselasky};
3207321936Shselasky
3208321936Shselaskyconst char *osm_get_lsa_str(IN uint8_t lsa, IN uint8_t lsea, IN uint8_t state,
3209321936Shselasky			    IN uint8_t fdr10)
3210321936Shselasky{
3211321936Shselasky	if (lsa > IB_LINK_SPEED_ACTIVE_10 || state == IB_LINK_DOWN)
3212321936Shselasky		return lsa_str_fixed_width[3];
3213321936Shselasky	if (lsea == IB_LINK_SPEED_EXT_ACTIVE_NONE) {
3214321936Shselasky		if (fdr10)
3215321936Shselasky			return "FDR10";
3216321936Shselasky		else
3217321936Shselasky			return lsa_str_fixed_width[lsa];
3218321936Shselasky	}
3219321936Shselasky	if (lsea > IB_LINK_SPEED_EXT_ACTIVE_25)
3220321936Shselasky		return lsa_str_fixed_width[3];
3221321936Shselasky	return lsea_str_fixed_width[lsea];
3222321936Shselasky}
3223321936Shselasky
3224321936Shselaskystatic const char *sm_mgr_signal_str[] = {
3225321936Shselasky	"OSM_SM_SIGNAL_NONE",	/* 0 */
3226321936Shselasky	"OSM_SM_SIGNAL_DISCOVERY_COMPLETED",	/* 1 */
3227321936Shselasky	"OSM_SM_SIGNAL_POLLING_TIMEOUT",	/* 2 */
3228321936Shselasky	"OSM_SM_SIGNAL_DISCOVER",	/* 3 */
3229321936Shselasky	"OSM_SM_SIGNAL_DISABLE",	/* 4 */
3230321936Shselasky	"OSM_SM_SIGNAL_HANDOVER",	/* 5 */
3231321936Shselasky	"OSM_SM_SIGNAL_HANDOVER_SENT",	/* 6 */
3232321936Shselasky	"OSM_SM_SIGNAL_ACKNOWLEDGE",	/* 7 */
3233321936Shselasky	"OSM_SM_SIGNAL_STANDBY",	/* 8 */
3234321936Shselasky	"OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED",	/* 9 */
3235321936Shselasky	"OSM_SM_SIGNAL_WAIT_FOR_HANDOVER",	/* 10 */
3236321936Shselasky	"UNKNOWN STATE!!"	/* 11 */
3237321936Shselasky};
3238321936Shselasky
3239321936Shselaskyconst char *osm_get_sm_mgr_signal_str(IN osm_sm_signal_t signal)
3240321936Shselasky{
3241321936Shselasky	if (signal > OSM_SM_SIGNAL_MAX)
3242321936Shselasky		signal = OSM_SM_SIGNAL_MAX;
3243321936Shselasky	return sm_mgr_signal_str[signal];
3244321936Shselasky}
3245321936Shselasky
3246321936Shselaskystatic const char *sm_mgr_state_str[] = {
3247321936Shselasky	"NOTACTIVE",		/* 0 */
3248321936Shselasky	"DISCOVERING",		/* 1 */
3249321936Shselasky	"STANDBY",		/* 2 */
3250321936Shselasky	"MASTER",		/* 3 */
3251321936Shselasky	"UNKNOWN STATE!!"	/* 4 */
3252321936Shselasky};
3253321936Shselasky
3254321936Shselaskyconst char *osm_get_sm_mgr_state_str(IN uint16_t state)
3255321936Shselasky{
3256321936Shselasky	return state < ARR_SIZE(sm_mgr_state_str) ?
3257321936Shselasky	    sm_mgr_state_str[state] :
3258321936Shselasky	    sm_mgr_state_str[ARR_SIZE(sm_mgr_state_str) - 1];
3259321936Shselasky}
3260321936Shselasky
3261321936Shselaskyint ib_mtu_is_valid(IN const int mtu)
3262321936Shselasky{
3263321936Shselasky	if (mtu < IB_MIN_MTU || mtu > IB_MAX_MTU)
3264321936Shselasky		return 0;
3265321936Shselasky	return 1;
3266321936Shselasky}
3267321936Shselasky
3268321936Shselaskyint ib_rate_is_valid(IN const int rate)
3269321936Shselasky{
3270321936Shselasky	if (rate < IB_MIN_RATE || rate > IB_MAX_RATE)
3271321936Shselasky		return 0;
3272321936Shselasky	return 1;
3273321936Shselasky}
3274321936Shselasky
3275321936Shselaskyint ib_path_compare_rates(IN const int rate1, IN const int rate2)
3276321936Shselasky{
3277321936Shselasky	int orate1 = 0, orate2 = 0;
3278321936Shselasky
3279321936Shselasky	CL_ASSERT(rate1 >= IB_MIN_RATE && rate1 <= IB_MAX_RATE);
3280321936Shselasky	CL_ASSERT(rate2 >= IB_MIN_RATE && rate2 <= IB_MAX_RATE);
3281321936Shselasky
3282321936Shselasky	if (rate1 <= IB_MAX_RATE)
3283321936Shselasky		orate1 = ordered_rates[rate1];
3284321936Shselasky	if (rate2 <= IB_MAX_RATE)
3285321936Shselasky		orate2 = ordered_rates[rate2];
3286321936Shselasky	if (orate1 < orate2)
3287321936Shselasky		return -1;
3288321936Shselasky	if (orate1 == orate2)
3289321936Shselasky		return 0;
3290321936Shselasky	return 1;
3291321936Shselasky}
3292321936Shselasky
3293321936Shselaskystatic int find_ordered_rate(IN const int rate)
3294321936Shselasky{
3295321936Shselasky	int i;
3296321936Shselasky
3297321936Shselasky	for (i = IB_MIN_RATE; i <= IB_MAX_RATE; i++) {
3298321936Shselasky		if (ordered_rates[i] == rate)
3299321936Shselasky			return i;
3300321936Shselasky	}
3301321936Shselasky	return 0;
3302321936Shselasky}
3303321936Shselasky
3304321936Shselaskyint ib_path_rate_get_prev(IN const int rate)
3305321936Shselasky{
3306321936Shselasky	int orate;
3307321936Shselasky
3308321936Shselasky	CL_ASSERT(rate >= IB_MIN_RATE && rate <= IB_MAX_RATE);
3309321936Shselasky
3310321936Shselasky	if (rate <= IB_MIN_RATE)
3311321936Shselasky		return 0;
3312321936Shselasky	if (rate > IB_MAX_RATE)
3313321936Shselasky		return 0;
3314321936Shselasky	orate = ordered_rates[rate];
3315321936Shselasky	orate--;
3316321936Shselasky	return find_ordered_rate(orate);
3317321936Shselasky}
3318321936Shselasky
3319321936Shselaskyint ib_path_rate_get_next(IN const int rate)
3320321936Shselasky{
3321321936Shselasky	int orate;
3322321936Shselasky
3323321936Shselasky	CL_ASSERT(rate >= IB_MIN_RATE && rate <= IB_MAX_RATE);
3324321936Shselasky
3325321936Shselasky	if (rate < IB_MIN_RATE)
3326321936Shselasky		return 0;
3327321936Shselasky	if (rate >= IB_MAX_RATE)
3328321936Shselasky		return 0;
3329321936Shselasky	orate = ordered_rates[rate];
3330321936Shselasky	orate++;
3331321936Shselasky	return find_ordered_rate(orate);
3332321936Shselasky}
3333