2 * Copyright (c) 2004,2005 Voltaire Inc. All rights reserved.
\r
4 * This software is available to you under the OpenFabrics.org BSD license
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * - Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
\r
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
32 # include <config.h>
\r
33 #endif /* HAVE_CONFIG_H */
\r
38 #if defined(_WIN32) || defined(_WIN64)
\r
39 #include <windows.h>
\r
43 #include <pthread.h>
\r
44 #include <sys/time.h>
\r
50 #define DEBUG if (ibdebug) IBWARN
\r
53 response_expected(int method)
\r
55 return method == IB_MAD_METHOD_GET ||
\r
56 method == IB_MAD_METHOD_SET ||
\r
57 method == IB_MAD_METHOD_TRAP;
\r
60 MAD_EXPORT uint8_t *
\r
61 ib_vendor_call(void *data, ib_portid_t *portid, ib_vendor_call_t *call)
\r
64 int range1 = 0, resp_expected;
\r
66 DEBUG("route %s data %p", portid2str(portid), data);
\r
67 if (portid->lid <= 0)
\r
68 return 0; /* no direct SMI */
\r
70 if (!(range1 = mad_is_vendor_range1(call->mgmt_class)) &&
\r
71 !(mad_is_vendor_range2(call->mgmt_class)))
\r
74 resp_expected = response_expected(call->method);
\r
76 rpc.mgtclass = call->mgmt_class;
\r
78 rpc.method = call->method;
\r
79 rpc.attr.id = call->attrid;
\r
80 rpc.attr.mod = call->mod;
\r
81 rpc.timeout = resp_expected ? call->timeout : 0;
\r
82 rpc.datasz = range1 ? IB_VENDOR_RANGE1_DATA_SIZE : IB_VENDOR_RANGE2_DATA_SIZE;
\r
83 rpc.dataoffs = range1 ? IB_VENDOR_RANGE1_DATA_OFFS : IB_VENDOR_RANGE2_DATA_OFFS;
\r
86 rpc.oui = call->oui;
\r
88 DEBUG("class 0x%x method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d",
\r
89 rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod,
\r
90 rpc.datasz, rpc.dataoffs, resp_expected);
\r
94 portid->qkey = IB_DEFAULT_QP1_QKEY;
\r
97 return madrpc_rmpp(&rpc, portid, 0, data); /* FIXME: no RMPP for now */
\r
99 return mad_send(&rpc, portid, 0, data) < 0 ? 0 : data; /* FIXME: no RMPP for now */
\r