Commit Graph

1249 Commits (226c285ec42241d2133877346563353f9849274f)

Author SHA1 Message Date
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
Jacob Keller 5bf265e860 missing: add onestep sync to missing.h
this patch uses grep to test whether the net_tstamp.h header has
HWTSTAMP_TX_ONESTEP_SYNC flag defined. If it doesn't then we can simply define
it with the correct value. This works because proper drivers should just report
that the value is not allowed if they don't support onestep mode. This is the
cleanest way to ensure that linuxptp will still work on kernels which have not
defined the one step flag, and also works for any distributions which backport
the feature.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2013-09-04 18:05:43 +02:00
Richard Cochran b7ebfab0cc Add a configuration file option for the extra sync-fup check.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-08-29 11:23:48 +02:00
Richard Cochran 7b7e046e91 Add an optional extra check on sync and follow up message ordering.
Because of packet reordering that can occur in the network, in the
hardware, or in the networking stack, a follow up message can appear
to arrive in the application before the matching sync message. As this
is a normal occurrence, and the sequenceID message field ensures
proper matching, the ptp4l program accepts out of order packets.

This patch adds an additional check using the software time stamps
from the networking stack to verify that the sync message did arrive
first. This check is only useful if the sequence IDs generated by
the master might possibly be incorrect.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-08-29 11:22:25 +02:00
Richard Cochran f299b6fb07 Announce master ambitions right away.
This patch lets a port send the first announce message one millisecond
after the port state transition, rather than waiting one announce interval.
This change is needed because it is desirable to reconfigure the time
network without delay, especially in P2P mode.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-08-26 18:30:54 +02:00
Richard Cochran c6e046e2a2 Add a configuration file option for the sync receive timeout.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-08-26 18:30:54 +02:00
Richard Cochran 7eef4101c9 Add a timer implementing the sync receive timeout.
This patch adds a new timer for use in 802.1AS-2011 applications. When
running as a slave in gPTP mode, the program must monitor both announce
and sync messages from the master. If either one goes missing, then we
trigger a BMC election. The sync timeout is actually reset by a valid
sync/follow up pair of messages.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-08-26 18:30:54 +02:00
Richard Cochran 329e4a2fff Rename the timer for sending sync messages.
This patch renames the per-port timer in order to make room in the
namespace for a timer that detects a sync message input timeout.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-08-26 14:45:21 +02:00
Richard Cochran 7e69672a88 Enforce the absolute lower limit for the announce receipt timeout.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-08-26 14:45:21 +02:00
Richard Cochran 78d3669b06 Inhibit lost link recovery in P2P mode.
The closing and reopening of the transport when in slave only mode is not
necessary if the port is using the peer delay mechanism. In that case, the
port will discover the network error by transmitting a peer delay request.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-08-26 14:42:27 +02:00
Delio Brignoli b268cf048b Do not qualify announce messages with stepsRemoved >= 255
See IEEE1588-2008 section 9.3.2.5 (d)

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-08-23 08:21:00 +02:00
Miroslav Lichvar ad1b14e126 Fix port numbering in clock log messages.
Add 1 to port numbers printed in the log messages to make them
consistent with messages from port.c. The port number 0 is the UDS port,
which is last in the clock->port array.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-08-23 08:18:39 +02:00
Miroslav Lichvar 011ba7b455 Use freeifaddrs() to free data from getifaddrs().
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-08-20 20:00:09 +02:00
Richard Cochran 6bcda22752 Version 1.3
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-08-02 11:24:40 +02:00
Richard Cochran 7be0698175 Fix bug in unlucky sync/follow up handling.
Ken Ichikawa has identified a situation in which a sync message can be
wrongly associated with a follow up after the sequence counter wraps
around.

   Port is LISTENING
   Sync (seqId 0) : ignored
   Fup  (seqId 0) : ignored
   Sync (seqId 1) : ignored
   Port becomes UNCALIBRATED here
   Fup  (seqId 1) : cached!
   Sync (seqId 2) : cached
   Fup  (seqId 2) : match
   Sync (seqId 3) : cached
   Fup  (seqId 3) : match
   ...
   Sync (seqId 65535) : cached
   Fup  (seqId 65535) : match
   Sync (seqId 0) : cached
   Fup  (seqId 0) : match
   Sync (seqId 1) : match with old Fup!!
   Fup  (seqId 1) : cached!
   Sync (seqId 2) : cached
   Fup  (seqId 2) : match

   Actually, I experienced 65500 secs offset every about 65500 secs.
   I'm thinking this is the cause.

