2 * Copyright (c) 2004-2007 Voltaire Inc. 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 */
45 #include <infiniband/umad.h>
49 #define DEBUG if (ibdebug) IBWARN
52 pma_query_via(void *rcvbuf, ib_portid_t *dest, int port,
53 unsigned timeout, unsigned id, const void *srcport)
58 DEBUG("lid %d port %d", lid, port);
61 IBWARN("only lid routed is supported");
65 rpc.mgtclass = IB_PERFORMANCE_CLASS;
66 rpc.method = IB_MAD_METHOD_GET;
69 /* Same for attribute IDs */
70 mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
72 rpc.timeout = timeout;
73 rpc.datasz = IB_PC_DATA_SZ;
74 rpc.dataoffs = IB_PC_DATA_OFFS;
78 dest->qkey = IB_DEFAULT_QP1_QKEY;
81 return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf);
83 return madrpc(&rpc, dest, rcvbuf, rcvbuf);
88 pma_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout, unsigned id)
90 return pma_query_via(rcvbuf, dest, port, timeout, id, NULL);
94 perf_classportinfo_query_via(void *rcvbuf, ib_portid_t *dest, int port,
95 unsigned timeout, const void *srcport)
97 return pma_query_via(rcvbuf, dest, port, timeout, CLASS_PORT_INFO,
102 perf_classportinfo_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
104 return pma_query(rcvbuf, dest, port, timeout, CLASS_PORT_INFO);
108 port_performance_query_via(void *rcvbuf, ib_portid_t *dest, int port,
109 unsigned timeout, const void *srcport)
111 return pma_query_via(rcvbuf, dest, port, timeout,
112 IB_GSI_PORT_COUNTERS, srcport);
116 port_performance_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
118 return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS);
122 performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
123 unsigned timeout, unsigned id, const void *srcport)
128 DEBUG("lid %d port %d mask 0x%x", lid, port, mask);
131 IBWARN("only lid routed is supported");
138 rpc.mgtclass = IB_PERFORMANCE_CLASS;
139 rpc.method = IB_MAD_METHOD_SET;
142 memset(rcvbuf, 0, IB_MAD_SIZE);
144 /* Same for attribute IDs */
145 mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
146 mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT_F, mask);
148 rpc.timeout = timeout;
149 rpc.datasz = IB_PC_DATA_SZ;
150 rpc.dataoffs = IB_PC_DATA_OFFS;
153 dest->qkey = IB_DEFAULT_QP1_QKEY;
156 return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf);
158 return madrpc(&rpc, dest, rcvbuf, rcvbuf);
163 performance_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
164 unsigned timeout, unsigned id)
166 return performance_reset_via(rcvbuf, dest, port, mask, timeout,
171 port_performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port,
172 unsigned mask, unsigned timeout, const void *srcport)
174 return performance_reset_via(rcvbuf, dest, port, mask, timeout,
175 IB_GSI_PORT_COUNTERS, srcport);
179 port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
182 return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS);
186 port_performance_ext_query_via(void *rcvbuf, ib_portid_t *dest, int port,
187 unsigned timeout, const void *srcport)
189 return pma_query_via(rcvbuf, dest, port, timeout,
190 IB_GSI_PORT_COUNTERS_EXT, srcport);
194 port_performance_ext_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
196 return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS_EXT);
200 port_performance_ext_reset_via(void *rcvbuf, ib_portid_t *dest, int port,
201 unsigned mask, unsigned timeout,
204 return performance_reset_via(rcvbuf, dest, port, mask, timeout,
205 IB_GSI_PORT_COUNTERS_EXT, srcport);
209 port_performance_ext_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
212 return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS_EXT);
216 port_samples_control_query_via(void *rcvbuf, ib_portid_t *dest, int port,
217 unsigned timeout, const void *srcport)
219 return pma_query_via(rcvbuf, dest, port, timeout,
220 IB_GSI_PORT_SAMPLES_CONTROL, srcport);
224 port_samples_control_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
226 return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_CONTROL);
230 port_samples_result_query_via(void *rcvbuf, ib_portid_t *dest, int port,
231 unsigned timeout, const void *srcport)
233 return pma_query_via(rcvbuf, dest, port, timeout,
234 IB_GSI_PORT_SAMPLES_RESULT, srcport);
238 port_samples_result_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
240 return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_RESULT);