blob: 63237805d6af56755717fa6fbf67969d6ed5447e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 *
Hal Rosenstockd2082ee2005-07-27 11:45:36 -070036 * $Id: ib_mad.h 2775 2005-07-02 13:42:12Z halr $
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 */
38
39#if !defined( IB_MAD_H )
40#define IB_MAD_H
41
Hal Rosenstock824c8ae2005-07-27 11:45:23 -070042#include <linux/pci.h>
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <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
Hal Rosenstockd2082ee2005-07-27 11:45:36 -070061#define IB_OPENIB_OUI (0x001405)
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063/* 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
Hal Rosenstockd2082ee2005-07-27 11:45:36 -070077/* 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_T2L 118
94#define IB_MGMT_RMPP_STATUS_BAD_LEN 119
95#define IB_MGMT_RMPP_STATUS_BAD_SEG 120
96#define IB_MGMT_RMPP_STATUS_BADT 121
97#define IB_MGMT_RMPP_STATUS_W2S 122
98#define IB_MGMT_RMPP_STATUS_S2B 123
99#define IB_MGMT_RMPP_STATUS_BAD_STATUS 124
100#define IB_MGMT_RMPP_STATUS_UNV 125
101#define IB_MGMT_RMPP_STATUS_TMR 126
102#define IB_MGMT_RMPP_STATUS_UNSPEC 127
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#define IB_QP0 0
105#define IB_QP1 __constant_htonl(1)
106#define IB_QP1_QKEY 0x80010000
Hal Rosenstock824c8ae2005-07-27 11:45:23 -0700107#define IB_QP_SET_QKEY 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109struct ib_mad_hdr {
110 u8 base_version;
111 u8 mgmt_class;
112 u8 class_version;
113 u8 method;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700114 __be16 status;
115 __be16 class_specific;
116 __be64 tid;
117 __be16 attr_id;
118 __be16 resv;
119 __be32 attr_mod;
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700120};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
122struct ib_rmpp_hdr {
123 u8 rmpp_version;
124 u8 rmpp_type;
125 u8 rmpp_rtime_flags;
126 u8 rmpp_status;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700127 __be32 seg_num;
128 __be32 paylen_newwin;
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700129};
130
131typedef u64 __bitwise ib_sa_comp_mask;
132
133#define IB_SA_COMP_MASK(n) ((__force ib_sa_comp_mask) cpu_to_be64(1ull << n))
134
135/*
136 * ib_sa_hdr and ib_sa_mad structures must be packed because they have
137 * 64-bit fields that are only 32-bit aligned. 64-bit architectures will
138 * lay them out wrong otherwise. (And unfortunately they are sent on
139 * the wire so we can't change the layout)
140 */
141struct ib_sa_hdr {
Sean Hefty97f52eb2005-08-13 21:05:57 -0700142 __be64 sm_key;
143 __be16 attr_offset;
144 __be16 reserved;
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700145 ib_sa_comp_mask comp_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146} __attribute__ ((packed));
147
148struct ib_mad {
149 struct ib_mad_hdr mad_hdr;
150 u8 data[232];
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700151};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
153struct ib_rmpp_mad {
154 struct ib_mad_hdr mad_hdr;
155 struct ib_rmpp_hdr rmpp_hdr;
156 u8 data[220];
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700157};
158
159struct ib_sa_mad {
160 struct ib_mad_hdr mad_hdr;
161 struct ib_rmpp_hdr rmpp_hdr;
162 struct ib_sa_hdr sa_hdr;
163 u8 data[200];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164} __attribute__ ((packed));
165
166struct ib_vendor_mad {
167 struct ib_mad_hdr mad_hdr;
168 struct ib_rmpp_hdr rmpp_hdr;
169 u8 reserved;
170 u8 oui[3];
171 u8 data[216];
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700172};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Hal Rosenstock824c8ae2005-07-27 11:45:23 -0700174/**
175 * ib_mad_send_buf - MAD data buffer and work request for sends.
176 * @mad: References an allocated MAD data buffer. The size of the data
177 * buffer is specified in the @send_wr.length field.
178 * @mapping: DMA mapping information.
179 * @mad_agent: MAD agent that allocated the buffer.
180 * @context: User-controlled context fields.
181 * @send_wr: An initialized work request structure used when sending the MAD.
182 * The wr_id field of the work request is initialized to reference this
183 * data structure.
184 * @sge: A scatter-gather list referenced by the work request.
185 *
186 * Users are responsible for initializing the MAD buffer itself, with the
187 * exception of specifying the payload length field in any RMPP MAD.
188 */
189struct ib_mad_send_buf {
190 struct ib_mad *mad;
191 DECLARE_PCI_UNMAP_ADDR(mapping)
192 struct ib_mad_agent *mad_agent;
193 void *context[2];
194 struct ib_send_wr send_wr;
195 struct ib_sge sge;
196};
197
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700198/**
199 * ib_get_rmpp_resptime - Returns the RMPP response time.
200 * @rmpp_hdr: An RMPP header.
201 */
202static inline u8 ib_get_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr)
203{
204 return rmpp_hdr->rmpp_rtime_flags >> 3;
205}
206
207/**
208 * ib_get_rmpp_flags - Returns the RMPP flags.
209 * @rmpp_hdr: An RMPP header.
210 */
211static inline u8 ib_get_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr)
212{
213 return rmpp_hdr->rmpp_rtime_flags & 0x7;
214}
215
216/**
217 * ib_set_rmpp_resptime - Sets the response time in an RMPP header.
218 * @rmpp_hdr: An RMPP header.
219 * @rtime: The response time to set.
220 */
221static inline void ib_set_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr, u8 rtime)
222{
223 rmpp_hdr->rmpp_rtime_flags = ib_get_rmpp_flags(rmpp_hdr) | (rtime << 3);
224}
225
226/**
227 * ib_set_rmpp_flags - Sets the flags in an RMPP header.
228 * @rmpp_hdr: An RMPP header.
229 * @flags: The flags to set.
230 */
231static inline void ib_set_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr, u8 flags)
232{
233 rmpp_hdr->rmpp_rtime_flags = (rmpp_hdr->rmpp_rtime_flags & 0xF1) |
234 (flags & 0x7);
235}
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237struct ib_mad_agent;
238struct ib_mad_send_wc;
239struct ib_mad_recv_wc;
240
241/**
242 * ib_mad_send_handler - callback handler for a sent MAD.
243 * @mad_agent: MAD agent that sent the MAD.
244 * @mad_send_wc: Send work completion information on the sent MAD.
245 */
246typedef void (*ib_mad_send_handler)(struct ib_mad_agent *mad_agent,
247 struct ib_mad_send_wc *mad_send_wc);
248
249/**
250 * ib_mad_snoop_handler - Callback handler for snooping sent MADs.
251 * @mad_agent: MAD agent that snooped the MAD.
252 * @send_wr: Work request information on the sent MAD.
253 * @mad_send_wc: Work completion information on the sent MAD. Valid
254 * only for snooping that occurs on a send completion.
255 *
256 * Clients snooping MADs should not modify data referenced by the @send_wr
257 * or @mad_send_wc.
258 */
259typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent,
260 struct ib_send_wr *send_wr,
261 struct ib_mad_send_wc *mad_send_wc);
262
263/**
264 * ib_mad_recv_handler - callback handler for a received MAD.
265 * @mad_agent: MAD agent requesting the received MAD.
266 * @mad_recv_wc: Received work completion information on the received MAD.
267 *
268 * MADs received in response to a send request operation will be handed to
269 * the user after the send operation completes. All data buffers given
270 * to registered agents through this routine are owned by the receiving
271 * client, except for snooping agents. Clients snooping MADs should not
272 * modify the data referenced by @mad_recv_wc.
273 */
274typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent,
275 struct ib_mad_recv_wc *mad_recv_wc);
276
277/**
278 * ib_mad_agent - Used to track MAD registration with the access layer.
279 * @device: Reference to device registration is on.
280 * @qp: Reference to QP used for sending and receiving MADs.
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700281 * @mr: Memory region for system memory usable for DMA.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 * @recv_handler: Callback handler for a received MAD.
283 * @send_handler: Callback handler for a sent MAD.
284 * @snoop_handler: Callback handler for snooped sent MADs.
285 * @context: User-specified context associated with this registration.
286 * @hi_tid: Access layer assigned transaction ID for this client.
287 * Unsolicited MADs sent by this client will have the upper 32-bits
288 * of their TID set to this value.
289 * @port_num: Port number on which QP is registered
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700290 * @rmpp_version: If set, indicates the RMPP version used by this agent.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 */
292struct ib_mad_agent {
293 struct ib_device *device;
294 struct ib_qp *qp;
Hal Rosenstockb82cab62005-07-27 11:45:22 -0700295 struct ib_mr *mr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 ib_mad_recv_handler recv_handler;
297 ib_mad_send_handler send_handler;
298 ib_mad_snoop_handler snoop_handler;
299 void *context;
300 u32 hi_tid;
301 u8 port_num;
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700302 u8 rmpp_version;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303};
304
305/**
306 * ib_mad_send_wc - MAD send completion information.
307 * @wr_id: Work request identifier associated with the send MAD request.
308 * @status: Completion status.
309 * @vendor_err: Optional vendor error information returned with a failed
310 * request.
311 */
312struct ib_mad_send_wc {
313 u64 wr_id;
314 enum ib_wc_status status;
315 u32 vendor_err;
316};
317
318/**
319 * ib_mad_recv_buf - received MAD buffer information.
320 * @list: Reference to next data buffer for a received RMPP MAD.
321 * @grh: References a data buffer containing the global route header.
322 * The data refereced by this buffer is only valid if the GRH is
323 * valid.
324 * @mad: References the start of the received MAD.
325 */
326struct ib_mad_recv_buf {
327 struct list_head list;
328 struct ib_grh *grh;
329 struct ib_mad *mad;
330};
331
332/**
333 * ib_mad_recv_wc - received MAD information.
334 * @wc: Completion information for the received data.
335 * @recv_buf: Specifies the location of the received data buffer(s).
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700336 * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 * @mad_len: The length of the received MAD, without duplicated headers.
338 *
339 * For received response, the wr_id field of the wc is set to the wr_id
340 * for the corresponding send request.
341 */
342struct ib_mad_recv_wc {
343 struct ib_wc *wc;
344 struct ib_mad_recv_buf recv_buf;
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700345 struct list_head rmpp_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 int mad_len;
347};
348
349/**
350 * ib_mad_reg_req - MAD registration request
351 * @mgmt_class: Indicates which management class of MADs should be receive
352 * by the caller. This field is only required if the user wishes to
353 * receive unsolicited MADs, otherwise it should be 0.
354 * @mgmt_class_version: Indicates which version of MADs for the given
355 * management class to receive.
356 * @oui: Indicates IEEE OUI when mgmt_class is a vendor class
357 * in the range from 0x30 to 0x4f. Otherwise not used.
358 * @method_mask: The caller will receive unsolicited MADs for any method
359 * where @method_mask = 1.
360 */
361struct ib_mad_reg_req {
362 u8 mgmt_class;
363 u8 mgmt_class_version;
364 u8 oui[3];
365 DECLARE_BITMAP(method_mask, IB_MGMT_MAX_METHODS);
366};
367
368/**
369 * ib_register_mad_agent - Register to send/receive MADs.
370 * @device: The device to register with.
371 * @port_num: The port on the specified device to use.
372 * @qp_type: Specifies which QP to access. Must be either
373 * IB_QPT_SMI or IB_QPT_GSI.
374 * @mad_reg_req: Specifies which unsolicited MADs should be received
375 * by the caller. This parameter may be NULL if the caller only
376 * wishes to receive solicited responses.
377 * @rmpp_version: If set, indicates that the client will send
378 * and receive MADs that contain the RMPP header for the given version.
379 * If set to 0, indicates that RMPP is not used by this client.
380 * @send_handler: The completion callback routine invoked after a send
381 * request has completed.
382 * @recv_handler: The completion callback routine invoked for a received
383 * MAD.
384 * @context: User specified context associated with the registration.
385 */
386struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
387 u8 port_num,
388 enum ib_qp_type qp_type,
389 struct ib_mad_reg_req *mad_reg_req,
390 u8 rmpp_version,
391 ib_mad_send_handler send_handler,
392 ib_mad_recv_handler recv_handler,
393 void *context);
394
395enum ib_mad_snoop_flags {
396 /*IB_MAD_SNOOP_POSTED_SENDS = 1,*/
397 /*IB_MAD_SNOOP_RMPP_SENDS = (1<<1),*/
398 IB_MAD_SNOOP_SEND_COMPLETIONS = (1<<2),
399 /*IB_MAD_SNOOP_RMPP_SEND_COMPLETIONS = (1<<3),*/
400 IB_MAD_SNOOP_RECVS = (1<<4)
401 /*IB_MAD_SNOOP_RMPP_RECVS = (1<<5),*/
402 /*IB_MAD_SNOOP_REDIRECTED_QPS = (1<<6)*/
403};
404
405/**
406 * ib_register_mad_snoop - Register to snoop sent and received MADs.
407 * @device: The device to register with.
408 * @port_num: The port on the specified device to use.
409 * @qp_type: Specifies which QP traffic to snoop. Must be either
410 * IB_QPT_SMI or IB_QPT_GSI.
411 * @mad_snoop_flags: Specifies information where snooping occurs.
412 * @send_handler: The callback routine invoked for a snooped send.
413 * @recv_handler: The callback routine invoked for a snooped receive.
414 * @context: User specified context associated with the registration.
415 */
416struct ib_mad_agent *ib_register_mad_snoop(struct ib_device *device,
417 u8 port_num,
418 enum ib_qp_type qp_type,
419 int mad_snoop_flags,
420 ib_mad_snoop_handler snoop_handler,
421 ib_mad_recv_handler recv_handler,
422 void *context);
423
424/**
425 * ib_unregister_mad_agent - Unregisters a client from using MAD services.
426 * @mad_agent: Corresponding MAD registration request to deregister.
427 *
428 * After invoking this routine, MAD services are no longer usable by the
429 * client on the associated QP.
430 */
431int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent);
432
433/**
434 * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
435 * with the registered client.
436 * @mad_agent: Specifies the associated registration to post the send to.
437 * @send_wr: Specifies the information needed to send the MAD(s).
438 * @bad_send_wr: Specifies the MAD on which an error was encountered.
439 *
440 * Sent MADs are not guaranteed to complete in the order that they were posted.
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700441 *
442 * If the MAD requires RMPP, the data buffer should contain a single copy
443 * of the common MAD, RMPP, and class specific headers, followed by the class
444 * defined data. If the class defined data would not divide evenly into
445 * RMPP segments, then space must be allocated at the end of the referenced
446 * buffer for any required padding. To indicate the amount of class defined
447 * data being transferred, the paylen_newwin field in the RMPP header should
448 * be set to the size of the class specific header plus the amount of class
449 * defined data being transferred. The paylen_newwin field should be
450 * specified in network-byte order.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 */
452int ib_post_send_mad(struct ib_mad_agent *mad_agent,
453 struct ib_send_wr *send_wr,
454 struct ib_send_wr **bad_send_wr);
455
456/**
457 * ib_coalesce_recv_mad - Coalesces received MAD data into a single buffer.
458 * @mad_recv_wc: Work completion information for a received MAD.
459 * @buf: User-provided data buffer to receive the coalesced buffers. The
460 * referenced buffer should be at least the size of the mad_len specified
461 * by @mad_recv_wc.
462 *
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700463 * This call copies a chain of received MAD segments into a single data buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 * removing duplicated headers.
465 */
Hal Rosenstockdf9f9ea2005-07-27 11:45:28 -0700466void ib_coalesce_recv_mad(struct ib_mad_recv_wc *mad_recv_wc, void *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
468/**
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700469 * ib_free_recv_mad - Returns data buffers used to receive a MAD.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 * @mad_recv_wc: Work completion information for a received MAD.
471 *
472 * Clients receiving MADs through their ib_mad_recv_handler must call this
473 * routine to return the work completion buffers to the access layer.
474 */
475void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc);
476
477/**
478 * ib_cancel_mad - Cancels an outstanding send MAD operation.
479 * @mad_agent: Specifies the registration associated with sent MAD.
480 * @wr_id: Indicates the work request identifier of the MAD to cancel.
481 *
482 * MADs will be returned to the user through the corresponding
483 * ib_mad_send_handler.
484 */
Hal Rosenstock03b61ad2005-07-27 11:45:32 -0700485void ib_cancel_mad(struct ib_mad_agent *mad_agent, u64 wr_id);
486
487/**
488 * ib_modify_mad - Modifies an outstanding send MAD operation.
489 * @mad_agent: Specifies the registration associated with sent MAD.
490 * @wr_id: Indicates the work request identifier of the MAD to modify.
491 * @timeout_ms: New timeout value for sent MAD.
492 *
493 * This call will reset the timeout value for a sent MAD to the specified
494 * value.
495 */
496int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497
498/**
499 * ib_redirect_mad_qp - Registers a QP for MAD services.
500 * @qp: Reference to a QP that requires MAD services.
501 * @rmpp_version: If set, indicates that the client will send
502 * and receive MADs that contain the RMPP header for the given version.
503 * If set to 0, indicates that RMPP is not used by this client.
504 * @send_handler: The completion callback routine invoked after a send
505 * request has completed.
506 * @recv_handler: The completion callback routine invoked for a received
507 * MAD.
508 * @context: User specified context associated with the registration.
509 *
510 * Use of this call allows clients to use MAD services, such as RMPP,
511 * on user-owned QPs. After calling this routine, users may send
512 * MADs on the specified QP by calling ib_mad_post_send.
513 */
514struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp,
515 u8 rmpp_version,
516 ib_mad_send_handler send_handler,
517 ib_mad_recv_handler recv_handler,
518 void *context);
519
520/**
521 * ib_process_mad_wc - Processes a work completion associated with a
522 * MAD sent or received on a redirected QP.
523 * @mad_agent: Specifies the registered MAD service using the redirected QP.
524 * @wc: References a work completion associated with a sent or received
525 * MAD segment.
526 *
527 * This routine is used to complete or continue processing on a MAD request.
528 * If the work completion is associated with a send operation, calling
529 * this routine is required to continue an RMPP transfer or to wait for a
530 * corresponding response, if it is a request. If the work completion is
531 * associated with a receive operation, calling this routine is required to
532 * process an inbound or outbound RMPP transfer, or to match a response MAD
533 * with its corresponding request.
534 */
535int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
536 struct ib_wc *wc);
537
Hal Rosenstock824c8ae2005-07-27 11:45:23 -0700538/**
539 * ib_create_send_mad - Allocate and initialize a data buffer and work request
540 * for sending a MAD.
541 * @mad_agent: Specifies the registered MAD service to associate with the MAD.
542 * @remote_qpn: Specifies the QPN of the receiving node.
543 * @pkey_index: Specifies which PKey the MAD will be sent using. This field
544 * is valid only if the remote_qpn is QP 1.
545 * @ah: References the address handle used to transfer to the remote node.
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700546 * @rmpp_active: Indicates if the send will enable RMPP.
Hal Rosenstock824c8ae2005-07-27 11:45:23 -0700547 * @hdr_len: Indicates the size of the data header of the MAD. This length
548 * should include the common MAD header, RMPP header, plus any class
549 * specific header.
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700550 * @data_len: Indicates the size of any user-transferred data. The call will
Hal Rosenstock824c8ae2005-07-27 11:45:23 -0700551 * automatically adjust the allocated buffer size to account for any
552 * additional padding that may be necessary.
553 * @gfp_mask: GFP mask used for the memory allocation.
554 *
555 * This is a helper routine that may be used to allocate a MAD. Users are
556 * not required to allocate outbound MADs using this call. The returned
557 * MAD send buffer will reference a data buffer usable for sending a MAD, along
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700558 * with an initialized work request structure. Users may modify the returned
559 * MAD data buffer or work request before posting the send.
560 *
561 * The returned data buffer will be cleared. Users are responsible for
562 * initializing the common MAD and any class specific headers. If @rmpp_active
563 * is set, the RMPP header will be initialized for sending.
Hal Rosenstock824c8ae2005-07-27 11:45:23 -0700564 */
565struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
566 u32 remote_qpn, u16 pkey_index,
Hal Rosenstockd2082ee2005-07-27 11:45:36 -0700567 struct ib_ah *ah, int rmpp_active,
Hal Rosenstock824c8ae2005-07-27 11:45:23 -0700568 int hdr_len, int data_len,
569 unsigned int __nocast gfp_mask);
570
571/**
572 * ib_free_send_mad - Returns data buffers used to send a MAD.
573 * @send_buf: Previously allocated send data buffer.
574 */
575void ib_free_send_mad(struct ib_mad_send_buf *send_buf);
576
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577#endif /* IB_MAD_H */