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 * Copyright (c) 2009 HNR Consulting. All rights reserved.
6 *
7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
12 *
13 * Redistribution and use in source and binary forms, with or
14 * without modification, are permitted provided that the following
15 * conditions are met:
16 *
17 * - Redistributions of source code must retain the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer.
20 *
21 * - Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE.
34 *
35 */
36
37 /*
38 * Abstract:
39 * Declaration of osm_mcast_tbl_t.
40 * This object represents a multicast forwarding table.
41 * This object is part of the OpenSM family of objects.
42 */
43
44 #ifndef _OSM_MCAST_TBL_H_
45 #define _OSM_MCAST_TBL_H_
46
47 #include <iba/ib_types.h>
48 #include <complib/cl_qmap.h>
49 #include <opensm/osm_base.h>
50
51 #ifdef __cplusplus
52 # define BEGIN_C_DECLS extern "C" {
53 # define END_C_DECLS }
54 #else /* !__cplusplus */
55 # define BEGIN_C_DECLS
56 # define END_C_DECLS
57 #endif /* __cplusplus */
58
59 BEGIN_C_DECLS
60 /****s* OpenSM: Forwarding Table/osm_mcast_tbl_t
61 * NAME
62 * osm_mcast_tbl_t
63 *
64 * DESCRIPTION
65 * Multicast Forwarding Table structure.
66 *
67 * Callers may directly access this object.
68 *
69 * SYNOPSIS
70 */
71 typedef struct osm_mcast_fwdbl {
72 uint8_t num_ports;
73 uint8_t max_position;
74 uint16_t max_block;
75 int16_t max_block_in_use;
76 uint16_t num_entries;
77 uint16_t max_mlid_ho;
78 uint16_t mft_depth;
79 uint16_t(*p_mask_tbl)[][IB_MCAST_POSITION_MAX + 1];
80 } osm_mcast_tbl_t;
81 /*
82 * FIELDS
83 * num_ports
84 * The number of ports in the port mask. This value
85 * is the same as the number of ports on the switch
86 *
87 * max_position
88 * Maximum bit mask position for this table. This value
89 * is computed from the number of ports on the switch.
90 *
91 * max_block
92 * Maximum block number supported in the table. This value
93 * is approximately the number of MLID entries divided by the
94 * number of MLIDs per block
95 *
96 * num_entries
97 * Number of entries in the table (aka number of MLIDs supported).
98 *
99 * max_mlid_ho
100 * Maximum MLID (host order) for the currently allocated multicast
101 * port mask table.
102 *
103 * mft_depth
104 * Number of MLIDs in the currently allocated multicast port mask
105 * table.
106 *
107 * p_mask_tbl
108 * Pointer to a two dimensional array of port_masks for this switch.
109 * The first dimension is MLID offset, second dimension is mask position.
110 * This pointer is null for switches that do not support multicast.
111 *
112 * SEE ALSO
113 *********/
114
115 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_init
116 * NAME
117 * osm_mcast_tbl_init
118 *
119 * DESCRIPTION
120 * This function initializes a Multicast Forwarding Table object.
121 *
122 * SYNOPSIS
123 */
124 void osm_mcast_tbl_init(IN osm_mcast_tbl_t * p_tbl, IN uint8_t num_ports,
125 IN uint16_t capacity);
126 /*
127 * PARAMETERS
128 * num_ports
129 * [in] Number of ports in the switch owning this table.
130 *
131 * capacity
132 * [in] The number of MLID entries (starting at 0xC000) supported
133 * by this switch.
134 *
135 * RETURN VALUE
136 * None.
137 *
138 * NOTES
139 *
140 * SEE ALSO
141 *********/
142
143 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_delete
144 * NAME
145 * osm_mcast_tbl_delete
146 *
147 * DESCRIPTION
148 * This destroys and deallocates a Multicast Forwarding Table object.
149 *
150 * SYNOPSIS
151 */
152 void osm_mcast_tbl_delete(IN osm_mcast_tbl_t ** pp_tbl);
153 /*
154 * PARAMETERS
155 * pp_tbl
156 * [in] Pointer a Pointer to the Multicast Forwarding Table object.
157 *
158 * RETURN VALUE
159 * On success, returns a pointer to a new Multicast Forwarding Table object
160 * of the specified size.
161 * NULL otherwise.
162 *
163 * NOTES
164 *
165 * SEE ALSO
166 *********/
167
168 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_realloc
169 * NAME
170 * osm_mcast_tbl_realloc
171 *
172 * DESCRIPTION
173 * This function reallocates the multicast port mask table if necessary.
174 *
175 * SYNOPSIS
176 */
177 int osm_mcast_tbl_realloc(IN osm_mcast_tbl_t * p_tbl, IN unsigned mlid_offset);
178 /*
179 * PARAMETERS
180 *
181 * p_tbl
182 * [in] Pointer to the Multicast Forwarding Table object.
183 *
184 * mlid_offset
185 * [in] Offset of MLID being accessed.
186 *
187 * RETURN VALUE
188 * Returns 0 on success and non-zero value otherwise.
189 *
190 * NOTES
191 *
192 * SEE ALSO
193 */
194
195 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_destroy
196 * NAME
197 * osm_mcast_tbl_destroy
198 *
199 * DESCRIPTION
200 * This destroys and deallocates a Multicast Forwarding Table object.
201 *
202 * SYNOPSIS
203 */
204 void osm_mcast_tbl_destroy(IN osm_mcast_tbl_t * p_tbl);
205 /*
206 * PARAMETERS
207 * p_tbl
208 * [in] Pointer to the Multicast Forwarding Table object.
209 *
210 * RETURN VALUE
211 * None
212 *
213 * NOTES
214 *
215 * SEE ALSO
216 *********/
217
218 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_set
219 * NAME
220 * osm_mcast_tbl_set
221 *
222 * DESCRIPTION
223 * Adds the port to the multicast group.
224 *
225 * SYNOPSIS
226 */
227 void osm_mcast_tbl_set(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho,
228 IN uint8_t port_num);
229 /*
230 * PARAMETERS
231 * p_tbl
232 * [in] Pointer to the Multicast Forwarding Table object.
233 *
234 * mlid_ho
235 * [in] MLID value (host order) for which to set the route.
236 *
237 * port_num
238 * [in] Port to add to the multicast group.
239 *
240 * RETURN VALUE
241 * None.
242 *
243 * NOTES
244 *
245 * SEE ALSO
246 *********/
247
248 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_clear_mlid
249 * NAME
250 * osm_mcast_tbl_clear_mlid
251 *
252 * DESCRIPTION
253 * Removes all multicast paths for the specified MLID.
254 *
255 * SYNOPSIS
256 */
257 void osm_mcast_tbl_clear_mlid(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho);
258 /*
259 * PARAMETERS
260 * p_tbl
261 * [in] Pointer to the Multicast Forwarding Table object.
262 *
263 * mlid_ho
264 * [in] MLID value (host order) for which to clear.
265 *
266 * RETURN VALUE
267 * None.
268 *
269 * NOTES
270 *
271 * SEE ALSO
272 *********/
273
274 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_is_port
275 * NAME
276 * osm_mcast_tbl_is_port
277 *
278 * DESCRIPTION
279 * Returns TRUE if the port is in the multicast group.
280 *
281 * SYNOPSIS
282 */
283 boolean_t osm_mcast_tbl_is_port(IN const osm_mcast_tbl_t * p_tbl,
284 IN uint16_t mlid_ho, IN uint8_t port_num);
285 /*
286 * PARAMETERS
287 * p_tbl
288 * [in] Pointer to the Multicast Forwarding Table object.
289 *
290 * mlid_ho
291 * [in] MLID value (host order).
292 *
293 * port_num
294 * [in] Port number on the switch
295 *
296 * RETURN VALUE
297 * Returns the port that routes the specified LID.
298 *
299 * NOTES
300 *
301 * SEE ALSO
302 *********/
303
304 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_is_any_port
305 * NAME
306 * osm_mcast_tbl_is_any_port
307 *
308 * DESCRIPTION
309 * Returns TRUE if any port is in the multicast group.
310 *
311 * SYNOPSIS
312 */
313 boolean_t osm_mcast_tbl_is_any_port(IN const osm_mcast_tbl_t * p_tbl,
314 IN uint16_t mlid_ho);
315 /*
316 * PARAMETERS
317 * p_tbl
318 * [in] Pointer to the Multicast Forwarding Table object.
319 *
320 * mlid_ho
321 * [in] MLID value (host order).
322 *
323 * RETURN VALUE
324 * Returns TRUE if any port is in the multicast group.
325 *
326 * NOTES
327 *
328 * SEE ALSO
329 *********/
330
331 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_set_block
332 * NAME
333 * osm_mcast_tbl_set_block
334 *
335 * DESCRIPTION
336 * Copies the specified block into the Multicast Forwarding Table.
337 *
338 * SYNOPSIS
339 */
340 ib_api_status_t osm_mcast_tbl_set_block(IN osm_mcast_tbl_t * p_tbl,
341 IN const ib_net16_t * p_block,
342 IN int16_t block_num,
343 IN uint8_t position);
344 /*
345 * PARAMETERS
346 * p_tbl
347 * [in] Pointer to the Multicast Forwarding Table object.
348 *
349 * p_block
350 * [in] Pointer to the Forwarding Table block.
351 *
352 * block_num
353 * [in] Block number of this block.
354 *
355 * RETURN VALUE
356 * None.
357 *
358 * NOTES
359 *
360 * SEE ALSO
361 *********/
362
363 /****f* OpenSM: Forwarding Table/osm_mcast_get_tbl_block
364 * NAME
365 * osm_mcast_get_tbl_block
366 *
367 * DESCRIPTION
368 * Retrieve a multicast forwarding table block.
369 *
370 * SYNOPSIS
371 */
372 boolean_t osm_mcast_tbl_get_block(IN osm_mcast_tbl_t * p_tbl,
373 IN int16_t block_num, IN uint8_t position,
374 OUT ib_net16_t * p_block);
375 /*
376 * PARAMETERS
377 * p_tbl
378 * [in] Pointer to an osm_mcast_tbl_t object.
379 *
380 * p_block
381 * [in] Pointer to the Forwarding Table block.
382 *
383 * block_num
384 * [in] Block number of this block.
385 *
386 * p_block
387 * [out] Pointer to the 32 entry array to store the
388 * forwarding table clock specified by block_id.
389 *
390 * RETURN VALUES
391 * Returns true if there are more blocks necessary to
392 * configure all the MLIDs reachable from this switch.
393 * FALSE otherwise.
394 *
395 * NOTES
396 *
397 * SEE ALSO
398 *********/
399
400 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_block
401 * NAME
402 * osm_mcast_tbl_get_max_block
403 *
404 * DESCRIPTION
405 * Returns the maximum block ID in this table.
406 *
407 * SYNOPSIS
408 */
osm_mcast_tbl_get_max_block(IN osm_mcast_tbl_t * p_tbl)409 static inline uint16_t osm_mcast_tbl_get_max_block(IN osm_mcast_tbl_t * p_tbl)
410 {
411 return p_tbl->max_block;
412 }
413
414 /*
415 * PARAMETERS
416 * p_tbl
417 * [in] Pointer to an osm_mcast_tbl_t object.
418 *
419 * RETURN VALUES
420 * Returns the maximum block ID in this table.
421 *
422 * NOTES
423 *
424 * SEE ALSO
425 *********/
426
427 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_block_in_use
428 * NAME
429 * osm_mcast_tbl_get_max_block_in_use
430 *
431 * DESCRIPTION
432 * Returns the maximum block ID in use in this table.
433 * A value of -1 indicates no blocks are in use.
434 *
435 * SYNOPSIS
436 */
437 static inline int16_t
osm_mcast_tbl_get_max_block_in_use(IN osm_mcast_tbl_t * p_tbl)438 osm_mcast_tbl_get_max_block_in_use(IN osm_mcast_tbl_t * p_tbl)
439 {
440 return (p_tbl->max_block_in_use);
441 }
442
443 /*
444 * PARAMETERS
445 * p_tbl
446 * [in] Pointer to an osm_mcast_tbl_t object.
447 *
448 * RETURN VALUES
449 * Returns the maximum block ID in use in this table.
450 * A value of -1 indicates no blocks are in use.
451 *
452 * NOTES
453 *
454 * SEE ALSO
455 *********/
456
457 /****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_position
458 * NAME
459 * osm_mcast_tbl_get_max_position
460 *
461 * DESCRIPTION
462 * Returns the maximum position in this table.
463 *
464 * SYNOPSIS
465 */
466 static inline uint8_t
osm_mcast_tbl_get_max_position(IN osm_mcast_tbl_t * p_tbl)467 osm_mcast_tbl_get_max_position(IN osm_mcast_tbl_t * p_tbl)
468 {
469 return (p_tbl->max_position);
470 }
471
472 /*
473 * PARAMETERS
474 * p_tbl
475 * [in] Pointer to an osm_mcast_tbl_t object.
476 *
477 * RETURN VALUES
478 * Returns the maximum position in this table.
479 *
480 * NOTES
481 *
482 * SEE ALSO
483 *********/
484
485 END_C_DECLS
486 #endif /* _OSM_MCAST_TBL_H_ */
487