xref: /linux/include/rdma/ib_sa.h (revision ee1c60b1bff8f258fa530def3459726f8e922caf)
1a4d61e84SRoland Dreier /*
2a4d61e84SRoland Dreier  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
3a4d61e84SRoland Dreier  * Copyright (c) 2005 Voltaire, Inc.  All rights reserved.
4c1a0b23bSMichael S. Tsirkin  * Copyright (c) 2006 Intel Corporation.  All rights reserved.
5a4d61e84SRoland Dreier  *
6a4d61e84SRoland Dreier  * This software is available to you under a choice of one of two
7a4d61e84SRoland Dreier  * licenses.  You may choose to be licensed under the terms of the GNU
8a4d61e84SRoland Dreier  * General Public License (GPL) Version 2, available from the file
9a4d61e84SRoland Dreier  * COPYING in the main directory of this source tree, or the
10a4d61e84SRoland Dreier  * OpenIB.org BSD license below:
11a4d61e84SRoland Dreier  *
12a4d61e84SRoland Dreier  *     Redistribution and use in source and binary forms, with or
13a4d61e84SRoland Dreier  *     without modification, are permitted provided that the following
14a4d61e84SRoland Dreier  *     conditions are met:
15a4d61e84SRoland Dreier  *
16a4d61e84SRoland Dreier  *      - Redistributions of source code must retain the above
17a4d61e84SRoland Dreier  *        copyright notice, this list of conditions and the following
18a4d61e84SRoland Dreier  *        disclaimer.
19a4d61e84SRoland Dreier  *
20a4d61e84SRoland Dreier  *      - Redistributions in binary form must reproduce the above
21a4d61e84SRoland Dreier  *        copyright notice, this list of conditions and the following
22a4d61e84SRoland Dreier  *        disclaimer in the documentation and/or other materials
23a4d61e84SRoland Dreier  *        provided with the distribution.
24a4d61e84SRoland Dreier  *
25a4d61e84SRoland Dreier  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26a4d61e84SRoland Dreier  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27a4d61e84SRoland Dreier  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28a4d61e84SRoland Dreier  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29a4d61e84SRoland Dreier  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30a4d61e84SRoland Dreier  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31a4d61e84SRoland Dreier  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32a4d61e84SRoland Dreier  * SOFTWARE.
33a4d61e84SRoland Dreier  */
34a4d61e84SRoland Dreier 
35a4d61e84SRoland Dreier #ifndef IB_SA_H
36a4d61e84SRoland Dreier #define IB_SA_H
37a4d61e84SRoland Dreier 
38c1a0b23bSMichael S. Tsirkin #include <linux/completion.h>
39a4d61e84SRoland Dreier #include <linux/compiler.h>
40a4d61e84SRoland Dreier 
4160063497SArun Sharma #include <linux/atomic.h>
42ba36e37fSMatan Barak #include <linux/netdevice.h>
43c1a0b23bSMichael S. Tsirkin 
44a4d61e84SRoland Dreier #include <rdma/ib_verbs.h>
45a4d61e84SRoland Dreier #include <rdma/ib_mad.h>
46a4d61e84SRoland Dreier 
47a4d61e84SRoland Dreier enum {
48a4d61e84SRoland Dreier 	IB_SA_CLASS_VERSION		= 2,	/* IB spec version 1.1/1.2 */
49a4d61e84SRoland Dreier 
50a4d61e84SRoland Dreier 	IB_SA_METHOD_GET_TABLE		= 0x12,
51a4d61e84SRoland Dreier 	IB_SA_METHOD_GET_TABLE_RESP	= 0x92,
521325cc79SHal Rosenstock 	IB_SA_METHOD_DELETE		= 0x15,
531325cc79SHal Rosenstock 	IB_SA_METHOD_DELETE_RESP	= 0x95,
541325cc79SHal Rosenstock 	IB_SA_METHOD_GET_MULTI		= 0x14,
551325cc79SHal Rosenstock 	IB_SA_METHOD_GET_MULTI_RESP	= 0x94,
561325cc79SHal Rosenstock 	IB_SA_METHOD_GET_TRACE_TBL	= 0x13
57a4d61e84SRoland Dreier };
58a4d61e84SRoland Dreier 
59fbed8eeeSHal Rosenstock enum {
60fbed8eeeSHal Rosenstock 	IB_SA_ATTR_CLASS_PORTINFO    = 0x01,
61fbed8eeeSHal Rosenstock 	IB_SA_ATTR_NOTICE	     = 0x02,
62fbed8eeeSHal Rosenstock 	IB_SA_ATTR_INFORM_INFO	     = 0x03,
63fbed8eeeSHal Rosenstock 	IB_SA_ATTR_NODE_REC	     = 0x11,
64fbed8eeeSHal Rosenstock 	IB_SA_ATTR_PORT_INFO_REC     = 0x12,
65fbed8eeeSHal Rosenstock 	IB_SA_ATTR_SL2VL_REC	     = 0x13,
66fbed8eeeSHal Rosenstock 	IB_SA_ATTR_SWITCH_REC	     = 0x14,
67fbed8eeeSHal Rosenstock 	IB_SA_ATTR_LINEAR_FDB_REC    = 0x15,
68fbed8eeeSHal Rosenstock 	IB_SA_ATTR_RANDOM_FDB_REC    = 0x16,
69fbed8eeeSHal Rosenstock 	IB_SA_ATTR_MCAST_FDB_REC     = 0x17,
70fbed8eeeSHal Rosenstock 	IB_SA_ATTR_SM_INFO_REC	     = 0x18,
71fbed8eeeSHal Rosenstock 	IB_SA_ATTR_LINK_REC	     = 0x20,
72fbed8eeeSHal Rosenstock 	IB_SA_ATTR_GUID_INFO_REC     = 0x30,
73fbed8eeeSHal Rosenstock 	IB_SA_ATTR_SERVICE_REC	     = 0x31,
74fbed8eeeSHal Rosenstock 	IB_SA_ATTR_PARTITION_REC     = 0x33,
75fbed8eeeSHal Rosenstock 	IB_SA_ATTR_PATH_REC	     = 0x35,
76fbed8eeeSHal Rosenstock 	IB_SA_ATTR_VL_ARB_REC	     = 0x36,
77fbed8eeeSHal Rosenstock 	IB_SA_ATTR_MC_MEMBER_REC     = 0x38,
78fbed8eeeSHal Rosenstock 	IB_SA_ATTR_TRACE_REC	     = 0x39,
79fbed8eeeSHal Rosenstock 	IB_SA_ATTR_MULTI_PATH_REC    = 0x3a,
80fbed8eeeSHal Rosenstock 	IB_SA_ATTR_SERVICE_ASSOC_REC = 0x3b,
81fbed8eeeSHal Rosenstock 	IB_SA_ATTR_INFORM_INFO_REC   = 0xf3
82fbed8eeeSHal Rosenstock };
83fbed8eeeSHal Rosenstock 
84a4d61e84SRoland Dreier enum ib_sa_selector {
85aec79fccSMichael S. Tsirkin 	IB_SA_GT   = 0,
86aec79fccSMichael S. Tsirkin 	IB_SA_LT   = 1,
87a4d61e84SRoland Dreier 	IB_SA_EQ   = 2,
88a4d61e84SRoland Dreier 	/*
89a4d61e84SRoland Dreier 	 * The meaning of "best" depends on the attribute: for
90a4d61e84SRoland Dreier 	 * example, for MTU best will return the largest available
91a4d61e84SRoland Dreier 	 * MTU, while for packet life time, best will return the
92a4d61e84SRoland Dreier 	 * smallest available life time.
93a4d61e84SRoland Dreier 	 */
94a4d61e84SRoland Dreier 	IB_SA_BEST = 3
95a4d61e84SRoland Dreier };
96a4d61e84SRoland Dreier 
97ab15c95aSAlex Vesker /*
98ab15c95aSAlex Vesker  * There are 4 types of join states:
99ab15c95aSAlex Vesker  * FullMember, NonMember, SendOnlyNonMember, SendOnlyFullMember.
100ab15c95aSAlex Vesker  * The order corresponds to JoinState bits in MCMemberRecord.
101ab15c95aSAlex Vesker  */
102ab15c95aSAlex Vesker enum ib_sa_mc_join_states {
103ab15c95aSAlex Vesker 	FULLMEMBER_JOIN,
104ab15c95aSAlex Vesker 	NONMEMBER_JOIN,
105ab15c95aSAlex Vesker 	SENDONLY_NONMEBER_JOIN,
106ab15c95aSAlex Vesker 	SENDONLY_FULLMEMBER_JOIN,
107ab15c95aSAlex Vesker 	NUM_JOIN_MEMBERSHIP_TYPES,
108ab15c95aSAlex Vesker };
109ab15c95aSAlex Vesker 
110628e6f75SErez Shitrit #define IB_SA_CAP_MASK2_SENDONLY_FULL_MEM_SUPPORT	BIT(12)
111628e6f75SErez Shitrit 
112a4d61e84SRoland Dreier /*
113a4d61e84SRoland Dreier  * Structures for SA records are named "struct ib_sa_xxx_rec."  No
114a4d61e84SRoland Dreier  * attempt is made to pack structures to match the physical layout of
115a4d61e84SRoland Dreier  * SA records in SA MADs; all packing and unpacking is handled by the
116a4d61e84SRoland Dreier  * SA query code.
117a4d61e84SRoland Dreier  *
118a4d61e84SRoland Dreier  * For a record with structure ib_sa_xxx_rec, the naming convention
119a4d61e84SRoland Dreier  * for the component mask value for field yyy is IB_SA_XXX_REC_YYY (we
120a4d61e84SRoland Dreier  * never use different abbreviations or otherwise change the spelling
121a4d61e84SRoland Dreier  * of xxx/yyy between ib_sa_xxx_rec.yyy and IB_SA_XXX_REC_YYY).
122a4d61e84SRoland Dreier  *
123a4d61e84SRoland Dreier  * Reserved rows are indicated with comments to help maintainability.
124a4d61e84SRoland Dreier  */
125a4d61e84SRoland Dreier 
126733d65feSSean Hefty #define IB_SA_PATH_REC_SERVICE_ID		       (IB_SA_COMP_MASK( 0) |\
127733d65feSSean Hefty 							IB_SA_COMP_MASK( 1))
128a4d61e84SRoland Dreier #define IB_SA_PATH_REC_DGID				IB_SA_COMP_MASK( 2)
129a4d61e84SRoland Dreier #define IB_SA_PATH_REC_SGID				IB_SA_COMP_MASK( 3)
130a4d61e84SRoland Dreier #define IB_SA_PATH_REC_DLID				IB_SA_COMP_MASK( 4)
131a4d61e84SRoland Dreier #define IB_SA_PATH_REC_SLID				IB_SA_COMP_MASK( 5)
132a4d61e84SRoland Dreier #define IB_SA_PATH_REC_RAW_TRAFFIC			IB_SA_COMP_MASK( 6)
133a4d61e84SRoland Dreier /* reserved:								 7 */
134a4d61e84SRoland Dreier #define IB_SA_PATH_REC_FLOW_LABEL       		IB_SA_COMP_MASK( 8)
135a4d61e84SRoland Dreier #define IB_SA_PATH_REC_HOP_LIMIT			IB_SA_COMP_MASK( 9)
136a4d61e84SRoland Dreier #define IB_SA_PATH_REC_TRAFFIC_CLASS			IB_SA_COMP_MASK(10)
137a4d61e84SRoland Dreier #define IB_SA_PATH_REC_REVERSIBLE			IB_SA_COMP_MASK(11)
138a4d61e84SRoland Dreier #define IB_SA_PATH_REC_NUMB_PATH			IB_SA_COMP_MASK(12)
139a4d61e84SRoland Dreier #define IB_SA_PATH_REC_PKEY				IB_SA_COMP_MASK(13)
140733d65feSSean Hefty #define IB_SA_PATH_REC_QOS_CLASS			IB_SA_COMP_MASK(14)
141a4d61e84SRoland Dreier #define IB_SA_PATH_REC_SL				IB_SA_COMP_MASK(15)
142a4d61e84SRoland Dreier #define IB_SA_PATH_REC_MTU_SELECTOR			IB_SA_COMP_MASK(16)
143a4d61e84SRoland Dreier #define IB_SA_PATH_REC_MTU				IB_SA_COMP_MASK(17)
144a4d61e84SRoland Dreier #define IB_SA_PATH_REC_RATE_SELECTOR			IB_SA_COMP_MASK(18)
145a4d61e84SRoland Dreier #define IB_SA_PATH_REC_RATE				IB_SA_COMP_MASK(19)
146a4d61e84SRoland Dreier #define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR	IB_SA_COMP_MASK(20)
147a4d61e84SRoland Dreier #define IB_SA_PATH_REC_PACKET_LIFE_TIME			IB_SA_COMP_MASK(21)
148a4d61e84SRoland Dreier #define IB_SA_PATH_REC_PREFERENCE			IB_SA_COMP_MASK(22)
149a4d61e84SRoland Dreier 
150a4d61e84SRoland Dreier struct ib_sa_path_rec {
151733d65feSSean Hefty 	__be64       service_id;
152a4d61e84SRoland Dreier 	union ib_gid dgid;
153a4d61e84SRoland Dreier 	union ib_gid sgid;
154a4d61e84SRoland Dreier 	__be16       dlid;
155a4d61e84SRoland Dreier 	__be16       slid;
15655efcfcdSJason Gunthorpe 	u8           raw_traffic;
157a4d61e84SRoland Dreier 	/* reserved */
158a4d61e84SRoland Dreier 	__be32       flow_label;
159a4d61e84SRoland Dreier 	u8           hop_limit;
160a4d61e84SRoland Dreier 	u8           traffic_class;
16155efcfcdSJason Gunthorpe 	u8           reversible;
162a4d61e84SRoland Dreier 	u8           numb_path;
163a4d61e84SRoland Dreier 	__be16       pkey;
164733d65feSSean Hefty 	__be16       qos_class;
165a4d61e84SRoland Dreier 	u8           sl;
166a4d61e84SRoland Dreier 	u8           mtu_selector;
167a4d61e84SRoland Dreier 	u8           mtu;
168a4d61e84SRoland Dreier 	u8           rate_selector;
169a4d61e84SRoland Dreier 	u8           rate;
170a4d61e84SRoland Dreier 	u8           packet_life_time_selector;
171a4d61e84SRoland Dreier 	u8           packet_life_time;
172a4d61e84SRoland Dreier 	u8           preference;
173dd5f03beSMatan Barak 	u8           dmac[ETH_ALEN];
174ba36e37fSMatan Barak 	/* ignored in IB */
175ba36e37fSMatan Barak 	int	     ifindex;
176ba36e37fSMatan Barak 	/* ignored in IB */
177ba36e37fSMatan Barak 	struct net  *net;
178b39ffa1dSMatan Barak 	enum ib_gid_type gid_type;
179a4d61e84SRoland Dreier };
180a4d61e84SRoland Dreier 
181ba36e37fSMatan Barak static inline struct net_device *ib_get_ndev_from_path(struct ib_sa_path_rec *rec)
182ba36e37fSMatan Barak {
183ba36e37fSMatan Barak 	return rec->net ? dev_get_by_index(rec->net, rec->ifindex) : NULL;
184ba36e37fSMatan Barak }
185ba36e37fSMatan Barak 
186a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_MGID				IB_SA_COMP_MASK( 0)
187a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_PORT_GID			IB_SA_COMP_MASK( 1)
188a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_QKEY				IB_SA_COMP_MASK( 2)
189a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_MLID				IB_SA_COMP_MASK( 3)
190a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_MTU_SELECTOR			IB_SA_COMP_MASK( 4)
191a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_MTU				IB_SA_COMP_MASK( 5)
192a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS		IB_SA_COMP_MASK( 6)
193a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_PKEY				IB_SA_COMP_MASK( 7)
194a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_RATE_SELECTOR		IB_SA_COMP_MASK( 8)
195a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_RATE				IB_SA_COMP_MASK( 9)
196a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR	IB_SA_COMP_MASK(10)
197a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME		IB_SA_COMP_MASK(11)
198a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_SL				IB_SA_COMP_MASK(12)
199a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_FLOW_LABEL			IB_SA_COMP_MASK(13)
200a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_HOP_LIMIT			IB_SA_COMP_MASK(14)
201a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_SCOPE			IB_SA_COMP_MASK(15)
202a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_JOIN_STATE			IB_SA_COMP_MASK(16)
203a4d61e84SRoland Dreier #define IB_SA_MCMEMBER_REC_PROXY_JOIN			IB_SA_COMP_MASK(17)
204a4d61e84SRoland Dreier 
205a4d61e84SRoland Dreier struct ib_sa_mcmember_rec {
206a4d61e84SRoland Dreier 	union ib_gid mgid;
207a4d61e84SRoland Dreier 	union ib_gid port_gid;
208a4d61e84SRoland Dreier 	__be32       qkey;
209a4d61e84SRoland Dreier 	__be16       mlid;
210a4d61e84SRoland Dreier 	u8           mtu_selector;
211a4d61e84SRoland Dreier 	u8           mtu;
212a4d61e84SRoland Dreier 	u8           traffic_class;
213a4d61e84SRoland Dreier 	__be16       pkey;
214a4d61e84SRoland Dreier 	u8 	     rate_selector;
215a4d61e84SRoland Dreier 	u8 	     rate;
216a4d61e84SRoland Dreier 	u8 	     packet_life_time_selector;
217a4d61e84SRoland Dreier 	u8 	     packet_life_time;
218a4d61e84SRoland Dreier 	u8           sl;
219a4d61e84SRoland Dreier 	__be32       flow_label;
220a4d61e84SRoland Dreier 	u8           hop_limit;
221a4d61e84SRoland Dreier 	u8           scope;
222a4d61e84SRoland Dreier 	u8           join_state;
22355efcfcdSJason Gunthorpe 	u8           proxy_join;
224a4d61e84SRoland Dreier };
225a4d61e84SRoland Dreier 
226a4d61e84SRoland Dreier /* Service Record Component Mask Sec 15.2.5.14 Ver 1.1	*/
227a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_ID			IB_SA_COMP_MASK( 0)
228a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_GID			IB_SA_COMP_MASK( 1)
229a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_PKEY			IB_SA_COMP_MASK( 2)
230a4d61e84SRoland Dreier /* reserved:								 3 */
231a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_LEASE			IB_SA_COMP_MASK( 4)
232a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_KEY			IB_SA_COMP_MASK( 5)
233a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_NAME			IB_SA_COMP_MASK( 6)
234a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_0		IB_SA_COMP_MASK( 7)
235a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_1		IB_SA_COMP_MASK( 8)
236a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_2		IB_SA_COMP_MASK( 9)
237a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_3		IB_SA_COMP_MASK(10)
238a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_4		IB_SA_COMP_MASK(11)
239a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_5		IB_SA_COMP_MASK(12)
240a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_6		IB_SA_COMP_MASK(13)
241a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_7		IB_SA_COMP_MASK(14)
242a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_8		IB_SA_COMP_MASK(15)
243a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_9		IB_SA_COMP_MASK(16)
244a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_10		IB_SA_COMP_MASK(17)
245a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_11		IB_SA_COMP_MASK(18)
246a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_12		IB_SA_COMP_MASK(19)
247a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_13		IB_SA_COMP_MASK(20)
248a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_14		IB_SA_COMP_MASK(21)
249a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA8_15		IB_SA_COMP_MASK(22)
250a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA16_0		IB_SA_COMP_MASK(23)
251a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA16_1		IB_SA_COMP_MASK(24)
252a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA16_2		IB_SA_COMP_MASK(25)
253a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA16_3		IB_SA_COMP_MASK(26)
254a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA16_4		IB_SA_COMP_MASK(27)
255a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA16_5		IB_SA_COMP_MASK(28)
256a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA16_6		IB_SA_COMP_MASK(29)
257a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA16_7		IB_SA_COMP_MASK(30)
258a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA32_0		IB_SA_COMP_MASK(31)
259a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA32_1		IB_SA_COMP_MASK(32)
260a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA32_2		IB_SA_COMP_MASK(33)
261a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA32_3		IB_SA_COMP_MASK(34)
262a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA64_0		IB_SA_COMP_MASK(35)
263a4d61e84SRoland Dreier #define IB_SA_SERVICE_REC_SERVICE_DATA64_1		IB_SA_COMP_MASK(36)
264a4d61e84SRoland Dreier 
265a4d61e84SRoland Dreier #define IB_DEFAULT_SERVICE_LEASE 	0xFFFFFFFF
266a4d61e84SRoland Dreier 
267a4d61e84SRoland Dreier struct ib_sa_service_rec {
268a4d61e84SRoland Dreier 	u64		id;
269a4d61e84SRoland Dreier 	union ib_gid	gid;
270a4d61e84SRoland Dreier 	__be16 		pkey;
271a4d61e84SRoland Dreier 	/* reserved */
272a4d61e84SRoland Dreier 	u32		lease;
273a4d61e84SRoland Dreier 	u8		key[16];
274a4d61e84SRoland Dreier 	u8		name[64];
275a4d61e84SRoland Dreier 	u8		data8[16];
276a4d61e84SRoland Dreier 	u16		data16[8];
277a4d61e84SRoland Dreier 	u32		data32[4];
278a4d61e84SRoland Dreier 	u64		data64[2];
279a4d61e84SRoland Dreier };
280a4d61e84SRoland Dreier 
281aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_LID		IB_SA_COMP_MASK(0)
282aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_BLOCK_NUM	IB_SA_COMP_MASK(1)
283aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_RES1		IB_SA_COMP_MASK(2)
284aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_RES2		IB_SA_COMP_MASK(3)
285aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_GID0		IB_SA_COMP_MASK(4)
286aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_GID1		IB_SA_COMP_MASK(5)
287aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_GID2		IB_SA_COMP_MASK(6)
288aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_GID3		IB_SA_COMP_MASK(7)
289aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_GID4		IB_SA_COMP_MASK(8)
290aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_GID5		IB_SA_COMP_MASK(9)
291aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_GID6		IB_SA_COMP_MASK(10)
292aeab97edSErez Shitrit #define IB_SA_GUIDINFO_REC_GID7		IB_SA_COMP_MASK(11)
293aeab97edSErez Shitrit 
294aeab97edSErez Shitrit struct ib_sa_guidinfo_rec {
295aeab97edSErez Shitrit 	__be16	lid;
296aeab97edSErez Shitrit 	u8	block_num;
297aeab97edSErez Shitrit 	/* reserved */
298aeab97edSErez Shitrit 	u8	res1;
299aeab97edSErez Shitrit 	__be32	res2;
300aeab97edSErez Shitrit 	u8	guid_info_list[64];
301aeab97edSErez Shitrit };
302aeab97edSErez Shitrit 
303c1a0b23bSMichael S. Tsirkin struct ib_sa_client {
304c1a0b23bSMichael S. Tsirkin 	atomic_t users;
305c1a0b23bSMichael S. Tsirkin 	struct completion comp;
306c1a0b23bSMichael S. Tsirkin };
307c1a0b23bSMichael S. Tsirkin 
308c1a0b23bSMichael S. Tsirkin /**
309c1a0b23bSMichael S. Tsirkin  * ib_sa_register_client - Register an SA client.
310c1a0b23bSMichael S. Tsirkin  */
311c1a0b23bSMichael S. Tsirkin void ib_sa_register_client(struct ib_sa_client *client);
312c1a0b23bSMichael S. Tsirkin 
313c1a0b23bSMichael S. Tsirkin /**
314c1a0b23bSMichael S. Tsirkin  * ib_sa_unregister_client - Deregister an SA client.
315c1a0b23bSMichael S. Tsirkin  * @client: Client object to deregister.
316c1a0b23bSMichael S. Tsirkin  */
317c1a0b23bSMichael S. Tsirkin void ib_sa_unregister_client(struct ib_sa_client *client);
318c1a0b23bSMichael S. Tsirkin 
319a4d61e84SRoland Dreier struct ib_sa_query;
320a4d61e84SRoland Dreier 
321a4d61e84SRoland Dreier void ib_sa_cancel_query(int id, struct ib_sa_query *query);
322a4d61e84SRoland Dreier 
323c1a0b23bSMichael S. Tsirkin int ib_sa_path_rec_get(struct ib_sa_client *client,
324c1a0b23bSMichael S. Tsirkin 		       struct ib_device *device, u8 port_num,
325a4d61e84SRoland Dreier 		       struct ib_sa_path_rec *rec,
326a4d61e84SRoland Dreier 		       ib_sa_comp_mask comp_mask,
327dd0fc66fSAl Viro 		       int timeout_ms, gfp_t gfp_mask,
328a4d61e84SRoland Dreier 		       void (*callback)(int status,
329a4d61e84SRoland Dreier 					struct ib_sa_path_rec *resp,
330a4d61e84SRoland Dreier 					void *context),
331a4d61e84SRoland Dreier 		       void *context,
332a4d61e84SRoland Dreier 		       struct ib_sa_query **query);
333a4d61e84SRoland Dreier 
334c1a0b23bSMichael S. Tsirkin int ib_sa_service_rec_query(struct ib_sa_client *client,
335c1a0b23bSMichael S. Tsirkin 			 struct ib_device *device, u8 port_num,
336a4d61e84SRoland Dreier 			 u8 method,
337a4d61e84SRoland Dreier 			 struct ib_sa_service_rec *rec,
338a4d61e84SRoland Dreier 			 ib_sa_comp_mask comp_mask,
339dd0fc66fSAl Viro 			 int timeout_ms, gfp_t gfp_mask,
340a4d61e84SRoland Dreier 			 void (*callback)(int status,
341a4d61e84SRoland Dreier 					  struct ib_sa_service_rec *resp,
342a4d61e84SRoland Dreier 					  void *context),
343a4d61e84SRoland Dreier 			 void *context,
344a4d61e84SRoland Dreier 			 struct ib_sa_query **sa_query);
345a4d61e84SRoland Dreier 
346faec2f7bSSean Hefty struct ib_sa_multicast {
347faec2f7bSSean Hefty 	struct ib_sa_mcmember_rec rec;
348faec2f7bSSean Hefty 	ib_sa_comp_mask		comp_mask;
349faec2f7bSSean Hefty 	int			(*callback)(int status,
350faec2f7bSSean Hefty 					    struct ib_sa_multicast *multicast);
351faec2f7bSSean Hefty 	void			*context;
352faec2f7bSSean Hefty };
353a4d61e84SRoland Dreier 
354a4d61e84SRoland Dreier /**
355faec2f7bSSean Hefty  * ib_sa_join_multicast - Initiates a join request to the specified multicast
356faec2f7bSSean Hefty  *   group.
357c1a0b23bSMichael S. Tsirkin  * @client: SA client
358faec2f7bSSean Hefty  * @device: Device associated with the multicast group.
359faec2f7bSSean Hefty  * @port_num: Port on the specified device to associate with the multicast
360faec2f7bSSean Hefty  *   group.
361faec2f7bSSean Hefty  * @rec: SA multicast member record specifying group attributes.
362faec2f7bSSean Hefty  * @comp_mask: Component mask indicating which group attributes of %rec are
363faec2f7bSSean Hefty  *   valid.
364faec2f7bSSean Hefty  * @gfp_mask: GFP mask for memory allocations.
365faec2f7bSSean Hefty  * @callback: User callback invoked once the join operation completes.
366faec2f7bSSean Hefty  * @context: User specified context stored with the ib_sa_multicast structure.
367a4d61e84SRoland Dreier  *
368faec2f7bSSean Hefty  * This call initiates a multicast join request with the SA for the specified
369faec2f7bSSean Hefty  * multicast group.  If the join operation is started successfully, it returns
370faec2f7bSSean Hefty  * an ib_sa_multicast structure that is used to track the multicast operation.
371faec2f7bSSean Hefty  * Users must free this structure by calling ib_free_multicast, even if the
372faec2f7bSSean Hefty  * join operation later fails.  (The callback status is non-zero.)
373a4d61e84SRoland Dreier  *
374faec2f7bSSean Hefty  * If the join operation fails; status will be non-zero, with the following
375faec2f7bSSean Hefty  * failures possible:
376faec2f7bSSean Hefty  * -ETIMEDOUT: The request timed out.
377faec2f7bSSean Hefty  * -EIO: An error occurred sending the query.
378faec2f7bSSean Hefty  * -EINVAL: The MCMemberRecord values differed from the existing group's.
379faec2f7bSSean Hefty  * -ENETRESET: Indicates that an fatal error has occurred on the multicast
380faec2f7bSSean Hefty  *   group, and the user must rejoin the group to continue using it.
381a4d61e84SRoland Dreier  */
382faec2f7bSSean Hefty struct ib_sa_multicast *ib_sa_join_multicast(struct ib_sa_client *client,
383c1a0b23bSMichael S. Tsirkin 					     struct ib_device *device, u8 port_num,
384a4d61e84SRoland Dreier 					     struct ib_sa_mcmember_rec *rec,
385faec2f7bSSean Hefty 					     ib_sa_comp_mask comp_mask, gfp_t gfp_mask,
386faec2f7bSSean Hefty 					     int (*callback)(int status,
387faec2f7bSSean Hefty 							     struct ib_sa_multicast
388faec2f7bSSean Hefty 								    *multicast),
389faec2f7bSSean Hefty 					     void *context);
390faec2f7bSSean Hefty 
391faec2f7bSSean Hefty /**
392faec2f7bSSean Hefty  * ib_free_multicast - Frees the multicast tracking structure, and releases
393faec2f7bSSean Hefty  *    any reference on the multicast group.
394faec2f7bSSean Hefty  * @multicast: Multicast tracking structure allocated by ib_join_multicast.
395faec2f7bSSean Hefty  *
396faec2f7bSSean Hefty  * This call blocks until the multicast identifier is destroyed.  It may
397faec2f7bSSean Hefty  * not be called from within the multicast callback; however, returning a non-
398faec2f7bSSean Hefty  * zero value from the callback will result in destroying the multicast
399faec2f7bSSean Hefty  * tracking structure.
400faec2f7bSSean Hefty  */
401faec2f7bSSean Hefty void ib_sa_free_multicast(struct ib_sa_multicast *multicast);
402faec2f7bSSean Hefty 
403faec2f7bSSean Hefty /**
404faec2f7bSSean Hefty  * ib_get_mcmember_rec - Looks up a multicast member record by its MGID and
405faec2f7bSSean Hefty  *   returns it if found.
406faec2f7bSSean Hefty  * @device: Device associated with the multicast group.
407faec2f7bSSean Hefty  * @port_num: Port on the specified device to associate with the multicast
408faec2f7bSSean Hefty  *   group.
409faec2f7bSSean Hefty  * @mgid: MGID of multicast group.
410faec2f7bSSean Hefty  * @rec: Location to copy SA multicast member record.
411faec2f7bSSean Hefty  */
412faec2f7bSSean Hefty int ib_sa_get_mcmember_rec(struct ib_device *device, u8 port_num,
413faec2f7bSSean Hefty 			   union ib_gid *mgid, struct ib_sa_mcmember_rec *rec);
414faec2f7bSSean Hefty 
415faec2f7bSSean Hefty /**
416faec2f7bSSean Hefty  * ib_init_ah_from_mcmember - Initialize address handle attributes based on
417faec2f7bSSean Hefty  * an SA multicast member record.
418faec2f7bSSean Hefty  */
419faec2f7bSSean Hefty int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
420faec2f7bSSean Hefty 			     struct ib_sa_mcmember_rec *rec,
421bee3c3c9SMoni Shoua 			     struct net_device *ndev,
422bee3c3c9SMoni Shoua 			     enum ib_gid_type gid_type,
423faec2f7bSSean Hefty 			     struct ib_ah_attr *ah_attr);
424a4d61e84SRoland Dreier 
4256d969a47SSean Hefty /**
4266d969a47SSean Hefty  * ib_init_ah_from_path - Initialize address handle attributes based on an SA
4276d969a47SSean Hefty  *   path record.
4286d969a47SSean Hefty  */
4296d969a47SSean Hefty int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
4306d969a47SSean Hefty 			 struct ib_sa_path_rec *rec,
4316d969a47SSean Hefty 			 struct ib_ah_attr *ah_attr);
432a4d61e84SRoland Dreier 
433a7ca1f00SSean Hefty /**
4342e08b587SSean Hefty  * ib_sa_pack_path - Conert a path record from struct ib_sa_path_rec
4352e08b587SSean Hefty  * to IB MAD wire format.
4362e08b587SSean Hefty  */
4372e08b587SSean Hefty void ib_sa_pack_path(struct ib_sa_path_rec *rec, void *attribute);
4382e08b587SSean Hefty 
4392e08b587SSean Hefty /**
440a7ca1f00SSean Hefty  * ib_sa_unpack_path - Convert a path record from MAD format to struct
441a7ca1f00SSean Hefty  * ib_sa_path_rec.
442a7ca1f00SSean Hefty  */
443a7ca1f00SSean Hefty void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec);
444a7ca1f00SSean Hefty 
445aeab97edSErez Shitrit /* Support GuidInfoRecord */
446aeab97edSErez Shitrit int ib_sa_guid_info_rec_query(struct ib_sa_client *client,
447aeab97edSErez Shitrit 			      struct ib_device *device, u8 port_num,
448aeab97edSErez Shitrit 			      struct ib_sa_guidinfo_rec *rec,
449aeab97edSErez Shitrit 			      ib_sa_comp_mask comp_mask, u8 method,
450aeab97edSErez Shitrit 			      int timeout_ms, gfp_t gfp_mask,
451aeab97edSErez Shitrit 			      void (*callback)(int status,
452aeab97edSErez Shitrit 					       struct ib_sa_guidinfo_rec *resp,
453aeab97edSErez Shitrit 					       void *context),
454aeab97edSErez Shitrit 			      void *context,
455aeab97edSErez Shitrit 			      struct ib_sa_query **sa_query);
4562e08b587SSean Hefty 
457*ee1c60b1SDasaratharaman Chandramouli bool ib_sa_sendonly_fullmem_support(struct ib_sa_client *client,
458*ee1c60b1SDasaratharaman Chandramouli 				    struct ib_device *device,
459*ee1c60b1SDasaratharaman Chandramouli 				    u8 port_num);
460628e6f75SErez Shitrit 
461a4d61e84SRoland Dreier #endif /* IB_SA_H */
462