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
50 #define DEBUG if (ibdebug) IBWARN
\r
53 smp_set_via(void *data, ib_portid_t *portid, unsigned attrid, unsigned mod, unsigned timeout, const void *srcport)
\r
57 DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
\r
58 if ((portid->lid <= 0) ||
\r
59 (portid->drpath.drslid == 0xffff) ||
\r
60 (portid->drpath.drdlid == 0xffff))
\r
61 rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
\r
63 rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
\r
65 rpc.method = IB_MAD_METHOD_SET;
\r
66 rpc.attr.id = attrid;
\r
68 rpc.timeout = timeout;
\r
69 rpc.datasz = IB_SMP_DATA_SIZE;
\r
70 rpc.dataoffs = IB_SMP_DATA_OFFS;
\r
76 return mad_rpc(srcport, &rpc, portid, data, data);
\r
78 return madrpc(&rpc, portid, data, data);
\r
82 MAD_EXPORT uint8_t *
\r
83 smp_set(void *data, ib_portid_t *portid, unsigned attrid, unsigned mod, unsigned timeout)
\r
85 return smp_set_via(data, portid, attrid, mod, timeout, NULL);
\r
89 smp_query_via(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod,
\r
90 unsigned timeout, const void *srcport)
\r
94 DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
\r
95 rpc.method = IB_MAD_METHOD_GET;
\r
96 rpc.attr.id = attrid;
\r
98 rpc.timeout = timeout;
\r
99 rpc.datasz = IB_SMP_DATA_SIZE;
\r
100 rpc.dataoffs = IB_SMP_DATA_OFFS;
\r
102 if ((portid->lid <= 0) ||
\r
103 (portid->drpath.drslid == 0xffff) ||
\r
104 (portid->drpath.drdlid == 0xffff))
\r
105 rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
\r
107 rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
\r
113 return mad_rpc(srcport, &rpc, portid, 0, rcvbuf);
\r
115 return madrpc(&rpc, portid, 0, rcvbuf);
\r
119 MAD_EXPORT uint8_t *
\r
120 smp_query(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod,
\r
123 return smp_query_via(rcvbuf, portid, attrid, mod, timeout, NULL);
\r