Commit Graph

113 Commits (b0d789a73e7f72973a05a89ff514131b02611e24)

Author SHA1 Message Date
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 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 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
Miroslav Lichvar fce0aa0a2f Fix compiler warnings with -O2.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-04-05 09:14:29 +02:00
Richard Cochran 9ee5c1fb8e Let a slaved port update the time properties on every announce message.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-04-02 19:28:10 +02:00
Libor Pechacek 0367bb5f1b Distinguish between ignored and malformed packets
When there is a peer speaking PTPv1 in the network we want to silently ignore
the packets instead of flooding system log with error messages.  At the same
time we still want to report malformed packets.  For that we reuse standard
error numbers and do more fine-grained error reporting in packet processing
routines.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
2013-03-28 18:48:52 +01:00
Delio Brignoli 789a5c8e37 Add support for FT_BAD_PEER_NETWORK
Handle reception of >=3 sequential multiple pdelay responses from
distinct peers as a fault of type FT_BAD_PEER_NETWORK.

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-20 19:10:22 +01:00
Delio Brignoli b936d35b6d Add support for multiple fault types
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-20 19:10:22 +01:00
Delio Brignoli 455ebe7d22 Rename set_tmo() to set_tmo_log(), add set_tmo_lin()
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-20 19:10:22 +01:00
Delio Brignoli d374ad6bf7 Explicitly detect and handle changes of the peer's port id by resetting asCapable and the port's nrate
This patch also changes port_capable() to reset the port's nrate every time asCapable changes
from true to false.

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-20 19:10:09 +01:00
Delio Brignoli 9650cb687d Log changes to asCapable
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-17 18:50:31 +01:00
Delio Brignoli 3cc285c691 Free peer delay responses and followup messages when sending a new peer delay request
If messages are not freed, it is possible (with purposely crafted traffic) to trigger
a peer delay calculation which will use message's data from the previous round.

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-14 05:17:41 +01:00
Delio Brignoli 4626487ff3 Implement neighborPropDelayThresh check in port_capable()
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2013-03-14 05:17:38 +01:00
Richard Cochran 48aa6712a9 Add support for the log peer delay interval management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-04 20:27:12 +01:00
Richard Cochran 9b5e37bbf8 Add support for the delay mechanism management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-04 20:23:32 +01:00
Richard Cochran d30d397c2b Add support for the version number management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-04 20:18:19 +01:00
Richard Cochran 06a65003f4 Add support for the log sync interval management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-04 20:14:05 +01:00
Richard Cochran d2f8bc5e38 Add support for the announce receipt timeout management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-04 20:10:51 +01:00
Richard Cochran 555c42e3d0 Add support for the log announce interval management request.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-03-04 20:06:36 +01:00
Geoff Salmon 36a5921e88 support GET CLOCK_DESCRIPTION and USER_DESCRIPTION mgmt messages
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-25 18:11:03 +01:00
Miroslav Lichvar c547145834 Check shift used in freq_est and stats max_count calculation.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-12 19:59:50 +01:00
Richard Cochran c7098364f2 Make the counters for the frequency and rate estimators unsigned.
These are simple 'up' counters.
There is no need for negative values here.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-09 08:51:19 +01:00
Richard Cochran 6dc1b90306 Send peer delay requests continuously in P2P mode.
When a port makes a transition from one state to another, it resets all of
the message timers. While this is the correct behavior for E2E mode, the
P2P mode requires sending peer delay requests most of the time.

Even though all the other timer logic is identical, still making an
exception for P2P mode would make the code even harder to follow. So this
patch introduces two nearly identical helper functions to handle timer
reprogramming during a state transition.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-06 19:27:48 +01:00
Geoff Salmon 3921557672 send NOT_SUPPORTED errors for all unhandled, known management IDs
Now that there are clock/port_management_set functions, the IDs that
GETs are handled for, like DEFUALT_DATA_SET, still need to be in the
case for sending NOT_SUPPORTED errors.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:36 +01:00
Geoff Salmon 507bee9e73 adds stub clock/port_management_set functions
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:36 +01:00
Geoff Salmon 0e497b9a45 send UNKNOWN_ID error for unknown management TLVs
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:36 +01:00
Geoff Salmon 1500605ff5 factors out functions for sending mgmt errors from clock and port
Adds port_management_send_error and clock_management_send_error to
avoid repeatedly checking the result of port_managment_send_error and
calling pr_err if it failed. Future patches send more mgmt errors so
this will avoid repeated code.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:35 +01:00
Geoff Salmon d5af4196fc fixes typo port_managment_error -> port_management_error
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-06 18:10:35 +01:00
Richard Cochran f530ae9333 Hide the grandmaster port state.
There really is no such state, but there probably should have been one.
In any case, we do have one just to make the code simpler, but this should
not appear in the management responses. This patch fixes the issue by
covering over our tracks before sending a response.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-06 13:34:49 +01:00
Richard Cochran 4f866b2761 Merge the branch with the 'asCapable' support.
Conflicts:
	port.c

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-03 18:43:56 +01:00
Richard Cochran 0dbdd9c2cd Stop handling file descriptor events after a port reset.
If the port resets itself after detecting a fault, then the polling events
for that port are no longer valid. This patch fixes a latent bug that
would appear if a fault and another event were to happen simultaneously.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-03 17:58:12 +01:00
Delio Brignoli da594e78d9 Make the fault reset interval a per-port configuration parameter.
A timeout of 15 seconds is not always acceptable, make it configurable.

