root/opal/mca/btl/tcp/btl_tcp_frag.h

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

INCLUDED FROM


   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2016 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) 2014-2015 Los Alamos National Security, LLC. All rights
  14  *                         reserved.
  15  * $COPYRIGHT$
  16  *
  17  * Additional copyrights may follow
  18  *
  19  * $HEADER$
  20  */
  21 
  22 #ifndef MCA_BTL_TCP_FRAG_H
  23 #define MCA_BTL_TCP_FRAG_H
  24 
  25 
  26 #include "opal_config.h"
  27 
  28 #ifdef HAVE_SYS_TYPES_H
  29 #include <sys/types.h>
  30 #endif
  31 #ifdef HAVE_SYS_UIO_H
  32 #include <sys/uio.h>
  33 #endif
  34 #ifdef HAVE_NET_UIO_H
  35 #include <net/uio.h>
  36 #endif
  37 
  38 #include "btl_tcp.h"
  39 #include "btl_tcp_hdr.h"
  40 
  41 BEGIN_C_DECLS
  42 
  43 #define MCA_BTL_TCP_FRAG_IOVEC_NUMBER  4
  44 
  45 /**
  46  * TCP fragment derived type.
  47  */
  48 struct mca_btl_tcp_frag_t {
  49     mca_btl_base_descriptor_t base;
  50     mca_btl_base_segment_t segments[2];
  51     struct mca_btl_base_endpoint_t *endpoint;
  52     struct mca_btl_tcp_module_t* btl;
  53     mca_btl_tcp_hdr_t hdr;
  54     struct iovec iov[MCA_BTL_TCP_FRAG_IOVEC_NUMBER + 1];
  55     struct iovec *iov_ptr;
  56     uint32_t iov_cnt;
  57     uint32_t iov_idx;
  58     size_t size;
  59     uint16_t next_step;
  60     int rc;
  61     opal_free_list_t* my_list;
  62     /* fake rdma completion */
  63     struct {
  64         mca_btl_base_rdma_completion_fn_t func;
  65         void *data;
  66         void *context;
  67     } cb;
  68 };
  69 typedef struct mca_btl_tcp_frag_t mca_btl_tcp_frag_t;
  70 OBJ_CLASS_DECLARATION(mca_btl_tcp_frag_t);
  71 
  72 typedef struct mca_btl_tcp_frag_t mca_btl_tcp_frag_eager_t;
  73 
  74 OBJ_CLASS_DECLARATION(mca_btl_tcp_frag_eager_t);
  75 
  76 typedef struct mca_btl_tcp_frag_t mca_btl_tcp_frag_max_t;
  77 
  78 OBJ_CLASS_DECLARATION(mca_btl_tcp_frag_max_t);
  79 
  80 typedef struct mca_btl_tcp_frag_t mca_btl_tcp_frag_user_t;
  81 
  82 OBJ_CLASS_DECLARATION(mca_btl_tcp_frag_user_t);
  83 
  84 
  85 /*
  86  * Macros to allocate/return descriptors from module specific
  87  * free list(s).
  88  */
  89 
  90 #define MCA_BTL_TCP_FRAG_ALLOC_EAGER(frag)                              \
  91 {                                                                       \
  92     frag = (mca_btl_tcp_frag_t*)                                        \
  93         opal_free_list_get (&mca_btl_tcp_component.tcp_frag_eager);     \
  94 }
  95 
  96 #define MCA_BTL_TCP_FRAG_ALLOC_MAX(frag)                                \
  97 {                                                                       \
  98     frag = (mca_btl_tcp_frag_t*)                                        \
  99         opal_free_list_get (&mca_btl_tcp_component.tcp_frag_max);       \
 100 }
 101 
 102 #define MCA_BTL_TCP_FRAG_ALLOC_USER(frag)                               \
 103 {                                                                       \
 104     frag = (mca_btl_tcp_frag_t*)                                        \
 105         opal_free_list_get (&mca_btl_tcp_component.tcp_frag_user);      \
 106 }
 107 
 108 #define MCA_BTL_TCP_FRAG_RETURN(frag)                                      \
 109 {                                                                          \
 110     opal_free_list_return (frag->my_list, (opal_free_list_item_t*)(frag)); \
 111 }
 112 
 113 #define MCA_BTL_TCP_FRAG_INIT_DST(frag,ep)                                 \
 114 do {                                                                       \
 115     frag->rc = 0;                                                          \
 116     frag->btl = ep->endpoint_btl;                                          \
 117     frag->endpoint = ep;                                                   \
 118     frag->iov[0].iov_len = sizeof(frag->hdr);                              \
 119     frag->iov[0].iov_base = (IOVBASE_TYPE*)&frag->hdr;                     \
 120     frag->iov_cnt = 1;                                                     \
 121     frag->iov_idx = 0;                                                     \
 122     frag->iov_ptr = frag->iov;                                             \
 123     frag->base.des_segments = frag->segments;                                 \
 124     frag->base.des_segment_count = 1;                                        \
 125 } while(0)
 126 
 127 
 128 bool mca_btl_tcp_frag_send(mca_btl_tcp_frag_t*, int sd);
 129 bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t*, int sd);
 130 size_t mca_btl_tcp_frag_dump(mca_btl_tcp_frag_t* frag, char* msg, char* buf, size_t length);
 131 END_C_DECLS
 132 #endif

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