Commit Graph

1066 Commits (faf0e0a02529f1135f80d9edba101e953b2064f8)

Author SHA1 Message Date
Richard Cochran faf0e0a025 Introduce unicast client logic.
This patch adds new code that runs the state machine and handles the
TLVs for requesting unicast service from a remote master.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 22:10:06 -07:00
Richard Cochran ffdb3f7192 fd: Introduce a unicast request timer.
This patch adds a new timer to be used by the client side unicast
negotiation logic.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran 1ccc55ef07 port: Add a method for constructing signaling messages.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran 0fffa6c4b5 Introduce the unicast client finite state machine.
In order to implement client side unicast negotiation, state is needed
per port and master.  This patch adds the needed state machines.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran e22dc6b113 config: Introduce a unicast master table.
This patch adds configuration file support for a table of unicast
masters.  Each table lives in its own section and has a unique,
positive numerical ID.  Entries in the table are a pair of transport
type and protocol address.

Each port may specify a table id to be used for unicast negotiation.
Tables may not be shared between ports, but nothing prevents table
entries from appearing in more than table.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran 1d450540c7 msg: Support unicast negotiation message formats.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran f94df4f625 port: Make the sync and announce transmit functions public.
These functions will be needed by the new unicast mode.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:48 -07:00
Richard Cochran 05dce31d81 port: Allow transmission of unicast announce messages.
This will be needed by unicast mode.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:47 -07:00
Richard Cochran bc18131d27 util: Add a method to compare binary addresses.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:47 -07:00
Richard Cochran 40480f3b28 util: Make a useful helper function more public.
The function, str2addr(), will be needed by the upcoming unicast
client code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-07-01 06:27:47 -07:00
Richard Cochran ffbafa557b transport: Fix even more callers to pass a proper enumeration value.
All of the callers of transport_peer() 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-07-01 06:25:34 -07:00
Rafaël Carré 5219b6417f udp*: multicast join work with specific addresses
Remove unused sockaddr size argument, and pass address using specific struct

Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré ee2a9d4ac9 follow_up_info_append: port argument is unused
Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré d52ef498cf phc2sys: document switch/case fallthrough so that gcc can understand it
Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré bdaff2ecd2 transport_txts(): transport argument is unused
Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré 77995137bf config_alloc_longopts(): argument is unused
Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Rafaël Carré 3c7fa5dd42 clock_send_notification: msg_len is unused
message length is already included in the msg structure

Signed-off-by: Rafaël Carré <funman@videolan.org>
2018-06-25 07:24:17 -07:00
Michael Walle 6bc77ccf4b Replace memcmp() with pid_eq() and cid_eq()
Consistenly use the pid_eq() and cid_eq() helper functions. Move the
functions into utils.h (making them inline functions) because they are
used in multiple source files.

Signed-off-by: Michael Walle <michael@walle.cc>
2018-06-21 07:18:24 -07:00
Cliff Spradlin via Linuxptp-devel 4c5d180ab3 phc2sys: don't over-control a destination clock
If ptp4l is running as a boundary clock, and multiple master ports
share a hardware clock that is different than the slave port's
hardware clock, then phc2sys in autocfg mode will synchronize that
clock multiple times per sync loop, once per-port.

Example output when this happens:
CLOCK_REALTIME phc offset        -9 s2 freq    -355 delay   3635
eth9 phc offset         9 s2 freq   +1762 delay   7488
eth8 phc offset        41 s2 freq   +1985 delay   7424
eth7 phc offset        15 s2 freq   +1952 delay   7440
eth6 phc offset        20 s2 freq   +1059 delay   7440
eth1 phc offset        22 s2 freq   +1783 delay   7424
eth12.400 phc offset        15 s2 freq -4207943 delay   7551
eth12.300 phc offset       388 s2 freq +2336645 delay   7536
eth12.200 phc offset       451 s2 freq +2516553 delay   7438
eth12.100 phc offset       268 s2 freq  +64274 delay   7405

This is easily reproducible by adding VLANs to a single network
interface and configuring ptp4l to use those VLAN interfaces as PTP
ports.

This patch prevents this problem by introducing a new deduplicated
destination clock list to phc2sys. Each time phc2sys reconfigures,
the destination clock list is re-populated. In the synchronization
loop, phc2sys will only use the clocks in this list.

Example output of reconfiguration with this patch:
reconfiguring after port state change
selecting eth9 for synchronization
selecting eth8 for synchronization
selecting eth7 for synchronization
selecting eth6 for synchronization
selecting eth1 for synchronization
selecting eth13.400 for synchronization
skipping eth13.300: eth13.400 has the same clock and is already selected
skipping eth13.200: eth13.400 has the same clock and is already selected
skipping eth13.100: eth13.400 has the same clock and is already selected
selecting eth12.400 for synchronization
skipping eth12.300: eth12.400 has the same clock and is already selected
skipping eth12.200: eth12.400 has the same clock and is already selected
skipping eth12.100: eth12.400 has the same clock and is already selected
skipping eth13.500: eth13.400 has the same clock and is already selected

This patch was tested with autocfg mode and also when specifying source
and destination manually via commandline.

Signed-off-by: Cliff Spradlin <cspradlin@google.com>
2018-06-18 11:01:56 -07:00
Cliff Spradlin via Linuxptp-devel dc0f6427bd port: don't clockcheck timestamps from other domains
ptp4l runs clockcheck on an incoming PTP message before checking its
domain number. If the time on another domain is different, then
clockcheck will trigger spurious synchronization faults.

This patch reorders the logic so that clockcheck only runs on messages
in the same time domain.

Reported-By: Filip Perich <perich@google.com>
Signed-off-by: Cliff Spradlin <cspradlin@google.com>
2018-06-13 21:15:19 -07:00
Richard Cochran ccfeb3b092 msg: Introduce a helper to test for unicast messages.
With increasing unicast support, the code needs to identify unicast
messages more often.  This patch replaces the open coded bit field
tests with a more readable in line helper function call.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 15:28:35 -07:00
Richard Cochran 28ddb51567 port: Don't take the interval from unicast sync messages.
According to the standard, unicast Sync messages are to be sent with
the interval field set to 127.  This patch adds a test to avoid
incorrectly adopting that value as a new interval.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 07:46:04 -07:00
Richard Cochran 494643d1fb port: Correct log message interval field of unicast Sync messages.
According to the standard, this field is special for unicast messages.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 07:46:03 -07:00
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