1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004 Topspin Communications.  All rights reserved.
3219820Sjeff * Copyright (c) 2005 Voltaire, Inc.  All rights reserved.
4219820Sjeff * Copyright (c) 2006 Intel Corporation.  All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff */
34219820Sjeff
35219820Sjeff#ifndef IB_SA_H
36219820Sjeff#define IB_SA_H
37219820Sjeff
38219820Sjeff#include <linux/completion.h>
39219820Sjeff#include <linux/compiler.h>
40219820Sjeff
41219820Sjeff#include <asm/atomic.h>
42219820Sjeff
43219820Sjeff#include <rdma/ib_verbs.h>
44219820Sjeff#include <rdma/ib_mad.h>
45219820Sjeff
46219820Sjeffenum {
47219820Sjeff	IB_SA_CLASS_VERSION		= 2,	/* IB spec version 1.1/1.2 */
48219820Sjeff
49219820Sjeff	IB_SA_METHOD_GET_TABLE		= 0x12,
50219820Sjeff	IB_SA_METHOD_GET_TABLE_RESP	= 0x92,
51219820Sjeff	IB_SA_METHOD_DELETE		= 0x15,
52219820Sjeff	IB_SA_METHOD_DELETE_RESP	= 0x95,
53219820Sjeff	IB_SA_METHOD_GET_MULTI		= 0x14,
54219820Sjeff	IB_SA_METHOD_GET_MULTI_RESP	= 0x94,
55219820Sjeff	IB_SA_METHOD_GET_TRACE_TBL	= 0x13
56219820Sjeff};
57219820Sjeff
58219820Sjeffenum {
59219820Sjeff	IB_SA_ATTR_CLASS_PORTINFO    = 0x01,
60219820Sjeff	IB_SA_ATTR_NOTICE	     = 0x02,
61219820Sjeff	IB_SA_ATTR_INFORM_INFO	     = 0x03,
62219820Sjeff	IB_SA_ATTR_NODE_REC	     = 0x11,
63219820Sjeff	IB_SA_ATTR_PORT_INFO_REC     = 0x12,
64219820Sjeff	IB_SA_ATTR_SL2VL_REC	     = 0x13,
65219820Sjeff	IB_SA_ATTR_SWITCH_REC	     = 0x14,
66219820Sjeff	IB_SA_ATTR_LINEAR_FDB_REC    = 0x15,
67219820Sjeff	IB_SA_ATTR_RANDOM_FDB_REC    = 0x16,
68219820Sjeff	IB_SA_ATTR_MCAST_FDB_REC     = 0x17,
69219820Sjeff	IB_SA_ATTR_SM_INFO_REC	     = 0x18,
70219820Sjeff	IB_SA_ATTR_LINK_REC	     = 0x20,
71219820Sjeff	IB_SA_ATTR_GUID_INFO_REC     = 0x30,
72219820Sjeff	IB_SA_ATTR_SERVICE_REC	     = 0x31,
73219820Sjeff	IB_SA_ATTR_PARTITION_REC     = 0x33,
74219820Sjeff	IB_SA_ATTR_PATH_REC	     = 0x35,
75219820Sjeff	IB_SA_ATTR_VL_ARB_REC	     = 0x36,
76219820Sjeff	IB_SA_ATTR_MC_MEMBER_REC     = 0x38,
77219820Sjeff	IB_SA_ATTR_TRACE_REC	     = 0x39,
78219820Sjeff	IB_SA_ATTR_MULTI_PATH_REC    = 0x3a,
79219820Sjeff	IB_SA_ATTR_SERVICE_ASSOC_REC = 0x3b,
80219820Sjeff	IB_SA_ATTR_INFORM_INFO_REC   = 0xf3
81219820Sjeff};
82219820Sjeff
83219820Sjeffenum ib_sa_selector {
84219820Sjeff	IB_SA_GT   = 0,
85219820Sjeff	IB_SA_LT   = 1,
86219820Sjeff	IB_SA_EQ   = 2,
87219820Sjeff	/*
88219820Sjeff	 * The meaning of "best" depends on the attribute: for
89219820Sjeff	 * example, for MTU best will return the largest available
90219820Sjeff	 * MTU, while for packet life time, best will return the
91219820Sjeff	 * smallest available life time.
92219820Sjeff	 */
93219820Sjeff	IB_SA_BEST = 3
94219820Sjeff};
95219820Sjeff
96219820Sjeff/*
97219820Sjeff * Structures for SA records are named "struct ib_sa_xxx_rec."  No
98219820Sjeff * attempt is made to pack structures to match the physical layout of
99219820Sjeff * SA records in SA MADs; all packing and unpacking is handled by the
100219820Sjeff * SA query code.
101219820Sjeff *
102219820Sjeff * For a record with structure ib_sa_xxx_rec, the naming convention
103219820Sjeff * for the component mask value for field yyy is IB_SA_XXX_REC_YYY (we
104219820Sjeff * never use different abbreviations or otherwise change the spelling
105219820Sjeff * of xxx/yyy between ib_sa_xxx_rec.yyy and IB_SA_XXX_REC_YYY).
106219820Sjeff *
107219820Sjeff * Reserved rows are indicated with comments to help maintainability.
108219820Sjeff */
109219820Sjeff
110219820Sjeff#define IB_SA_PATH_REC_SERVICE_ID		       (IB_SA_COMP_MASK( 0) |\
111219820Sjeff							IB_SA_COMP_MASK( 1))
112219820Sjeff#define IB_SA_PATH_REC_DGID				IB_SA_COMP_MASK( 2)
113219820Sjeff#define IB_SA_PATH_REC_SGID				IB_SA_COMP_MASK( 3)
114219820Sjeff#define IB_SA_PATH_REC_DLID				IB_SA_COMP_MASK( 4)
115219820Sjeff#define IB_SA_PATH_REC_SLID				IB_SA_COMP_MASK( 5)
116219820Sjeff#define IB_SA_PATH_REC_RAW_TRAFFIC			IB_SA_COMP_MASK( 6)
117219820Sjeff/* reserved:								 7 */
118219820Sjeff#define IB_SA_PATH_REC_FLOW_LABEL       		IB_SA_COMP_MASK( 8)
119219820Sjeff#define IB_SA_PATH_REC_HOP_LIMIT			IB_SA_COMP_MASK( 9)
120219820Sjeff#define IB_SA_PATH_REC_TRAFFIC_CLASS			IB_SA_COMP_MASK(10)
121219820Sjeff#define IB_SA_PATH_REC_REVERSIBLE			IB_SA_COMP_MASK(11)
122219820Sjeff#define IB_SA_PATH_REC_NUMB_PATH			IB_SA_COMP_MASK(12)
123219820Sjeff#define IB_SA_PATH_REC_PKEY				IB_SA_COMP_MASK(13)
124219820Sjeff#define IB_SA_PATH_REC_QOS_CLASS			IB_SA_COMP_MASK(14)
125219820Sjeff#define IB_SA_PATH_REC_SL				IB_SA_COMP_MASK(15)
126219820Sjeff#define IB_SA_PATH_REC_MTU_SELECTOR			IB_SA_COMP_MASK(16)
127219820Sjeff#define IB_SA_PATH_REC_MTU				IB_SA_COMP_MASK(17)
128219820Sjeff#define IB_SA_PATH_REC_RATE_SELECTOR			IB_SA_COMP_MASK(18)
129219820Sjeff#define IB_SA_PATH_REC_RATE				IB_SA_COMP_MASK(19)
130219820Sjeff#define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR	IB_SA_COMP_MASK(20)
131219820Sjeff#define IB_SA_PATH_REC_PACKET_LIFE_TIME			IB_SA_COMP_MASK(21)
132219820Sjeff#define IB_SA_PATH_REC_PREFERENCE			IB_SA_COMP_MASK(22)
133219820Sjeff
134219820Sjeffstruct ib_sa_path_rec {
135219820Sjeff	__be64       service_id;
136219820Sjeff	union ib_gid dgid;
137219820Sjeff	union ib_gid sgid;
138219820Sjeff	__be16       dlid;
139219820Sjeff	__be16       slid;
140219820Sjeff	int          raw_traffic;
141219820Sjeff	/* reserved */
142219820Sjeff	__be32       flow_label;
143219820Sjeff	u8           hop_limit;
144219820Sjeff	u8           traffic_class;
145219820Sjeff	int          reversible;
146219820Sjeff	u8           numb_path;
147219820Sjeff	__be16       pkey;
148219820Sjeff	__be16       qos_class;
149219820Sjeff	u8           sl;
150219820Sjeff	u8           mtu_selector;
151219820Sjeff	u8           mtu;
152219820Sjeff	u8           rate_selector;
153219820Sjeff	u8           rate;
154219820Sjeff	u8           packet_life_time_selector;
155219820Sjeff	u8           packet_life_time;
156219820Sjeff	u8           preference;
157278886Shselasky	u8           smac[ETH_ALEN];
158278886Shselasky	u8           dmac[6];
159278886Shselasky	__be16       vlan_id;
160219820Sjeff};
161219820Sjeff
162219820Sjeff#define IB_SA_MCMEMBER_REC_MGID				IB_SA_COMP_MASK( 0)
163219820Sjeff#define IB_SA_MCMEMBER_REC_PORT_GID			IB_SA_COMP_MASK( 1)
164219820Sjeff#define IB_SA_MCMEMBER_REC_QKEY				IB_SA_COMP_MASK( 2)
165219820Sjeff#define IB_SA_MCMEMBER_REC_MLID				IB_SA_COMP_MASK( 3)
166219820Sjeff#define IB_SA_MCMEMBER_REC_MTU_SELECTOR			IB_SA_COMP_MASK( 4)
167219820Sjeff#define IB_SA_MCMEMBER_REC_MTU				IB_SA_COMP_MASK( 5)
168219820Sjeff#define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS		IB_SA_COMP_MASK( 6)
169219820Sjeff#define IB_SA_MCMEMBER_REC_PKEY				IB_SA_COMP_MASK( 7)
170219820Sjeff#define IB_SA_MCMEMBER_REC_RATE_SELECTOR		IB_SA_COMP_MASK( 8)
171219820Sjeff#define IB_SA_MCMEMBER_REC_RATE				IB_SA_COMP_MASK( 9)
172219820Sjeff#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR	IB_SA_COMP_MASK(10)
173219820Sjeff#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME		IB_SA_COMP_MASK(11)
174219820Sjeff#define IB_SA_MCMEMBER_REC_SL				IB_SA_COMP_MASK(12)
175219820Sjeff#define IB_SA_MCMEMBER_REC_FLOW_LABEL			IB_SA_COMP_MASK(13)
176219820Sjeff#define IB_SA_MCMEMBER_REC_HOP_LIMIT			IB_SA_COMP_MASK(14)
177219820Sjeff#define IB_SA_MCMEMBER_REC_SCOPE			IB_SA_COMP_MASK(15)
178219820Sjeff#define IB_SA_MCMEMBER_REC_JOIN_STATE			IB_SA_COMP_MASK(16)
179219820Sjeff#define IB_SA_MCMEMBER_REC_PROXY_JOIN			IB_SA_COMP_MASK(17)
180219820Sjeff
181219820Sjeffstruct ib_sa_mcmember_rec {
182219820Sjeff	union ib_gid mgid;
183219820Sjeff	union ib_gid port_gid;
184219820Sjeff	__be32       qkey;
185219820Sjeff	__be16       mlid;
186219820Sjeff	u8           mtu_selector;
187219820Sjeff	u8           mtu;
188219820Sjeff	u8           traffic_class;
189219820Sjeff	__be16       pkey;
190219820Sjeff	u8 	     rate_selector;
191219820Sjeff	u8 	     rate;
192219820Sjeff	u8 	     packet_life_time_selector;
193219820Sjeff	u8 	     packet_life_time;
194219820Sjeff	u8           sl;
195219820Sjeff	__be32       flow_label;
196219820Sjeff	u8           hop_limit;
197219820Sjeff	u8           scope;
198219820Sjeff	u8           join_state;
199219820Sjeff	int          proxy_join;
200219820Sjeff};
201219820Sjeff
202219820Sjeff/* Service Record Component Mask Sec 15.2.5.14 Ver 1.1	*/
203219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_ID			IB_SA_COMP_MASK( 0)
204219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_GID			IB_SA_COMP_MASK( 1)
205219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_PKEY			IB_SA_COMP_MASK( 2)
206219820Sjeff/* reserved:								 3 */
207219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_LEASE			IB_SA_COMP_MASK( 4)
208219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_KEY			IB_SA_COMP_MASK( 5)
209219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_NAME			IB_SA_COMP_MASK( 6)
210219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_0		IB_SA_COMP_MASK( 7)
211219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_1		IB_SA_COMP_MASK( 8)
212219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_2		IB_SA_COMP_MASK( 9)
213219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_3		IB_SA_COMP_MASK(10)
214219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_4		IB_SA_COMP_MASK(11)
215219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_5		IB_SA_COMP_MASK(12)
216219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_6		IB_SA_COMP_MASK(13)
217219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_7		IB_SA_COMP_MASK(14)
218219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_8		IB_SA_COMP_MASK(15)
219219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_9		IB_SA_COMP_MASK(16)
220219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_10		IB_SA_COMP_MASK(17)
221219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_11		IB_SA_COMP_MASK(18)
222219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_12		IB_SA_COMP_MASK(19)
223219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_13		IB_SA_COMP_MASK(20)
224219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_14		IB_SA_COMP_MASK(21)
225219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA8_15		IB_SA_COMP_MASK(22)
226219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA16_0		IB_SA_COMP_MASK(23)
227219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA16_1		IB_SA_COMP_MASK(24)
228219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA16_2		IB_SA_COMP_MASK(25)
229219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA16_3		IB_SA_COMP_MASK(26)
230219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA16_4		IB_SA_COMP_MASK(27)
231219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA16_5		IB_SA_COMP_MASK(28)
232219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA16_6		IB_SA_COMP_MASK(29)
233219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA16_7		IB_SA_COMP_MASK(30)
234219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA32_0		IB_SA_COMP_MASK(31)
235219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA32_1		IB_SA_COMP_MASK(32)
236219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA32_2		IB_SA_COMP_MASK(33)
237219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA32_3		IB_SA_COMP_MASK(34)
238219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA64_0		IB_SA_COMP_MASK(35)
239219820Sjeff#define IB_SA_SERVICE_REC_SERVICE_DATA64_1		IB_SA_COMP_MASK(36)
240219820Sjeff
241219820Sjeff#define IB_DEFAULT_SERVICE_LEASE 	0xFFFFFFFF
242219820Sjeff
243219820Sjeffstruct ib_sa_service_rec {
244219820Sjeff	u64		id;
245219820Sjeff	union ib_gid	gid;
246219820Sjeff	__be16 		pkey;
247219820Sjeff	/* reserved */
248219820Sjeff	u32		lease;
249219820Sjeff	u8		key[16];
250219820Sjeff	u8		name[64];
251219820Sjeff	u8		data8[16];
252219820Sjeff	u16		data16[8];
253219820Sjeff	u32		data32[4];
254219820Sjeff	u64		data64[2];
255219820Sjeff};
256219820Sjeff
257255932Salfred#define IB_SA_GUIDINFO_REC_LID		IB_SA_COMP_MASK(0)
258255932Salfred#define IB_SA_GUIDINFO_REC_BLOCK_NUM	IB_SA_COMP_MASK(1)
259255932Salfred#define IB_SA_GUIDINFO_REC_RES1		IB_SA_COMP_MASK(2)
260255932Salfred#define IB_SA_GUIDINFO_REC_RES2		IB_SA_COMP_MASK(3)
261255932Salfred#define IB_SA_GUIDINFO_REC_GID0		IB_SA_COMP_MASK(4)
262255932Salfred#define IB_SA_GUIDINFO_REC_GID1		IB_SA_COMP_MASK(5)
263255932Salfred#define IB_SA_GUIDINFO_REC_GID2		IB_SA_COMP_MASK(6)
264255932Salfred#define IB_SA_GUIDINFO_REC_GID3		IB_SA_COMP_MASK(7)
265255932Salfred#define IB_SA_GUIDINFO_REC_GID4		IB_SA_COMP_MASK(8)
266255932Salfred#define IB_SA_GUIDINFO_REC_GID5		IB_SA_COMP_MASK(9)
267255932Salfred#define IB_SA_GUIDINFO_REC_GID6		IB_SA_COMP_MASK(10)
268255932Salfred#define IB_SA_GUIDINFO_REC_GID7		IB_SA_COMP_MASK(11)
269255932Salfred
270255932Salfredstruct ib_sa_guidinfo_rec {
271255932Salfred	__be16	lid;
272255932Salfred	u8	block_num;
273255932Salfred	/* reserved */
274255932Salfred	u8	res1;
275255932Salfred	__be32	res2;
276255932Salfred	u8	guid_info_list[64];
277255932Salfred};
278255932Salfred
279219820Sjeffstruct ib_sa_client {
280219820Sjeff	atomic_t users;
281219820Sjeff	struct completion comp;
282219820Sjeff};
283219820Sjeff
284219820Sjeff/**
285219820Sjeff * ib_sa_register_client - Register an SA client.
286219820Sjeff */
287219820Sjeffvoid ib_sa_register_client(struct ib_sa_client *client);
288219820Sjeff
289219820Sjeff/**
290219820Sjeff * ib_sa_unregister_client - Deregister an SA client.
291219820Sjeff * @client: Client object to deregister.
292219820Sjeff */
293219820Sjeffvoid ib_sa_unregister_client(struct ib_sa_client *client);
294219820Sjeff
295219820Sjeffstruct ib_sa_query;
296219820Sjeff
297219820Sjeffvoid ib_sa_cancel_query(int id, struct ib_sa_query *query);
298219820Sjeff
299219820Sjeffint ib_sa_path_rec_get(struct ib_sa_client *client,
300219820Sjeff		       struct ib_device *device, u8 port_num,
301219820Sjeff		       struct ib_sa_path_rec *rec,
302219820Sjeff		       ib_sa_comp_mask comp_mask,
303219820Sjeff		       int timeout_ms, gfp_t gfp_mask,
304219820Sjeff		       void (*callback)(int status,
305219820Sjeff					struct ib_sa_path_rec *resp,
306219820Sjeff					void *context),
307219820Sjeff		       void *context,
308219820Sjeff		       struct ib_sa_query **query);
309219820Sjeff
310219820Sjeffint ib_sa_service_rec_query(struct ib_sa_client *client,
311219820Sjeff			 struct ib_device *device, u8 port_num,
312219820Sjeff			 u8 method,
313219820Sjeff			 struct ib_sa_service_rec *rec,
314219820Sjeff			 ib_sa_comp_mask comp_mask,
315219820Sjeff			 int timeout_ms, gfp_t gfp_mask,
316219820Sjeff			 void (*callback)(int status,
317219820Sjeff					  struct ib_sa_service_rec *resp,
318219820Sjeff					  void *context),
319219820Sjeff			 void *context,
320219820Sjeff			 struct ib_sa_query **sa_query);
321219820Sjeff
322219820Sjeffstruct ib_sa_multicast {
323219820Sjeff	struct ib_sa_mcmember_rec rec;
324219820Sjeff	ib_sa_comp_mask		comp_mask;
325219820Sjeff	int			(*callback)(int status,
326219820Sjeff					    struct ib_sa_multicast *multicast);
327219820Sjeff	void			*context;
328219820Sjeff};
329219820Sjeff
330219820Sjeff/**
331219820Sjeff * ib_sa_join_multicast - Initiates a join request to the specified multicast
332219820Sjeff *   group.
333219820Sjeff * @client: SA client
334219820Sjeff * @device: Device associated with the multicast group.
335219820Sjeff * @port_num: Port on the specified device to associate with the multicast
336219820Sjeff *   group.
337219820Sjeff * @rec: SA multicast member record specifying group attributes.
338219820Sjeff * @comp_mask: Component mask indicating which group attributes of %rec are
339219820Sjeff *   valid.
340219820Sjeff * @gfp_mask: GFP mask for memory allocations.
341219820Sjeff * @callback: User callback invoked once the join operation completes.
342219820Sjeff * @context: User specified context stored with the ib_sa_multicast structure.
343219820Sjeff *
344219820Sjeff * This call initiates a multicast join request with the SA for the specified
345219820Sjeff * multicast group.  If the join operation is started successfully, it returns
346219820Sjeff * an ib_sa_multicast structure that is used to track the multicast operation.
347219820Sjeff * Users must free this structure by calling ib_free_multicast, even if the
348219820Sjeff * join operation later fails.  (The callback status is non-zero.)
349219820Sjeff *
350219820Sjeff * If the join operation fails; status will be non-zero, with the following
351219820Sjeff * failures possible:
352219820Sjeff * -ETIMEDOUT: The request timed out.
353219820Sjeff * -EIO: An error occurred sending the query.
354219820Sjeff * -EINVAL: The MCMemberRecord values differed from the existing group's.
355219820Sjeff * -ENETRESET: Indicates that an fatal error has occurred on the multicast
356219820Sjeff *   group, and the user must rejoin the group to continue using it.
357219820Sjeff */
358219820Sjeffstruct ib_sa_multicast *ib_sa_join_multicast(struct ib_sa_client *client,
359219820Sjeff					     struct ib_device *device, u8 port_num,
360219820Sjeff					     struct ib_sa_mcmember_rec *rec,
361219820Sjeff					     ib_sa_comp_mask comp_mask, gfp_t gfp_mask,
362219820Sjeff					     int (*callback)(int status,
363219820Sjeff							     struct ib_sa_multicast
364219820Sjeff								    *multicast),
365219820Sjeff					     void *context);
366219820Sjeff
367219820Sjeff/**
368219820Sjeff * ib_free_multicast - Frees the multicast tracking structure, and releases
369219820Sjeff *    any reference on the multicast group.
370219820Sjeff * @multicast: Multicast tracking structure allocated by ib_join_multicast.
371219820Sjeff *
372219820Sjeff * This call blocks until the multicast identifier is destroyed.  It may
373219820Sjeff * not be called from within the multicast callback; however, returning a non-
374219820Sjeff * zero value from the callback will result in destroying the multicast
375219820Sjeff * tracking structure.
376219820Sjeff */
377219820Sjeffvoid ib_sa_free_multicast(struct ib_sa_multicast *multicast);
378219820Sjeff
379219820Sjeff/**
380219820Sjeff * ib_get_mcmember_rec - Looks up a multicast member record by its MGID and
381219820Sjeff *   returns it if found.
382219820Sjeff * @device: Device associated with the multicast group.
383219820Sjeff * @port_num: Port on the specified device to associate with the multicast
384219820Sjeff *   group.
385219820Sjeff * @mgid: MGID of multicast group.
386219820Sjeff * @rec: Location to copy SA multicast member record.
387219820Sjeff */
388219820Sjeffint ib_sa_get_mcmember_rec(struct ib_device *device, u8 port_num,
389219820Sjeff			   union ib_gid *mgid, struct ib_sa_mcmember_rec *rec);
390219820Sjeff
391219820Sjeff/**
392219820Sjeff * ib_init_ah_from_mcmember - Initialize address handle attributes based on
393219820Sjeff * an SA multicast member record.
394219820Sjeff */
395219820Sjeffint ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
396219820Sjeff			     struct ib_sa_mcmember_rec *rec,
397219820Sjeff			     struct ib_ah_attr *ah_attr);
398219820Sjeff
399219820Sjeff/**
400219820Sjeff * ib_init_ah_from_path - Initialize address handle attributes based on an SA
401219820Sjeff *   path record.
402219820Sjeff */
403219820Sjeffint ib_init_ah_from_path(struct ib_device *device, u8 port_num,
404219820Sjeff			 struct ib_sa_path_rec *rec,
405219820Sjeff			 struct ib_ah_attr *ah_attr);
406219820Sjeff
407219820Sjeff/**
408219820Sjeff * ib_sa_unpack_path - Convert a path record from MAD format to struct
409219820Sjeff * ib_sa_path_rec.
410219820Sjeff */
411219820Sjeffvoid ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec);
412219820Sjeff
413278886Shselasky/* Support GuidInfoRecord */
414255932Salfredint ib_sa_guid_info_rec_query(struct ib_sa_client *client,
415255932Salfred                              struct ib_device *device, u8 port_num,
416255932Salfred                              struct ib_sa_guidinfo_rec *rec,
417255932Salfred                              ib_sa_comp_mask comp_mask, u8 method,
418255932Salfred                              int timeout_ms, gfp_t gfp_mask,
419255932Salfred                              void (*callback)(int status,
420255932Salfred                                               struct ib_sa_guidinfo_rec *resp,
421255932Salfred                                               void *context),
422255932Salfred                              void *context,
423255932Salfred                              struct ib_sa_query **sa_query);
424219820Sjeff#endif /* IB_SA_H */
425