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
38 * Declaration of osm_mad_wrapper_t.
39 * This object represents the context wrapper for OpenSM MAD processing.
40 * This object is part of the OpenSM family of objects.
47 #include <iba/ib_types.h>
48 #include <complib/cl_qlist.h>
49 #include <complib/cl_dispatcher.h>
50 #include <opensm/osm_base.h>
51 #include <vendor/osm_vendor.h>
54 # define BEGIN_C_DECLS extern "C" {
55 # define END_C_DECLS }
56 #else /* !__cplusplus */
57 # define BEGIN_C_DECLS
59 #endif /* __cplusplus */
62 /****s* OpenSM: MAD Wrapper/osm_bind_info_t
70 typedef struct osm_bind_info {
73 uint8_t class_version;
74 boolean_t is_responder;
75 boolean_t is_trap_processor;
76 boolean_t is_report_processor;
83 * PortGuid of local port
92 * True if this is a GSI Agent
95 * True if GSI Trap msgs are handled
98 * True if GSI Report msgs are handled
109 /****h* OpenSM/MAD Wrapper
114 * The MAD Wrapper object encapsulates the information needed by the
115 * OpenSM to manage individual MADs. The OpenSM allocates one MAD Wrapper
118 * The MAD Wrapper is not thread safe, thus callers must provide
121 * This object should be treated as opaque and should be
122 * manipulated only through the provided functions.
129 /****s* OpenSM: MAD Wrapper/osm_ni_context_t
134 * Context needed by recipient of NodeInfo attribute.
138 typedef struct osm_ni_context {
139 ib_net64_t node_guid;
141 ib_net64_t dup_node_guid;
142 uint8_t dup_port_num;
148 * Pointer to the node thru which we got to this node.
151 * Pointer to the switch object (if any) of the switch
152 * thru which we got to this node.
155 * Port number on the node or switch thru which we got
161 /****s* OpenSM: MAD Wrapper/osm_pi_context_t
166 * Context needed by recipient of PortInfo attribute.
170 typedef struct osm_pi_context {
171 ib_net64_t node_guid;
172 ib_net64_t port_guid;
173 boolean_t set_method;
174 boolean_t light_sweep;
175 boolean_t active_transition;
179 /****s* OpenSM: MAD Wrapper/osm_nd_context_t
184 * Context needed by recipient of NodeDescription attribute.
188 typedef struct osm_nd_context {
189 ib_net64_t node_guid;
193 /****s* OpenSM: MAD Wrapper/osm_si_context_t
198 * Context needed by recipient of SwitchInfo attribute.
202 typedef struct osm_si_context {
203 ib_net64_t node_guid;
204 boolean_t set_method;
205 boolean_t light_sweep;
209 /****s* OpenSM: MAD Wrapper/osm_lft_context_t
214 * Context needed by recipient of LinearForwardingTable attribute.
218 typedef struct osm_lft_context {
219 ib_net64_t node_guid;
220 boolean_t set_method;
224 /****s* OpenSM: MAD Wrapper/osm_mft_context_t
229 * Context needed by recipient of MulticastForwardingTable attribute.
233 typedef struct osm_mft_context {
234 ib_net64_t node_guid;
235 boolean_t set_method;
239 /****s* OpenSM: MAD Wrapper/osm_smi_context_t
244 * Context needed by recipient of SMInfo attribute.
248 typedef struct osm_smi_context {
249 ib_net64_t port_guid;
250 boolean_t set_method;
251 boolean_t light_sweep;
255 /****s* OpenSM: MAD Wrapper/osm_pkey_context_t
260 * Context needed by recipient of P_Key attribute.
264 typedef struct osm_pkey_context {
265 ib_net64_t node_guid;
266 ib_net64_t port_guid;
267 boolean_t set_method;
268 } osm_pkey_context_t;
271 /****s* OpenSM: MAD Wrapper/osm_slvl_context_t
276 * Context needed by recipient of PortInfo attribute.
280 typedef struct osm_slvl_context {
281 ib_net64_t node_guid;
282 ib_net64_t port_guid;
283 boolean_t set_method;
284 } osm_slvl_context_t;
287 /****s* OpenSM: MAD Wrapper/osm_vla_context_t
292 * Context needed by recipient of VL Arb attribute.
296 typedef struct osm_vla_context {
297 ib_net64_t node_guid;
298 ib_net64_t port_guid;
299 boolean_t set_method;
303 /****s* OpenSM: MAD Wrapper/osm_perfmgr_context_t
305 * Context for Performance manager queries
307 typedef struct osm_perfmgr_context {
310 uint8_t mad_method; /* was this a get or a set */
311 #if ENABLE_OSM_PERF_MGR_PROFILE
312 struct timeval query_start;
314 } osm_perfmgr_context_t;
317 #ifndef OSM_VENDOR_INTF_OPENIB
318 /****s* OpenSM: MAD Wrapper/osm_arbitrary_context_t
320 * osm_arbitrary_context_t
323 * Context needed by arbitrary recipient.
327 typedef struct osm_arbitrary_context {
330 } osm_arbitrary_context_t;
334 /****s* OpenSM: MAD Wrapper/osm_madw_context_t
339 * Context needed by recipients of MAD responses.
343 typedef union _osm_madw_context {
344 osm_ni_context_t ni_context;
345 osm_pi_context_t pi_context;
346 osm_nd_context_t nd_context;
347 osm_si_context_t si_context;
348 osm_lft_context_t lft_context;
349 osm_mft_context_t mft_context;
350 osm_smi_context_t smi_context;
351 osm_slvl_context_t slvl_context;
352 osm_pkey_context_t pkey_context;
353 osm_vla_context_t vla_context;
354 osm_perfmgr_context_t perfmgr_context;
355 #ifndef OSM_VENDOR_INTF_OPENIB
356 osm_arbitrary_context_t arb_context;
358 } osm_madw_context_t;
361 /****s* OpenSM: MAD Wrapper/osm_mad_addr_t
369 typedef struct osm_mad_addr {
375 ib_net16_t source_lid;
380 ib_net32_t remote_qp;
381 ib_net32_t remote_qkey;
383 uint8_t service_level;
384 boolean_t global_route;
395 /****s* OpenSM: MAD Wrapper/osm_madw_t
400 * Context needed for processing individual MADs
404 typedef struct osm_madw {
405 cl_list_item_t list_item;
406 osm_bind_handle_t h_bind;
407 osm_vend_wrap_t vend_wrap;
408 osm_mad_addr_t mad_addr;
409 osm_bind_info_t bind_info;
410 osm_madw_context_t context;
412 ib_api_status_t status;
413 cl_disp_msgid_t fail_msg;
414 boolean_t resp_expected;
415 const ib_mad_t *p_mad;
420 * List linkage for lists. MUST BE FIRST MEMBER!
423 * Bind handle for the port on which this MAD will be sent
427 * Transport vendor specific context. This structure is not
428 * used outside MAD transport vendor specific code.
431 * Union of controller specific contexts needed for this MAD.
432 * This structure allows controllers to indirectly communicate
433 * with each other through the dispatcher.
436 * Size of this MAD in bytes.
439 * Status of completed operation on the MAD.
440 * CL_SUCCESS if the operation was successful.
443 * Dispatcher message with which to post this MAD on failure.
444 * This value is set by the originator of the MAD.
445 * If an operation on this MAD fails, for example due to a timeout,
446 * then the transport layer will dispose of the MAD by sending
447 * it through the Dispatcher with this message type. Presumably,
448 * there is a controller listening for the failure message that can
452 * TRUE if a response is expected to this MAD.
456 * Pointer to the wire MAD. The MAD itself cannot be part of the
457 * wrapper, since wire MADs typically reside in special memory
458 * registered with the local HCA.
463 /****f* OpenSM: MAD Wrapper/osm_madw_init
468 * Initializes a MAD Wrapper object for use.
473 osm_madw_init(IN osm_madw_t * const p_madw,
474 IN osm_bind_handle_t h_bind,
475 IN const uint32_t mad_size,
476 IN const osm_mad_addr_t * const p_mad_addr)
478 memset(p_madw, 0, sizeof(*p_madw));
479 p_madw->h_bind = h_bind;
480 p_madw->fail_msg = CL_DISP_MSGID_NONE;
481 p_madw->mad_size = mad_size;
483 p_madw->mad_addr = *p_mad_addr;
484 p_madw->resp_expected = FALSE;
490 * [in] Pointer to an osm_madw_t object to initialize.
493 * [in] Pointer to the wire MAD.
496 * [in] Pointer to the MAD address structure. This parameter may
497 * be NULL for directed route MADs.
507 /****f* OpenSM: MAD Wrapper/osm_madw_get_smp_ptr
509 * osm_madw_get_smp_ptr
512 * Gets a pointer to the SMP in this MAD.
516 static inline ib_smp_t *osm_madw_get_smp_ptr(IN const osm_madw_t * const p_madw)
518 return ((ib_smp_t *) p_madw->p_mad);
524 * [in] Pointer to an osm_madw_t object to initialize.
527 * Pointer to the start of the SMP MAD.
535 /****f* OpenSM: MAD Wrapper/osm_madw_get_sa_mad_ptr
537 * osm_madw_get_sa_mad_ptr
540 * Gets a pointer to the SA MAD in this MAD wrapper.
544 static inline ib_sa_mad_t *osm_madw_get_sa_mad_ptr(IN const osm_madw_t *
547 return ((ib_sa_mad_t *) p_madw->p_mad);
553 * [in] Pointer to an osm_madw_t object.
556 * Pointer to the start of the SA MAD.
564 /****f* OpenSM: MAD Wrapper/osm_madw_get_perfmgt_mad_ptr
566 * Gets a pointer to the PerfMgt MAD in this MAD wrapper.
570 static inline ib_perfmgt_mad_t *osm_madw_get_perfmgt_mad_ptr(IN const osm_madw_t
573 return ((ib_perfmgt_mad_t *) p_madw->p_mad);
579 * [in] Pointer to an osm_madw_t object.
582 * Pointer to the start of the PerfMgt MAD.
590 /****f* OpenSM: MAD Wrapper/osm_madw_get_ni_context_ptr
592 * osm_madw_get_ni_context_ptr
595 * Gets a pointer to the NodeInfo context in this MAD.
599 static inline osm_ni_context_t *osm_madw_get_ni_context_ptr(IN const osm_madw_t
602 return ((osm_ni_context_t *) & p_madw->context);
608 * [in] Pointer to an osm_madw_t object.
611 * Pointer to the start of the context structure.
618 /****f* OpenSM: MAD Wrapper/osm_madw_get_pi_context_ptr
620 * osm_madw_get_pi_context_ptr
623 * Gets a pointer to the PortInfo context in this MAD.
627 static inline osm_pi_context_t *osm_madw_get_pi_context_ptr(IN const osm_madw_t
630 return ((osm_pi_context_t *) & p_madw->context);
636 * [in] Pointer to an osm_madw_t object.
639 * Pointer to the start of the context structure.
646 /****f* OpenSM: MAD Wrapper/osm_madw_get_nd_context_ptr
648 * osm_madw_get_nd_context_ptr
651 * Gets a pointer to the NodeDescription context in this MAD.
655 static inline osm_nd_context_t *osm_madw_get_nd_context_ptr(IN const osm_madw_t
658 return ((osm_nd_context_t *) & p_madw->context);
664 * [in] Pointer to an osm_madw_t object.
667 * Pointer to the start of the context structure.
674 /****f* OpenSM: MAD Wrapper/osm_madw_get_lft_context_ptr
676 * osm_madw_get_lft_context_ptr
679 * Gets a pointer to the LFT context in this MAD.
683 static inline osm_lft_context_t *osm_madw_get_lft_context_ptr(IN const
687 return ((osm_lft_context_t *) & p_madw->context);
693 * [in] Pointer to an osm_madw_t object.
696 * Pointer to the start of the context structure.
703 /****f* OpenSM: MAD Wrapper/osm_madw_get_mft_context_ptr
705 * osm_madw_get_mft_context_ptr
708 * Gets a pointer to the MFT context in this MAD.
712 static inline osm_mft_context_t *osm_madw_get_mft_context_ptr(IN const
716 return ((osm_mft_context_t *) & p_madw->context);
722 * [in] Pointer to an osm_madw_t object.
725 * Pointer to the start of the context structure.
732 /****f* OpenSM: MAD Wrapper/osm_madw_get_si_context_ptr
734 * osm_madw_get_si_context_ptr
737 * Gets a pointer to the SwitchInfo context in this MAD.
741 static inline osm_si_context_t *osm_madw_get_si_context_ptr(IN const osm_madw_t
744 return ((osm_si_context_t *) & p_madw->context);
750 * [in] Pointer to an osm_madw_t object.
753 * Pointer to the start of the context structure.
760 /****f* OpenSM: MAD Wrapper/osm_madw_get_smi_context_ptr
762 * osm_madw_get_smi_context_ptr
765 * Gets a pointer to the SMInfo context in this MAD.
769 static inline osm_smi_context_t *osm_madw_get_smi_context_ptr(IN const
773 return ((osm_smi_context_t *) & p_madw->context);
779 * [in] Pointer to an osm_madw_t object.
782 * Pointer to the start of the context structure.
789 /****f* OpenSM: MAD Wrapper/osm_madw_get_pkey_context_ptr
791 * osm_madw_get_pkey_context_ptr
794 * Gets a pointer to the P_Key context in this MAD.
798 static inline osm_pkey_context_t *osm_madw_get_pkey_context_ptr(IN const
802 return ((osm_pkey_context_t *) & p_madw->context);
808 * [in] Pointer to an osm_madw_t object.
811 * Pointer to the start of the context structure.
818 /****f* OpenSM: MAD Wrapper/osm_madw_get_slvl_context_ptr
820 * osm_madw_get_slvl_context_ptr
823 * Gets a pointer to the PortInfo context in this MAD.
827 static inline osm_slvl_context_t *osm_madw_get_slvl_context_ptr(IN const
831 return ((osm_slvl_context_t *) & p_madw->context);
837 * [in] Pointer to an osm_madw_t object.
840 * Pointer to the start of the context structure.
847 /****f* OpenSM: MAD Wrapper/osm_madw_get_vla_context_ptr
849 * osm_madw_get_vla_context_ptr
852 * Gets a pointer to the Vl Arb context in this MAD.
856 static inline osm_vla_context_t *osm_madw_get_vla_context_ptr(IN const
860 return ((osm_vla_context_t *) & p_madw->context);
866 * [in] Pointer to an osm_madw_t object.
869 * Pointer to the start of the context structure.
876 #ifndef OSM_VENDOR_INTF_OPENIB
877 /****f* OpenSM: MAD Wrapper/osm_madw_get_arbitrary_context_ptr
879 * osm_madw_get_arbitrary_context_ptr
882 * Gets a pointer to the arbitrary context in this MAD.
886 static inline osm_arbitrary_context_t *osm_madw_get_arbitrary_context_ptr(IN
893 return ((osm_arbitrary_context_t *) & p_madw->context);
899 * [in] Pointer to an osm_madw_t object.
902 * Pointer to the start of the context structure.
910 /****f* OpenSM: MAD Wrapper/osm_madw_get_vend_ptr
912 * osm_madw_get_vend_ptr
915 * Gets a pointer to the vendor specific MAD wrapper component.
919 static inline osm_vend_wrap_t *osm_madw_get_vend_ptr(IN const osm_madw_t *
922 return ((osm_vend_wrap_t *) & p_madw->vend_wrap);
928 * [in] Pointer to an osm_madw_t object.
931 * Gets a pointer to the vendor specific MAD wrapper component.
938 /****f* OpenSM: MAD Wrapper/osm_madw_get_vend_ptr
940 * osm_madw_get_vend_ptr
943 * Returns the bind handle associated with this MAD.
947 static inline osm_bind_handle_t
948 osm_madw_get_bind_handle(IN const osm_madw_t * const p_madw)
950 return ((osm_bind_handle_t) p_madw->h_bind);
956 * [in] Pointer to an osm_madw_t object.
959 * Returns the bind handle associated with this MAD.
966 /****f* OpenSM: MAD Wrapper/osm_madw_get_mad_addr_ptr
968 * osm_madw_get_mad_addr_ptr
971 * Returns the mad address structure associated with this MAD.
975 static inline osm_mad_addr_t *osm_madw_get_mad_addr_ptr(IN const osm_madw_t *
978 return ((osm_mad_addr_t *) & p_madw->mad_addr);
984 * [in] Pointer to an osm_madw_t object.
987 * Returns the mad address structure associated with this MAD.
994 /****f* OpenSM: MAD Wrapper/osm_madw_get_mad_ptr
996 * osm_madw_get_mad_ptr
999 * Returns the mad address structure associated with this MAD.
1003 static inline ib_mad_t *osm_madw_get_mad_ptr(IN const osm_madw_t * const p_madw)
1005 return ((ib_mad_t *) p_madw->p_mad);
1011 * [in] Pointer to an osm_madw_t object.
1014 * Returns the mad address structure associated with this MAD.
1021 /****f* OpenSM: MAD Wrapper/osm_madw_get_err_msg
1023 * osm_madw_get_err_msg
1026 * Returns the message with which to post this mad wrapper if
1027 * an error occurs during processing the mad.
1031 static inline cl_disp_msgid_t
1032 osm_madw_get_err_msg(IN const osm_madw_t * const p_madw)
1034 return ((cl_disp_msgid_t) p_madw->fail_msg);
1040 * [in] Pointer to an osm_madw_t object.
1043 * Returns the message with which to post this mad wrapper if
1044 * an error occurs during processing the mad.
1051 /****f* OpenSM: MAD Wrapper/osm_madw_set_mad
1056 * Associates a wire MAD with this MAD Wrapper object.
1061 osm_madw_set_mad(IN osm_madw_t * const p_madw, IN const ib_mad_t * const p_mad)
1063 p_madw->p_mad = p_mad;
1069 * [in] Pointer to an osm_madw_t object.
1072 * [in] Pointer to the wire MAD to attach to this wrapper.
1082 /****f* OpenSM: MAD Wrapper/osm_madw_copy_context
1084 * osm_madw_copy_context
1087 * Copies the controller context from one MAD Wrapper to another.
1092 osm_madw_copy_context(IN osm_madw_t * const p_dest,
1093 IN const osm_madw_t * const p_src)
1095 p_dest->context = p_src->context;
1101 * [in] Pointer to the destination osm_madw_t object.
1104 * [in] Pointer to the source osm_madw_t object.
1115 #endif /* _OSM_MADW_H_ */