Commit Graph

1162 Commits (ee6930a884e5b1c2b521b69bbb766e659560c80c)

Author SHA1 Message Date
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
Anders Selhammer da7bc1db1e clock: Fix coding style
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-04-12 19:47:51 -07:00
Anders Selhammer b36142cb51 port: Fix coding style
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-04-12 19:47:51 -07:00
Richard Cochran 98e6c8de58 sk: Silence gcc warning about unused variable.
When compiling with "-O1 -D_FORTIFY_SOURCE=1", gcc throws a false positive
warning.  The code is not performance sensitive, so this patch silences
the warning by initializing the offending local variable explicitly.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-06 18:41:15 -07:00
Miroslav Lichvar 73c4d9a3c7 port: fix buffer overflow in net_sync_resp_append()
The PortAddress structure has no space for the actual address and should
be used only as a pointer to a larger buffer.

The issue was reported by gcc with enabled source fortification.

[ RC: Replace magic number with sizeof() macro. ]

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-06 18:41:10 -07:00
Richard Cochran 74cdaafd5b Correct the make install target.
The make install target tries to install a man page that does not
exist.  This patch fixes the makefile to install the existing man
pages only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-06 18:41:05 -07:00
Richard Cochran 46acbcee42 port: share init code, peer delay code, and helpers
This patch makes a number of subroutines into global functions in order
to share code with the TC implementations to come.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-03 09:28:22 -07:00
Richard Cochran d87bb60712 port: export a private interface.
This patch places the internal port data structure into a common header
for use by the original BC and the new TC code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-03 09:28:22 -07:00
Richard Cochran 866da1044c port: Provide a common method for updating the port state.
When computing the next port state based on a FSM event, much of the logic
will stay the same for OC, BC, and TC nodes.

- handling a fault ASAP
- INITIALIZING state handling
- showing the transition in the log
- sending notifications

This patch moves this common code into a global port method, making it
available to future TC implementations.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-03 09:28:22 -07:00
Richard Cochran c170405822 port: make the dispatch and event methods variable based on clock type.
This paves the way to allow different implementations for the upcoming
Transparent Clock code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-03 09:28:22 -07:00
Richard Cochran dc1b7c66c6 bmc: Make the second part of the data set comparison algorithm public.
This code will be shared by future alternative algorithms.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-03 09:28:22 -07:00
Richard Cochran 1b3ef0d195 bmc: Allow alternative data set comparison algorithms.
Instead of using a hard coded algorithm, let the caller provide the
function that performs the comparison.  This will allow implementing
alternative algorithms from PTP profiles.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-03 09:28:22 -07:00
Richard Cochran b05991dbb8 clock: Make the data set comparison algorithm into a function variable.
This will allow adding alternative algorithms as defined in PTP profiles.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-03 09:28:22 -07:00
Richard Cochran ec33010f56 port: Make the data set comparison algorithm into a function variable.
This will allow adding alternative algorithms as defined in PTP profiles.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-03 09:28:22 -07:00
Richard Cochran d14f11fd32 msg: Append multiple TLVs correctly.
The logic that adds TLVs to the end of a message mixes up the 'L'
length in "TLV" with the total TLV length.  As a result, the second
and subsequent TLVs will corrupt the previous TLV in the buffer.  This
patch corrects the code to find the correct offset for the second and
following appended TLVs.

Note that the stack does not currently trigger this latent bug because
only single TLVs are appended.

Fixes: 4a8877f904 ("msg: Introduce method for appending multiple TLVs on transmit.")

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-02 22:09:50 -07:00
Richard Cochran d8a9591dac Version 1.9
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-31 11:36:56 -07:00
Richard Cochran 4e35931bc8 phc2sys: Clean up before exiting.
Valgrind complains about memory leaks, none of which are serious.  This
patch frees the allocations on exit, so that any future *real* memory leaks
will be obvious in the valgrind report.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-31 11:32:55 -07:00
Richard Cochran 992e292055 Make the LIST_FOREACH_SAFE publicly visible.
We will want to use this macro in more than one source file.  This patch
moves the macro into the common header for possibly undefined code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-31 11:05:57 -07:00
Richard Cochran d465406106 pmc: Initialize variable on the stack.
Valgrind is complaining that the pmc program is using uninitialized
data.  Actually the data are partially initialized, but it can't hurt
to zero the entire data structure.  Doing so silences the valgrind
warning, and after all it is good practice.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-30 10:29:30 -07:00
Richard Cochran 8857ad9834 Expand and rationalize time stamping options.
Up until now, one step operation was controlled by a combination of
options, namely time_stamping=hardware with twoStepFlag=0.  The
introduction of peer to peer one step makes the situation a bit more
complicated.

