Commit Graph

1018 Commits (e5ba2dae5f102a66e152b96f9cc7b06aff4b90b5)

Author SHA1 Message Date
Richard Cochran bbbc0cd451 pmc: require a configuration for creating a PMC instance.
In the near future, the transports will need to consult the configuration
database in order to obtain various options.  This patch also introduces
the idea of a configuration file into the phc2sys and pmc programs.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-16 11:20:23 +02:00
Richard Cochran b297f22a82 clock: add a method to obtain the configuration.
This function allows the ports to read configuration variables without
changing the port method signatures.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-16 11:20:23 +02:00
Richard Cochran 1579b7893b clock: store the configuration in the clock data structure.
This will help us to simplify the passing of parameters between the main
program. clock, and ports.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-16 11:20:23 +02:00
Richard Cochran ae09c1c4c0 Add a configuration option to use the "nullf" servo.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-07-24 22:17:09 +02:00
Richard Cochran fa79141211 Add a servo that inhibits all frequency adjustment
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>
2015-07-24 22:17:09 +02:00
Richard Cochran 3e1e894d22 pmc: support setting the priority attributes.
This patch lets the pmc program change the priority1 and priority2
elements of the "default data set" at run time.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-07-24 21:59:43 +02:00
Richard Cochran 2318432b94 clock: support management SET of the priority attributes.
This patch adds support for changing the priority1 and priority2
elements of the "default data set" at run time.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-07-24 21:59:43 +02:00
IOhannes m zmölnig 572438b85e install into DESTDIR
and use 'install' throughout (rather than 'mkdir')

Signed-off-by: IOhannes m zmölnig <zmoelnig@umlaeute.mur.at>
2015-06-08 14:46:37 +02:00
IOhannes m zmölnig 0e1b25176d fixed hyphen/minus signs in groff
in manpages, the '-' denotes a hyphen.
for a proper minus, we need to write '\-'

Signed-off-by: IOhannes m zmölnig <zmoelnig@umlaeute.mur.at>
2015-06-08 14:46:37 +02:00
IOhannes m zmölnig 6415f56acb fixed spelling: "MANAGEMENT"
rather than "MANAGMENT"

Signed-off-by: IOhannes m zmölnig <zmoelnig@umlaeute.mur.at>
2015-06-08 14:46:37 +02:00
IOhannes m zmölnig bb88fb1117 Explain how to contribute patches
Make the workflow of contribution (creating patches, submitting,
reviewing) explicit.

Signed-off-by: IOhannes m zmölnig <zmoelnig@umlaeute.mur.at>
2015-06-08 14:45:09 +02:00
Miroslav Lichvar 0ee9b9000f timemaster: kill processes by PID instead of process group.
Instead of killing the whole process group, which may contain other
processes than timemaster and its children (e.g. when it is started from
a shell script), save the PIDs and kill the processes individually.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-05-14 15:08:31 +02:00
Miroslav Lichvar 32689328f1 pi: use sample weight.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar 5d6c3433f7 linreg: use sample weight.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar f0b0c1116a servo: add support for weighted samples.
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>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar 06fcfe123c tsproc: add raw and weighting modes.
Add new time stamp processing modes to return raw delay and offset based
on the raw delay instead of the long-term filtered delay, and to return
also a weight of the sample. The weight is set to the ratio between the
two delays. This gives smaller weight to samples where the sync and/or
delay messages were delayed significantly in the network and possibly
include a large error.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar c452e862dd Refactor time stamp processing.
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>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar 6813fd7c3d Convert and correct time stamps early.
Convert time stamps to tmv_t and apply all corrections before passing
them to clock/port functions to reduce the number of parameters.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar 09e5e6e934 phc2sys: don't synchronize clock to itself in automatic mode.
When no source is found in the automatic mode and a clock is selected as
the default source, set its state temporarily to slave to prevent the
clock from being synchronized to itself and drifting quickly away.

Also, don't use this mode with only one PTP clock and don't include the
system clock.

This fixes phc2sys with SHM servo (e.g. used by timemaster).
2015-02-11 17:26:07 +01:00
Miroslav Lichvar e9ac26f909 timemaster: set mode in ntp config to create private SHM segments.
In ntp-4.2.8p1 the segment access was made configurable with the
refclock mode option. Set the mode to 1 to create all SHM segments
with owner-only access.
2015-02-09 22:03:39 +01:00
Richard Cochran a1e2a08b4e Version 1.5
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-23 12:37:36 +01:00
Richard Cochran 2ab2fbbdda phc2sys: default to the first clock in automatic mode.
If we have clocks to synchronize but no source, just pick the last one in
the list, which is the first one from the ptp4l command line.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-18 11:38:00 +01:00
Richard Cochran e1ea4ea810 phc2sys: automatic mode: synchronize all non-slave ports.
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>
2014-12-18 11:38:00 +01:00
Richard Cochran e706f48981 port: allow running a boundary clock with multiple clock devices.
If the user has configured the appropriate option, then simply warn
about the clock device mismatch, and then go on in "JBOD" mode.
Whenever the port enters the uncalibrated state, it tells the clock
to switch to the new PHC device.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-18 11:38:00 +01:00
Richard Cochran a96797a7fc clock: Introduce a function to switch the PTP Hardware Clock.
When switching clock devices in JBOD mode, we need to be able to reset the
servo. The existing servo_reset() function will not serve us well, because
in this case we also need to seed the existing frequency offset and limit.
This patch adds a new method that simply starts the servo from scratch.

