Commit Graph

67 Commits (72a92126009f81d64d58500a8784786e3c525076)

Author SHA1 Message Date
Miroslav Lichvar e63a6ea89b Adjust tick length with system clock.
This increases the maximum frequency adjustment of the system clock
from 500 ppm to 10%.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-04 14:36:35 +01:00
Miroslav Lichvar ed379b4028 Add clock sanity check.
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>
2013-10-27 08:24:01 +01:00
Ken ICHIKAWA b943ea2fba phc2sys: Fix lower bound value of update_rate
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>
2013-09-04 18:11:24 +02:00
Richard Cochran b0d789a73e pmc: optional legacy zero length TLV for GET actions.
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>
2013-07-22 21:47:28 +02:00
Miroslav Lichvar 639ebbca13 phc2sys: Set servo sync interval.
[RC: merged servo_sync_interval signature change with earlier patch]

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-07-14 21:37:53 +02:00
Ken ICHIKAWA 28b8dc9996 Add a new servo option which specifies first step threshold
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>
2013-06-21 07:27:11 +02:00
Libor Pechacek daca2773de phc2sys: common code exit point for bad usage case
Removed duplicate calls to usage() by providing common exit point for the case.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
2013-06-18 17:51:21 +02:00
Ken ICHIKAWA 74e703727e ptp4l and phc2sys: Get argument values with strict error checking
Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-06-04 20:16:22 +02:00
Libor Pechacek a29b3bc4f9 phc2sys: Require either -O or -w on command line
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>
2013-06-03 15:59:01 +02:00
Jacob Keller 2a89756654 phc2sys: update usage/error reporting
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>
2013-05-16 19:58:23 +02:00
Jacob Keller 73105bc65a phc2sys: update open_clock and deprecate '-i' option
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>
2013-05-16 19:58:23 +02:00
Richard Cochran 3ae0ff1f44 phc2sys: Use nanosleep instead of usleep.
[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>
2013-05-16 14:49:20 +02:00
Miroslav Lichvar 9c83fcb3c9 phc2sys: Change update rate parameter to floating-point.
This allows update intervals longer than 1 second.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-05-10 09:44:59 +02:00
Miroslav Lichvar 3414d99609 phc2sys: Use currentUtcOffset only with PTP timescale.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-05-10 08:16:57 +02:00
Jiri Benc 4004273cd8 phc2sys: enable PPS output from PHC
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>
2013-04-19 17:52:25 +02:00
Miroslav Lichvar 4929d50a3f Let kernel synchronize RTC to system clock.
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>
2013-04-09 07:08:45 +02:00
Miroslav Lichvar 7b162c4821 clockadj: Remove clkid parameter from set_leap function.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-09 07:08:44 +02:00
Miroslav Lichvar 24c4e851fc phc2sys: Add option to set domain number.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-09 07:08:44 +02:00
Miroslav Lichvar d5cf47f7f6 phc2sys: Use phc_open().
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-09 07:08:44 +02:00
Miroslav Lichvar 5835effd2a phc2sys: Don't try PTP_SYS_OFFSET with system clock as source.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-09 07:08:44 +02:00
Miroslav Lichvar e3f57d1579 phc2sys: Read maximum frequency adjustment.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-09 07:08:44 +02:00
Miroslav Lichvar fce0aa0a2f Fix compiler warnings with -O2.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-05 09:14:29 +02:00
Ken ICHIKAWA 5d7e1b0f18 phc2sys: add help messages for -l, -m and -q
This patch adds help messages for -l, -m and -q options.
Also it swaps -h for -v because ptp4l's help is this order.

Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-03-28 07:10:35 +01:00
Miroslav Lichvar 4e24248a71 Add options to not apply leap seconds in kernel.
Add kernel_leap option for ptp4l and -x option for phc2sys to disable
setting of the STA_INS/STA_DEL bit to slowly correct the one-second
offset by servo.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-03-20 19:37:40 +01:00
Miroslav Lichvar eb93926bc9 phc2sys: Handle leap seconds.
Update the currentUtcOffset and leap61/59 values at one minute
interval. When a leap second is detected, set the STA_INS/STA_DEL
bit for the system clock.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-03-20 19:37:39 +01:00
Miroslav Lichvar a29b1a4105 Move clock_adjtime wrapping to clockadj.c.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-03-20 19:37:39 +01:00
Miroslav Lichvar 58b1f3f37d phc2sys: Update sync offset periodically with -w.
Modify the pmc to allow non-blocking operation. Run it on each clock
update to have the sync offset updated from currentUtcOffset with every
other call.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-03-20 19:37:39 +01:00
Miroslav Lichvar 7d8f31da45 Change stats max_count variables to unsigned.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-12 19:59:50 +01:00
Miroslav Lichvar 3136e3e46c Add summary statistics.
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>
2013-02-09 10:09:25 +01:00
Miroslav Lichvar 42b305478d phc2sys: Print clock reading delay.
If the delay is known, print it together with the offset and frequency.
Remove the time stamp from the output to fit it into 80 chars.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-08 18:41:34 +01:00
Miroslav Lichvar cb5ebd9b24 Change label of frequency offset.
Change the label of the frequency offset in the clock messages printed
by ptp4l and phc2sys from "adj" to "freq" to indicate it's a frequency
value.

Also, modify clock_no_adjust() to print the frequency offset instead of
the ratio and use PRId64 instead of lld to print int64_t values.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-08 18:41:34 +01:00
Miroslav Lichvar 9e7517a31a Remove trailing whitespaces.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-06 19:30:02 +01:00
Miroslav Lichvar 158daa697d phc2sys: Use printing facility.
Use pr_* functions to print messages and add -m, -q, -l options to allow
configuration of the printing level and where should be the messages sent.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-06 19:30:01 +01:00
Miroslav Lichvar 11fa191505 phc2sys: Open PPS device sooner.
Possible error messages should be printed before waiting on ptp4l.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-06 19:30:01 +01:00
Miroslav Lichvar ecbbf4cdb1 Move Unix domain sockets to /var/run.
According to FHS, /var/run is the right place for them.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-06 19:30:01 +01:00
Miroslav Lichvar 09fdc45220 phc2sys: Add option to set step threshold.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-06 19:30:01 +01:00
Richard Cochran f530ae9333 Hide the grandmaster port state.
There really is no such state, but there probably should have been one.
In any case, we do have one just to make the code simpler, but this should
not appear in the management responses. This patch fixes the issue by
covering over our tracks before sending a response.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-06 13:34:49 +01:00
Miroslav Lichvar 74692bb1b0 phc2sys: include PTP management client.
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>
2013-02-03 19:08:34 +01:00
Miroslav Lichvar 24a1a6a81e phc2sys: allow PPS loop only with system clock.
The PPS time stamps are always made by the system clock, don't allow
running the PPS loop with other clocks.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-01-18 07:11:19 +01:00
Miroslav Lichvar c5ce4ef764 phc2sys: read PHC with each PPS sample.
In the PPS loop, instead of setting the system clock from the PHC only
once on start, read PHC with each PPS sample and use the time stamp to
get the whole number of seconds in the offset. This will prevent phc2sys
from losing track of the system clock.

Also, check if the PPS is synchronized to the PHC.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-01-18 07:11:19 +01:00
Miroslav Lichvar f09b4bb7e3 phc2sys: remove unnecessary clock step with non-PPS loops.
With non-PPS loops let the servo make the inital correction. Move the
code to the PPS loop and change it to use the sample filtering to reduce
the error in the initial correction.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-01-16 20:28:22 +01:00
Miroslav Lichvar fc1a695493 phc2sys: don't zero clock frequency on start.
Instead of always starting at zero frequency offset, read the currently
stored value on start and pass it to the servo. As the read may silently
fail and return zero, set the clock frequency back to the read value to
make sure it's always equal to the actual frequency of the clock.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-01-16 20:28:21 +01:00
Miroslav Lichvar 2d4b2f1640 phc2sys: move phc loop to its own function.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-01-16 20:28:21 +01:00
Miroslav Lichvar 627bc0fdf7 phc2sys: use servo code from ptp4l.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-01-16 20:28:21 +01:00
Miroslav Lichvar 3d4ff7882f phc2sys: check that specified interface has a PHC. 2012-12-18 18:52:02 +01:00
Miroslav Lichvar 84c7ac6b52 Fix -Wformat warnings. 2012-12-18 18:52:02 +01:00
Richard Cochran 39e8ee0642 Add command line options to print the software version.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-10 15:11:51 +01:00
Richard Cochran 4ef70c3d2e phc2sys: use the system offset method if available
We use the PTP_SYS_OFFSET ioctl method in preference to doing
clock_gettime from user space, the assumption being that the kernel space
measurement will always be more accurate.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-29 17:43:51 +01:00
Jacob Keller 004b62d22b sk: change sk_interface_phc to sk_get_ts_info
this patch changes sk_interface_phc to sk_get_ts_info, by allowing the function
to store all the data returned by Ethtool's get_ts_info IOCTL in a struct. A new
struct "sk_ts_info" contains the same data as well as a field for specifying the
structure as valid (in order to support old kernels without the IOCTL). The
valid field should be set only when the IOCTL successfully populates the fields.

A follow-on patch will add new functionality possible because of these
changes. This patch only updates the programs which use the call to perform the
minimum they already do, using the new interface.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-11-14 20:22:10 +01:00
Miroslav Lichvar 1a83619b17 phc2sys: add option to set slave-master time offset.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2012-11-08 18:17:31 +01:00