This patch adds support for setting the one step options directly by
using the "time_stamping" option.  The "twoStepFlag" is adjusted
automatically if needed.  The legacy behavior for Sync message one
step is preserved.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-27 22:26:32 -07:00
Richard Cochran 4842d2c7ec Introduce peer to peer one step.
The 1588 standard defines one step operation for both Sync and
PDelay_Resp messages.  Up until now, hardware with P2P one step has
been rare, and kernel support was lacking.  This patch adds support of
the mode in anticipation of new kernel and hardware developments.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-27 22:26:32 -07:00
Richard Cochran 510777deca msg: Move the check for missing HW time stamps into caller.
On the transmit path, the port-level code calls msg_sots_missing()
directly, but on receive this check is buried in the message layer.
With the coming addition of peer to peer one step, the ingress check
will need knowledge of the configured time stamping option.  This
patch moves the check in order to accommodate the exceptional case.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-27 22:26:32 -07:00
Richard Cochran a412982300 Correct macro to avoid undefined C language behavior.
I stumbled across a kernel commit that fixes the macro that convert
between file descriptors and clock ID types (see below).  This patch
corrects the FD-to-clockid macro by casting to unsigned before
shifting.

commit 29f1b2b0fecfae69e31833836f1da3136696eee5
Author: Nick Desaulniers <nick.desaulniers@gmail.com>
Date:   Thu Dec 28 22:11:36 2017 -0500

    posix-timers: Prevent UB from shifting negative signed value

    Shifting a negative signed number is undefined behavior. Looking at the
    macros MAKE_PROCESS_CPUCLOCK and FD_TO_CLOCKID, it seems that the
    subexpression:

    (~(clockid_t) (pid) << 3)

    where clockid_t resolves to a signed int, which once negated, is
    undefined behavior to shift the value of if the results thus far are
    negative.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-27 18:30:09 -07:00
Jacob Keller 862724fda5 differ message printed when local clock is best master
Make the log output a bit more clear by changing how we inform the user
when the local clock is the best master clock. This allows easier
parsing of the log and identifying when the local clock is being
selected as the best clock.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
2018-03-27 18:22:22 -07:00
Peter Schneider c4e5879233 pmc: Documentation for long opts / cfg file
[ RC - Correct the punctuation and abbreviation. ]

Signed-off-by: Peter Schneider <peter@psch.de>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-24 21:15:17 -07:00
Peter Schneider c96dea72f1 pmc: add long options and configuration file
[ RC: - Add new flag into usage message.
      - Fix up coding style of the automatic variables. ]

Signed-off-by: Peter Schneider <peter@psch.de>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-24 21:15:17 -07:00
Peter Schneider ea9dda30e2 pmc_common: Preset uninitialized 'iface.ts_label' with 'iface.name'
pmc_create() calls transport_create(), which sets the open function
for the interface 'iface' to raw_open(), if Layer 2 is used. The
immediate following call of transport_open() calls raw_open(), which
uses the field .ts_label for opening, instead of the field .name
(which is used in the other transport layers). Therefore, the
field .name is copied here into the field .ts_label .

[ RC - Actually ts_label should always be initialized. Made the
       assignment of ts_label unconditional, regardless of the choice
       of transport layer. ]

Signed-off-by: Peter Schneider <peter@psch.de>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-24 21:14:35 -07:00
Anders Selhammer f9db6855fd port: Added TAILQ for sent delay_req
In a ptp unaware network (like the telecom profile for frequency sync
G.8265.1), both the RTD and the PDV can be substantially higher than
in a ptp aware network. To achieve more accurate measurements, the
rate may need to be configured higher to get more data and increase
the chance of lucky packets.
In a combination of a high configured rate of delay_req and high
RTD/PDV in network, the risk that the response from the previously
sent delay_req have not been received before a new delay_req is sent
also become high. In that case, the need of storing more than the
latest sent delay_req arise.

This patch adds a queue for sent delay requests so several request can
be ongoing in parallel. When a delay response is received, a matching
request will be searched for in the queue and after processed removed
from the queue.
The stored delay_req will be removed if older than 5 seconds. Check is
made before a new delay_req is sent or announce receipt tmo expires.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-03-24 14:40:35 -07:00
Anders Selhammer 9320f768e2 port: Fix coding style
We always but braces around 'if' blocks.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-03-24 14:40:35 -07:00
Michael Brown 1e19ce204a port: Remove unnecessary conversions from tmv_t to int64_t
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Michael Brown 73c59e83d9 port: Remove unnecessary ts_to_Timestamp() wrapper
The function ts_to_Timestamp() is now just a wrapper around
tmv_to_Timestamp().  Simplify code by using tmv_to_Timestamp()
directly.

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Michael Brown 7f59858d08 msg: Represent hw_timestamp "sw" field as tmv_t
Convert a software timestamp to the internal tmv_t representation at
the earliest possible opportunity, to match the behaviour for hardware
timestamps.

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00