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

Fix PPS missing issue

After around 36 hours, one PPS was missing. This was due to an issue in
the WR extension. When the sequence id in the announce message was
moving from 65535 to 0, the WR handshake was restarted. As a result of
that, the side effects would be :
- a missing PPS
- an unlock of the PLL
parent 135c480e
......@@ -198,6 +198,14 @@ int wrh_servo_got_presp(struct pp_instance *ppi)
return 1;
}
static void setState(struct pp_instance *ppi, int newState) {
struct pp_servo *gs=SRV(ppi);
if ( gs->state != newState ) {
pp_diag(ppi, servo, 2, "new state %s\n", wrh_servo_state_name[newState]);
gs->state=newState;
}
}
static int __wrh_servo_update(struct pp_instance *ppi)
{
struct pp_servo *gs=SRV(ppi);
......@@ -249,7 +257,7 @@ static int __wrh_servo_update(struct pp_instance *ppi)
/* So, we didn't return. Choose the right state */
if (offsetMS.secs) {/* so bad... */
gs->state = WRH_SYNC_TAI;
setState(ppi,WRH_SYNC_TAI);
pp_diag(ppi, servo, 2, "offsetMS: %li sec ...\n",
(long)offsetMS.secs);
} else {
......@@ -260,7 +268,7 @@ static int __wrh_servo_update(struct pp_instance *ppi)
(long)offset_ps);
if (offset_ticks) /* not that bad */
gs->state = WRH_SYNC_NSEC;
setState(ppi,WRH_SYNC_NSEC);
/* else, let the states below choose the sequence */
}
......@@ -280,13 +288,13 @@ static int __wrh_servo_update(struct pp_instance *ppi)
* Else, we must ensure we leave this status towards
* fine tuning
*/
gs->state = WRH_SYNC_PHASE;
setState(ppi,WRH_SYNC_PHASE);
break;
case WRH_SYNC_NSEC:
WRH_OPER()->adjust_counters(0, offset_ticks);
gs->flags |= PP_SERVO_FLAG_WAIT_HW;
gs->state = WRH_SYNC_PHASE;
setState(ppi,WRH_SYNC_PHASE);
break;
case WRH_SYNC_PHASE:
......@@ -298,7 +306,7 @@ static int __wrh_servo_update(struct pp_instance *ppi)
WRH_OPER()->adjust_phase(s->cur_setpoint_ps);
gs->flags |= PP_SERVO_FLAG_WAIT_HW;
gs->state = WRH_WAIT_OFFSET_STABLE;
setState(ppi,WRH_WAIT_OFFSET_STABLE);
if (CONFIG_ARCH_IS_WRS) {
/*
......@@ -321,13 +329,13 @@ static int __wrh_servo_update(struct pp_instance *ppi)
if(remaining_offset < WRH_SERVO_OFFSET_STABILITY_THRESHOLD) {
TOPS(ppi)->enable_timing_output(GLBS(ppi),1);
s->prev_delayMS_ps = s->delayMS_ps;
gs->state = WRH_TRACK_PHASE;
setState(ppi,WRH_TRACK_PHASE);
} else {
s->missed_iters++;
}
if (s->missed_iters >= 10) {
s->missed_iters = 0;
gs->state = WRH_SYNC_PHASE;
setState(ppi,WRH_SYNC_PHASE);
}
break;
......@@ -338,7 +346,7 @@ static int __wrh_servo_update(struct pp_instance *ppi)
if(wrh_tracking_enabled) {
if (abs(offset_ps) >
2 * WRH_SERVO_OFFSET_STABILITY_THRESHOLD) {
gs->state = WRH_SYNC_PHASE;
setState(ppi,WRH_SYNC_PHASE);
break;
}
......
......@@ -2,8 +2,7 @@
# All files are under directory D: I'm lazy
D := proto-ext-whiterabbit
OBJ-y += $D/fsm-table.o \
$D/hooks.o \
OBJ-y += $D/hooks.o \
$D/common-fun.o \
$D/state-wr-present.o \
$D/state-wr-m-lock.o \
......
/*
* Copyright (C) 2011 CERN (www.cern.ch)
* Author: Aurelio Colosimo
*
* Released according to the GNU LGPL, version 2.1 or any later version.
*/
#include <ppsi/ppsi.h>
/*
* This is the WR state machine table.
*/
#if 0
struct pp_state_table_item pp_state_table[] = {
{ PPS_INITIALIZING, "initializing", pp_initializing,},
{ PPS_FAULTY, "faulty", pp_faulty,},
{ PPS_DISABLED, "disabled", pp_disabled,},
{ PPS_LISTENING, "listening", pp_listening,},
{ PPS_PRE_MASTER, "pre-master", pp_master,},
{ PPS_MASTER, "master", pp_master,},
{ PPS_PASSIVE, "passive", pp_passive,},
{ PPS_UNCALIBRATED, "uncalibrated", pp_slave,},
{ PPS_SLAVE, "slave", pp_slave,},
{ WRS_PRESENT, "uncalibrated/wr-present", wr_present,},
{ WRS_M_LOCK, "master/wr-m-lock", wr_m_lock,},
{ WRS_S_LOCK, "uncalibrated/wr-s-lock", wr_s_lock,},
{ WRS_LOCKED, "uncalibrated/wr-locked", wr_locked,},
{ WRS_CALIBRATION, "wr-calibration", wr_calibration,},
{ WRS_CALIBRATED, "wr-calibrated", wr_calibrated,},
{ WRS_RESP_CALIB_REQ, "wr-resp-calib-req", wr_resp_calib_req,},
{ WRS_WR_LINK_ON, "wr-link-on", wr_link_on,},
#ifdef CONFIG_ABSCAL
{ WRS_ABSCAL, "absolute-calibration", wr_abscal,},
#endif
{ PPS_END_OF_TABLE,}
};
#endif
......@@ -148,8 +148,8 @@ static void wr_unpack_announce(struct pp_instance *ppi,void *buf, MsgAnnounce *a
Boolean samePid=!bmc_pidcmp(pid, &wrp->parentAnnPortIdentity);
if ( !samePid ||
(samePid &&
(hdr->sequenceId!=wrp->parentAnnSequenceId+1 &&
hdr->sequenceId!=wrp->parentAnnSequenceId+2)
(hdr->sequenceId!=(UInteger16) (wrp->parentAnnSequenceId+1) &&
hdr->sequenceId!=(UInteger16) (wrp->parentAnnSequenceId+2))
)) {
/* For other states, it is done in the state_change hook */
resetWrProtocol=slaveUncalState;
......@@ -176,7 +176,7 @@ static void wr_unpack_announce(struct pp_instance *ppi,void *buf, MsgAnnounce *a
}
if ( resetWrProtocol ) {
ppi->state=PPS_UNCALIBRATED;
ppi->next_state=PPS_UNCALIBRATED;
wrp->next_state=WRS_PRESENT;
wrp->wrMode=WR_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