[PATCH] m68knommu: change addr arg to const in bitops.h/find_next_zero_bit()
[pandora-kernel.git] / include / rdma / ib_mad.h
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 struct ib_class_port_info
177 {
178         u8                      base_version;
179         u8                      class_version;
180         __be16                  capability_mask;
181         u8                      reserved[3];
182         u8                      resp_time_value;
183         u8                      redirect_gid[16];
184         __be32                  redirect_tcslfl;
185         __be16                  redirect_lid;
186         __be16                  redirect_pkey;
187         __be32                  redirect_qp;
188         __be32                  redirect_qkey;
189         u8                      trap_gid[16];
190         __be32                  trap_tcslfl;
191         __be16                  trap_lid;
192         __be16                  trap_pkey;
193         __be32                  trap_hlqp;
194         __be32                  trap_qkey;
195 };
196
197 /**
198  * ib_mad_send_buf - MAD data buffer and work request for sends.
199  * @mad: References an allocated MAD data buffer.  The size of the data
200  *   buffer is specified in the @send_wr.length field.
201  * @mapping: DMA mapping information.
202  * @mad_agent: MAD agent that allocated the buffer.
203  * @context: User-controlled context fields.
204  * @send_wr: An initialized work request structure used when sending the MAD.
205  *   The wr_id field of the work request is initialized to reference this
206  *   data structure.
207  * @sge: A scatter-gather list referenced by the work request.
208  *
209  * Users are responsible for initializing the MAD buffer itself, with the
210  * exception of specifying the payload length field in any RMPP MAD.
211  */
212 struct ib_mad_send_buf {
213         struct ib_mad           *mad;
214         DECLARE_PCI_UNMAP_ADDR(mapping)
215         struct ib_mad_agent     *mad_agent;
216         void                    *context[2];
217         struct ib_send_wr       send_wr;
218         struct ib_sge           sge;
219 };
220
221 /**
222  * ib_get_rmpp_resptime - Returns the RMPP response time.
223  * @rmpp_hdr: An RMPP header.
224  */
225 static inline u8 ib_get_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr)
226 {
227         return rmpp_hdr->rmpp_rtime_flags >> 3;
228 }
229
230 /**
231  * ib_get_rmpp_flags - Returns the RMPP flags.
232  * @rmpp_hdr: An RMPP header.
233  */
234 static inline u8 ib_get_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr)
235 {
236         return rmpp_hdr->rmpp_rtime_flags & 0x7;
237 }
238
239 /**
240  * ib_set_rmpp_resptime - Sets the response time in an RMPP header.
241  * @rmpp_hdr: An RMPP header.
242  * @rtime: The response time to set.
243  */
244 static inline void ib_set_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr, u8 rtime)
245 {
246         rmpp_hdr->rmpp_rtime_flags = ib_get_rmpp_flags(rmpp_hdr) | (rtime << 3);
247 }
248
249 /**
250  * ib_set_rmpp_flags - Sets the flags in an RMPP header.
251  * @rmpp_hdr: An RMPP header.
252  * @flags: The flags to set.
253  */
254 static inline void ib_set_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr, u8 flags)
255 {
256         rmpp_hdr->rmpp_rtime_flags = (rmpp_hdr->rmpp_rtime_flags & 0xF1) |
257                                      (flags & 0x7);
258 }
259
260 struct ib_mad_agent;
261 struct ib_mad_send_wc;
262 struct ib_mad_recv_wc;
263
264 /**
265  * ib_mad_send_handler - callback handler for a sent MAD.
266  * @mad_agent: MAD agent that sent the MAD.
267  * @mad_send_wc: Send work completion information on the sent MAD.
268  */
269 typedef void (*ib_mad_send_handler)(struct ib_mad_agent *mad_agent,
270                                     struct ib_mad_send_wc *mad_send_wc);
271
272 /**
273  * ib_mad_snoop_handler - Callback handler for snooping sent MADs.
274  * @mad_agent: MAD agent that snooped the MAD.
275  * @send_wr: Work request information on the sent MAD.
276  * @mad_send_wc: Work completion information on the sent MAD.  Valid
277  *   only for snooping that occurs on a send completion.
278  *
279  * Clients snooping MADs should not modify data referenced by the @send_wr
280  * or @mad_send_wc.
281  */
282 typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent,
283                                      struct ib_send_wr *send_wr,
284                                      struct ib_mad_send_wc *mad_send_wc);
285
286 /**
287  * ib_mad_recv_handler - callback handler for a received MAD.
288  * @mad_agent: MAD agent requesting the received MAD.
289  * @mad_recv_wc: Received work completion information on the received MAD.
290  *
291  * MADs received in response to a send request operation will be handed to
292  * the user after the send operation completes.  All data buffers given
293  * to registered agents through this routine are owned by the receiving
294  * client, except for snooping agents.  Clients snooping MADs should not
295  * modify the data referenced by @mad_recv_wc.
296  */
297 typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent,
298                                     struct ib_mad_recv_wc *mad_recv_wc);
299
300 /**
301  * ib_mad_agent - Used to track MAD registration with the access layer.
302  * @device: Reference to device registration is on.
303  * @qp: Reference to QP used for sending and receiving MADs.
304  * @mr: Memory region for system memory usable for DMA.
305  * @recv_handler: Callback handler for a received MAD.
306  * @send_handler: Callback handler for a sent MAD.
307  * @snoop_handler: Callback handler for snooped sent MADs.
308  * @context: User-specified context associated with this registration.
309  * @hi_tid: Access layer assigned transaction ID for this client.
310  *   Unsolicited MADs sent by this client will have the upper 32-bits
311  *   of their TID set to this value.
312  * @port_num: Port number on which QP is registered
313  * @rmpp_version: If set, indicates the RMPP version used by this agent.
314  */
315 struct ib_mad_agent {
316         struct ib_device        *device;
317         struct ib_qp            *qp;
318         struct ib_mr            *mr;
319         ib_mad_recv_handler     recv_handler;
320         ib_mad_send_handler     send_handler;
321         ib_mad_snoop_handler    snoop_handler;
322         void                    *context;
323         u32                     hi_tid;
324         u8                      port_num;
325         u8                      rmpp_version;
326 };
327
328 /**
329  * ib_mad_send_wc - MAD send completion information.
330  * @wr_id: Work request identifier associated with the send MAD request.
331  * @status: Completion status.
332  * @vendor_err: Optional vendor error information returned with a failed
333  *   request.
334  */
335 struct ib_mad_send_wc {
336         u64                     wr_id;
337         enum ib_wc_status       status;
338         u32                     vendor_err;
339 };
340
341 /**
342  * ib_mad_recv_buf - received MAD buffer information.
343  * @list: Reference to next data buffer for a received RMPP MAD.
344  * @grh: References a data buffer containing the global route header.
345  *   The data refereced by this buffer is only valid if the GRH is
346  *   valid.
347  * @mad: References the start of the received MAD.
348  */
349 struct ib_mad_recv_buf {
350         struct list_head        list;
351         struct ib_grh           *grh;
352         struct ib_mad           *mad;
353 };
354
355 /**
356  * ib_mad_recv_wc - received MAD information.
357  * @wc: Completion information for the received data.
358  * @recv_buf: Specifies the location of the received data buffer(s).
359  * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers.
360  * @mad_len: The length of the received MAD, without duplicated headers.
361  *
362  * For received response, the wr_id field of the wc is set to the wr_id
363  *   for the corresponding send request.
364  */
365 struct ib_mad_recv_wc {
366         struct ib_wc            *wc;
367         struct ib_mad_recv_buf  recv_buf;
368         struct list_head        rmpp_list;
369         int                     mad_len;
370 };
371
372 /**
373  * ib_mad_reg_req - MAD registration request
374  * @mgmt_class: Indicates which management class of MADs should be receive
375  *   by the caller.  This field is only required if the user wishes to
376  *   receive unsolicited MADs, otherwise it should be 0.
377  * @mgmt_class_version: Indicates which version of MADs for the given
378  *   management class to receive.
379  * @oui: Indicates IEEE OUI when mgmt_class is a vendor class
380  *   in the range from 0x30 to 0x4f. Otherwise not used.
381  * @method_mask: The caller will receive unsolicited MADs for any method
382  *   where @method_mask = 1.
383  */
384 struct ib_mad_reg_req {
385         u8      mgmt_class;
386         u8      mgmt_class_version;
387         u8      oui[3];
388         DECLARE_BITMAP(method_mask, IB_MGMT_MAX_METHODS);
389 };
390
391 /**
392  * ib_register_mad_agent - Register to send/receive MADs.
393  * @device: The device to register with.
394  * @port_num: The port on the specified device to use.
395  * @qp_type: Specifies which QP to access.  Must be either
396  *   IB_QPT_SMI or IB_QPT_GSI.
397  * @mad_reg_req: Specifies which unsolicited MADs should be received
398  *   by the caller.  This parameter may be NULL if the caller only
399  *   wishes to receive solicited responses.
400  * @rmpp_version: If set, indicates that the client will send
401  *   and receive MADs that contain the RMPP header for the given version.
402  *   If set to 0, indicates that RMPP is not used by this client.
403  * @send_handler: The completion callback routine invoked after a send
404  *   request has completed.
405  * @recv_handler: The completion callback routine invoked for a received
406  *   MAD.
407  * @context: User specified context associated with the registration.
408  */
409 struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
410                                            u8 port_num,
411                                            enum ib_qp_type qp_type,
412                                            struct ib_mad_reg_req *mad_reg_req,
413                                            u8 rmpp_version,
414                                            ib_mad_send_handler send_handler,
415                                            ib_mad_recv_handler recv_handler,
416                                            void *context);
417
418 enum ib_mad_snoop_flags {
419         /*IB_MAD_SNOOP_POSTED_SENDS        = 1,*/
420         /*IB_MAD_SNOOP_RMPP_SENDS          = (1<<1),*/
421         IB_MAD_SNOOP_SEND_COMPLETIONS      = (1<<2),
422         /*IB_MAD_SNOOP_RMPP_SEND_COMPLETIONS = (1<<3),*/
423         IB_MAD_SNOOP_RECVS                 = (1<<4)
424         /*IB_MAD_SNOOP_RMPP_RECVS          = (1<<5),*/
425         /*IB_MAD_SNOOP_REDIRECTED_QPS      = (1<<6)*/
426 };
427
428 /**
429  * ib_register_mad_snoop - Register to snoop sent and received MADs.
430  * @device: The device to register with.
431  * @port_num: The port on the specified device to use.
432  * @qp_type: Specifies which QP traffic to snoop.  Must be either
433  *   IB_QPT_SMI or IB_QPT_GSI.
434  * @mad_snoop_flags: Specifies information where snooping occurs.
435  * @send_handler: The callback routine invoked for a snooped send.
436  * @recv_handler: The callback routine invoked for a snooped receive.
437  * @context: User specified context associated with the registration.
438  */
439 struct ib_mad_agent *ib_register_mad_snoop(struct ib_device *device,
440                                            u8 port_num,
441                                            enum ib_qp_type qp_type,
442                                            int mad_snoop_flags,
443                                            ib_mad_snoop_handler snoop_handler,
444                                            ib_mad_recv_handler recv_handler,
445                                            void *context);
446
447 /**
448  * ib_unregister_mad_agent - Unregisters a client from using MAD services.
449  * @mad_agent: Corresponding MAD registration request to deregister.
450  *
451  * After invoking this routine, MAD services are no longer usable by the
452  * client on the associated QP.
453  */
454 int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent);
455
456 /**
457  * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
458  *   with the registered client.
459  * @mad_agent: Specifies the associated registration to post the send to.
460  * @send_wr: Specifies the information needed to send the MAD(s).
461  * @bad_send_wr: Specifies the MAD on which an error was encountered.
462  *
463  * Sent MADs are not guaranteed to complete in the order that they were posted.
464  *
465  * If the MAD requires RMPP, the data buffer should contain a single copy
466  * of the common MAD, RMPP, and class specific headers, followed by the class
467  * defined data.  If the class defined data would not divide evenly into
468  * RMPP segments, then space must be allocated at the end of the referenced
469  * buffer for any required padding.  To indicate the amount of class defined
470  * data being transferred, the paylen_newwin field in the RMPP header should
471  * be set to the size of the class specific header plus the amount of class
472  * defined data being transferred.  The paylen_newwin field should be
473  * specified in network-byte order.
474  */
475 int ib_post_send_mad(struct ib_mad_agent *mad_agent,
476                      struct ib_send_wr *send_wr,
477                      struct ib_send_wr **bad_send_wr);
478
479 /**
480  * ib_coalesce_recv_mad - Coalesces received MAD data into a single buffer.
481  * @mad_recv_wc: Work completion information for a received MAD.
482  * @buf: User-provided data buffer to receive the coalesced buffers.  The
483  *   referenced buffer should be at least the size of the mad_len specified
484  *   by @mad_recv_wc.
485  *
486  * This call copies a chain of received MAD segments into a single data buffer,
487  * removing duplicated headers.
488  */
489 void ib_coalesce_recv_mad(struct ib_mad_recv_wc *mad_recv_wc, void *buf);
490
491 /**
492  * ib_free_recv_mad - Returns data buffers used to receive a MAD.
493  * @mad_recv_wc: Work completion information for a received MAD.
494  *
495  * Clients receiving MADs through their ib_mad_recv_handler must call this
496  * routine to return the work completion buffers to the access layer.
497  */
498 void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc);
499
500 /**
501  * ib_cancel_mad - Cancels an outstanding send MAD operation.
502  * @mad_agent: Specifies the registration associated with sent MAD.
503  * @wr_id: Indicates the work request identifier of the MAD to cancel.
504  *
505  * MADs will be returned to the user through the corresponding
506  * ib_mad_send_handler.
507  */
508 void ib_cancel_mad(struct ib_mad_agent *mad_agent, u64 wr_id);
509
510 /**
511  * ib_modify_mad - Modifies an outstanding send MAD operation.
512  * @mad_agent: Specifies the registration associated with sent MAD.
513  * @wr_id: Indicates the work request identifier of the MAD to modify.
514  * @timeout_ms: New timeout value for sent MAD.
515  *
516  * This call will reset the timeout value for a sent MAD to the specified
517  * value.
518  */
519 int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms);
520
521 /**
522  * ib_redirect_mad_qp - Registers a QP for MAD services.
523  * @qp: Reference to a QP that requires MAD services.
524  * @rmpp_version: If set, indicates that the client will send
525  *   and receive MADs that contain the RMPP header for the given version.
526  *   If set to 0, indicates that RMPP is not used by this client.
527  * @send_handler: The completion callback routine invoked after a send
528  *   request has completed.
529  * @recv_handler: The completion callback routine invoked for a received
530  *   MAD.
531  * @context: User specified context associated with the registration.
532  *
533  * Use of this call allows clients to use MAD services, such as RMPP,
534  * on user-owned QPs.  After calling this routine, users may send
535  * MADs on the specified QP by calling ib_mad_post_send.
536  */
537 struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp,
538                                         u8 rmpp_version,
539                                         ib_mad_send_handler send_handler,
540                                         ib_mad_recv_handler recv_handler,
541                                         void *context);
542
543 /**
544  * ib_process_mad_wc - Processes a work completion associated with a
545  *   MAD sent or received on a redirected QP.
546  * @mad_agent: Specifies the registered MAD service using the redirected QP.
547  * @wc: References a work completion associated with a sent or received
548  *   MAD segment.
549  *
550  * This routine is used to complete or continue processing on a MAD request.
551  * If the work completion is associated with a send operation, calling
552  * this routine is required to continue an RMPP transfer or to wait for a
553  * corresponding response, if it is a request.  If the work completion is
554  * associated with a receive operation, calling this routine is required to
555  * process an inbound or outbound RMPP transfer, or to match a response MAD
556  * with its corresponding request.
557  */
558 int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
559                       struct ib_wc *wc);
560
561 /**
562  * ib_create_send_mad - Allocate and initialize a data buffer and work request
563  *   for sending a MAD.
564  * @mad_agent: Specifies the registered MAD service to associate with the MAD.
565  * @remote_qpn: Specifies the QPN of the receiving node.
566  * @pkey_index: Specifies which PKey the MAD will be sent using.  This field
567  *   is valid only if the remote_qpn is QP 1.
568  * @ah: References the address handle used to transfer to the remote node.
569  * @rmpp_active: Indicates if the send will enable RMPP.
570  * @hdr_len: Indicates the size of the data header of the MAD.  This length
571  *   should include the common MAD header, RMPP header, plus any class
572  *   specific header.
573  * @data_len: Indicates the size of any user-transferred data.  The call will
574  *   automatically adjust the allocated buffer size to account for any
575  *   additional padding that may be necessary.
576  * @gfp_mask: GFP mask used for the memory allocation.
577  *
578  * This is a helper routine that may be used to allocate a MAD.  Users are
579  * not required to allocate outbound MADs using this call.  The returned
580  * MAD send buffer will reference a data buffer usable for sending a MAD, along
581  * with an initialized work request structure.  Users may modify the returned
582  * MAD data buffer or work request before posting the send.
583  *
584  * The returned data buffer will be cleared.  Users are responsible for
585  * initializing the common MAD and any class specific headers.  If @rmpp_active
586  * is set, the RMPP header will be initialized for sending.
587  */
588 struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
589                                             u32 remote_qpn, u16 pkey_index,
590                                             struct ib_ah *ah, int rmpp_active,
591                                             int hdr_len, int data_len,
592                                             unsigned int __nocast gfp_mask);
593
594 /**
595  * ib_free_send_mad - Returns data buffers used to send a MAD.
596  * @send_buf: Previously allocated send data buffer.
597  */
598 void ib_free_send_mad(struct ib_mad_send_buf *send_buf);
599
600 #endif /* IB_MAD_H */