1 /*
2 * Copyright (c) 2004-2005 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) 2010 Oracle and/or its affiliates. All rights reserved
13 * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
14 * $COPYRIGHT$
15 *
16 * Additional copyrights may follow
17 *
18 * $HEADER$
19 */
20
21 #ifndef MCA_BTL_TCP_PROC_H
22 #define MCA_BTL_TCP_PROC_H
23
24 #include "opal/class/opal_object.h"
25 #include "ompi/proc/proc.h"
26 #include "orte/types.h"
27 #include "btl_tcp2.h"
28 #include "btl_tcp2_addr.h"
29 #include "btl_tcp2_endpoint.h"
30
31 BEGIN_C_DECLS
32
33 /**
34 * Represents the state of a remote process and the set of addresses
35 * that it exports. Also cache an instance of mca_btl_base_endpoint_t for
36 * each
37 * BTL instance that attempts to open a connection to the process.
38 */
39 struct mca_btl_tcp2_proc_t {
40 opal_list_item_t super;
41 /**< allow proc to be placed on a list */
42
43 ompi_proc_t *proc_ompi;
44 /**< pointer to corresponding ompi_proc_t */
45
46 struct mca_btl_tcp2_addr_t* proc_addrs;
47 /**< array of addresses exported by peer */
48
49 size_t proc_addr_count;
50 /**< number of addresses published by endpoint */
51
52 struct mca_btl_base_endpoint_t **proc_endpoints;
53 /**< array of endpoints that have been created to access this proc */
54
55 size_t proc_endpoint_count;
56 /**< number of endpoints */
57
58 opal_mutex_t proc_lock;
59 /**< lock to protect against concurrent access to proc state */
60 };
61 typedef struct mca_btl_tcp2_proc_t mca_btl_tcp2_proc_t;
62 OBJ_CLASS_DECLARATION(mca_btl_tcp2_proc_t);
63
64 /* the highest possible interface kernel index we can handle */
65 #define MAX_KERNEL_INTERFACE_INDEX 65536
66
67 /* the maximum number of kernel interfaces we can handle */
68 #define MAX_KERNEL_INTERFACES 8
69
70 /* The maximum number of interfaces that we can have and use the
71 * recursion code for determining the best set of connections. When
72 * the number is greater than this, we switch to a simpler algorithm
73 * to speed things up. */
74 #define MAX_PERMUTATION_INTERFACES 8
75
76 /*
77 * FIXME: this should probably be part of an ompi list, so we need the
78 * appropriate definitions
79 */
80
81 struct mca_btl_tcp2_interface_t {
82 struct sockaddr_storage* ipv4_address;
83 struct sockaddr_storage* ipv6_address;
84 mca_btl_tcp2_addr_t* ipv4_endpoint_addr;
85 mca_btl_tcp2_addr_t* ipv6_endpoint_addr;
86 uint32_t ipv4_netmask;
87 uint32_t ipv6_netmask;
88 int kernel_index;
89 int peer_interface;
90 int index;
91 int inuse;
92 };
93
94 typedef struct mca_btl_tcp2_interface_t mca_btl_tcp2_interface_t;
95
96 /*
97 * describes the quality of a possible connection between a local and
98 * a remote network interface
99 */
100 enum mca_btl_tcp2_connection_quality {
101 CQ_NO_CONNECTION,
102 CQ_PRIVATE_DIFFERENT_NETWORK,
103 CQ_PRIVATE_SAME_NETWORK,
104 CQ_PUBLIC_DIFFERENT_NETWORK,
105 CQ_PUBLIC_SAME_NETWORK
106 };
107
108
109 mca_btl_tcp2_proc_t* mca_btl_tcp2_proc_create(ompi_proc_t* ompi_proc);
110 mca_btl_tcp2_proc_t* mca_btl_tcp2_proc_lookup(const orte_process_name_t* name);
111 int mca_btl_tcp2_proc_insert(mca_btl_tcp2_proc_t*, mca_btl_base_endpoint_t*);
112 int mca_btl_tcp2_proc_remove(mca_btl_tcp2_proc_t*, mca_btl_base_endpoint_t*);
113 bool mca_btl_tcp2_proc_accept(mca_btl_tcp2_proc_t*, struct sockaddr*, int);
114 bool mca_btl_tcp2_proc_tosocks(mca_btl_tcp2_addr_t*, struct sockaddr_storage*);
115
116 /**
117 * Inlined function to return local TCP proc instance.
118 */
119
120 static inline mca_btl_tcp2_proc_t* mca_btl_tcp2_proc_local(void)
121 {
122 if(NULL == mca_btl_tcp2_component.tcp_local)
123 mca_btl_tcp2_component.tcp_local = mca_btl_tcp2_proc_create(ompi_proc_local());
124 return mca_btl_tcp2_component.tcp_local;
125 }
126
127 END_C_DECLS
128 #endif