This patch adds a new module for slave event monitoring with its own
configuration option, a UDS address. If the option is enabled, then
the monitor will send events to the configured address. The default
setting produces an inactive monitor that does nothing.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Many GPS radios provide both a 1-PPS and time of day information via
NMEA sentences. This patch introduces a ts2phc master that decodes
the "recommended minimum data" sentence, RMC, which provides UTC time
and a validity flag. Together with the file based leap second table,
this sentence provides adequate time of day for determining the time
of the PPS edge.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch introduces a new ts2phc source using a PHC device. There
are multiple use cases for such a master. By connecting pins of two
or more separate PHC devices together, one may act as the source, and
the others may be synchronized to it in hardware. In this way, "just
a bunch of devices" together forms a Transparent Clock. If the master
clock is synchronized to a global time source (like a PPS from a GPS),
then the system becomes a mutli-port Grand Master or a Boundary Clock
with GM capability.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Some PTP Hardware Clocks have input pins that can generate time stamps
on the edges of external signals. This functionality can be used in
various ways. For example, one can synchronize a PHC device to a
global time source by taking a Pulse Per Second signal from the source
into the PHC. This patch adds support for synchronizing one or more
PHC slaves to a given master clock.
The implementation follows a modular design that allows adding
different kinds of master clocks in the future. This patch starts off
with a single "generic" PPS master, meaning a PPS signal that lacks
and time or date information. The generic master assumes that the
Linux system time is approximately correct (by NTP or RTC for example)
in order to calculate the time of the incoming PPS edges.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Balint Ferencz <fernya@gmail.com>
Unfortunately the SNMP code still has issues like not passing the
valgrind test, and no one is able to finish this up right now. This
patch removes the SNMP program so that the upcoming release does not
contain unfinished work, potentially misleading end users about the
scope and completeness of the features.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Many of the users only require a read only reference to the interface name.
This patch adds an appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Any program that links to the servo interface must also link with the
implementations of that interface. Similarly, the filter and network
transport interfaces each require their implementations. This patch
re-factors the makefile to reflect this fact in order to simplify
adding new programs making use of these interfaces.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
The two programs, phc2sys and phc_ctl, use nearly identical subroutines to
open an instance of a dynamic posix clock. In anticipation of yet a third
program with similar needs, this patch refactors the common code into the
utilities.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This adds config option to specify static roles for master and slave
in the Best Master Clock Algorithm. This is the case for Automotive
Profile where networks are mostly static and role for each device is
known in advance.
masterOnly and slaveOnly will be used to determine the roles for the
devices. Since masterOnly is a per-port config and slaveOnly is a global
config option, role assignment will be slightly odd in case of bridges.
If slaveOnly is set to 1, all the ports will be in slave roles except
for the ones where masterOnly is set to 1. These ports will assume the
master role.
Two new FSMs which will be used for master and slave roles for this
config option have also been added.
Signed-off-by: Vedang Patel <vedang.patel@intel.com>
The sub agent use net-snmp library and AgentX protocol for the
communication towards the snmp master agent.
snmpd.c should only include general setup needed for handling snmp.
Supported MIBs should be implemented in separate files.
Makefile will include snmpd if libsnmp is available during compilation.
configs/snmpd.conf should be placed in /etc/snmp/
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
This patch adds new code that handles unicast service contracts,
sending messages according the negotiated schedule.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch adds new code that runs the state machine and handles the
TLVs for requesting unicast service from a remote master.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In order to implement client side unicast negotiation, state is needed
per port and master. This patch adds the needed state machines.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The E2E TC forwards Announce, Delay_Req, Delay_Resp, Management,
Signaling, and Sync messages, and drops P2P Delay messages.
This implementation tracks the GM using the BMCA in order
to syntonize (or possibly even synchronize) with it.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The P2P TC forwards Announce, Management, Signaling, and Sync
messages, consumes P2P Delay messages, and drops E2E Delay messages.
This implementation tracks the GM using the BMCA in order
to syntonize (or possibly even synchronize) with it.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch adds code that sends an event messages received on one port out
all the other ports and calculates the residence time. The correction,
ingress port, and the original message are remembered in a TC transmit
descriptor. These descriptors are recycled in a memory pool in a similar
way to the message buffers.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The first half of the telecom algorithm from G.8275.1 and G.8275.2
differs from the one in 1588, making use of profile specific
"localPriority" attributes.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Use the rtnl_get_ts_device() function to get the name of the slave
interface which will be timestamping PTP packets and use it instead of
the master interface to check the timestamping capabilities and PHC.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
The make install target tries to install a man page that does not
exist. This patch fixes the makefile to install the existing man
pages only.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch adds a new "NSM" program. The new code handles only one
outstanding NSM command at a time. If and when all four event time
stamps have arrived, the code prints the instantaneous estimated
offset without any averaging or smoothing.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch makes the build system less surprising by removing the
executable binaries in the 'clean' target. This behavior is more in
line with the GNU makefile guidelines.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Suggested-by: Manuel Traut <manut@linutronix.de>
This patch adds a source module that implements RT netlink sockets
for the purpose of link monitoring. Unfortunately the netlink API
offers no possibility for per-port notification. Instead it
forces us to use a de-multiplexing pattern.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch introduces generic code for adding and parsing new options.
The public 'get' methods return option values directly. Although the
API is easy to use, it does not provide error checking in case the
option does not exist or if there is a type mismatch.
Therefore the code performs a BIST to ensure that the options are
properly populated. In addition, the code terminates the program in
case of missing options or type mismatches. This heavy handed
approach is meant to catch errors during development and should never
trigger during normal usage.
As a first element, we include an option for specifying the UDP TTL.
Users are required to call 'config_init', and so this patch add that into
all three programs, ptp4l, phc2sys and pmc.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
When running with Synchronous Ethernet (SyncE), the correct clock
frequency is provided by the link partner. In this case, only the
offset needs correcting.
This patch provides SyncE nodes with an way to keep the frequency
correction dialed to zero.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Introduce a time stamp processor for offset/delay calculations and use
it in the clock and port modules.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
timemaster is a program that uses ptp4l and phc2sys in combination with
chronyd or ntpd to synchronize the system clock to NTP and PTP time
sources. The PTP time is provided by phc2sys and ptp4l via SHM reference
clocks to chronyd/ntpd, which can compare all time sources and use the
best sources to synchronize the system clock.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
This is an updated version of a script I wrote a couple years ago for
debugging the PHC when writing a new driver. I figured that it might be
handy for the LinuxPTP project to include, as it can give some insight
into the PHC directly. I have updated it to make use of the shared code
here, in order to reduce duplication. Hopefully this is of some use to
everyone.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.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>
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>
Median filter has an advantage over moving average that it is much less
sensitive to outliers.
For instance, it allows much faster recovery from an external clock
time step which happened between receiving sync message and sending
delay_req message. The measured delay includes a large error, but the
median is still a good estimate of the delay and the first step
correction applied by the servo is right.
In this implementation the median update has linear time complexity.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Similarly to the servo interface, allow multiple filters to be
used for delay filtering. Convert mave to the new interface.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Instead of maintaining a table of precalculated values, use the
newly added set_tmo_random() function to set the delay request timeout.
It saves some memory and improves the timeout granularity, but has a
higher computational cost. It follows the requirements from section
9.5.11.2 of the spec.
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>
This patch introduces a shell script to figure out the proper definitions
for the HAVE_CLOCK_ADJTIME and HAVE_ONESTEP_SYNC macros, as well as the
include path. The intent is to "do the right thing" for three different
user scenarios, namely cross compiling, compiling against a custom kernel,
and using a plain old disto kernel.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
this patch uses grep to test whether the net_tstamp.h header has
HWTSTAMP_TX_ONESTEP_SYNC flag defined. If it doesn't then we can simply define
it with the correct value. This works because proper drivers should just report
that the value is not allowed if they don't support onestep mode. This is the
cleanest way to ensure that linuxptp will still work on kernels which have not
defined the one step flag, and also works for any distributions which backport
the feature.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Ever since upgrading to Debian 7.0, building linuxptp results in an
annoying error message. This is due to the fact that the directory
/usr/include/bits is no longer present, but our makefile expects it
to exist. This patch fixes the issue by telling grep not to complain
about missing files.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Add new options to ptp4l and phc2sys to print summary statistics of the
clock instead of the individual samples.
[ RC - Fix () function prototype with (void).
- Use unsigned for sample counter.
- Fix over-zealous line breaks. ]
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Add a new option to wait for ptp4l to be in a synchronized state.
Periodically check PORT_DATA_SET and wait until there is a port in
SLAVE, MASTER or GRAND_MASTER state. Also, set the default
synchronization offset according to the currentUtcOffset value from
TIME_PROPERTIES_DATA_SET and the direction of the clock synchronization.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>