ipc_votequorum.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * Copyright (c) 2009-2012 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Authors: Christine Caulfield (ccaulfie@redhat.com)
  7. * Fabio M. Di Nitto (fdinitto@redhat.com)
  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 CONTIBUTORS "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 IPC_VOTEQUORUM_H_DEFINED
  36. #define IPC_VOTEQUORUM_H_DEFINED
  37. #include <corosync/mar_gen.h>
  38. #define VOTEQUORUM_QDEVICE_NODEID 0
  39. #define VOTEQUORUM_QDEVICE_MAX_NAME_LEN 255
  40. #define VOTEQUORUM_QDEVICE_DEFAULT_TIMEOUT 10000
  41. /**
  42. * @brief The req_votequorum_types enum
  43. */
  44. enum req_votequorum_types {
  45. MESSAGE_REQ_VOTEQUORUM_GETINFO = 0,
  46. MESSAGE_REQ_VOTEQUORUM_SETEXPECTED,
  47. MESSAGE_REQ_VOTEQUORUM_SETVOTES,
  48. MESSAGE_REQ_VOTEQUORUM_TRACKSTART,
  49. MESSAGE_REQ_VOTEQUORUM_TRACKSTOP,
  50. MESSAGE_REQ_VOTEQUORUM_QDEVICE_REGISTER,
  51. MESSAGE_REQ_VOTEQUORUM_QDEVICE_UNREGISTER,
  52. MESSAGE_REQ_VOTEQUORUM_QDEVICE_UPDATE,
  53. MESSAGE_REQ_VOTEQUORUM_QDEVICE_POLL,
  54. MESSAGE_REQ_VOTEQUORUM_QDEVICE_MASTER_WINS
  55. };
  56. /**
  57. * @brief The res_votequorum_types enum
  58. */
  59. enum res_votequorum_types {
  60. MESSAGE_RES_VOTEQUORUM_STATUS = 0,
  61. MESSAGE_RES_VOTEQUORUM_GETINFO,
  62. MESSAGE_RES_VOTEQUORUM_TRACKSTART,
  63. MESSAGE_RES_VOTEQUORUM_QUORUM_NOTIFICATION,
  64. MESSAGE_RES_VOTEQUORUM_EXPECTEDVOTES_NOTIFICATION,
  65. MESSAGE_RES_VOTEQUORUM_NODELIST_NOTIFICATION,
  66. };
  67. /**
  68. * @brief The mar_votequorum_ring_id struct
  69. */
  70. struct mar_votequorum_ring_id {
  71. mar_uint32_t nodeid;
  72. mar_uint64_t seq;
  73. };
  74. /**
  75. * @brief The req_lib_votequorum_qdevice_register struct
  76. */
  77. struct req_lib_votequorum_qdevice_register {
  78. struct qb_ipc_request_header header __attribute__((aligned(8)));
  79. char name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN];
  80. };
  81. /**
  82. * @brief The req_lib_votequorum_qdevice_unregister struct
  83. */
  84. struct req_lib_votequorum_qdevice_unregister {
  85. struct qb_ipc_request_header header __attribute__((aligned(8)));
  86. char name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN];
  87. };
  88. /**
  89. * @brief The req_lib_votequorum_qdevice_update struct
  90. */
  91. struct req_lib_votequorum_qdevice_update {
  92. struct qb_ipc_request_header header __attribute__((aligned(8)));
  93. char oldname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN];
  94. char newname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN];
  95. };
  96. /**
  97. * @brief The req_lib_votequorum_qdevice_poll struct
  98. */
  99. struct req_lib_votequorum_qdevice_poll {
  100. struct qb_ipc_request_header header __attribute__((aligned(8)));
  101. char name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN];
  102. int cast_vote;
  103. struct mar_votequorum_ring_id ring_id __attribute__((aligned(8)));
  104. };
  105. /**
  106. * @brief The req_lib_votequorum_qdevice_master_wins struct
  107. */
  108. struct req_lib_votequorum_qdevice_master_wins {
  109. struct qb_ipc_request_header header __attribute__((aligned(8)));
  110. char name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN];
  111. unsigned int allow;
  112. };
  113. /**
  114. * @brief The req_lib_votequorum_setvotes struct
  115. */
  116. struct req_lib_votequorum_setvotes {
  117. struct qb_ipc_request_header header __attribute__((aligned(8)));
  118. unsigned int votes;
  119. int nodeid;
  120. };
  121. /**
  122. * @brief The req_lib_votequorum_setexpected struct
  123. */
  124. struct req_lib_votequorum_setexpected {
  125. struct qb_ipc_request_header header __attribute__((aligned(8)));
  126. unsigned int expected_votes;
  127. };
  128. /**
  129. * @brief The req_lib_votequorum_trackstart struct
  130. */
  131. struct req_lib_votequorum_trackstart {
  132. struct qb_ipc_request_header header __attribute__((aligned(8)));
  133. uint64_t context;
  134. unsigned int track_flags;
  135. };
  136. /**
  137. * @brief The req_lib_votequorum_general struct
  138. */
  139. struct req_lib_votequorum_general {
  140. struct qb_ipc_request_header header __attribute__((aligned(8)));
  141. };
  142. /**
  143. * @brief The req_lib_votequorum_getinfo struct
  144. */
  145. struct req_lib_votequorum_getinfo {
  146. struct qb_ipc_request_header header __attribute__((aligned(8)));
  147. int nodeid;
  148. };
  149. /**
  150. * @brief The res_lib_votequorum_status struct
  151. */
  152. struct res_lib_votequorum_status {
  153. struct qb_ipc_response_header header __attribute__((aligned(8)));
  154. };
  155. #define VOTEQUORUM_INFO_TWONODE 1
  156. #define VOTEQUORUM_INFO_QUORATE 2
  157. #define VOTEQUORUM_INFO_WAIT_FOR_ALL 4
  158. #define VOTEQUORUM_INFO_LAST_MAN_STANDING 8
  159. #define VOTEQUORUM_INFO_AUTO_TIE_BREAKER 16
  160. #define VOTEQUORUM_INFO_ALLOW_DOWNSCALE 32
  161. #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64
  162. #define VOTEQUORUM_INFO_QDEVICE_ALIVE 128
  163. #define VOTEQUORUM_INFO_QDEVICE_CAST_VOTE 256
  164. #define VOTEQUORUM_INFO_QDEVICE_MASTER_WINS 512
  165. #define VOTEQUORUM_NODESTATE_MEMBER 1
  166. #define VOTEQUORUM_NODESTATE_DEAD 2
  167. #define VOTEQUORUM_NODESTATE_LEAVING 3
  168. /**
  169. * @brief The res_lib_votequorum_getinfo struct
  170. */
  171. struct res_lib_votequorum_getinfo {
  172. struct qb_ipc_response_header header __attribute__((aligned(8)));
  173. unsigned int nodeid;
  174. unsigned int state;
  175. unsigned int votes;
  176. unsigned int expected_votes;
  177. unsigned int highest_expected;
  178. unsigned int total_votes;
  179. unsigned int quorum;
  180. unsigned int flags;
  181. unsigned int qdevice_votes;
  182. char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN];
  183. };
  184. /**
  185. * @brief The votequorum_node struct
  186. */
  187. struct votequorum_node {
  188. mar_uint32_t nodeid;
  189. mar_uint32_t state;
  190. };
  191. /**
  192. * @brief The res_lib_votequorum_quorum_notification struct
  193. */
  194. struct res_lib_votequorum_quorum_notification {
  195. struct qb_ipc_response_header header __attribute__((aligned(8)));
  196. mar_uint32_t quorate __attribute__((aligned(8)));
  197. mar_uint64_t context __attribute__((aligned(8)));
  198. mar_uint32_t node_list_entries __attribute__((aligned(8)));
  199. struct votequorum_node node_list[] __attribute__((aligned(8)));
  200. };
  201. struct res_lib_votequorum_nodelist_notification {
  202. struct qb_ipc_response_header header __attribute__((aligned(8)));
  203. mar_uint64_t context __attribute__((aligned(8)));
  204. struct mar_votequorum_ring_id ring_id __attribute__((aligned(8)));
  205. mar_uint32_t node_list_entries __attribute__((aligned(8)));
  206. mar_uint32_t node_list[] __attribute__((aligned(8)));
  207. };
  208. /**
  209. * @brief The res_lib_votequorum_expectedvotes_notification struct
  210. */
  211. struct res_lib_votequorum_expectedvotes_notification {
  212. struct qb_ipc_response_header header __attribute__((aligned(8)));
  213. mar_uint64_t context __attribute__((aligned(8)));
  214. mar_uint32_t expected_votes __attribute__((aligned(8)));
  215. };
  216. /**
  217. * @brief marshall_from_mar_votequorum_ring_id
  218. * @param dest
  219. * @param src
  220. */
  221. static inline void marshall_from_mar_votequorum_ring_id (
  222. votequorum_ring_id_t *dest,
  223. const struct mar_votequorum_ring_id *src)
  224. {
  225. dest->nodeid = src->nodeid;
  226. dest->seq = src->seq;
  227. };
  228. /**
  229. * @brief marshall_to_mar_votequorum_ring_id
  230. * @param dest
  231. * @param src
  232. */
  233. static inline void marshall_to_mar_votequorum_ring_id (
  234. struct mar_votequorum_ring_id *dest,
  235. const votequorum_ring_id_t *src)
  236. {
  237. dest->nodeid = src->nodeid;
  238. dest->seq = src->seq;
  239. };
  240. #endif