hwstamp_ctl: explain ERANGE error better

ERANGE is used by the kernel to indicate the hardware does not support the
requested time stamping mode. Explain this error to the user.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Enable LOG_MIN_PDELAY_REQ_INTERVAL management request

Why don't you enable LOG_MIN_PDELAY_REQ_INTERVAL management request?
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>
Distinguish between ignored and malformed packets

When there is a peer speaking PTPv1 in the network we want to silently ignore
the packets instead of flooding system log with error messages.  At the same
time we still want to report malformed packets.  For that we reuse standard
error numbers and do more fine-grained error reporting in packet processing
routines.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
Add a clock method to update the time properties data set.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Let a slaved port update the time properties on every announce message.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
ptp4l: Set clock frequency on start.

Due to a bug in older kernels, frequency reading may silently fail and
return 0. Set the frequency to the read value to make sure the servo
has the actual frequency of the clock.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
ptp4l: Read system clock maximum frequency adjustment.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Fix compiler warnings with -O2.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Apply utc offset correction even when free running.

When using software time stamping and a free running clock, the
statistics appear to be off by the TAI offset. This patch fixes the
issue by setting the internal UTC timescale flag in such cases.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
ptp4l: Use poll() instead of a try-again loop

This patch modifies sk_receive in order to use poll() on POLLERR instead of the
tryagain loop as this resolves issues with drivers who do not return timestamps
quickly enough. It also resolves the issue of wasting time repeating every
microsecond. It lets the kernel sleep our application until the data or timeout arrives.

This change also replaces the old tx_timestamp_retries config value with
tx_timestamp_timeout specified in milliseconds (the smallest length of time poll
accepts). This does have the side effect of increasing the minimum delay before
missing a timestamp by up to 1ms, but the poll should return sooner in the
normal case where a packet timestamp was not dropped.

This change vastly improves some devices and cleans the code up by simplifying a
race condition window due to drivers returning tx timestamp on the error queue.

[ RC - removed the unused 'try_again' variable. ]

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
clockadj: make Doxygen comment by using two stars.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
clockadj: remove useless clockid parameter.

The clockid parameter to the function to get the system clock's maximum
adjustment is redundant, so let us just remove it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
phc2sys: Read maximum frequency adjustment.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
phc2sys: Don't try PTP_SYS_OFFSET with system clock as source.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
phc2sys: Use phc_open().

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
phc2sys: Add option to set domain number.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
clockadj: Remove clkid parameter from set_leap function.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
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>
Add option to set maximum frequency adjustment.

The option sets an additional limit to the hardware limit. It's disabled
if set to zero. The default is 900000000 ppb.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>