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_sa_t.
39 * This object represents an IBA subnet.
40 * This object is part of the OpenSM family of objects.
46 #include <iba/ib_types.h>
47 #include <complib/cl_passivelock.h>
48 #include <complib/cl_event.h>
49 #include <complib/cl_thread.h>
50 #include <complib/cl_timer.h>
51 #include <complib/cl_dispatcher.h>
52 #include <opensm/osm_stats.h>
53 #include <opensm/osm_subnet.h>
54 #include <vendor/osm_vendor_api.h>
55 #include <opensm/osm_mad_pool.h>
56 #include <opensm/osm_log.h>
57 #include <opensm/osm_sa_mad_ctrl.h>
58 #include <opensm/osm_sm.h>
59 #include <opensm/osm_multicast.h>
62 # define BEGIN_C_DECLS extern "C" {
63 # define END_C_DECLS }
64 #else /* !__cplusplus */
65 # define BEGIN_C_DECLS
67 #endif /* __cplusplus */
75 * The SA object encapsulates the information needed by the
76 * OpenSM to instantiate a subnet administrator. The OpenSM allocates
77 * one SA object per subnet manager.
79 * The SA object is thread safe.
81 * This object should be treated as opaque and should
82 * be manipulated only through the provided functions.
85 * Ranjit Pandit, Intel
86 * Anil Keshavamurthy, Intel
89 /****d* OpenSM: SA/osm_sa_state_t
94 * Enumerates the possible states of SA object.
98 typedef enum _osm_sa_state {
99 OSM_SA_STATE_INIT = 0,
104 /****s* OpenSM: SM/osm_sa_t
109 * Subnet Administration structure.
111 * This object should be treated as opaque and should
112 * be manipulated only through the provided functions.
116 typedef struct osm_sa {
117 osm_sa_state_t state;
120 osm_vendor_t *p_vendor;
122 osm_mad_pool_t *p_mad_pool;
123 cl_dispatcher_t *p_disp;
125 atomic32_t sa_trans_id;
126 osm_sa_mad_ctrl_t mad_ctrl;
128 cl_disp_reg_handle_t cpi_disp_h;
129 cl_disp_reg_handle_t nr_disp_h;
130 cl_disp_reg_handle_t pir_disp_h;
131 cl_disp_reg_handle_t gir_disp_h;
132 cl_disp_reg_handle_t lr_disp_h;
133 cl_disp_reg_handle_t pr_disp_h;
134 cl_disp_reg_handle_t smir_disp_h;
135 cl_disp_reg_handle_t mcmr_disp_h;
136 cl_disp_reg_handle_t sr_disp_h;
137 #if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
138 cl_disp_reg_handle_t mpr_disp_h;
140 cl_disp_reg_handle_t infr_disp_h;
141 cl_disp_reg_handle_t infir_disp_h;
142 cl_disp_reg_handle_t vlarb_disp_h;
143 cl_disp_reg_handle_t slvl_disp_h;
144 cl_disp_reg_handle_t pkey_disp_h;
145 cl_disp_reg_handle_t lft_disp_h;
146 cl_disp_reg_handle_t sir_disp_h;
147 cl_disp_reg_handle_t mft_disp_h;
152 * State of this SA object
155 * Pointer to the Subnet Manager object.
158 * Pointer to the Subnet object for this subnet.
161 * Pointer to the vendor specific interfaces object.
164 * Pointer to the log object.
167 * Pointer to the MAD pool.
170 * Pointer to dispatcher
173 * Pointer to Lock for serialization
185 /****f* OpenSM: SA/osm_sa_construct
190 * This function constructs an SA object.
194 void osm_sa_construct(IN osm_sa_t * const p_sa);
198 * [in] Pointer to a SA object to construct.
201 * This function does not return a value.
204 * Allows calling osm_sa_destroy.
206 * Calling osm_sa_construct is a prerequisite to calling any other
207 * method except osm_sa_init.
210 * SA object, osm_sa_init, osm_sa_destroy
213 /****f* OpenSM: SA/osm_sa_shutdown
218 * The osm_sa_shutdown function shutdowns an SA, unregistering from all
219 * dispatcher messages and unbinding the QP1 mad service
223 void osm_sa_shutdown(IN osm_sa_t * const p_sa);
227 * [in] Pointer to a SA object to shutdown.
230 * This function does not return a value.
233 * SA object, osm_sa_construct, osm_sa_init
236 /****f* OpenSM: SA/osm_sa_destroy
241 * The osm_sa_destroy function destroys an SA, releasing
246 void osm_sa_destroy(IN osm_sa_t * const p_sa);
250 * [in] Pointer to a SA object to destroy.
253 * This function does not return a value.
256 * Performs any necessary cleanup of the specified SA object.
257 * Further operations should not be attempted on the destroyed object.
258 * This function should only be called after a call to osm_sa_construct or
262 * SA object, osm_sa_construct, osm_sa_init
265 /****f* OpenSM: SA/osm_sa_init
270 * The osm_sa_init function initializes a SA object for use.
274 ib_api_status_t osm_sa_init(IN osm_sm_t * const p_sm,
275 IN osm_sa_t * const p_sa,
276 IN osm_subn_t * const p_subn,
277 IN osm_vendor_t * const p_vendor,
278 IN osm_mad_pool_t * const p_mad_pool,
279 IN osm_log_t * const p_log,
280 IN osm_stats_t * const p_stats,
281 IN cl_dispatcher_t * const p_disp,
282 IN cl_plock_t * const p_lock);
286 * [in] Pointer to an osm_sa_t object to initialize.
289 * [in] Pointer to the Subnet object for this subnet.
292 * [in] Pointer to the vendor specific interfaces object.
295 * [in] Pointer to the MAD pool.
298 * [in] Pointer to the log object.
301 * [in] Pointer to the statistics object.
304 * [in] Pointer to the OpenSM central Dispatcher.
307 * [in] Pointer to the OpenSM serializing lock.
310 * CL_SUCCESS if the SA object was initialized successfully.
313 * Allows calling other SA methods.
316 * SA object, osm_sa_construct, osm_sa_destroy
319 /****f* OpenSM: SA/osm_sa_bind
324 * Binds the SA object to a port guid.
329 osm_sa_bind(IN osm_sa_t * const p_sa, IN const ib_net64_t port_guid);
333 * [in] Pointer to an osm_sa_t object to bind.
336 * [in] Local port GUID with which to bind.
343 * A given SA object can only be bound to one port at a time.
348 /****f* OpenSM: SA/osm_sa_send
353 * Sends SA MAD via osm_vendor_send and maintains the QP1 sent statistic
357 ib_api_status_t osm_sa_send(osm_sa_t *sa, IN osm_madw_t * const p_madw,
358 IN boolean_t const resp_expected);
360 /****f* IBA Base: Types/osm_sa_send_error
365 * Sends a generic SA response with the specified error status.
366 * The payload is simply replicated from the request MAD.
370 void osm_sa_send_error(IN osm_sa_t * sa, IN const osm_madw_t * const p_madw,
371 IN const ib_net16_t sa_status);
375 * [in] Pointer to an osm_sa_t object.
378 * [in] Original MAD to which the response must be sent.
381 * [in] Status to send in the response.
390 /****f* OpenSM: SA/osm_sa_respond
395 * Sends SA MAD response
397 void osm_sa_respond(osm_sa_t *sa, osm_madw_t *madw, size_t attr_size,
402 * [in] Pointer to an osm_sa_t object.
405 * [in] Original MAD to which the response must be sent.
408 * [in] Size of this SA attribute.
411 * [in] List of attribute to respond - it will be freed after
422 /****f* OpenSM: SA/osm_sa_db_file_dump
424 * osm_sa_db_file_dump
427 * Dumps the SA DB to the dump file.
431 int osm_sa_db_file_dump(struct osm_opensm *p_osm);
435 * [in] Pointer to an osm_opensm_t object.
442 /****f* OpenSM: SA/osm_sa_db_file_load
444 * osm_sa_db_file_load
447 * Loads SA DB from the file.
451 int osm_sa_db_file_load(struct osm_opensm *p_osm);
455 * [in] Pointer to an osm_opensm_t object.
458 * 0 on success, other value on failure.
462 /****f* OpenSM: MC Member Record Receiver/osm_mcmr_rcv_find_or_create_new_mgrp
464 * osm_mcmr_rcv_find_or_create_new_mgrp
467 * Create new Multicast group
473 osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa,
474 IN uint64_t comp_mask,
476 const p_recvd_mcmember_rec,
477 OUT osm_mgrp_t ** pp_mgrp);
481 * [in] Pointer to an osm_sa_t object.
482 * p_recvd_mcmember_rec
483 * [in] Received Multicast member record
486 * [out] pointer the osm_mgrp_t object
489 * IB_SUCCESS, IB_ERROR
493 osm_mgrp_t *osm_get_mgrp_by_mgid(IN osm_sa_t * sa, IN ib_gid_t * p_mgid);
496 #endif /* _OSM_SA_H_ */