Blame include/opensm/osm_mtree.h

Packit 13e616
/*
Packit 13e616
 * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
Packit 13e616
 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
Packit 13e616
 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
Packit 13e616
 *
Packit 13e616
 * This software is available to you under a choice of one of two
Packit 13e616
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 13e616
 * General Public License (GPL) Version 2, available from the file
Packit 13e616
 * COPYING in the main directory of this source tree, or the
Packit 13e616
 * OpenIB.org BSD license below:
Packit 13e616
 *
Packit 13e616
 *     Redistribution and use in source and binary forms, with or
Packit 13e616
 *     without modification, are permitted provided that the following
Packit 13e616
 *     conditions are met:
Packit 13e616
 *
Packit 13e616
 *      - Redistributions of source code must retain the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer.
Packit 13e616
 *
Packit 13e616
 *      - Redistributions in binary form must reproduce the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer in the documentation and/or other materials
Packit 13e616
 *        provided with the distribution.
Packit 13e616
 *
Packit 13e616
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 13e616
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 13e616
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 13e616
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 13e616
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 13e616
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 13e616
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 13e616
 * SOFTWARE.
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
/*
Packit 13e616
 * Abstract:
Packit 13e616
 * 	Declaration of osm_mtree_t.
Packit 13e616
 *	This object represents multicast spanning tree.
Packit 13e616
 *	This object is part of the OpenSM family of objects.
Packit 13e616
 */
