24 #ifndef MCA_BTL_IB_FRAG_H
25 #define MCA_BTL_IB_FRAG_H
27 #include "ompi_config.h"
28 #include "opal/align.h"
30 #include <infiniband/verbs.h>
38 mca_btl_base_tag_t tag;
41 #if OMPI_OPENIB_PAD_HDR
46 #define BTL_OPENIB_RDMA_CREDITS_FLAG (1<<15)
47 #define BTL_OPENIB_IS_RDMA_CREDITS(I) ((I)&BTL_OPENIB_RDMA_CREDITS_FLAG)
48 #define BTL_OPENIB_CREDITS(I) ((I)&~BTL_OPENIB_RDMA_CREDITS_FLAG)
50 #define BTL_OPENIB_HEADER_HTON(h) \
52 (h).credits = htons((h).credits); \
55 #define BTL_OPENIB_HEADER_NTOH(h) \
57 (h).credits = ntohs((h).credits); \
61 mca_btl_base_tag_t tag;
64 #if OMPI_OPENIB_PAD_HDR
69 #define BTL_OPENIB_HEADER_COALESCED_NTOH(h) \
71 (h).size = ntohl((h).size); \
72 (h).alloc_size = ntohl((h).alloc_size); \
75 #define BTL_OPENIB_HEADER_COALESCED_HTON(h) \
77 (h).size = htonl((h).size); \
78 (h).alloc_size = htonl((h).alloc_size); \
81 #if OMPI_OPENIB_PAD_HDR
111 #define BTL_OPENIB_FTR_PADDING(size) \
112 OPAL_ALIGN_PAD_AMOUNT(size, sizeof(uint64_t))
118 #define BTL_OPENIB_ALIGN_COALESCE_HDR(ptr) \
119 OPAL_ALIGN_PTR(ptr, sizeof(uint32_t), unsigned char*)
126 #define BTL_OPENIB_COALESCE_HDR_PADDING(ptr) \
127 OPAL_ALIGN_PAD_AMOUNT(ptr, sizeof(uint32_t))
129 #define BTL_OPENIB_FTR_PADDING(size) 0
130 #define BTL_OPENIB_ALIGN_COALESCE_HDR(ptr) ptr
131 #define BTL_OPENIB_COALESCE_HDR_PADDING(ptr) 0
135 #if OPAL_ENABLE_DEBUG
142 #if OMPI_OPENIB_PAD_HDR
143 #if OPAL_ENABLE_DEBUG
157 #ifdef WORDS_BIGENDIAN
158 #define MCA_BTL_OPENIB_FTR_SIZE_REVERSE(ftr)
160 #define MCA_BTL_OPENIB_FTR_SIZE_REVERSE(ftr) \
162 uint8_t tmp = (ftr).u.buf[0]; \
163 (ftr).u.buf[0]=(ftr).u.buf[2]; \
164 (ftr).u.buf[2]=tmp; \
168 #if OPAL_ENABLE_DEBUG
169 #define BTL_OPENIB_FOOTER_SEQ_HTON(h) ((h).seq = htonl((h).seq))
170 #define BTL_OPENIB_FOOTER_SEQ_NTOH(h) ((h).seq = ntohl((h).seq))
172 #define BTL_OPENIB_FOOTER_SEQ_HTON(h)
173 #define BTL_OPENIB_FOOTER_SEQ_NTOH(h)
176 #define BTL_OPENIB_FOOTER_HTON(h) \
178 BTL_OPENIB_FOOTER_SEQ_HTON(h); \
179 MCA_BTL_OPENIB_FTR_SIZE_REVERSE(h); \
182 #define BTL_OPENIB_FOOTER_NTOH(h) \
184 BTL_OPENIB_FOOTER_SEQ_NTOH(h); \
185 MCA_BTL_OPENIB_FTR_SIZE_REVERSE(h); \
188 #define MCA_BTL_OPENIB_CONTROL_CREDITS 0
189 #define MCA_BTL_OPENIB_CONTROL_RDMA 1
190 #define MCA_BTL_OPENIB_CONTROL_COALESCED 2
191 #define MCA_BTL_OPENIB_CONTROL_CTS 3
192 #if BTL_OPENIB_FAILOVER_ENABLED
193 #define MCA_BTL_OPENIB_CONTROL_EP_BROKEN 4
194 #define MCA_BTL_OPENIB_CONTROL_EP_EAGER_RDMA_ERROR 5
199 #if OMPI_OPENIB_PAD_HDR
212 #define BTL_OPENIB_EAGER_RDMA_CONTROL_HEADER_HTON(h) \
214 (h).rkey = htonl((h).rkey); \
215 (h).rdma_start.lval = hton64((h).rdma_start.lval); \
218 #define BTL_OPENIB_EAGER_RDMA_CONTROL_HEADER_NTOH(h) \
220 (h).rkey = ntohl((h).rkey); \
221 (h).rdma_start.lval = ntoh64((h).rdma_start.lval); \
227 #if OMPI_OPENIB_PAD_HDR
231 uint16_t rdma_credits;
235 #define BTL_OPENIB_RDMA_CREDITS_HEADER_HTON(h) \
237 (h).rdma_credits = htons((h).rdma_credits); \
240 #define BTL_OPENIB_RDMA_CREDITS_HEADER_NTOH(h) \
242 (h).rdma_credits = ntohs((h).rdma_credits); \
245 #if BTL_OPENIB_FAILOVER_ENABLED
246 struct mca_btl_openib_broken_connection_header_t {
253 typedef struct mca_btl_openib_broken_connection_header_t mca_btl_openib_broken_connection_header_t;
255 #define BTL_OPENIB_BROKEN_CONNECTION_HEADER_HTON(h) \
257 (h).lid = htonl((h).lid); \
258 (h).subnet_id = hton64((h).subnet_id); \
259 (h).vpid = htonl((h).vpid); \
260 (h).index = htonl((h).index); \
263 #define BTL_OPENIB_BROKEN_CONNECTION_HEADER_NTOH(h) \
265 (h).lid = ntohl((h).lid); \
266 (h).subnet_id = ntoh64((h).subnet_id); \
267 (h).vpid = ntohl((h).vpid); \
268 (h).index = ntohl((h).index); \
271 enum mca_btl_openib_frag_type_t {
272 MCA_BTL_OPENIB_FRAG_RECV,
273 MCA_BTL_OPENIB_FRAG_RECV_USER,
274 MCA_BTL_OPENIB_FRAG_SEND,
275 MCA_BTL_OPENIB_FRAG_SEND_USER,
276 MCA_BTL_OPENIB_FRAG_EAGER_RDMA,
277 MCA_BTL_OPENIB_FRAG_CONTROL,
278 MCA_BTL_OPENIB_FRAG_COALESCED
280 typedef enum mca_btl_openib_frag_type_t mca_btl_openib_frag_type_t;
282 #define openib_frag_type(f) (to_base_frag(f)->type)
291 mca_btl_openib_frag_type_t type;
296 #define to_base_frag(f) ((mca_btl_openib_frag_t*)(f))
301 struct ibv_sge sg_entry;
307 #define to_com_frag(f) ((mca_btl_openib_com_frag_t*)(f))
311 struct ibv_send_wr sr_desc;
315 #define to_out_frag(f) ((mca_btl_openib_out_frag_t*)(f))
320 #define to_in_frag(f) ((mca_btl_openib_in_frag_t*)(f))
327 uint32_t coalesced_length;
332 #define to_send_frag(f) ((mca_btl_openib_send_frag_t*)(f))
338 struct ibv_recv_wr rd_desc;
343 #define to_recv_frag(f) ((mca_btl_openib_recv_frag_t*)(f))
348 #define to_put_frag(f) ((mca_btl_openib_put_frag_t*)(f))
352 struct ibv_send_wr sr_desc;
356 #define to_get_frag(f) ((mca_btl_openib_get_frag_t*)(f))
361 #define to_send_control_frag(f) ((mca_btl_openib_send_control_frag_t*)(f))
370 #define to_coalesced_frag(f) ((mca_btl_openib_coalesced_frag_t*)(f))
383 OMPI_FREE_LIST_WAIT(&btl->device->send_free_control, item, rc);
385 return to_send_control_frag(item);
392 for(qp = 0; qp < mca_btl_openib_component.
num_qps; qp++)
393 if(mca_btl_openib_component.qp_infos[qp].size >= size)
396 return MCA_BTL_NO_ORDER;
404 OMPI_FREE_LIST_GET(&mca_btl_openib_component.
send_user_free, item, rc);
406 return to_com_frag(item);
414 OMPI_FREE_LIST_GET(&mca_btl_openib_component.
recv_user_free, item, rc);
416 return to_com_frag(item);
424 OMPI_FREE_LIST_GET(&mca_btl_openib_component.send_free_coalesced, item, rc);
426 return to_coalesced_frag(item);
429 #define MCA_BTL_IB_FRAG_RETURN(frag) \
431 OMPI_FREE_LIST_RETURN(to_base_frag(frag)->list, \
432 (ompi_free_list_item_t*)(frag)); \
435 #define MCA_BTL_OPENIB_CLEAN_PENDING_FRAGS(list) \
436 while(!opal_list_is_empty(list)){ \
437 opal_list_item_t *frag_item; \
438 frag_item = opal_list_remove_first(list); \
439 MCA_BTL_IB_FRAG_RETURN(frag_item); \
Definition: btl_openib.h:470
A descriptor that holds the parameters to a send/put/get operation along w/ a callback routine that i...
Definition: btl.h:275
Definition: btl_openib_frag.h:322
Definition: btl_openib_frag.h:334
IB BTL Interface.
Definition: btl_openib.h:432
uint8_t num_qps
total number of qp's
Definition: btl_openib.h:194
Definition: btl_openib_frag.h:363
ompi_free_list_t send_user_free
free list of frags only; used for pining user memory
Definition: btl_openib.h:286
IB fragment derived type.
Definition: btl_openib_frag.h:288
Byte Transfer Layer (BTL)
Definition: btl_openib_frag.h:444
Definition: ompi_free_list.h:39
Definition: btl_openib_frag.h:350
ompi_free_list_t recv_user_free
frags for coalesced massages
Definition: btl_openib.h:288
State of ELAN endpoint connection.
Definition: btl_elan_endpoint.h:33
Definition: ompi_free_list.h:62
Definition: btl_openib_frag.h:309
Definition: opal_list.h:147
Definition: btl_openib_frag.h:299
Describes a region/segment of memory that is addressable by an BTL.
Definition: btl.h:236
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236