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
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.
47 #endif /* HAVE_CONFIG_H */
49 #ifdef OSM_VENDOR_INTF_TEST
53 #include <opensm/osm_log.h>
54 #include <vendor/osm_vendor_test.h>
55 #include <vendor/osm_vendor_api.h>
57 /**********************************************************************
58 **********************************************************************/
59 void osm_vendor_construct(IN osm_vendor_t * const p_vend)
61 memset(p_vend, 0, sizeof(*p_vend));
64 /**********************************************************************
65 **********************************************************************/
66 void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
71 /**********************************************************************
72 **********************************************************************/
73 void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
77 osm_vendor_destroy(*pp_vend);
82 /**********************************************************************
83 **********************************************************************/
85 osm_vendor_init(IN osm_vendor_t * const p_vend,
86 IN osm_log_t * const p_log, IN const uint32_t timeout)
93 p_vend->p_log = p_log;
94 p_vend->timeout = timeout;
99 /**********************************************************************
100 **********************************************************************/
101 osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
102 IN const uint32_t timeout)
104 ib_api_status_t status;
105 osm_vendor_t *p_vend;
106 OSM_LOG_ENTER(p_log);
110 p_vend = malloc(sizeof(*p_vend));
111 if (p_vend != NULL) {
112 memset(p_vend, 0, sizeof(*p_vend));
114 status = osm_vendor_init(p_vend, p_log, timeout);
115 if (status != IB_SUCCESS) {
116 osm_vendor_delete(&p_vend);
124 /**********************************************************************
125 **********************************************************************/
126 ib_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)
130 osm_vendor_t *p_vend;
132 OSM_LOG_ENTER(h_bind->p_vend->p_log);
134 UNUSED_PARAM(p_vend_wrap);
136 p_vend = h_bind->p_vend;
139 Simply malloc the MAD off the heap.
141 p_mad = (ib_mad_t *) malloc(size);
143 osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
144 "osm_vendor_get: " "MAD %p.\n", p_mad);
147 memset(p_mad, 0, size);
149 OSM_LOG_EXIT(p_vend->p_log);
153 /**********************************************************************
154 **********************************************************************/
156 osm_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)
160 osm_vendor_t *p_vend;
162 OSM_LOG_ENTER(h_bind->p_vend->p_log);
164 UNUSED_PARAM(p_vend_wrap);
166 p_vend = h_bind->p_vend;
168 osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
169 "osm_vendor_put: " "MAD %p.\n", p_mad);
172 Return the MAD to the heap.
176 OSM_LOG_EXIT(p_vend->p_log);
179 /**********************************************************************
180 **********************************************************************/
182 osm_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)
188 osm_vendor_t *p_vend = h_bind->p_vend;
190 OSM_LOG_ENTER(p_vend->p_log);
192 UNUSED_PARAM(p_vend_wrap);
193 UNUSED_PARAM(p_mad_addr);
194 UNUSED_PARAM(transaction_context);
195 UNUSED_PARAM(resp_expected);
197 osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
198 "osm_vendor_send: " "MAD %p.\n", p_mad);
200 OSM_LOG_EXIT(p_vend->p_log);
204 /**********************************************************************
205 **********************************************************************/
207 osm_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,
213 osm_bind_handle_t h_bind;
215 OSM_LOG_ENTER(p_vend->p_log);
218 CL_ASSERT(p_bind_info);
219 CL_ASSERT(p_mad_pool);
220 CL_ASSERT(mad_recv_callback);
223 UNUSED_PARAM(p_vend);
224 UNUSED_PARAM(p_mad_pool);
225 UNUSED_PARAM(mad_recv_callback);
226 UNUSED_PARAM(context);
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;
242 OSM_LOG_EXIT(p_vend->p_log);
246 /**********************************************************************
247 **********************************************************************/
249 osm_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)
253 OSM_LOG_ENTER(p_vend->p_log);
255 *p_guids = CL_NTOH64(0x0000000000001234);
258 OSM_LOG_EXIT(p_vend->p_log);
262 /**********************************************************************
263 **********************************************************************/
264 ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
266 osm_vendor_t *p_vend = h_bind->p_vend;
268 OSM_LOG_ENTER(p_vend->p_log);
270 OSM_LOG_EXIT(p_vend->p_log);
275 /**********************************************************************
276 **********************************************************************/
277 void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
282 #endif /* OSM_VENDOR_INTF_TEST */