Add PHC refclock driver

Implement a driver which allows using PTP hardware clock (PHC) as a
reference clock. It uses the PTP_SYS_OFFSET ioctl or clock_gettime()
to measure the offset between the PTP clock and the system clock. Ten
readings are made for every driver poll and the fastest one is returned.

As PHCs are typically kept in TAI instead of UTC, it's necessary to set
the TAI/UTC offset manually by the offset option. This could be improved
by obtaining the offset automatically from the right/UTC timezone.
This commit is contained in:
Miroslav Lichvar
2013-08-14 18:13:39 +02:00
parent b5658f4d9c
commit 1d289787b6
5 changed files with 227 additions and 3 deletions

View File

@@ -2462,7 +2462,7 @@ can function as a stratum 1 server. They are specified by the
@code{refclock} directive. It has two mandatory parameters, a refclock driver
name and a driver specific parameter.
There are currently three drivers included:
There are currently four drivers included:
@table @code
@item PPS
@@ -2512,6 +2512,17 @@ protocol. The path where the socket should be created is described in the
refclock SOCK /var/run/chrony.ttyS0.sock
@end example
@item PHC
PTP hardware clock (PHC) driver. The parameter is the path to the device of
the PTP clock, which can be synchronised by a PTP daemon (e.g. @code{ptp4l}
from the @uref{http://linuxptp.sourceforge.net/, Linux PTP project}. The PTP
clocks are typically kept in TAI instead of UTC. The @code{offset} option can
be used to compensate for the current UTC/TAI offset. For example:
@example
refclock PHC /dev/ptp0 poll 3 dpoll -2 offset -35
@end example
@end table
The @code{refclock} command also supports a number of subfields (which