When running a "jbod" Boundary Clock, as long as we have one slaved port,
we always want the clocks on the other ports to be synchronized, regardless
of their port state.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Jiri Benc <jbenc@redhat.com>
The reconfigure function is missing a check whether state for the given
clock actually changed or not. This caused state for all unchanged ports to
be zeroed.
Reported-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Instead of setting it to the PTP domain number, add a new option to
ptp4l and phc2sys to set it as needed. The default value is 0. This
allows multiple ptp4l/phc2sys instances running in the same domain.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
In pmc and phc2sys handle terminating signals and close the UDS
transport before exit to remove the sockets in /var/run.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Always disable the clock sanity check when the ntpshm servo is used,
because it doesn't know when or how is the clock adjusted. Disable also
the kernel leap option as the process controlling the clock is
responsible for setting the kernel flag.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Introduce a new function to inform the servo about upcoming leap second.
This is used when the kernel leap is disabled to allow the servo to
handle better the sudden 1 second step in the offset when the leap
second is inserted or deleted.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
After moving the leap second check away from update_pmc(), the time
stamp is used only to control the pmc update interval. Switch to
CLOCK_MONOTONIC to keep the interval stable when CLOCK_REALTIME is
stepped.
When synchronizing the system clock and the PTP UTC offset is valid and
traceable, set the TAI offset of the clock to have correct CLOCK_TAI
(which is implemented in the kernel as CLOCK_REALTIME + TAI offset).
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
This simplifies passing of pending leap seconds to the clocks and it
will also allow to apply leap second to other clocks than system clock
if needed in future.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
This is a simple servo that provides the NTP SHM reference clock. It
doesn't make any clock adjustments and it always returns with the
unlocked state. It writes all samples to the SHM segment and another
process (e.g. chronyd or ntpd) is needed to read the samples and
actually synchronize the clock. The SHM segment number is set to the PTP
domain number to allow multiple SHM reference clocks running at the same
time.
This is mainly useful when other time sources are available on the
system (e.g. NTP, hardware reference clocks, or other PTP domains)
and a fallback to/from PTP is needed.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
When grandmaster does not use PTP timescale but the previous one did, we
need to reset sync offset and leap flag.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
By default, do not synchronize CLOCK_REALTIME. To do it, -r option is
needed. That will only consider CLOCK_REALTIME as the destination. To
consider it also as a possible time source, use -rr.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Recognize errors returned in MANAGEMENT_ERROR_STATUS TLV and return
a distinct value from run_pmc in case such error is received.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Add support for subscribing to events (run_pmc_subscribe) and receiving and
handling of received events (run_pmc_events).
Add initial support for port status changes.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Do not call clock_open to open a clock device but let clock_add do that and
return the newly created struct. Also, store the device (interface) name in
struct clock.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
This just moves code around to have related functions together and forward
declaration at the beginning of the file. No code changes.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
For now, only CLOCK_REALTIME can be UTC. This may stay this way forever but
now we have a clean separation between codepaths where CLOCK_REALTIME is
required and codepaths any UTC clock should take.
The main motiviation behind this change is removal of sync_offset_direction.
It has to be computed on the fly based on the source and destination when we
have multiple clocks supported and automatic following of ptp4l state
changes implemented.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Split members that apply to all synchronized clocks and members that apply
to an individual clock. Keep all clocks in a list, with a pointer to the
source clock. This will allow to support multiple clocks synchronization.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Split the generic (global) part of update_sync_offset and the part that
affects individual clocks. This is in preparation for phc2sys handling
synchronization of more clocks.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Make run_pmc usable for any kind of management message. Create wrappers for
waiting for ptp4l and for getting UTC offset.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Most PHC drivers implement stepping (ADJ_SETOFFSET) by reading the
clock, adjusting the value by the offset and writing it back. This is
not perfectly accurate and if the operation is slow (e.g. due to PCIe
latencies), the error can be in microseconds.
Increase the default first step threshold from 100 nanoseconds to 20
microseconds to step only when the initial offset is larger than
the error in the step.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
This servo uses linear regression to estimate current time and
frequency error. The number of points used in the regression is
variable (from 4 to 64 in powers of 2) and is selected by a long-term
statistic of the prediction error.
Future improvements could include tracking of sudden frequency changes
(e.g. due to temperature variations), better stability of the error
statistic when a large offset is corrected, options to set the speed of
the adaptation, minimum and maximum number of points, or an option to
prefer frequency accuracy over time accuracy.
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>
Check the sanity of the synchronized clock by comparing its uncorrected
frequency with the system monotonic clock. When the measured frequency
offset is larger than the value of the sanity_freq_limit option (20% by
default), a warning message will be printed and the servo will be reset.
Setting the option to zero disables the check.
This is useful to detect when the clock is broken or adjusted by another
program.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Following command produces unexpected update rate.
# phc2sys -s eth0 -q -m -O0 -R1.0842021724855044e-19
This is caused by wrong validation of phc_interval related to
significant digits of double precision and phc_interval_tp.tv_sec
overflow.
To avoid these unwanted trouble, this patch limits lower bound of
phc_rate to 1e-9.
There is no profound meaning in the lower bound value. I just think
it's enough to actual use and it doesn't cause phc_interval_tp.tv_sec
overflow in not only 64bit environment but also 32bit environment.
Thereby, messy validation of phc_interval is no longer needed.
Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
This patch makes the original behavior of sending the
TLV values for GET actions with a length of zero.
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 default zero offset can lead to misalignment between system clocks or wrong
time to be broadcast to the domain. Therefore we require setting offset upon
invocation.
Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
This patch updates phc2sys usage reporting to give a slightly better indication
of why the program was unable to run.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
This patch modifies phc2sys to enable the use of interface names in clock_open
rather than having to do that by hand. This enables cleaner use of the -s and -c
options as they can accept interface names. This also enables the user to set
the slave clock by network interface as well.
-v2-
* fix clock_open as it used device instead of phc_device in the final call to phc_open
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
[RC: use CLOCK_MONOTONIC as suggested on the list.]
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
PPS output from a PHC has to be enabled by PTP_ENABLE_PPS ioctl. Call
the ioctl when both PHC device and PPS device are specified and PPS is
supported by the PHC.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Reset the STA_UNSYNC flag and maxerror value with every frequency update
to let the kernel synchronize the RTC to the system clock (11 minute mode).
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>