2 * Copyright (c) 2004 Topspin Communications. 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
32 * $Id: ib_sa.h 1389 2004-12-27 22:56:47Z roland $
38 #include <linux/compiler.h>
44 IB_SA_CLASS_VERSION
= 2, /* IB spec version 1.1/1.2 */
46 IB_SA_METHOD_DELETE
= 0x15
54 * The meaning of "best" depends on the attribute: for
55 * example, for MTU best will return the largest available
56 * MTU, while for packet life time, best will return the
57 * smallest available life time.
63 IB_SA_RATE_2_5_GBPS
= 2,
64 IB_SA_RATE_5_GBPS
= 5,
65 IB_SA_RATE_10_GBPS
= 3,
66 IB_SA_RATE_20_GBPS
= 6,
67 IB_SA_RATE_30_GBPS
= 4,
68 IB_SA_RATE_40_GBPS
= 7,
69 IB_SA_RATE_60_GBPS
= 8,
70 IB_SA_RATE_80_GBPS
= 9,
71 IB_SA_RATE_120_GBPS
= 10
74 static inline int ib_sa_rate_enum_to_int(enum ib_sa_rate rate
)
77 case IB_SA_RATE_2_5_GBPS
: return 1;
78 case IB_SA_RATE_5_GBPS
: return 2;
79 case IB_SA_RATE_10_GBPS
: return 4;
80 case IB_SA_RATE_20_GBPS
: return 8;
81 case IB_SA_RATE_30_GBPS
: return 12;
82 case IB_SA_RATE_40_GBPS
: return 16;
83 case IB_SA_RATE_60_GBPS
: return 24;
84 case IB_SA_RATE_80_GBPS
: return 32;
85 case IB_SA_RATE_120_GBPS
: return 48;
90 typedef u64 __bitwise ib_sa_comp_mask
;
92 #define IB_SA_COMP_MASK(n) ((__force ib_sa_comp_mask) cpu_to_be64(1ull << n))
95 * Structures for SA records are named "struct ib_sa_xxx_rec." No
96 * attempt is made to pack structures to match the physical layout of
97 * SA records in SA MADs; all packing and unpacking is handled by the
100 * For a record with structure ib_sa_xxx_rec, the naming convention
101 * for the component mask value for field yyy is IB_SA_XXX_REC_YYY (we
102 * never use different abbreviations or otherwise change the spelling
103 * of xxx/yyy between ib_sa_xxx_rec.yyy and IB_SA_XXX_REC_YYY).
105 * Reserved rows are indicated with comments to help maintainability.
110 #define IB_SA_PATH_REC_DGID IB_SA_COMP_MASK( 2)
111 #define IB_SA_PATH_REC_SGID IB_SA_COMP_MASK( 3)
112 #define IB_SA_PATH_REC_DLID IB_SA_COMP_MASK( 4)
113 #define IB_SA_PATH_REC_SLID IB_SA_COMP_MASK( 5)
114 #define IB_SA_PATH_REC_RAW_TRAFFIC IB_SA_COMP_MASK( 6)
116 #define IB_SA_PATH_REC_FLOW_LABEL IB_SA_COMP_MASK( 8)
117 #define IB_SA_PATH_REC_HOP_LIMIT IB_SA_COMP_MASK( 9)
118 #define IB_SA_PATH_REC_TRAFFIC_CLASS IB_SA_COMP_MASK(10)
119 #define IB_SA_PATH_REC_REVERSIBLE IB_SA_COMP_MASK(11)
120 #define IB_SA_PATH_REC_NUMB_PATH IB_SA_COMP_MASK(12)
121 #define IB_SA_PATH_REC_PKEY IB_SA_COMP_MASK(13)
123 #define IB_SA_PATH_REC_SL IB_SA_COMP_MASK(15)
124 #define IB_SA_PATH_REC_MTU_SELECTOR IB_SA_COMP_MASK(16)
125 #define IB_SA_PATH_REC_MTU IB_SA_COMP_MASK(17)
126 #define IB_SA_PATH_REC_RATE_SELECTOR IB_SA_COMP_MASK(18)
127 #define IB_SA_PATH_REC_RATE IB_SA_COMP_MASK(19)
128 #define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(20)
129 #define IB_SA_PATH_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(21)
130 #define IB_SA_PATH_REC_PREFERENCE IB_SA_COMP_MASK(22)
132 struct ib_sa_path_rec
{
153 u8 packet_life_time_selector
;
158 #define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0)
159 #define IB_SA_MCMEMBER_REC_PORT_GID IB_SA_COMP_MASK( 1)
160 #define IB_SA_MCMEMBER_REC_QKEY IB_SA_COMP_MASK( 2)
161 #define IB_SA_MCMEMBER_REC_MLID IB_SA_COMP_MASK( 3)
162 #define IB_SA_MCMEMBER_REC_MTU_SELECTOR IB_SA_COMP_MASK( 4)
163 #define IB_SA_MCMEMBER_REC_MTU IB_SA_COMP_MASK( 5)
164 #define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS IB_SA_COMP_MASK( 6)
165 #define IB_SA_MCMEMBER_REC_PKEY IB_SA_COMP_MASK( 7)
166 #define IB_SA_MCMEMBER_REC_RATE_SELECTOR IB_SA_COMP_MASK( 8)
167 #define IB_SA_MCMEMBER_REC_RATE IB_SA_COMP_MASK( 9)
168 #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(10)
169 #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(11)
170 #define IB_SA_MCMEMBER_REC_SL IB_SA_COMP_MASK(12)
171 #define IB_SA_MCMEMBER_REC_FLOW_LABEL IB_SA_COMP_MASK(13)
172 #define IB_SA_MCMEMBER_REC_HOP_LIMIT IB_SA_COMP_MASK(14)
173 #define IB_SA_MCMEMBER_REC_SCOPE IB_SA_COMP_MASK(15)
174 #define IB_SA_MCMEMBER_REC_JOIN_STATE IB_SA_COMP_MASK(16)
175 #define IB_SA_MCMEMBER_REC_PROXY_JOIN IB_SA_COMP_MASK(17)
177 struct ib_sa_mcmember_rec
{
179 union ib_gid port_gid
;
188 u8 packet_life_time_selector
;
200 void ib_sa_cancel_query(int id
, struct ib_sa_query
*query
);
202 int ib_sa_path_rec_get(struct ib_device
*device
, u8 port_num
,
203 struct ib_sa_path_rec
*rec
,
204 ib_sa_comp_mask comp_mask
,
205 int timeout_ms
, int gfp_mask
,
206 void (*callback
)(int status
,
207 struct ib_sa_path_rec
*resp
,
210 struct ib_sa_query
**query
);
212 int ib_sa_mcmember_rec_query(struct ib_device
*device
, u8 port_num
,
214 struct ib_sa_mcmember_rec
*rec
,
215 ib_sa_comp_mask comp_mask
,
216 int timeout_ms
, int gfp_mask
,
217 void (*callback
)(int status
,
218 struct ib_sa_mcmember_rec
*resp
,
221 struct ib_sa_query
**query
);
224 * ib_sa_mcmember_rec_set - Start an MCMember set query
225 * @device:device to send query on
226 * @port_num: port number to send query on
227 * @rec:MCMember Record to send in query
228 * @comp_mask:component mask to send in query
229 * @timeout_ms:time to wait for response
230 * @gfp_mask:GFP mask to use for internal allocations
231 * @callback:function called when query completes, times out or is
233 * @context:opaque user context passed to callback
234 * @sa_query:query context, used to cancel query
236 * Send an MCMember Set query to the SA (eg to join a multicast
237 * group). The callback function will be called when the query
238 * completes (or fails); status is 0 for a successful response, -EINTR
239 * if the query is canceled, -ETIMEDOUT is the query timed out, or
240 * -EIO if an error occurred sending the query. The resp parameter of
241 * the callback is only valid if status is 0.
243 * If the return value of ib_sa_mcmember_rec_set() is negative, it is
244 * an error code. Otherwise it is a query ID that can be used to
248 ib_sa_mcmember_rec_set(struct ib_device
*device
, u8 port_num
,
249 struct ib_sa_mcmember_rec
*rec
,
250 ib_sa_comp_mask comp_mask
,
251 int timeout_ms
, int gfp_mask
,
252 void (*callback
)(int status
,
253 struct ib_sa_mcmember_rec
*resp
,
256 struct ib_sa_query
**query
)
258 return ib_sa_mcmember_rec_query(device
, port_num
,
261 timeout_ms
, gfp_mask
, callback
,
266 * ib_sa_mcmember_rec_delete - Start an MCMember delete query
267 * @device:device to send query on
268 * @port_num: port number to send query on
269 * @rec:MCMember Record to send in query
270 * @comp_mask:component mask to send in query
271 * @timeout_ms:time to wait for response
272 * @gfp_mask:GFP mask to use for internal allocations
273 * @callback:function called when query completes, times out or is
275 * @context:opaque user context passed to callback
276 * @sa_query:query context, used to cancel query
278 * Send an MCMember Delete query to the SA (eg to leave a multicast
279 * group). The callback function will be called when the query
280 * completes (or fails); status is 0 for a successful response, -EINTR
281 * if the query is canceled, -ETIMEDOUT is the query timed out, or
282 * -EIO if an error occurred sending the query. The resp parameter of
283 * the callback is only valid if status is 0.
285 * If the return value of ib_sa_mcmember_rec_delete() is negative, it
286 * is an error code. Otherwise it is a query ID that can be used to
290 ib_sa_mcmember_rec_delete(struct ib_device
*device
, u8 port_num
,
291 struct ib_sa_mcmember_rec
*rec
,
292 ib_sa_comp_mask comp_mask
,
293 int timeout_ms
, int gfp_mask
,
294 void (*callback
)(int status
,
295 struct ib_sa_mcmember_rec
*resp
,
298 struct ib_sa_query
**query
)
300 return ib_sa_mcmember_rec_query(device
, port_num
,
303 timeout_ms
, gfp_mask
, callback
,