Packit 13e616
Packit 13e616
#ifndef _OSM_MTREE_H_
Packit 13e616
#define _OSM_MTREE_H_
Packit 13e616
Packit 13e616
#include <iba/ib_types.h>
Packit 13e616
#include <complib/cl_qmap.h>
Packit 13e616
#include <opensm/osm_base.h>
Packit 13e616
#include <opensm/osm_switch.h>
Packit 13e616
Packit 13e616
#ifdef __cplusplus
Packit 13e616
#  define BEGIN_C_DECLS extern "C" {
Packit 13e616
#  define END_C_DECLS   }
Packit 13e616
#else				/* !__cplusplus */
Packit 13e616
#  define BEGIN_C_DECLS
Packit 13e616
#  define END_C_DECLS
Packit 13e616
#endif				/* __cplusplus */
Packit 13e616
Packit 13e616
BEGIN_C_DECLS
Packit 13e616
#define OSM_MTREE_LEAF ((void*)-1)
Packit 13e616
/****h* OpenSM/Multicast Tree
Packit 13e616
* NAME
Packit 13e616
*	Multicast Tree
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The Multicast Tree object encapsulates the information needed by the
Packit 13e616
*	OpenSM to manage multicast fabric routes.  It is a tree structure
Packit 13e616
*	in which each node in the tree represents a switch, and may have a
Packit 13e616
*	varying number of children.
Packit 13e616
*
Packit 13e616
*	Multicast trees do not contain loops.
Packit 13e616
*
Packit 13e616
*	The Multicast Tree is not thread safe, thus callers must provide
Packit 13e616
*	serialization.
Packit 13e616
*
Packit 13e616
*	This object should be treated as opaque and should be
Packit 13e616
*	manipulated only through the provided functions.
Packit 13e616
*
Packit 13e616
* AUTHOR
Packit 13e616
*	Steve King, Intel
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
/****s* OpenSM: Multicast Tree/osm_mtree_node_t
Packit 13e616
* NAME
Packit 13e616
*	osm_mtree_node_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The MTree Node object encapsulates the information needed by the
Packit 13e616
*	OpenSM for a particular switch in the multicast tree.
Packit 13e616
*
Packit 13e616
*	The MTree Node object is not thread safe, thus callers must provide
Packit 13e616
*	serialization.
Packit 13e616
*
Packit 13e616
*	This object should be treated as opaque and should be
Packit 13e616
*	manipulated only through the provided functions.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef struct osm_mtree_node {
Packit 13e616
	cl_map_item_t map_item;
Packit 13e616
	const osm_switch_t *p_sw;
Packit 13e616
	uint8_t max_children;
Packit 13e616
	struct osm_mtree_node *p_up;
Packit 13e616
	struct osm_mtree_node *child_array[1];
Packit 13e616
} osm_mtree_node_t;
Packit 13e616
/*
Packit 13e616
* FIELDS
Packit 13e616
*	map_item
Packit 13e616
*		Linkage for quick map.  MUST BE FIRST ELEMENT!!!
Packit 13e616
*
Packit 13e616
*	p_sw
Packit 13e616
*		Pointer to the switch represented by this tree node.
Packit 13e616
*
Packit 13e616
*	max_children
Packit 13e616
*		Maximum number of child nodes of this node.  Equal to the
Packit 13e616
*		the number of ports on the switch if the switch supports
Packit 13e616
*		multicast.  Equal to 1 (default route) if the switch does
Packit 13e616
*		not support multicast.
Packit 13e616
*
Packit 13e616
*	p_up
Packit 13e616
*		Pointer to the parent of this node.  If this pointer is
Packit 13e616
*		NULL, the node is at the root of the tree.
Packit 13e616
*
Packit 13e616
*	child_array
Packit 13e616
*		Array (indexed by port number) of pointers to the
Packit 13e616
*		child osm_mtree_node_t objects of this tree node, if any.
Packit 13e616
*		MUST BE LAST ELEMENT!!!
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Multicast Tree/osm_mtree_node_new
Packit 13e616
* NAME
Packit 13e616
*	osm_mtree_node_new
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Returns an initialized Multicast Tree object for use.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
osm_mtree_node_t *osm_mtree_node_new(IN const osm_switch_t * p_sw);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_sw
Packit 13e616
*		[in] Pointer to the switch represented by this node.
Packit 13e616
*
Packit 13e616
* RETURN VALUES
Packit 13e616
*	Pointer to an initialized tree node.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Multicast Tree/osm_mtree_destroy
Packit 13e616
* NAME
Packit 13e616
*	osm_mtree_destroy
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Destroys a Multicast Tree object given by the p_mtn
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void osm_mtree_destroy(IN osm_mtree_node_t * p_mtn);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_mtn
Packit 13e616
*		[in] Pointer to an osm_mtree_node_t object to destroy.
Packit 13e616
*
Packit 13e616
* RETURN VALUES
Packit 13e616
*	None.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Multicast Tree/osm_mtree_node_get_max_children
Packit 13e616
* NAME
Packit 13e616
*	osm_mtree_node_get_max_children
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Returns the number maximum number of children of this node.
Packit 13e616
*	The return value is 1 greater than the highest valid port
Packit 13e616
*	number on the switch.
Packit 13e616
*
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
static inline uint8_t
Packit 13e616
osm_mtree_node_get_max_children(IN const osm_mtree_node_t * p_mtn)
Packit 13e616
{
Packit 13e616
	return (p_mtn->max_children);
Packit 13e616
}
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_mtn
Packit 13e616
*		[in] Pointer to the multicast tree node.
Packit 13e616
*
Packit 13e616
* RETURN VALUES
Packit 13e616
*	See description.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Multicast Tree/osm_mtree_node_get_child
Packit 13e616
* NAME
Packit 13e616
*	osm_mtree_node_get_child
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Returns the specified child node of this node.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
static inline osm_mtree_node_t *osm_mtree_node_get_child(IN const
Packit 13e616
							 osm_mtree_node_t *
Packit 13e616
							 p_mtn,
Packit 13e616
							 IN uint8_t child)
Packit 13e616
{
Packit 13e616
	CL_ASSERT(child < p_mtn->max_children);
Packit 13e616
	return (p_mtn->child_array[child]);
Packit 13e616
}
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_mtn
Packit 13e616
*		[in] Pointer to the multicast tree node.
Packit 13e616
*
Packit 13e616
*	child
Packit 13e616
*		[in] Index of the child to retrieve.
Packit 13e616
*
Packit 13e616
* RETURN VALUES
Packit 13e616
*	Returns the specified child node of this node.
Packit 13e616
*
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* OpenSM: Multicast Tree/osm_mtree_node_get_switch_ptr
Packit 13e616
* NAME
Packit 13e616
*	osm_mtree_node_get_switch_ptr
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Returns a pointer to the switch object represented by this tree node.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
static inline const osm_switch_t *osm_mtree_node_get_switch_ptr(IN const
Packit 13e616
							  osm_mtree_node_t *
Packit 13e616
							  p_mtn)
Packit 13e616
{
Packit 13e616
	return p_mtn->p_sw;
Packit 13e616
}
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_mtn
Packit 13e616
*		[in] Pointer to the multicast tree node.
Packit 13e616
*
Packit 13e616
* RETURN VALUES
Packit 13e616
*	Returns a pointer to the switch object represented by this tree node.
Packit 13e616
*
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*********/
Packit 13e616
Packit 13e616
END_C_DECLS
Packit 13e616
#endif				/* _OSM_MTREE_H_ */