1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved. 3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. 4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 5219820Sjeff * 6219820Sjeff * This software is available to you under a choice of one of two 7219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 8219820Sjeff * General Public License (GPL) Version 2, available from the file 9219820Sjeff * COPYING in the main directory of this source tree, or the 10219820Sjeff * OpenIB.org BSD license below: 11219820Sjeff * 12219820Sjeff * Redistribution and use in source and binary forms, with or 13219820Sjeff * without modification, are permitted provided that the following 14219820Sjeff * conditions are met: 15219820Sjeff * 16219820Sjeff * - Redistributions of source code must retain the above 17219820Sjeff * copyright notice, this list of conditions and the following 18219820Sjeff * disclaimer. 19219820Sjeff * 20219820Sjeff * - Redistributions in binary form must reproduce the above 21219820Sjeff * copyright notice, this list of conditions and the following 22219820Sjeff * disclaimer in the documentation and/or other materials 23219820Sjeff * provided with the distribution. 24219820Sjeff * 25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32219820Sjeff * SOFTWARE. 33219820Sjeff * 34219820Sjeff */ 35219820Sjeff 36219820Sjeff/* 37219820Sjeff * Abstract: 38219820Sjeff * Implementation of vendor specific transport interface. 39219820Sjeff * This is the "Test" vendor which allows compilation and some 40219820Sjeff * testing without a real vendor interface. 41219820Sjeff * These objects are part of the opensm family of objects. 42219820Sjeff * 43219820Sjeff */ 44219820Sjeff 45219820Sjeff#if HAVE_CONFIG_H 46219820Sjeff# include <config.h> 47219820Sjeff#endif /* HAVE_CONFIG_H */ 48219820Sjeff 49219820Sjeff#ifdef OSM_VENDOR_INTF_TEST 50219820Sjeff 51219820Sjeff#include <stdlib.h> 52219820Sjeff#include <string.h> 53219820Sjeff#include <opensm/osm_log.h> 54219820Sjeff#include <vendor/osm_vendor_test.h> 55219820Sjeff#include <vendor/osm_vendor_api.h> 56219820Sjeff 57219820Sjeff/********************************************************************** 58219820Sjeff **********************************************************************/ 59219820Sjeffvoid osm_vendor_construct(IN osm_vendor_t * const p_vend) 60219820Sjeff{ 61219820Sjeff memset(p_vend, 0, sizeof(*p_vend)); 62219820Sjeff} 63219820Sjeff 64219820Sjeff/********************************************************************** 65219820Sjeff **********************************************************************/ 66219820Sjeffvoid osm_vendor_destroy(IN osm_vendor_t * const p_vend) 67219820Sjeff{ 68219820Sjeff UNUSED_PARAM(p_vend); 69219820Sjeff} 70219820Sjeff 71219820Sjeff/********************************************************************** 72219820Sjeff **********************************************************************/ 73219820Sjeffvoid osm_vendor_delete(IN osm_vendor_t ** const pp_vend) 74219820Sjeff{ 75219820Sjeff CL_ASSERT(pp_vend); 76219820Sjeff 77219820Sjeff osm_vendor_destroy(*pp_vend); 78219820Sjeff free(*pp_vend); 79219820Sjeff *pp_vend = NULL; 80219820Sjeff} 81219820Sjeff 82219820Sjeff/********************************************************************** 83219820Sjeff **********************************************************************/ 84219820Sjeffib_api_status_t 85219820Sjeffosm_vendor_init(IN osm_vendor_t * const p_vend, 86219820Sjeff IN osm_log_t * const p_log, IN const uint32_t timeout) 87219820Sjeff{ 88219820Sjeff OSM_LOG_ENTER(p_log); 89219820Sjeff 90219820Sjeff CL_ASSERT(p_vend); 91219820Sjeff CL_ASSERT(p_log); 92219820Sjeff 93219820Sjeff p_vend->p_log = p_log; 94219820Sjeff p_vend->timeout = timeout; 95219820Sjeff OSM_LOG_EXIT(p_log); 96219820Sjeff return (IB_SUCCESS); 97219820Sjeff} 98219820Sjeff 99219820Sjeff/********************************************************************** 100219820Sjeff **********************************************************************/ 101219820Sjeffosm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log, 102219820Sjeff IN const uint32_t timeout) 103219820Sjeff{ 104219820Sjeff ib_api_status_t status; 105219820Sjeff osm_vendor_t *p_vend; 106219820Sjeff OSM_LOG_ENTER(p_log); 107219820Sjeff 108219820Sjeff CL_ASSERT(p_log); 109219820Sjeff 110219820Sjeff p_vend = malloc(sizeof(*p_vend)); 111219820Sjeff if (p_vend != NULL) { 112219820Sjeff memset(p_vend, 0, sizeof(*p_vend)); 113219820Sjeff 114219820Sjeff status = osm_vendor_init(p_vend, p_log, timeout); 115219820Sjeff if (status != IB_SUCCESS) { 116219820Sjeff osm_vendor_delete(&p_vend); 117219820Sjeff } 118219820Sjeff } 119219820Sjeff 120219820Sjeff OSM_LOG_EXIT(p_log); 121219820Sjeff return (p_vend); 122219820Sjeff} 123219820Sjeff 124219820Sjeff/********************************************************************** 125219820Sjeff **********************************************************************/ 126219820Sjeffib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind, 127219820Sjeff IN const uint32_t size, 128219820Sjeff IN osm_vend_wrap_t * const p_vend_wrap) 129219820Sjeff{ 130219820Sjeff osm_vendor_t *p_vend; 131219820Sjeff ib_mad_t *p_mad; 132219820Sjeff OSM_LOG_ENTER(h_bind->p_vend->p_log); 133219820Sjeff 134219820Sjeff UNUSED_PARAM(p_vend_wrap); 135219820Sjeff 136219820Sjeff p_vend = h_bind->p_vend; 137219820Sjeff 138219820Sjeff /* 139219820Sjeff Simply malloc the MAD off the heap. 140219820Sjeff */ 141219820Sjeff p_mad = (ib_mad_t *) malloc(size); 142219820Sjeff 143219820Sjeff osm_log(p_vend->p_log, OSM_LOG_VERBOSE, 144219820Sjeff "osm_vendor_get: " "MAD %p.\n", p_mad); 145219820Sjeff 146219820Sjeff if (p_mad) 147219820Sjeff memset(p_mad, 0, size); 148219820Sjeff 149219820Sjeff OSM_LOG_EXIT(p_vend->p_log); 150219820Sjeff return (p_mad); 151219820Sjeff} 152219820Sjeff 153219820Sjeff/********************************************************************** 154219820Sjeff **********************************************************************/ 155219820Sjeffvoid 156219820Sjeffosm_vendor_put(IN osm_bind_handle_t h_bind, 157219820Sjeff IN osm_vend_wrap_t * const p_vend_wrap, 158219820Sjeff IN ib_mad_t * const p_mad) 159219820Sjeff{ 160219820Sjeff osm_vendor_t *p_vend; 161219820Sjeff 162219820Sjeff OSM_LOG_ENTER(h_bind->p_vend->p_log); 163219820Sjeff 164219820Sjeff UNUSED_PARAM(p_vend_wrap); 165219820Sjeff 166219820Sjeff p_vend = h_bind->p_vend; 167219820Sjeff 168219820Sjeff osm_log(p_vend->p_log, OSM_LOG_VERBOSE, 169219820Sjeff "osm_vendor_put: " "MAD %p.\n", p_mad); 170219820Sjeff 171219820Sjeff /* 172219820Sjeff Return the MAD to the heap. 173219820Sjeff */ 174219820Sjeff free(p_mad); 175219820Sjeff 176219820Sjeff OSM_LOG_EXIT(p_vend->p_log); 177219820Sjeff} 178219820Sjeff 179219820Sjeff/********************************************************************** 180219820Sjeff **********************************************************************/ 181219820Sjeffib_api_status_t 182219820Sjeffosm_vendor_send(IN osm_bind_handle_t h_bind, 183219820Sjeff IN osm_vend_wrap_t * const p_vend_wrap, 184219820Sjeff IN osm_mad_addr_t * const p_mad_addr, 185219820Sjeff IN ib_mad_t * const p_mad, 186219820Sjeff IN void *transaction_context, IN boolean_t const resp_expected) 187219820Sjeff{ 188219820Sjeff osm_vendor_t *p_vend = h_bind->p_vend; 189219820Sjeff 190219820Sjeff OSM_LOG_ENTER(p_vend->p_log); 191219820Sjeff 192219820Sjeff UNUSED_PARAM(p_vend_wrap); 193219820Sjeff UNUSED_PARAM(p_mad_addr); 194219820Sjeff UNUSED_PARAM(transaction_context); 195219820Sjeff UNUSED_PARAM(resp_expected); 196219820Sjeff 197219820Sjeff osm_log(p_vend->p_log, OSM_LOG_VERBOSE, 198219820Sjeff "osm_vendor_send: " "MAD %p.\n", p_mad); 199219820Sjeff 200219820Sjeff OSM_LOG_EXIT(p_vend->p_log); 201219820Sjeff return (IB_SUCCESS); 202219820Sjeff} 203219820Sjeff 204219820Sjeff/********************************************************************** 205219820Sjeff **********************************************************************/ 206219820Sjeffosm_bind_handle_t 207219820Sjeffosm_vendor_bind(IN osm_vendor_t * const p_vend, 208219820Sjeff IN osm_bind_info_t * const p_bind_info, 209219820Sjeff IN osm_mad_pool_t * const p_mad_pool, 210219820Sjeff IN osm_vend_mad_recv_callback_t mad_recv_callback, 211219820Sjeff IN void *context) 212219820Sjeff{ 213219820Sjeff osm_bind_handle_t h_bind; 214219820Sjeff 215219820Sjeff OSM_LOG_ENTER(p_vend->p_log); 216219820Sjeff 217219820Sjeff CL_ASSERT(p_vend); 218219820Sjeff CL_ASSERT(p_bind_info); 219219820Sjeff CL_ASSERT(p_mad_pool); 220219820Sjeff CL_ASSERT(mad_recv_callback); 221219820Sjeff CL_ASSERT(context); 222219820Sjeff 223219820Sjeff UNUSED_PARAM(p_vend); 224219820Sjeff UNUSED_PARAM(p_mad_pool); 225219820Sjeff UNUSED_PARAM(mad_recv_callback); 226219820Sjeff UNUSED_PARAM(context); 227219820Sjeff 228219820Sjeff h_bind = (osm_bind_handle_t) malloc(sizeof(*h_bind)); 229219820Sjeff if (h_bind != NULL) { 230219820Sjeff memset(h_bind, 0, sizeof(*h_bind)); 231219820Sjeff h_bind->p_vend = p_vend; 232219820Sjeff h_bind->port_guid = p_bind_info->port_guid; 233219820Sjeff h_bind->mad_class = p_bind_info->mad_class; 234219820Sjeff h_bind->class_version = p_bind_info->class_version; 235219820Sjeff h_bind->is_responder = p_bind_info->is_responder; 236219820Sjeff h_bind->is_trap_processor = p_bind_info->is_trap_processor; 237219820Sjeff h_bind->is_report_processor = p_bind_info->is_report_processor; 238219820Sjeff h_bind->send_q_size = p_bind_info->send_q_size; 239219820Sjeff h_bind->recv_q_size = p_bind_info->recv_q_size; 240219820Sjeff } 241219820Sjeff 242219820Sjeff OSM_LOG_EXIT(p_vend->p_log); 243219820Sjeff return (h_bind); 244219820Sjeff} 245219820Sjeff 246219820Sjeff/********************************************************************** 247219820Sjeff **********************************************************************/ 248219820Sjeffib_api_status_t 249219820Sjeffosm_vendor_get_ports(IN osm_vendor_t * const p_vend, 250219820Sjeff IN ib_net64_t * const p_guids, 251219820Sjeff IN uint32_t * const num_guids) 252219820Sjeff{ 253219820Sjeff OSM_LOG_ENTER(p_vend->p_log); 254219820Sjeff 255219820Sjeff *p_guids = CL_NTOH64(0x0000000000001234); 256219820Sjeff *num_guids = 1; 257219820Sjeff 258219820Sjeff OSM_LOG_EXIT(p_vend->p_log); 259219820Sjeff return (IB_SUCCESS); 260219820Sjeff} 261219820Sjeff 262219820Sjeff/********************************************************************** 263219820Sjeff **********************************************************************/ 264219820Sjeffib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind) 265219820Sjeff{ 266219820Sjeff osm_vendor_t *p_vend = h_bind->p_vend; 267219820Sjeff 268219820Sjeff OSM_LOG_ENTER(p_vend->p_log); 269219820Sjeff 270219820Sjeff OSM_LOG_EXIT(p_vend->p_log); 271219820Sjeff 272219820Sjeff return (IB_SUCCESS); 273219820Sjeff} 274219820Sjeff 275219820Sjeff/********************************************************************** 276219820Sjeff **********************************************************************/ 277219820Sjeffvoid osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level) 278219820Sjeff{ 279219820Sjeff 280219820Sjeff} 281219820Sjeff 282219820Sjeff#endif /* OSM_VENDOR_INTF_TEST */ 283