Commit Graph

168 Commits (8efb623f128d066212a31ceb0bfd6a03daf33938)

Author SHA1 Message Date
Richard Cochran 8efb623f12 config: prot: convert 'transportSpecific' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran fffb6a53bd config: port: convert 'syncReceiptTimeout' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 35227f2d1f config: port: convert 'announceReceiptTimeout' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 639ce56fa0 config: port: convert 'logMinPdelayReqInterval' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 0578e321fb config: port: convert 'logMinDelayReqInterval' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 769a8d3fa6 config: port: convert 'logSyncInterval' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 8026663c43 config: port: convert 'logAnnounceInterval' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 95a629624f config: port: convert 'delayAsymmetry' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 3189a7bc0a transport: store the configuration in the transport data structure.
This will allow modules to read out various user options.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-16 11:20:23 +02:00
Miroslav Lichvar 06fcfe123c tsproc: add raw and weighting modes.
Add new time stamp processing modes to return raw delay and offset based
on the raw delay instead of the long-term filtered delay, and to return
also a weight of the sample. The weight is set to the ratio between the
two delays. This gives smaller weight to samples where the sync and/or
delay messages were delayed significantly in the network and possibly
include a large error.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar c452e862dd Refactor time stamp processing.
Introduce a time stamp processor for offset/delay calculations and use
it in the clock and port modules.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Miroslav Lichvar 6813fd7c3d Convert and correct time stamps early.
Convert time stamps to tmv_t and apply all corrections before passing
them to clock/port functions to reduce the number of parameters.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-03-27 10:58:04 +01:00
Richard Cochran e706f48981 port: allow running a boundary clock with multiple clock devices.
If the user has configured the appropriate option, then simply warn
about the clock device mismatch, and then go on in "JBOD" mode.
Whenever the port enters the uncalibrated state, it tells the clock
to switch to the new PHC device.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-18 11:38:00 +01:00
Richard Cochran 017235f881 port: correct transmit and receive time stamps for their calibrated delays.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-12 21:44:56 +01:00
Richard Cochran ef49629387 Invoke the clock check even if the time stamp nanoseconds field is zero.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-12 21:44:56 +01:00
Richard Cochran 8e8a989720 Coding style: add missing break statement from a switch/case construct.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-11-07 19:47:36 +01:00
Miroslav Lichvar 594f59c50d port: fix fda initialization.
Initialize all descriptors to prevent polling invalid descriptors from
faulty ports.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-11-07 18:57:05 +01:00
Richard Cochran 6b05b4e7d3 Restore the peer addresses in P2P mode.
Commit ea7a7882 removed the calls to transport_peer(), inadvertently
substituting them with transport_send(), resulting in PDelay messages
being sent with an incorrect destination address.

This patch fixes the issue by introducing peer_prepare_and_send(),
analogous to the port_prepare_and_send() function.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Jiri Benc <jbenc@redhat.com>
2014-10-11 21:03:27 +02:00
Jiri Benc 08575133b3 Dynamic port allocation
Remove the limit of MAX_PORTS ports (default 8) and keep the ports in
a linked list. This allows ptp4l to be used on large machines and in the
future, it will allow dynamic adding and removing of ports while ptp4l is
running.

For this to work, pollfd needs to be dynamically allocated. Changed pollfd
handling from clock_install_fda/clock_remove_fda to notification
(clock_fda_changed), where the clock will rebuild pollfd by querying all its
ports.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Jiri Benc 2d1a88ca5d Put fault_fd into struct port
The fault timer file descriptor is a per port item, put it inside struct
port where other per port file descriptors are kept.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-09-21 13:15:59 +02:00
Miroslav Lichvar 70dd682349 Prefix TLV IDs.
To avoid conflicts in generic names add TLV_ prefix to all TLV IDs
defined in tlv.h.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-07-09 06:31:25 +02:00
Jiri Benc 424bbde8fc Custom management TLV PORT_PROPERTIES_NP
Will be used by phc2sys to find out interfaces corresponding to ports.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-06 20:09:00 +02:00
Jiri Benc c8c6f7288f Event notification: port state
Notify subscribers about port state changes.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-06 20:08:59 +02:00
Jiri Benc 648197153e clock: event notification
Split management message creation to more fine-grained functions to allow
notification messages to be created.

The new clock_management_fill_response is called from
clock_management_get_response (so the function behaves exactly the same as
before this patch) and from a new clock_notify_event function. The
difference is clock_management_get_response uses the request message to
construct the reply message, while clock_notify_event constructs the reply
message based on the notification id.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-06 20:08:59 +02:00
Jiri Benc 122314926a port: event notification
Split management message creation to more fine-grained functions to allow
notification messages to be created.

The new port_management_fill_response is called from
port_management_get_response (so the function behaves exactly the same
as before this patch) and from a new port_notify_event function. The
difference is port_management_get_response uses the request message to
construct the reply message, while port_notify_event constructs the
reply message based on the notification id.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-06 20:08:59 +02:00
Jiri Benc d0a67e8b1a Implement port_forward_to
Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-03 13:56:57 +02:00
Jiri Benc d6e4173e19 Remove unneeded parameter in port_forward
This parameter was made obsolete by the common address refactoring.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-03 13:56:57 +02:00
Jiri Benc ba577d7123 Respond with an error to management messages to non-existing ports
Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-03 13:56:57 +02:00
Jiri Benc bbe634d790 Let transport_recv/send/peer use ptp_message
The callers of those functions are all using ptp_message. As we're going to
return more information (the address), let those functions just fill in the
ptp_message fields directly.

Some minor reshuffling needed to prevent circular header dependencies.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-04-17 06:49:38 +02:00
Jiri Benc ea7a7882e5 Move common code into port_prepare_and_send
The task of preparing the message for transmission and sending it appears
at many places. Unify them into a new function.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-03-26 16:59:45 +01:00
Miroslav Lichvar 61de819d56 Include clock rate ratio in delay calculation.
With the new linreg servo the frequency offset and time offset are
controlled separately. The ratio between master's frequency and the
current frequency of the local clock is known and can be used when
calculating delay or peer delay to improve their accuracy.

This greatly improves the stability of the delay when the servo is
correcting a large offset.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-03-14 09:52:40 +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
Miroslav Lichvar 9190959693 Fix new -Wformat warnings.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-02-14 16:17:28 +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 e2586af94a Merge Miroslav's random PTP timeout branch.
Conflicts:
	makefile
2013-12-19 19:20:58 +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
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 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
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 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
Miroslav Lichvar b366b79306 Reset delay timer when switching to P2P delay mechanism.
When ptp4l was configured to use the auto delay mechanism and the first
pdelay request was not received in the slave or uncalibrated state, it
would not make any pdelay requests itself, because there was no delay
timer running.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-09-21 08:15:28 +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