Add weight parameter to the sample function. Samples with smaller weight
are less reliable, they can be ignored by the servo or the adjustments
of the clock can be smaller.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
These settings will be useful for all implemented servos, so move them
to the common servo code to avoid duplication. The configuration options
are renamed, but the they can be still set by their old names.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
The initial check if the clock should be stepped always passed after the
servo was reset (e.g. from clock sanity check). Fix the condition to
step only when the threshold is exceeded.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Store the current frequency and return it when the servo is in unlocked
state instead of zero. This fixes values printed in log messages.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
When the drift value is adjusted by the newly measured frequency offset,
multiply the frequencies instead of adding the measured offset to the
old value to get accurate result even when updating a large drift.
[ RC: use a simpler form of the frequency update calculation. ]
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Instead of using fixed constants, set them by the following formula from
the current sync to allow good performance of the servo even when the
sync interval changes in runtime and to avoid instability.
kp = min(kp_scale * sync^kp_exponent, kp_norm_max / sync)
ki = min(ki_scale * sync^ki_exponent, ki_norm_max / sync)
The scale, exponent and norm_max constants are configurable. The
defaults are chosen so there is no change to the previous default
constants of the servo with one second sync interval. The automatic
adjustment can be disabled by setting the pi_proportional_const and
pi_integral_const options to a non-zero value, but stability of the
servo is always enforced.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
A slow servo (with smaller constants and lower sync rate) needs a
longer, better frequency estimation, but a higher sync rate hardly
needs any estimation at all, since it learns the frequency right away
in any case.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch adds a new servo method to let the algorithm know about the
master clock's reported sync message interval. This information can be
used by the servo to adapt its synchronization parameters.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Current pi servo steps clock without any condition on start.
This patch adds a new servo option "configured_pi_f_offset". The option is similar
to configured_pi_offset but only affects in the first clock update. Therefore,
if this option is set as 0.0, we can prevent clock step on start.
The new servo option can be specified from phc2sys by using -F option.
This feature is usefull when we need to restart phc2sys without system
clock jump. Restarting phc2sys is needed to change its configuration.
changes since v2:
- manual page fix.
- also apply max_offset along with max_f_offset in servo step1.
- add a variable to check if first update is done.
changes since v1:(http://sourceforge.net/mailarchive/message.php?msg_id=31039874)
- remake as a new servo option.
Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
The option sets an additional limit to the hardware limit. It's disabled
if set to zero. The default is 900000000 ppb.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Before calculating the clock drift in the PI servo, make sure
the first sample is older than the second sample to avoid getting
invalid drift or NaN.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Similarly to the servo in phc2sys, when clock is stepped, set
immediately also its frequency. This significantly improves the initial
convergence with large frequency offsets.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Current date stored in nanoseconds doesn't fit in 64-bit double format.
Keep the offset and the time stamp in integer nanoseconds.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Make it easier to find out the compiled-in defaults in the code
and set all options in default.cfg.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
this patch modifies the pi servo to add a configurable max offset (default
infinity). When ever the detected offset is larger than this value, the clock
will jump and reset the servo state. The value of this feature is for decreasing
time to stabalize when clock is off by a large ammount during late running. This
can occur when the upstream master changes, or when the clock is reset due to
outside forces. The method used to reset clock is simply to reset the pi servo
to the unlocked state.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
If software time stamping is to be used, then the servo will want to
have appropriate filtering.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>