diff options
author | Roland Dreier <roland@eddore.topspincom.com> | 2005-08-25 16:40:04 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-08-26 23:37:38 -0400 |
commit | a4d61e84804f3b14cc35c5e2af768a07c0f64ef6 (patch) | |
tree | ecd1d07e5d5643ef1764e2e99de5ddd4103aec5d /include/rdma/ib_mad.h | |
parent | 1ad62a19f177e61d4dde111ba35fb4badd0c2106 (diff) |
[PATCH] IB: move include files to include/rdma
Move the InfiniBand headers from drivers/infiniband/include to include/rdma.
This allows InfiniBand-using code to live elsewhere, and lets us remove the
ugly EXTRA_CFLAGS include path from the InfiniBand Makefiles.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'include/rdma/ib_mad.h')
-rw-r--r-- | include/rdma/ib_mad.h | 579 |
1 files changed, 579 insertions, 0 deletions
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h new file mode 100644 index 000000000000..fc6b1c18ffc6 --- /dev/null +++ b/include/rdma/ib_mad.h | |||
@@ -0,0 +1,579 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. | ||
3 | * Copyright (c) 2004 Infinicon Corporation. All rights reserved. | ||
4 | * Copyright (c) 2004 Intel Corporation. All rights reserved. | ||
5 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. | ||
6 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. | ||
7 | * | ||
8 | * This software is available to you under a choice of one of two | ||
9 | * licenses. You may choose to be licensed under the terms of the GNU | ||
10 | * General Public License (GPL) Version 2, available from the file | ||
11 | * COPYING in the main directory of this source tree, or the | ||
12 | * OpenIB.org BSD license below: | ||
13 | * | ||
14 | * Redistribution and use in source and binary forms, with or | ||
15 | * without modification, are permitted provided that the following | ||
16 | * conditions are met: | ||
17 | * | ||
18 | * - Redistributions of source code must retain the above | ||
19 | * copyright notice, this list of conditions and the following | ||
20 | * disclaimer. | ||
21 | * | ||
22 | * - Redistributions in binary form must reproduce the above | ||
23 | * copyright notice, this list of conditions and the following | ||
24 | * disclaimer in the documentation and/or other materials | ||
25 | * provided with the distribution. | ||
26 | * | ||
27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
28 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
29 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
30 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
31 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
32 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
33 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
34 | * SOFTWARE. | ||
35 | * | ||
36 | * $Id: ib_mad.h 2775 2005-07-02 13:42:12Z halr $ | ||
37 | */ | ||
38 | |||
39 | #if !defined( IB_MAD_H ) | ||
40 | #define IB_MAD_H | ||
41 | |||
42 | #include <linux/pci.h> | ||
43 | |||
44 | #include <rdma/ib_verbs.h> | ||
45 | |||
46 | /* Management base version */ | ||
47 | #define IB_MGMT_BASE_VERSION 1 | ||
48 | |||
49 | /* Management classes */ | ||
50 | #define IB_MGMT_CLASS_SUBN_LID_ROUTED 0x01 | ||
51 | #define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE 0x81 | ||
52 | #define IB_MGMT_CLASS_SUBN_ADM 0x03 | ||
53 | #define IB_MGMT_CLASS_PERF_MGMT 0x04 | ||
54 | #define IB_MGMT_CLASS_BM 0x05 | ||
55 | #define IB_MGMT_CLASS_DEVICE_MGMT 0x06 | ||
56 | #define IB_MGMT_CLASS_CM 0x07 | ||
57 | #define IB_MGMT_CLASS_SNMP 0x08 | ||
58 | #define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30 | ||
59 | #define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F | ||
60 | |||
61 | #define IB_OPENIB_OUI (0x001405) | ||
62 | |||
63 | /* Management methods */ | ||
64 | #define IB_MGMT_METHOD_GET 0x01 | ||
65 | #define IB_MGMT_METHOD_SET 0x02 | ||
66 | #define IB_MGMT_METHOD_GET_RESP 0x81 | ||
67 | #define IB_MGMT_METHOD_SEND 0x03 | ||
68 | #define IB_MGMT_METHOD_TRAP 0x05 | ||
69 | #define IB_MGMT_METHOD_REPORT 0x06 | ||
70 | #define IB_MGMT_METHOD_REPORT_RESP 0x86 | ||
71 | #define IB_MGMT_METHOD_TRAP_REPRESS 0x07 | ||
72 | |||
73 | #define IB_MGMT_METHOD_RESP 0x80 | ||
74 | |||
75 | #define IB_MGMT_MAX_METHODS 128 | ||
76 | |||
77 | /* RMPP information */ | ||
78 | #define IB_MGMT_RMPP_VERSION 1 | ||
79 | |||
80 | #define IB_MGMT_RMPP_TYPE_DATA 1 | ||
81 | #define IB_MGMT_RMPP_TYPE_ACK 2 | ||
82 | #define IB_MGMT_RMPP_TYPE_STOP 3 | ||
83 | #define IB_MGMT_RMPP_TYPE_ABORT 4 | ||
84 | |||
85 | #define IB_MGMT_RMPP_FLAG_ACTIVE 1 | ||
86 | #define IB_MGMT_RMPP_FLAG_FIRST (1<<1) | ||
87 | #define IB_MGMT_RMPP_FLAG_LAST (1<<2) | ||
88 | |||
89 | #define IB_MGMT_RMPP_NO_RESPTIME 0x1F | ||
90 | |||
91 | #define IB_MGMT_RMPP_STATUS_SUCCESS 0 | ||
92 | #define IB_MGMT_RMPP_STATUS_RESX 1 | ||
93 | #define IB_MGMT_RMPP_STATUS_ABORT_MIN 118 | ||
94 | #define IB_MGMT_RMPP_STATUS_T2L 118 | ||
95 | #define IB_MGMT_RMPP_STATUS_BAD_LEN 119 | ||
96 | #define IB_MGMT_RMPP_STATUS_BAD_SEG 120 | ||
97 | #define IB_MGMT_RMPP_STATUS_BADT 121 | ||
98 | #define IB_MGMT_RMPP_STATUS_W2S 122 | ||
99 | #define IB_MGMT_RMPP_STATUS_S2B 123 | ||
100 | #define IB_MGMT_RMPP_STATUS_BAD_STATUS 124 | ||
101 | #define IB_MGMT_RMPP_STATUS_UNV 125 | ||
102 | #define IB_MGMT_RMPP_STATUS_TMR 126 | ||
103 | #define IB_MGMT_RMPP_STATUS_UNSPEC 127 | ||
104 | #define IB_MGMT_RMPP_STATUS_ABORT_MAX 127 | ||
105 | |||
106 | #define IB_QP0 0 | ||
107 | #define IB_QP1 __constant_htonl(1) | ||
108 | #define IB_QP1_QKEY 0x80010000 | ||
109 | #define IB_QP_SET_QKEY 0x80000000 | ||
110 | |||
111 | struct ib_mad_hdr { | ||
112 | u8 base_version; | ||
113 | u8 mgmt_class; | ||
114 | u8 class_version; | ||
115 | u8 method; | ||
116 | __be16 status; | ||
117 | __be16 class_specific; | ||
118 | __be64 tid; | ||
119 | __be16 attr_id; | ||
120 | __be16 resv; | ||
121 | __be32 attr_mod; | ||
122 | }; | ||
123 | |||
124 | struct ib_rmpp_hdr { | ||
125 | u8 rmpp_version; | ||
126 | u8 rmpp_type; | ||
127 | u8 rmpp_rtime_flags; | ||
128 | u8 rmpp_status; | ||
129 | __be32 seg_num; | ||
130 | __be32 paylen_newwin; | ||
131 | }; | ||
132 | |||
133 | typedef u64 __bitwise ib_sa_comp_mask; | ||
134 | |||
135 | #define IB_SA_COMP_MASK(n) ((__force ib_sa_comp_mask) cpu_to_be64(1ull << n)) | ||
136 | |||
137 | /* | ||
138 | * ib_sa_hdr and ib_sa_mad structures must be packed because they have | ||
139 | * 64-bit fields that are only 32-bit aligned. 64-bit architectures will | ||
140 | * lay them out wrong otherwise. (And unfortunately they are sent on | ||
141 | * the wire so we can't change the layout) | ||
142 | */ | ||
143 | struct ib_sa_hdr { | ||
144 | __be64 sm_key; | ||
145 | __be16 attr_offset; | ||
146 | __be16 reserved; | ||
147 | ib_sa_comp_mask comp_mask; | ||
148 | } __attribute__ ((packed)); | ||
149 | |||
150 | struct ib_mad { | ||
151 | struct ib_mad_hdr mad_hdr; | ||
152 | u8 data[232]; | ||
153 | }; | ||
154 | |||
155 | struct ib_rmpp_mad { | ||
156 | struct ib_mad_hdr mad_hdr; | ||
157 | struct ib_rmpp_hdr rmpp_hdr; | ||
158 | u8 data[220]; | ||
159 | }; | ||
160 | |||
161 | struct ib_sa_mad { | ||
162 | struct ib_mad_hdr mad_hdr; | ||
163 | struct ib_rmpp_hdr rmpp_hdr; | ||
164 | struct ib_sa_hdr sa_hdr; | ||
165 | u8 data[200]; | ||
166 | } __attribute__ ((packed)); | ||
167 | |||
168 | struct ib_vendor_mad { | ||
169 | struct ib_mad_hdr mad_hdr; | ||
170 | struct ib_rmpp_hdr rmpp_hdr; | ||
171 | u8 reserved; | ||
172 | u8 oui[3]; | ||
173 | u8 data[216]; | ||
174 | }; | ||
175 | |||
176 | /** | ||
177 | * ib_mad_send_buf - MAD data buffer and work request for sends. | ||
178 | * @mad: References an allocated MAD data buffer. The size of the data | ||
179 | * buffer is specified in the @send_wr.length field. | ||
180 | * @mapping: DMA mapping information. | ||
181 | * @mad_agent: MAD agent that allocated the buffer. | ||
182 | * @context: User-controlled context fields. | ||
183 | * @send_wr: An initialized work request structure used when sending the MAD. | ||
184 | * The wr_id field of the work request is initialized to reference this | ||
185 | * data structure. | ||
186 | * @sge: A scatter-gather list referenced by the work request. | ||
187 | * | ||
188 | * Users are responsible for initializing the MAD buffer itself, with the | ||
189 | * exception of specifying the payload length field in any RMPP MAD. | ||
190 | */ | ||
191 | struct ib_mad_send_buf { | ||
192 | struct ib_mad *mad; | ||
193 | DECLARE_PCI_UNMAP_ADDR(mapping) | ||
194 | struct ib_mad_agent *mad_agent; | ||
195 | void *context[2]; | ||
196 | struct ib_send_wr send_wr; | ||
197 | struct ib_sge sge; | ||
198 | }; | ||
199 | |||
200 | /** | ||
201 | * ib_get_rmpp_resptime - Returns the RMPP response time. | ||
202 | * @rmpp_hdr: An RMPP header. | ||
203 | */ | ||
204 | static inline u8 ib_get_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr) | ||
205 | { | ||
206 | return rmpp_hdr->rmpp_rtime_flags >> 3; | ||
207 | } | ||
208 | |||
209 | /** | ||
210 | * ib_get_rmpp_flags - Returns the RMPP flags. | ||
211 | * @rmpp_hdr: An RMPP header. | ||
212 | */ | ||
213 | static inline u8 ib_get_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr) | ||
214 | { | ||
215 | return rmpp_hdr->rmpp_rtime_flags & 0x7; | ||
216 | } | ||
217 | |||
218 | /** | ||
219 | * ib_set_rmpp_resptime - Sets the response time in an RMPP header. | ||
220 | * @rmpp_hdr: An RMPP header. | ||
221 | * @rtime: The response time to set. | ||
222 | */ | ||
223 | static inline void ib_set_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr, u8 rtime) | ||
224 | { | ||
225 | rmpp_hdr->rmpp_rtime_flags = ib_get_rmpp_flags(rmpp_hdr) | (rtime << 3); | ||
226 | } | ||
227 | |||
228 | /** | ||
229 | * ib_set_rmpp_flags - Sets the flags in an RMPP header. | ||
230 | * @rmpp_hdr: An RMPP header. | ||
231 | * @flags: The flags to set. | ||
232 | */ | ||
233 | static inline void ib_set_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr, u8 flags) | ||
234 | { | ||
235 | rmpp_hdr->rmpp_rtime_flags = (rmpp_hdr->rmpp_rtime_flags & 0xF1) | | ||
236 | (flags & 0x7); | ||
237 | } | ||
238 | |||
239 | struct ib_mad_agent; | ||
240 | struct ib_mad_send_wc; | ||
241 | struct ib_mad_recv_wc; | ||
242 | |||
243 | /** | ||
244 | * ib_mad_send_handler - callback handler for a sent MAD. | ||
245 | * @mad_agent: MAD agent that sent the MAD. | ||
246 | * @mad_send_wc: Send work completion information on the sent MAD. | ||
247 | */ | ||
248 | typedef void (*ib_mad_send_handler)(struct ib_mad_agent *mad_agent, | ||
249 | struct ib_mad_send_wc *mad_send_wc); | ||
250 | |||
251 | /** | ||
252 | * ib_mad_snoop_handler - Callback handler for snooping sent MADs. | ||
253 | * @mad_agent: MAD agent that snooped the MAD. | ||
254 | * @send_wr: Work request information on the sent MAD. | ||
255 | * @mad_send_wc: Work completion information on the sent MAD. Valid | ||
256 | * only for snooping that occurs on a send completion. | ||
257 | * | ||
258 | * Clients snooping MADs should not modify data referenced by the @send_wr | ||
259 | * or @mad_send_wc. | ||
260 | */ | ||
261 | typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent, | ||
262 | struct ib_send_wr *send_wr, | ||
263 | struct ib_mad_send_wc *mad_send_wc); | ||
264 | |||
265 | /** | ||
266 | * ib_mad_recv_handler - callback handler for a received MAD. | ||
267 | * @mad_agent: MAD agent requesting the received MAD. | ||
268 | * @mad_recv_wc: Received work completion information on the received MAD. | ||
269 | * | ||
270 | * MADs received in response to a send request operation will be handed to | ||
271 | * the user after the send operation completes. All data buffers given | ||
272 | * to registered agents through this routine are owned by the receiving | ||
273 | * client, except for snooping agents. Clients snooping MADs should not | ||
274 | * modify the data referenced by @mad_recv_wc. | ||
275 | */ | ||
276 | typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent, | ||
277 | struct ib_mad_recv_wc *mad_recv_wc); | ||
278 | |||
279 | /** | ||
280 | * ib_mad_agent - Used to track MAD registration with the access layer. | ||
281 | * @device: Reference to device registration is on. | ||
282 | * @qp: Reference to QP used for sending and receiving MADs. | ||
283 | * @mr: Memory region for system memory usable for DMA. | ||
284 | * @recv_handler: Callback handler for a received MAD. | ||
285 | * @send_handler: Callback handler for a sent MAD. | ||
286 | * @snoop_handler: Callback handler for snooped sent MADs. | ||
287 | * @context: User-specified context associated with this registration. | ||
288 | * @hi_tid: Access layer assigned transaction ID for this client. | ||
289 | * Unsolicited MADs sent by this client will have the upper 32-bits | ||
290 | * of their TID set to this value. | ||
291 | * @port_num: Port number on which QP is registered | ||
292 | * @rmpp_version: If set, indicates the RMPP version used by this agent. | ||
293 | */ | ||
294 | struct ib_mad_agent { | ||
295 | struct ib_device *device; | ||
296 | struct ib_qp *qp; | ||
297 | struct ib_mr *mr; | ||
298 | ib_mad_recv_handler recv_handler; | ||
299 | ib_mad_send_handler send_handler; | ||
300 | ib_mad_snoop_handler snoop_handler; | ||
301 | void *context; | ||
302 | u32 hi_tid; | ||
303 | u8 port_num; | ||
304 | u8 rmpp_version; | ||
305 | }; | ||
306 | |||
307 | /** | ||
308 | * ib_mad_send_wc - MAD send completion information. | ||
309 | * @wr_id: Work request identifier associated with the send MAD request. | ||
310 | * @status: Completion status. | ||
311 | * @vendor_err: Optional vendor error information returned with a failed | ||
312 | * request. | ||
313 | */ | ||
314 | struct ib_mad_send_wc { | ||
315 | u64 wr_id; | ||
316 | enum ib_wc_status status; | ||
317 | u32 vendor_err; | ||
318 | }; | ||
319 | |||
320 | /** | ||
321 | * ib_mad_recv_buf - received MAD buffer information. | ||
322 | * @list: Reference to next data buffer for a received RMPP MAD. | ||
323 | * @grh: References a data buffer containing the global route header. | ||
324 | * The data refereced by this buffer is only valid if the GRH is | ||
325 | * valid. | ||
326 | * @mad: References the start of the received MAD. | ||
327 | */ | ||
328 | struct ib_mad_recv_buf { | ||
329 | struct list_head list; | ||
330 | struct ib_grh *grh; | ||
331 | struct ib_mad *mad; | ||
332 | }; | ||
333 | |||
334 | /** | ||
335 | * ib_mad_recv_wc - received MAD information. | ||
336 | * @wc: Completion information for the received data. | ||
337 | * @recv_buf: Specifies the location of the received data buffer(s). | ||
338 | * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers. | ||
339 | * @mad_len: The length of the received MAD, without duplicated headers. | ||
340 | * | ||
341 | * For received response, the wr_id field of the wc is set to the wr_id | ||
342 | * for the corresponding send request. | ||
343 | */ | ||
344 | struct ib_mad_recv_wc { | ||
345 | struct ib_wc *wc; | ||
346 | struct ib_mad_recv_buf recv_buf; | ||
347 | struct list_head rmpp_list; | ||
348 | int mad_len; | ||
349 | }; | ||
350 | |||
351 | /** | ||
352 | * ib_mad_reg_req - MAD registration request | ||
353 | * @mgmt_class: Indicates which management class of MADs should be receive | ||
354 | * by the caller. This field is only required if the user wishes to | ||
355 | * receive unsolicited MADs, otherwise it should be 0. | ||
356 | * @mgmt_class_version: Indicates which version of MADs for the given | ||
357 | * management class to receive. | ||
358 | * @oui: Indicates IEEE OUI when mgmt_class is a vendor class | ||
359 | * in the range from 0x30 to 0x4f. Otherwise not used. | ||
360 | * @method_mask: The caller will receive unsolicited MADs for any method | ||
361 | * where @method_mask = 1. | ||
362 | */ | ||
363 | struct ib_mad_reg_req { | ||
364 | u8 mgmt_class; | ||
365 | u8 mgmt_class_version; | ||
366 | u8 oui[3]; | ||
367 | DECLARE_BITMAP(method_mask, IB_MGMT_MAX_METHODS); | ||
368 | }; | ||
369 | |||
370 | /** | ||
371 | * ib_register_mad_agent - Register to send/receive MADs. | ||
372 | * @device: The device to register with. | ||
373 | * @port_num: The port on the specified device to use. | ||
374 | * @qp_type: Specifies which QP to access. Must be either | ||
375 | * IB_QPT_SMI or IB_QPT_GSI. | ||
376 | * @mad_reg_req: Specifies which unsolicited MADs should be received | ||
377 | * by the caller. This parameter may be NULL if the caller only | ||
378 | * wishes to receive solicited responses. | ||
379 | * @rmpp_version: If set, indicates that the client will send | ||
380 | * and receive MADs that contain the RMPP header for the given version. | ||
381 | * If set to 0, indicates that RMPP is not used by this client. | ||
382 | * @send_handler: The completion callback routine invoked after a send | ||
383 | * request has completed. | ||
384 | * @recv_handler: The completion callback routine invoked for a received | ||
385 | * MAD. | ||
386 | * @context: User specified context associated with the registration. | ||
387 | */ | ||
388 | struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, | ||
389 | u8 port_num, | ||
390 | enum ib_qp_type qp_type, | ||
391 | struct ib_mad_reg_req *mad_reg_req, | ||
392 | u8 rmpp_version, | ||
393 | ib_mad_send_handler send_handler, | ||
394 | ib_mad_recv_handler recv_handler, | ||
395 | void *context); | ||
396 | |||
397 | enum ib_mad_snoop_flags { | ||
398 | /*IB_MAD_SNOOP_POSTED_SENDS = 1,*/ | ||
399 | /*IB_MAD_SNOOP_RMPP_SENDS = (1<<1),*/ | ||
400 | IB_MAD_SNOOP_SEND_COMPLETIONS = (1<<2), | ||
401 | /*IB_MAD_SNOOP_RMPP_SEND_COMPLETIONS = (1<<3),*/ | ||
402 | IB_MAD_SNOOP_RECVS = (1<<4) | ||
403 | /*IB_MAD_SNOOP_RMPP_RECVS = (1<<5),*/ | ||
404 | /*IB_MAD_SNOOP_REDIRECTED_QPS = (1<<6)*/ | ||
405 | }; | ||
406 | |||
407 | /** | ||
408 | * ib_register_mad_snoop - Register to snoop sent and received MADs. | ||
409 | * @device: The device to register with. | ||
410 | * @port_num: The port on the specified device to use. | ||
411 | * @qp_type: Specifies which QP traffic to snoop. Must be either | ||
412 | * IB_QPT_SMI or IB_QPT_GSI. | ||
413 | * @mad_snoop_flags: Specifies information where snooping occurs. | ||
414 | * @send_handler: The callback routine invoked for a snooped send. | ||
415 | * @recv_handler: The callback routine invoked for a snooped receive. | ||
416 | * @context: User specified context associated with the registration. | ||
417 | */ | ||
418 | struct ib_mad_agent *ib_register_mad_snoop(struct ib_device *device, | ||
419 | u8 port_num, | ||
420 | enum ib_qp_type qp_type, | ||
421 | int mad_snoop_flags, | ||
422 | ib_mad_snoop_handler snoop_handler, | ||
423 | ib_mad_recv_handler recv_handler, | ||
424 | void *context); | ||
425 | |||
426 | /** | ||
427 | * ib_unregister_mad_agent - Unregisters a client from using MAD services. | ||
428 | * @mad_agent: Corresponding MAD registration request to deregister. | ||
429 | * | ||
430 | * After invoking this routine, MAD services are no longer usable by the | ||
431 | * client on the associated QP. | ||
432 | */ | ||
433 | int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent); | ||
434 | |||
435 | /** | ||
436 | * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated | ||
437 | * with the registered client. | ||
438 | * @mad_agent: Specifies the associated registration to post the send to. | ||
439 | * @send_wr: Specifies the information needed to send the MAD(s). | ||
440 | * @bad_send_wr: Specifies the MAD on which an error was encountered. | ||
441 | * | ||
442 | * Sent MADs are not guaranteed to complete in the order that they were posted. | ||
443 | * | ||
444 | * If the MAD requires RMPP, the data buffer should contain a single copy | ||
445 | * of the common MAD, RMPP, and class specific headers, followed by the class | ||
446 | * defined data. If the class defined data would not divide evenly into | ||
447 | * RMPP segments, then space must be allocated at the end of the referenced | ||
448 | * buffer for any required padding. To indicate the amount of class defined | ||
449 | * data being transferred, the paylen_newwin field in the RMPP header should | ||
450 | * be set to the size of the class specific header plus the amount of class | ||
451 | * defined data being transferred. The paylen_newwin field should be | ||
452 | * specified in network-byte order. | ||
453 | */ | ||
454 | int ib_post_send_mad(struct ib_mad_agent *mad_agent, | ||
455 | struct ib_send_wr *send_wr, | ||
456 | struct ib_send_wr **bad_send_wr); | ||
457 | |||
458 | /** | ||
459 | * ib_coalesce_recv_mad - Coalesces received MAD data into a single buffer. | ||
460 | * @mad_recv_wc: Work completion information for a received MAD. | ||
461 | * @buf: User-provided data buffer to receive the coalesced buffers. The | ||
462 | * referenced buffer should be at least the size of the mad_len specified | ||
463 | * by @mad_recv_wc. | ||
464 | * | ||
465 | * This call copies a chain of received MAD segments into a single data buffer, | ||
466 | * removing duplicated headers. | ||
467 | */ | ||
468 | void ib_coalesce_recv_mad(struct ib_mad_recv_wc *mad_recv_wc, void *buf); | ||
469 | |||
470 | /** | ||
471 | * ib_free_recv_mad - Returns data buffers used to receive a MAD. | ||
472 | * @mad_recv_wc: Work completion information for a received MAD. | ||
473 | * | ||
474 | * Clients receiving MADs through their ib_mad_recv_handler must call this | ||
475 | * routine to return the work completion buffers to the access layer. | ||
476 | */ | ||
477 | void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc); | ||
478 | |||
479 | /** | ||
480 | * ib_cancel_mad - Cancels an outstanding send MAD operation. | ||
481 | * @mad_agent: Specifies the registration associated with sent MAD. | ||
482 | * @wr_id: Indicates the work request identifier of the MAD to cancel. | ||
483 | * | ||
484 | * MADs will be returned to the user through the corresponding | ||
485 | * ib_mad_send_handler. | ||
486 | */ | ||
487 | void ib_cancel_mad(struct ib_mad_agent *mad_agent, u64 wr_id); | ||
488 | |||
489 | /** | ||
490 | * ib_modify_mad - Modifies an outstanding send MAD operation. | ||
491 | * @mad_agent: Specifies the registration associated with sent MAD. | ||
492 | * @wr_id: Indicates the work request identifier of the MAD to modify. | ||
493 | * @timeout_ms: New timeout value for sent MAD. | ||
494 | * | ||
495 | * This call will reset the timeout value for a sent MAD to the specified | ||
496 | * value. | ||
497 | */ | ||
498 | int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms); | ||
499 | |||
500 | /** | ||
501 | * ib_redirect_mad_qp - Registers a QP for MAD services. | ||
502 | * @qp: Reference to a QP that requires MAD services. | ||
503 | * @rmpp_version: If set, indicates that the client will send | ||
504 | * and receive MADs that contain the RMPP header for the given version. | ||
505 | * If set to 0, indicates that RMPP is not used by this client. | ||
506 | * @send_handler: The completion callback routine invoked after a send | ||
507 | * request has completed. | ||
508 | * @recv_handler: The completion callback routine invoked for a received | ||
509 | * MAD. | ||
510 | * @context: User specified context associated with the registration. | ||
511 | * | ||
512 | * Use of this call allows clients to use MAD services, such as RMPP, | ||
513 | * on user-owned QPs. After calling this routine, users may send | ||
514 | * MADs on the specified QP by calling ib_mad_post_send. | ||
515 | */ | ||
516 | struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp, | ||
517 | u8 rmpp_version, | ||
518 | ib_mad_send_handler send_handler, | ||
519 | ib_mad_recv_handler recv_handler, | ||
520 | void *context); | ||
521 | |||
522 | /** | ||
523 | * ib_process_mad_wc - Processes a work completion associated with a | ||
524 | * MAD sent or received on a redirected QP. | ||
525 | * @mad_agent: Specifies the registered MAD service using the redirected QP. | ||
526 | * @wc: References a work completion associated with a sent or received | ||
527 | * MAD segment. | ||
528 | * | ||
529 | * This routine is used to complete or continue processing on a MAD request. | ||
530 | * If the work completion is associated with a send operation, calling | ||
531 | * this routine is required to continue an RMPP transfer or to wait for a | ||
532 | * corresponding response, if it is a request. If the work completion is | ||
533 | * associated with a receive operation, calling this routine is required to | ||
534 | * process an inbound or outbound RMPP transfer, or to match a response MAD | ||
535 | * with its corresponding request. | ||
536 | */ | ||
537 | int ib_process_mad_wc(struct ib_mad_agent *mad_agent, | ||
538 | struct ib_wc *wc); | ||
539 | |||
540 | /** | ||
541 | * ib_create_send_mad - Allocate and initialize a data buffer and work request | ||
542 | * for sending a MAD. | ||
543 | * @mad_agent: Specifies the registered MAD service to associate with the MAD. | ||
544 | * @remote_qpn: Specifies the QPN of the receiving node. | ||
545 | * @pkey_index: Specifies which PKey the MAD will be sent using. This field | ||
546 | * is valid only if the remote_qpn is QP 1. | ||
547 | * @ah: References the address handle used to transfer to the remote node. | ||
548 | * @rmpp_active: Indicates if the send will enable RMPP. | ||
549 | * @hdr_len: Indicates the size of the data header of the MAD. This length | ||
550 | * should include the common MAD header, RMPP header, plus any class | ||
551 | * specific header. | ||
552 | * @data_len: Indicates the size of any user-transferred data. The call will | ||
553 | * automatically adjust the allocated buffer size to account for any | ||
554 | * additional padding that may be necessary. | ||
555 | * @gfp_mask: GFP mask used for the memory allocation. | ||
556 | * | ||
557 | * This is a helper routine that may be used to allocate a MAD. Users are | ||
558 | * not required to allocate outbound MADs using this call. The returned | ||
559 | * MAD send buffer will reference a data buffer usable for sending a MAD, along | ||
560 | * with an initialized work request structure. Users may modify the returned | ||
561 | * MAD data buffer or work request before posting the send. | ||
562 | * | ||
563 | * The returned data buffer will be cleared. Users are responsible for | ||
564 | * initializing the common MAD and any class specific headers. If @rmpp_active | ||
565 | * is set, the RMPP header will be initialized for sending. | ||
566 | */ | ||
567 | struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent, | ||
568 | u32 remote_qpn, u16 pkey_index, | ||
569 | struct ib_ah *ah, int rmpp_active, | ||
570 | int hdr_len, int data_len, | ||
571 | unsigned int __nocast gfp_mask); | ||
572 | |||
573 | /** | ||
574 | * ib_free_send_mad - Returns data buffers used to send a MAD. | ||
575 | * @send_buf: Previously allocated send data buffer. | ||
576 | */ | ||
577 | void ib_free_send_mad(struct ib_mad_send_buf *send_buf); | ||
578 | |||
579 | #endif /* IB_MAD_H */ | ||