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$
14 *
15 * Additional copyrights may follow
16 *
17 * $HEADER$
18 */
19
20 #ifndef MCA_BTL_TCP_PROC_H
21 #define MCA_BTL_TCP_PROC_H
22
23 #include "opal/class/opal_object.h"
24 #include "opal/util/proc.h"
25 #include "btl_tcp.h"
26 #include "btl_tcp_addr.h"
27 #include "btl_tcp_endpoint.h"
28
29 BEGIN_C_DECLS
30
31 /**
32 * Represents the state of a remote process and the set of addresses
33 * that it exports. Also cache an instance of mca_btl_base_endpoint_t for
34 * each
35 * BTL instance that attempts to open a connection to the process.
36 */
37 struct mca_btl_tcp_proc_t {
38 opal_list_item_t super;
39 /**< allow proc to be placed on a list */
40
41 opal_proc_t *proc_opal;
42 /**< pointer to corresponding opal_proc_t */
43
44 struct mca_btl_tcp_addr_t* proc_addrs;
45 /**< array of addresses exported by peer */
46
47 size_t proc_addr_count;
48 /**< number of addresses published by endpoint */
49
50 struct mca_btl_base_endpoint_t **proc_endpoints;
51 /**< array of endpoints that have been created to access this proc */
52
53 size_t proc_endpoint_count;
54 /**< number of endpoints */
55
56 opal_mutex_t proc_lock;
57 /**< lock to protect against concurrent access to proc state */
58 };
59 typedef struct mca_btl_tcp_proc_t mca_btl_tcp_proc_t;
60 OBJ_CLASS_DECLARATION(mca_btl_tcp_proc_t);
61
62 /* the highest possible interface kernel index we can handle */
63 #define MAX_KERNEL_INTERFACE_INDEX 65536
64
65 /* the maximum number of kernel interfaces we can handle */
66 #define MAX_KERNEL_INTERFACES 8
67
68 /* The maximum number of interfaces that we can have and use the
69 * recursion code for determining the best set of connections. When
70 * the number is greater than this, we switch to a simpler algorithm
71 * to speed things up. */
72 #define MAX_PERMUTATION_INTERFACES 8
73
74 /*
75 * FIXME: this should probably be part of an ompi list, so we need the
76 * appropriate definitions
77 */
78
79 struct mca_btl_tcp_interface_t {
80 struct sockaddr_storage* ipv4_address;
81 struct sockaddr_storage* ipv6_address;
82 mca_btl_tcp_addr_t* ipv4_endpoint_addr;
83 mca_btl_tcp_addr_t* ipv6_endpoint_addr;
84 uint32_t ipv4_netmask;
85 uint32_t ipv6_netmask;
86 int kernel_index;
87 int peer_interface;
88 int index;
89 int inuse;
90 };
91
92 typedef struct mca_btl_tcp_interface_t mca_btl_tcp_interface_t;
93
94 /*
95 * describes the quality of a possible connection between a local and
96 * a remote network interface
97 */
98 enum mca_btl_tcp_connection_quality {
99 CQ_NO_CONNECTION,
100 CQ_PRIVATE_DIFFERENT_NETWORK,
101 CQ_PRIVATE_SAME_NETWORK,
102 CQ_PUBLIC_DIFFERENT_NETWORK,
103 CQ_PUBLIC_SAME_NETWORK
104 };
105
106
107 mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(opal_proc_t* proc);
108 mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const opal_process_name_t* name);
109 int mca_btl_tcp_proc_insert(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*);
110 int mca_btl_tcp_proc_remove(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*);
111 void mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t*, struct sockaddr*, int);
112 bool mca_btl_tcp_proc_tosocks(mca_btl_tcp_addr_t*, struct sockaddr_storage*);
113
114 END_C_DECLS
115 #endif