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) 2015-2019 Intel, Inc. All rights reserved.
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 */
22
23 #ifndef _MCA_OOB_TCP_PEER_H_
24 #define _MCA_OOB_TCP_PEER_H_
25
26 #include "orte_config.h"
27
28 #include "opal/mca/event/event.h"
29
30 #include "orte/util/threads.h"
31 #include "oob_tcp.h"
32 #include "oob_tcp_sendrecv.h"
33
34 typedef struct {
35 opal_list_item_t super;
36 struct sockaddr_storage addr; // an address where a peer can be found
37 int retries; // number of times we have tried to connect to this address
38 mca_oob_tcp_state_t state; // state of this address
39 } mca_oob_tcp_addr_t;
40 OBJ_CLASS_DECLARATION(mca_oob_tcp_addr_t);
41
42 /* object for tracking peers in the module */
43 typedef struct {
44 opal_list_item_t super;
45 /* although not required, there is enough debug
46 * value that retaining the name makes sense
47 */
48 orte_process_name_t name;
49 char *auth_method; // method they used to authenticate
50 int sd;
51 opal_list_t addrs;
52 mca_oob_tcp_addr_t *active_addr;
53 mca_oob_tcp_state_t state;
54 int num_retries;
55 opal_event_base_t *ev_base; // progress thread this peer is assigned to
56 opal_event_t send_event; /**< registration with event thread for send events */
57 bool send_ev_active;
58 opal_event_t recv_event; /**< registration with event thread for recv events */
59 bool recv_ev_active;
60 opal_event_t timer_event; /**< timer for retrying connection failures */
61 bool timer_ev_active;
62 opal_list_t send_queue; /**< list of messages to send */
63 mca_oob_tcp_send_t *send_msg; /**< current send in progress */
64 mca_oob_tcp_recv_t *recv_msg; /**< current recv in progress */
65 } mca_oob_tcp_peer_t;
66 OBJ_CLASS_DECLARATION(mca_oob_tcp_peer_t);
67
68 /* state machine for processing peer data */
69 typedef struct {
70 opal_object_t super;
71 opal_event_t ev;
72 orte_process_name_t peer;
73 uint16_t af_family;
74 char *net;
75 char *port;
76 } mca_oob_tcp_peer_op_t;
77 OBJ_CLASS_DECLARATION(mca_oob_tcp_peer_op_t);
78
79 #define ORTE_ACTIVATE_TCP_CMP_OP(p, cbfunc) \
80 do { \
81 mca_oob_tcp_peer_op_t *pop; \
82 pop = OBJ_NEW(mca_oob_tcp_peer_op_t); \
83 pop->peer.jobid = (p)->name.jobid; \
84 pop->peer.vpid = (p)->name.vpid; \
85 ORTE_THREADSHIFT(pop, orte_oob_base.ev_base, \
86 (cbfunc), ORTE_MSG_PRI); \
87 } while(0);
88
89 #endif /* _MCA_OOB_TCP_PEER_H_ */