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-2011 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-2007 Voltaire All rights reserved.
13  * Copyright (c) 2008      Cisco Systems, Inc.  All rights reserved.
14  * Copyright (c) 2015      Mellanox Technologies. All rights reserved.
15  *
16  * $COPYRIGHT$
17  *
18  * Additional copyrights may follow
19  *
20  * $HEADER$
21  */
22 
23 #ifndef MCA_BTL_IB_PROC_H
24 #define MCA_BTL_IB_PROC_H
25 
26 #include "opal/class/opal_object.h"
27 #include "opal/util/proc.h"
28 #include "btl_openib.h"
29 #include "btl_openib_endpoint.h"
30 
31 BEGIN_C_DECLS
32 
33 /* Must forward reference this to avoid include file loop */
34 struct opal_btl_openib_connect_base_module_data_t;
35 
36 /**
37  * Data received from the modex.  For each openib BTL module/port in
38  * the peer, we'll receive two things:
39  *
40  * 1. Data about the peer's port
41  * 2. An array of CPCs that the peer has available on that port, each
42  *    of which has its own meta data
43  *
44  * Hence, these two items need to be bundled together;
45  */
46 typedef struct mca_btl_openib_proc_modex_t {
47     /** Information about the peer's port */
48     mca_btl_openib_modex_message_t pm_port_info;
49 
50     /** Array of the peer's CPCs available on this port */
51     opal_btl_openib_connect_base_module_data_t *pm_cpc_data;
52 
53     /** Length of the pm_cpc_data array */
54     uint8_t pm_cpc_data_count;
55 } mca_btl_openib_proc_modex_t;
56 
57 /**
58  * The list element to hold pointers to openin_btls that are using this
59  * ib_proc.
60  */
61 
62 struct mca_btl_openib_proc_btlptr_t {
63     opal_list_item_t super;
64     mca_btl_openib_module_t* openib_btl;
65 };
66 typedef struct mca_btl_openib_proc_btlptr_t mca_btl_openib_proc_btlptr_t;
67 
68 OBJ_CLASS_DECLARATION(mca_btl_openib_proc_btlptr_t);
69 
70 /**
71  * Represents the state of a remote process and the set of addresses
72  * that it exports. Also cache an instance of mca_btl_base_endpoint_t for
73  * each
74  * BTL instance that attempts to open a connection to the process.
75  */
76 struct mca_btl_openib_proc_t {
77     /** allow proc to be placed on a list */
78     opal_list_item_t super;
79 
80     /** pointer to corresponding opal_proc_t */
81     const opal_proc_t *proc_opal;
82 
83     /** modex messages from this proc; one for each port in the peer */
84     mca_btl_openib_proc_modex_t *proc_ports;
85 
86     /** length of proc_ports array */
87     uint8_t proc_port_count;
88 
89     /** list of openib_btl's that touched this proc **/
90     opal_list_t openib_btls;
91 
92     /** array of endpoints that have been created to access this proc */
93     volatile struct mca_btl_base_endpoint_t **proc_endpoints;
94 
95     /** number of endpoints (length of proc_endpoints array) */
96     volatile size_t proc_endpoint_count;
97 
98     /** lock to protect against concurrent access to proc state */
99     opal_mutex_t proc_lock;
100 };
101 typedef struct mca_btl_openib_proc_t mca_btl_openib_proc_t;
102 
103 OBJ_CLASS_DECLARATION(mca_btl_openib_proc_t);
104 
105 mca_btl_openib_proc_t* mca_btl_openib_proc_get_locked(opal_proc_t* proc);
106 int mca_btl_openib_proc_insert(mca_btl_openib_proc_t*, mca_btl_base_endpoint_t*);
107 int mca_btl_openib_proc_remove(opal_proc_t* proc,
108                                mca_btl_base_endpoint_t* module_endpoint);
109 int mca_btl_openib_proc_reg_btl(mca_btl_openib_proc_t* ib_proc,
110                                 mca_btl_openib_module_t* openib_btl);
111 
112 
113 END_C_DECLS
114 
115 #endif
116