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>
48 #define DEBUG if (ibdebug) IBWARN
50 uint8_t *pma_query_via(void *rcvbuf, ib_portid_t * dest, int port,
51 unsigned timeout, unsigned id,
52 const struct ibmad_port * srcport)
54 ib_rpc_v1_t rpc = { 0 };
55 ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
59 DEBUG("lid %u port %d", lid, port);
62 IBWARN("only lid routed is supported");
66 rpc.mgtclass = IB_PERFORMANCE_CLASS | IB_MAD_RPC_VERSION1;
67 rpc.method = IB_MAD_METHOD_GET;
70 /* Same for attribute IDs */
71 mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
73 rpc.timeout = timeout;
74 rpc.datasz = IB_PC_DATA_SZ;
75 rpc.dataoffs = IB_PC_DATA_OFFS;
80 dest->qkey = IB_DEFAULT_QP1_QKEY;
82 p_ret = mad_rpc(srcport, rpcold, dest, rcvbuf, rcvbuf);
87 uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest,
88 int port, unsigned mask, unsigned timeout,
89 unsigned id, const struct ibmad_port * srcport)
91 ib_rpc_v1_t rpc = { 0 };
92 ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
97 DEBUG("lid %u port %d mask 0x%x", lid, port, mask);
100 IBWARN("only lid routed is supported");
107 rpc.mgtclass = IB_PERFORMANCE_CLASS | IB_MAD_RPC_VERSION1;
108 rpc.method = IB_MAD_METHOD_SET;
111 memset(rcvbuf, 0, IB_MAD_SIZE);
113 /* Next 2 lines - same for attribute IDs */
114 mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
115 mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT_F, mask);
117 if (id == IB_GSI_PORT_COUNTERS_EXT)
118 mad_set_field(rcvbuf, 0, IB_PC_EXT_COUNTER_SELECT2_F, mask);
120 mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT2_F, mask);
122 rpc.timeout = timeout;
123 rpc.datasz = IB_PC_DATA_SZ;
124 rpc.dataoffs = IB_PC_DATA_OFFS;
128 dest->qkey = IB_DEFAULT_QP1_QKEY;
130 p_ret = mad_rpc(srcport, rpcold, dest, rcvbuf, rcvbuf);