2 * Copyright (c) 2004-2008 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 void osm_vendor_construct(IN osm_vendor_t * const p_vend)
59 memset(p_vend, 0, sizeof(*p_vend));
62 void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
67 void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
71 osm_vendor_destroy(*pp_vend);
77 osm_vendor_init(IN osm_vendor_t * const p_vend,
78 IN osm_log_t * const p_log, IN const uint32_t timeout)
85 p_vend->p_log = p_log;
86 p_vend->timeout = timeout;
91 osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
92 IN const uint32_t timeout)
94 ib_api_status_t status;
100 p_vend = malloc(sizeof(*p_vend));
101 if (p_vend != NULL) {
102 memset(p_vend, 0, sizeof(*p_vend));
104 status = osm_vendor_init(p_vend, p_log, timeout);
105 if (status != IB_SUCCESS) {
106 osm_vendor_delete(&p_vend);
114 ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
115 IN const uint32_t size,
116 IN osm_vend_wrap_t * const p_vend_wrap)
118 osm_vendor_t *p_vend;
120 OSM_LOG_ENTER(h_bind->p_vend->p_log);
122 UNUSED_PARAM(p_vend_wrap);
124 p_vend = h_bind->p_vend;
127 Simply malloc the MAD off the heap.
129 p_mad = (ib_mad_t *) malloc(size);
131 osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
132 "osm_vendor_get: " "MAD %p.\n", p_mad);
135 memset(p_mad, 0, size);
137 OSM_LOG_EXIT(p_vend->p_log);
142 osm_vendor_put(IN osm_bind_handle_t h_bind,
143 IN osm_vend_wrap_t * const p_vend_wrap,
144 IN ib_mad_t * const p_mad)
146 osm_vendor_t *p_vend;
148 OSM_LOG_ENTER(h_bind->p_vend->p_log);
150 UNUSED_PARAM(p_vend_wrap);
152 p_vend = h_bind->p_vend;
154 osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
155 "osm_vendor_put: " "MAD %p.\n", p_mad);
158 Return the MAD to the heap.
162 OSM_LOG_EXIT(p_vend->p_log);
166 osm_vendor_send(IN osm_bind_handle_t h_bind,
167 IN osm_vend_wrap_t * const p_vend_wrap,
168 IN osm_mad_addr_t * const p_mad_addr,
169 IN ib_mad_t * const p_mad,
170 IN void *transaction_context, IN boolean_t const resp_expected)
172 osm_vendor_t *p_vend = h_bind->p_vend;
174 OSM_LOG_ENTER(p_vend->p_log);
176 UNUSED_PARAM(p_vend_wrap);
177 UNUSED_PARAM(p_mad_addr);
178 UNUSED_PARAM(transaction_context);
179 UNUSED_PARAM(resp_expected);
181 osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
182 "osm_vendor_send: " "MAD %p.\n", p_mad);
184 OSM_LOG_EXIT(p_vend->p_log);
189 osm_vendor_bind(IN osm_vendor_t * const p_vend,
190 IN osm_bind_info_t * const p_bind_info,
191 IN osm_mad_pool_t * const p_mad_pool,
192 IN osm_vend_mad_recv_callback_t mad_recv_callback,
195 osm_bind_handle_t h_bind;
197 OSM_LOG_ENTER(p_vend->p_log);
200 CL_ASSERT(p_bind_info);
201 CL_ASSERT(p_mad_pool);
202 CL_ASSERT(mad_recv_callback);
205 UNUSED_PARAM(p_vend);
206 UNUSED_PARAM(p_mad_pool);
207 UNUSED_PARAM(mad_recv_callback);
208 UNUSED_PARAM(context);
210 h_bind = (osm_bind_handle_t) malloc(sizeof(*h_bind));
211 if (h_bind != NULL) {
212 memset(h_bind, 0, sizeof(*h_bind));
213 h_bind->p_vend = p_vend;
214 h_bind->port_guid = p_bind_info->port_guid;
215 h_bind->mad_class = p_bind_info->mad_class;
216 h_bind->class_version = p_bind_info->class_version;
217 h_bind->is_responder = p_bind_info->is_responder;
218 h_bind->is_trap_processor = p_bind_info->is_trap_processor;
219 h_bind->is_report_processor = p_bind_info->is_report_processor;
220 h_bind->send_q_size = p_bind_info->send_q_size;
221 h_bind->recv_q_size = p_bind_info->recv_q_size;
224 OSM_LOG_EXIT(p_vend->p_log);
229 osm_vendor_get_ports(IN osm_vendor_t * const p_vend,
230 IN ib_net64_t * const p_guids,
231 IN uint32_t * const num_guids)
233 OSM_LOG_ENTER(p_vend->p_log);
235 *p_guids = CL_NTOH64(0x0000000000001234);
238 OSM_LOG_EXIT(p_vend->p_log);
242 ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
244 osm_vendor_t *p_vend = h_bind->p_vend;
246 OSM_LOG_ENTER(p_vend->p_log);
248 OSM_LOG_EXIT(p_vend->p_log);
253 void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
258 #endif /* OSM_VENDOR_INTF_TEST */