Commit d39aa5ee authored by Jean-Claude BAU's avatar Jean-Claude BAU

BMCA: new qualification algorithm

Introduction of an other way to calculate the best foreign master. It
has been changed to fix bugs found during ISPC20119 (IOL test). Tests
showed unstable behavior in the computation of foreign master
qualification in some specific circumstances (time window of 8s with
announce messages every 5s)
parent 724ce5a3
......@@ -4,6 +4,7 @@
#define pp_error(...) pp_printf("ERROR: " __VA_ARGS__)
#define pp_info(...) pp_printf("INFO: " __VA_ARGS__)
/*
* The "new" diagnostics is based on flags: there are per-instance d_flags
......
......@@ -260,6 +260,8 @@ typedef struct { /* page 68 */
ClockQuality grandmasterClockQuality;
UInteger8 grandmasterPriority1;
UInteger8 grandmasterPriority2;
/* Private data */
Boolean newGrandmaster;
} parentDS_t;
/* Port Data set */
......
......@@ -77,9 +77,6 @@ struct pp_channel {
* it is called foreignMasterDS, see 9.3.2.4
*/
struct pp_frgn_master {
/* how many announce messages from this port where received in the
* interval */
UInteger16 foreignMasterAnnounceMessages[PP_FOREIGN_MASTER_TIME_WINDOW];
/* BMC related information */
UInteger16 sequenceId;
UInteger16 stepsRemoved;
......@@ -93,7 +90,11 @@ struct pp_frgn_master {
UInteger8 grandmasterPriority2;
Enumeration8 timeSource;
Octet flagField[2];
unsigned long ext_specific; /* used by extension */
/* Private data */
Boolean qualified; // TRUE if qualified
unsigned long lastAnnounceMsgMs; // Last time in ms when the announce message was received
/* used by extension */
unsigned long ext_specific;
};
/*
......@@ -259,6 +260,7 @@ struct pp_instance {
* messages */
UInteger16 frgn_rec_num;
Integer16 frgn_rec_best;
UInteger32 frgn_master_time_window_ms;
struct pp_frgn_master frgn_master[PP_NR_FOREIGN_RECORDS];
portDS_t *portDS; /* page 72 */
......
This diff is collapsed.
......@@ -116,6 +116,9 @@ int pp_initializing(struct pp_instance *ppi, void *buf, int len)
pp_timeout_init(ppi);
pp_timeout_setall(ppi);
/* Foreign master time window */
ppi->frgn_master_time_window_ms= pp_timeout_log_to_ms(DSPOR(ppi)->logAnnounceInterval)*PP_FOREIGN_MASTER_TIME_WINDOW;
ppi->pdstate = PP_PDSTATE_NONE; // Default value for PTP. Can be overwritten in specific init
ppi->extState=(ppi->protocol_extension==PPSI_EXT_NONE) ? PP_EXSTATE_DISABLE : PP_EXSTATE_ACTIVE;
......
......@@ -245,6 +245,7 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
int ret = PP_SEND_OK; /* error var, to check errors in msg handling */
Boolean uncalibrated = (ppi->state == PPS_UNCALIBRATED);
MsgHeader *hdr = &ppi->received_ptp_header;
int newState=ppi->is_new_state;
/* upgrade from uncalibrated to slave or back*/
if (uncalibrated) {
......@@ -257,6 +258,23 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
}
}
/* Check if the foreign master has changed */
if ( DSPAR(ppi)->newGrandmaster ) {
// New grandmaster detected
DSPAR(ppi)->newGrandmaster=FALSE; // Clear it
if ( !uncalibrated )
// State must transition from SLAVE to UNCALIBRATED
ppi->next_state =PPS_UNCALIBRATED;
else
newState=1;// If already in uncalibrated state, force to see it as a new state
Octet *id=DSPAR(ppi)->parentPortIdentity.clockIdentity.id;
pp_info("New grandmaster detected: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
id[0],id[1],id[2],id[3],id[4],id[5],id[6],id[7]);
}
/* Force to stay on desired state if externalPortConfiguration option is enabled */
if (is_externalPortConfigurationEnabled(DSDEF(ppi)) &&
ppi->next_state == PPS_SLAVE &&
......@@ -264,9 +282,9 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
ppi->next_state = PPS_UNCALIBRATED; //Force to stay in uncalibrated state
/* when entering uncalibrated init servo */
if (uncalibrated && (ppi->is_new_state)) {
if (uncalibrated && newState) {
memset(&ppi->t1, 0, sizeof(ppi->t1));
pp_diag(ppi, bmc, 2, "Entered to uncalibrated, reset servo\n");
pp_diag(ppi, bmc, 2, "Entered to uncalibrated, reset servo\n");
pp_servo_init(ppi);
if (is_ext_hook_available(ppi,new_slave))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment