totem.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. /**
  53. * Maximum number of continuous gather states
  54. */
  55. #define MAX_NO_CONT_GATHER 3
  56. struct totem_interface {
  57. struct totem_ip_address bindnet;
  58. struct totem_ip_address boundto;
  59. struct totem_ip_address mcast_addr;
  60. uint16_t ip_port;
  61. uint16_t ttl;
  62. int member_count;
  63. struct totem_ip_address member_list[PROCESSOR_COUNT_MAX];
  64. };
  65. struct totem_logging_configuration {
  66. void (*log_printf) (
  67. int level,
  68. int subsys,
  69. const char *function_name,
  70. const char *file_name,
  71. int file_line,
  72. const char *format,
  73. ...) __attribute__((format(printf, 6, 7)));
  74. int log_level_security;
  75. int log_level_error;
  76. int log_level_warning;
  77. int log_level_notice;
  78. int log_level_debug;
  79. int log_subsys_id;
  80. };
  81. enum { TOTEM_PRIVATE_KEY_LEN = 128 };
  82. enum { TOTEM_RRP_MODE_BYTES = 64 };
  83. typedef enum {
  84. TOTEM_TRANSPORT_UDP = 0,
  85. TOTEM_TRANSPORT_UDPU = 1,
  86. TOTEM_TRANSPORT_RDMA = 2
  87. } totem_transport_t;
  88. struct totem_config {
  89. int version;
  90. /*
  91. * network
  92. */
  93. struct totem_interface *interfaces;
  94. unsigned int interface_count;
  95. unsigned int node_id;
  96. unsigned int clear_node_high_bit;
  97. /*
  98. * key information
  99. */
  100. unsigned char private_key[TOTEM_PRIVATE_KEY_LEN];
  101. unsigned int private_key_len;
  102. /*
  103. * Totem configuration parameters
  104. */
  105. unsigned int token_timeout;
  106. unsigned int token_retransmit_timeout;
  107. unsigned int token_hold_timeout;
  108. unsigned int token_retransmits_before_loss_const;
  109. unsigned int join_timeout;
  110. unsigned int send_join_timeout;
  111. unsigned int consensus_timeout;
  112. unsigned int merge_timeout;
  113. unsigned int downcheck_timeout;
  114. unsigned int fail_to_recv_const;
  115. unsigned int seqno_unchanged_const;
  116. unsigned int rrp_token_expired_timeout;
  117. unsigned int rrp_problem_count_timeout;
  118. unsigned int rrp_problem_count_threshold;
  119. unsigned int rrp_problem_count_mcast_threshold;
  120. unsigned int rrp_autorecovery_check_timeout;
  121. char rrp_mode[TOTEM_RRP_MODE_BYTES];
  122. struct totem_logging_configuration totem_logging_configuration;
  123. unsigned int secauth;
  124. unsigned int net_mtu;
  125. unsigned int threads;
  126. unsigned int heartbeat_failures_allowed;
  127. unsigned int max_network_delay;
  128. unsigned int window_size;
  129. unsigned int max_messages;
  130. const char *vsf_type;
  131. unsigned int broadcast_use;
  132. enum { TOTEM_CRYPTO_SOBER=0, TOTEM_CRYPTO_NSS } crypto_type;
  133. enum { TOTEM_CRYPTO_ACCEPT_OLD=0, TOTEM_CRYPTO_ACCEPT_NEW } crypto_accept;
  134. int crypto_crypt_type;
  135. int crypto_sign_type;
  136. totem_transport_t transport_number;
  137. unsigned int miss_count_const;
  138. };
  139. #define TOTEM_CONFIGURATION_TYPE
  140. enum totem_configuration_type {
  141. TOTEM_CONFIGURATION_REGULAR,
  142. TOTEM_CONFIGURATION_TRANSITIONAL
  143. };
  144. #define TOTEM_CALLBACK_TOKEN_TYPE
  145. enum totem_callback_token_type {
  146. TOTEM_CALLBACK_TOKEN_RECEIVED = 1,
  147. TOTEM_CALLBACK_TOKEN_SENT = 2
  148. };
  149. enum totem_event_type {
  150. TOTEM_EVENT_DELIVERY_CONGESTED,
  151. TOTEM_EVENT_NEW_MSG,
  152. };
  153. #define MEMB_RING_ID
  154. struct memb_ring_id {
  155. struct totem_ip_address rep;
  156. unsigned long long seq;
  157. } __attribute__((packed));
  158. typedef struct {
  159. hdb_handle_t handle;
  160. int is_dirty;
  161. time_t last_updated;
  162. } totem_stats_header_t;
  163. typedef struct {
  164. totem_stats_header_t hdr;
  165. uint32_t iface_changes;
  166. } totemnet_stats_t;
  167. typedef struct {
  168. totem_stats_header_t hdr;
  169. totemnet_stats_t *net;
  170. char *algo_name;
  171. } totemrrp_stats_t;
  172. typedef struct {
  173. uint32_t rx;
  174. uint32_t tx;
  175. int backlog_calc;
  176. } totemsrp_token_stats_t;
  177. typedef struct {
  178. totem_stats_header_t hdr;
  179. totemrrp_stats_t *rrp;
  180. uint64_t orf_token_tx;
  181. uint64_t orf_token_rx;
  182. uint64_t memb_merge_detect_tx;
  183. uint64_t memb_merge_detect_rx;
  184. uint64_t memb_join_tx;
  185. uint64_t memb_join_rx;
  186. uint64_t mcast_tx;
  187. uint64_t mcast_retx;
  188. uint64_t mcast_rx;
  189. uint64_t memb_commit_token_tx;
  190. uint64_t memb_commit_token_rx;
  191. uint64_t token_hold_cancel_tx;
  192. uint64_t token_hold_cancel_rx;
  193. uint64_t operational_entered;
  194. uint64_t operational_token_lost;
  195. uint64_t gather_entered;
  196. uint64_t gather_token_lost;
  197. uint64_t commit_entered;
  198. uint64_t commit_token_lost;
  199. uint64_t recovery_entered;
  200. uint64_t recovery_token_lost;
  201. uint64_t consensus_timeouts;
  202. uint64_t rx_msg_dropped;
  203. uint32_t continuous_gather;
  204. int earliest_token;
  205. int latest_token;
  206. #define TOTEM_TOKEN_STATS_MAX 100
  207. totemsrp_token_stats_t token[TOTEM_TOKEN_STATS_MAX];
  208. } totemsrp_stats_t;
  209. #define TOTEM_CONFIGURATION_TYPE
  210. typedef struct {
  211. totem_stats_header_t hdr;
  212. totemsrp_stats_t *srp;
  213. } totemmrp_stats_t;
  214. typedef struct {
  215. totem_stats_header_t hdr;
  216. totemmrp_stats_t *mrp;
  217. uint32_t msg_reserved;
  218. uint32_t msg_queue_avail;
  219. } totempg_stats_t;
  220. #endif /* TOTEM_H_DEFINED */