Commit Graph

1203 Commits (aed79c38d45f57fd2d307dcb4a806508124937d0)

Author SHA1 Message Date
Miroslav Lichvar 31feb00194 Move PI step threshold and max frequency settings to common servo code.
These settings will be useful for all implemented servos, so move them
to the common servo code to avoid duplication. The configuration options
are renamed, but the they can be still set by their old names.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-03-14 09:52:39 +01:00
Miroslav Lichvar 72a9212600 Don't always step clock on PI servo reset.
The initial check if the clock should be stepped always passed after the
servo was reset (e.g. from clock sanity check). Fix the condition to
step only when the threshold is exceeded.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-03-13 08:32:37 +01:00
Miroslav Lichvar 91e240679b Restrict SET actions to UDS port.
Setting GRANDMASTER_SETTINGS_NP is allowed only from UDS, but
PORT_DATA_SET can be set from any port. Move the port check to
clock_manage(), so all clock and port SET actions are restricted
to the UDS port.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-25 14:15:49 +01:00
Miroslav Lichvar c0fd772974 pmc: print cumulativeScaledRateOffset as offset.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-25 14:15:49 +01:00
Miroslav Lichvar 7d773a9b93 Initialize clock rate ratio.
This fixes cumulativeScaledRateOffset reported in TIME_STATUS_NP before
the rate ratio is updated from port.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-25 14:15:49 +01:00
Miroslav Lichvar 85cebe0265 Fix conversion of cumulativeScaledRateOffset in TIME_STATUS_NP.
This fixes reporting of negative offsets.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-25 14:15:49 +01:00
Delio Brignoli b2bde6f5ec config: Add min_neighbor_prop_delay configuration variable
When peer delay is < min_neighbor_prop_delay the port is flagged
as non 802.1AS capable. min_neighbor_prop_delay defaults to -20ms.

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2014-02-25 14:14:01 +01:00
Delio Brignoli bd001fdec7 port: adjust peer delay calculation using neighborRateRatio
Previouly the peer delay was not taking into account the
frequency offset between the local clock and the peer's clock.
Reset neighborRateRatio to 1.0 in port_nrate_initialize().

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2014-02-25 14:13:05 +01:00
Richard Cochran 54c9effeba Version 1.4
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-02-14 16:20:14 +01:00
Miroslav Lichvar 9190959693 Fix new -Wformat warnings.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-14 16:17:28 +01:00
Miroslav Lichvar 1fa57ac411 Set printf format attribute for print().
This allows gcc to check format strings used in pr_* calls.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-11 21:27:52 +01:00
Miroslav Lichvar 661639420c Clarify units used in clock stepping constants.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-11 21:27:52 +01:00
Stephan Gatzka 110849d422 Make functions and structs dealing with string literals const correct.
This allows the compiler to check if someone writes into string
literals.

Signed-off-by: Stephan Gatzka <stephan.gatzka@gmail.com>
2014-02-07 19:41:47 +01:00
Stephan Gatzka 886112e202 Make udp_physical_addr() and udp_protocol_addr() static.
They aren't used outside udp.c

