Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_site_role_policy.c File Reference

See rte_site_role_policy.h. Moved unchanged from RBC_GP's ab_gp_site_role.c and the generic part of ab_gp_standby_policy.c (ADR-040 step 1); only the names changed. More...

Include dependency graph for rte_site_role_policy.c:

Go to the source code of this file.

Functions

static bool peer_answering (const rte_site_role_input_t *in)
static bool pair_ready_to_promote (const rte_site_role_input_t *in)
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.

Detailed Description

See rte_site_role_policy.h. Moved unchanged from RBC_GP's ab_gp_site_role.c and the generic part of ab_gp_standby_policy.c (ADR-040 step 1); only the names changed.

Definition in file rte_site_role_policy.c.

Function Documentation

◆ peer_answering()

bool peer_answering ( const rte_site_role_input_t * in)
static

The counterpart answered within the last 2 cycles.

Definition at line 9 of file rte_site_role_policy.c.

◆ pair_ready_to_promote()

bool pair_ready_to_promote ( const rte_site_role_input_t * in)
static

The A/B pair may promote: this channel is ready and its sibling is ONLINE, ready, or not there.

Definition at line 15 of file rte_site_role_policy.c.

◆ 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:

  1. own FAULTED and counterpart FAULTED: RENEGOTIATE.
  2. this channel is STANDBY, healthy, counterpart FAULTED: PROMOTE (PEER_FAULTED).
  3. own FAULTED, counterpart healthy and holding an ONLINE snapshot: DEMOTE (RECOVERED).
  4. STANDBY, counterpart silent, dispatcher confirmation valid: PROMOTE (DISPATCHER_CONFIRMED).
  5. ONLINE and the counterpart, answering within 2 cycles, is ONLINE too: DEMOTE (YIELD_TO_TAKEOVER) if this channel was cut off while ONLINE, otherwise ALARM (DUAL_ONLINE).
  6. STANDBY, link up, counterpart answering within 2 cycles and not ONLINE for RTE_SITE_ROLE_BOTH_STANDBY_CYCLES cycles (or 1 cycle when the A/B sibling is already ONLINE): PROMOTE (BOTH_STANDBY_WEST / _SIBLING).
  7. STANDBY, A/B sibling ONLINE, own link view unusable and counterpart not verifiably ONLINE: follow the sibling after 2 cycles, PROMOTE (BOTH_STANDBY_SIBLING).

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.

Parameters
infacts; must not be NULL
Returns
the decision; both_standby_cycles must be stored by the caller

Definition at line 20 of file rte_site_role_policy.c.

◆ rte_site_role_reason_text()

const char * rte_site_role_reason_text ( rte_site_role_reason_t reason)
Returns
a short text for a reason, for logs.

Definition at line 101 of file rte_site_role_policy.c.

◆ rte_site_role_reason_token()

const char * rte_site_role_reason_token ( rte_site_role_reason_t reason)
Returns
a one-word token (no spaces) for a reason, for the status frame.

Definition at line 141 of file rte_site_role_policy.c.

◆ 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.

Parameters
sync_enabledtrue when standby_mode is warm or hot
is_onlinethis channel is ONLINE
link_upthe inter-site link is open
healthySTANDBY answered the last sync
cyclecurrent cycle number
last_trycycle of the last sync attempt made while unhealthy
Returns
true if a sync should be sent now

Definition at line 181 of file rte_site_role_policy.c.

◆ 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).

Returns
true if the snapshot has been silent for more than RTE_SITE_ROLE_STANDBY_DATA_TIMEOUT_CYCLES, or the cycle counter restarted since it arrived

Definition at line 202 of file rte_site_role_policy.c.

◆ 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. 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.

◆ 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 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.