aboutsummaryrefslogtreecommitdiffstats
path: root/include/rdma
diff options
context:
space:
mode:
authorSean Hefty <sean.hefty@intel.com>2005-10-25 13:51:39 -0400
committerRoland Dreier <rolandd@cisco.com>2005-10-25 13:51:39 -0400
commit34816ad98efe4d47ffd858a0345321f9d85d9420 (patch)
tree8a5ed6a9b80e667c4c02d9993711ced06d158555 /include/rdma
parentae7971a7706384ca373fb7e212fe195698e6c5a1 (diff)
[IB] Fix MAD layer DMA mappings to avoid touching data buffer once mapped
The MAD layer was violating the DMA API by touching data buffers used for sends after the DMA mapping was done. This causes problems on non-cache-coherent architectures, because the device doing DMA won't see updates to the payload buffers that exist only in the CPU cache. Fix this by having all MAD consumers use ib_create_send_mad() to allocate their send buffers, and moving the DMA mapping into the MAD layer so it can be done just before calling send (and after any modifications of the send buffer by the MAD layer). Tested on a non-cache-coherent PowerPC 440SPe system. Signed-off-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/ib_mad.h66
-rw-r--r--include/rdma/ib_verbs.h3
2 files changed, 34 insertions, 35 deletions
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 4172e6841e3d..2c133506742b 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -109,10 +109,14 @@
109#define IB_QP_SET_QKEY 0x80000000 109#define IB_QP_SET_QKEY 0x80000000
110 110
111enum { 111enum {
112 IB_MGMT_MAD_HDR = 24,
112 IB_MGMT_MAD_DATA = 232, 113 IB_MGMT_MAD_DATA = 232,
114 IB_MGMT_RMPP_HDR = 36,
113 IB_MGMT_RMPP_DATA = 220, 115 IB_MGMT_RMPP_DATA = 220,
116 IB_MGMT_VENDOR_HDR = 40,
114 IB_MGMT_VENDOR_DATA = 216, 117 IB_MGMT_VENDOR_DATA = 216,
115 IB_MGMT_SA_DATA = 200 118 IB_MGMT_SA_HDR = 56,
119 IB_MGMT_SA_DATA = 200,
116}; 120};
117 121
118struct ib_mad_hdr { 122struct ib_mad_hdr {
@@ -203,26 +207,25 @@ struct ib_class_port_info
203 207
204/** 208/**
205 * ib_mad_send_buf - MAD data buffer and work request for sends. 209 * ib_mad_send_buf - MAD data buffer and work request for sends.
206 * @mad: References an allocated MAD data buffer. The size of the data 210 * @next: A pointer used to chain together MADs for posting.
207 * buffer is specified in the @send_wr.length field. 211 * @mad: References an allocated MAD data buffer.
208 * @mapping: DMA mapping information.
209 * @mad_agent: MAD agent that allocated the buffer. 212 * @mad_agent: MAD agent that allocated the buffer.
213 * @ah: The address handle to use when sending the MAD.
210 * @context: User-controlled context fields. 214 * @context: User-controlled context fields.
211 * @send_wr: An initialized work request structure used when sending the MAD. 215 * @timeout_ms: Time to wait for a response.
212 * The wr_id field of the work request is initialized to reference this 216 * @retries: Number of times to retry a request for a response.
213 * data structure.
214 * @sge: A scatter-gather list referenced by the work request.
215 * 217 *
216 * Users are responsible for initializing the MAD buffer itself, with the 218 * Users are responsible for initializing the MAD buffer itself, with the
217 * exception of specifying the payload length field in any RMPP MAD. 219 * exception of specifying the payload length field in any RMPP MAD.
218 */ 220 */
219struct ib_mad_send_buf { 221struct ib_mad_send_buf {
220 struct ib_mad *mad; 222 struct ib_mad_send_buf *next;
221 DECLARE_PCI_UNMAP_ADDR(mapping) 223 void *mad;
222 struct ib_mad_agent *mad_agent; 224 struct ib_mad_agent *mad_agent;
225 struct ib_ah *ah;
223 void *context[2]; 226 void *context[2];
224 struct ib_send_wr send_wr; 227 int timeout_ms;
225 struct ib_sge sge; 228 int retries;
226}; 229};
227 230
228/** 231/**
@@ -287,7 +290,7 @@ typedef void (*ib_mad_send_handler)(struct ib_mad_agent *mad_agent,
287 * or @mad_send_wc. 290 * or @mad_send_wc.
288 */ 291 */
289typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent, 292typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent,
290 struct ib_send_wr *send_wr, 293 struct ib_mad_send_buf *send_buf,
291 struct ib_mad_send_wc *mad_send_wc); 294 struct ib_mad_send_wc *mad_send_wc);
292 295
293/** 296/**
@@ -334,13 +337,13 @@ struct ib_mad_agent {
334 337
335/** 338/**
336 * ib_mad_send_wc - MAD send completion information. 339 * ib_mad_send_wc - MAD send completion information.
337 * @wr_id: Work request identifier associated with the send MAD request. 340 * @send_buf: Send MAD data buffer associated with the send MAD request.
338 * @status: Completion status. 341 * @status: Completion status.
339 * @vendor_err: Optional vendor error information returned with a failed 342 * @vendor_err: Optional vendor error information returned with a failed
340 * request. 343 * request.
341 */ 344 */
342struct ib_mad_send_wc { 345struct ib_mad_send_wc {
343 u64 wr_id; 346 struct ib_mad_send_buf *send_buf;
344 enum ib_wc_status status; 347 enum ib_wc_status status;
345 u32 vendor_err; 348 u32 vendor_err;
346}; 349};
@@ -366,7 +369,7 @@ struct ib_mad_recv_buf {
366 * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers. 369 * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers.
367 * @mad_len: The length of the received MAD, without duplicated headers. 370 * @mad_len: The length of the received MAD, without duplicated headers.
368 * 371 *
369 * For received response, the wr_id field of the wc is set to the wr_id 372 * For received response, the wr_id contains a pointer to the ib_mad_send_buf
370 * for the corresponding send request. 373 * for the corresponding send request.
371 */ 374 */
372struct ib_mad_recv_wc { 375struct ib_mad_recv_wc {
@@ -463,9 +466,9 @@ int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent);
463/** 466/**
464 * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated 467 * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
465 * with the registered client. 468 * with the registered client.
466 * @mad_agent: Specifies the associated registration to post the send to. 469 * @send_buf: Specifies the information needed to send the MAD(s).
467 * @send_wr: Specifies the information needed to send the MAD(s). 470 * @bad_send_buf: Specifies the MAD on which an error was encountered. This
468 * @bad_send_wr: Specifies the MAD on which an error was encountered. 471 * parameter is optional if only a single MAD is posted.
469 * 472 *
470 * Sent MADs are not guaranteed to complete in the order that they were posted. 473 * Sent MADs are not guaranteed to complete in the order that they were posted.
471 * 474 *
@@ -479,9 +482,8 @@ int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent);
479 * defined data being transferred. The paylen_newwin field should be 482 * defined data being transferred. The paylen_newwin field should be
480 * specified in network-byte order. 483 * specified in network-byte order.
481 */ 484 */
482int ib_post_send_mad(struct ib_mad_agent *mad_agent, 485int ib_post_send_mad(struct ib_mad_send_buf *send_buf,
483 struct ib_send_wr *send_wr, 486 struct ib_mad_send_buf **bad_send_buf);
484 struct ib_send_wr **bad_send_wr);
485 487
486/** 488/**
487 * ib_coalesce_recv_mad - Coalesces received MAD data into a single buffer. 489 * ib_coalesce_recv_mad - Coalesces received MAD data into a single buffer.
@@ -507,23 +509,25 @@ void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc);
507/** 509/**
508 * ib_cancel_mad - Cancels an outstanding send MAD operation. 510 * ib_cancel_mad - Cancels an outstanding send MAD operation.
509 * @mad_agent: Specifies the registration associated with sent MAD. 511 * @mad_agent: Specifies the registration associated with sent MAD.
510 * @wr_id: Indicates the work request identifier of the MAD to cancel. 512 * @send_buf: Indicates the MAD to cancel.
511 * 513 *
512 * MADs will be returned to the user through the corresponding 514 * MADs will be returned to the user through the corresponding
513 * ib_mad_send_handler. 515 * ib_mad_send_handler.
514 */ 516 */
515void ib_cancel_mad(struct ib_mad_agent *mad_agent, u64 wr_id); 517void ib_cancel_mad(struct ib_mad_agent *mad_agent,
518 struct ib_mad_send_buf *send_buf);
516 519
517/** 520/**
518 * ib_modify_mad - Modifies an outstanding send MAD operation. 521 * ib_modify_mad - Modifies an outstanding send MAD operation.
519 * @mad_agent: Specifies the registration associated with sent MAD. 522 * @mad_agent: Specifies the registration associated with sent MAD.
520 * @wr_id: Indicates the work request identifier of the MAD to modify. 523 * @send_buf: Indicates the MAD to modify.
521 * @timeout_ms: New timeout value for sent MAD. 524 * @timeout_ms: New timeout value for sent MAD.
522 * 525 *
523 * This call will reset the timeout value for a sent MAD to the specified 526 * This call will reset the timeout value for a sent MAD to the specified
524 * value. 527 * value.
525 */ 528 */
526int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms); 529int ib_modify_mad(struct ib_mad_agent *mad_agent,
530 struct ib_mad_send_buf *send_buf, u32 timeout_ms);
527 531
528/** 532/**
529 * ib_redirect_mad_qp - Registers a QP for MAD services. 533 * ib_redirect_mad_qp - Registers a QP for MAD services.
@@ -572,7 +576,6 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
572 * @remote_qpn: Specifies the QPN of the receiving node. 576 * @remote_qpn: Specifies the QPN of the receiving node.
573 * @pkey_index: Specifies which PKey the MAD will be sent using. This field 577 * @pkey_index: Specifies which PKey the MAD will be sent using. This field
574 * is valid only if the remote_qpn is QP 1. 578 * is valid only if the remote_qpn is QP 1.
575 * @ah: References the address handle used to transfer to the remote node.
576 * @rmpp_active: Indicates if the send will enable RMPP. 579 * @rmpp_active: Indicates if the send will enable RMPP.
577 * @hdr_len: Indicates the size of the data header of the MAD. This length 580 * @hdr_len: Indicates the size of the data header of the MAD. This length
578 * should include the common MAD header, RMPP header, plus any class 581 * should include the common MAD header, RMPP header, plus any class
@@ -582,11 +585,10 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
582 * additional padding that may be necessary. 585 * additional padding that may be necessary.
583 * @gfp_mask: GFP mask used for the memory allocation. 586 * @gfp_mask: GFP mask used for the memory allocation.
584 * 587 *
585 * This is a helper routine that may be used to allocate a MAD. Users are 588 * This routine allocates a MAD for sending. The returned MAD send buffer
586 * not required to allocate outbound MADs using this call. The returned 589 * will reference a data buffer usable for sending a MAD, along
587 * MAD send buffer will reference a data buffer usable for sending a MAD, along
588 * with an initialized work request structure. Users may modify the returned 590 * with an initialized work request structure. Users may modify the returned
589 * MAD data buffer or work request before posting the send. 591 * MAD data buffer before posting the send.
590 * 592 *
591 * The returned data buffer will be cleared. Users are responsible for 593 * The returned data buffer will be cleared. Users are responsible for
592 * initializing the common MAD and any class specific headers. If @rmpp_active 594 * initializing the common MAD and any class specific headers. If @rmpp_active
@@ -594,7 +596,7 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
594 */ 596 */
595struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent, 597struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
596 u32 remote_qpn, u16 pkey_index, 598 u32 remote_qpn, u16 pkey_index,
597 struct ib_ah *ah, int rmpp_active, 599 int rmpp_active,
598 int hdr_len, int data_len, 600 int hdr_len, int data_len,
599 gfp_t gfp_mask); 601 gfp_t gfp_mask);
600 602
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index a5a963cb5676..f72d46d54e0a 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -595,11 +595,8 @@ struct ib_send_wr {
595 } atomic; 595 } atomic;
596 struct { 596 struct {
597 struct ib_ah *ah; 597 struct ib_ah *ah;
598 struct ib_mad_hdr *mad_hdr;
599 u32 remote_qpn; 598 u32 remote_qpn;
600 u32 remote_qkey; 599 u32 remote_qkey;
601 int timeout_ms; /* valid for MADs only */
602 int retries; /* valid for MADs only */
603 u16 pkey_index; /* valid for GSI only */ 600 u16 pkey_index; /* valid for GSI only */
604 u8 port_num; /* valid for DR SMPs on switch only */ 601 u8 port_num; /* valid for DR SMPs on switch only */
605 } ud; 602 } ud;