2 * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 #ifndef _OSM_HELPER_H_
37 #define _OSM_HELPER_H_
39 #include <iba/ib_types.h>
40 #include <complib/cl_dispatcher.h>
41 #include <opensm/osm_base.h>
42 #include <opensm/osm_log.h>
43 #include <opensm/osm_msgdef.h>
44 #include <opensm/osm_path.h>
47 # define BEGIN_C_DECLS extern "C" {
48 # define END_C_DECLS }
49 #else /* !__cplusplus */
50 # define BEGIN_C_DECLS
52 #endif /* __cplusplus */
57 * Declaration of helpful functions.
59 /****f* OpenSM: Helper/ib_get_sa_method_str
61 * ib_get_sa_method_str
64 * Returns a string for the specified SA Method value.
68 const char *ib_get_sa_method_str(IN uint8_t method);
72 * [in] Network order METHOD ID value.
75 * Pointer to the method string.
82 /****f* OpenSM: Helper/ib_get_sm_method_str
84 * ib_get_sm_method_str
87 * Returns a string for the specified SM Method value.
91 const char *ib_get_sm_method_str(IN uint8_t method);
95 * [in] Network order METHOD ID value.
98 * Pointer to the method string.
105 /****f* OpenSM: Helper/ib_get_sm_attr_str
110 * Returns a string for the specified SM attribute value.
114 const char *ib_get_sm_attr_str(IN ib_net16_t attr);
118 * [in] Network order attribute ID value.
121 * Pointer to the attribute string.
128 /****f* OpenSM: Helper/ib_get_sa_attr_str
133 * Returns a string for the specified SA attribute value.
137 const char *ib_get_sa_attr_str(IN ib_net16_t attr);
141 * [in] Network order attribute ID value.
144 * Pointer to the attribute string.
151 /****f* OpenSM: Helper/ib_get_trap_str
156 * Returns a name for the specified trap.
160 const char *ib_get_trap_str(uint16_t trap_num);
164 * [in] Network order trap number.
171 /****f* OpenSM: Helper/osm_dump_port_info
176 * Dumps the PortInfo attribute to the log.
180 void osm_dump_port_info(IN osm_log_t * const p_log,
181 IN const ib_net64_t node_guid,
182 IN const ib_net64_t port_guid,
183 IN const uint8_t port_num,
184 IN const ib_port_info_t * const p_pi,
185 IN const osm_log_level_t log_level);
189 * [in] Pointer to the osm_log_t object
192 * [in] Node GUID that owns this port.
195 * [in] Port GUID for this port.
198 * [in] Port number for this port.
201 * [in] Pointer to the PortInfo attribute
204 * [in] Log verbosity level with which to dump the data.
215 osm_dump_path_record(IN osm_log_t * const p_log,
216 IN const ib_path_rec_t * const p_pr,
217 IN const osm_log_level_t log_level);
220 osm_dump_multipath_record(IN osm_log_t * const p_log,
221 IN const ib_multipath_rec_t * const p_mpr,
222 IN const osm_log_level_t log_level);
225 osm_dump_node_record(IN osm_log_t * const p_log,
226 IN const ib_node_record_t * const p_nr,
227 IN const osm_log_level_t log_level);
230 osm_dump_mc_record(IN osm_log_t * const p_log,
231 IN const ib_member_rec_t * const p_mcmr,
232 IN const osm_log_level_t log_level);
235 osm_dump_link_record(IN osm_log_t * const p_log,
236 IN const ib_link_record_t * const p_lr,
237 IN const osm_log_level_t log_level);
240 osm_dump_service_record(IN osm_log_t * const p_log,
241 IN const ib_service_record_t * const p_sr,
242 IN const osm_log_level_t log_level);
245 osm_dump_portinfo_record(IN osm_log_t * const p_log,
246 IN const ib_portinfo_record_t * const p_pir,
247 IN const osm_log_level_t log_level);
250 osm_dump_guidinfo_record(IN osm_log_t * const p_log,
251 IN const ib_guidinfo_record_t * const p_gir,
252 IN const osm_log_level_t log_level);
255 osm_dump_inform_info(IN osm_log_t * const p_log,
256 IN const ib_inform_info_t * const p_ii,
257 IN const osm_log_level_t log_level);
260 osm_dump_inform_info_record(IN osm_log_t * const p_log,
261 IN const ib_inform_info_record_t * const p_iir,
262 IN const osm_log_level_t log_level);
265 osm_dump_switch_info_record(IN osm_log_t * const p_log,
266 IN const ib_switch_info_record_t * const p_sir,
267 IN const osm_log_level_t log_level);
270 osm_dump_sm_info_record(IN osm_log_t * const p_log,
271 IN const ib_sminfo_record_t * const p_smir,
272 IN const osm_log_level_t log_level);
275 osm_dump_pkey_block(IN osm_log_t * const p_log,
276 IN uint64_t port_guid,
277 IN uint16_t block_num,
279 IN const ib_pkey_table_t * const p_pkey_tbl,
280 IN const osm_log_level_t log_level);
283 osm_dump_slvl_map_table(IN osm_log_t * const p_log,
284 IN uint64_t port_guid,
285 IN uint8_t in_port_num,
286 IN uint8_t out_port_num,
287 IN const ib_slvl_table_t * const p_slvl_tbl,
288 IN const osm_log_level_t log_level);
291 osm_dump_vl_arb_table(IN osm_log_t * const p_log,
292 IN uint64_t port_guid,
293 IN uint8_t block_num,
295 IN const ib_vl_arb_table_t * const p_vla_tbl,
296 IN const osm_log_level_t log_level);
298 /****f* OpenSM: Helper/osm_dump_port_info
303 * Dumps the PortInfo attribute to the log.
307 void osm_dump_node_info(IN osm_log_t * const p_log,
308 IN const ib_node_info_t * const p_ni,
309 IN const osm_log_level_t log_level);
313 * [in] Pointer to the osm_log_t object
316 * [in] Pointer to the NodeInfo attribute
319 * [in] Log verbosity level with which to dump the data.
329 /****f* OpenSM: Helper/osm_dump_sm_info
334 * Dumps the SMInfo attribute to the log.
339 osm_dump_sm_info(IN osm_log_t * const p_log,
340 IN const ib_sm_info_t * const p_smi,
341 IN const osm_log_level_t log_level);
345 * [in] Pointer to the osm_log_t object
348 * [in] Pointer to the SMInfo attribute
351 * [in] Log verbosity level with which to dump the data.
361 /****f* OpenSM: Helper/osm_dump_switch_info
363 * osm_dump_switch_info
366 * Dumps the SwitchInfo attribute to the log.
371 osm_dump_switch_info(IN osm_log_t * const p_log,
372 IN const ib_switch_info_t * const p_si,
373 IN const osm_log_level_t log_level);
377 * [in] Pointer to the osm_log_t object
380 * [in] Pointer to the SwitchInfo attribute
383 * [in] Log verbosity level with which to dump the data.
393 /****f* OpenSM: Helper/osm_dump_notice
398 * Dumps the Notice attribute to the log.
403 osm_dump_notice(IN osm_log_t * const p_log,
404 IN const ib_mad_notice_attr_t * p_ntci,
405 IN const osm_log_level_t log_level);
409 * [in] Pointer to the osm_log_t object
412 * [in] Pointer to the Notice attribute
415 * [in] Log verbosity level with which to dump the data.
425 /****f* IBA Base: Types/osm_get_disp_msg_str
427 * osm_get_disp_msg_str
430 * Returns a string for the specified Dispatcher message.
434 const char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg);
438 * [in] Dispatcher message ID value.
441 * Pointer to the message discription string.
448 void osm_dump_dr_path(IN osm_log_t * const p_log,
449 IN const osm_dr_path_t * const p_path,
450 IN const osm_log_level_t level);
452 void osm_dump_smp_dr_path(IN osm_log_t * const p_log,
453 IN const ib_smp_t * const p_smp,
454 IN const osm_log_level_t level);
456 void osm_dump_dr_smp(IN osm_log_t * const p_log,
457 IN const ib_smp_t * const p_smp,
458 IN const osm_log_level_t level);
460 void osm_dump_sa_mad(IN osm_log_t * const p_log,
461 IN const ib_sa_mad_t * const p_smp,
462 IN const osm_log_level_t level);
464 /****f* IBA Base: Types/osm_get_sm_signal_str
466 * osm_get_sm_signal_str
469 * Returns a string for the specified SM state.
473 const char *osm_get_sm_signal_str(IN osm_signal_t signal);
480 * Pointer to the signal discription string.
487 const char *osm_get_port_state_str_fixed_width(IN uint8_t port_state);
489 const char *osm_get_node_type_str_fixed_width(IN uint8_t node_type);
491 const char *osm_get_manufacturer_str(IN uint64_t const guid_ho);
493 const char *osm_get_mtu_str(IN uint8_t const mtu);
495 const char *osm_get_lwa_str(IN uint8_t const lwa);
497 const char *osm_get_mtu_str(IN uint8_t const mtu);
499 const char *osm_get_lwa_str(IN uint8_t const lwa);
501 const char *osm_get_lsa_str(IN uint8_t const lsa);
503 /****f* IBA Base: Types/osm_get_sm_mgr_signal_str
505 * osm_get_sm_mgr_signal_str
508 * Returns a string for the specified SM manager signal.
512 const char *osm_get_sm_mgr_signal_str(IN osm_sm_signal_t signal);
516 * [in] SM manager signal
519 * Pointer to the signal discription string.
526 /****f* IBA Base: Types/osm_get_sm_mgr_state_str
528 * osm_get_sm_mgr_state_str
531 * Returns a string for the specified SM manager state.
535 const char *osm_get_sm_mgr_state_str(IN uint16_t state);
539 * [in] SM manager state
542 * Pointer to the state discription string.
550 #endif /* _OSM_HELPER_H_ */