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
40 #include <opensm/osm_base.h>
41 #include <vendor/osm_vendor_api.h>
44 # define BEGIN_C_DECLS extern "C" {
45 # define END_C_DECLS }
46 #else /* !__cplusplus */
47 # define BEGIN_C_DECLS
49 #endif /* __cplusplus */
54 * Declaration of path related objects.
55 * These objects are part of the OpenSM family of objects.
57 /****h* OpenSM/DR Path
62 * The DR Path structure encapsulates a directed route through the subnet.
64 * This structure allows direct access to member variables.
70 /****s* OpenSM: DR Path/osm_dr_path_t
75 * Directed Route structure.
77 * This structure allows direct access to member variables.
81 typedef struct osm_dr_path {
82 osm_bind_handle_t h_bind;
84 uint8_t path[IB_SUBNET_PATH_HOPS_MAX];
89 * Bind handle for port to which this path applies.
92 * The number of hops in this path.
95 * The array of port numbers that comprise this path.
100 /****f* OpenSM: DR Path/osm_dr_path_construct
102 * osm_dr_path_construct
105 * This function constructs a directed route path object.
109 static inline void osm_dr_path_construct(IN osm_dr_path_t * const p_path)
111 /* The first location in the path array is reserved. */
112 memset(p_path, 0, sizeof(*p_path));
113 p_path->h_bind = OSM_BIND_INVALID_HANDLE;
119 * [in] Pointer to a directed route path object to initialize.
122 * [in] Bind handle for the port on which this path applies.
125 * [in] Hop count needed to reach this node.
128 * [in] Directed route path to reach this node.
138 /****f* OpenSM: DR Path/osm_dr_path_init
143 * This function initializes a directed route path object.
148 osm_dr_path_init(IN osm_dr_path_t * const p_path,
149 IN const osm_bind_handle_t h_bind,
150 IN const uint8_t hop_count,
151 IN const uint8_t path[IB_SUBNET_PATH_HOPS_MAX])
153 /* The first location in the path array is reserved. */
154 CL_ASSERT(path[0] == 0);
155 CL_ASSERT(hop_count < IB_SUBNET_PATH_HOPS_MAX);
156 p_path->h_bind = h_bind;
157 p_path->hop_count = hop_count;
158 memcpy(p_path->path, path, IB_SUBNET_PATH_HOPS_MAX);
164 * [in] Pointer to a directed route path object to initialize.
167 * [in] Bind handle for the port on which this path applies.
170 * [in] Hop count needed to reach this node.
173 * [in] Directed route path to reach this node.
182 /****f* OpenSM: DR Path/osm_dr_path_extend
187 * Adds a new hop to a path.
192 osm_dr_path_extend(IN osm_dr_path_t * const p_path, IN const uint8_t port_num)
195 CL_ASSERT(p_path->hop_count < IB_SUBNET_PATH_HOPS_MAX);
197 Location 0 in the path array is reserved per IB spec.
199 p_path->path[p_path->hop_count] = port_num;
205 * [in] Pointer to a directed route path object to initialize.
208 * [in] Additional port to add to the DR path.
218 /****f* OpenSM: DR Path/osm_dr_path_get_bind_handle
220 * osm_dr_path_get_bind_handle
223 * Gets the bind handle from a path.
227 static inline osm_bind_handle_t
228 osm_dr_path_get_bind_handle(IN const osm_dr_path_t * const p_path)
230 return (p_path->h_bind);
236 * [in] Pointer to a directed route path object to initialize.
239 * [in] Additional port to add to the DR path.
250 #endif /* _OSM_PATH_H_ */