Signed-off-by: Stephan Gatzka <stephan.gatzka@gmail.com>
2014-02-07 19:40:29 +01:00
Delio Brignoli 29063a8227 pmc: support retrieving neighborPropDelayThresh and asCapable using management interface
Define new PORT_DATA_SET_NP TLV
neighborPropDelayThresh can also be set using the same TLV

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2014-02-04 18:59:26 +01:00
Richard Cochran f36af8e0c3 uds: disable the accidentally enabled announce timer.
Commit e425da2f inadvertently enabled the announce timer on the UDS port,
causing it to continually reopen the socket when in slave mode. This patch
fixes the issue by passing zero in the 'span' field of the new function,
set_tmo_random, which disables the timer again.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Rohrer Hansjoerg <hj.rohrer@mobatime.com>
2014-01-08 18:59:20 +01:00
Richard Cochran 21889c5e7e uds: take the interface data off the stack.
The 'struct interface' for the UDS port is allocated on the stack, and
when this gets passed to port_open, the port instance takes a pointer to
the string in the 'name' field. Currently this is harmless for the UDS
port, but it is not good form. This patch fixes the issue by making the
interface part of the clock instance.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-08 18:59:11 +01:00
Miroslav Lichvar 5dd5af5565 phc2sys: Mention that PPS output needs to be enabled without -s.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-08 16:06:42 +01:00
Miroslav Lichvar cee9397b66 Print current frequency when PI servo is in unlocked state.
Store the current frequency and return it when the servo is in unlocked
state instead of zero. This fixes values printed in log messages.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-08 15:50:02 +01:00
Miroslav Lichvar f7d745f8fa Change level of negative path delay messages to debug.
Negative path delay measurements are expected with E2E, the user doesn't
need to know when that happens.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-08 15:50:02 +01:00
Miroslav Lichvar 647bce1c0c Clarify c1, c2, c3 in negative path delay log message.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-01-08 15:50:02 +01:00
Miroslav Lichvar 2ca067dcac Fix drift calculation in PI servo with large values.
When the drift value is adjusted by the newly measured frequency offset,
multiply the frequencies instead of adding the measured offset to the
old value to get accurate result even when updating a large drift.

[ RC: use a simpler form of the frequency update calculation. ]

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-01-08 15:46:15 +01:00
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
Richard Cochran eb9b0bd275 Simplify the text of the driver support matrix in the readme file.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-01-04 14:28:11 +01:00
Richard Cochran c00889f9eb Fix filter allocation failure on the UDS port.
Although it does not need to, the UDS port tries to allocate a filter,
just as any normal port would. Since the given length is zero, the
filter tries to allocate storage of size zero. When running with
uClibc, calloc(1, 0) returns NULL, but glibc is apparently returning
"a unique pointer value that can later be successfully passed to
free()." Both behaviors are allowed (see MALLOC(3)).

This patch works around the issue by letting the UDS port have a
filter of length one.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-12-26 19:09:26 +01:00
Richard Cochran 3aedebe74b clock: add missing call to clockcheck_destroy.
This patch lets the clock release allocated memory when shutting down. The
main benefit is just to exhibit good form and to make valgrind happier.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-12-26 10:48:25 +01:00
Richard Cochran e2586af94a Merge Miroslav's random PTP timeout branch.
Conflicts:
	makefile
2013-12-19 19:20:58 +01:00
Richard Cochran 101e9dcc0e Add a configuration file option for the 802.1AS gmCapable flag.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-12-18 18:34:33 +01:00
Richard Cochran d72e795727 Inhibit sync messages from unwilling 802.1AS ports.
According to 802.1AS, ports are always expected to transmit announce
messages, even if they never want to become the grand master. Instead
of using a slave only BMC state machine as in 1588, 802.1AS offers a
"grand master capable" flag which allows clocks to not send sync
messages.

This patch keeps a port from transmitting sync (but not announce)
messages when there is no other master.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-12-18 18:34:32 +01:00
Richard Cochran bdbda10c73 Introduce the gmCapable flag for use with 802.1AS clocks.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-12-01 20:32:05 +01:00
Delio Brignoli 7f7012eab5 Reset pdr_missing early in port_nrate_calculate(), implement ratio_valid flag
[ RC: the point is that a port may not be considered capable until
  enough messages to compute the ratio have been received. ]

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
Reviewed-by: Richard Cochran <richardcochran@gmail.com>
2013-11-30 20:36:14 +01:00
Delio Brignoli a0171b035e Set sync timeout only on port_synchronize()
Sync rx timeout should be set only after receiving the first sync, see
section 10.2.7, figure 10-4 PortSyncSyncReceive state machine in 802.1AS

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-11-30 20:16:16 +01:00
Miroslav Lichvar 85a1bcfa8e Add options to configure delay filter.
Add new options delay_filter and delay_filter_length to select the
filter and its length. They set both the clock delay filter and the port
peer delay filter. The default is now moving median with 10 samples.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-30 21:54:07 +01:00
Miroslav Lichvar ed9e0fa975 Add median filter.
Median filter has an advantage over moving average that it is much less
sensitive to outliers.

