2 * Copyright (c) 2004-2009 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 */
42 #include <infiniband/umad.h>
43 #include <infiniband/mad.h>
44 #include "mad_internal.h"
47 #define DEBUG if (ibdebug) IBWARN
49 uint8_t *sa_rpc_call(const struct ibmad_port *ibmad_port, void *rcvbuf,
50 ib_portid_t * portid, ib_sa_call_t * sa, unsigned timeout)
55 DEBUG("attr 0x%x mod 0x%x route %s", sa->attrid, sa->mod,
58 if (portid->lid <= 0) {
59 IBWARN("only lid routes are supported");
63 rpc.mgtclass = IB_SA_CLASS;
64 rpc.method = sa->method;
65 rpc.attr.id = sa->attrid;
66 rpc.attr.mod = sa->mod;
68 rpc.timeout = timeout;
69 rpc.datasz = IB_SA_DATA_SIZE;
70 rpc.dataoffs = IB_SA_DATA_OFFS;
75 portid->qkey = IB_DEFAULT_QP1_QKEY;
77 p = mad_rpc_rmpp(ibmad_port, &rpc, portid, 0 /*&sa->rmpp */ , rcvbuf); /* TODO: RMPP */
79 sa->recsz = rpc.recsz;
84 uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa,
87 return sa_rpc_call(ibmp, rcvbuf, portid, sa, timeout);
91 #define IB_PR_COMPMASK_DGID (1ull<<2)
92 #define IB_PR_COMPMASK_SGID (1ull<<3)
93 #define IB_PR_COMPMASK_DLID (1ull<<4)
94 #define IB_PR_COMPMASK_SLID (1ull<<5)
95 #define IB_PR_COMPMASK_RAWTRAFIC (1ull<<6)
96 #define IB_PR_COMPMASK_RESV0 (1ull<<7)
97 #define IB_PR_COMPMASK_FLOWLABEL (1ull<<8)
98 #define IB_PR_COMPMASK_HOPLIMIT (1ull<<9)
99 #define IB_PR_COMPMASK_TCLASS (1ull<<10)
100 #define IB_PR_COMPMASK_REVERSIBLE (1ull<<11)
101 #define IB_PR_COMPMASK_NUMBPATH (1ull<<12)
102 #define IB_PR_COMPMASK_PKEY (1ull<<13)
103 #define IB_PR_COMPMASK_RESV1 (1ull<<14)
104 #define IB_PR_COMPMASK_SL (1ull<<15)
105 #define IB_PR_COMPMASK_MTUSELEC (1ull<<16)
106 #define IB_PR_COMPMASK_MTU (1ull<<17)
107 #define IB_PR_COMPMASK_RATESELEC (1ull<<18)
108 #define IB_PR_COMPMASK_RATE (1ull<<19)
109 #define IB_PR_COMPMASK_PKTLIFETIMESELEC (1ull<<20)
110 #define IB_PR_COMPMASK_PKTLIFETIME (1ull<<21)
111 #define IB_PR_COMPMASK_PREFERENCE (1ull<<22)
113 #define IB_PR_DEF_MASK (IB_PR_COMPMASK_DGID |\
116 int ib_path_query_via(const struct ibmad_port *srcport, ibmad_gid_t srcgid,
117 ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf)
119 ib_sa_call_t sa = { 0 };
123 memset(&sa, 0, sizeof sa);
124 sa.method = IB_MAD_METHOD_GET;
125 sa.attrid = IB_SA_ATTR_PATHRECORD;
126 sa.mask = IB_PR_DEF_MASK;
127 sa.trid = mad_trid();
129 memset(buf, 0, IB_SA_PR_RECSZ);
131 mad_encode_field(buf, IB_SA_PR_DGID_F, destgid);
132 mad_encode_field(buf, IB_SA_PR_SGID_F, srcgid);
134 p = sa_rpc_call(srcport, buf, sm_id, &sa, 0);
136 IBWARN("sa call path_query failed");
140 mad_decode_field(p, IB_SA_PR_DLID_F, &dlid);
144 int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id,
147 return ib_path_query_via(ibmp, srcgid, destgid, sm_id, buf);
151 #define IB_NR_COMPMASK_LID (1ull<<0)
152 #define IB_NR_COMPMASK_RESERVED1 (1ull<<1)
153 #define IB_NR_COMPMASK_BASEVERSION (1ull<<2)
154 #define IB_NR_COMPMASK_CLASSVERSION (1ull<<3)
155 #define IB_NR_COMPMASK_NODETYPE (1ull<<4)
156 #define IB_NR_COMPMASK_NUMPORTS (1ull<<5)
157 #define IB_NR_COMPMASK_SYSIMAGEGUID (1ull<<6)
158 #define IB_NR_COMPMASK_NODEGUID (1ull<<7)
159 #define IB_NR_COMPMASK_PORTGUID (1ull<<8)
160 #define IB_NR_COMPMASK_PARTCAP (1ull<<9)
161 #define IB_NR_COMPMASK_DEVID (1ull<<10)
162 #define IB_NR_COMPMASK_REV (1ull<<11)
163 #define IB_NR_COMPMASK_PORTNUM (1ull<<12)
164 #define IB_NR_COMPMASK_VENDID (1ull<<13)
165 #define IB_NR_COMPMASK_NODEDESC (1ull<<14)
167 #define IB_NR_DEF_MASK IB_NR_COMPMASK_PORTGUID
169 int ib_node_query_via(const struct ibmad_port *srcport, uint64_t guid,
170 ib_portid_t * sm_id, void *buf)
172 ib_sa_call_t sa = { 0 };
175 memset(&sa, 0, sizeof sa);
176 sa.method = IB_MAD_METHOD_GET;
177 sa.attrid = IB_SA_ATTR_NODERECORD;
178 sa.mask = IB_NR_DEF_MASK;
179 sa.trid = mad_trid();
181 memset(buf, 0, IB_SA_NR_RECSZ);
183 mad_encode_field(buf, IB_SA_NR_PORT_GUID_F, &guid);
185 p = sa_rpc_call(srcport, buf, sm_id, &sa, 0);
187 IBWARN("sa call node_query failed");