1/*
2 * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2009 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5 *
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:
11 *
12 *     Redistribution and use in source and binary forms, with or
13 *     without modification, are permitted provided that the following
14 *     conditions are met:
15 *
16 *      - Redistributions of source code must retain the above
17 *        copyright notice, this list of conditions and the following
18 *        disclaimer.
19 *
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.
24 *
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
32 * SOFTWARE.
33 *
34 */
35
36/*
37 * Abstract:
38 * 	Declaration of osm_ucast_mgr_t.
39 *	This object represents the Unicast Manager object.
40 *	This object is part of the OpenSM family of objects.
41 */
42
43#ifndef _OSM_UCAST_MGR_H_
44#define _OSM_UCAST_MGR_H_
45
46#include <complib/cl_passivelock.h>
47#include <complib/cl_qlist.h>
48#include <opensm/osm_madw.h>
49#include <opensm/osm_subnet.h>
50#include <opensm/osm_switch.h>
51#include <opensm/osm_log.h>
52#include <opensm/osm_ucast_cache.h>
53
54#ifdef __cplusplus
55#  define BEGIN_C_DECLS extern "C" {
56#  define END_C_DECLS   }
57#else				/* !__cplusplus */
58#  define BEGIN_C_DECLS
59#  define END_C_DECLS
60#endif				/* __cplusplus */
61
62BEGIN_C_DECLS
63/****h* OpenSM/Unicast Manager
64* NAME
65*	Unicast Manager
66*
67* DESCRIPTION
68*	The Unicast Manager object encapsulates the information
69*	needed to control unicast LID forwarding on the subnet.
70*
71*	The Unicast Manager object is thread safe.
72*
73*	This object should be treated as opaque and should be
74*	manipulated only through the provided functions.
75*
76* AUTHOR
77*	Steve King, Intel
78*
79*********/
80struct osm_sm;
81/****s* OpenSM: Unicast Manager/osm_ucast_mgr_t
82* NAME
83*	osm_ucast_mgr_t
84*
85* DESCRIPTION
86*	Unicast Manager structure.
87*
88*	This object should be treated as opaque and should
89*	be manipulated only through the provided functions.
90*
91* SYNOPSIS
92*/
93typedef struct osm_ucast_mgr {
94	struct osm_sm *sm;
95	osm_subn_t *p_subn;
96	osm_log_t *p_log;
97	cl_plock_t *p_lock;
98	uint16_t max_lid;
99	cl_qlist_t port_order_list;
100	boolean_t is_dor;
101	boolean_t some_hop_count_set;
102	cl_qmap_t cache_sw_tbl;
103	boolean_t cache_valid;
104} osm_ucast_mgr_t;
105/*
106* FIELDS
107*	sm
108*		Pointer to the SM object.
109*
110*	p_subn
111*		Pointer to the Subnet object for this subnet.
112*
113*	p_log
114*		Pointer to the log object.
115*
116*	p_lock
117*		Pointer to the serializing lock.
118*
119*	is_dor
120*		Dimension Order Routing (DOR) will be done
121*
122*	port_order_list
123*		List of ports ordered for routing.
124*
125*	some_hop_count_set
126*		Initialized to FALSE at the beginning of each the min hop
127*		tables calculation iteration cycle, set to TRUE to indicate
128*		that some hop count changes were done.
129*
130*	cache_sw_tbl
131*		Cached switches table.
132*
133*	cache_valid
134*		TRUE if the unicast cache is valid.
135*
136* SEE ALSO
137*	Unicast Manager object
138*********/
139
140/****f* OpenSM: Unicast Manager/osm_ucast_mgr_construct
141* NAME
142*	osm_ucast_mgr_construct
143*
144* DESCRIPTION
145*	This function constructs a Unicast Manager object.
146*
147* SYNOPSIS
148*/
149void osm_ucast_mgr_construct(IN osm_ucast_mgr_t * p_mgr);
150/*
151* PARAMETERS
152*	p_mgr
153*		[in] Pointer to a Unicast Manager object to construct.
154*
155* RETURN VALUE
156*	This function does not return a value.
157*
158* NOTES
159*	Allows osm_ucast_mgr_destroy
160*
161*	Calling osm_ucast_mgr_construct is a prerequisite to calling any other
162*	method except osm_ucast_mgr_init.
163*
164* SEE ALSO
165*	Unicast Manager object, osm_ucast_mgr_init,
166*	osm_ucast_mgr_destroy
167*********/
168
169/****f* OpenSM: Unicast Manager/osm_ucast_mgr_destroy
170* NAME
171*	osm_ucast_mgr_destroy
172*
173* DESCRIPTION
174*	The osm_ucast_mgr_destroy function destroys the object, releasing
175*	all resources.
176*
177* SYNOPSIS
178*/
179void osm_ucast_mgr_destroy(IN osm_ucast_mgr_t * p_mgr);
180/*
181* PARAMETERS
182*	p_mgr
183*		[in] Pointer to the object to destroy.
184*
185* RETURN VALUE
186*	This function does not return a value.
187*
188* NOTES
189*	Performs any necessary cleanup of the specified
190*	Unicast Manager object.
191*	Further operations should not be attempted on the destroyed object.
192*	This function should only be called after a call to
193*	osm_ucast_mgr_construct or osm_ucast_mgr_init.
194*
195* SEE ALSO
196*	Unicast Manager object, osm_ucast_mgr_construct,
197*	osm_ucast_mgr_init
198*********/
199
200/****f* OpenSM: Unicast Manager/osm_ucast_mgr_init
201* NAME
202*	osm_ucast_mgr_init
203*
204* DESCRIPTION
205*	The osm_ucast_mgr_init function initializes a
206*	Unicast Manager object for use.
207*
208* SYNOPSIS
209*/
210ib_api_status_t osm_ucast_mgr_init(IN osm_ucast_mgr_t * p_mgr,
211				   IN struct osm_sm * sm);
212/*
213* PARAMETERS
214*	p_mgr
215*		[in] Pointer to an osm_ucast_mgr_t object to initialize.
216*
217*	sm
218*		[in] Pointer to the SM object.
219*
220* RETURN VALUES
221*	IB_SUCCESS if the Unicast Manager object was initialized
222*	successfully.
223*
224* NOTES
225*	Allows calling other Unicast Manager methods.
226*
227* SEE ALSO
228*	Unicast Manager object, osm_ucast_mgr_construct,
229*	osm_ucast_mgr_destroy
230*********/
231
232/****f* OpenSM: Unicast Manager/osm_ucast_mgr_set_fwd_tables
233* NAME
234*	osm_ucast_mgr_set_fwd_tables
235*
236* DESCRIPTION
237*	Setup forwarding table for the switch (from prepared new_lft).
238*
239* SYNOPSIS
240*/
241void osm_ucast_mgr_set_fwd_tables(IN osm_ucast_mgr_t * p_mgr);
242/*
243* PARAMETERS
244*	p_mgr
245*		[in] Pointer to an osm_ucast_mgr_t object.
246*
247* SEE ALSO
248*	Unicast Manager
249*********/
250
251/****f* OpenSM: Unicast Manager/osm_ucast_mgr_build_lid_matrices
252* NAME
253*	osm_ucast_mgr_build_lid_matrices
254*
255* DESCRIPTION
256*	Build switches's lid matrices.
257*
258* SYNOPSIS
259*/
260int osm_ucast_mgr_build_lid_matrices(IN osm_ucast_mgr_t * p_mgr);
261/*
262* PARAMETERS
263*	p_mgr
264*		[in] Pointer to an osm_ucast_mgr_t object.
265*
266* NOTES
267*	This function processes the subnet, configuring switches'
268*	min hops tables (aka lid matrices).
269*
270* SEE ALSO
271*	Unicast Manager
272*********/
273
274/****f* OpenSM: Unicast Manager/osm_ucast_mgr_process
275* NAME
276*	osm_ucast_mgr_process
277*
278* DESCRIPTION
279*	Process and configure the subnet's unicast forwarding tables.
280*
281* SYNOPSIS
282*/
283int osm_ucast_mgr_process(IN osm_ucast_mgr_t * p_mgr);
284/*
285* PARAMETERS
286*	p_mgr
287*		[in] Pointer to an osm_ucast_mgr_t object.
288*
289* RETURN VALUES
290*	Returns zero on success and negative value on failure.
291*
292* NOTES
293*	This function processes the subnet, configuring switch
294*	unicast forwarding tables.
295*
296* SEE ALSO
297*	Unicast Manager, Node Info Response Controller
298*********/
299
300int ucast_dummy_build_lid_matrices(void *context);
301END_C_DECLS
302#endif				/* _OSM_UCAST_MGR_H_ */
303