1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #ifndef MCA_BTL_TCP_FRAG_H
21 #define MCA_BTL_TCP_FRAG_H
22
23
24 #define MCA_BTL_TCP_FRAG_ALIGN (8)
25 #include "ompi_config.h"
26
27 #ifdef HAVE_SYS_TYPES_H
28 #include <sys/types.h>
29 #endif
30 #ifdef HAVE_SYS_UIO_H
31 #include <sys/uio.h>
32 #endif
33 #ifdef HAVE_NET_UIO_H
34 #include <net/uio.h>
35 #endif
36
37 #include "btl_tcp2.h"
38 #include "btl_tcp2_hdr.h"
39
40 BEGIN_C_DECLS
41
42 #define MCA_BTL_TCP_FRAG_IOVEC_NUMBER 4
43
44
45
46
47
48 #define MCA_BTL_TCP_FRAG_STEP_UNDEFINED ((uint16_t)0x0000)
49 #define MCA_BTL_TCP_FRAG_STEP_SEND_COMPLETE ((uint16_t)0x0001)
50 #define MCA_BTL_TCP_FRAG_STEP_RECV_COMPLETE ((uint16_t)0x0002)
51
52
53
54
55 struct mca_btl_tcp2_frag_t {
56 mca_btl_base_descriptor_t base;
57 mca_btl_base_segment_t segments[2];
58 struct mca_btl_base_endpoint_t *endpoint;
59 struct mca_btl_tcp2_module_t* btl;
60 mca_btl_tcp2_hdr_t hdr;
61 struct iovec iov[MCA_BTL_TCP_FRAG_IOVEC_NUMBER + 1];
62 struct iovec *iov_ptr;
63 size_t iov_cnt;
64 size_t iov_idx;
65 size_t size;
66 int rc;
67 ompi_free_list_t* my_list;
68 };
69 typedef struct mca_btl_tcp2_frag_t mca_btl_tcp2_frag_t;
70 OBJ_CLASS_DECLARATION(mca_btl_tcp2_frag_t);
71
72 typedef struct mca_btl_tcp2_frag_t mca_btl_tcp2_frag_eager_t;
73
74 OBJ_CLASS_DECLARATION(mca_btl_tcp2_frag_eager_t);
75
76 typedef struct mca_btl_tcp2_frag_t mca_btl_tcp2_frag_max_t;
77
78 OBJ_CLASS_DECLARATION(mca_btl_tcp2_frag_max_t);
79
80 typedef struct mca_btl_tcp2_frag_t mca_btl_tcp2_frag_user_t;
81
82 OBJ_CLASS_DECLARATION(mca_btl_tcp2_frag_user_t);
83
84
85
86
87
88
89
90 #define MCA_BTL_TCP_FRAG_ALLOC_EAGER(frag) \
91 { \
92 ompi_free_list_item_t *item; \
93 MCA_BTL_TCP_CRITICAL_SECTION_ENTER(&mca_btl_tcp_component.tcp_frag_eager_mutex); \
94 OMPI_FREE_LIST_GET_MT(&mca_btl_tcp_component.tcp_frag_eager, item); \
95 MCA_BTL_TCP_CRITICAL_SECTION_LEAVE(&mca_btl_tcp_component.tcp_frag_eager_mutex); \
96 frag = (mca_btl_tcp_frag_t*) item; \
97 }
98
99 #define MCA_BTL_TCP_FRAG_ALLOC_MAX(frag) \
100 { \
101 ompi_free_list_item_t *item; \
102 MCA_BTL_TCP_CRITICAL_SECTION_ENTER(&mca_btl_tcp_component.tcp_frag_max_mutex); \
103 OMPI_FREE_LIST_GET_MT(&mca_btl_tcp_component.tcp_frag_max, item); \
104 MCA_BTL_TCP_CRITICAL_SECTION_LEAVE(&mca_btl_tcp_component.tcp_frag_max_mutex); \
105 frag = (mca_btl_tcp_frag_t*) item; \
106 }
107
108 #define MCA_BTL_TCP_FRAG_ALLOC_USER(frag) \
109 { \
110 ompi_free_list_item_t *item; \
111 MCA_BTL_TCP_CRITICAL_SECTION_ENTER(&mca_btl_tcp_component.tcp_frag_user_mutex); \
112 OMPI_FREE_LIST_GET_MT(&mca_btl_tcp_component.tcp_frag_user, item); \
113 MCA_BTL_TCP_CRITICAL_SECTION_LEAVE(&mca_btl_tcp_component.tcp_frag_user_mutex); \
114 frag = (mca_btl_tcp_frag_t*) item; \
115 }
116
117 #if MCA_BTL_TCP_USES_PROGRESS_THREAD
118 #define MCA_BTL_TCP_FRAG_RETURN(frag) \
119 { \
120 (frag)->next_step = MCA_BTL_TCP_FRAG_STEP_UNDEFINED; \
121 if( frag->my_list == &mca_btl_tcp_component.tcp_frag_eager ) { \
122 MCA_BTL_TCP_CRITICAL_SECTION_ENTER(&mca_btl_tcp_component.tcp_frag_eager_mutex); \
123 OMPI_FREE_LIST_RETURN_MT(frag->my_list, (ompi_free_list_item_t*)(frag)); \
124 MCA_BTL_TCP_CRITICAL_SECTION_LEAVE(&mca_btl_tcp_component.tcp_frag_eager_mutex); \
125 } else if( frag->my_list == &mca_btl_tcp_component.tcp_frag_max ) { \
126 MCA_BTL_TCP_CRITICAL_SECTION_ENTER(&mca_btl_tcp_component.tcp_frag_max_mutex); \
127 OMPI_FREE_LIST_RETURN_MT(frag->my_list, (ompi_free_list_item_t*)(frag)); \
128 MCA_BTL_TCP_CRITICAL_SECTION_LEAVE(&mca_btl_tcp_component.tcp_frag_max_mutex); \
129 } else { \
130 assert( frag->my_list == &mca_btl_tcp_component.tcp_frag_user ); \
131 MCA_BTL_TCP_CRITICAL_SECTION_ENTER(&mca_btl_tcp_component.tcp_frag_user_mutex); \
132 OMPI_FREE_LIST_RETURN_MT(frag->my_list, (ompi_free_list_item_t*)(frag)); \
133 MCA_BTL_TCP_CRITICAL_SECTION_LEAVE(&mca_btl_tcp_component.tcp_frag_user_mutex); \
134 } \
135 }
136 #else
137 #define MCA_BTL_TCP_FRAG_RETURN(frag) \
138 { \
139 (frag)->next_step = MCA_BTL_TCP_FRAG_STEP_UNDEFINED; \
140 OMPI_FREE_LIST_RETURN_MT(frag->my_list, (ompi_free_list_item_t*)(frag)); \
141 }
142 #endif
143
144 #define MCA_BTL_TCP_FRAG_INIT_DST(frag,ep) \
145 do { \
146 frag->base.des_src = NULL; \
147 frag->base.des_src_cnt = 0; \
148 frag->base.des_dst = frag->segments; \
149 frag->base.des_dst_cnt = 1; \
150 frag->endpoint = ep; \
151 frag->iov[0].iov_len = sizeof(frag->hdr); \
152 frag->iov[0].iov_base = (IOVBASE_TYPE*)&frag->hdr; \
153 frag->iov_cnt = 1; \
154 frag->iov_idx = 0; \
155 frag->iov_ptr = frag->iov; \
156 frag->rc = 0; \
157 } while(0)
158
159
160 bool mca_btl_tcp2_frag_send(mca_btl_tcp2_frag_t*, int sd);
161 bool mca_btl_tcp2_frag_recv(mca_btl_tcp2_frag_t*, int sd);
162
163 void mca_btl_tcp_dump_frag( mca_btl_tcp_frag_t* frag, char* msg );
164
165 END_C_DECLS
166 #endif