Commit Graph

199 Commits (ac92a711614c413b75a4963eab95cd1aa2de8293)

Author SHA1 Message Date
Richard Cochran 6b471d45ed port: Change port_dispatch() into a void function.
This global function used to return an error code, but now it always
returns zero.  This patch converts the function signature to return void
and simplifies the main clock loop by removing the useless test.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-02-05 18:25:18 +01:00
Richard Cochran b738afb604 fsm: Make the transition out of INITIALIZING part of the FSM code.
The state machines in 1588 do not specify an event that causes a transition
out of the initializing state.  This was left as a local issue.  For this
transition, the current code assigns the next state outside of the FSM.  But
doing so prevents an alternative FSM to handle this transition differently.

By introducing a new event, this patch places this transition where it
belongs, namely under the control of the FSM code,

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-01-08 21:34:54 +01:00
Richard Cochran 01ee947457 Disentangle initialization from fault clearing.
Although leaving the INITIALIZING state and clearing the FAULTY state
ASAP both result in a port entering the LISTENING state, still there
is no benefit from conflating the two.  In the FAULTY case, the
current code actually skips the INITIALIZING state altogether.

This patch separates the two cases resulting in two benefits.  First,
the check for ASAP fault status is only made when a fault is actually
present, unlike the present unconditional check.  Second, this change
will allow us to cleanly support alternative state machines later on.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-01-08 21:34:53 +01:00
Richard Cochran 1f66948d38 Make the fault handling code more readable.
The code that decides whether a fault qualifies for ASAP treatment is
a tangle of logical operators.  This patch replaces the open coded
logic with a helper function whose name makes the intent clear.  This
is a cosmetic change only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-01-08 21:34:53 +01:00
Richard Cochran 80a28a9dc3 Change a misleading fault handling function signature.
Looking at the fault logic in port_dispatch(), you might think that
the function, fault_interval(), checks whether a fault is active, but
you would be wrong, since that function always returns zero.

This patch removes the superfluous input error checking inside of
fault_interval() and changes the return type to void, making the
actual behavior explicit.  Dropping the input check is safe because
that function has exactly two callers, both of whom always provide
valid inputs.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-01-08 21:34:53 +01:00
Richard Cochran 10d4e7f8b0 port: Make the finite state machine into a function variable.
This allows adding new FSM flavors in the future.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-01-08 21:34:53 +01:00
Richard Cochran 5e3156da15 port: Provide methods to set and get the link status.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-10-16 12:42:56 +02:00
Richard Cochran 5e5c98b3da port: Fix input to the BMC for forming the spanning tree.
If a non-slave port on a boundary clock see an announce message, then it
must decide whether it should take on the MASTER or the PASSIVE role.  When
the GM fields from the local clock are identical to those in the announce,
then the sender/receiver ports are used as a tie breaker.

Following a typographical error in 1588, the code wrongly uses the port
identity of the upstream parent as the "receiver" id.  As a result, a port
that should be PASSIVE may choose MASTER instead. This patch fixes the
code to use local port id.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-08-03 14:00:04 +02:00
Richard Cochran 3938cbc101 uds: Prevent unintentional announce message timeouts.
During the configuration rework, the announce span was wrongly converted
into a hard coded macro.  In addition, the announceReceiptTimeout option
inadvertently became non-zero for the UDS port.  As a result, the UDS port
sets a useless announce message timer, causing the code to close and reopen
the UDS port every few seconds.

This bug has an interesting history.  It was first reported and fixed in
commit f36af8e0 ("uds: disable the accidentally enabled announce timer.").

That very fix was wrongly removed in commit 54f45063 ("port: change
'announce_span' into a macro.").  Because of various code changes, this
bad commit cannot be simply reverted now.

This patch re-introduces the 'announce_span' variable and clears both it
and 'announceReceiptTimeout' for the UDS port, effectively disabling the
announce message timer.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-07-07 18:41:57 +02:00
Richard Cochran 948d511550 clock: offer a method to get the type rather than the number of ports.
The port code is not interested in the number of ports but rather the
clock type.  Since the polymorphic clock object will be able to report
its own type, this patch changes the clock interface accordingly.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Richard Cochran 01dcf7e9ac Properly initialize the message lists.
The message lists are implemented using a TAILQ from queue(3).  The heads
of the list must be initialized using the provided macros, since the field
called 'tqh_last' is non-zero in the initial state.  This patch fixes a
potential null pointer dereference by properly initializing the queues.

Note that there is no actual bug in the current code, because it uses the
lists in such a way as to initialize 'tqh_last' before any dereference.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-04-03 14:45:41 +02:00
Miroslav Lichvar cdd11b744b port: print bogus delay request message as rate limited info.
Upgrade the message level to info so the user can see it, but print it
at most once per 5 minutes to not spam the syslog too much.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-09-11 21:24:34 +02:00
Richard Cochran e85cb68320 Support hybrid E2E using unicast delay requests and responses.
The draft Enterprise Profile [1] specifies a hybrid E2E delay mechanism,
where the delay response message is sent "in kind".  That is, if the
request is unicast, then the response is also unicast.  Apparently this
scheme is already in widespread use in some industries.  Also, it makes
sense, because those messages are of no interest to the other slaves in
the PTP network.

Because of the address work already in place, in turns out that adding
this mode is almost trivial.  This patch introduces an "hybrid_e2e" option
that enabled the new mode.

1. https://datatracker.ietf.org/doc/draft-ietf-tictoc-ptp-enterprise-profile

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-29 11:33:34 +02:00
Richard Cochran 0135e5344d port: constrain the master's logMinDelayReqInterval.
Buggy or mis-configured masters can place bogus logMessageInterval values
in their delay response messages.  This patch places reasonable limits on
the range of values that we will accept.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-28 17:55:32 +02:00
Richard Cochran a8a3ddec6a Fix integer overflow in the foreign master bookkeeping code.
The logMessageInterval field has an improbable range from 2^-128 to 2^127
seconds.  The extreme ends cause an integer overflow in the calculation
of the "foreign master time window".  Buggy or mis-configured foreign
masters advertising extreme values will cause incorrect announce message
aging.

This patch fixes the issue by adding thresholds for the bogus extremes.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-28 17:02:01 +02:00
Richard Cochran b6a91303a9 config: convert 'delay_filter' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:46 +02:00
Richard Cochran a8b550887d config: convert 'tsproc_mode' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran bf29022005 config: convert 'delay_mechanism' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 3d1d93bcb2 config: convert 'network_transport' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 0bb690c16c config: remove the 'port_defaults' structure.
This definition is now empty and can serve no purpose any more.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran bbd8d62bec config: convert the fault interval options to the new scheme.
This conversion is not straightforward due to the fact that these options
can take a value of "ASAP" or a number.  We check for the special ASAP
case in a helper function and leave the numbers to the generic code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 38c891b2c8 config: clock, port: convert 'boundary_clock_jbod' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran eaa70f165f config: port: convert 'delay_filter_length' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 83e26ec68b config: port: convert 'ingressLatency' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran a19318b413 config: port: convert 'egressLatency' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 3ff0e4a589 config: port: convert 'min_neighbor_prop_delay' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 7895466de1 config: port: convert 'neighborPropDelayThresh' to new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran ffa7d49df6 config: clock, port: convert 'freq_est_interval' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran becc6262cc config: port: convert 'follow_up_info' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran e1dcf8ea11 config: port: convert 'path_trace_enabled' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Richard Cochran 54f45063df port: change 'announce_span' into a macro.
This probably should not have been a variable in the first place.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
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