This patch fixes the issue by changing the port code to remember one
sync or one follow up, never both. The previous ad hoc logic has been
replaced with a small state machine that handles the messages in the
proper order.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-08-01 22:21:52 +02:00
Richard Cochran 7789f0c313 Be more careful when receiving clock description TLVs.
This patch adds checks to prevent buffer overruns in the TLV parsing code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-28 17:43:04 +02:00
Andy Lutomirski f6536fe36a Fix check for timestamping modes
The code was checking the wrong interface's capabilities.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
2013-07-28 14:42:54 +02:00
Richard Cochran b74e46724e pmc: release the message cache on exit.
This makes valgrind happier by freeing any cached message buffers.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-23 19:56:02 +02:00
Richard Cochran a3762c506e pmc: add a command to select the target port.
This patch adds a new pmc command called "target" that lets the user
address a particular clock and port. Previously all management requests
were sent to the wild card address.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:47:28 +02:00
Richard Cochran 923ff5bbc1 pmc_common: introduce a variable for the target port identity.
This patch replaces the hard coded wild card target port identity with
a variable initially set to the wild card value. The intent is to allow
the caller to set specific targets.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:47:28 +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
Richard Cochran 0650b079f9 pmc: send GET management messages according to interpretation #29.
This commit makes the GET messages have data bodies, just like the erratum
says to. It really doesn't make sense, but have to do it anyhow. We also
introduce a variable that will enable the legacy behavior of sending
empty bodies.

   http://standards.ieee.org/findstds/interps/1588-2008.html

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:47:28 +02:00
Richard Cochran 4ae27d9179 pmc: make the TLV length a functional result.
This patch lets the TLV length field of GET messages come from a
function. For now, the function still results in a length of two,
but the intent is to allow different values later.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:47:27 +02:00
Richard Cochran b4b5487887 msg: Add missing network byte order conversion.
This patch adds proper byte order processing for the target port
identity field of management messages. This bug was not previously
noticed due to the fact that our client had always set this field
to the wild card port number of 0xffff.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:46:20 +02:00
Jiri Benc 48f4dcbeb2 ptp4l: flush old cached packets
This patch fixes a bug with time mysteriously jumping back and forth:

ptp4l[930.687]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED
ptp4l[931.687]: master offset         17 s2 freq  +33014 path delay      2728
ptp4l[932.687]: master offset        -74 s2 freq  +32928 path delay      2734
ptp4l[933.687]: master offset          2 s2 freq  +32982 path delay      2734
ptp4l[934.687]: master offset         -3 s2 freq  +32977 path delay      2728
ptp4l[935.687]: master offset         17 s2 freq  +32996 path delay      2729
ptp4l[936.687]: master offset        -10 s2 freq  +32974 path delay      2729
ptp4l[937.687]: master offset         35 s2 freq  +33016 path delay      2727
ptp4l[938.686]: master offset 60001851388 s2 freq +62499999 path delay      2728
ptp4l[939.687]: master offset  -62464938 s2 freq -62431946 path delay      2728

The last follow up message arriving out of order is cached. Before the state
machine changes to UNCALIBRATED, all sync and follow up messages are discarded.
If we get into that state between a sync and follow up message, the latter is
cached. When there's no real roerdering happening, it's kept cached forever.

When we restart the master, it starts numbering the messages from zero again.
The initial synchronization doesn't take always the same amount of time, so it
can happen that we get into UNCALIBRATED a little bit faster than before,
managing to get the sync message with the sequenceId that we missed last time.
As it has the same sequenceId as the cached (old) follow up message, it's
incorrectly assumed those two belong together.

Flush the cache when changing to UNCALIBRATED. Also, do similar thing for other
cached packets.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2013-07-19 16:17:46 +02:00
Richard Cochran 46db400589 Become the grand master when all alone.
This patch cleans up the BMC logic to allow assuming the GM role when no
other clocks are found in the network. By allowing the "best" to be NULL,
we can let the BMC to naturally pick the local clock as GM. As an added
bonus, this also get rid of the hacky check for a lost master.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:48:23 +02:00
Miroslav Lichvar c7c675852e Adjust constants of PI servo according to sync interval.
Instead of using fixed constants, set them by the following formula from
the current sync to allow good performance of the servo even when the
sync interval changes in runtime and to avoid instability.

kp = min(kp_scale * sync^kp_exponent, kp_norm_max / sync)
ki = min(ki_scale * sync^ki_exponent, ki_norm_max / sync)

