Commit Graph

1066 Commits (faf0e0a02529f1135f80d9edba101e953b2064f8)

Author SHA1 Message Date
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
Michael Brown 29a99ad513 msg: Represent hw_timestamp "ts" field as tmv_t
Convert a hardware timestamp to the internal tmv_t representation at
the earliest possible opportunity.  This allows us to:

- eliminate multiple redundant calls to timespec_to_tmv()

- use tmv_add() instead of open-coded manipulation of a struct
  timespec in ts_add()

- use tmv_to_Timestamp() instead of open-coded manipulation of a
  struct timespec and struct Timestamp in ts_to_Timestamp()

- use tmv_is_zero() instead of open-coded manipulation of a struct
  timespec in msg_sots_valid()

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Michael Brown 5a23ccddf6 port: Match calling convention for tmv_to_Timestamp()
The function ts_to_timestamp() currently performs open-coded
manipulation of a struct timespec and struct Timestamp instead of
using the tmv_t abstractions.

Prepare for the removal of this code by matching the calling
convention for tmv_to_Timestamp(): returning a struct Timestamp rather
than accepting a pointer to a struct Timestamp.

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Michael Brown cdceec59fa port: Treat ingressLatency and egressLatency as corrections
The function ts_add() currently performs open-coded manipulation of a
struct timespec instead of using the tmv_t abstractions.

Prepare for the removal of this code by storing ingressLatency and
egressLatency as corrections (matching the behaviour for
delayAsymmetry).

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Michael Brown c9f3fad780 clock: Remove open-coded conversion of struct timespec
The function clock_check_ts() performs open-coded manipulation of a
struct timespec instead of using the tmv_t abstractions.

Use the existing tmv_t abstractions to convert from struct timespec to
nanoseconds, and modify the prototype of clock_check_ts() to match
that of the underlying clockcheck_sample().

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Richard Cochran ab8dc20cf7 nsm: Implement the NetSync Monitor query.
This patch adds a new "NSM" program.  The new code handles only one
outstanding NSM command at a time.  If and when all four event time
stamps have arrived, the code prints the instantaneous estimated
offset without any averaging or smoothing.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-08 07:20:42 -08:00
Richard Cochran 0483bf4972 util: Relocate utility functions from pmc.c.
The file, pmc.c, contains utility functions for printing out a port address
structure.  We will want to call these functions from pmc_common.c, and so
this patch moves the utility functions where they belong.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-08 07:20:42 -08:00
Richard Cochran d89d26d618 Add a configuration file option to enable the NetSync Monitor protocol.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-08 07:20:42 -08:00
Richard Cochran 61e57e9fca port: Implement the NetSync Monitor protocol.
When NSM is enabled on a given port, that port always replies to a NSM
delay request with a delay response, sync, and follow up, regardless
of the current state of the port.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-08 07:20:42 -08:00
Richard Cochran b0d9c9600a port: Introduce unicast sync messages.
The port will need to send unicast Sync messages in order to support
the NSM protocol.  Besides that, we will need this ability anyhow if
we ever want to implement unicast operation.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-08 07:20:42 -08:00
Richard Cochran 3a264e6eec tlv: Introduce the NetSync Monitor TLVs.
This patch adds support for packing and unpacking the NSM TLVs.  In
addition, it introduces macros to make the ntoh/htoh boilerplate easier
to read.  The idea is to reduce the number of monstrous muti-line
assignments like:

	pds->grandmasterClockQuality.offsetScaledLogVariance =
		htons(pds->grandmasterClockQuality.offsetScaledLogVariance);

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-08 07:20:42 -08:00
Richard Cochran 7a2013360a tmv: Add a method to convert to a struct Timestamp.
This will be needed in order to generate a TLV for the NSM protocol.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-08 07:20:42 -08:00
Richard Cochran 36550e415c clock: Introduce a method to obtain the last synchronization time.
The NetSync Monitor protocol will require us to report the time stamp of
the last synchronization.  This patch adds new the method.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran fb2c979182 clock: Introduce a method to get the current dataset.
As part of the NetSync Monitor protocol, the port will need to have
access to the current data set.  This patch adds the appropriate
function.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 9d48046e95 msg: Allow tacking a TLV onto a delay request message.
This will be needed in order to support the NetSync Monitor protocol.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 613f005996 msg: Allow zero length TLVs.
The NetSync Monitor protocol features a TLV with a length of zero.
Our input message parsing assumes that every TLV will have some sort
of payload, and up until now this was true.  This patch adjusts the
parsing code to accept TLVs of length zero.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran a003b4c36e port: Accept multiple TLVs on receive.
Path trace TLVs and Follow-Up info TLVs might be mixed in among other
random TLVs.  This patch fixes the parsing code to find these TLVs even
when multiple other TLVs are present.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran ecb5fa8ffb msg: Remove the 'last_tlv' field.
All users have been converted to the TLV list, so remove the field.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran a061256bbd msg: Use the TLV list on transmit.
Now that the list is in place and is used on all transmit paths, simply
iterate through the list when converting to network byte order.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran e0005dac94 port: Convert to the API for appending TLVs on the transmit path.
The current code uses an ad hoc method of appending TLVs.  When
constructing a message, the code computes the total PDU length by adding
the message size to the TLV size.  By using the new API, this patch
simplifies message construction, letting each TLV add its own length
to the total.

