Commit Graph

2 Commits (master)

Author SHA1 Message Date
Vladimir Oltean 703c3c7bc7 ts2phc: create a private data structure
Eliminate the ad-hoc use of global variables in the ts2phc program by
introducing one data structure that incorporates them. This might make
the code more understandable to people coming from a kernel background,
since it resembles the type of data organization used there. It is also
now closer to the data organization of phc2sys, a similar program in
both purpose and implementation.

The reason why this is needed has to do with the ts2phc polymorphism for
a PPS master.

In the next patches, PPS masters will expose a struct clock, which will
be synchronized from the main ts2phc.c.

Not all PPS masters will expose a clock, only the PHC kind will. So the
current object encapsulation model needs to be loosened up little bit,
because the main ts2phc.c needs to synchronize a list of clocks, list
which is populated by the slaves and the masters which are capable of
being synchronized.

So instead of having the translation modules of ts2phc communicate
through global variables, let's make struct ts2phc_private the common
working space for the entire program, which is a paradigm that is more
natural.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
2020-08-30 02:28:04 +03:00
Richard Cochran 1bdc9143aa Introduce the ts2phc program.
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>
2020-05-07 14:57:47 -07:00