Commit Graph

1193 Commits (0a4d85c2ed9baa948673bdf6aeb32fda934ebe44)

Author SHA1 Message Date
Richard Cochran a4981b2050 Move the configuration files to their own directory.
We will be getting more and more of these.  Let's put them into their
own area.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 07:46:03 -07:00
Christoph Seifert 1bf9d1e392 config: Fix value range for tc_spanning_tree option
This fix allows disabling tc_spanning_tree explicitly.

Signed-off-by: Christoph Seifert <christoph.seifert@posteo.me>
2018-05-17 10:41:59 -07:00
Richard Cochran a8b66ce7f2 Fix crash in hybrid E2E mode.
Richard Hill reported an occasional NULL pointer deference in
port_delay_request() when in hybrid mode.

	if (p->hybrid_e2e) {
		struct ptp_message *dst = TAILQ_FIRST(&p->best->messages);
		msg->address = dst->address;
		...
	}

The code assumes that the p->best->messages list can't be empty
because:

    The function, port_delay_request(), is called only when
    FD_DELAY_TIMER expires.  That timer is only set by the function,
    port_set_delay_tmo(), which is called:

    1. from process_delay_resp(), but only when state is UNCALIBRATED
       or SLAVE.

    2. from port_e2e_transition(), but only when state is UNCALIBRATED
       or SLAVE.

    Looking at handle_state_decision_event(), a port can only enter
    UNCALIBRATED or SLAVE when it has a valid foreign master record,
    ie p->best->messages is not null.

    A port also only clears p->best->messages when it leaves
    UNCALIBRATED or SLAVE, at which point the FD_DELAY_TIMER is also
    cleared.

*However* the p->best->messages list *can* be empty if the
FD_ANNOUNCE_TIMER and the FD_DELAY_TIMER expire at the same time.  In
this case, the poll() call indicates events on both file descriptors.
The announce timeout is handled like this:

	case FD_ANNOUNCE_TIMER:
        case FD_SYNC_RX_TIMER:
                if (p->best)
                        fc_clear(p->best);

So then the port_delay_request() call de-references the null
TAILQ_FIRST message pointer.

This patch fixes the issue by re-ordering the timer file descriptors
within the polling list.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Richard Hill <plonta@gmx.de>
2018-05-16 06:44:56 -07:00
Jacob Keller cacf272d1c phc2sys: fix manpage documentation for -F
Clearly indicate the value is the maximum offset for which clock skewing
will be used at the start. An offset of a lower value will be fixed by
frequency changes only, while a larger value will be fixed with an
initial clock jump. This matches similar wording found in the -S option
explanation.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2018-05-15 06:14:19 -07:00
Richard Cochran bdbbe24ef9 Add an example configuration for an end to end transparent clock.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:46:43 -07:00
Richard Cochran fd80721493 Add an example configuration for a peer to peer transparent clock.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:46:43 -07:00
Richard Cochran e6af4608c4 config: Add a configuration option for preventing loops in TC mode.
According to 1588, PTP message loops are simply someone else's problem
with respect to transparent clocks.  Since we are running the BMCA for
syntonization anyway, we might as well go ahead and implement the spanning
tree for PTP messages.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:46:43 -07:00
Richard Cochran c8107c8d4b config: Add a configuration option for TC mode.
This patch adds a new configuation option that enables transparent
clock mode.  When TC mode is specified, the configured delay mechanism
must also match.  The legacy behavior of upgrading a multi-port clock
from OC to BC is preserved.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:46:43 -07:00
Richard Cochran 96716060b1 e2e_tc: Implement an end to end transparent clock.
The E2E TC forwards Announce, Delay_Req, Delay_Resp, Management,
Signaling, and Sync messages, and drops P2P Delay messages.

