2 * Copyright (c) 2004-2006 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.
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:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
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.
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
38 * Declaration of osm_mtree_t.
39 * This object represents multicast spanning tree.
40 * This object is part of the OpenSM family of objects.
46 #include <iba/ib_types.h>
47 #include <complib/cl_qmap.h>
48 #include <opensm/osm_base.h>
49 #include <opensm/osm_switch.h>
52 # define BEGIN_C_DECLS extern "C" {
53 # define END_C_DECLS }
54 #else /* !__cplusplus */
55 # define BEGIN_C_DECLS
57 #endif /* __cplusplus */
60 #define OSM_MTREE_LEAF ((void*)-1)
61 /****h* OpenSM/Multicast Tree
66 * The Multicast Tree object encapsulates the information needed by the
67 * OpenSM to manage multicast fabric routes. It is a tree structure
68 * in which each node in the tree represents a switch, and may have a
69 * varying number of children.
71 * Multicast trees do not contain loops.
73 * The Multicast Tree is not thread safe, thus callers must provide
76 * This object should be treated as opaque and should be
77 * manipulated only through the provided functions.
83 /****s* OpenSM: Multicast Tree/osm_mtree_node_t
88 * The MTree Node object encapsulates the information needed by the
89 * OpenSM for a particular switch in the multicast tree.
91 * The MTree Node object is not thread safe, thus callers must provide
94 * This object should be treated as opaque and should be
95 * manipulated only through the provided functions.
99 typedef struct osm_mtree_node {
100 cl_map_item_t map_item;
102 uint8_t max_children;
103 struct osm_mtree_node *p_up;
104 struct osm_mtree_node *child_array[1];
109 * Linkage for quick map. MUST BE FIRST ELEMENT!!!
112 * Pointer to the switch represented by this tree node.
115 * Maximum number of child nodes of this node. Equal to the
116 * the number of ports on the switch if the switch supports
117 * multicast. Equal to 1 (default route) if the switch does
118 * not support multicast.
121 * Pointer to the parent of this node. If this pointer is
122 * NULL, the node is at the root of the tree.
125 * Array (indexed by port number) of pointers to the
126 * child osm_mtree_node_t objects of this tree node, if any.
131 /****f* OpenSM: Multicast Tree/osm_mtree_node_new
136 * Returns an initialized a Multicast Tree object for use.
140 osm_mtree_node_t *osm_mtree_node_new(IN const osm_switch_t * const p_sw);
144 * [in] Pointer to the switch represented by this node.
147 * Pointer to an initialized tree node.
154 /****f* OpenSM: Multicast Tree/osm_mtree_destroy
159 * Destroys a Multicast Tree object given by the p_mtn
163 void osm_mtree_destroy(IN osm_mtree_node_t * p_mtn);
167 * [in] Pointer to an osm_mtree_node_t object to destroy.
177 /****f* OpenSM: Multicast Tree/osm_mtree_node_get_max_children
179 * osm_mtree_node_get_max_children
182 * Returns the number maximum number of children of this node.
183 * The return value is 1 greater than the highest valid port
184 * number on the switch.
189 static inline uint8_t
190 osm_mtree_node_get_max_children(IN const osm_mtree_node_t * const p_mtn)
192 return (p_mtn->max_children);
197 * [in] Pointer to the multicast tree node.
207 /****f* OpenSM: Multicast Tree/osm_mtree_node_get_child
209 * osm_mtree_node_get_child
212 * Returns the specified child node of this node.
216 static inline osm_mtree_node_t *osm_mtree_node_get_child(IN const
219 IN const uint8_t child)
221 CL_ASSERT(child < p_mtn->max_children);
222 return (p_mtn->child_array[child]);
227 * [in] Pointer to the multicast tree node.
230 * [in] Index of the child to retrieve.
233 * Returns the specified child node of this node.
241 /****f* OpenSM: Multicast Tree/osm_mtree_node_get_switch_ptr
243 * osm_mtree_node_get_switch_ptr
246 * Returns a pointer to the switch object represented by this tree node.
250 static inline osm_switch_t *osm_mtree_node_get_switch_ptr(IN const
254 return (p_mtn->p_sw);
259 * [in] Pointer to the multicast tree node.
262 * [in] Index of the child to retrieve.
265 * Returns a pointer to the switch object represented by this tree node.
274 #endif /* _OSM_MTREE_H_ */