2 * Copyright (c) 2011 Lawrence Livermore National Lab. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 #endif /* HAVE_CONFIG_H */
42 #include <infiniband/umad.h>
43 #include <infiniband/mad.h>
44 #include "mad_internal.h"
47 #define DEBUG if (ibdebug) IBWARN
49 void *cc_query_status_via(void *rcvbuf, ib_portid_t * portid,
50 unsigned attrid, unsigned mod, unsigned timeout,
51 int *rstatus, const struct ibmad_port * srcport,
54 ib_rpc_cc_t rpc = { 0 };
57 DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
58 rpc.method = IB_MAD_METHOD_GET;
61 rpc.timeout = timeout;
62 if (attrid == IB_CC_ATTR_CONGESTION_LOG) {
63 rpc.datasz = IB_CC_LOG_DATA_SZ;
64 rpc.dataoffs = IB_CC_LOG_DATA_OFFS;
67 rpc.datasz = IB_CC_DATA_SZ;
68 rpc.dataoffs = IB_CC_DATA_OFFS;
70 rpc.mgtclass = IB_CC_CLASS;
75 portid->qkey = IB_DEFAULT_QP1_QKEY;
77 res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, rcvbuf, rcvbuf);
79 *rstatus = rpc.rstatus;
84 void *cc_config_status_via(void *payload, void *rcvbuf, ib_portid_t * portid,
85 unsigned attrid, unsigned mod, unsigned timeout,
86 int *rstatus, const struct ibmad_port * srcport,
89 ib_rpc_cc_t rpc = { 0 };
92 DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
93 rpc.method = IB_MAD_METHOD_SET;
96 rpc.timeout = timeout;
97 if (attrid == IB_CC_ATTR_CONGESTION_LOG) {
98 rpc.datasz = IB_CC_LOG_DATA_SZ;
99 rpc.dataoffs = IB_CC_LOG_DATA_OFFS;
102 rpc.datasz = IB_CC_DATA_SZ;
103 rpc.dataoffs = IB_CC_DATA_OFFS;
105 rpc.mgtclass = IB_CC_CLASS;
110 portid->qkey = IB_DEFAULT_QP1_QKEY;
112 res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, payload, rcvbuf);
114 *rstatus = rpc.rstatus;