This implementation tracks the GM using the BMCA in order
to syntonize (or possibly even synchronize) with it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:46:43 -07:00
Richard Cochran 6a928ae867 p2p_tc: Implement a peer to peer transparent clock.
The P2P TC forwards Announce, Management, Signaling, and Sync
messages, consumes P2P Delay messages, and drops E2E Delay messages.

This implementation tracks the GM using the BMCA in order
to syntonize (or possibly even synchronize) with it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:46:43 -07:00
Richard Cochran a13212fcbb tc: Add the transparent clock implementation.
This patch adds code that sends an event messages received on one port out
all the other ports and calculates the residence time.  The correction,
ingress port, and the original message are remembered in a TC transmit
descriptor.  These descriptors are recycled in a memory pool in a similar
way to the message buffers.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:46:43 -07:00
Richard Cochran 4cfbb2627f port: Share more helper functions.
The transparent clock code will want to set qualification timeouts and
perform end to end delay measurements.  This patch exposes the needed
methods.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:46:28 -07:00
Richard Cochran 8f2b1db4fd clock: Add a method to determine whether a clock is free running.
This will be needed by the end-to-end transparent clock code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-01 07:01:57 -07:00
Richard Cochran 8feaa8ada8 Condense the 802.1AS example configuration.
As we add more and more options, it is getting to be a chore to add
each new option to multiple configuration files.  As we add more
profiles, each with its own example configuration file, the problem
will only get worse.

This patch condenses the gPTP example down to those options which
differ from the built in defaults.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-28 14:45:22 -07:00
Richard Cochran 4d69d48f96 telecom: Introduce the masterOnly option.
When masterOnly is true, the port always returns NULL when computing
its best foreign master.  As a result, the port will never enter the
SLAVE state, and the clock will ignore Announce messages received on
that port.

This attribute is specifically called out in G.8275.1 and G.8275.2,
and it is implied by the "master only" mode G.8265.1.  In addition,
this option will probably appear in the next revision of IEEE 1588.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-24 21:50:07 -07:00
Richard Cochran 0c30ab463f telecom: Add a configuration option to use the alternate BMCA.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-24 21:50:03 -07:00
Richard Cochran 4545fd1150 telecom: Add a configuration option for G.8275.portDS.localPriority.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-24 21:39:14 -07:00
Richard Cochran c7fb525721 telecom: Add a configuration option for G.8275.defaultDS.localPriority.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-24 21:39:13 -07:00
Richard Cochran f848a30a3e telecom: Add the data set comparison algorithm from the Telecom Profiles.
The first half of the telecom algorithm from G.8275.1 and G.8275.2
differs from the one in 1588, making use of profile specific
"localPriority" attributes.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-24 21:39:13 -07:00
Richard Cochran a8d0eb92c6 telecom: Introduce the local priority attribute into the data set.
The Telecom Profiles G.8275.1 and G.8275.2 have invented a new
per-port and per-clock attribute, not in 1588, called "localPriority".
The use of this attribute is a distinguishing feature of the telecom
data set comparison algorithm.

This patch adds the attribute, hard coded to its default value.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-24 21:39:13 -07:00
Richard Cochran 6f96ebb7b8 Refactor the data set comparison function variable.
There is no need to keep two copies of the data set comparison
function.  This patch adds a method that allows the port code to
obtain the function from the clock code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-24 21:39:10 -07:00
Ethel b2a36350bb nsm: Allow commands on command line.
Add a batch mode, where the commands are taken from the command line
instead of the standard input.

[ RC: keep automatic variables in alphabetical order and in reverse
  Christmas tree style. ]

