[PATCH] IB: Add RMPP implementation
[deliverable/linux.git] / drivers / infiniband / include / ib_sa.h
CommitLineData
1da177e4
LT
1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 *
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:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
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.
22 *
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
30 * SOFTWARE.
31 *
32 * $Id: ib_sa.h 1389 2004-12-27 22:56:47Z roland $
33 */
34
35#ifndef IB_SA_H
36#define IB_SA_H
37
38#include <linux/compiler.h>
39
40#include <ib_verbs.h>
41#include <ib_mad.h>
42
43enum {
44 IB_SA_CLASS_VERSION = 2, /* IB spec version 1.1/1.2 */
45
46 IB_SA_METHOD_DELETE = 0x15
47};
48
49enum ib_sa_selector {
50 IB_SA_GTE = 0,
51 IB_SA_LTE = 1,
52 IB_SA_EQ = 2,
53 /*
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.
58 */
59 IB_SA_BEST = 3
60};
61
62enum ib_sa_rate {
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
72};
73
74static inline int ib_sa_rate_enum_to_int(enum ib_sa_rate rate)
75{
76 switch (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;
86 default: return -1;
87 }
88}
89
1da177e4
LT
90/*
91 * Structures for SA records are named "struct ib_sa_xxx_rec." No
92 * attempt is made to pack structures to match the physical layout of
93 * SA records in SA MADs; all packing and unpacking is handled by the
94 * SA query code.
95 *
96 * For a record with structure ib_sa_xxx_rec, the naming convention
97 * for the component mask value for field yyy is IB_SA_XXX_REC_YYY (we
98 * never use different abbreviations or otherwise change the spelling
99 * of xxx/yyy between ib_sa_xxx_rec.yyy and IB_SA_XXX_REC_YYY).
100 *
101 * Reserved rows are indicated with comments to help maintainability.
102 */
103
104/* reserved: 0 */
105/* reserved: 1 */
106#define IB_SA_PATH_REC_DGID IB_SA_COMP_MASK( 2)
107#define IB_SA_PATH_REC_SGID IB_SA_COMP_MASK( 3)
108#define IB_SA_PATH_REC_DLID IB_SA_COMP_MASK( 4)
109#define IB_SA_PATH_REC_SLID IB_SA_COMP_MASK( 5)
110#define IB_SA_PATH_REC_RAW_TRAFFIC IB_SA_COMP_MASK( 6)
111/* reserved: 7 */
112#define IB_SA_PATH_REC_FLOW_LABEL IB_SA_COMP_MASK( 8)
113#define IB_SA_PATH_REC_HOP_LIMIT IB_SA_COMP_MASK( 9)
114#define IB_SA_PATH_REC_TRAFFIC_CLASS IB_SA_COMP_MASK(10)
115#define IB_SA_PATH_REC_REVERSIBLE IB_SA_COMP_MASK(11)
116#define IB_SA_PATH_REC_NUMB_PATH IB_SA_COMP_MASK(12)
117#define IB_SA_PATH_REC_PKEY IB_SA_COMP_MASK(13)
118/* reserved: 14 */
119#define IB_SA_PATH_REC_SL IB_SA_COMP_MASK(15)
120#define IB_SA_PATH_REC_MTU_SELECTOR IB_SA_COMP_MASK(16)
121#define IB_SA_PATH_REC_MTU IB_SA_COMP_MASK(17)
122#define IB_SA_PATH_REC_RATE_SELECTOR IB_SA_COMP_MASK(18)
123#define IB_SA_PATH_REC_RATE IB_SA_COMP_MASK(19)
124#define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(20)
125#define IB_SA_PATH_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(21)
126#define IB_SA_PATH_REC_PREFERENCE IB_SA_COMP_MASK(22)
127
128struct ib_sa_path_rec {
129 /* reserved */
130 /* reserved */
131 union ib_gid dgid;
132 union ib_gid sgid;
133 u16 dlid;
134 u16 slid;
135 int raw_traffic;
136 /* reserved */
137 u32 flow_label;
138 u8 hop_limit;
139 u8 traffic_class;
140 int reversible;
141 u8 numb_path;
142 u16 pkey;
143 /* reserved */
144 u8 sl;
145 u8 mtu_selector;
3bf4fb82 146 u8 mtu;
1da177e4
LT
147 u8 rate_selector;
148 u8 rate;
149 u8 packet_life_time_selector;
150 u8 packet_life_time;
151 u8 preference;
152};
153
154#define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0)
155#define IB_SA_MCMEMBER_REC_PORT_GID IB_SA_COMP_MASK( 1)
156#define IB_SA_MCMEMBER_REC_QKEY IB_SA_COMP_MASK( 2)
157#define IB_SA_MCMEMBER_REC_MLID IB_SA_COMP_MASK( 3)
158#define IB_SA_MCMEMBER_REC_MTU_SELECTOR IB_SA_COMP_MASK( 4)
159#define IB_SA_MCMEMBER_REC_MTU IB_SA_COMP_MASK( 5)
160#define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS IB_SA_COMP_MASK( 6)
161#define IB_SA_MCMEMBER_REC_PKEY IB_SA_COMP_MASK( 7)
162#define IB_SA_MCMEMBER_REC_RATE_SELECTOR IB_SA_COMP_MASK( 8)
163#define IB_SA_MCMEMBER_REC_RATE IB_SA_COMP_MASK( 9)
164#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(10)
165#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(11)
166#define IB_SA_MCMEMBER_REC_SL IB_SA_COMP_MASK(12)
167#define IB_SA_MCMEMBER_REC_FLOW_LABEL IB_SA_COMP_MASK(13)
168#define IB_SA_MCMEMBER_REC_HOP_LIMIT IB_SA_COMP_MASK(14)
169#define IB_SA_MCMEMBER_REC_SCOPE IB_SA_COMP_MASK(15)
170#define IB_SA_MCMEMBER_REC_JOIN_STATE IB_SA_COMP_MASK(16)
171#define IB_SA_MCMEMBER_REC_PROXY_JOIN IB_SA_COMP_MASK(17)
172
173struct ib_sa_mcmember_rec {
174 union ib_gid mgid;
175 union ib_gid port_gid;
176 u32 qkey;
177 u16 mlid;
178 u8 mtu_selector;
3bf4fb82 179 u8 mtu;
1da177e4
LT
180 u8 traffic_class;
181 u16 pkey;
182 u8 rate_selector;
183 u8 rate;
184 u8 packet_life_time_selector;
185 u8 packet_life_time;
186 u8 sl;
187 u32 flow_label;
188 u8 hop_limit;
189 u8 scope;
190 u8 join_state;
191 int proxy_join;
192};
193
194struct ib_sa_query;
195
196void ib_sa_cancel_query(int id, struct ib_sa_query *query);
197
198int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
199 struct ib_sa_path_rec *rec,
200 ib_sa_comp_mask comp_mask,
201 int timeout_ms, int gfp_mask,
202 void (*callback)(int status,
203 struct ib_sa_path_rec *resp,
204 void *context),
205 void *context,
206 struct ib_sa_query **query);
207
208int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
209 u8 method,
210 struct ib_sa_mcmember_rec *rec,
211 ib_sa_comp_mask comp_mask,
212 int timeout_ms, int gfp_mask,
213 void (*callback)(int status,
214 struct ib_sa_mcmember_rec *resp,
215 void *context),
216 void *context,
217 struct ib_sa_query **query);
218
219/**
220 * ib_sa_mcmember_rec_set - Start an MCMember set query
221 * @device:device to send query on
222 * @port_num: port number to send query on
223 * @rec:MCMember Record to send in query
224 * @comp_mask:component mask to send in query
225 * @timeout_ms:time to wait for response
226 * @gfp_mask:GFP mask to use for internal allocations
227 * @callback:function called when query completes, times out or is
228 * canceled
229 * @context:opaque user context passed to callback
230 * @sa_query:query context, used to cancel query
231 *
232 * Send an MCMember Set query to the SA (eg to join a multicast
233 * group). The callback function will be called when the query
234 * completes (or fails); status is 0 for a successful response, -EINTR
235 * if the query is canceled, -ETIMEDOUT is the query timed out, or
236 * -EIO if an error occurred sending the query. The resp parameter of
237 * the callback is only valid if status is 0.
238 *
239 * If the return value of ib_sa_mcmember_rec_set() is negative, it is
240 * an error code. Otherwise it is a query ID that can be used to
241 * cancel the query.
242 */
243static inline int
244ib_sa_mcmember_rec_set(struct ib_device *device, u8 port_num,
245 struct ib_sa_mcmember_rec *rec,
246 ib_sa_comp_mask comp_mask,
247 int timeout_ms, int gfp_mask,
248 void (*callback)(int status,
249 struct ib_sa_mcmember_rec *resp,
250 void *context),
251 void *context,
252 struct ib_sa_query **query)
253{
254 return ib_sa_mcmember_rec_query(device, port_num,
255 IB_MGMT_METHOD_SET,
256 rec, comp_mask,
257 timeout_ms, gfp_mask, callback,
258 context, query);
259}
260
261/**
262 * ib_sa_mcmember_rec_delete - Start an MCMember delete query
263 * @device:device to send query on
264 * @port_num: port number to send query on
265 * @rec:MCMember Record to send in query
266 * @comp_mask:component mask to send in query
267 * @timeout_ms:time to wait for response
268 * @gfp_mask:GFP mask to use for internal allocations
269 * @callback:function called when query completes, times out or is
270 * canceled
271 * @context:opaque user context passed to callback
272 * @sa_query:query context, used to cancel query
273 *
274 * Send an MCMember Delete query to the SA (eg to leave a multicast
275 * group). The callback function will be called when the query
276 * completes (or fails); status is 0 for a successful response, -EINTR
277 * if the query is canceled, -ETIMEDOUT is the query timed out, or
278 * -EIO if an error occurred sending the query. The resp parameter of
279 * the callback is only valid if status is 0.
280 *
281 * If the return value of ib_sa_mcmember_rec_delete() is negative, it
282 * is an error code. Otherwise it is a query ID that can be used to
283 * cancel the query.
284 */
285static inline int
286ib_sa_mcmember_rec_delete(struct ib_device *device, u8 port_num,
287 struct ib_sa_mcmember_rec *rec,
288 ib_sa_comp_mask comp_mask,
289 int timeout_ms, int gfp_mask,
290 void (*callback)(int status,
291 struct ib_sa_mcmember_rec *resp,
292 void *context),
293 void *context,
294 struct ib_sa_query **query)
295{
296 return ib_sa_mcmember_rec_query(device, port_num,
297 IB_SA_METHOD_DELETE,
298 rec, comp_mask,
299 timeout_ms, gfp_mask, callback,
300 context, query);
301}
302
303
304#endif /* IB_SA_H */
This page took 0.064849 seconds and 5 git commands to generate.