Safe API Framework
0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
Loading...
Searching...
No Matches
rte_site_role_policy.h
Go to the documentation of this file.
1
22
#ifndef RTE_SITE_ROLE_POLICY_H
23
#define RTE_SITE_ROLE_POLICY_H
24
25
#include <stdbool.h>
26
#include <stdint.h>
27
28
#ifdef __cplusplus
29
extern
"C"
{
30
#endif
31
33
#define RTE_SITE_ROLE_STANDBY_DATA_TIMEOUT_CYCLES 3U
34
36
#define RTE_SITE_ROLE_STANDBY_SYNC_RETRY_CYCLES 10U
37
39
#define RTE_SITE_ROLE_TAKEOVER_CONFIRM_VALID_CYCLES 120U
40
42
#define RTE_SITE_ROLE_BOTH_STANDBY_CYCLES 6U
43
45
typedef
enum
46
{
47
RTE_SITE_ROLE_ACTION_NONE
= 0,
48
RTE_SITE_ROLE_ACTION_PROMOTE
,
49
RTE_SITE_ROLE_ACTION_DEMOTE
,
50
RTE_SITE_ROLE_ACTION_RENEGOTIATE
,
51
RTE_SITE_ROLE_ACTION_ALARM
,
52
RTE_SITE_ROLE_ACTION_WAIT
53
}
rte_site_role_action_t
;
54
56
typedef
enum
57
{
58
RTE_SITE_ROLE_REASON_NONE = 0,
59
RTE_SITE_ROLE_REASON_BOTH_FAULTED
,
60
RTE_SITE_ROLE_REASON_PEER_FAULTED
,
61
RTE_SITE_ROLE_REASON_RECOVERED
,
62
RTE_SITE_ROLE_REASON_DISPATCHER_CONFIRMED
,
63
RTE_SITE_ROLE_REASON_BOTH_STANDBY_WEST
,
64
RTE_SITE_ROLE_REASON_BOTH_STANDBY_SIBLING
,
65
RTE_SITE_ROLE_REASON_YIELD_TO_TAKEOVER
,
66
RTE_SITE_ROLE_REASON_DUAL_ONLINE
,
67
RTE_SITE_ROLE_REASON_WAITING_READY
68
}
rte_site_role_reason_t
;
69
71
typedef
struct
72
{
73
bool
is_online
;
74
bool
own_faulted
;
75
bool
is_west
;
76
bool
link_up
;
77
bool
peer_unresponsive
;
78
uint32_t
cycle
;
79
uint32_t
peer_last_rx_cycle
;
80
bool
peer_online_now
;
81
bool
peer_faulted
;
82
bool
peer_snapshot_valid
;
83
bool
sibling_online
;
84
bool
takeover_confirmed
;
85
uint32_t
takeover_confirm_cycle
;
86
bool
lost_peer_while_online
;
87
uint32_t
both_standby_cycles
;
88
bool
own_ready
;
89
bool
sibling_ready
;
90
bool
sibling_reachable
;
91
}
rte_site_role_input_t
;
92
94
typedef
struct
95
{
96
rte_site_role_action_t
action;
97
rte_site_role_reason_t
reason;
98
uint32_t
both_standby_cycles
;
99
}
rte_site_role_decision_t
;
100
119
rte_site_role_decision_t
rte_site_role_decide
(
const
rte_site_role_input_t
*in);
120
122
const
char
*
rte_site_role_reason_text
(
rte_site_role_reason_t
reason);
123
125
const
char
*
rte_site_role_reason_token
(
rte_site_role_reason_t
reason);
126
137
bool
rte_site_role_standby_sync_due
(
bool
sync_enabled,
bool
is_online,
bool
link_up,
bool
healthy, uint32_t cycle,
138
uint32_t last_try);
139
145
bool
rte_site_role_standby_data_stale
(
bool
sync_enabled,
bool
is_online,
bool
have_snapshot, uint32_t cycle,
146
uint32_t last_rx_cycle);
147
153
bool
rte_site_role_takeover_allowed
(
bool
is_online,
bool
own_faulted,
bool
peer_unresponsive,
bool
confirmed,
154
uint32_t cycle, uint32_t confirm_cycle);
155
161
bool
rte_site_role_both_standby_tiebreak
(uint32_t both_standby_cycles,
bool
is_west,
bool
sibling_online);
162
163
#ifdef __cplusplus
164
}
165
#endif
166
167
#endif
/* RTE_SITE_ROLE_POLICY_H */
rte_site_role_standby_data_stale
bool rte_site_role_standby_data_stale(bool sync_enabled, bool is_online, bool have_snapshot, uint32_t cycle, uint32_t last_rx_cycle)
Whether STANDBY's held snapshot is stale and must be dropped (STANDBY goes cold).
Definition
rte_site_role_policy.c:202
rte_site_role_decide
rte_site_role_decision_t rte_site_role_decide(const rte_site_role_input_t *in)
Decides this cycle's role action. Rules are evaluated in this order and the first that applies wins:
Definition
rte_site_role_policy.c:20
rte_site_role_reason_t
rte_site_role_reason_t
Definition
rte_site_role_policy.h:57
RTE_SITE_ROLE_REASON_DUAL_ONLINE
@ RTE_SITE_ROLE_REASON_DUAL_ONLINE
Definition
rte_site_role_policy.h:66
RTE_SITE_ROLE_REASON_WAITING_READY
@ RTE_SITE_ROLE_REASON_WAITING_READY
Definition
rte_site_role_policy.h:67
RTE_SITE_ROLE_REASON_PEER_FAULTED
@ RTE_SITE_ROLE_REASON_PEER_FAULTED
Definition
rte_site_role_policy.h:60
RTE_SITE_ROLE_REASON_BOTH_FAULTED
@ RTE_SITE_ROLE_REASON_BOTH_FAULTED
Definition
rte_site_role_policy.h:59
RTE_SITE_ROLE_REASON_DISPATCHER_CONFIRMED
@ RTE_SITE_ROLE_REASON_DISPATCHER_CONFIRMED
Definition
rte_site_role_policy.h:62
RTE_SITE_ROLE_REASON_BOTH_STANDBY_SIBLING
@ RTE_SITE_ROLE_REASON_BOTH_STANDBY_SIBLING
Definition
rte_site_role_policy.h:64
RTE_SITE_ROLE_REASON_RECOVERED
@ RTE_SITE_ROLE_REASON_RECOVERED
Definition
rte_site_role_policy.h:61
RTE_SITE_ROLE_REASON_YIELD_TO_TAKEOVER
@ RTE_SITE_ROLE_REASON_YIELD_TO_TAKEOVER
Definition
rte_site_role_policy.h:65
RTE_SITE_ROLE_REASON_BOTH_STANDBY_WEST
@ RTE_SITE_ROLE_REASON_BOTH_STANDBY_WEST
Definition
rte_site_role_policy.h:63
rte_site_role_reason_text
const char * rte_site_role_reason_text(rte_site_role_reason_t reason)
Definition
rte_site_role_policy.c:101
rte_site_role_both_standby_tiebreak
bool rte_site_role_both_standby_tiebreak(uint32_t both_standby_cycles, bool is_west, bool sibling_online)
Negotiation tie-break for "both sites STANDBY": a channel whose A/B sibling is already ONLINE joins i...
Definition
rte_site_role_policy.c:229
rte_site_role_action_t
rte_site_role_action_t
Definition
rte_site_role_policy.h:46
RTE_SITE_ROLE_ACTION_NONE
@ RTE_SITE_ROLE_ACTION_NONE
Definition
rte_site_role_policy.h:47
RTE_SITE_ROLE_ACTION_RENEGOTIATE
@ RTE_SITE_ROLE_ACTION_RENEGOTIATE
Definition
rte_site_role_policy.h:50
RTE_SITE_ROLE_ACTION_PROMOTE
@ RTE_SITE_ROLE_ACTION_PROMOTE
Definition
rte_site_role_policy.h:48
RTE_SITE_ROLE_ACTION_DEMOTE
@ RTE_SITE_ROLE_ACTION_DEMOTE
Definition
rte_site_role_policy.h:49
RTE_SITE_ROLE_ACTION_WAIT
@ RTE_SITE_ROLE_ACTION_WAIT
Definition
rte_site_role_policy.h:52
RTE_SITE_ROLE_ACTION_ALARM
@ RTE_SITE_ROLE_ACTION_ALARM
Definition
rte_site_role_policy.h:51
rte_site_role_takeover_allowed
bool rte_site_role_takeover_allowed(bool is_online, bool own_faulted, bool peer_unresponsive, bool confirmed, uint32_t cycle, uint32_t confirm_cycle)
Whether a STANDBY channel may promote itself because its counterpart stopped responding....
Definition
rte_site_role_policy.c:216
rte_site_role_standby_sync_due
bool rte_site_role_standby_sync_due(bool sync_enabled, bool is_online, bool link_up, bool healthy, uint32_t cycle, uint32_t last_try)
Whether ONLINE should attempt the pre-commit standby sync this cycle.
Definition
rte_site_role_policy.c:181
rte_site_role_reason_token
const char * rte_site_role_reason_token(rte_site_role_reason_t reason)
Definition
rte_site_role_policy.c:141
rte_site_role_decision_t
Definition
rte_site_role_policy.h:95
rte_site_role_decision_t::both_standby_cycles
uint32_t both_standby_cycles
Definition
rte_site_role_policy.h:98
rte_site_role_input_t
Definition
rte_site_role_policy.h:72
rte_site_role_input_t::own_ready
bool own_ready
Definition
rte_site_role_policy.h:88
rte_site_role_input_t::link_up
bool link_up
Definition
rte_site_role_policy.h:76
rte_site_role_input_t::sibling_ready
bool sibling_ready
Definition
rte_site_role_policy.h:89
rte_site_role_input_t::peer_snapshot_valid
bool peer_snapshot_valid
Definition
rte_site_role_policy.h:82
rte_site_role_input_t::peer_last_rx_cycle
uint32_t peer_last_rx_cycle
Definition
rte_site_role_policy.h:79
rte_site_role_input_t::peer_unresponsive
bool peer_unresponsive
Definition
rte_site_role_policy.h:77
rte_site_role_input_t::lost_peer_while_online
bool lost_peer_while_online
Definition
rte_site_role_policy.h:86
rte_site_role_input_t::both_standby_cycles
uint32_t both_standby_cycles
Definition
rte_site_role_policy.h:87
rte_site_role_input_t::peer_online_now
bool peer_online_now
Definition
rte_site_role_policy.h:80
rte_site_role_input_t::cycle
uint32_t cycle
Definition
rte_site_role_policy.h:78
rte_site_role_input_t::sibling_online
bool sibling_online
Definition
rte_site_role_policy.h:83
rte_site_role_input_t::takeover_confirmed
bool takeover_confirmed
Definition
rte_site_role_policy.h:84
rte_site_role_input_t::sibling_reachable
bool sibling_reachable
Definition
rte_site_role_policy.h:90
rte_site_role_input_t::own_faulted
bool own_faulted
Definition
rte_site_role_policy.h:74
rte_site_role_input_t::takeover_confirm_cycle
uint32_t takeover_confirm_cycle
Definition
rte_site_role_policy.h:85
rte_site_role_input_t::peer_faulted
bool peer_faulted
Definition
rte_site_role_policy.h:81
rte_site_role_input_t::is_west
bool is_west
Definition
rte_site_role_policy.h:75
rte_site_role_input_t::is_online
bool is_online
Definition
rte_site_role_policy.h:73
include
rte
redundancy
site_role
rte_site_role_policy.h
Generated by
1.18.0