1 /*
2 * Copyright (c) 2004-2007 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.
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 ** const 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 * const 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 */
osm_router_get_port_ptr(IN const osm_router_t * const p_rtr)167 static inline osm_port_t *osm_router_get_port_ptr(IN const osm_router_t *
168 const p_rtr)
169 {
170 return (p_rtr->p_port);
171 }
172
173 /*
174 * PARAMETERS
175 * p_rtr
176 * [in] Pointer to an osm_router_t object.
177 *
178 * RETURN VALUES
179 * Returns a pointer to the Port object for this router.
180 *
181 * NOTES
182 *
183 * SEE ALSO
184 * Router object
185 *********/
186
187 /****f* OpenSM: Router/osm_router_get_node_ptr
188 * NAME
189 * osm_router_get_node_ptr
190 *
191 * DESCRIPTION
192 * Returns a pointer to the Node object for this router.
193 *
194 * SYNOPSIS
195 */
osm_router_get_node_ptr(IN const osm_router_t * const p_rtr)196 static inline osm_node_t *osm_router_get_node_ptr(IN const osm_router_t *
197 const p_rtr)
198 {
199 return (p_rtr->p_port->p_node);
200 }
201
202 /*
203 * PARAMETERS
204 * p_rtr
205 * [in] Pointer to an osm_router_t object.
206 *
207 * RETURN VALUES
208 * Returns a pointer to the Node object for this router.
209 *
210 * NOTES
211 *
212 * SEE ALSO
213 * Router object
214 *********/
215
216 END_C_DECLS
217 #endif /* _OSM_ROUTER_H_ */
218