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.

438 lines
18 KiB

  1. #ifndef _JRGPOS_H_
  2. #define _JRGPOS_H_
  3. #ifdef __TANDEM
  4. #pragma columns 79
  5. #pragma page "jrgpos.h - T9050 - OS-specific declarations 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 (jrgpos.h) contains OS-specific declarations used by Regroup.
  23. * Use appropriate #includes to pull in declarations from other native
  24. * OS files.
  25. *---------------------------------------------------------------------------*/
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif /* __cplusplus */
  29. #ifdef NSK
  30. #include <jmsgtyp.h> /* to get "uint8", "uint16" and "uint32" */
  31. #include <dmem.h>
  32. #include <dcpuctl.h>
  33. #include <jmsglit.h>
  34. #define RGP_NULL_PTR NIL_ /* Null pointer for use by RGP */
  35. #define MAX_CLUSTER_SIZE MAX_CPUS /* max # of nodes supported in system */
  36. #define LOWEST_NODENUM ((node_t)0) /* starting node number */
  37. #define RGP_NULL_NODE ((node_t)-1) /* special node# for defaults */
  38. #define RGP_KEY_NODE RGP_NULL_NODE /* No node is special */
  39. #endif /* NSK */
  40. #if defined(LCU) || defined(UNIX) || defined(NT)
  41. typedef unsigned char uint8;
  42. typedef unsigned short uint16;
  43. typedef unsigned int uint32;
  44. #ifndef NULL
  45. #define NULL ((void *)0)
  46. #endif /* NULL */
  47. #define RGP_NULL_PTR NULL /* Null pointer for use by RGP */
  48. #if defined(LCU) || defined(UNIX)
  49. #define MAX_CLUSTER_SIZE 16 /* max # of nodes supported in system */
  50. #define LOWEST_NODENUM ((node_t)1) /* starting node number */
  51. #endif
  52. #if defined(NT)
  53. #include "service.h"
  54. #define MAX_CLUSTER_SIZE ClusterDefaultMaxNodes
  55. /* max # of nodes supported in system */
  56. #define LOWEST_NODENUM ((node_t)ClusterMinNodeId) /* starting node number */
  57. #endif
  58. #define RGP_NULL_NODE ((node_t)-1)
  59. /* special node# for defaults */
  60. #define RGP_KEY_NODE RGP_NULL_NODE /* No node is special */
  61. #define _priv /* used only by NSK compilers */
  62. #define _resident /* used only by NSK compilers */
  63. #endif /* LCU || UNIX || NT */
  64. /*---------------------------------------------------------------
  65. * Unacknowledged packet subtypes used by regroup.
  66. * These are made visible to the OS for reporting and counting
  67. * purposes only.
  68. *---------------------------------------------------------------*/
  69. /* Maximum payload of packets sent by Regroup is 56 bytes.
  70. * This allows a maximum transport overhead of 8 bytes in the
  71. * ServerNet interrupt packet which has a size of 64 bytes.
  72. */
  73. #define RGP_UNACK_PKTLEN 56 /*bytes*/
  74. typedef struct
  75. {
  76. uint8 pktsubtype;
  77. uint8 subtype_specific[RGP_UNACK_PKTLEN - sizeof(uint8)];
  78. } rgp_unseq_pkt_t;
  79. /* Regroup unacknowledged packet subtypes */
  80. #define RGP_UNACK_IAMALIVE (uint8) 1 /* I am alive packet */
  81. #define RGP_UNACK_REGROUP (uint8) 2 /* regroup status packet */
  82. #define RGP_UNACK_POISON (uint8) 3 /* poison packet */
  83. /*---------------------------------------------------------------*/
  84. /* Processor status codes returned by the Service Processor (SP) */
  85. /*---------------------------------------------------------------*/
  86. #define RGP_NODE_UNREACHABLE 0
  87. #define RGP_NODE_TIMED_OUT 1
  88. #define RGP_NODE_FROZEN 2
  89. #define RGP_NODE_HALTED 3
  90. #define RGP_NODE_OPERATIONAL 4
  91. /*----------------------*/
  92. /* Processor halt codes */
  93. /*----------------------*/
  94. #ifdef NSK
  95. #include <dhalt.h>
  96. #endif /* NSK */
  97. #if defined(LCU) || defined(UNIX) || defined(NT)
  98. #define RGP_RELOADFAILED 1
  99. #define RGP_INTERNAL_ERROR 2
  100. #define RGP_MISSED_POLL_TO_SELF 3
  101. #define RGP_AVOID_SPLIT_BRAIN 4
  102. #define RGP_PRUNED_OUT 5
  103. #define RGP_PARIAH 6
  104. #define RGP_PARIAH_FIRST RGP_PARIAH + LOWEST_NODENUM
  105. #define RGP_PARIAH_LAST RGP_PARIAH_FIRST + MAX_CLUSTER_SIZE - 1
  106. #define RGP_ARBITRATION_FAILED 1000
  107. #define RGP_ARBITRATION_STALLED 1001
  108. #define RGP_SHUTDOWN_DURING_RGP 1002 // Alias of MM_STOP_REQUESTED in mmapi.h
  109. #endif /* LCU || UNIX || NT */
  110. /*-------------------------------------------------------------------------
  111. * Timing parameters for Regroup. Of these, RGP_IAMALIVE_TICKS can be
  112. * overridden at run time using the rgp_getrgpinfo(), rgp_setrgpinfo()
  113. * routine pair. This is useful to slow node failure detection during
  114. * kernel debug sessions.
  115. *-------------------------------------------------------------------------*/
  116. #ifdef NSK
  117. #define RGP_CLOCK_PERIOD 30 /* period between regroup ticks,
  118. * in units of 10 milliseconds */
  119. #define RGP_PFAIL_TICKS 16 /* # of regroup ticks after a
  120. * power on event to forgive
  121. * missing self IamAlives */
  122. #endif /* NSK */
  123. #ifdef LCU
  124. #define RGP_CLOCK_PERIOD 30 /* period between regroup ticks,
  125. * in units of 10 milliseconds */
  126. #define RGP_PFAIL_TICKS 16 /* # of regroup ticks after a
  127. * power on event to forgive
  128. * missing self IamAlives */
  129. #endif /* LCU */
  130. #ifdef UNIX
  131. #define RGP_CLOCK_PERIOD 100 /* period between regroup ticks,
  132. * in units of 10 milliseconds */
  133. #define RGP_PFAIL_TICKS 16 /* # of regroup ticks after a
  134. * power on event to forgive
  135. * missing self IamAlives */
  136. #endif /* UNIX */
  137. #ifdef NT
  138. #define RGP_INACTIVE_PERIOD 60000 /* period between regroup ticks in ms when
  139. * node is inactive. 1 minute period */
  140. #define RGP_CLOCK_PERIOD 300 /* period between regroup ticks,
  141. * in units of milliseconds */
  142. #define RGP_PFAIL_TICKS 16 /* # of regroup ticks after a
  143. * power on event to forgive
  144. * missing self IamAlives */
  145. #endif /* NT */
  146. /* The following timing parameters can be overridden at run time by using
  147. * the rgp_getrgpinfo(), rgp_setrgpinfo() routine pair.
  148. */
  149. // Bug#328641
  150. //
  151. // Extend min_stage1 to approx 4 seconds to match NM values (check_ticks 2=>3)
  152. // Extend connectivity ticks to 3 to 9 ticks
  153. // adjust rgp_must_restart accordingly (20=>23) half conn_tick increase
  154. //
  155. #define RGP_IAMALIVE_TICKS 4 /* rgp clock ticks between IamAlives */
  156. #define RGP_CHECK_TICKS 3 /* rgp clock ticks before at least 1 ImAlive received */
  157. #define RGP_MIN_STAGE1_TICKS (RGP_IAMALIVE_TICKS * RGP_CHECK_TICKS)
  158. /* The following parameters can be made to be OS-dependent if needed.
  159. */
  160. #define RGP_MUST_ENTER_STAGE2 32 /* must enter stage2 after this many
  161. ticks, regardless of conditions */
  162. #define RGP_CONNECTIVITY_TICKS 9 /* max # of ticks to wait in stage 2
  163. to collect connectivity info */
  164. #define RGP_MUST_RESTART 23 /* stall detector tick count; if no
  165. progress after this many ticks,
  166. abort and restart regroup. */
  167. #define RGP_RESTART_MAX 3 /* maximum number of restarts
  168. allowed per regroup incident;
  169. if this is exceeded, the node
  170. halts. */
  171. /*--------------------------------------*/
  172. /* Definition of node and cluster types */
  173. /*--------------------------------------*/
  174. typedef short node_t;
  175. /* The cluster_t data type is a bit array with MAX_CLUSTER_SIZE
  176. * bits. It is implemented as an array of MAX_CLUSTER_SIZE/8
  177. * (rounded up) uint8s.
  178. */
  179. #define BYTEL 8 /* number of bits in a uint8 */
  180. #define BYTES_IN_CLUSTER ((MAX_CLUSTER_SIZE + BYTEL - 1) / BYTEL)
  181. typedef uint8 cluster_t [BYTES_IN_CLUSTER];
  182. /************************************************************************
  183. * rgp_msgsys_t (shared by regroup and message system)
  184. * ---------------------------------------------------
  185. * This structure is used by Regroup and the Message System to co-ordinate
  186. * actions that are to be done by the Message System on behalf of Regroup.
  187. * Regroup posts work requests in timer or IPC interrupt context and the
  188. * message system performs these at appropriate times (from the
  189. * dispatcher in NSK).
  190. *
  191. * ___________________________________________________________
  192. * wd0 | flags (bitfields) | regroup_nodes |
  193. * |_____________________________|_____________________________|
  194. * wd1 | iamalive_nodes | poison_nodes |
  195. * |_____________________________|_____________________________|
  196. * wd2 | *regroup_data |
  197. * |___________________________________________________________|
  198. * wd3 | *iamalive_data |
  199. * |___________________________________________________________|
  200. * wd4 | *poison_data |
  201. * |___________________________________________________________|
  202. * wd5 | regroup_datalen |
  203. * |___________________________________________________________|
  204. * wd6 | iamalive_datalen |
  205. * |___________________________________________________________|
  206. * wd7 | poison_datalen |
  207. * |___________________________________________________________|
  208. *
  209. *
  210. * flags:
  211. *
  212. * sendrgppkts - have regroup status packets to send
  213. * sendiamalives - have iamalive status packets to send
  214. * sendpoisons - have poison packets to send
  215. * phase1_cleanup - need to start phase1 cleanup due to node death
  216. * phase2_cleanup - need to start phase2 cleanup due to node death
  217. *
  218. * regroup_nodes - mask of nodes to send regroup pkts to
  219. * iamalive_nodes - mask of nodes to send iamalives to
  220. * poison_nodes - mask of nodes to send poison pkts to
  221. *
  222. * The following fields are used in NSK and the user-level UNIX
  223. * simulation only.
  224. *
  225. * regroup_data - address of regroup pkt data to send
  226. * iamalive_data - address of iamalive data to send
  227. * poison_data - address of poison pkt data to send
  228. *
  229. * regroup_datalen - length of regroup pkt data to send
  230. * iamalive_datalen - length of iamalive data to send
  231. * poison_datalen - length of poison pkt data to send
  232. *
  233. */
  234. #ifdef __TANDEM
  235. #pragma fieldalign shared8 rgp_msgsys
  236. #endif /* __TANDEM */
  237. typedef struct rgp_msgsys
  238. {
  239. uint16 sendrgppkts : 1;
  240. uint16 sendiamalives : 1;
  241. uint16 sendpoisons : 1;
  242. uint16 phase1_cleanup : 1;
  243. uint16 phase2_cleanup : 1;
  244. uint16 filler : 11;
  245. cluster_t regroup_nodes;
  246. cluster_t iamalive_nodes;
  247. cluster_t poison_nodes;
  248. #if defined(NSK) || defined(UNIX) || defined(NT)
  249. void *regroup_data;
  250. void *iamalive_data;
  251. void *poison_data;
  252. uint32 regroup_datalen;
  253. uint32 iamalive_datalen;
  254. uint32 poison_datalen;
  255. #endif /* NSK || UNIX || NT */
  256. } rgp_msgsys_t;
  257. typedef struct rgp_msgsys *rgp_msgsys_p;
  258. /*----------------------------------------------------------------------
  259. * OS-dependent routines used by Regroup.
  260. *
  261. * These are defined either in the regroup file srgpos.c or in other
  262. * modules in the OS.
  263. *----------------------------------------------------------------------*/
  264. _priv _resident extern void rgp_init_OS(void);
  265. _priv _resident extern void rgp_broadcast(uint8 packet_subtype);
  266. _priv _resident extern void rgp_node_failed(node_t node);
  267. _priv _resident extern void rgp_start_phase1_cleanup(void);
  268. _priv _resident extern void rgp_start_phase2_cleanup(void);
  269. _priv _resident extern void rgp_cleanup_complete(void);
  270. _priv _resident extern void rgp_had_power_failure(node_t node);
  271. _priv _resident extern int rgp_status_of_node(node_t node);
  272. _priv _resident extern void rgp_newnode_online(node_t newnode);
  273. _priv _resident extern int rgp_select_cluster(cluster_t cluster_choices[],
  274. int num_clusters);
  275. _priv _resident extern int rgp_select_cluster_ex(cluster_t cluster_choices[],
  276. int num_clusters, node_t keynode);
  277. _priv _resident extern void rgp_cleanup_OS(void);
  278. #ifdef NSK
  279. #include <tsrtnvl.h> /*F40:MB06452.1*/
  280. #include <tsdevdf.h> /*F40:MB06452.2*/
  281. #include <tsport.h> /*F40:MB06452.3*/
  282. #include <tsentry.h> /*F40:MB06452.4*/
  283. /*F40:MB06452.5*/
  284. #define rgp_hold_all_io TSER_TRANSFER_PAUSE_ /*F40:MB064514.1*/
  285. #define rgp_resume_all_io TSER_TRANSFER_CONTINUE_ /*F40:MB064514.2*/
  286. /*F40:MB06452.8*/
  287. #else
  288. _priv _resident extern void rgp_hold_all_io(void);
  289. _priv _resident extern void rgp_resume_all_io(void);
  290. #endif /* NSK */
  291. /*
  292. * Macros to set and get the members of a cluster using a mask of
  293. * appropriate size.
  294. */
  295. #define SetCluster(/* cluster_t */ cluster, /* uint16 */ mask) \
  296. { \
  297. cluster[0] = (uint8)(mask >> 8); \
  298. cluster[1] = (uint8)(mask & 0xFF); \
  299. }
  300. #define GetCluster(/* cluster_t */ cluster) \
  301. (((uint16)cluster[0] << 8) | (uint16)cluster[1])
  302. /* Macro to combine two cluster masks into a uint32.
  303. * This is used in tracing regroup events.
  304. */
  305. #define RGP_MERGE_TO_32( c1, c2 ) \
  306. ( ( GetCluster( c1 ) << 16 ) | ( GetCluster( c2 ) ) )
  307. /*----------------------------------------------------------------------
  308. * OS-dependent routines used by the Regroup module.
  309. *
  310. * These are defined in srgpos.c.
  311. *----------------------------------------------------------------------*/
  312. /* Routines to halt the node upon catastrophic errors. */
  313. #ifdef NSK
  314. #include <dutil.h> /*F40:MB06458.3*/
  315. #define RGP_ERROR(/* uint16 */ halt_code) SYSTEM_FREEZE_(halt_code)
  316. #else
  317. _priv _resident extern void RGP_ERROR_EX (uint16 halt_code, char* fname, DWORD lineno);
  318. #define RGP_ERROR(halt_code) RGP_ERROR_EX(halt_code, __FILE__, __LINE__)
  319. #endif /* NSK */
  320. #ifdef UNIX
  321. _priv _resident extern void PrintRegroupStart();
  322. _priv _resident extern void PrintPruningResult();
  323. _priv _resident extern void PrintStage();
  324. _priv _resident extern void PrintMatrix();
  325. #endif /* UNIX */
  326. #ifdef __cplusplus
  327. }
  328. #endif /* __cplusplus */
  329. #if 0
  330. History of changes to this file:
  331. -------------------------------------------------------------------------
  332. 1995, December 13 F40:KSK0610 /*F40:KSK06102.1*/
  333. This file is part of the portable Regroup Module used in the NonStop
  334. Kernel (NSK) and Loosely Coupled UNIX (LCU) operating systems. There
  335. are 10 files in the module - jrgp.h, jrgpos.h, wrgp.h, wrgpos.h,
  336. srgpif.c, srgpos.c, srgpsm.c, srgputl.c, srgpcli.c and srgpsvr.c.
  337. The last two are simulation files to test the Regroup Module on a
  338. UNIX workstation in user mode with processes simulating processor nodes
  339. and UDP datagrams used to send unacknowledged datagrams.
  340. This file was first submitted for release into NSK on 12/13/95.
  341. ------------------------------------------------------------------------------
  342. This change occurred on 19 Jan 1996 /*F40:MB06458.4*/
  343. Changes for phase IV Sierra message system release. Includes: /*F40:MB06458.5*/
  344. - Some cleanup of the code /*F40:MB06458.6*/
  345. - Increment KCCB counters to count the number of setup messages and /*F40:MB06458.7*/
  346. unsequenced messages sent. /*F40:MB06458.8*/
  347. - Fixed some bugs /*F40:MB06458.9*/
  348. - Disable interrupts before allocating broadcast sibs. /*F40:MB06458.10*/
  349. - Change per-packet-timeout to 5ms /*F40:MB06458.11*/
  350. - Make the regroup and powerfail broadcast use highest priority /*F40:MB06458.12*/
  351. tnet services queue. /*F40:MB06458.13*/
  352. - Call the millicode backdoor to get the processor status from SP /*F40:MB06458.14*/
  353. - Fixed expand bug in msg_listen_ and msg_readctrl_ /*F40:MB06458.15*/
  354. - Added enhancement to msngr_sendmsg_ so that clients do not need /*F40:MB06458.16*/
  355. to be unstoppable before calling this routine. /*F40:MB06458.17*/
  356. - Added new steps in the build file called /*F40:MB06458.18*/
  357. MSGSYS_C - compiles all the message system C files /*F40:MB06458.19*/
  358. MSDRIVER - compiles all the MSDriver files /*F40:MB06458.20*/
  359. REGROUP - compiles all the regroup files /*F40:MB06458.21*/
  360. ----------------------------------------------------------------------- /*F40:MB06458.22*/
  361. #endif /* 0 - change descriptions */
  362. #endif /* _JRGPOS_H_ defined */
  363.