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 */
46 #include <infiniband/common.h>
49 #define DEBUG if (ibdebug) IBWARN
52 sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t *portid,
53 ib_sa_call_t *sa, unsigned timeout)
58 DEBUG("attr 0x%x mod 0x%x route %s", sa->attrid, sa->mod,
61 if (portid->lid <= 0) {
62 IBWARN("only lid routes are supported");
66 rpc.mgtclass = IB_SA_CLASS;
67 rpc.method = sa->method;
68 rpc.attr.id = sa->attrid;
69 rpc.attr.mod = sa->mod;
71 rpc.timeout = timeout;
72 rpc.datasz = IB_SA_DATA_SIZE;
73 rpc.dataoffs = IB_SA_DATA_OFFS;
78 portid->qkey = IB_DEFAULT_QP1_QKEY;
80 p = mad_rpc_rmpp(ibmad_port, &rpc, portid, 0/*&sa->rmpp*/, rcvbuf); /* TODO: RMPP */
82 sa->recsz = rpc.recsz;
88 #define IB_PR_COMPMASK_DGID (1ull<<2)
89 #define IB_PR_COMPMASK_SGID (1ull<<3)
90 #define IB_PR_COMPMASK_DLID (1ull<<4)
91 #define IB_PR_COMPMASK_SLID (1ull<<5)
92 #define IB_PR_COMPMASK_RAWTRAFIC (1ull<<6)
93 #define IB_PR_COMPMASK_RESV0 (1ull<<7)
94 #define IB_PR_COMPMASK_FLOWLABEL (1ull<<8)
95 #define IB_PR_COMPMASK_HOPLIMIT (1ull<<9)
96 #define IB_PR_COMPMASK_TCLASS (1ull<<10)
97 #define IB_PR_COMPMASK_REVERSIBLE (1ull<<11)
98 #define IB_PR_COMPMASK_NUMBPATH (1ull<<12)
99 #define IB_PR_COMPMASK_PKEY (1ull<<13)
100 #define IB_PR_COMPMASK_RESV1 (1ull<<14)
101 #define IB_PR_COMPMASK_SL (1ull<<15)
102 #define IB_PR_COMPMASK_MTUSELEC (1ull<<16)
103 #define IB_PR_COMPMASK_MTU (1ull<<17)
104 #define IB_PR_COMPMASK_RATESELEC (1ull<<18)
105 #define IB_PR_COMPMASK_RATE (1ull<<19)
106 #define IB_PR_COMPMASK_PKTLIFETIMESELEC (1ull<<20)
107 #define IB_PR_COMPMASK_PKTLIFETIME (1ull<<21)
108 #define IB_PR_COMPMASK_PREFERENCE (1ull<<22)
110 #define IB_PR_DEF_MASK (IB_PR_COMPMASK_DGID |\
111 IB_PR_COMPMASK_SGID |\
112 IB_PR_COMPMASK_NUMBPATH)
115 ib_path_query_via(const void *srcport, ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t *sm_id, void *buf)
118 ib_sa_call_t sa = {0};
122 npath = 1; /* only MAD_METHOD_GET is supported */
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_NPATH_F, &npath);
132 mad_encode_field(buf, IB_SA_PR_DGID_F, destgid);
133 mad_encode_field(buf, IB_SA_PR_SGID_F, srcgid);
136 p = sa_rpc_call (srcport, buf, sm_id, &sa, 0);
138 p = safe_sa_call(buf, sm_id, &sa, 0);
141 IBWARN("sa call path_query failed");
145 mad_decode_field(p, IB_SA_PR_DLID_F, &dlid);
149 ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t *sm_id, void *buf)
151 return ib_path_query_via (NULL, srcgid, destgid, sm_id, buf);