Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

494 lines
17 KiB

  1. #ifndef _WRGPOS_H_
  2. #define _WRGPOS_H_
  3. #ifdef __TANDEM
  4. #pragma columns 79
  5. #pragma page "wrgpos.h - T9050 - OS-dependent external decs for Regroup Module"
  6. #endif
  7. /* @@@ START COPYRIGHT @@@
  8. ** Tandem Confidential: Need to Know only
  9. ** Copyright (c) 1995, Tandem Computers Incorporated
  10. ** Protected as an unpublished work.
  11. ** All Rights Reserved.
  12. **
  13. ** The computer program listings, specifications, and documentation
  14. ** herein are the property of Tandem Computers Incorporated and shall
  15. ** not be reproduced, copied, disclosed, or used in whole or in part
  16. ** for any reason without the prior express written permission of
  17. ** Tandem Computers Incorporated.
  18. **
  19. ** @@@ END COPYRIGHT @@@
  20. **/
  21. /*---------------------------------------------------------------------------
  22. * This file (wrgpos.h) contains OS-specific declarations used by
  23. * srgpos.c.
  24. *---------------------------------------------------------------------------*/
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif /* __cplusplus */
  28. /*-----------------------------------NSK section-----------------------------*/
  29. #ifdef NSK
  30. #include <dmilli.h>
  31. #include <jmsgtrc.h>
  32. #define QUEUESEND _send_queued_()
  33. /* Regroup tracing macro */
  34. /* In NSK, regroup uses the trace buffer and macro provided by the
  35. * message system. Regroup puts TR_NODATA for the trace type.
  36. */
  37. #define RGP_TRACE( str, parm1, parm2, parm3, parm4 ) \
  38. TRACE_L1 ( str, TR_NODATA, parm1, parm2, parm3, parm4 )
  39. /* Regroup counters */
  40. /* In NSK, regroup uses the counter buffer and macro provided by the
  41. * message system.
  42. */
  43. #define RGP_INCREMENT_COUNTER TCount
  44. /* Macros to lock and unlock the regroup data structure to prevent
  45. * access by interrupt handlers or other processors (in SMP nodes).
  46. */
  47. /* On NSK with uniprocessor nodes, these macros must mask off the
  48. * interrupt handlers that can access the regroup structure, namely,
  49. * the IPC and timer interrupts.
  50. *
  51. * To avoid complexities due to nesting of MUTEXes, the regroup locks
  52. * are defined to be no-ops. The NSK caller of all regroup routines
  53. * (except the inquiry routines rgp_estimate_memory, rgp_sequence_number
  54. * and rgp_is_perturbed) must ensure that IPC and timer interrupts are
  55. * disabled before calling the regroup routine.
  56. */
  57. #define RGP_LOCK /* null; NSK must ensure that timer and IPC interrupts
  58. are disabled before calling regroup routines. */
  59. #define RGP_UNLOCK /* null; NSK must ensure that timer and IPC interrupts
  60. are disabled before calling regroup routines. */
  61. #ifdef __TANDEM
  62. #pragma fieldalign shared8 OS_specific_rgp_control
  63. #endif /* __TANDEM */
  64. typedef struct OS_specific_rgp_control
  65. {
  66. uint32 filler; /* no special fields needed for NSK */
  67. } OS_specific_rgp_control_t;
  68. #endif /* NSK */
  69. /*-----------------------------end of NSK section----------------------------*/
  70. /*-----------------------------------LCU section-----------------------------*/
  71. #ifdef LCU
  72. #include <lcuxprt.h>
  73. #define LCU_RGP_PORT 0 /* pick up from appropriate file */
  74. #define HZ 100 /* pick up from appropriate file */
  75. #define plstr 0 /* pick up from appropriate file */
  76. #define TO_PERIODIC 0 /* pick up from appropriate file */
  77. #define CE_PANIC 3 /* pick up from appropriate file */
  78. #define LCU_RGP_FLAGS (LCUF_SENDMSG || LCUF_NOSLEEP) /* msg alloc flags */
  79. extern void rgp_msgsys_work(lcumsg_t *lcumsgp, int status);
  80. #define QUEUESEND rgp_msgsys_work(NULL, 0)
  81. /* Regroup tracing macro */
  82. #define RGP_TRACE( str, parm1, parm2, parm3, parm4 ) /* empty for now */
  83. /* Regroup counters */
  84. typedef struct
  85. {
  86. uint32 QueuedIAmAlive;
  87. uint32 RcvdLocalIAmAlive;
  88. uint32 RcvdRemoteIAmAlive;
  89. uint32 RcvdRegroup;
  90. } rgp_counter_t;
  91. #define RGP_INCREMENT_COUNTER( field ) rgp->OS_specific_control.counter.field++
  92. /* Regroup locks */
  93. typedef struct rgp_lock
  94. {
  95. uint32 var1;
  96. uint32 var2;
  97. } rgp_lock_t;
  98. /* Macros to lock and unlock the regroup data structure to prevent
  99. * access by interrupt handlers or other processors (in SMP nodes)
  100. */
  101. #define RGP_LOCK /* null for now; need to be filled in */
  102. #define RGP_UNLOCK /* null for now; need to be filled in */
  103. typedef struct
  104. {
  105. rgp_lock_t rgp_lock; /* to serialize access */
  106. rgp_counter_t counter; /* to count events */
  107. lcumsg_t *lcumsg_regroup_p; /* pointer to regroup status message */
  108. lcumsg_t *lcumsg_iamalive_p; /* pointer to iamalive message */
  109. lcumsg_t *lcumsg_poison_p; /* pointer to poison message */
  110. sysnum_t my_sysnum; /* local system number */
  111. } OS_specific_rgp_control_t;
  112. #endif /* LCU */
  113. /*-----------------------------end of LCU section----------------------------*/
  114. /*----------------------------------UNIX section-----------------------------*/
  115. #ifdef UNIX
  116. extern void rgp_msgsys_work(void);
  117. #define QUEUESEND rgp_msgsys_work();
  118. #include <jrgp.h>
  119. #include <wrgp.h>
  120. #include <stdlib.h>
  121. #include <unistd.h>
  122. #include <signal.h>
  123. #include <sys/types.h>
  124. #include <sys/socket.h>
  125. #include <netinet/in.h>
  126. #include <netdb.h>
  127. #include <errno.h>
  128. #include <stdio.h>
  129. extern int errno;
  130. #define MSG_FLAGS 0 /* flags for message send/receive */
  131. #define RGP_PORT_BASE 5757 /* for use with sockets */
  132. typedef struct
  133. {
  134. int event;
  135. union
  136. {
  137. node_t node;
  138. rgpinfo_t rgpinfo;
  139. } data; /* depends on the event */
  140. rgp_unseq_pkt_t unseq_pkt;
  141. } rgp_msgbuf;
  142. #define BUFLEN sizeof(rgp_msgbuf)
  143. /* Additional events created for testing regroup using process-level
  144. * simulation.
  145. */
  146. #define RGP_EVT_START 10
  147. #define RGP_EVT_ADD_NODE 11
  148. #define RGP_EVT_MONITOR_NODE 12
  149. #define RGP_EVT_REMOVE_NODE 13
  150. #define RGP_EVT_GETRGPINFO 14
  151. #define RGP_EVT_SETRGPINFO 15
  152. #define RGP_EVT_HALT 16
  153. #define RGP_EVT_FREEZE 17
  154. #define RGP_EVT_THAW 18
  155. #define RGP_EVT_STOP_SENDING 19
  156. #define RGP_EVT_RESUME_SENDING 20
  157. #define RGP_EVT_STOP_RECEIVING 21
  158. #define RGP_EVT_RESUME_RECEIVING 22
  159. #define RGP_EVT_SEND_POISON 23
  160. #define RGP_EVT_STOP_TIMER_POPS 24
  161. #define RGP_EVT_RESUME_TIMER_POPS 25
  162. #define RGP_EVT_RELOAD 26
  163. #define RGP_EVT_FIRST_EVENT 1
  164. #define RGP_EVT_FIRST_DEBUG_EVENT 10
  165. #define RGP_EVT_LAST_EVENT 26
  166. /* Regroup tracing macro */
  167. #define RGP_TRACE( str, parm1, parm2, parm3, parm4 ) \
  168. do \
  169. { \
  170. printf("Node %3d: %16s: 0x%8X, 0x%8X, 0x%8X, 0x%8X.\n", \
  171. EXT_NODE(rgp->mynode), str, parm1, parm2, parm3, parm4); \
  172. fflush(stdout); \
  173. } while (0)
  174. /* Regroup counters */
  175. typedef struct
  176. {
  177. uint32 QueuedIAmAlive;
  178. uint32 RcvdLocalIAmAlive;
  179. uint32 RcvdRemoteIAmAlive;
  180. uint32 RcvdRegroup;
  181. } rgp_counter_t;
  182. #define RGP_INCREMENT_COUNTER( field ) rgp->OS_specific_control.counter.field++
  183. /* Macros to lock and unlock the regroup data structure to prevent
  184. * access by interrupt handlers or other processors (in SMP nodes)
  185. */
  186. #define RGP_LOCK /* null; all access done from one thread */
  187. #define RGP_UNLOCK /* null; all access done from one thread */
  188. /* This struct keeps some debugging info. */
  189. typedef struct rgpdebug
  190. {
  191. uint32 frozen : 1; /* node is frozen; ignore all events except
  192. the thaw command */
  193. uint32 reload_in_progress : 1; /* reload in progess; if set, refuse
  194. new reload command */
  195. uint32 unused : 30;
  196. cluster_t stop_sending; /* stop sending to these nodes */
  197. cluster_t stop_receiving; /* stop receiving from these nodes */
  198. } rgp_debug_t;
  199. typedef struct
  200. {
  201. rgp_counter_t counter; /* to count events */
  202. rgp_debug_t debug; /* for debugging purposes */
  203. } OS_specific_rgp_control_t;
  204. /* Variables and routines provided by the srgpsvr.c driver program */
  205. extern unsigned int alarm_period;
  206. extern void alarm_handler(void);
  207. extern void (*alarm_callback)();
  208. extern void rgp_send(node_t node, void *data, int datasize);
  209. extern void rgp_msgsys_work();
  210. #endif /* UNIX */
  211. /*----------------------------end of UNIX section----------------------------*/
  212. /*----------------------------------NT section-----------------------------*/
  213. #ifdef NT
  214. extern void rgp_msgsys_work(void);
  215. #define QUEUESEND rgp_msgsys_work();
  216. #if !defined (TDM_DEBUG)
  217. #define LOG_CURRENT_MODULE LOG_MODULE_MM
  218. #include <service.h>
  219. #include <winsock2.h>
  220. #else //TDM_DEBUG
  221. #define _WIN32_WINNT 0x0400
  222. #include <mmapi.h>
  223. #include <time.h>
  224. extern int errno;
  225. #endif
  226. #include <jrgp.h>
  227. #include <wrgp.h>
  228. #include <stdlib.h>
  229. #include <sys/types.h>
  230. #include <errno.h>
  231. #include <stdio.h>
  232. #include <windows.h>
  233. #include <clmsg.h>
  234. #undef small // otherwise we have to change a bunch of our code
  235. typedef struct
  236. {
  237. int event;
  238. union
  239. {
  240. node_t node;
  241. rgpinfo_t rgpinfo;
  242. } data; /* depends on the event */
  243. rgp_unseq_pkt_t unseq_pkt;
  244. } rgp_msgbuf;
  245. #define BUFLEN sizeof(rgp_msgbuf)
  246. /* Additional events created for testing regroup using process-level
  247. * simulation.
  248. */
  249. #define RGP_EVT_START 10
  250. #define RGP_EVT_ADD_NODE 11
  251. #define RGP_EVT_MONITOR_NODE 12
  252. #define RGP_EVT_REMOVE_NODE 13
  253. #define RGP_EVT_GETRGPINFO 14
  254. #define RGP_EVT_SETRGPINFO 15
  255. #define RGP_EVT_HALT 16
  256. #define RGP_EVT_FREEZE 17
  257. #define RGP_EVT_THAW 18
  258. #define RGP_EVT_STOP_SENDING 19
  259. #define RGP_EVT_RESUME_SENDING 20
  260. #define RGP_EVT_STOP_RECEIVING 21
  261. #define RGP_EVT_RESUME_RECEIVING 22
  262. #define RGP_EVT_SEND_POISON 23
  263. #define RGP_EVT_STOP_TIMER_POPS 24
  264. #define RGP_EVT_RESUME_TIMER_POPS 25
  265. #define RGP_EVT_RELOAD 26
  266. #define RGP_EVT_TRACING 27
  267. #define RGP_EVT_INFO 28
  268. // MM events
  269. #define MM_EVT_EJECT 29
  270. #define MM_EVT_LEAVE 30
  271. #define MM_EVT_INSERT_TESTPOINTS 31
  272. #define RGP_EVT_FIRST_EVENT 1
  273. #define RGP_EVT_FIRST_DEBUG_EVENT 10
  274. #define RGP_EVT_LAST_EVENT 31
  275. /* internal timeout for acknowledged messages */
  276. #define RGP_ACKMSG_TIMEOUT 500 // 0.5 seconds
  277. /* Regroup tracing macro */
  278. #if defined (TDM_DEBUG)
  279. #define RGP_TRACE( str, parm1, parm2, parm3, parm4 ) \
  280. if ( rgp->OS_specific_control.debug.doing_tracing ) \
  281. do \
  282. { \
  283. printf("Node %3d: %16hs: 0x%8X, 0x%8X, 0x%8X, 0x%8X.\n", \
  284. EXT_NODE(rgp->mynode), str, parm1, parm2, parm3, parm4); \
  285. fflush(stdout); \
  286. } while (0)
  287. #else // WOLFPACK
  288. #define RGP_TRACE( str, parm1, parm2, parm3, parm4 ) \
  289. ClRtlLogPrint(LOG_NOISE, \
  290. "[RGP] Node %1!d!: %2!16hs!: 0x%3!x!, 0x%4!x!, 0x%5!x!, 0x%6!x!.\n", \
  291. EXT_NODE(rgp->mynode), str, parm1, parm2, parm3, parm4)
  292. #endif
  293. /* Regroup counters */
  294. typedef struct
  295. {
  296. uint32 QueuedIAmAlive;
  297. uint32 RcvdLocalIAmAlive;
  298. uint32 RcvdRemoteIAmAlive;
  299. uint32 RcvdRegroup;
  300. } rgp_counter_t;
  301. #define RGP_INCREMENT_COUNTER( field ) rgp->OS_specific_control.counter.field++
  302. /* Macros to lock and unlock the regroup data structure to prevent
  303. * access from other concurrent threads.
  304. */
  305. #define RGP_LOCK EnterCriticalSection( &rgp->OS_specific_control.RgpCriticalSection );
  306. #define RGP_UNLOCK LeaveCriticalSection( &rgp->OS_specific_control.RgpCriticalSection );
  307. #if defined(TDM_DEBUG)
  308. typedef union {
  309. struct {
  310. uint32 joinfailADD : 1;
  311. uint32 joinfailMON : 1;
  312. uint32 description3 : 1;
  313. uint32 description4 : 1;
  314. uint32 description5 : 1;
  315. uint32 description6 : 1;
  316. uint32 description7 : 1;
  317. uint32 description8 : 1;
  318. uint32 description9 : 1;
  319. uint32 description10 : 1;
  320. uint32 description11 : 1;
  321. uint32 description12 : 1;
  322. uint32 description13 : 1;
  323. uint32 description14 : 1;
  324. uint32 description15 : 1;
  325. uint32 description16 : 1;
  326. uint32 morebits : 16;
  327. } TestPointBits;
  328. uint32 TestPointWord;
  329. }TestPointInfo;
  330. /* This struct keeps some debugging info. */
  331. typedef struct rgpdebug
  332. {
  333. uint32 frozen : 1; /* node is frozen; ignore all events except
  334. the thaw command */
  335. uint32 reload_in_progress : 1; /* reload in progess; if set, refuse
  336. new reload command */
  337. uint32 timer_frozen : 1; /* timer pops are ignored */
  338. uint32 doing_tracing : 1; /* whether or not RGP_TRACE is a nop */
  339. uint32 unused : 28;
  340. cluster_t stop_sending; /* stop sending to these nodes */
  341. cluster_t stop_receiving; /* stop receiving from these nodes */
  342. TestPointInfo MyTestPoints; /* Controls test points for error/other insertion */
  343. } rgp_debug_t;
  344. #endif // TDM_DEBUG
  345. typedef struct
  346. {
  347. rgp_counter_t counter; /* to count events */
  348. HANDLE TimerThread; /* HANDLE of HeartBeat timer thread */
  349. DWORD TimerThreadId;/* Thread ID of HeartBeat timer thread */
  350. HANDLE TimerSignal; /* Event used to change HB rate and cause Terminate */
  351. HANDLE RGPTimer; /* Regroup Timer - Used by timer thread */
  352. CRITICAL_SECTION RgpCriticalSection; /* CriticalSection object for regroup activities */
  353. ULONG EventEpoch; /* used to detect stale events from clusnet */
  354. MMNodeChange UpDownCallback; /*Callback to announce node up and node down event*/
  355. MMQuorumSelect QuorumCallback; /*Callback to check if Quorum disk accessible - split brain avoidance */
  356. MMHoldAllIO HoldIOCallback; /*Callback to suspend all IO and message activity during early regroup */
  357. MMResumeAllIO ResumeIOCallback; /*Callback to resume all IO and message activity after PRUNING stage */
  358. MMMsgCleanup1 MsgCleanup1Callback; /*Callback for Phase1 Message system cleanup from down node */
  359. MMMsgCleanup2 MsgCleanup2Callback; /*Callback for Phase2 Message system cleanup to down node */
  360. MMHalt HaltCallback; /*Callback to announce internal error or Poison packet or cluster ejection */
  361. MMJoinFailed JoinFailedCallback; /*Callback to announce failure to join cluster. Retry required */
  362. MMNodesDown NodesDownCallback; /* Callback to announce failure of one or more nodes.*/
  363. cluster_t CPUUPMASK; /* Bitmask of UP Nodes for consistent Info api */
  364. cluster_t NeedsNodeDownCallback; /* node(s) went down, need to do UpDown callback */
  365. cluster_t Banished; /* mask of banished nodes */
  366. HANDLE Stabilized; /* event which is set when the regroup is not active */
  367. BOOL ArbitrationInProgress; /* it is set to True while regroup waits for arbitate callback to return */
  368. DWORD ArbitratingNode; /* MM_INVALID_NODE or the arbitrating node (last regroup)*/
  369. DWORD ApproxArbitrationWinner; /* Like ArbitratingNode, but spans multiple regroups */
  370. BOOL ShuttingDown; /* indicate that a node is shutting done */
  371. cluster_t MulticastReachable; /* indicate which nodes can be reachable via mcast */
  372. #if defined( TDM_DEBUG )
  373. rgp_debug_t debug; /* for debugging purposes */
  374. #endif
  375. } OS_specific_rgp_control_t;
  376. extern DWORD QuorumOwner; /* updated by SetQuorumOwner and successful arbitrator*/
  377. /* this variable can be set by the first node coming up before Mm is initialized */
  378. /* Variables and routines provided by the srgpsvr.c driver program */
  379. extern unsigned int alarm_period;
  380. //extern void alarm_handler(void);
  381. //extern void (*alarm_callback)();
  382. extern void rgp_send(node_t node, void *data, int datasize);
  383. extern void rgp_msgsys_work();
  384. #endif /* NT */
  385. /*----------------------------end of NT section----------------------------*/
  386. #ifdef __cplusplus
  387. }
  388. #endif /* __cplusplus */
  389. #if 0
  390. History of changes to this file:
  391. -------------------------------------------------------------------------
  392. 1995, December 13 F40:KSK0610 /*F40:KSK06102.1*/
  393. This file is part of the portable Regroup Module used in the NonStop
  394. Kernel (NSK) and Loosely Coupled UNIX (LCU) operating systems. There
  395. are 10 files in the module - jrgp.h, jrgpos.h, wrgp.h, wrgpos.h,
  396. srgpif.c, srgpos.c, srgpsm.c, srgputl.c, srgpcli.c and srgpsvr.c.
  397. The last two are simulation files to test the Regroup Module on a
  398. UNIX workstation in user mode with processes simulating processor nodes
  399. and UDP datagrams used to send unacknowledged datagrams.
  400. This file was first submitted for release into NSK on 12/13/95.
  401. ------------------------------------------------------------------------------
  402. #endif /* 0 - change descriptions */
  403. #endif /* _WRGPOS_H_ defined */
  404.