By popular consensus, instead of using a linear number of seconds, use
the 2^N format for the time interval, just like the other intervals in
the PTP data sets. In addition to numeric values, let the configuration
file support 'ASAP' to have the fault reset immediately.

[RC - moved the handling of special case tmo=0 and added a break out
      of the fd event loop in case the fds have been closed.
    - changed the linear seconds option to log second instead.
    - changed the commit message to reflect the final version. ]

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-02-03 17:53:33 +01:00
Richard Cochran 285b88ade4 Let a port become 'capable' according to 802.1AS.
This patch implements the capable flag as follows.

1. After calculating the neighbor rate, we are capable.
2. If we miss too many responses, we are incapable.
3. If we get multiple responses, we throw a fault,
   and so we are also incapable.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-01-27 20:58:19 +01:00
Richard Cochran ea833f3d6b Add a default of 'incapable' for 802.1AS mode.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-01-27 20:58:19 +01:00
Richard Cochran ad8a197a0b Add port logic for the 'capable' flag from 802.1AS.
This commit only provides helper functions that will implement the effect
of a port being not capable. We let the port be always 'capable' for now,
until we actually have added the details of that flag.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-01-27 20:58:19 +01:00
Richard Cochran 90f791d881 Introduce a test for running in 802.1AS mode.
We use the follow_up_info to control behavior that is specific to the
802.1AS standard. In several instances, that standard goes against the
1588 standard or requires new run time logic that exceeds what can be
reasonably described as a 1588 profile.

Since we will need a few more run time exceptions in order to support
802.1AS, we introduce a helper function to identify this case, rather
than hard coding a test for follow_up_info, in order to be more clear
about it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-01-27 20:58:19 +01:00
Richard Cochran a1cd223962 Start P2P messages right away when listening after initializing.
Because of an oversight in the event code, a port will not send peer delay
request messages while in the initial listening state. This patch fixes
the issue by expanding this special, initial case.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-01-27 20:58:19 +01:00
Richard Cochran b810153ed5 Add asymmetry correction.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Jacob Keller <Jacob.e.keller@intel.com>
2012-12-11 14:36:30 +01:00
Richard Cochran 2aaae0854e Distinguish between get and set management requests.
The code previously treated all supported request as 'get' actions and
ignored the actual action field in the message. This commit makes the
code look at the action field when processing the requests.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-04 13:25:50 +01:00
Richard Cochran 0e244e7f36 Respond to the port data set management query.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-02 21:06:37 +01:00
Richard Cochran 970bc7f95c Maintain the peer mean path delay field of the port data set.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-02 20:48:29 +01:00
Richard Cochran aa6708d09a Use the management message memory layout for the timePropertiesDS.
Reforming the data structure in this way will greatly simplify the
implementation of the management message for this data set.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-12-02 11:24:31 +01:00
Richard Cochran 71c4bf203c Use the management message memory layout for the parentDS.
Reforming the data structure in this way will greatly simplify the
implementation of the management message for this data set.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-30 22:35:26 +01:00
Richard Cochran b26a36d493 Implement the NULL management message.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-30 20:26:22 +01:00
Richard Cochran b96e73994b Support one step sync operation.
The Linux kernel supports a hardware time stamping mode that allows
sending a one step sync message. This commit adds support for this mode
by expanding the time stamp type enumeration. In order to enable this
mode, the configuration must specify both hardware time stamping and set
the twoStepFlag to false.

We still do not support the one step peer delay request mechanism since
there is neither kernel nor hardware support for it at this time.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-30 11:34:29 +01:00
Jacob Keller 004b62d22b sk: change sk_interface_phc to sk_get_ts_info
this patch changes sk_interface_phc to sk_get_ts_info, by allowing the function
to store all the data returned by Ethtool's get_ts_info IOCTL in a struct. A new
struct "sk_ts_info" contains the same data as well as a field for specifying the
structure as valid (in order to support old kernels without the IOCTL). The
valid field should be set only when the IOCTL successfully populates the fields.

A follow-on patch will add new functionality possible because of these
changes. This patch only updates the programs which use the call to perform the
minimum they already do, using the new interface.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2012-11-14 20:22:10 +01:00
Miroslav Lichvar 7894339cdd Fix errors found by Coverity Static Analysis.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2012-10-18 19:58:40 +02:00
Miroslav Lichvar 937f3aec5b Don't try calling SIOCETHTOOL on UDS.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2012-10-11 20:35:11 +02:00
Richard Cochran 671358b21d Warn if a slave only node is selected by the bmc.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-22 11:30:50 +02:00
Richard Cochran 8f5bd0edda Guard against divide by zero.
If a buggy driver or hardware delivers bogus time stamps, then we might
crash with a divide by zero exception.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-04 08:16:53 +02:00