2 * Copyright (c) 2004-2007 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
31 # include <config.h>
\r
32 #endif /* HAVE_CONFIG_H */
\r
37 #if defined(_WIN32) || defined(_WIN64)
\r
38 #include <windows.h>
\r
39 #include <winsock2.h>
\r
43 #include <pthread.h>
\r
44 #include <sys/time.h>
\r
47 #include <infiniband/umad.h>
\r
51 #define DEBUG if (ibdebug) IBWARN
\r
54 pma_query_via(void *rcvbuf, ib_portid_t *dest, int port,
\r
55 unsigned timeout, unsigned id, const void *srcport)
\r
58 int lid = dest->lid;
\r
60 DEBUG("lid %d port %d", lid, port);
\r
63 IBWARN("only lid routed is supported");
\r
67 rpc.mgtclass = IB_PERFORMANCE_CLASS;
\r
68 rpc.method = IB_MAD_METHOD_GET;
\r
71 /* Same for attribute IDs */
\r
72 mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
\r
74 rpc.timeout = timeout;
\r
75 rpc.datasz = IB_PC_DATA_SZ;
\r
76 rpc.dataoffs = IB_PC_DATA_OFFS;
\r
80 dest->qkey = IB_DEFAULT_QP1_QKEY;
\r
83 return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf);
\r
85 return madrpc(&rpc, dest, rcvbuf, rcvbuf);
\r
90 pma_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout, unsigned id)
\r
92 return pma_query_via(rcvbuf, dest, port, timeout, id, NULL);
\r
96 perf_classportinfo_query_via(void *rcvbuf, ib_portid_t *dest, int port,
\r
97 unsigned timeout, const void *srcport)
\r
99 return pma_query_via(rcvbuf, dest, port, timeout, CLASS_PORT_INFO,
\r
103 MAD_EXPORT uint8_t *
\r
104 perf_classportinfo_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
\r
106 return pma_query(rcvbuf, dest, port, timeout, CLASS_PORT_INFO);
\r
110 port_performance_query_via(void *rcvbuf, ib_portid_t *dest, int port,
\r
111 unsigned timeout, const void *srcport)
\r
113 return pma_query_via(rcvbuf, dest, port, timeout,
\r
114 IB_GSI_PORT_COUNTERS, srcport);
\r
117 MAD_EXPORT uint8_t *
\r
118 port_performance_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
\r
120 return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS);
\r
124 performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
\r
125 unsigned timeout, unsigned id, const void *srcport)
\r
127 ib_rpc_t rpc = {0};
\r
128 int lid = dest->lid;
\r
130 DEBUG("lid %d port %d mask 0x%x", lid, port, mask);
\r
133 IBWARN("only lid routed is supported");
\r
140 rpc.mgtclass = IB_PERFORMANCE_CLASS;
\r
141 rpc.method = IB_MAD_METHOD_SET;
\r
144 memset(rcvbuf, 0, IB_MAD_SIZE);
\r
146 /* Same for attribute IDs */
\r
147 mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
\r
148 mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT_F, mask);
\r
150 rpc.timeout = timeout;
\r
151 rpc.datasz = IB_PC_DATA_SZ;
\r
152 rpc.dataoffs = IB_PC_DATA_OFFS;
\r
155 dest->qkey = IB_DEFAULT_QP1_QKEY;
\r
158 return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf);
\r
160 return madrpc(&rpc, dest, rcvbuf, rcvbuf);
\r
165 performance_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
\r
166 unsigned timeout, unsigned id)
\r
168 return performance_reset_via(rcvbuf, dest, port, mask, timeout,
\r
173 port_performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port,
\r
174 unsigned mask, unsigned timeout, const void *srcport)
\r
176 return performance_reset_via(rcvbuf, dest, port, mask, timeout,
\r
177 IB_GSI_PORT_COUNTERS, srcport);
\r
180 MAD_EXPORT uint8_t *
\r
181 port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
\r
184 return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS);
\r
188 port_performance_ext_query_via(void *rcvbuf, ib_portid_t *dest, int port,
\r
189 unsigned timeout, const void *srcport)
\r
191 return pma_query_via(rcvbuf, dest, port, timeout,
\r
192 IB_GSI_PORT_COUNTERS_EXT, srcport);
\r
195 MAD_EXPORT uint8_t *
\r
196 port_performance_ext_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
\r
198 return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS_EXT);
\r
202 port_performance_ext_reset_via(void *rcvbuf, ib_portid_t *dest, int port,
\r
203 unsigned mask, unsigned timeout,
\r
204 const void *srcport)
\r
206 return performance_reset_via(rcvbuf, dest, port, mask, timeout,
\r
207 IB_GSI_PORT_COUNTERS_EXT, srcport);
\r
210 MAD_EXPORT uint8_t *
\r
211 port_performance_ext_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
\r
214 return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS_EXT);
\r
218 port_samples_control_query_via(void *rcvbuf, ib_portid_t *dest, int port,
\r
219 unsigned timeout, const void *srcport)
\r
221 return pma_query_via(rcvbuf, dest, port, timeout,
\r
222 IB_GSI_PORT_SAMPLES_CONTROL, srcport);
\r
225 MAD_EXPORT uint8_t *
\r
226 port_samples_control_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
\r
228 return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_CONTROL);
\r
232 port_samples_result_query_via(void *rcvbuf, ib_portid_t *dest, int port,
\r
233 unsigned timeout, const void *srcport)
\r
235 return pma_query_via(rcvbuf, dest, port, timeout,
\r
236 IB_GSI_PORT_SAMPLES_RESULT, srcport);
\r
239 MAD_EXPORT uint8_t *
\r
240 port_samples_result_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
\r
242 return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_RESULT);
\r