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/* 37 * Abstract: 38 * Implementation of vendor specific transport interface. 39 * This is the "Test" vendor which allows compilation and some 40 * testing without a real vendor interface. 41 * These objects are part of the opensm family of objects. 42 * 43 */ 44 45#if HAVE_CONFIG_H 46# include <config.h> 47#endif /* HAVE_CONFIG_H */ 48 49#ifdef OSM_VENDOR_INTF_TEST 50 51#include <stdlib.h> 52#include <string.h> 53#include <opensm/osm_log.h> 54#include <vendor/osm_vendor_test.h> 55#include <vendor/osm_vendor_api.h> 56 57/********************************************************************** 58 **********************************************************************/ 59void osm_vendor_construct(IN osm_vendor_t * const p_vend) 60{ 61 memset(p_vend, 0, sizeof(*p_vend)); 62} 63 64/********************************************************************** 65 **********************************************************************/ 66void osm_vendor_destroy(IN osm_vendor_t * const p_vend) 67{ 68 UNUSED_PARAM(p_vend); 69} 70 71/********************************************************************** 72 **********************************************************************/ 73void osm_vendor_delete(IN osm_vendor_t ** const pp_vend) 74{ 75 CL_ASSERT(pp_vend); 76 77 osm_vendor_destroy(*pp_vend); 78 free(*pp_vend); 79 *pp_vend = NULL; 80} 81 82/********************************************************************** 83 **********************************************************************/ 84ib_api_status_t 85osm_vendor_init(IN osm_vendor_t * const p_vend, 86 IN osm_log_t * const p_log, IN const uint32_t timeout) 87{ 88 OSM_LOG_ENTER(p_log); 89 90 CL_ASSERT(p_vend); 91 CL_ASSERT(p_log); 92 93 p_vend->p_log = p_log; 94 p_vend->timeout = timeout; 95 OSM_LOG_EXIT(p_log); 96 return (IB_SUCCESS); 97} 98 99/********************************************************************** 100 **********************************************************************/ 101osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log, 102 IN const uint32_t timeout) 103{ 104 ib_api_status_t status; 105 osm_vendor_t *p_vend; 106 OSM_LOG_ENTER(p_log); 107 108 CL_ASSERT(p_log); 109 110 p_vend = malloc(sizeof(*p_vend)); 111 if (p_vend != NULL) { 112 memset(p_vend, 0, sizeof(*p_vend)); 113 114 status = osm_vendor_init(p_vend, p_log, timeout); 115 if (status != IB_SUCCESS) { 116 osm_vendor_delete(&p_vend); 117 } 118 } 119 120 OSM_LOG_EXIT(p_log); 121 return (p_vend); 122} 123 124/********************************************************************** 125 **********************************************************************/ 126ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind, 127 IN const uint32_t size, 128 IN osm_vend_wrap_t * const p_vend_wrap) 129{ 130 osm_vendor_t *p_vend; 131 ib_mad_t *p_mad; 132 OSM_LOG_ENTER(h_bind->p_vend->p_log); 133 134 UNUSED_PARAM(p_vend_wrap); 135 136 p_vend = h_bind->p_vend; 137 138 /* 139 Simply malloc the MAD off the heap. 140 */ 141 p_mad = (ib_mad_t *) malloc(size); 142 143 osm_log(p_vend->p_log, OSM_LOG_VERBOSE, 144 "osm_vendor_get: " "MAD %p.\n", p_mad); 145 146 if (p_mad) 147 memset(p_mad, 0, size); 148 149 OSM_LOG_EXIT(p_vend->p_log); 150 return (p_mad); 151} 152 153/********************************************************************** 154 **********************************************************************/ 155void 156osm_vendor_put(IN osm_bind_handle_t h_bind, 157 IN osm_vend_wrap_t * const p_vend_wrap, 158 IN ib_mad_t * const p_mad) 159{ 160 osm_vendor_t *p_vend; 161 162 OSM_LOG_ENTER(h_bind->p_vend->p_log); 163 164 UNUSED_PARAM(p_vend_wrap); 165 166 p_vend = h_bind->p_vend; 167 168 osm_log(p_vend->p_log, OSM_LOG_VERBOSE, 169 "osm_vendor_put: " "MAD %p.\n", p_mad); 170 171 /* 172 Return the MAD to the heap. 173 */ 174 free(p_mad); 175 176 OSM_LOG_EXIT(p_vend->p_log); 177} 178 179/********************************************************************** 180 **********************************************************************/ 181ib_api_status_t 182osm_vendor_send(IN osm_bind_handle_t h_bind, 183 IN osm_vend_wrap_t * const p_vend_wrap, 184 IN osm_mad_addr_t * const p_mad_addr, 185 IN ib_mad_t * const p_mad, 186 IN void *transaction_context, IN boolean_t const resp_expected) 187{ 188 osm_vendor_t *p_vend = h_bind->p_vend; 189 190 OSM_LOG_ENTER(p_vend->p_log); 191 192 UNUSED_PARAM(p_vend_wrap); 193 UNUSED_PARAM(p_mad_addr); 194 UNUSED_PARAM(transaction_context); 195 UNUSED_PARAM(resp_expected); 196 197 osm_log(p_vend->p_log, OSM_LOG_VERBOSE, 198 "osm_vendor_send: " "MAD %p.\n", p_mad); 199 200 OSM_LOG_EXIT(p_vend->p_log); 201 return (IB_SUCCESS); 202} 203 204/********************************************************************** 205 **********************************************************************/ 206osm_bind_handle_t 207osm_vendor_bind(IN osm_vendor_t * const p_vend, 208 IN osm_bind_info_t * const p_bind_info, 209 IN osm_mad_pool_t * const p_mad_pool, 210 IN osm_vend_mad_recv_callback_t mad_recv_callback, 211 IN void *context) 212{ 213 osm_bind_handle_t h_bind; 214 215 OSM_LOG_ENTER(p_vend->p_log); 216 217 CL_ASSERT(p_vend); 218 CL_ASSERT(p_bind_info); 219 CL_ASSERT(p_mad_pool); 220 CL_ASSERT(mad_recv_callback); 221 CL_ASSERT(context); 222 223 UNUSED_PARAM(p_vend); 224 UNUSED_PARAM(p_mad_pool); 225 UNUSED_PARAM(mad_recv_callback); 226 UNUSED_PARAM(context); 227 228 h_bind = (osm_bind_handle_t) malloc(sizeof(*h_bind)); 229 if (h_bind != NULL) { 230 memset(h_bind, 0, sizeof(*h_bind)); 231 h_bind->p_vend = p_vend; 232 h_bind->port_guid = p_bind_info->port_guid; 233 h_bind->mad_class = p_bind_info->mad_class; 234 h_bind->class_version = p_bind_info->class_version; 235 h_bind->is_responder = p_bind_info->is_responder; 236 h_bind->is_trap_processor = p_bind_info->is_trap_processor; 237 h_bind->is_report_processor = p_bind_info->is_report_processor; 238 h_bind->send_q_size = p_bind_info->send_q_size; 239 h_bind->recv_q_size = p_bind_info->recv_q_size; 240 } 241 242 OSM_LOG_EXIT(p_vend->p_log); 243 return (h_bind); 244} 245 246/********************************************************************** 247 **********************************************************************/ 248ib_api_status_t 249osm_vendor_get_ports(IN osm_vendor_t * const p_vend, 250 IN ib_net64_t * const p_guids, 251 IN uint32_t * const num_guids) 252{ 253 OSM_LOG_ENTER(p_vend->p_log); 254 255 *p_guids = CL_NTOH64(0x0000000000001234); 256 *num_guids = 1; 257 258 OSM_LOG_EXIT(p_vend->p_log); 259 return (IB_SUCCESS); 260} 261 262/********************************************************************** 263 **********************************************************************/ 264ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind) 265{ 266 osm_vendor_t *p_vend = h_bind->p_vend; 267 268 OSM_LOG_ENTER(p_vend->p_log); 269 270 OSM_LOG_EXIT(p_vend->p_log); 271 272 return (IB_SUCCESS); 273} 274 275/********************************************************************** 276 **********************************************************************/ 277void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level) 278{ 279 280} 281 282#endif /* OSM_VENDOR_INTF_TEST */ 283