totem.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /*
  2. * Copyright (c) 2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2009 Red Hat, Inc.
  4. *
  5. * Author: Steven Dake (sdake@redhat.com)
  6. *
  7. * All rights reserved.
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef TOTEM_H_DEFINED
  36. #define TOTEM_H_DEFINED
  37. #include "totemip.h"
  38. #include <corosync/hdb.h>
  39. #ifdef HAVE_SMALL_MEMORY_FOOTPRINT
  40. #define PROCESSOR_COUNT_MAX 16
  41. #define MESSAGE_SIZE_MAX 1024*64
  42. #define MESSAGE_QUEUE_MAX 512
  43. #else
  44. #define PROCESSOR_COUNT_MAX 384
  45. #define MESSAGE_SIZE_MAX 1024*1024 /* (1MB) */
  46. #define MESSAGE_QUEUE_MAX MESSAGE_SIZE_MAX / totem_config->net_mtu
  47. #endif /* HAVE_SMALL_MEMORY_FOOTPRINT */
  48. #define FRAME_SIZE_MAX 10000
  49. #define TRANSMITS_ALLOWED 16
  50. #define SEND_THREADS_MAX 16
  51. #define INTERFACE_MAX 2
  52. struct totem_interface {
  53. struct totem_ip_address bindnet;
  54. struct totem_ip_address boundto;
  55. struct totem_ip_address mcast_addr;
  56. uint16_t ip_port;
  57. int member_count;
  58. struct totem_ip_address member_list[PROCESSOR_COUNT_MAX];
  59. };
  60. struct totem_logging_configuration {
  61. void (*log_printf) (
  62. unsigned int rec_ident,
  63. const char *function_name,
  64. const char *file_name,
  65. int file_line,
  66. const char *format,
  67. ...) __attribute__((format(printf, 5, 6)));
  68. int log_level_security;
  69. int log_level_error;
  70. int log_level_warning;
  71. int log_level_notice;
  72. int log_level_debug;
  73. int log_subsys_id;
  74. };
  75. enum { TOTEM_PRIVATE_KEY_LEN = 128 };
  76. enum { TOTEM_RRP_MODE_BYTES = 64 };
  77. typedef enum {
  78. TOTEM_TRANSPORT_UDP = 0,
  79. TOTEM_TRANSPORT_UDPU = 1,
  80. TOTEM_TRANSPORT_RDMA = 2
  81. } totem_transport_t;
  82. struct totem_config {
  83. int version;
  84. /*
  85. * network
  86. */
  87. struct totem_interface *interfaces;
  88. unsigned int interface_count;
  89. unsigned int node_id;
  90. unsigned int clear_node_high_bit;
  91. /*
  92. * key information
  93. */
  94. unsigned char private_key[TOTEM_PRIVATE_KEY_LEN];
  95. unsigned int private_key_len;
  96. /*
  97. * Totem configuration parameters
  98. */
  99. unsigned int token_timeout;
  100. unsigned int token_retransmit_timeout;
  101. unsigned int token_hold_timeout;
  102. unsigned int token_retransmits_before_loss_const;
  103. unsigned int join_timeout;
  104. unsigned int send_join_timeout;
  105. unsigned int consensus_timeout;
  106. unsigned int merge_timeout;
  107. unsigned int downcheck_timeout;
  108. unsigned int fail_to_recv_const;
  109. unsigned int seqno_unchanged_const;
  110. unsigned int rrp_token_expired_timeout;
  111. unsigned int rrp_problem_count_timeout;
  112. unsigned int rrp_problem_count_threshold;
  113. char rrp_mode[TOTEM_RRP_MODE_BYTES];
  114. struct totem_logging_configuration totem_logging_configuration;
  115. void (*log_rec) (
  116. int subsysid,
  117. const char *function_name,
  118. const char *file_name,
  119. int file_line,
  120. unsigned int rec_ident,
  121. ...);
  122. unsigned int secauth;
  123. unsigned int net_mtu;
  124. unsigned int threads;
  125. unsigned int heartbeat_failures_allowed;
  126. unsigned int max_network_delay;
  127. unsigned int window_size;
  128. unsigned int max_messages;
  129. const char *vsf_type;
  130. unsigned int broadcast_use;
  131. enum { TOTEM_CRYPTO_SOBER=0, TOTEM_CRYPTO_NSS } crypto_type;
  132. enum { TOTEM_CRYPTO_ACCEPT_OLD=0, TOTEM_CRYPTO_ACCEPT_NEW } crypto_accept;
  133. int crypto_crypt_type;
  134. int crypto_sign_type;
  135. totem_transport_t transport_number;
  136. unsigned int miss_count_const;
  137. };
  138. #define TOTEM_CONFIGURATION_TYPE
  139. enum totem_configuration_type {
  140. TOTEM_CONFIGURATION_REGULAR,
  141. TOTEM_CONFIGURATION_TRANSITIONAL
  142. };
  143. #define TOTEM_CALLBACK_TOKEN_TYPE
  144. enum totem_callback_token_type {
  145. TOTEM_CALLBACK_TOKEN_RECEIVED = 1,
  146. TOTEM_CALLBACK_TOKEN_SENT = 2
  147. };
  148. enum totem_event_type {
  149. TOTEM_EVENT_DELIVERY_CONGESTED,
  150. TOTEM_EVENT_NEW_MSG,
  151. };
  152. #define MEMB_RING_ID
  153. struct memb_ring_id {
  154. struct totem_ip_address rep;
  155. unsigned long long seq;
  156. } __attribute__((packed));
  157. typedef struct {
  158. hdb_handle_t handle;
  159. int is_dirty;
  160. time_t last_updated;
  161. } totem_stats_header_t;
  162. typedef struct {
  163. totem_stats_header_t hdr;
  164. uint32_t iface_changes;
  165. } totemnet_stats_t;
  166. typedef struct {
  167. totem_stats_header_t hdr;
  168. totemnet_stats_t *net;
  169. char *algo_name;
  170. } totemrrp_stats_t;
  171. typedef struct {
  172. uint32_t rx;
  173. uint32_t tx;
  174. int backlog_calc;
  175. } totemsrp_token_stats_t;
  176. typedef struct {
  177. totem_stats_header_t hdr;
  178. totemrrp_stats_t *rrp;
  179. uint64_t orf_token_tx;
  180. uint64_t orf_token_rx;
  181. uint64_t memb_merge_detect_tx;
  182. uint64_t memb_merge_detect_rx;
  183. uint64_t memb_join_tx;
  184. uint64_t memb_join_rx;
  185. uint64_t mcast_tx;
  186. uint64_t mcast_retx;
  187. uint64_t mcast_rx;
  188. uint64_t memb_commit_token_tx;
  189. uint64_t memb_commit_token_rx;
  190. uint64_t token_hold_cancel_tx;
  191. uint64_t token_hold_cancel_rx;
  192. uint64_t operational_entered;
  193. uint64_t operational_token_lost;
  194. uint64_t gather_entered;
  195. uint64_t gather_token_lost;
  196. uint64_t commit_entered;
  197. uint64_t commit_token_lost;
  198. uint64_t recovery_entered;
  199. uint64_t recovery_token_lost;
  200. uint64_t consensus_timeouts;
  201. uint64_t rx_msg_dropped;
  202. int earliest_token;
  203. int latest_token;
  204. #define TOTEM_TOKEN_STATS_MAX 100
  205. totemsrp_token_stats_t token[TOTEM_TOKEN_STATS_MAX];
  206. } totemsrp_stats_t;
  207. #define TOTEM_CONFIGURATION_TYPE
  208. typedef struct {
  209. totem_stats_header_t hdr;
  210. totemsrp_stats_t *srp;
  211. } totemmrp_stats_t;
  212. typedef struct {
  213. totem_stats_header_t hdr;
  214. totemmrp_stats_t *mrp;
  215. } totempg_stats_t;
  216. #endif /* TOTEM_H_DEFINED */