For instance, it allows much faster recovery from an external clock
time step which happened between receiving sync message and sending
delay_req message. The measured delay includes a large error, but the
median is still a good estimate of the delay and the first step
correction applied by the servo is right.

In this implementation the median update has linear time complexity.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-30 21:54:07 +01:00
Miroslav Lichvar 2c9718f3c2 Add modular filter interface.
Similarly to the servo interface, allow multiple filters to be
used for delay filtering. Convert mave to the new interface.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-30 21:43:37 +01:00
Jacob Keller 7bd59737d3 sk: update error message for Tx timestamp polling
This patch cleans up the error message for the Tx timestamp polling, and adds a
line which indicates where the bug might have originated. This should help a
user more easily diagnose what went wrong.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2013-10-30 21:20:13 +01:00
Miroslav Lichvar ab84eade0a Make random() more random between machines.
Include also nanoseconds from the current time in the srandom() call.
This should significantly decrease the chance of two machines using the
same random sequence.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-27 14:03:05 +01:00
Miroslav Lichvar 23d31d090e Drop tmtab module.
Instead of maintaining a table of precalculated values, use the
newly added set_tmo_random() function to set the delay request timeout.
It saves some memory and improves the timeout granularity, but has a
higher computational cost. It follows the requirements from section
9.5.11.2 of the spec.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-27 14:03:05 +01:00
Miroslav Lichvar e425da2f17 Add random delay to announce timeout.
According to 9.2.6.11 of the spec the ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
timeout in addition to announceReceiptTimeoutInterval includes a random
number up to one announceInterval.

Add a new function for setting random timeout and use it in
port_set_announce_tmo().

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-27 13:59:26 +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
Miroslav Lichvar cc7be3fc67 Add reset function to servo.
This will be used with clock sanity checking.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-27 08:24:01 +01:00
Richard Cochran 25cf96d4ca Merge the configurable UDS server path branch. 2013-10-26 18:14:37 +02:00
Miroslav Lichvar 52c5e0cfc9 Don't calculate delay with old master's sync time stamp.
When a new master is selected, drop the old sync time stamp to prevent
calculating invalid delay in case delay_resp will be received before
first sync from the new master.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-11 19:44:50 +02:00
Miroslav Lichvar ea4201298c Ignore delay_resp messages from foreign masters.
When a new master appears, it will start to respond to our delay_req
messages. Make sure we process only responses from our current master
before switching to the new master.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-10-11 19:44:49 +02:00
Richard Cochran 289699e3c9 pmc: bring the man page more up to date.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-10-08 20:11:20 +02:00
Richard Cochran 67b0386042 Extend the interface name length to allow any UDS address.
This patch increases the maximum length of an interface name to
accommodate a UNIX domain socket address of 108 bytes. (This value is
hard coded in the glibc headers, and so we cannot use the Linux kernel
header macro, UNIX_PATH_MAX.)

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-10-08 20:11:20 +02:00
Richard Cochran 4f6f1e1cba pmc: add a command line option to select the server's UDS address.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-10-08 20:11:20 +02:00
Richard Cochran 9fe2ffd2ef Introduce a configuration file option for the server's UDS address.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-10-08 20:11:20 +02:00
Richard Cochran e5ddfd491e Convert the hard coded UDS server path into a variable.
This patch changes the macro for the server socket address into a global
variable so that a subsequent patch can provide a way to set the variable.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-09-29 20:17:01 +02:00
Richard Cochran ba12da671f Make the CFLAGS more robust.
This patch introduces a shell script to figure out the proper definitions
for the HAVE_CLOCK_ADJTIME and HAVE_ONESTEP_SYNC macros, as well as the
include path. The intent is to "do the right thing" for three different
user scenarios, namely cross compiling, compiling against a custom kernel,
and using a plain old disto kernel.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-09-29 20:16:16 +02:00