3333 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3434 * SOFTWARE.
3535 *
36- * $Id: ib_mad.h 1389 2004-12-27 22:56:47Z roland $
36+ * $Id: ib_mad.h 2775 2005-07-02 13:42:12Z halr $
3737 */
3838
3939#if !defined( IB_MAD_H )
5858#define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30
5959#define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F
6060
61+ #define IB_OPENIB_OUI (0x001405)
62+
6163/* Management methods */
6264#define IB_MGMT_METHOD_GET 0x01
6365#define IB_MGMT_METHOD_SET 0x02
7274
7375#define IB_MGMT_MAX_METHODS 128
7476
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_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+
75104#define IB_QP0 0
76105#define IB_QP1 __constant_htonl(1)
77106#define IB_QP1_QKEY 0x80010000
@@ -88,7 +117,7 @@ struct ib_mad_hdr {
88117 u16 attr_id ;
89118 u16 resv ;
90119 u32 attr_mod ;
91- } __attribute__ (( packed )) ;
120+ };
92121
93122struct ib_rmpp_hdr {
94123 u8 rmpp_version ;
@@ -97,17 +126,41 @@ struct ib_rmpp_hdr {
97126 u8 rmpp_status ;
98127 u32 seg_num ;
99128 u32 paylen_newwin ;
129+ };
130+
131+ typedef 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+ */
141+ struct ib_sa_hdr {
142+ u64 sm_key ;
143+ u16 attr_offset ;
144+ u16 reserved ;
145+ ib_sa_comp_mask comp_mask ;
100146} __attribute__ ((packed ));
101147
102148struct ib_mad {
103149 struct ib_mad_hdr mad_hdr ;
104150 u8 data [232 ];
105- } __attribute__ (( packed )) ;
151+ };
106152
107153struct ib_rmpp_mad {
108154 struct ib_mad_hdr mad_hdr ;
109155 struct ib_rmpp_hdr rmpp_hdr ;
110156 u8 data [220 ];
157+ };
158+
159+ struct 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 ];
111164} __attribute__ ((packed ));
112165
113166struct ib_vendor_mad {
@@ -116,7 +169,7 @@ struct ib_vendor_mad {
116169 u8 reserved ;
117170 u8 oui [3 ];
118171 u8 data [216 ];
119- } __attribute__ (( packed )) ;
172+ };
120173
121174/**
122175 * ib_mad_send_buf - MAD data buffer and work request for sends.
@@ -142,6 +195,45 @@ struct ib_mad_send_buf {
142195 struct ib_sge sge ;
143196};
144197
198+ /**
199+ * ib_get_rmpp_resptime - Returns the RMPP response time.
200+ * @rmpp_hdr: An RMPP header.
201+ */
202+ static 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+ */
211+ static 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+ */
221+ static 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+ */
231+ static 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+
145237struct ib_mad_agent ;
146238struct ib_mad_send_wc ;
147239struct ib_mad_recv_wc ;
@@ -186,6 +278,7 @@ typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent,
186278 * ib_mad_agent - Used to track MAD registration with the access layer.
187279 * @device: Reference to device registration is on.
188280 * @qp: Reference to QP used for sending and receiving MADs.
281+ * @mr: Memory region for system memory usable for DMA.
189282 * @recv_handler: Callback handler for a received MAD.
190283 * @send_handler: Callback handler for a sent MAD.
191284 * @snoop_handler: Callback handler for snooped sent MADs.
@@ -194,6 +287,7 @@ typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent,
194287 * Unsolicited MADs sent by this client will have the upper 32-bits
195288 * of their TID set to this value.
196289 * @port_num: Port number on which QP is registered
290+ * @rmpp_version: If set, indicates the RMPP version used by this agent.
197291 */
198292struct ib_mad_agent {
199293 struct ib_device * device ;
@@ -205,6 +299,7 @@ struct ib_mad_agent {
205299 void * context ;
206300 u32 hi_tid ;
207301 u8 port_num ;
302+ u8 rmpp_version ;
208303};
209304
210305/**
@@ -238,6 +333,7 @@ struct ib_mad_recv_buf {
238333 * ib_mad_recv_wc - received MAD information.
239334 * @wc: Completion information for the received data.
240335 * @recv_buf: Specifies the location of the received data buffer(s).
336+ * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers.
241337 * @mad_len: The length of the received MAD, without duplicated headers.
242338 *
243339 * For received response, the wr_id field of the wc is set to the wr_id
@@ -246,6 +342,7 @@ struct ib_mad_recv_buf {
246342struct ib_mad_recv_wc {
247343 struct ib_wc * wc ;
248344 struct ib_mad_recv_buf recv_buf ;
345+ struct list_head rmpp_list ;
249346 int mad_len ;
250347};
251348
@@ -341,6 +438,16 @@ int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent);
341438 * @bad_send_wr: Specifies the MAD on which an error was encountered.
342439 *
343440 * Sent MADs are not guaranteed to complete in the order that they were posted.
441+ *
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.
344451 */
345452int ib_post_send_mad (struct ib_mad_agent * mad_agent ,
346453 struct ib_send_wr * send_wr ,
@@ -353,14 +460,13 @@ int ib_post_send_mad(struct ib_mad_agent *mad_agent,
353460 * referenced buffer should be at least the size of the mad_len specified
354461 * by @mad_recv_wc.
355462 *
356- * This call copies a chain of received RMPP MADs into a single data buffer,
463+ * This call copies a chain of received MAD segments into a single data buffer,
357464 * removing duplicated headers.
358465 */
359466void ib_coalesce_recv_mad (struct ib_mad_recv_wc * mad_recv_wc , void * buf );
360467
361468/**
362- * ib_free_recv_mad - Returns data buffers used to receive a MAD to the
363- * access layer.
469+ * ib_free_recv_mad - Returns data buffers used to receive a MAD.
364470 * @mad_recv_wc: Work completion information for a received MAD.
365471 *
366472 * Clients receiving MADs through their ib_mad_recv_handler must call this
@@ -437,22 +543,28 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
437543 * @pkey_index: Specifies which PKey the MAD will be sent using. This field
438544 * is valid only if the remote_qpn is QP 1.
439545 * @ah: References the address handle used to transfer to the remote node.
546+ * @rmpp_active: Indicates if the send will enable RMPP.
440547 * @hdr_len: Indicates the size of the data header of the MAD. This length
441548 * should include the common MAD header, RMPP header, plus any class
442549 * specific header.
443- * @data_len: Indicates the size of any user-transfered data. The call will
550+ * @data_len: Indicates the size of any user-transferred data. The call will
444551 * automatically adjust the allocated buffer size to account for any
445552 * additional padding that may be necessary.
446553 * @gfp_mask: GFP mask used for the memory allocation.
447554 *
448555 * This is a helper routine that may be used to allocate a MAD. Users are
449556 * not required to allocate outbound MADs using this call. The returned
450557 * MAD send buffer will reference a data buffer usable for sending a MAD, along
451- * with an intialized work request structure.
558+ * 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.
452564 */
453565struct ib_mad_send_buf * ib_create_send_mad (struct ib_mad_agent * mad_agent ,
454566 u32 remote_qpn , u16 pkey_index ,
455- struct ib_ah * ah ,
567+ struct ib_ah * ah , int rmpp_active ,
456568 int hdr_len , int data_len ,
457569 unsigned int __nocast gfp_mask );
458570
0 commit comments