1 /* 2 * Copyright (c) 2004, 2005 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 /* 37 * Abstract: 38 * Definition of interface for the MTL Vendor 39 * This object is part of the OpenSM family of objects. 40 */ 41 42 #ifndef _OSM_VENDOR_MTL_H_ 43 #define _OSM_VENDOR_MTL_H_ 44 45 #undef IN 46 #undef OUT 47 #include <vapi_types.h> 48 #include <evapi.h> 49 #include <ib_mgt.h> 50 #define IN 51 #define OUT 52 #include "iba/ib_types.h" 53 #include "iba/ib_al.h" 54 #include <complib/cl_thread.h> 55 #include <complib/cl_types_osd.h> 56 #include <opensm/osm_base.h> 57 58 #ifdef __cplusplus 59 # define BEGIN_C_DECLS extern "C" { 60 # define END_C_DECLS } 61 #else /* !__cplusplus */ 62 # define BEGIN_C_DECLS 63 # define END_C_DECLS 64 #endif /* __cplusplus */ 65 66 BEGIN_C_DECLS 67 /****h* OpenSM/Vendor MTL 68 * NAME 69 * Vendor MTL 70 * 71 * DESCRIPTION 72 * 73 * The Vendor MTL object is thread safe. 74 * 75 * This object should be treated as opaque and should be 76 * manipulated only through the provided functions. 77 * 78 * 79 * AUTHOR 80 * 81 * 82 *********/ 83 /****s* OpenSM: Vendor MTL/osm_ca_info_t 84 * NAME 85 * osm_ca_info_t 86 * 87 * DESCRIPTION 88 * Structure containing information about local Channle Adapters. 89 * 90 * SYNOPSIS 91 */ 92 typedef struct _osm_ca_info { 93 ib_net64_t guid; 94 size_t attr_size; 95 ib_ca_attr_t *p_attr; 96 97 } osm_ca_info_t; 98 99 /* 100 * FIELDS 101 * guid 102 * Node GUID of the local CA. 103 * 104 * attr_size 105 * Size of the CA attributes for this CA. 106 * 107 * p_attr 108 * Pointer to dynamicly allocated CA Attribute structure. 109 * 110 * SEE ALSO 111 *********/ 112 113 #define OSM_DEFAULT_RETRY_COUNT 3 114 115 /***** OpenSM: Vendor MTL/osm_vendor_t 116 * NAME 117 * osm_vendor_t 118 * 119 * DESCRIPTION 120 * The structure defining a vendor 121 * 122 * SYNOPSIS 123 */ 124 typedef struct _osm_vendor { 125 ib_al_handle_t h_al; 126 osm_log_t *p_log; 127 uint32_t ca_count; 128 osm_ca_info_t *p_ca_info; 129 uint32_t timeout; 130 struct osm_transaction_mgr_t *p_transaction_mgr; 131 } osm_vendor_t; 132 133 /* 134 * FIELDS 135 * h_al 136 * Handle returned by MTL open call (ib_open_al). 137 * 138 * p_log 139 * Pointer to the log object. 140 * 141 * ca_count 142 * Number of CA's in the array pointed to by p_ca_info. 143 * 144 * p_ca_info 145 * Pointer to dynamically allocated array of CA info objects. 146 * 147 * timeout 148 * Transaction timeout time in milliseconds. 149 * 150 * p_transaction_mgr 151 * Pointer to Transaction Manager. 152 * 153 * SEE ALSO 154 *********/ 155 156 /****f* OpenSM: Vendor MTL/CA Info/osm_ca_info_get_port_guid 157 * NAME 158 * osm_ca_info_get_port_guid 159 * 160 * DESCRIPTION 161 * Returns the port GUID of the specified port owned by this CA. 162 * 163 * SYNOPSIS 164 */ 165 static inline ib_net64_t 166 osm_ca_info_get_port_guid(IN const osm_ca_info_t * const p_ca_info, 167 IN const uint8_t index) 168 { 169 return (p_ca_info->p_attr->p_port_attr[index].port_guid); 170 } 171 172 /* 173 * PARAMETERS 174 * p_ca_info 175 * [in] Pointer to a CA Info object. 176 * 177 * index 178 * [in] Port "index" for which to retrieve the port GUID. 179 * The index is the offset into the ca's internal array 180 * of port attributes. 181 * 182 * RETURN VALUE 183 * Returns the port GUID of the specified port owned by this CA. 184 * 185 * NOTES 186 * 187 * SEE ALSO 188 *********/ 189 190 /****f* OpenSM: Vendor MTL/CA Info/osm_ca_info_get_num_ports 191 * NAME 192 * osm_ca_info_get_num_ports 193 * 194 * DESCRIPTION 195 * Returns the number of ports of the given ca_info 196 * 197 * SYNOPSIS 198 */ 199 static inline uint8_t 200 osm_ca_info_get_num_ports(IN const osm_ca_info_t * const p_ca_info) 201 { 202 return (p_ca_info->p_attr->num_ports); 203 } 204 205 /* 206 * PARAMETERS 207 * p_ca_info 208 * [in] Pointer to a CA Info object. 209 * 210 * RETURN VALUE 211 * Returns the number of CA ports 212 * 213 * NOTES 214 * 215 * SEE ALSO 216 *********/ 217 218 /****f* OpenSM: SM Vendor/osm_vendor_get_guid_ca_and_port 219 * NAME 220 * osm_vendor_get_guid_ca_and_port 221 * 222 * DESCRIPTION 223 * Given the vendor obj and a guid 224 * return the ca id and port number that have that guid 225 * 226 * SYNOPSIS 227 */ 228 ib_api_status_t 229 osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend, 230 IN ib_net64_t const guid, 231 OUT VAPI_hca_hndl_t * p_hca_hndl, 232 OUT VAPI_hca_id_t * p_hca_id, 233 OUT uint32_t * p_port_num); 234 235 /* 236 * PARAMETERS 237 * p_vend 238 * [in] Pointer to an osm_vendor_t object. 239 * 240 * guid 241 * [in] The guid to search for. 242 * 243 * p_hca_id 244 * [out] The HCA Id (VAPI_hca_id_t *) that the port is found on. 245 * 246 * p_port_num 247 * [out] Pointer to a port number arg to be filled with the port number with the given guid. 248 * 249 * RETURN VALUES 250 * IB_SUCCESS on SUCCESS 251 * IB_INVALID_GUID if the guid is notfound on any Local HCA Port 252 * 253 * NOTES 254 * 255 * SEE ALSO 256 *********/ 257 258 /****f* OpenSM: Vendor MTL/osm_vendor_get_all_port_attr 259 * NAME 260 * osm_vendor_get_all_port_attr 261 * 262 * DESCRIPTION 263 * Fill in the array of port_attr with all available ports on ALL the 264 * avilable CAs on this machine. 265 * ALSO - 266 * UPDATE THE VENDOR OBJECT LIST OF CA_INFO STRUCTS 267 * 268 * SYNOPSIS 269 */ 270 ib_api_status_t osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend, 271 IN ib_port_attr_t * 272 const p_attr_array, 273 IN uint32_t * const p_num_ports); 274 275 /* 276 * PARAMETERS 277 * p_vend 278 * [in] Pointer to an osm_vendor_t object. 279 * 280 * p_attr_array 281 * [out] Pre-allocated array of port attributes to be filled in 282 * 283 * p_num_ports 284 * [out] The size of the given array. Filled in by the actual numberof ports found. 285 * 286 * RETURN VALUES 287 * IB_SUCCESS if OK 288 * IB_INSUFFICIENT_MEMORY if not enough place for all ports was provided. 289 * 290 * NOTES 291 * 292 * SEE ALSO 293 *********/ 294 295 #define OSM_BIND_INVALID_HANDLE 0 296 297 /****s* OpenSM: Vendor MTL/osm_bind_handle_t 298 * NAME 299 * osm_bind_handle_t 300 * 301 * DESCRIPTION 302 * handle returned by the vendor transport bind call. 303 * 304 * SYNOPSIS 305 */ 306 typedef void *osm_bind_handle_t; 307 308 /***********/ 309 310 /****s* OpenSM: Vendor MTL/osm_vend_wrap_t 311 * NAME 312 * MTL Vendor MAD Wrapper 313 * 314 * DESCRIPTION 315 * MTL specific MAD wrapper. MTL transport layer uses this for 316 * housekeeping. 317 * 318 * SYNOPSIS 319 *********/ 320 typedef struct _osm_vend_wrap_t { 321 uint32_t size; 322 osm_bind_handle_t h_bind; 323 // ib_av_handle_t h_av; 324 ib_mad_t *mad_buf_p; 325 void *p_resp_madw; 326 } osm_vend_wrap_t; 327 328 /* 329 * FIELDS 330 * size 331 * Size of the allocated MAD 332 * 333 * h_bind 334 * Bind handle used on this transaction 335 * 336 * h_av 337 * Address vector handle used for this transaction. 338 * 339 * p_resp_madw 340 * Pointer to the mad wrapper structure used to hold the pending 341 * reponse to the mad, if any. If a response is expected, the 342 * wrapper for the reponse is allocated during the send call. 343 * 344 * SEE ALSO 345 *********/ 346 347 END_C_DECLS 348 #endif /* _OSM_VENDOR_MTL_H_ */ 349