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