The scale, exponent and norm_max constants are configurable. The
defaults are chosen so there is no change to the previous default
constants of the servo with one second sync interval. The automatic
adjustment can be disabled by setting the pi_proportional_const and
pi_integral_const options to a non-zero value, but stability of the
servo is always enforced.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-07-14 21:37:53 +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
Richard Cochran 6edbea4996 Use a dynamic frequency estimation interval.
A slow servo (with smaller constants and lower sync rate) needs a
longer, better frequency estimation, but a higher sync rate hardly
needs any estimation at all, since it learns the frequency right away
in any case.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:53 +02:00
Richard Cochran 3695137619 Let the clock servo know the expected sync interval.
This patch adds a new servo method to let the algorithm know about the
master clock's reported sync message interval. This information can be
used by the servo to adapt its synchronization parameters.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Richard Cochran 617a905643 pmc: add our very first SET command.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Richard Cochran 6a1a16ac66 pmc: add a utility function for sending a message with the SET action.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Richard Cochran a367175b0d Throw a state decision event if the clock quality changes.
Management messages can cause a change in the clock quality. If this
happens, then it is time to run the Best Master Clock algorithm again.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Richard Cochran 12ab15818c Support configuration of the grand master settings.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Richard Cochran 661d7a7716 pmc: Support the grandmaster settings management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:36:18 +02:00
Richard Cochran 24ecd786c8 Support the grand master settings management query.
This patch also replaces the hard coded logic for the UTC offset and the
time property flags with clock variables. This new clock state will be
used for adjusting the grand master attributes at run time.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:45 +02:00
Richard Cochran 64ec047823 Introduce a non-portable management TLV for grand masters.
When running as grand master, the attributes of the local clock are not
known by the ptp4l program. Since these attributes may change over time,
for example when losing signal from GPS satellites, we need to have a
way to provide updated information at run time. This patch provides a
new TLV intended for local IPC that contains the required settings.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:45 +02:00
Richard Cochran f89e203209 Add a configuration option for the time source.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:45 +02:00
Richard Cochran 4782d669c2 Add a clock variable to hold the value of the time source.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:45 +02:00
Richard Cochran d9bdf4f876 Add missing option to the default configuration file.
While the userDescription field is implemented in the code, the same
option is not present in the sample configuration file. This patch
fixes the issue by adding the option with an empty default value.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Rohrer Hansjoerg <hj.rohrer@mobatime.com>
2013-07-07 18:55:44 +02:00
Richard Cochran 81db403af8 Reset announce timer when port is passive.
Whenever a port enters the passive state, it should act like a slaved
port in one respect. Incoming announce messages from the grand master
are supposed to reset the announce timer. This patch fixes the port
logic to properly maintain the passive state.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Rohrer Hansjoerg <hj.rohrer@mobatime.com>
2013-07-07 18:55:44 +02:00
Richard Cochran 5be0770dfc pmc: fix coding style by using K&R style functions. 2013-07-07 18:55:44 +02:00
Richard Cochran 93c609eee9 Clean up indented white space.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:44 +02:00
Richard Cochran c9ac677c98 No need to set kernel_leap twice in a row.
This patch removes a redundant initialization of the kernel_leap clock
variable. The field is already set in clock_create a few lines earlier.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:44 +02:00
Richard Cochran 4b21400869 Add another Freescale driver into the support matrix.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-07 18:55:44 +02:00
Geoff Salmon 42b2173a4d Allow received GET management messages to have bodies
You'd probably expect the body of GET messages to be empty, but
interpretation #29 in
http://standards.ieee.org/findstds/interps/1588-2008.html implies
otherwise. With this change, ptp4l will respond to GETs containing
either an empty dataField or a dataField whose length matches the
managementId. If present, the contents of the dataField are ignored.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-06-28 07:38:59 +02:00
Dale P. Smith 6dedf8bc24 Place clock type values in the correct positon
Signed-off-by: Dale P. Smith  <dalepsmith@gmail.com>
2013-06-28 07:37:42 +02:00
Ken ICHIKAWA fa41be7e6e ptp4l: add support for using configured_pi_f_offset servo option
This patch adds support for using the configured_pi_f_offset servo option to ptp4l.
If "pi_f_offset_const 0.0" is specified in the config file, stepping on the first
update is prevented. If any other positive value is specified, stepping on the
first update occurs when the offset is larger than the specified value.

change since v1
 - add the new option to default.cfg and gPTP.cfg

Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-06-25 07:16:24 +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
Miroslav Lichvar b796d90e80 Minor documentation improvements.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-06-18 18:56:27 +02:00