|
Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
|
Site-role policy: one pure decision function for "should this channel promote, demote or stay?" and the timing predicates of standby sync, takeover and the both-STANDBY tie-break. More...
#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | rte_site_role_input_t |
| struct | rte_site_role_decision_t |
Macros | |
| #define | RTE_SITE_ROLE_STANDBY_DATA_TIMEOUT_CYCLES 3U |
| #define | RTE_SITE_ROLE_STANDBY_SYNC_RETRY_CYCLES 10U |
| #define | RTE_SITE_ROLE_TAKEOVER_CONFIRM_VALID_CYCLES 120U |
| #define | RTE_SITE_ROLE_BOTH_STANDBY_CYCLES 6U |
Functions | |
| 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: | |
| const char * | rte_site_role_reason_text (rte_site_role_reason_t reason) |
| const char * | rte_site_role_reason_token (rte_site_role_reason_t reason) |
| 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. | |
| 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). | |
| 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. Silence alone never promotes: the dispatcher must have confirmed, within RTE_SITE_ROLE_TAKEOVER_CONFIRM_VALID_CYCLES, that the other site is not ONLINE. | |
| 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 it at once; otherwise WEST promotes after RTE_SITE_ROLE_BOTH_STANDBY_CYCLES. Both sites compute the same answer from the same link, so this is a negotiation outcome, not a unilateral promotion. | |
Site-role policy: one pure decision function for "should this channel promote, demote or stay?" and the timing predicates of standby sync, takeover and the both-STANDBY tie-break.
ADR-040 step 1: the Capella model places site-role negotiation in RTE Redundancy Services; the application keeps a declarative Site Role Client. This header is the pure part of that service, moved unchanged from RBC_GP (ab_gp_site_role, ab_gp_standby_policy). No I/O, no globals: facts come from the caller, the answer is one action per cycle, and the both-STANDBY counter is passed in and returned.
A channel becomes ONLINE only through:
REQ-SITEROLE-001: rte_site_role_decide() evaluates the rules in the documented order; the first that applies wins. REQ-SITEROLE-002: a promotion is carried out only when the pair is ready (else WAIT). REQ-SITEROLE-003: silence alone never promotes (rte_site_role_takeover_allowed needs a valid confirmation). REQ-SITEROLE-004: a restarted cycle counter makes a takeover confirmation expired and a held snapshot stale.
Definition in file rte_site_role_policy.h.
| #define RTE_SITE_ROLE_STANDBY_DATA_TIMEOUT_CYCLES 3U |
Cycles STANDBY may go without a valid snapshot before it is treated as cold.
Definition at line 33 of file rte_site_role_policy.h.
| #define RTE_SITE_ROLE_STANDBY_SYNC_RETRY_CYCLES 10U |
While STANDBY is considered not working, ONLINE retries the sync every this many cycles.
Definition at line 36 of file rte_site_role_policy.h.
| #define RTE_SITE_ROLE_TAKEOVER_CONFIRM_VALID_CYCLES 120U |
How long (cycles) a dispatcher takeover confirmation stays valid.
Definition at line 39 of file rte_site_role_policy.h.
| #define RTE_SITE_ROLE_BOTH_STANDBY_CYCLES 6U |
Consecutive cycles both sites must be STANDBY (counterpart responding, neither ONLINE nor FAULTED) before the tie-break.
Definition at line 42 of file rte_site_role_policy.h.
What the channel should do this cycle.
Definition at line 45 of file rte_site_role_policy.h.
Why (the log line, the status frame and the tests use it).
Definition at line 56 of file rte_site_role_policy.h.
| 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:
A promotion is only carried out when this channel is ready AND its A/B sibling is ONLINE already, or confirms it is ready, or cannot be reached (single channel). Otherwise the answer is WAIT.
| in | facts; must not be NULL |
Definition at line 20 of file rte_site_role_policy.c.
| const char * rte_site_role_reason_text | ( | rte_site_role_reason_t | reason | ) |
Definition at line 101 of file rte_site_role_policy.c.
| const char * rte_site_role_reason_token | ( | rte_site_role_reason_t | reason | ) |
Definition at line 141 of file rte_site_role_policy.c.
| 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.
| sync_enabled | true when standby_mode is warm or hot |
| is_online | this channel is ONLINE |
| link_up | the inter-site link is open |
| healthy | STANDBY answered the last sync |
| cycle | current cycle number |
| last_try | cycle of the last sync attempt made while unhealthy |
Definition at line 181 of file rte_site_role_policy.c.
| 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 at line 202 of file rte_site_role_policy.c.
| 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. Silence alone never promotes: the dispatcher must have confirmed, within RTE_SITE_ROLE_TAKEOVER_CONFIRM_VALID_CYCLES, that the other site is not ONLINE.
Definition at line 216 of file rte_site_role_policy.c.
| 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 it at once; otherwise WEST promotes after RTE_SITE_ROLE_BOTH_STANDBY_CYCLES. Both sites compute the same answer from the same link, so this is a negotiation outcome, not a unilateral promotion.
Definition at line 229 of file rte_site_role_policy.c.