1152615Sle/*
2152615Sle * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
3152615Sle * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4152615Sle * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5152615Sle *
6152615Sle * This software is available to you under a choice of one of two
7152615Sle * licenses.  You may choose to be licensed under the terms of the GNU
8152634Sle * General Public License (GPL) Version 2, available from the file
9152615Sle * COPYING in the main directory of this source tree, or the
10152615Sle * OpenIB.org BSD license below:
11152615Sle *
12152615Sle *     Redistribution and use in source and binary forms, with or
13152615Sle *     without modification, are permitted provided that the following
14152615Sle *     conditions are met:
15152615Sle *
16152615Sle *      - Redistributions of source code must retain the above
17152634Sle *        copyright notice, this list of conditions and the following
18152615Sle *        disclaimer.
19152615Sle *
20152615Sle *      - Redistributions in binary form must reproduce the above
21152615Sle *        copyright notice, this list of conditions and the following
22152615Sle *        disclaimer in the documentation and/or other materials
23152615Sle *        provided with the distribution.
24152615Sle *
25152615Sle * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26152615Sle * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27152615Sle * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28152615Sle * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29152615Sle * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30152615Sle * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31152615Sle * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32152615Sle * SOFTWARE.
33152615Sle *
34152615Sle */
35152615Sle
36152615Sle/*
37152615Sle * Abstract:
38152615Sle * 	Declaration of osm_lid_mgr_t.
39152615Sle *	This object represents the LID Manager object.
40152615Sle *	This object is part of the OpenSM family of objects.
41152615Sle */
42152615Sle
43152615Sle#ifndef _OSM_LID_MGR_H_
44152615Sle#define _OSM_LID_MGR_H_
45152615Sle
46152615Sle#include <complib/cl_passivelock.h>
47152615Sle#include <opensm/osm_base.h>
48152615Sle#include <opensm/osm_madw.h>
49152615Sle#include <opensm/osm_subnet.h>
50152615Sle#include <opensm/osm_db.h>
51190507Slulf#include <opensm/osm_log.h>
52190507Slulf
53152615Sle#ifdef __cplusplus
54152615Sle#  define BEGIN_C_DECLS extern "C" {
55152615Sle#  define END_C_DECLS   }
56152615Sle#else				/* !__cplusplus */
57185309Slulf#  define BEGIN_C_DECLS
58185309Slulf#  define END_C_DECLS
59185309Slulf#endif				/* __cplusplus */
60185309Slulf
61152615SleBEGIN_C_DECLS
62152615Sle#define OSM_LID_MGR_LIST_SIZE_MIN 256
63152615Sle/****h* OpenSM/LID Manager
64152615Sle* NAME
65152615Sle*	LID Manager
66152615Sle*
67152615Sle* DESCRIPTION
68152615Sle*	The LID Manager object encapsulates the information
69152615Sle*	needed to control LID assignments on the subnet.
70152615Sle*
71152615Sle*	The LID Manager object is thread safe.
72152615Sle*
73152615Sle*	This object should be treated as opaque and should be
74152615Sle*	manipulated only through the provided functions.
75152615Sle*
76152615Sle* AUTHOR
77152615Sle*	Steve King, Intel
78152615Sle*
79152615Sle*********/
80152615Slestruct osm_sm;
81152615Sle/****s* OpenSM: LID Manager/osm_lid_mgr_t
82190507Slulf* NAME
83190507Slulf*	osm_lid_mgr_t
84190507Slulf*
85152615Sle* DESCRIPTION
86152615Sle*	LID Manager structure.
87152615Sle*
88152615Sle*	This object should be treated as opaque and should
89152615Sle*	be manipulated only through the provided functions.
90152615Sle*
91152615Sle* SYNOPSIS
92190507Slulf*/
93190507Slulftypedef struct osm_lid_mgr {
94190507Slulf	struct osm_sm *sm;
95152615Sle	osm_subn_t *p_subn;
96152615Sle	osm_db_t *p_db;
97152615Sle	osm_log_t *p_log;
98152615Sle	cl_plock_t *p_lock;
99152615Sle	boolean_t send_set_reqs;
100152615Sle	osm_db_domain_t *p_g2l;
101152615Sle	cl_ptr_vector_t used_lids;
102190507Slulf	cl_qlist_t free_ranges;
103190507Slulf} osm_lid_mgr_t;
104190507Slulf/*
105152615Sle* FIELDS
106152615Sle*	sm
107152615Sle*		Pointer to the SM object.
108152615Sle*
109152615Sle*	p_subn
110152615Sle*		Pointer to the Subnet object for this subnet.
111152615Sle*
112190507Slulf*	p_db
113190507Slulf*		Pointer to the database (persistency) object
114190507Slulf*
115152615Sle*	p_log
116152615Sle*		Pointer to the log object.
117152615Sle*
118152615Sle*	p_lock
119152615Sle*		Pointer to the serializing lock.
120152615Sle*
121152615Sle*	send_set_reqs
122190507Slulf*		Boolean to indicate whether any set requests sent.
123190507Slulf*
124190507Slulf*	p_g2l
125152615Sle*		Pointer to the database domain storing guid to lid mapping.
126152615Sle*
127152615Sle*	used_lids
128152615Sle*		A vector the maps from the lid to its guid. keeps track of
129152615Sle*		existing and non existing mapping of guid->lid
130190507Slulf*
131190507Slulf*	free_ranges
132190507Slulf*		A list of available free lid ranges. The list is initialized
133152615Sle*		by the code that initializes the lid assignment and is consumed
134152615Sle*		by the procedure that finds a free range. It holds elements of
135190507Slulf*		type osm_lid_mgr_range_t
136190507Slulf*
137190507Slulf* SEE ALSO
138152615Sle*	LID Manager object
139152615Sle*********/
140190507Slulf
141152615Sle/****f* OpenSM: LID Manager/osm_lid_mgr_construct
142152615Sle* NAME
143152615Sle*	osm_lid_mgr_construct
144152615Sle*
145190507Slulf* DESCRIPTION
146190507Slulf*	This function constructs a LID Manager object.
147152615Sle*
148190507Slulf* SYNOPSIS
149152615Sle*/
150190507Slulfvoid osm_lid_mgr_construct(IN osm_lid_mgr_t * const p_mgr);
151152615Sle/*
152152615Sle* PARAMETERS
153152615Sle*	p_mgr
154152615Sle*		[in] Pointer to a LID Manager object to construct.
155190507Slulf*
156190507Slulf* RETURN VALUE
157190507Slulf*	This function does not return a value.
158152615Sle*
159152615Sle* NOTES
160152633Sle*	Allows osm_lid_mgr_destroy
161152633Sle*
162190507Slulf*	Calling osm_lid_mgr_construct is a prerequisite to calling any other
163152633Sle*	method except osm_lid_mgr_init.
164190507Slulf*
165190507Slulf* SEE ALSO
166190507Slulf*	LID Manager object, osm_lid_mgr_init,
167152633Sle*	osm_lid_mgr_destroy
168190507Slulf*********/
169152633Sle
170152615Sle/****f* OpenSM: LID Manager/osm_lid_mgr_destroy
171190507Slulf* NAME
172152615Sle*	osm_lid_mgr_destroy
173152615Sle*
174152615Sle* DESCRIPTION
175190507Slulf*	The osm_lid_mgr_destroy function destroys the object, releasing
176213318Slulf*	all resources.
177152633Sle*
178190507Slulf* SYNOPSIS
179190507Slulf*/
180152633Slevoid osm_lid_mgr_destroy(IN osm_lid_mgr_t * const p_mgr);
181190507Slulf/*
182190507Slulf* PARAMETERS
183190507Slulf*	p_mgr
184190507Slulf*		[in] Pointer to the object to destroy.
185190507Slulf*
186190507Slulf* RETURN VALUE
187152615Sle*	This function does not return a value.
188190507Slulf*
189152615Sle* NOTES
190152615Sle*	Performs any necessary cleanup of the specified
191190507Slulf*	LID Manager object.
192152615Sle*	Further operations should not be attempted on the destroyed object.
193152615Sle*	This function should only be called after a call to
194152615Sle*	osm_lid_mgr_construct or osm_lid_mgr_init.
195152615Sle*
196152615Sle* SEE ALSO
197152615Sle*	LID Manager object, osm_lid_mgr_construct,
198152615Sle*	osm_lid_mgr_init
199190507Slulf*********/
200190507Slulf
201152615Sle/****f* OpenSM: LID Manager/osm_lid_mgr_init
202190507Slulf* NAME
203152615Sle*	osm_lid_mgr_init
204152615Sle*
205152615Sle* DESCRIPTION
206190507Slulf*	The osm_lid_mgr_init function initializes a
207190507Slulf*	LID Manager object for use.
208190507Slulf*
209152615Sle* SYNOPSIS
210152615Sle*/
211190507Slulfib_api_status_t
212190507Slulfosm_lid_mgr_init(IN osm_lid_mgr_t * const p_mgr, IN struct osm_sm * sm);
213190507Slulf/*
214190507Slulf* PARAMETERS
215152633Sle*	p_mgr
216190507Slulf*		[in] Pointer to an osm_lid_mgr_t object to initialize.
217152633Sle*
218190507Slulf*	sm
219190507Slulf*		[in] Pointer to the SM object for this subnet.
220152615Sle*
221152615Sle* RETURN VALUES
222190507Slulf*	CL_SUCCESS if the LID Manager object was initialized
223190507Slulf*	successfully.
224190507Slulf*
225152615Sle* NOTES
226190507Slulf*	Allows calling other LID Manager methods.
227152615Sle*
228190507Slulf* SEE ALSO
229152615Sle*	LID Manager object, osm_lid_mgr_construct,
230152615Sle*	osm_lid_mgr_destroy
231152615Sle*********/
232190507Slulf
233190507Slulf/****f* OpenSM: LID Manager/osm_lid_mgr_process_sm
234152615Sle* NAME
235190507Slulf*	osm_lid_mgr_process_sm
236190507Slulf*
237190507Slulf* DESCRIPTION
238152615Sle*	Configures the SM's port with its designated LID values.
239152615Sle*
240152615Sle* SYNOPSIS
241190507Slulf*/
242152615Sleosm_signal_t osm_lid_mgr_process_sm(IN osm_lid_mgr_t * const p_mgr);
243152615Sle/*
244152615Sle* PARAMETERS
245190507Slulf*	p_mgr
246213318Slulf*		[in] Pointer to an osm_lid_mgr_t object.
247152633Sle*
248190507Slulf* RETURN VALUES
249190507Slulf*	Returns the appropriate signal to the caller:
250152633Sle*		OSM_SIGNAL_DONE - operation is complete
251190507Slulf*		OSM_SIGNAL_DONE_PENDING - local operations are complete, but
252190507Slulf*			transactions are still pending on the wire.
253190507Slulf*
254190507Slulf* NOTES
255152615Sle*
256152633Sle* SEE ALSO
257152615Sle*	LID Manager
258152615Sle*********/
259152634Sle
260152615Sle/****f* OpenSM: LID Manager/osm_lid_mgr_process_subnet
261152615Sle* NAME
262*	osm_lid_mgr_process_subnet
263*
264* DESCRIPTION
265*	Configures subnet ports (except the SM port itself) with their
266*	designated LID values.
267*
268* SYNOPSIS
269*/
270osm_signal_t osm_lid_mgr_process_subnet(IN osm_lid_mgr_t * const p_mgr);
271/*
272* PARAMETERS
273*	p_mgr
274*		[in] Pointer to an osm_lid_mgr_t object.
275*
276* RETURN VALUES
277*	Returns the appropriate signal to the caller:
278*		OSM_SIGNAL_DONE - operation is complete
279*		OSM_SIGNAL_DONE_PENDING - local operations are complete, but
280*			transactions are still pending on the wire.
281*
282* NOTES
283*
284* SEE ALSO
285*	LID Manager
286*********/
287
288END_C_DECLS
289#endif				/* _OSM_LID_MGR_H_ */
290