11#include <flexptp_options.h>
17#define S (gPtpCoreState)
22#define COMPARE_AND_RETURN(pmp1, pmp2, field) \
24 if (pmp1->field < pmp2->field) { \
26 } else if (pmp1->field > pmp2->field) { \
52#define SBMC_PRINT_LOG(p, c) \
54 MSG("%s -> %s\n", BMCA_HINTS[(p)], BMCA_HINTS[(c)]);
58 if (S.bmca.state != state) {
63 S.bmca.stateDuration = 0;
74 uint32_t sd = S.bmca.stateDuration;
78 bmCI = S.bmca.masterProps.grandmasterClockIdentity;
79 ourCI = S.capabilities.grandmasterClockIdentity;
85 if (master_mode_enabled) {
86 S.bmca.masterProps = S.capabilities;
91 if (master_mode_enabled && (bmCI == ourCI)) {
94 if ((bmCI != ourCI) && (bmCI != ~((uint64_t)0)) && (bmCI != 0)) {
110 if (master_mode_enabled) {
111 S.bmca.masterProps = S.capabilities;
123 S.bmca.stateDuration++;
137 bool masterChanged =
false;
143 if (master_mode_enabled) {
146 masterChanged =
true;
151 masterChanged =
true;
161 masterChanged =
true;
175 S.bmca.masterTOCntr = 0;
184 S.bmca.masterTOCntr = 0;
#define SBMC_PRINT_LOG(p, c)
#define COMPARE_AND_RETURN(pmp1, pmp2, field)
static void ptp_bmca_handle_state_change(PtpBmcaFsmState state)
static char * BMCA_HINTS[]
void ptp_handle_announce_msg(PtpAnnounceBody *pAnn, PtpHeader *pHeader)
int ptp_select_better_master(PtpMasterProperties *pMP1, PtpMasterProperties *pMP2)
This module implements the Best Master Clock Algorithm.
This module defines clock identity related operations.
In this module are the core and user events defined.
@ PTP_CEV_BMCA_STATE_CHANGED
Core of the PTP implementation. Defines functions for message processing, clock tuning,...
In here reside a multitude of fundamental PTP-related constants and definitions.
#define PTP_HEARTBEAT_TICKRATE_MS
Heartbeat ticking period.
#define PTP_MASTER_QUALIFICATION_TIMEOUT
Number of Announce intervals.
#define PTP_CLOCK_PRIORITY2
Clock priority2.
#define PTP_ANNOUNCE_RECEIPT_TIMEOUT
Number of tolerated consecutive lost Announce messages.
#define PTP_CLOCK_PRIORITY1
Clock priority1.
#define PTP_BMCA_LISTENING_TIMEOUT_MS
BMCA LISTENING state timeout.
#define PTP_TIME_SOURCE
Time source of this device.
#define PTP_ENABLE_MASTER_OPERATION
By default, disable Master operation mode.
#define PTP_WORST_ACCURACY
Worst accuracy of this device.
#define PTP_FALLBACK_UTC_OFFSET
UTC offset caused by the accumulated leap seconds.
#define PTP_BEST_CLOCK_CLASS
Best clock class of this device.
This module defines the fundamental PTP message and state machine type, flags, bitfields and the PTP ...
#define PTP_VARIANCE_HAS_NOT_BEEN_COMPUTED
@ PTP_PF_SLAVE_ONLY
Operating only in SLAVE mode.
Contents of a PTP Announce message without the common PTP header.
uint16_t currentUTCOffset
Current UTC Offset.
uint64_t grandmasterClockIdentity
Grandmaster Clock Identity.
uint8_t grandmasterClockClass
Grandmaster Clock Class.
uint8_t grandmasterClockAccuracy
Grandmaster Clock Accuracy.
uint16_t localStepsRemoved
Local Steps Removed.
uint16_t grandmasterClockVariance
Grandmaster Clock Variance.
uint8_t priority2
Priority 2.
uint8_t timeSource
Time Source.
uint8_t priority1
Priority 1.
PtpMasterProperties masterProps
Master clock properties.
PtpBmcaFsmState state
BMCA state.
uint16_t masterAnnPer_ms
Message period of current master.
bool ptp_event_enqueue(const PtpCoreEvent *event)
The entry point of the whole PTP-implementation. Calling reg_task_ptp() initializes the PTP-engine,...