2 * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
3 * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 #endif /* HAVE_CONFIG_H */
44 #include <infiniband/umad.h>
45 #include <infiniband/mad.h>
46 #include "mad_internal.h"
49 #define DEBUG if (ibdebug) IBWARN
51 static inline int response_expected(int method)
53 return method == IB_MAD_METHOD_GET ||
54 method == IB_MAD_METHOD_SET || method == IB_MAD_METHOD_TRAP;
57 uint8_t *ib_vendor_call(void *data, ib_portid_t * portid,
58 ib_vendor_call_t * call)
60 return ib_vendor_call_via(data, portid, call, ibmp);
63 uint8_t *ib_vendor_call_via(void *data, ib_portid_t * portid,
64 ib_vendor_call_t * call,
65 struct ibmad_port * srcport)
67 ib_rpc_v1_t rpc = { 0 };
68 ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
69 int range1 = 0, resp_expected;
72 DEBUG("route %s data %p", portid2str(portid), data);
74 return NULL; /* no direct SMI */
76 if (!(range1 = mad_is_vendor_range1(call->mgmt_class)) &&
77 !(mad_is_vendor_range2(call->mgmt_class)))
80 resp_expected = response_expected(call->method);
82 rpc.mgtclass = call->mgmt_class | IB_MAD_RPC_VERSION1;
84 rpc.method = call->method;
85 rpc.attr.id = call->attrid;
86 rpc.attr.mod = call->mod;
87 rpc.timeout = resp_expected ? call->timeout : 0;
89 range1 ? IB_VENDOR_RANGE1_DATA_SIZE : IB_VENDOR_RANGE2_DATA_SIZE;
91 range1 ? IB_VENDOR_RANGE1_DATA_OFFS : IB_VENDOR_RANGE2_DATA_OFFS;
97 ("class 0x%x method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d",
98 rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod, rpc.datasz,
99 rpc.dataoffs, resp_expected);
103 portid->qkey = IB_DEFAULT_QP1_QKEY;
106 p_ret = mad_rpc_rmpp(srcport, rpcold, portid, 0, data); /* FIXME: no RMPP for now */
111 return mad_send_via(rpcold, portid, 0, data, srcport) < 0 ? 0 : data; /* FIXME: no RMPP for now */