1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef MCA_BTL_TCP_ENDPOINT_H
20 #define MCA_BTL_TCP_ENDPOINT_H
21
22 #include "opal/class/opal_list.h"
23 #include "opal/mca/event/event.h"
24 #include "btl_tcp_frag.h"
25 #include "btl_tcp.h"
26 BEGIN_C_DECLS
27
28 #define MCA_BTL_TCP_ENDPOINT_CACHE 1
29 #define MCA_BTL_TCP_MAGIC_STRING_LENGTH 16
30
31
32
33
34 typedef enum {
35 MCA_BTL_TCP_CONNECTING = 0,
36 MCA_BTL_TCP_CONNECT_ACK,
37 MCA_BTL_TCP_CLOSED,
38 MCA_BTL_TCP_FAILED,
39 MCA_BTL_TCP_CONNECTED
40 } mca_btl_tcp_state_t;
41
42
43
44
45
46
47
48
49 struct mca_btl_base_endpoint_t {
50 opal_list_item_t super;
51 struct mca_btl_tcp_module_t* endpoint_btl;
52 struct mca_btl_tcp_proc_t* endpoint_proc;
53 struct mca_btl_tcp_addr_t* endpoint_addr;
54 int endpoint_sd;
55 int endpoint_sd_next;
56 #if MCA_BTL_TCP_ENDPOINT_CACHE
57 char* endpoint_cache;
58 char* endpoint_cache_pos;
59 size_t endpoint_cache_length;
60 #endif
61 struct mca_btl_tcp_frag_t* endpoint_send_frag;
62 struct mca_btl_tcp_frag_t* endpoint_recv_frag;
63 mca_btl_tcp_state_t endpoint_state;
64 uint32_t endpoint_retries;
65 opal_list_t endpoint_frags;
66 opal_mutex_t endpoint_send_lock;
67 opal_mutex_t endpoint_recv_lock;
68 opal_event_t endpoint_accept_event;
69 opal_event_t endpoint_send_event;
70 opal_event_t endpoint_recv_event;
71 bool endpoint_nbo;
72 };
73
74 typedef struct mca_btl_base_endpoint_t mca_btl_base_endpoint_t;
75 typedef mca_btl_base_endpoint_t mca_btl_tcp_endpoint_t;
76 OBJ_CLASS_DECLARATION(mca_btl_tcp_endpoint_t);
77
78
79 extern const char mca_btl_tcp_magic_id_string[MCA_BTL_TCP_MAGIC_STRING_LENGTH];
80
81 typedef struct {
82 opal_process_name_t guid;
83 char magic_id[MCA_BTL_TCP_MAGIC_STRING_LENGTH];
84 } mca_btl_tcp_endpoint_hs_msg_t;
85
86 void mca_btl_tcp_set_socket_options(int sd);
87 void mca_btl_tcp_endpoint_close(mca_btl_base_endpoint_t*);
88 int mca_btl_tcp_endpoint_send(mca_btl_base_endpoint_t*, struct mca_btl_tcp_frag_t*);
89 void mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t*, struct sockaddr*, int);
90 void mca_btl_tcp_endpoint_shutdown(mca_btl_base_endpoint_t*);
91
92
93
94
95
96 #define WANT_PEER_DUMP 0
97
98 #if OPAL_ENABLE_DEBUG && WANT_PEER_DUMP
99 #define MCA_BTL_TCP_ENDPOINT_DUMP(LEVEL, ENDPOINT, INFO, MSG) mca_btl_tcp_endpoint_dump((LEVEL), __FILE__, __LINE__, __func__, (ENDPOINT), (INFO), (MSG))
100 void mca_btl_tcp_endpoint_dump(int level, const char* fname, int lineno, const char* funcname,
101 mca_btl_base_endpoint_t* btl_endpoint, bool full_info, const char* msg);
102 #else
103 #define MCA_BTL_TCP_ENDPOINT_DUMP(LEVEL, ENDPOINT, INFO, MSG)
104 #endif
105
106 END_C_DECLS
107
108 #endif