xref: /freebsd/contrib/ofed/opensm/include/opensm/osm_router.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /*
2  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
3  * Copyright (c) 2002-2005,2008 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_router_t.
39  *	This object represents an IBA router.
40  *	This object is part of the OpenSM family of objects.
41  */
42 
43 #ifndef _OSM_ROUTER_H_
44 #define _OSM_ROUTER_H_
45 
46 #include <iba/ib_types.h>
47 #include <opensm/osm_base.h>
48 #include <opensm/osm_madw.h>
49 #include <opensm/osm_node.h>
50 #include <opensm/osm_port.h>
51 #include <opensm/osm_mcast_tbl.h>
52 #include <opensm/osm_port_profile.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 
62 BEGIN_C_DECLS
63 /****h* OpenSM/Router
64 * NAME
65 *	Router
66 *
67 * DESCRIPTION
68 *	The Router object encapsulates the information needed by the
69 *	OpenSM to manage routers.  The OpenSM allocates one router object
70 *	per router in the IBA subnet.
71 *
72 *	The Router object is not thread safe, thus callers must provide
73 *	serialization.
74 *
75 *	This object should be treated as opaque and should be
76 *	manipulated only through the provided functions.
77 *
78 * AUTHOR
79 *	Hal Rosenstock, Voltaire
80 *
81 *********/
82 /****s* OpenSM: Router/osm_router_t
83 * NAME
84 *	osm_router_t
85 *
86 * DESCRIPTION
87 *	Router structure.
88 *
89 *	This object should be treated as opaque and should
90 *	be manipulated only through the provided functions.
91 *
92 * SYNOPSIS
93 */
94 typedef struct osm_router {
95 	cl_map_item_t map_item;
96 	osm_port_t *p_port;
97 } osm_router_t;
98 /*
99 * FIELDS
100 *	map_item
101 *		Linkage structure for cl_qmap.  MUST BE FIRST MEMBER!
102 *
103 *	p_port
104 *		Pointer to the Port object for this router.
105 *
106 * SEE ALSO
107 *	Router object
108 *********/
109 
110 /****f* OpenSM: Router/osm_router_delete
111 * NAME
112 *	osm_router_delete
113 *
114 * DESCRIPTION
115 *	Destroys and deallocates the object.
116 *
117 * SYNOPSIS
118 */
119 void osm_router_delete(IN OUT osm_router_t ** pp_rtr);
120 /*
121 * PARAMETERS
122 *	p_rtr
123 *		[in] Pointer to the object to destroy.
124 *
125 * RETURN VALUE
126 *	None.
127 *
128 * NOTES
129 *
130 * SEE ALSO
131 *	Router object, osm_router_new
132 *********/
133 
134 /****f* OpenSM: Router/osm_router_new
135 * NAME
136 *	osm_router_new
137 *
138 * DESCRIPTION
139 *	The osm_router_new function initializes a Router object for use.
140 *
141 * SYNOPSIS
142 */
143 osm_router_t *osm_router_new(IN osm_port_t * p_port);
144 /*
145 * PARAMETERS
146 *	p_node
147 *		[in] Pointer to the node object of this router
148 *
149 * RETURN VALUES
150 *	Pointer to the new initialized router object.
151 *
152 * NOTES
153 *
154 * SEE ALSO
155 *	Router object, osm_router_new
156 *********/
157 
158 /****f* OpenSM: Router/osm_router_get_port_ptr
159 * NAME
160 *	osm_router_get_port_ptr
161 *
162 * DESCRIPTION
163 *	Returns a pointer to the Port object for this router.
164 *
165 * SYNOPSIS
166 */
167 static inline osm_port_t *osm_router_get_port_ptr(IN const osm_router_t * p_rtr)
168 {
169 	return p_rtr->p_port;
170 }
171 
172 /*
173 * PARAMETERS
174 *	p_rtr
175 *		[in] Pointer to an osm_router_t object.
176 *
177 * RETURN VALUES
178 *	Returns a pointer to the Port object for this router.
179 *
180 * NOTES
181 *
182 * SEE ALSO
183 *	Router object
184 *********/
185 
186 /****f* OpenSM: Router/osm_router_get_node_ptr
187 * NAME
188 *	osm_router_get_node_ptr
189 *
190 * DESCRIPTION
191 *	Returns a pointer to the Node object for this router.
192 *
193 * SYNOPSIS
194 */
195 static inline osm_node_t *osm_router_get_node_ptr(IN const osm_router_t * p_rtr)
196 {
197 	return p_rtr->p_port->p_node;
198 }
199 
200 /*
201 * PARAMETERS
202 *	p_rtr
203 *		[in] Pointer to an osm_router_t object.
204 *
205 * RETURN VALUES
206 *	Returns a pointer to the Node object for this router.
207 *
208 * NOTES
209 *
210 * SEE ALSO
211 *	Router object
212 *********/
213 
214 END_C_DECLS
215 #endif				/* _OSM_ROUTER_H_ */
216