Commit 63cb8ae9 authored by Alessandro Rubini's avatar Alessandro Rubini

wr-servo: make re-track much faster

There is no need to go to 0 phase at servo init. It is already 0
at the beginning of the world, but on re-track it can be the same
as it was.

With this change, if we loose track due to packet loss and timeout
(thanks to a few commits ago), we recover in 1..4 seconds as opposed
to 5..9 without this commit.

Tested with "fault drop 0 1000" and later "fault drop 0 0", and
a syslog server:

   Jan  1 00:00:10 192.168.16.229 (22:33:44:55:66:77) Node up since 10 seconds
   Mar 14 15:48:55 192.168.16.229 Tracking after 7.178 s
   Mar 14 15:49:07 192.168.16.229 Lost track
   Mar 14 15:49:11 192.168.16.229 2-th re-rtrack after 4.171 s
   Mar 14 15:49:30 192.168.16.229 Lost track
   Mar 14 15:49:32 192.168.16.229 3-th re-rtrack after 2.485 s
   Mar 14 15:49:49 192.168.16.229 Lost track
   Mar 14 15:49:51 192.168.16.229 4-th re-rtrack after 2.559 s
   Mar 14 15:50:13 192.168.16.229 Lost track
   Mar 14 15:50:16 192.168.16.229 5-th re-rtrack after 3.171 s
   Mar 14 15:50:31 192.168.16.229 Lost track
   Mar 14 15:50:32 192.168.16.229 6-th re-rtrack after 1.589 s

With the original commit for this, Adam found that by unplugging
and re-plugging the fiber our setpoint is always increasing, up to big
values. I checked, and the softpll is always using the module. I brought
the phase value up to hundreds of nanos both positive and negative, without
any issues.  So this version of the commit makes a modulus of the set
point, to avoid it getting too big and scare a user watching the logs.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent a72f6bdc
......@@ -159,10 +159,16 @@ int wr_servo_init(struct pp_instance *ppi)
wrp->ops->enable_timing_output(ppi, 0);
strncpy(s->if_name, ppi->cfg.iface_name, sizeof(s->if_name));
s->cur_setpoint = 0;
/*
* Do not reset cur_setpoint, but trim it to be less than one tick.
* The softpll code uses the module anyways, but if we unplug-replug
* the fiber it will always increase, so don't scare the user
*/
if (s->cur_setpoint > s->clock_period_ps)
s->cur_setpoint %= s->clock_period_ps;
wrp->ops->adjust_phase(s->cur_setpoint);
s->missed_iters = 0;
s->state = WR_SYNC_TAI;
s->state = WR_UNINITIALIZED;
s->delta_tx_m = delta_to_ps(wrp->otherNodeDeltaTx);
s->delta_rx_m = delta_to_ps(wrp->otherNodeDeltaRx);
......@@ -436,6 +442,11 @@ int wr_servo_update(struct pp_instance *ppi)
s->state = WR_SYNC_TAI;
else if (ts_offset_ticks) /* not that bad */
s->state = WR_SYNC_NSEC;
else if (s->state == WR_UNINITIALIZED) {
/* Likely a restart; already good, but force phase fsm */
s->state = WR_SYNC_PHASE;
}
/* else, let the states below choose the sequence */
pp_diag(ppi, servo, 1, "wr_servo state: %s%s\n",
......
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