Signed-off-by: Ethel <ethel.nilsson@est.tech>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-20 07:12:56 -07:00
Miroslav Lichvar a335ac556a phc2sys: fix PPS mode with no source clock.
When using a PPS source with no source clock specified with the -s
option, avoid referencing a NULL pointer and using CLOCK_INVALID in
system calls.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-04-19 20:08:04 -07:00
Miroslav Lichvar 966eff0161 phc2sys: fix race between signals and port initialization.
Check if a signal was received when waiting for ptp4l in the automatic
mode to not get stuck in an infinite loop.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-04-19 07:41:11 -07:00
Miroslav Lichvar e79e5040a0 timemaster: restart terminated processes.
If a ptp4l or phc2sys process is terminated (e.g. due to a crash) and
timemaster was running for at least one second (i.e. it's not an error
in ptp4l/phc2sys configuration), start the process again. Restart all
processes corresponding to the same time source at the same time to
ensure phc2sys is always connected to the currently running ptp4l.

Add a new option to disable the restarting.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-04-19 07:41:11 -07:00
Miroslav Lichvar e5ba2dae5f timemaster: add support for bonded interfaces.
Use the rtnl_get_ts_device() function to get the name of the slave
interface which will be timestamping PTP packets and use it instead of
the master interface to check the timestamping capabilities and PHC.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-04-19 07:41:11 -07:00
Miroslav Lichvar 742f878821 rtnl: remove dependency on config.h.
Change the rtnl_get_ts_label() function to accept the name of the master
interface and the buffer for the slave interface directly instead of the
struct interface from config.h.

Also, rename the function to rtnl_get_ts_device().

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-04-19 07:41:11 -07:00
Richard Cochran 29cd088347 msg: Detect missing HW time stamps on duplicated messages.
As of 510777deca message layer no longer returns -ETIME.  Callers of
msg_post_recv() are expected to check for missing time stamps themselves,
but the message duplication function followed the obsolete code pattern
of expecting that msg_post_recv() performs the check.  This patch fixes
the method to check properly for this error condition.

Fixes: 51b540875f ("msg: Introduce a method to copy a message.")

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-18 18:44:28 -07:00
Richard Cochran 7a76c36b34 nsm, pmc: Check for missing HW time stamps.
As of 510777deca message layer no longer returns -ETIME.  Callers of
msg_post_recv() are expected to check for missing time stamps themselves.
This patch updates the two forgotten call sites.

Fixes: 510777deca ("msg: Move the check for missing HW time stamps into caller.")

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-18 18:44:28 -07:00
Peter Schneider 0455489158 pmc: Fix LOG_SYNC_INTERVAL
In pmc, there is a little bug (only text, not functional):
When pmc is called with the management id 'LOG_SYNC_INTERVAL',
the response is '... seq 0 RESPONSE MANAGEMENT ANNOUNCE_RECEIPT_TIMEOUT' .
It should be '... seq 0 RESPONSE MANAGEMENT LOG_SYNC_INTERVAL'.
This patch fixes this.

[RC: Include explanation from 0/1 in commit message. ]

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:51:57 -07:00
Peter Schneider 89969b4b0f phc2sys.8: Doc long opts / cfgfile handling
[RC: Added -f flag help and removed extraneous text.]

