1193323Sed/*
2193323Sed * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
3193323Sed * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4193323Sed * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5193323Sed *
6193323Sed * This software is available to you under a choice of one of two
7193323Sed * licenses.  You may choose to be licensed under the terms of the GNU
8193323Sed * General Public License (GPL) Version 2, available from the file
9193323Sed * COPYING in the main directory of this source tree, or the
10193323Sed * OpenIB.org BSD license below:
11193323Sed *
12193323Sed *     Redistribution and use in source and binary forms, with or
13193323Sed *     without modification, are permitted provided that the following
14193323Sed *     conditions are met:
15193323Sed *
16193323Sed *      - Redistributions of source code must retain the above
17193323Sed *        copyright notice, this list of conditions and the following
18193323Sed *        disclaimer.
19193323Sed *
20193323Sed *      - Redistributions in binary form must reproduce the above
21193323Sed *        copyright notice, this list of conditions and the following
22193323Sed *        disclaimer in the documentation and/or other materials
23193323Sed *        provided with the distribution.
24193323Sed *
25218893Sdim * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26218893Sdim * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27198090Srdivacky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28193323Sed * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29193323Sed * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30193323Sed * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31193323Sed * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32193323Sed * SOFTWARE.
33205218Srdivacky *
34193323Sed */
35193323Sed
36218893Sdim#ifndef _OSM_HELPER_H_
37193323Sed#define _OSM_HELPER_H_
38193323Sed
39212904Sdim#include <iba/ib_types.h>
40193323Sed#include <complib/cl_dispatcher.h>
41193323Sed#include <opensm/osm_base.h>
42193323Sed#include <opensm/osm_log.h>
43198090Srdivacky#include <opensm/osm_msgdef.h>
44205218Srdivacky#include <opensm/osm_path.h>
45218893Sdim
46193323Sed#ifdef __cplusplus
47193323Sed#  define BEGIN_C_DECLS extern "C" {
48193323Sed#  define END_C_DECLS   }
49218893Sdim#else				/* !__cplusplus */
50218893Sdim#  define BEGIN_C_DECLS
51218893Sdim#  define END_C_DECLS
52218893Sdim#endif				/* __cplusplus */
53218893Sdim
54218893SdimBEGIN_C_DECLS
55218893Sdim/*
56218893Sdim * Abstract:
57218893Sdim * 	Declaration of helpful functions.
58218893Sdim */
59218893Sdim/****f* OpenSM: Helper/ib_get_sa_method_str
60218893Sdim * NAME
61212904Sdim *	ib_get_sa_method_str
62212904Sdim *
63212904Sdim * DESCRIPTION
64218893Sdim *	Returns a string for the specified SA Method value.
65212904Sdim *
66193323Sed * SYNOPSIS
67198090Srdivacky */
68193323Sedconst char *ib_get_sa_method_str(IN uint8_t method);
69193323Sed/*
70193323Sed * PARAMETERS
71218893Sdim *	method
72201360Srdivacky *		[in] Network order METHOD ID value.
73218893Sdim *
74218893Sdim * RETURN VALUES
75218893Sdim *	Pointer to the method string.
76218893Sdim *
77218893Sdim * NOTES
78193323Sed *
79193323Sed * SEE ALSO
80193323Sed *********/
81193323Sed
82218893Sdim/****f* OpenSM: Helper/ib_get_sm_method_str
83218893Sdim* NAME
84218893Sdim*	ib_get_sm_method_str
85218893Sdim*
86218893Sdim* DESCRIPTION
87218893Sdim*	Returns a string for the specified SM Method value.
88193323Sed*
89193323Sed* SYNOPSIS
90193323Sed*/
91218893Sdimconst char *ib_get_sm_method_str(IN uint8_t method);
92218893Sdim/*
93218893Sdim* PARAMETERS
94193323Sed*	method
95193323Sed*		[in] Network order METHOD ID value.
96198090Srdivacky*
97218893Sdim* RETURN VALUES
98198090Srdivacky*	Pointer to the method string.
99198090Srdivacky*
100198090Srdivacky* NOTES
101203954Srdivacky*
102203954Srdivacky* SEE ALSO
103203954Srdivacky*********/
104203954Srdivacky
105193323Sed/****f* OpenSM: Helper/ib_get_sm_attr_str
106193323Sed* NAME
107193323Sed*	ib_get_sm_attr_str
108193323Sed*
109193323Sed* DESCRIPTION
110218893Sdim*	Returns a string for the specified SM attribute value.
111218893Sdim*
112218893Sdim* SYNOPSIS
113205218Srdivacky*/
114198396Srdivackyconst char *ib_get_sm_attr_str(IN ib_net16_t attr);
115193323Sed/*
116193323Sed* PARAMETERS
117193323Sed*	attr
118193323Sed*		[in] Network order attribute ID value.
119193323Sed*
120193323Sed* RETURN VALUES
121212904Sdim*	Pointer to the attribute string.
122218893Sdim*
123193323Sed* NOTES
124193323Sed*
125193323Sed* SEE ALSO
126193323Sed*********/
127193323Sed
128193323Sed/****f* OpenSM: Helper/ib_get_sa_attr_str
129193323Sed* NAME
130193323Sed*	ib_get_sa_attr_str
131193323Sed*
132193323Sed* DESCRIPTION
133193323Sed*	Returns a string for the specified SA attribute value.
134193323Sed*
135193323Sed* SYNOPSIS
136193323Sed*/
137193323Sedconst char *ib_get_sa_attr_str(IN ib_net16_t attr);
138193323Sed/*
139193323Sed* PARAMETERS
140193323Sed*	attr
141218893Sdim*		[in] Network order attribute ID value.
142201360Srdivacky*
143193323Sed* RETURN VALUES
144193323Sed*	Pointer to the attribute string.
145193323Sed*
146193323Sed* NOTES
147218893Sdim*
148218893Sdim* SEE ALSO
149218893Sdim*********/
150218893Sdim
151193323Sed/****f* OpenSM: Helper/ib_get_trap_str
152193323Sed* NAME
153193323Sed*	ib_get_trap_str
154193323Sed*
155193323Sed* DESCRIPTION
156193323Sed*	Returns a name for the specified trap.
157193323Sed*
158193323Sed* SYNOPSIS
159218893Sdim*/
160218893Sdimconst char *ib_get_trap_str(uint16_t trap_num);
161218893Sdim/*
162193323Sed* PARAMETERS
163193323Sed*	trap_num
164193323Sed*		[in] Network order trap number.
165193323Sed*
166193323Sed* RETURN VALUES
167193323Sed*	Name of the trap.
168193323Sed*
169193323Sed*********/
170193323Sed
171193323Sed/****f* OpenSM: Helper/osm_dump_port_info
172193323Sed* NAME
173193323Sed*	osm_dump_port_info
174193323Sed*
175193323Sed* DESCRIPTION
176193323Sed*	Dumps the PortInfo attribute to the log.
177193323Sed*
178193323Sed* SYNOPSIS
179193323Sed*/
180193323Sedvoid osm_dump_port_info(IN osm_log_t * const p_log,
181193323Sed			IN const ib_net64_t node_guid,
182193323Sed			IN const ib_net64_t port_guid,
183193323Sed			IN const uint8_t port_num,
184193323Sed			IN const ib_port_info_t * const p_pi,
185193323Sed			IN const osm_log_level_t log_level);
186193323Sed/*
187193323Sed* PARAMETERS
188193323Sed*	p_log
189193323Sed*		[in] Pointer to the osm_log_t object
190193323Sed*
191193323Sed*	node_guid
192193323Sed*		[in] Node GUID that owns this port.
193193323Sed*
194193323Sed*	port_guid
195193323Sed*		[in] Port GUID for this port.
196193323Sed*
197193323Sed*	port_num
198193323Sed*		[in] Port number for this port.
199193323Sed*
200193323Sed*	p_pi
201193323Sed*		[in] Pointer to the PortInfo attribute
202193323Sed*
203193323Sed*	log_level
204193323Sed*		[in] Log verbosity level with which to dump the data.
205193323Sed*
206193323Sed* RETURN VALUES
207193323Sed*	None.
208193323Sed*
209193323Sed* NOTES
210193323Sed*
211193323Sed* SEE ALSO
212193323Sed*********/
213193323Sed
214193323Sedvoid
215193323Sedosm_dump_path_record(IN osm_log_t * const p_log,
216193323Sed		     IN const ib_path_rec_t * const p_pr,
217193323Sed		     IN const osm_log_level_t log_level);
218193323Sed
219206083Srdivackyvoid
220193323Sedosm_dump_multipath_record(IN osm_log_t * const p_log,
221193323Sed			  IN const ib_multipath_rec_t * const p_mpr,
222193323Sed			  IN const osm_log_level_t log_level);
223193323Sed
224193323Sedvoid
225193323Sedosm_dump_node_record(IN osm_log_t * const p_log,
226193323Sed		     IN const ib_node_record_t * const p_nr,
227193323Sed		     IN const osm_log_level_t log_level);
228193323Sed
229193323Sedvoid
230193323Sedosm_dump_mc_record(IN osm_log_t * const p_log,
231193323Sed		   IN const ib_member_rec_t * const p_mcmr,
232193323Sed		   IN const osm_log_level_t log_level);
233193323Sed
234193323Sedvoid
235193323Sedosm_dump_link_record(IN osm_log_t * const p_log,
236193323Sed		     IN const ib_link_record_t * const p_lr,
237193323Sed		     IN const osm_log_level_t log_level);
238193323Sed
239193323Sedvoid
240193323Sedosm_dump_service_record(IN osm_log_t * const p_log,
241193323Sed			IN const ib_service_record_t * const p_sr,
242193323Sed			IN const osm_log_level_t log_level);
243193323Sed
244193323Sedvoid
245193323Sedosm_dump_portinfo_record(IN osm_log_t * const p_log,
246193323Sed			 IN const ib_portinfo_record_t * const p_pir,
247193323Sed			 IN const osm_log_level_t log_level);
248193323Sed
249193323Sedvoid
250193323Sedosm_dump_guidinfo_record(IN osm_log_t * const p_log,
251193323Sed			 IN const ib_guidinfo_record_t * const p_gir,
252193323Sed			 IN const osm_log_level_t log_level);
253193323Sed
254193323Sedvoid
255193323Sedosm_dump_inform_info(IN osm_log_t * const p_log,
256193323Sed		     IN const ib_inform_info_t * const p_ii,
257193323Sed		     IN const osm_log_level_t log_level);
258193323Sed
259193323Sedvoid
260193323Sedosm_dump_inform_info_record(IN osm_log_t * const p_log,
261193323Sed			    IN const ib_inform_info_record_t * const p_iir,
262193323Sed			    IN const osm_log_level_t log_level);
263193323Sed
264193323Sedvoid
265193323Sedosm_dump_switch_info_record(IN osm_log_t * const p_log,
266193323Sed			    IN const ib_switch_info_record_t * const p_sir,
267193323Sed			    IN const osm_log_level_t log_level);
268193323Sed
269193323Sedvoid
270193323Sedosm_dump_sm_info_record(IN osm_log_t * const p_log,
271193323Sed			IN const ib_sminfo_record_t * const p_smir,
272193323Sed			IN const osm_log_level_t log_level);
273193323Sed
274193323Sedvoid
275193323Sedosm_dump_pkey_block(IN osm_log_t * const p_log,
276193323Sed		    IN uint64_t port_guid,
277193323Sed		    IN uint16_t block_num,
278193323Sed		    IN uint8_t port_num,
279193323Sed		    IN const ib_pkey_table_t * const p_pkey_tbl,
280193323Sed		    IN const osm_log_level_t log_level);
281193323Sed
282193323Sedvoid
283193323Sedosm_dump_slvl_map_table(IN osm_log_t * const p_log,
284193323Sed			IN uint64_t port_guid,
285202375Srdivacky			IN uint8_t in_port_num,
286193323Sed			IN uint8_t out_port_num,
287193323Sed			IN const ib_slvl_table_t * const p_slvl_tbl,
288193323Sed			IN const osm_log_level_t log_level);
289193323Sed
290193323Sedvoid
291193323Sedosm_dump_vl_arb_table(IN osm_log_t * const p_log,
292193323Sed		      IN uint64_t port_guid,
293193323Sed		      IN uint8_t block_num,
294198090Srdivacky		      IN uint8_t port_num,
295193323Sed		      IN const ib_vl_arb_table_t * const p_vla_tbl,
296193323Sed		      IN const osm_log_level_t log_level);
297193323Sed
298193323Sed/****f* OpenSM: Helper/osm_dump_port_info
299202375Srdivacky* NAME
300193323Sed*	osm_dump_port_info
301193323Sed*
302193323Sed* DESCRIPTION
303193323Sed*	Dumps the PortInfo attribute to the log.
304193323Sed*
305193323Sed* SYNOPSIS
306193323Sed*/
307193323Sedvoid osm_dump_node_info(IN osm_log_t * const p_log,
308193323Sed			IN const ib_node_info_t * const p_ni,
309193323Sed			IN const osm_log_level_t log_level);
310193323Sed/*
311193323Sed* PARAMETERS
312193323Sed*	p_log
313193323Sed*		[in] Pointer to the osm_log_t object
314193323Sed*
315193323Sed*	p_ni
316193323Sed*		[in] Pointer to the NodeInfo attribute
317193323Sed*
318193323Sed*	log_level
319193323Sed*		[in] Log verbosity level with which to dump the data.
320193323Sed*
321193323Sed* RETURN VALUES
322193323Sed*	None.
323193323Sed*
324193323Sed* NOTES
325193323Sed*
326193323Sed* SEE ALSO
327193323Sed*********/
328193323Sed
329193323Sed/****f* OpenSM: Helper/osm_dump_sm_info
330193323Sed* NAME
331193323Sed*	osm_dump_sm_info
332193323Sed*
333193323Sed* DESCRIPTION
334193323Sed*	Dumps the SMInfo attribute to the log.
335193323Sed*
336218893Sdim* SYNOPSIS
337218893Sdim*/
338218893Sdimvoid
339218893Sdimosm_dump_sm_info(IN osm_log_t * const p_log,
340218893Sdim		 IN const ib_sm_info_t * const p_smi,
341218893Sdim		 IN const osm_log_level_t log_level);
342218893Sdim/*
343201360Srdivacky* PARAMETERS
344201360Srdivacky*	p_log
345201360Srdivacky*		[in] Pointer to the osm_log_t object
346198090Srdivacky*
347193323Sed*	p_smi
348218893Sdim*		[in] Pointer to the SMInfo attribute
349193323Sed*
350202375Srdivacky*	log_level
351193323Sed*		[in] Log verbosity level with which to dump the data.
352193323Sed*
353203954Srdivacky* RETURN VALUES
354203954Srdivacky*	None.
355203954Srdivacky*
356203954Srdivacky* NOTES
357203954Srdivacky*
358203954Srdivacky* SEE ALSO
359203954Srdivacky*********/
360203954Srdivacky
361203954Srdivacky/****f* OpenSM: Helper/osm_dump_switch_info
362203954Srdivacky* NAME
363203954Srdivacky*	osm_dump_switch_info
364203954Srdivacky*
365203954Srdivacky* DESCRIPTION
366203954Srdivacky*	Dumps the SwitchInfo attribute to the log.
367203954Srdivacky*
368203954Srdivacky* SYNOPSIS
369203954Srdivacky*/
370203954Srdivackyvoid
371203954Srdivackyosm_dump_switch_info(IN osm_log_t * const p_log,
372203954Srdivacky		     IN const ib_switch_info_t * const p_si,
373203954Srdivacky		     IN const osm_log_level_t log_level);
374203954Srdivacky/*
375203954Srdivacky* PARAMETERS
376203954Srdivacky*	p_log
377203954Srdivacky*		[in] Pointer to the osm_log_t object
378203954Srdivacky*
379203954Srdivacky*	p_si
380203954Srdivacky*		[in] Pointer to the SwitchInfo attribute
381203954Srdivacky*
382203954Srdivacky*	log_level
383203954Srdivacky*		[in] Log verbosity level with which to dump the data.
384203954Srdivacky*
385203954Srdivacky* RETURN VALUES
386203954Srdivacky*	None.
387203954Srdivacky*
388203954Srdivacky* NOTES
389203954Srdivacky*
390203954Srdivacky* SEE ALSO
391203954Srdivacky*********/
392203954Srdivacky
393203954Srdivacky/****f* OpenSM: Helper/osm_dump_notice
394203954Srdivacky* NAME
395203954Srdivacky*	osm_dump_notice
396203954Srdivacky*
397203954Srdivacky* DESCRIPTION
398203954Srdivacky*	Dumps the Notice attribute to the log.
399203954Srdivacky*
400203954Srdivacky* SYNOPSIS
401203954Srdivacky*/
402203954Srdivackyvoid
403203954Srdivackyosm_dump_notice(IN osm_log_t * const p_log,
404203954Srdivacky		IN const ib_mad_notice_attr_t * p_ntci,
405203954Srdivacky		IN const osm_log_level_t log_level);
406203954Srdivacky/*
407203954Srdivacky* PARAMETERS
408203954Srdivacky*	p_log
409203954Srdivacky*		[in] Pointer to the osm_log_t object
410203954Srdivacky*
411203954Srdivacky*	p_ntci
412203954Srdivacky*		[in] Pointer to the Notice attribute
413203954Srdivacky*
414203954Srdivacky*	log_level
415203954Srdivacky*		[in] Log verbosity level with which to dump the data.
416193323Sed*
417203954Srdivacky* RETURN VALUES
418193323Sed*	None.
419193323Sed*
420193323Sed* NOTES
421193323Sed*
422193323Sed* SEE ALSO
423193323Sed*********/
424193323Sed
425193323Sed/****f* IBA Base: Types/osm_get_disp_msg_str
426193323Sed* NAME
427193323Sed*	osm_get_disp_msg_str
428193323Sed*
429193323Sed* DESCRIPTION
430193323Sed*	Returns a string for the specified Dispatcher message.
431203954Srdivacky*
432193323Sed* SYNOPSIS
433193323Sed*/
434203954Srdivackyconst char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg);
435193323Sed/*
436193323Sed* PARAMETERS
437193323Sed*	msg
438193323Sed*		[in] Dispatcher message ID value.
439193323Sed*
440193323Sed* RETURN VALUES
441193323Sed*	Pointer to the message discription string.
442193323Sed*
443193323Sed* NOTES
444203954Srdivacky*
445203954Srdivacky* SEE ALSO
446203954Srdivacky*********/
447203954Srdivacky
448203954Srdivackyvoid osm_dump_dr_path(IN osm_log_t * const p_log,
449203954Srdivacky		      IN const osm_dr_path_t * const p_path,
450193323Sed		      IN const osm_log_level_t level);
451193323Sed
452193323Sedvoid osm_dump_smp_dr_path(IN osm_log_t * const p_log,
453203954Srdivacky			  IN const ib_smp_t * const p_smp,
454193323Sed			  IN const osm_log_level_t level);
455193323Sed
456193323Sedvoid osm_dump_dr_smp(IN osm_log_t * const p_log,
457193323Sed		     IN const ib_smp_t * const p_smp,
458194612Sed		     IN const osm_log_level_t level);
459194612Sed
460193323Sedvoid osm_dump_sa_mad(IN osm_log_t * const p_log,
461193323Sed		     IN const ib_sa_mad_t * const p_smp,
462193323Sed		     IN const osm_log_level_t level);
463193323Sed
464193323Sed/****f* IBA Base: Types/osm_get_sm_signal_str
465193323Sed* NAME
466198090Srdivacky*	osm_get_sm_signal_str
467198090Srdivacky*
468193323Sed* DESCRIPTION
469193323Sed*	Returns a string for the specified SM state.
470193323Sed*
471193323Sed* SYNOPSIS
472193323Sed*/
473193323Sedconst char *osm_get_sm_signal_str(IN osm_signal_t signal);
474193323Sed/*
475193323Sed* PARAMETERS
476193323Sed*	state
477193323Sed*		[in] Signal value
478193323Sed*
479193323Sed* RETURN VALUES
480212904Sdim*	Pointer to the signal discription string.
481198090Srdivacky*
482212904Sdim* NOTES
483198090Srdivacky*
484193323Sed* SEE ALSO
485193323Sed*********/
486193323Sed
487193323Sedconst char *osm_get_port_state_str_fixed_width(IN uint8_t port_state);
488193323Sed
489193323Sedconst char *osm_get_node_type_str_fixed_width(IN uint8_t node_type);
490193323Sed
491193323Sedconst char *osm_get_manufacturer_str(IN uint64_t const guid_ho);
492193323Sed
493193323Sedconst char *osm_get_mtu_str(IN uint8_t const mtu);
494193323Sed
495193323Sedconst char *osm_get_lwa_str(IN uint8_t const lwa);
496193323Sed
497193323Sedconst char *osm_get_mtu_str(IN uint8_t const mtu);
498193323Sed
499193323Sedconst char *osm_get_lwa_str(IN uint8_t const lwa);
500193323Sed
501193323Sedconst char *osm_get_lsa_str(IN uint8_t const lsa);
502193323Sed
503193323Sed/****f* IBA Base: Types/osm_get_sm_mgr_signal_str
504193323Sed* NAME
505193323Sed*	osm_get_sm_mgr_signal_str
506193323Sed*
507193323Sed* DESCRIPTION
508193323Sed*	Returns a string for the specified SM manager signal.
509193323Sed*
510193323Sed* SYNOPSIS
511193323Sed*/
512193323Sedconst char *osm_get_sm_mgr_signal_str(IN osm_sm_signal_t signal);
513193323Sed/*
514193323Sed* PARAMETERS
515193323Sed*	signal
516193323Sed*		[in] SM manager signal
517193323Sed*
518193323Sed* RETURN VALUES
519193323Sed*	Pointer to the signal discription string.
520193323Sed*
521193323Sed* NOTES
522193323Sed*
523193323Sed* SEE ALSO
524193323Sed*********/
525193323Sed
526193323Sed/****f* IBA Base: Types/osm_get_sm_mgr_state_str
527218893Sdim* NAME
528193323Sed*	osm_get_sm_mgr_state_str
529193323Sed*
530193323Sed* DESCRIPTION
531193323Sed*	Returns a string for the specified SM manager state.
532193323Sed*
533193323Sed* SYNOPSIS
534193323Sed*/
535193323Sedconst char *osm_get_sm_mgr_state_str(IN uint16_t state);
536193323Sed/*
537193323Sed* PARAMETERS
538193323Sed*	state
539193323Sed*		[in] SM manager state
540193323Sed*
541193323Sed* RETURN VALUES
542193323Sed*	Pointer to the state discription string.
543193323Sed*
544193323Sed* NOTES
545193323Sed*
546193323Sed* SEE ALSO
547193323Sed*********/
548193323Sed
549193323SedEND_C_DECLS
550193323Sed#endif				/* _OSM_HELPER_H_ */
551193323Sed