In the unlikely event of a resource allocation failure, the method will
simply continue to use the previous device, which is better than nothing
and certainly preferable to bailing out the program.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-17 16:15:25 +01:00
Richard Cochran d70d38ade3 config: add a option to enable a poor man's boundary clock.
This patch adds a configuration option that allows running a boundary clock
using "just a bunch of devices". Normally each port is probed to make sure
they all share the same PTP hardware clock, but this option will allow a
heterogeneous collection of devices, should the user really want it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Jiri Benc <jbenc@redhat.com>
2014-12-16 21:33:23 +01:00
Richard Cochran 017235f881 port: correct transmit and receive time stamps for their calibrated delays.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-12 21:44:56 +01:00
Richard Cochran 53a08ec4df config: Introduce options for correcting transmit and receive delays.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-12 21:44:56 +01:00
Richard Cochran ef49629387 Invoke the clock check even if the time stamp nanoseconds field is zero.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-12 21:44:56 +01:00
Richard Cochran b295df24b5 Introduce a helper function to identify valid (non-zero) time stamps.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-12 21:44:56 +01:00
Richard Cochran 4fb0346520 Add a bunch more drivers into the support matrix.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-11-30 21:24:29 +01:00
Miroslav Lichvar 37459fd1ad linreg: fix servo resetting
The stats for the maximum size were not reset, which caused the
the servo to reuse old data instead of returning with unlocked
state.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-11-20 20:15:34 +01:00
Jiri Benc 7455c24148 phc2sys: fix overwriting of the clock state
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>
2014-11-18 15:58:25 +01:00
Richard Cochran 7144aa9263 config: remove useless parameter.
The 'cfg' passed to parse_port_setting() is never used, so just remove it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-11-07 19:47:37 +01:00
Richard Cochran 5b36399e35 trivial: update gitignore with the timemaster build product.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-11-07 19:47:37 +01:00
Richard Cochran a4264b3e6e trivial: do not assign a FP constant to an integer.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-11-07 19:47:36 +01:00
Richard Cochran 8e8a989720 Coding style: add missing break statement from a switch/case construct.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-11-07 19:47:36 +01:00
Richard Cochran a5911e69c7 Use SO_SELECT_ERR_QUEUE when available.
The current implementation fetches a transmit time stamp by polling on the
socket with pollfd.events set to zero, and then checking if POLLERR has
been returned by the kernel in pollfd.revents. This has the unfortunate
side effect of sleeping in poll() for the entire time out duration,
regardless of when the error queue becomes readable.

Linux kernel version 3.10 introduced a new socket option that allows
polling for transmit time stamps explicitly, waking the process as soon as
a time stamp becomes available. This patch enables the socket option,
falling back to the old behavior if necessary.

Suggested-by: Joe Schaack <jschaack@xes-inc.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-11-07 19:47:36 +01:00
Miroslav Lichvar 50d5c63e16 clock: keep ports in specified order.
When adding a new port, put it at the end of the list instead of head.
This restores the order of received management messages as was before
commit 08575133.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-11-07 18:57:40 +01:00
Miroslav Lichvar 594f59c50d port: fix fda initialization.
Initialize all descriptors to prevent polling invalid descriptors from
faulty ports.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-11-07 18:57:05 +01:00
Richard Cochran 6b05b4e7d3 Restore the peer addresses in P2P mode.
Commit ea7a7882 removed the calls to transport_peer(), inadvertently
substituting them with transport_send(), resulting in PDelay messages
being sent with an incorrect destination address.

This patch fixes the issue by introducing peer_prepare_and_send(),
analogous to the port_prepare_and_send() function.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Jiri Benc <jbenc@redhat.com>
2014-10-11 21:03:27 +02:00
Miroslav Lichvar 82f13c594a Add timemaster.
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>
2014-10-03 14:25:19 +02:00
Miroslav Lichvar 2098d7c162 Add string and pointer array utility functions.
Add some functions to work with strings and arrays of pointers that will
be useful later.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-10-03 14:25:19 +02:00
Miroslav Lichvar 48046e593e Don't include config.h in util.h
The config module is used by ptp4l only, but util is shared with other
programs.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-10-03 14:25:19 +02:00
Miroslav Lichvar aa24ba58e1 Don't print messages in signal handler.
Only reentrant functions should be called here.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-10-03 14:25:19 +02:00
Richard Cochran e5f20ea6df Merge Jiri's Dynamic port allocation series. 2014-09-21 19:40:49 +02:00
Jiri Benc 5e0196d647 Dynamic allocation of interface config entries
Remove the limit of MAX_PORTS ports also when parsing command line
arguments.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc c017adc8d1 Remember last used port number
For the ports to be truly created and removed dynamically, the last used
port number has to be remembered by the clock and used for port creation.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc 83f637fb8e Lazy regeneration of pollfd
There's no need to regenerate pollfd multiple times during batches of port
operations (like creating of the clock). Just be lazy and regenerate it only
once it's needed.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc 08575133b3 Dynamic port allocation
Remove the limit of MAX_PORTS ports (default 8) and keep the ports in
a linked list. This allows ptp4l to be used on large machines and in the
future, it will allow dynamic adding and removing of ports while ptp4l is
running.

For this to work, pollfd needs to be dynamically allocated. Changed pollfd
handling from clock_install_fda/clock_remove_fda to notification
(clock_fda_changed), where the clock will rebuild pollfd by querying all its
ports.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00