Signed-off-by: Peter Schneider <peter@psch.de>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-18 14:37:12 -07:00
Peter Schneider 79d290e222 phc2sys.c: Implement using transportSpecific
Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider c93045b37b phc2sys.c: Implement handling of Long options
Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider c70f9b3e07 phc2sys.c: Implement configuration file handling
Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider 26308c219a phc2sys.c: Sync variable 'node.sanity_freq_limit with cfg item
Copy 'node.sanity_freq_limit' to struct config item 'sanity_freq_limit'.
Check for 'servo_type' == CLOCK_SERVO_NTPSHM.

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider c22864a807 phc2sys.c: Sync variable 'node.kernel_leap with cfg item
Use struct config item 'kernel_leap' for parameter handling. Copy this to
node.kernel_leap afterwards. Check for 'servo_type' == CLOCK_SERVO_NTPSHM.

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider 41fa8e9d32 phc2sys.c: Sync variable 'node.clock_servo with cfg item
Use struct config item 'clock_servo' for parameter handling. Copy this to
node.servo_type afterwards.

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider cfbc8bdc18 phc2sys.c: Replace usage of variable 'use_syslog'
Replaced usage of variable 'use_syslog' with struct config item
'use_syslog'. Original variable removed.

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider f7274b1e84 phc2sys.c: Replace variable 'verbose'
Replaced usage of variable 'verbose' with struct config item 'verbose'.
Original variable removed.

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider 97ff23cc07 phc2sys.c: Replace variable 'message_tag'
Replaced usage of variable 'message_tag' with struct config item
'message_tag'. Original variable removed.

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:40 -07:00
Peter Schneider 7986e10302 phc2sys.c: Replace variable 'print_level'
Replaced usage of variable 'print_level' with struct config item
'logging_level'. Original variable still used for range checking.

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:39 -07:00
Peter Schneider e8d01515cf phc2sys.c: Replace variable 'domain_number
Replaced usage of variable 'domain_number' with struct config item
'domainNumber'. Original variable still used for range checking. Removed
(now obsolete) third parameter of init_pmc().

Signed-off-by: Peter Schneider <peter@psch.de>
2018-04-18 14:27:39 -07:00
Richard Cochran f26ca92f1c clock: Maintain the master/local rate ratio when free running.
When using long chains of transparent clocks, the recommended practice is
to measure the rate ratio without adjusting the local clock.  Then the
residence times should be corrected to reflect the master's frequency.

This patch expands the clock_rate_ratio() method to provide the estimated
ratio when the clock is free running.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:37:26 -07:00
Richard Cochran eb8507a45a clock: Calculate frequency offset even without any delay estimation.
If the "free_running" option is set, the "no adjust" calculates and
prints an estimation of the phase and frequency offsets to the remote
master.  Because the phase estimate requires a delay measurement, this
calculation is not performed without having the delay estimate first.
However, a typical transparent clock application will want to use the
frequency offset to correct the residence times to match the master's
frequency.

This patch adds a call to the "no adjust" routine even if no valid
delay measurement has been made.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:37:26 -07:00
Richard Cochran 51b540875f msg: Introduce a method to copy a message.
The transparent clock will want to have two copies of certain messages,
one for forwarding and one for internal use (in the BMCA and for
syntonization).  This patch add a function that duplicates a given
message, including all of the attached TLVs.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:37:09 -07:00
Richard Cochran 1f65c3745c msg: Refactor the finding of the TLV suffix on receive.
Now that we have a helper routine to find the suffix, use that instead of
open coding the same logic.  This simplifies the code and consolidates the
definition of which message types are allowed to carry TLVs.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:29:05 -07:00
Richard Cochran 5f9163af4b transport: Introduce method for fetching a deferred transmit time stamp.
When a messages is sent with the DEFER_EVENT flag, the lower transport
code does not fetch the time stamp right away.  This patch introduces
a method that allows a second call to retrieve the waiting transmit
time stamp.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:29:05 -07:00
Richard Cochran e160bad721 transport: Introduce transmit time stamp deferral.
Up until now, the code has always fetched the time stamp immediately
after transmitting a message.  However, a transparent clock will want
to forward a given incoming message out all egress ports with as
little delay as possible, in order to minimize the residence time of
the message within the switch.

This patch adds a new transmit mode for event messages that will be
used to signal the new behavior.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:29:05 -07:00
Richard Cochran a1c5e3f2ed transport: Fix callers to pass a proper enumeration value.
The majority of the callers of transport_send() use hard coded magic
numbers.  This patch fixes them to use the corresponding enumerated
values instead.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:29:05 -07:00
Richard Cochran 4247eeb104 transport: Use the proper enumerated event code.
Originally the 'event' parameter to transport_send() was a single
Boolean flag.  Over time, we grew an enumerated list of event
flavors, but the function signatures were never updated.  This patch
changes the methods to use the proper type.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:27:03 -07:00