totem.h 6.6 KB

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