home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / io / bmi / bmi-method-support.h < prev    next >
C/C++ Source or Header  |  2010-04-30  |  9KB  |  252 lines

  1. /*
  2.  * (C) 2001 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. /* These are some support functions and data types shared across the
  8.  * various BMI methods.
  9.  */
  10.  
  11. #ifndef __BMI_METHOD_SUPPORT_H
  12. #define __BMI_METHOD_SUPPORT_H
  13.  
  14. #include "quicklist.h"
  15. #include "bmi-types.h"
  16. #include "pint-event.h"
  17.  
  18. #define BMI_MAX_CONTEXTS 16
  19.  
  20. /* magic number for BMI headers and control messages */
  21. #define BMI_MAGIC_NR 51903
  22.  
  23. #ifndef timersub
  24. # define timersub(a, b, result) \
  25.   do { \
  26.     (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
  27.     (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
  28.     if ((result)->tv_usec < 0) { \
  29.       --(result)->tv_sec; \
  30.       (result)->tv_usec += 1000000; \
  31.     } \
  32.   } while (0)
  33. #endif
  34.  
  35. /********************************************************
  36.  * method interfaces and data structures 
  37.  */
  38.  
  39. /* This is the generic address structure which contains adressing
  40.  * information for every protocol we support.  The method routines
  41.  * upcast the void* to find their particular device information.
  42.  */
  43. struct bmi_method_addr
  44. {
  45.     int method_type;
  46.     void *method_data;        /* area to be used by specific methods */
  47.     void *parent;               /* pointer back to generic BMI address info */  
  48. };
  49. typedef struct bmi_method_addr *bmi_method_addr_p;
  50.  
  51. /* used to describe unexpected messages that arrive */
  52. struct bmi_method_unexpected_info
  53. {
  54.     bmi_error_code_t error_code;
  55.     bmi_method_addr_p addr;
  56.     void *buffer;
  57.     bmi_size_t size;
  58.     bmi_msg_tag_t tag;
  59. };
  60.  
  61. /* flags that can be set per method to affect behavior */
  62. #define BMI_METHOD_FLAG_NO_POLLING 1
  63.  
  64. /* This is the table of interface functions that must be provided by BMI
  65.  * methods.
  66.  */
  67. struct bmi_method_ops
  68. {
  69.     const char *method_name;
  70.     int flags;
  71.     int (*initialize) (bmi_method_addr_p, int, int);
  72.     int (*finalize) (void);
  73.     int (*set_info) (int, void *);
  74.     int (*get_info) (int, void *);
  75.     void *(*memalloc) (bmi_size_t, enum bmi_op_type);
  76.     int (*memfree) (void *, bmi_size_t, enum bmi_op_type);
  77.  
  78.     int (*unexpected_free) (void *);
  79.  
  80.     int (*post_send) (bmi_op_id_t *,
  81.                       bmi_method_addr_p,
  82.                       const void *,
  83.                       bmi_size_t,
  84.                       enum bmi_buffer_type,
  85.                       bmi_msg_tag_t,
  86.                       void *,
  87.                       bmi_context_id,
  88.                       PVFS_hint hints);
  89.     int (*post_sendunexpected) (bmi_op_id_t *,
  90.                                 bmi_method_addr_p,
  91.                                 const void *,
  92.                                 bmi_size_t,
  93.                                 enum bmi_buffer_type,
  94.                                 bmi_msg_tag_t,
  95.                                 void *,
  96.                                 bmi_context_id,
  97.                                 PVFS_hint hints);
  98.     int (*post_recv) (bmi_op_id_t *,
  99.                       bmi_method_addr_p,
  100.                       void *,
  101.                       bmi_size_t,
  102.                       bmi_size_t *,
  103.                       enum bmi_buffer_type,
  104.                       bmi_msg_tag_t,
  105.                       void *,
  106.                       bmi_context_id,
  107.                       PVFS_hint hints);
  108.     int (*test) (bmi_op_id_t,
  109.                  int *,
  110.                  bmi_error_code_t *,
  111.                  bmi_size_t *,
  112.                  void **,
  113.                  int,
  114.                  bmi_context_id);
  115.     int (*testsome) (int,
  116.                      bmi_op_id_t *,
  117.                      int *,
  118.                      int *,
  119.                      bmi_error_code_t *,
  120.                      bmi_size_t *,
  121.                      void **,
  122.                      int,
  123.                      bmi_context_id);
  124.     int (*testcontext) (int,
  125.                         bmi_op_id_t*,
  126.                         int *,
  127.                         bmi_error_code_t *,
  128.                         bmi_size_t *,
  129.                         void **,
  130.                         int,
  131.                         bmi_context_id);
  132.     int (*testunexpected) (int,
  133.                            int *,
  134.                            struct bmi_method_unexpected_info *,
  135.                            int);
  136.     bmi_method_addr_p (*method_addr_lookup) (const char *);
  137.     int (*post_send_list) (bmi_op_id_t *,
  138.                            bmi_method_addr_p,
  139.                            const void *const *,
  140.                            const bmi_size_t *,
  141.                            int,
  142.                            bmi_size_t,
  143.                            enum bmi_buffer_type,
  144.                            bmi_msg_tag_t,
  145.                            void *,
  146.                            bmi_context_id,
  147.                            PVFS_hint hints);
  148.     int (*post_recv_list) (bmi_op_id_t *,
  149.                            bmi_method_addr_p,
  150.                            void *const *,
  151.                            const bmi_size_t *,
  152.                            int,
  153.                            bmi_size_t,
  154.                            bmi_size_t *,
  155.                            enum bmi_buffer_type,
  156.                            bmi_msg_tag_t,
  157.                            void *,
  158.                            bmi_context_id,
  159.                            PVFS_hint Hints);
  160.     int (*post_sendunexpected_list) (bmi_op_id_t *,
  161.                                      bmi_method_addr_p,
  162.                                      const void *const *,
  163.                                      const bmi_size_t *,
  164.                                      int,
  165.                                      bmi_size_t,
  166.                                      enum bmi_buffer_type,
  167.                                      bmi_msg_tag_t,
  168.                                      void *,
  169.                                      bmi_context_id,
  170.                                      PVFS_hint hints);
  171.     int (*open_context)(bmi_context_id);
  172.     void (*close_context)(bmi_context_id);
  173.     int (*cancel)(bmi_op_id_t, bmi_context_id);
  174.     const char* (*rev_lookup_unexpected)(bmi_method_addr_p);
  175.     int (*query_addr_range)(bmi_method_addr_p, const char *, int);
  176. };
  177.  
  178.  
  179. /*
  180.  * This structure is somewhat optional.  TCP and GM use the elements in
  181.  * here extensively, but IB, MX, Portals only use the bits required by
  182.  * the generic BMI layer.  Those are op_id and addr.  Everything else is
  183.  * ignored.  Would be nice to push most of method_op down into TCP and GM
  184.  * so other BMI implementations do not need to drag around the unused fields.
  185.  */
  186. struct method_op
  187. {
  188.     bmi_op_id_t op_id;        /* operation identifier */
  189.     enum bmi_op_type send_recv;    /* type of operation */
  190.     void *user_ptr;        /* user_ptr associated with this op */
  191.     bmi_msg_tag_t msg_tag;    /* message tag */
  192.     bmi_error_code_t error_code;    /* final status of operation */
  193.     bmi_size_t amt_complete;    /* how much is completed */
  194.     bmi_size_t env_amt_complete;    /* amount of the envelope that is completed */
  195.     void *buffer;        /* the memory region to transfer */
  196.     bmi_size_t actual_size;    /* total size of the transfer */
  197.     bmi_size_t expected_size;    /* expected size of the transfer */
  198.     bmi_method_addr_p addr;    /* peer address involved in the communication */
  199.     int mode;        /* operation mode */
  200.     bmi_context_id context_id;  /* context */
  201.     struct qlist_head op_list_entry;    /* op_list link */
  202.     struct qlist_head hash_link;    /* hash table link */
  203.     void *method_data;        /* for use by individual methods */
  204.  
  205.     /************************************************************
  206.      * following items were added for convenience of methods that 
  207.      * implement send_list and recv_list 
  208.      */
  209.     void *const *buffer_list;        /* list of buffers */
  210.     const bmi_size_t *size_list;    /* list of buffer sizes */
  211.     int list_count;        /* # of items in buffer list */
  212.     int list_index;        /* index of current buffer to xfer */
  213.     /* how much is completed in current buffer */
  214.     bmi_size_t cur_index_complete;
  215.     PINT_event_id event_id;
  216. };
  217. typedef struct method_op method_op_st, *method_op_p;
  218.  
  219. struct method_drop_addr_query
  220. {
  221.     struct bmi_method_addr* addr;
  222.     int response;
  223. };
  224.  
  225. /***********************************************************
  226.  * utility functions provided for use by the network methods 
  227.  */
  228.  
  229. /* functions for managing operations */
  230. method_op_p bmi_alloc_method_op(bmi_size_t payload_size);
  231. void bmi_dealloc_method_op(method_op_p op_p);
  232.  
  233. /* These functions can be used to manage generic address structures */
  234. bmi_method_addr_p bmi_alloc_method_addr(int method_type,
  235.                 bmi_size_t payload_size);
  236. void bmi_dealloc_method_addr(bmi_method_addr_p old_method_addr);
  237.  
  238. /* string parsing utilities */
  239. char *string_key(const char *key,
  240.          const char *id_string);
  241.  
  242. #endif /* __BMI_METHOD_SUPPORT_H */
  243.  
  244. /*
  245.  * Local variables:
  246.  *  c-indent-level: 4
  247.  *  c-basic-offset: 4
  248.  * End:
  249.  *
  250.  * vim: ts=8 sts=4 sw=4 expandtab
  251.  */
  252.