Commit Graph

1130 Commits (86723cfc6a7ac1d9b1bff5e90b7f4696d6460a0e)

Author SHA1 Message Date
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
Miroslav Lichvar f657e47c26 Add missing state setting in PI servo when date check fails.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-06-18 18:56:27 +02:00
Libor Pechacek 0bf412d24b Reordered options in manual page synopsis
Options without parameters are now grouped together at the beginning of line
for better legibility.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
Cc: Miroslav Lichvar <mlichvar@redhat.com>
2013-06-18 17:51:21 +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
Richard Cochran f394e1796d uClinux: Add another missing system call wrapper.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-06-14 12:58:57 +02:00
Richard Cochran d6d6a9ba64 Bring the readme file up to date with the equipment donations.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-06-14 12:58:56 +02:00
Richard Cochran e67276a56e trivial: break the very long lines of the get_ functions.
The get_ranged_ and get_arg_ declarations and definitions are just a wee
bit much too long. This patch breaks the overly long lines into two.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-06-14 12:58:56 +02:00
Richard Cochran c14a243b46 Silence grep error during build.
Ever since upgrading to Debian 7.0, building linuxptp results in an
annoying error message. This is due to the fact that the directory
/usr/include/bits is no longer present, but our makefile expects it
to exist. This patch fixes the issue by telling grep not to complain
about missing files.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-06-14 12:04:52 +02:00
Ken ICHIKAWA 0513c3b15b config: Apply more strict input validation to almost all config file options
Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-06-14 11:51:07 +02:00
Ken ICHIKAWA 67c925f459 Don't return bogus clock id
phc_open() can open any device and return clkid even if the device is not phc
for example /dev/kvm and so on.
As a result, phc2sys keeps running with reading bogus clock as below:
 # phc2sys -s /dev/kvm -O 0 -q -m
 phc2sys[687019.699]: failed to read clock: Invalid argument
 phc2sys[687020.699]: failed to read clock: Invalid argument
 phc2sys[687021.699]: failed to read clock: Invalid argument
 phc2sys[687022.699]: failed to read clock: Invalid argument
 ...

This patch fixes that problem.

Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-06-06 17:00:25 +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
Ken ICHIKAWA 42cb449eaa util: Add common procedures to get argument values for ptp4l and phc2sys
Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-06-04 20:16:21 +02:00
Ken ICHIKAWA a92f42de38 config: Apply config value validation to logging_level option
Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-06-04 20:16:21 +02:00
Ken ICHIKAWA 306f83e7b1 Add support for more strict config value validation
This patch adds functions to get int, uint, double value from string
with error checking and range specification.
These functions don't allow overflow and outside of the range values.

In addition, it adds parser_result cases "MALFORMED" and "OUT_OF_RANGE" to make
reason of parse error more clear.

Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-06-04 20:16:21 +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
Libor Pechacek 6e4734316f Document PTP time scale usage and provide examples
Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
2013-06-03 15:59:01 +02:00
Delio Brignoli 3f8471ea68 Fix parsing of fault_badpeernet_interval option
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-05-30 15:40:28 +02:00
Miroslav Lichvar 026d422f8f ptp4l: Reset path delay when new master is selected.
When a new master is selected, drop the old path delay and don't
calculate the offset until the delay is measured again with the new
master.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-05-28 16:48:09 +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