1/* 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. 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#ifndef _OSM_PATH_H_ 37#define _OSM_PATH_H_ 38 39#include <string.h> 40#include <opensm/osm_base.h> 41#include <vendor/osm_vendor_api.h> 42 43#ifdef __cplusplus 44# define BEGIN_C_DECLS extern "C" { 45# define END_C_DECLS } 46#else /* !__cplusplus */ 47# define BEGIN_C_DECLS 48# define END_C_DECLS 49#endif /* __cplusplus */ 50 51BEGIN_C_DECLS 52/* 53 * Abstract: 54 * Declaration of path related objects. 55 * These objects are part of the OpenSM family of objects. 56 */ 57/****h* OpenSM/DR Path 58* NAME 59* DR Path 60* 61* DESCRIPTION 62* The DR Path structure encapsulates a directed route through the subnet. 63* 64* This structure allows direct access to member variables. 65* 66* AUTHOR 67* Steve King, Intel 68* 69*********/ 70/****s* OpenSM: DR Path/osm_dr_path_t 71* NAME 72* osm_dr_path_t 73* 74* DESCRIPTION 75* Directed Route structure. 76* 77* This structure allows direct access to member variables. 78* 79* SYNOPSIS 80*/ 81typedef struct osm_dr_path { 82 osm_bind_handle_t h_bind; 83 uint8_t hop_count; 84 uint8_t path[IB_SUBNET_PATH_HOPS_MAX]; 85} osm_dr_path_t; 86/* 87* FIELDS 88* h_bind 89* Bind handle for port to which this path applies. 90* 91* hop_count 92* The number of hops in this path. 93* 94* path 95* The array of port numbers that comprise this path. 96* 97* SEE ALSO 98* DR Path structure 99*********/ 100/****f* OpenSM: DR Path/osm_dr_path_construct 101* NAME 102* osm_dr_path_construct 103* 104* DESCRIPTION 105* This function constructs a directed route path object. 106* 107* SYNOPSIS 108*/ 109static inline void osm_dr_path_construct(IN osm_dr_path_t * const p_path) 110{ 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; 114} 115 116/* 117* PARAMETERS 118* p_path 119* [in] Pointer to a directed route path object to initialize. 120* 121* h_bind 122* [in] Bind handle for the port on which this path applies. 123* 124* hop_count 125* [in] Hop count needed to reach this node. 126* 127* path 128* [in] Directed route path to reach this node. 129* 130* RETURN VALUE 131* None. 132* 133* NOTES 134* 135* SEE ALSO 136*********/ 137 138/****f* OpenSM: DR Path/osm_dr_path_init 139* NAME 140* osm_dr_path_init 141* 142* DESCRIPTION 143* This function initializes a directed route path object. 144* 145* SYNOPSIS 146*/ 147static inline void 148osm_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]) 152{ 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); 159} 160 161/* 162* PARAMETERS 163* p_path 164* [in] Pointer to a directed route path object to initialize. 165* 166* h_bind 167* [in] Bind handle for the port on which this path applies. 168* 169* hop_count 170* [in] Hop count needed to reach this node. 171* 172* path 173* [in] Directed route path to reach this node. 174* 175* RETURN VALUE 176* None. 177* 178* NOTES 179* 180* SEE ALSO 181*********/ 182/****f* OpenSM: DR Path/osm_dr_path_extend 183* NAME 184* osm_dr_path_extend 185* 186* DESCRIPTION 187* Adds a new hop to a path. 188* 189* SYNOPSIS 190*/ 191static inline void 192osm_dr_path_extend(IN osm_dr_path_t * const p_path, IN const uint8_t port_num) 193{ 194 p_path->hop_count++; 195 CL_ASSERT(p_path->hop_count < IB_SUBNET_PATH_HOPS_MAX); 196 /* 197 Location 0 in the path array is reserved per IB spec. 198 */ 199 p_path->path[p_path->hop_count] = port_num; 200} 201 202/* 203* PARAMETERS 204* p_path 205* [in] Pointer to a directed route path object to initialize. 206* 207* port_num 208* [in] Additional port to add to the DR path. 209* 210* RETURN VALUE 211* None. 212* 213* NOTES 214* 215* SEE ALSO 216*********/ 217 218/****f* OpenSM: DR Path/osm_dr_path_get_bind_handle 219* NAME 220* osm_dr_path_get_bind_handle 221* 222* DESCRIPTION 223* Gets the bind handle from a path. 224* 225* SYNOPSIS 226*/ 227static inline osm_bind_handle_t 228osm_dr_path_get_bind_handle(IN const osm_dr_path_t * const p_path) 229{ 230 return (p_path->h_bind); 231} 232 233/* 234* PARAMETERS 235* p_path 236* [in] Pointer to a directed route path object to initialize. 237* 238* port_num 239* [in] Additional port to add to the DR path. 240* 241* RETURN VALUE 242* None. 243* 244* NOTES 245* 246* SEE ALSO 247*********/ 248 249END_C_DECLS 250#endif /* _OSM_PATH_H_ */ 251