Send peer delay requests continuously in P2P mode.

When a port makes a transition from one state to another, it resets all of
the message timers. While this is the correct behavior for E2E mode, the
P2P mode requires sending peer delay requests most of the time.

Even though all the other timer logic is identical, still making an
exception for P2P mode would make the code even harder to follow. So this
patch introduces two nearly identical helper functions to handle timer
reprogramming during a state transition.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
phc2sys: Add option to set step threshold.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
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>
pmc: Allow commands on command line.

Add a batch mode, where the commands are taken from the command line
instead of the standard input.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
phc2sys: Open PPS device sooner.

Possible error messages should be printed before waiting on ptp4l.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
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>
Print messages with level below LOG_NOTICE to stderr.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Check sample time stamps in drift calculation.

Before calculating the clock drift in the PI servo, make sure
the first sample is older than the second sample to avoid getting
invalid drift or NaN.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Update comment in pi.c.

This was missed in commit d8cb9be46a225a159168581531d401fa2eff8c68.

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

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