1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff *
34219820Sjeff */
35219820Sjeff
36219820Sjeff/*
37219820Sjeff * Abstract:
38219820Sjeff * 	Declaration of osm_lid_mgr_t.
39219820Sjeff *	This object represents the LID Manager object.
40219820Sjeff *	This object is part of the OpenSM family of objects.
41219820Sjeff */
42219820Sjeff
43219820Sjeff#ifndef _OSM_LID_MGR_H_
44219820Sjeff#define _OSM_LID_MGR_H_
45219820Sjeff
46219820Sjeff#include <complib/cl_passivelock.h>
47219820Sjeff#include <opensm/osm_base.h>
48219820Sjeff#include <opensm/osm_madw.h>
49219820Sjeff#include <opensm/osm_subnet.h>
50219820Sjeff#include <opensm/osm_db.h>
51219820Sjeff#include <opensm/osm_log.h>
52219820Sjeff
53219820Sjeff#ifdef __cplusplus
54219820Sjeff#  define BEGIN_C_DECLS extern "C" {
55219820Sjeff#  define END_C_DECLS   }
56219820Sjeff#else				/* !__cplusplus */
57219820Sjeff#  define BEGIN_C_DECLS
58219820Sjeff#  define END_C_DECLS
59219820Sjeff#endif				/* __cplusplus */
60219820Sjeff
61219820SjeffBEGIN_C_DECLS
62219820Sjeff#define OSM_LID_MGR_LIST_SIZE_MIN 256
63219820Sjeff/****h* OpenSM/LID Manager
64219820Sjeff* NAME
65219820Sjeff*	LID Manager
66219820Sjeff*
67219820Sjeff* DESCRIPTION
68219820Sjeff*	The LID Manager object encapsulates the information
69219820Sjeff*	needed to control LID assignments on the subnet.
70219820Sjeff*
71219820Sjeff*	The LID Manager object is thread safe.
72219820Sjeff*
73219820Sjeff*	This object should be treated as opaque and should be
74219820Sjeff*	manipulated only through the provided functions.
75219820Sjeff*
76219820Sjeff* AUTHOR
77219820Sjeff*	Steve King, Intel
78219820Sjeff*
79219820Sjeff*********/
80219820Sjeffstruct osm_sm;
81219820Sjeff/****s* OpenSM: LID Manager/osm_lid_mgr_t
82219820Sjeff* NAME
83219820Sjeff*	osm_lid_mgr_t
84219820Sjeff*
85219820Sjeff* DESCRIPTION
86219820Sjeff*	LID Manager structure.
87219820Sjeff*
88219820Sjeff*	This object should be treated as opaque and should
89219820Sjeff*	be manipulated only through the provided functions.
90219820Sjeff*
91219820Sjeff* SYNOPSIS
92219820Sjeff*/
93219820Sjefftypedef struct osm_lid_mgr {
94219820Sjeff	struct osm_sm *sm;
95219820Sjeff	osm_subn_t *p_subn;
96219820Sjeff	osm_db_t *p_db;
97219820Sjeff	osm_log_t *p_log;
98219820Sjeff	cl_plock_t *p_lock;
99219820Sjeff	boolean_t send_set_reqs;
100219820Sjeff	osm_db_domain_t *p_g2l;
101219820Sjeff	cl_ptr_vector_t used_lids;
102219820Sjeff	cl_qlist_t free_ranges;
103219820Sjeff} osm_lid_mgr_t;
104219820Sjeff/*
105219820Sjeff* FIELDS
106219820Sjeff*	sm
107219820Sjeff*		Pointer to the SM object.
108219820Sjeff*
109219820Sjeff*	p_subn
110219820Sjeff*		Pointer to the Subnet object for this subnet.
111219820Sjeff*
112219820Sjeff*	p_db
113219820Sjeff*		Pointer to the database (persistency) object
114219820Sjeff*
115219820Sjeff*	p_log
116219820Sjeff*		Pointer to the log object.
117219820Sjeff*
118219820Sjeff*	p_lock
119219820Sjeff*		Pointer to the serializing lock.
120219820Sjeff*
121219820Sjeff*	send_set_reqs
122219820Sjeff*		Boolean to indicate whether any set requests sent.
123219820Sjeff*
124219820Sjeff*	p_g2l
125219820Sjeff*		Pointer to the database domain storing guid to lid mapping.
126219820Sjeff*
127219820Sjeff*	used_lids
128219820Sjeff*		A vector the maps from the lid to its guid. keeps track of
129219820Sjeff*		existing and non existing mapping of guid->lid
130219820Sjeff*
131219820Sjeff*	free_ranges
132219820Sjeff*		A list of available free lid ranges. The list is initialized
133219820Sjeff*		by the code that initializes the lid assignment and is consumed
134219820Sjeff*		by the procedure that finds a free range. It holds elements of
135219820Sjeff*		type osm_lid_mgr_range_t
136219820Sjeff*
137219820Sjeff* SEE ALSO
138219820Sjeff*	LID Manager object
139219820Sjeff*********/
140219820Sjeff
141219820Sjeff/****f* OpenSM: LID Manager/osm_lid_mgr_construct
142219820Sjeff* NAME
143219820Sjeff*	osm_lid_mgr_construct
144219820Sjeff*
145219820Sjeff* DESCRIPTION
146219820Sjeff*	This function constructs a LID Manager object.
147219820Sjeff*
148219820Sjeff* SYNOPSIS
149219820Sjeff*/
150219820Sjeffvoid osm_lid_mgr_construct(IN osm_lid_mgr_t * const p_mgr);
151219820Sjeff/*
152219820Sjeff* PARAMETERS
153219820Sjeff*	p_mgr
154219820Sjeff*		[in] Pointer to a LID Manager object to construct.
155219820Sjeff*
156219820Sjeff* RETURN VALUE
157219820Sjeff*	This function does not return a value.
158219820Sjeff*
159219820Sjeff* NOTES
160219820Sjeff*	Allows osm_lid_mgr_destroy
161219820Sjeff*
162219820Sjeff*	Calling osm_lid_mgr_construct is a prerequisite to calling any other
163219820Sjeff*	method except osm_lid_mgr_init.
164219820Sjeff*
165219820Sjeff* SEE ALSO
166219820Sjeff*	LID Manager object, osm_lid_mgr_init,
167219820Sjeff*	osm_lid_mgr_destroy
168219820Sjeff*********/
169219820Sjeff
170219820Sjeff/****f* OpenSM: LID Manager/osm_lid_mgr_destroy
171219820Sjeff* NAME
172219820Sjeff*	osm_lid_mgr_destroy
173219820Sjeff*
174219820Sjeff* DESCRIPTION
175219820Sjeff*	The osm_lid_mgr_destroy function destroys the object, releasing
176219820Sjeff*	all resources.
177219820Sjeff*
178219820Sjeff* SYNOPSIS
179219820Sjeff*/
180219820Sjeffvoid osm_lid_mgr_destroy(IN osm_lid_mgr_t * const p_mgr);
181219820Sjeff/*
182219820Sjeff* PARAMETERS
183219820Sjeff*	p_mgr
184219820Sjeff*		[in] Pointer to the object to destroy.
185219820Sjeff*
186219820Sjeff* RETURN VALUE
187219820Sjeff*	This function does not return a value.
188219820Sjeff*
189219820Sjeff* NOTES
190219820Sjeff*	Performs any necessary cleanup of the specified
191219820Sjeff*	LID Manager object.
192219820Sjeff*	Further operations should not be attempted on the destroyed object.
193219820Sjeff*	This function should only be called after a call to
194219820Sjeff*	osm_lid_mgr_construct or osm_lid_mgr_init.
195219820Sjeff*
196219820Sjeff* SEE ALSO
197219820Sjeff*	LID Manager object, osm_lid_mgr_construct,
198219820Sjeff*	osm_lid_mgr_init
199219820Sjeff*********/
200219820Sjeff
201219820Sjeff/****f* OpenSM: LID Manager/osm_lid_mgr_init
202219820Sjeff* NAME
203219820Sjeff*	osm_lid_mgr_init
204219820Sjeff*
205219820Sjeff* DESCRIPTION
206219820Sjeff*	The osm_lid_mgr_init function initializes a
207219820Sjeff*	LID Manager object for use.
208219820Sjeff*
209219820Sjeff* SYNOPSIS
210219820Sjeff*/
211219820Sjeffib_api_status_t
212219820Sjeffosm_lid_mgr_init(IN osm_lid_mgr_t * const p_mgr, IN struct osm_sm * sm);
213219820Sjeff/*
214219820Sjeff* PARAMETERS
215219820Sjeff*	p_mgr
216219820Sjeff*		[in] Pointer to an osm_lid_mgr_t object to initialize.
217219820Sjeff*
218219820Sjeff*	sm
219219820Sjeff*		[in] Pointer to the SM object for this subnet.
220219820Sjeff*
221219820Sjeff* RETURN VALUES
222219820Sjeff*	CL_SUCCESS if the LID Manager object was initialized
223219820Sjeff*	successfully.
224219820Sjeff*
225219820Sjeff* NOTES
226219820Sjeff*	Allows calling other LID Manager methods.
227219820Sjeff*
228219820Sjeff* SEE ALSO
229219820Sjeff*	LID Manager object, osm_lid_mgr_construct,
230219820Sjeff*	osm_lid_mgr_destroy
231219820Sjeff*********/
232219820Sjeff
233219820Sjeff/****f* OpenSM: LID Manager/osm_lid_mgr_process_sm
234219820Sjeff* NAME
235219820Sjeff*	osm_lid_mgr_process_sm
236219820Sjeff*
237219820Sjeff* DESCRIPTION
238219820Sjeff*	Configures the SM's port with its designated LID values.
239219820Sjeff*
240219820Sjeff* SYNOPSIS
241219820Sjeff*/
242219820Sjeffosm_signal_t osm_lid_mgr_process_sm(IN osm_lid_mgr_t * const p_mgr);
243219820Sjeff/*
244219820Sjeff* PARAMETERS
245219820Sjeff*	p_mgr
246219820Sjeff*		[in] Pointer to an osm_lid_mgr_t object.
247219820Sjeff*
248219820Sjeff* RETURN VALUES
249219820Sjeff*	Returns the appropriate signal to the caller:
250219820Sjeff*		OSM_SIGNAL_DONE - operation is complete
251219820Sjeff*		OSM_SIGNAL_DONE_PENDING - local operations are complete, but
252219820Sjeff*			transactions are still pending on the wire.
253219820Sjeff*
254219820Sjeff* NOTES
255219820Sjeff*
256219820Sjeff* SEE ALSO
257219820Sjeff*	LID Manager
258219820Sjeff*********/
259219820Sjeff
260219820Sjeff/****f* OpenSM: LID Manager/osm_lid_mgr_process_subnet
261219820Sjeff* NAME
262219820Sjeff*	osm_lid_mgr_process_subnet
263219820Sjeff*
264219820Sjeff* DESCRIPTION
265219820Sjeff*	Configures subnet ports (except the SM port itself) with their
266219820Sjeff*	designated LID values.
267219820Sjeff*
268219820Sjeff* SYNOPSIS
269219820Sjeff*/
270219820Sjeffosm_signal_t osm_lid_mgr_process_subnet(IN osm_lid_mgr_t * const p_mgr);
271219820Sjeff/*
272219820Sjeff* PARAMETERS
273219820Sjeff*	p_mgr
274219820Sjeff*		[in] Pointer to an osm_lid_mgr_t object.
275219820Sjeff*
276219820Sjeff* RETURN VALUES
277219820Sjeff*	Returns the appropriate signal to the caller:
278219820Sjeff*		OSM_SIGNAL_DONE - operation is complete
279219820Sjeff*		OSM_SIGNAL_DONE_PENDING - local operations are complete, but
280219820Sjeff*			transactions are still pending on the wire.
281219820Sjeff*
282219820Sjeff* NOTES
283219820Sjeff*
284219820Sjeff* SEE ALSO
285219820Sjeff*	LID Manager
286219820Sjeff*********/
287219820Sjeff
288219820SjeffEND_C_DECLS
289219820Sjeff#endif				/* _OSM_LID_MGR_H_ */
290