As a result of the this change, the return value for the helper
functions, follow_up_info_append() and path_trace_append(), has
changed meaning.  Instead of returning the TLV length, these functions
now provide an error code.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran e09d3a4aea pmc: Remove unused parameter.
The third parameter of the function, pmc_send(), is never used.  This patch
removes it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran b6fa8e20ee pmc: Convert to the API for appending TLVs on the transmit path.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 4a8877f904 msg: Introduce method for appending multiple TLVs on transmit.
In order to support multiple TLVs, the transmit code must be able to
append one TLV after another.  This patch adds a method that checks
whether there is room, allocates the TLV descriptor, sets the buffer
pointer, and appends the descriptor to the list.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 7fe69e7ba0 msg: Populate the TLV list on receive.
This patch changes the receive message parsing code to place each TLV
into the list.  A method is introduced that allows attaching TLVs to
the end of the list.

In addition, msg.last_tlv is converted into a pointer to the last item
in the list.  Because of this change, the transmit code that uses this
field now allocates a TLV before using it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 22b894b687 msg: Introduce a TLV list.
In order to support multiple TLVs per message, a list is needed.
This patch adds the list to the message structure.  This list will
eventually replace the 'last_tlv' field.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran c8d9d05e7a tlv: Implement a memory pool for TLV descriptors.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Michael Brown d432cdc52a tmv: Convert tmv_t to a non-scalar type
Enforce the use of the tmv_t wrapper functions by converting tmv_t
from an int64_t to a struct containing an int64_t.

Inspection of the disassembly shows that this change has essentially
no impact on the resulting object code, at least for x86_64 with
compiler optimisations enabled.

RC:
  - Fixed up after dropping one previous patch in the series.
  - Removed the new function, tmv_to_Timestamp, as that will
    be introduced later on.

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 11:39:28 -08:00
Michael Brown ffc5b93f95 tmv: Add tmv_sign()
The sign of time values is tested in tsproc.c.  Add an abstraction
tmv_sign() to return the sign of a time value.

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Michael Brown 1b7ff890be tmv: Generalise tmv_eq() to tmv_cmp()
Time values are compared using an inequality test in mmedian.c
Generalise tmv_eq() to tmv_cmp() (by analogy with memcmp()) and
replace existing uses of tmv_eq().

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Michael Brown ea82ae6c28 tmv: Add missing uses of tmv_to_nanoseconds()
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Michael Brown 12c9805eab tmv: Add missing uses of tmv_dbl()
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Michael Brown 5df2779ef0 tmv: Add missing uses of tmv_is_zero()
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Michael Brown 288810bb36 tmv: Add missing uses of tmv_zero()
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Michael Brown 759f3f4019 clock: Pass floating point values to stats_add_value()
Use tmv_dbl() to obtain the floating point value passed to
stats_add_value() rather than relying on the existing implicit cast
from the result of tmv_to_nanoseconds().

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Richard Cochran 8982ef9c40 tlv: Fix coding style.
We are programming C, not Java, and so opening braces of a function
belong on a line all by themselves.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:37:54 -08:00
Richard Cochran d34d253fb4 port: Fix coding style.
We always but braces around 'if' blocks.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:37:54 -08:00
Richard Cochran 8ecdedaa69 pmc: Add missing break in switch/case.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:37:54 -08:00
Richard Cochran 201abc9b95 pmc: Fix white space errors.
We indent with tabs, not spaces.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:37:54 -08:00
Richard Cochran 3870bc1c5b clock: Fix coding style. 2018-03-06 06:37:54 -08:00
Richard Cochran 4a39103c74 clock: Simplify management response logic.
The code uses a local variable for program flow control in a silly way.
This patch simplifies the logic by using the common switch/case/default
pattern instead.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:37:54 -08:00
Richard Cochran 2d25209993 port: Simplify management response logic.
The code uses a local variable for program flow control in a silly way.
This patch simplifies the logic by using the common switch/case/default
pattern instead.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:37:54 -08:00
Richard Cochran 0a726b4390 port: Clean up coding style.
Re-arrange local variables into a more legible reverse Christmas tree.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:31:46 -08:00
Richard Cochran b01e84af98 raw: Fix valgrind setsockopt warning.
Valgrind is nagging us, saying we pass uninitialized data through a
setsockopt() call.  This patch fixes the issue by clearing the entire
passed structure.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:31:46 -08:00
Richard Cochran ae28894814 msg: Share a static global more globally.
Any code that wants to call one_step() needs to link with the static
global 'assume_two_step'.  This patch moves that variable's definition
from ptp4l.c to msg.c.  Not only is that file the more natural choice
(since the variable is used on msg.h) but also this allows other
programs to call the one_step() function.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:31:46 -08:00
Richard Cochran 99fd084253 Introduce an option to ignore the transport specific field.
Up until now the transportSpecific field has been treated according to
802.1AS, namely as a field that must match exactly on receive.
However, 1588 mandates ignoring this field for some transports, and
there is equipment in the wild that does in fact set the reserved
bits.

This patch adds an option to ignore the field on receive completely.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Petr Kulhavy <brain@jikos.cz>
2018-03-06 06:31:04 -08:00
Miroslav Lichvar 4b957cf566 clock: add option to specify initial path delay.
This option allows the clock to be updated before the path delay is
measured in order to speed up the initial correction of the clock, e.g.
in domains using a very long logMinDelayReqInterval.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-02-19 09:47:13 -08:00
Miroslav Lichvar 16e9abceee port: update timeout after changing logMinDelayReqInterval.
When the minimum delay request interval is changed after processing a
delay response, update the current timeout to immediately follow the new
interval.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-02-19 09:47:13 -08:00