1 /*
2 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2006 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2006-2013 Los Alamos National Security, LLC.
13 * All rights reserved.
14 * Copyright (c) 2010-2011 Cisco Systems, Inc. All rights reserved.
15 * Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 */
22
23 #ifndef _MCA_OOB_TCP_COMPONENT_H_
24 #define _MCA_OOB_TCP_COMPONENT_H_
25
26 #include "orte_config.h"
27
28 #ifdef HAVE_SYS_TIME_H
29 #include <sys/time.h>
30 #endif
31
32 #include "opal/class/opal_bitmap.h"
33 #include "opal/class/opal_list.h"
34 #include "opal/class/opal_pointer_array.h"
35 #include "opal/class/opal_hash_table.h"
36 #include "opal/mca/event/event.h"
37
38 #include "orte/mca/oob/oob.h"
39 #include "oob_tcp.h"
40
41 /**
42 * OOB TCP Component
43 */
44 typedef struct {
45 mca_oob_base_component_t super; /**< base OOB component */
46 uint32_t addr_count; /**< total number of addresses */
47 int num_links; /**< number of logical links per physical device */
48 int max_retries; /**< max number of retries before declaring peer gone */
49 opal_list_t events; /**< events for monitoring connections */
50 int peer_limit; /**< max size of tcp peer cache */
51 opal_pointer_array_t ev_bases; // event base array for progress threads
52 char** ev_threads; // event progress thread names
53 int next_base; // counter to load-level thread use
54 opal_hash_table_t peers; // connection addresses for peers
55
56 /* Port specifications */
57 char* if_include; /**< list of ip interfaces to include */
58 char* if_exclude; /**< list of ip interfaces to exclude */
59 int tcp_sndbuf; /**< socket send buffer size */
60 int tcp_rcvbuf; /**< socket recv buffer size */
61
62 /* IPv4 support */
63 bool disable_ipv4_family; /**< disable this AF */
64 char** tcp_static_ports; /**< Static ports - IPV4 */
65 char** tcp_dyn_ports; /**< Dynamic ports - IPV4 */
66 char** ipv4conns;
67 char** ipv4ports;
68
69 /* IPv6 support */
70 bool disable_ipv6_family; /**< disable this AF */
71 char** tcp6_static_ports; /**< Static ports - IPV6 */
72 char** tcp6_dyn_ports; /**< Dynamic ports - IPV6 */
73 char** ipv6conns;
74 char** ipv6ports;
75
76 /* connection support */
77 char* my_uri; /**< uri for connecting to the TCP module */
78 int num_hnp_ports; /**< number of ports the HNP should listen on */
79 opal_list_t listeners; /**< List of sockets being monitored by event or thread */
80 opal_thread_t listen_thread; /**< handle to the listening thread */
81 bool listen_thread_active;
82 struct timeval listen_thread_tv; /**< Timeout when using listen thread */
83 int stop_thread[2]; /**< pipe used to exit the listen thread */
84 int keepalive_probes; /**< number of keepalives that can be missed before declaring error */
85 int keepalive_time; /**< idle time in seconds before starting to send keepalives */
86 int keepalive_intvl; /**< time between keepalives, in seconds */
87 int retry_delay; /**< time to wait before retrying connection */
88 int max_recon_attempts; /**< maximum number of times to attempt connect before giving up (-1 for never) */
89 } mca_oob_tcp_component_t;
90
91 ORTE_MODULE_DECLSPEC extern mca_oob_tcp_component_t mca_oob_tcp_component;
92
93 ORTE_MODULE_DECLSPEC void mca_oob_tcp_component_set_module(int fd, short args, void *cbdata);
94 ORTE_MODULE_DECLSPEC void mca_oob_tcp_component_lost_connection(int fd, short args, void *cbdata);
95 ORTE_MODULE_DECLSPEC void mca_oob_tcp_component_failed_to_connect(int fd, short args, void *cbdata);
96 ORTE_MODULE_DECLSPEC void mca_oob_tcp_component_no_route(int fd, short args, void *cbdata);
97 ORTE_MODULE_DECLSPEC void mca_oob_tcp_component_hop_unknown(int fd, short args, void *cbdata);
98
99 #define ORTE_OOB_TCP_NEXT_BASE(p) \
100 do { \
101 ++mca_oob_tcp_component.next_base; \
102 if (orte_oob_base.num_threads <= mca_oob_tcp_component.next_base) { \
103 mca_oob_tcp_component.next_base = 0; \
104 } \
105 (p)->ev_base = (opal_event_base_t*)opal_pointer_array_get_item(&mca_oob_tcp_component.ev_bases, mca_oob_tcp_component.next_base); \
106 } while(0)
107
108 #endif /* _MCA_OOB_TCP_COMPONENT_H_ */