2 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
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_sm_mad_ctrl_t.
39 * This object represents a controller that receives the IBA NodeInfo
40 * attribute from a node.
41 * This object is part of the OpenSM family of objects.
44 #ifndef _OSM_SM_MAD_CTRL_H_
45 #define _OSM_SM_MAD_CTRL_H_
47 #include <complib/cl_passivelock.h>
48 #include <complib/cl_dispatcher.h>
49 #include <opensm/osm_base.h>
50 #include <opensm/osm_stats.h>
51 #include <opensm/osm_madw.h>
52 #include <opensm/osm_mad_pool.h>
53 #include <opensm/osm_subnet.h>
54 #include <opensm/osm_log.h>
55 #include <opensm/osm_vl15intf.h>
58 # define BEGIN_C_DECLS extern "C" {
59 # define END_C_DECLS }
60 #else /* !__cplusplus */
61 # define BEGIN_C_DECLS
63 #endif /* __cplusplus */
66 /****h* OpenSM/SM MAD Controller
71 * The SM MAD Controller object encapsulates
72 * the information needed to receive MADs from the transport layer.
74 * The SM MAD Controller object is thread safe.
76 * This object should be treated as opaque and should be
77 * manipulated only through the provided functions.
83 /****s* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_t
88 * SM MAD Controller structure.
90 * This object should be treated as opaque and should
91 * be manipulated only through the provided functions.
95 typedef struct osm_sm_mad_ctrl {
98 osm_mad_pool_t *p_mad_pool;
100 osm_vendor_t *p_vendor;
101 osm_bind_handle_t h_bind;
103 cl_dispatcher_t *p_disp;
104 cl_disp_reg_handle_t h_disp;
105 osm_stats_t *p_stats;
110 * Pointer to the log object.
113 * Pointer to the subnet object.
116 * Pointer to the MAD pool.
119 * Pointer to the vendor specific interfaces object.
122 * Bind handle returned by the transport layer.
125 * Pointer to the serializing lock.
128 * Pointer to the Dispatcher.
131 * Handle returned from dispatcher registration.
134 * Pointer to the OpenSM statistics block.
137 * SM MAD Controller object
141 /****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_construct
143 * osm_sm_mad_ctrl_construct
146 * This function constructs a SM MAD Controller object.
150 void osm_sm_mad_ctrl_construct(IN osm_sm_mad_ctrl_t * const p_ctrl);
154 * [in] Pointer to a SM MAD Controller
155 * object to construct.
158 * This function does not return a value.
161 * Allows calling osm_sm_mad_ctrl_init, and osm_sm_mad_ctrl_destroy.
163 * Calling osm_sm_mad_ctrl_construct is a prerequisite to calling any other
164 * method except osm_sm_mad_ctrl_init.
167 * SM MAD Controller object, osm_sm_mad_ctrl_init,
168 * osm_sm_mad_ctrl_destroy
171 /****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_destroy
173 * osm_sm_mad_ctrl_destroy
176 * The osm_sm_mad_ctrl_destroy function destroys the object, releasing
181 void osm_sm_mad_ctrl_destroy(IN osm_sm_mad_ctrl_t * const p_ctrl);
185 * [in] Pointer to the object to destroy.
188 * This function does not return a value.
191 * Performs any necessary cleanup of the specified
192 * SM MAD Controller object.
193 * Further operations should not be attempted on the destroyed object.
194 * This function should only be called after a call to
195 * osm_sm_mad_ctrl_construct or osm_sm_mad_ctrl_init.
198 * SM MAD Controller object, osm_sm_mad_ctrl_construct,
199 * osm_sm_mad_ctrl_init
202 /****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_init
204 * osm_sm_mad_ctrl_init
207 * The osm_sm_mad_ctrl_init function initializes a
208 * SM MAD Controller object for use.
213 osm_sm_mad_ctrl_init(IN osm_sm_mad_ctrl_t * const p_ctrl,
214 IN osm_subn_t * const p_subn,
215 IN osm_mad_pool_t * const p_mad_pool,
216 IN osm_vl15_t * const p_vl15,
217 IN osm_vendor_t * const p_vendor,
218 IN osm_log_t * const p_log,
219 IN osm_stats_t * const p_stats,
220 IN cl_plock_t * const p_lock,
221 IN cl_dispatcher_t * const p_disp);
225 * [in] Pointer to an osm_sm_mad_ctrl_t object to initialize.
228 * [in] Pointer to the MAD pool.
231 * [in] Pointer to the VL15 interface object.
234 * [in] Pointer to the vendor specific interfaces object.
237 * [in] Pointer to the log object.
240 * [in] Pointer to the OpenSM stastics block.
243 * [in] Pointer to the OpenSM serializing lock.
246 * [in] Pointer to the OpenSM central Dispatcher.
249 * IB_SUCCESS if the SM MAD Controller object was initialized
253 * Allows calling other SM MAD Controller methods.
256 * SM MAD Controller object, osm_sm_mad_ctrl_construct,
257 * osm_sm_mad_ctrl_destroy
260 /****f* OpenSM: SM/osm_sm_mad_ctrl_bind
262 * osm_sm_mad_ctrl_bind
265 * Binds the SM MAD Controller object to a port guid.
270 osm_sm_mad_ctrl_bind(IN osm_sm_mad_ctrl_t * const p_ctrl,
271 IN const ib_net64_t port_guid);
275 * [in] Pointer to an osm_sm_mad_ctrl_t object to initialize.
278 * [in] Local port GUID with which to bind.
285 * A given SM MAD Controller object can only be bound to one
291 /****f* OpenSM: SM/osm_sm_mad_ctrl_get_bind_handle
293 * osm_sm_mad_ctrl_get_bind_handle
296 * Returns the bind handle.
300 static inline osm_bind_handle_t
301 osm_sm_mad_ctrl_get_bind_handle(IN const osm_sm_mad_ctrl_t * const p_ctrl)
303 return (p_ctrl->h_bind);
309 * [in] Pointer to an osm_sm_mad_ctrl_t object.
312 * Returns the bind handle, which may be OSM_BIND_INVALID_HANDLE
313 * if no port has been bound.
316 * A given SM MAD Controller object can only be bound to one
323 #endif /* _OSM_SM_MAD_CTRL_H_ */