root/contrib/build-mca-comps-outside-of-tree/btl_tcp2.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2009 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         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  * @file
  22  */
  23 #ifndef MCA_BTL_TCP_H
  24 #define MCA_BTL_TCP_H
  25 
  26 #include "ompi_config.h"
  27 #ifdef HAVE_SYS_TYPES_H
  28 #include <sys/types.h>
  29 #endif
  30 #ifdef HAVE_SYS_SOCKET_H
  31 #include <sys/socket.h>
  32 #endif
  33 #ifdef HAVE_NETINET_IN_H
  34 #include <netinet/in.h>
  35 #endif
  36 
  37 /* Open MPI includes */
  38 #include "opal/mca/event/event.h"
  39 #include "ompi/class/ompi_free_list.h"
  40 #include "ompi/mca/btl/btl.h"
  41 #include "ompi/mca/btl/base/base.h"
  42 #include "ompi/mca/mpool/mpool.h"
  43 #include "ompi/mca/btl/btl.h"
  44 #include "opal/class/opal_hash_table.h"
  45 
  46 #define MCA_BTL_TCP_STATISTICS 0
  47 BEGIN_C_DECLS
  48 
  49 
  50 /**
  51  * TCP BTL component.
  52  */
  53 
  54 struct mca_btl_tcp2_component_t {
  55     mca_btl_base_component_2_0_0_t super;   /**< base BTL component */
  56     uint32_t tcp_addr_count;                /**< total number of addresses */
  57     uint32_t tcp_num_btls;                  /**< number of hcas available to the TCP component */
  58     uint32_t tcp_num_links;                 /**< number of logical links per physical device */
  59     struct mca_btl_tcp2_module_t **tcp_btls; /**< array of available BTL modules */
  60     struct mca_btl_tcp2_proc_t* tcp_local;   /**< local proc struct */
  61     int tcp_free_list_num;                  /**< initial size of free lists */
  62     int tcp_free_list_max;                  /**< maximum size of free lists */
  63     int tcp_free_list_inc;                  /**< number of elements to alloc when growing free lists */
  64     int tcp_endpoint_cache;                 /**< amount of cache on each endpoint */
  65     opal_hash_table_t tcp_procs;            /**< hash table of tcp proc structures */
  66     opal_list_t tcp_events;                 /**< list of pending tcp events */
  67     opal_mutex_t tcp_lock;                  /**< lock for accessing module state */
  68 
  69     opal_event_t tcp_recv_event;            /**< recv event for IPv4 listen socket */
  70     int tcp_listen_sd;                      /**< IPv4 listen socket for incoming connection requests */
  71     unsigned short tcp_listen_port;         /**< IPv4 listen port */
  72     int32_t tcp_port_min;                   /**< IPv4 minimum port */
  73     int32_t tcp_port_range;                 /**< IPv4 port range */
  74 #if OPAL_ENABLE_IPV6
  75     opal_event_t tcp6_recv_event;           /**< recv event for IPv6 listen socket */
  76     int tcp6_listen_sd;                     /**< IPv6 listen socket for incoming connection requests */
  77     unsigned short tcp6_listen_port;        /**< IPv6 listen port */
  78     int32_t tcp6_port_min;                  /**< IPv4 minimum port */
  79     int32_t tcp6_port_range;                /**< IPv4 port range */
  80 #endif
  81     /* Port range restriction */
  82 
  83     char*  tcp_if_include;                  /**< comma seperated list of interface to include */
  84     char*  tcp_if_exclude;                  /**< comma seperated list of interface to exclude */
  85     int    tcp_sndbuf;                      /**< socket sndbuf size */
  86     int    tcp_rcvbuf;                      /**< socket rcvbuf size */
  87     int    tcp_disable_family;              /**< disabled AF_family */
  88 
  89     /* free list of fragment descriptors */
  90     ompi_free_list_t tcp_frag_eager;
  91     ompi_free_list_t tcp_frag_max;
  92     ompi_free_list_t tcp_frag_user;
  93 
  94     /* Do we want to use TCP_NODELAY? */
  95     int    tcp_use_nodelay;
  96 };
  97 typedef struct mca_btl_tcp2_component_t mca_btl_tcp2_component_t;
  98 
  99 OMPI_MODULE_DECLSPEC extern mca_btl_tcp2_component_t mca_btl_tcp2_component;
 100 
 101 /**
 102  * BTL Module Interface
 103  */
 104 struct mca_btl_tcp2_module_t {
 105     mca_btl_base_module_t  super;  /**< base BTL interface */
 106     uint16_t           tcp_ifkindex; /** <BTL kernel interface index */
 107 #if 0
 108     int                tcp_ifindex; /**< PTL interface index */
 109 #endif
 110     struct sockaddr_storage tcp_ifaddr; /**< PTL interface address */
 111     uint32_t           tcp_ifmask;  /**< PTL interface netmask */
 112     opal_list_t        tcp_endpoints;
 113 #if MCA_BTL_TCP_STATISTICS
 114     size_t tcp_bytes_sent;
 115     size_t tcp_bytes_recv;
 116     size_t tcp_send_handler;
 117 #endif
 118 };
 119 typedef struct mca_btl_tcp2_module_t mca_btl_tcp2_module_t;
 120 extern mca_btl_tcp2_module_t mca_btl_tcp2_module;
 121 
 122 #define CLOSE_THE_SOCKET(socket)   close(socket)
 123 
 124 /**
 125  * Register TCP component parameters with the MCA framework
 126  */
 127 extern int mca_btl_tcp2_component_open(void);
 128 
 129 /**
 130  * Any final cleanup before being unloaded.
 131  */
 132 extern int mca_btl_tcp2_component_close(void);
 133 
 134 /**
 135  * TCP component initialization.
 136  *
 137  * @param num_btl_modules (OUT)           Number of BTLs returned in BTL array.
 138  * @param allow_multi_user_threads (OUT)  Flag indicating wether BTL supports user threads (TRUE)
 139  * @param have_hidden_threads (OUT)       Flag indicating wether BTL uses threads (TRUE)
 140  */
 141 extern mca_btl_base_module_t** mca_btl_tcp2_component_init(
 142     int *num_btl_modules,
 143     bool allow_multi_user_threads,
 144     bool have_hidden_threads
 145 );
 146 
 147 /**
 148  * TCP component control.
 149  */
 150 int mca_btl_tcp2_component_control(
 151     int param,
 152     void* value,
 153     size_t size
 154 );
 155 
 156 
 157 /**
 158  * TCP component progress.
 159  */
 160 extern int mca_btl_tcp2_component_progress(void);
 161 
 162 
 163 
 164 /**
 165  * Cleanup any resources held by the BTL.
 166  *
 167  * @param btl  BTL instance.
 168  * @return     OMPI_SUCCESS or error status on failure.
 169  */
 170 
 171 extern int mca_btl_tcp2_finalize(
 172     struct mca_btl_base_module_t* btl
 173 );
 174 
 175 
 176 /**
 177  * PML->BTL notification of change in the process list.
 178  *
 179  * @param btl (IN)
 180  * @param nprocs (IN)     Number of processes
 181  * @param procs (IN)      Set of processes
 182  * @param peers (OUT)     Set of (optional) peer addressing info.
 183  * @param peers (IN/OUT)  Set of processes that are reachable via this BTL.
 184  * @return     OMPI_SUCCESS or error status on failure.
 185  *
 186  */
 187 
 188 extern int mca_btl_tcp2_add_procs(
 189     struct mca_btl_base_module_t* btl,
 190     size_t nprocs,
 191     struct ompi_proc_t **procs,
 192     struct mca_btl_base_endpoint_t** peers,
 193     opal_bitmap_t* reachable
 194 );
 195 
 196 /**
 197  * PML->BTL notification of change in the process list.
 198  *
 199  * @param btl (IN)     BTL instance
 200  * @param nproc (IN)   Number of processes.
 201  * @param procs (IN)   Set of processes.
 202  * @param peers (IN)   Set of peer data structures.
 203  * @return             Status indicating if cleanup was successful
 204  *
 205  */
 206 
 207 extern int mca_btl_tcp2_del_procs(
 208     struct mca_btl_base_module_t* btl,
 209     size_t nprocs,
 210     struct ompi_proc_t **procs,
 211     struct mca_btl_base_endpoint_t** peers
 212 );
 213 
 214 
 215 /**
 216  * Initiate an asynchronous send.
 217  *
 218  * @param btl (IN)         BTL module
 219  * @param endpoint (IN)    BTL addressing information
 220  * @param descriptor (IN)  Description of the data to be transfered
 221  * @param tag (IN)         The tag value used to notify the peer.
 222  */
 223 
 224 extern int mca_btl_tcp2_send(
 225     struct mca_btl_base_module_t* btl,
 226     struct mca_btl_base_endpoint_t* btl_peer,
 227     struct mca_btl_base_descriptor_t* descriptor,
 228     mca_btl_base_tag_t tag
 229 );
 230 
 231 
 232 /**
 233  * Initiate an asynchronous put.
 234  *
 235  * @param btl (IN)         BTL module
 236  * @param endpoint (IN)    BTL addressing information
 237  * @param descriptor (IN)  Description of the data to be transferred
 238  */
 239 
 240 extern int mca_btl_tcp2_put(
 241     struct mca_btl_base_module_t* btl,
 242     struct mca_btl_base_endpoint_t* btl_peer,
 243     struct mca_btl_base_descriptor_t* decriptor
 244 );
 245 
 246 
 247 /**
 248  * Initiate an asynchronous get.
 249  *
 250  * @param btl (IN)         BTL module
 251  * @param endpoint (IN)    BTL addressing information
 252  * @param descriptor (IN)  Description of the data to be transferred
 253  */
 254 
 255 extern int mca_btl_tcp2_get(
 256     struct mca_btl_base_module_t* btl,
 257     struct mca_btl_base_endpoint_t* btl_peer,
 258     struct mca_btl_base_descriptor_t* decriptor
 259 );
 260 
 261 /**
 262  * Allocate a descriptor with a segment of the requested size.
 263  * Note that the BTL layer may choose to return a smaller size
 264  * if it cannot support the request.
 265  *
 266  * @param btl (IN)      BTL module
 267  * @param size (IN)     Request segment size.
 268  */
 269 
 270 extern mca_btl_base_descriptor_t* mca_btl_tcp2_alloc(
 271     struct mca_btl_base_module_t* btl,
 272     struct mca_btl_base_endpoint_t* endpoint,
 273     uint8_t order,
 274     size_t size,
 275     uint32_t flags);
 276 
 277 
 278 /**
 279  * Return a segment allocated by this BTL.
 280  *
 281  * @param btl (IN)      BTL module
 282  * @param descriptor (IN)  Allocated descriptor.
 283  */
 284 
 285 extern int mca_btl_tcp2_free(
 286     struct mca_btl_base_module_t* btl,
 287     mca_btl_base_descriptor_t* des);
 288 
 289 
 290 /**
 291  * Prepare a descriptor for send/rdma using the supplied
 292  * convertor. If the convertor references data that is contigous,
 293  * the descriptor may simply point to the user buffer. Otherwise,
 294  * this routine is responsible for allocating buffer space and
 295  * packing if required.
 296  *
 297  * @param btl (IN)          BTL module
 298  * @param endpoint (IN)     BTL peer addressing
 299  * @param convertor (IN)    Data type convertor
 300  * @param reserve (IN)      Additional bytes requested by upper layer to precede user data
 301  * @param size (IN/OUT)     Number of bytes to prepare (IN), number of bytes actually prepared (OUT)
 302 */
 303 
 304 mca_btl_base_descriptor_t* mca_btl_tcp2_prepare_src(
 305     struct mca_btl_base_module_t* btl,
 306     struct mca_btl_base_endpoint_t* peer,
 307     struct mca_mpool_base_registration_t*,
 308     struct opal_convertor_t* convertor,
 309     uint8_t order,
 310     size_t reserve,
 311     size_t* size,
 312     uint32_t flags
 313 );
 314 
 315 extern mca_btl_base_descriptor_t* mca_btl_tcp2_prepare_dst(
 316     struct mca_btl_base_module_t* btl,
 317     struct mca_btl_base_endpoint_t* peer,
 318     struct mca_mpool_base_registration_t*,
 319     struct opal_convertor_t* convertor,
 320     uint8_t order,
 321     size_t reserve,
 322     size_t* size,
 323     uint32_t flags);
 324 
 325 
 326 /**
 327   * Fault Tolerance Event Notification Function
 328   * @param state Checkpoint Stae
 329   * @return OMPI_SUCCESS or failure status
 330   */
 331 int mca_btl_tcp2_ft_event(int state);
 332 
 333 END_C_DECLS
 334 #endif

/* [<][>][^][v][top][bottom][index][help] */