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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
When a network interface doesn't support the most specific PTP filter
(e.g. it can timestamp either all or no received packets), it is
expected that the driver will report a different filter than was
requested. Turn the warnings into debug messages to avoid confusing
the users.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
The UDS port is not expected to be used by PTP clocks and forwarding of
management messages to the port can be limited to responses.
This prevents ptp4l from printing error messages when a management
request is received from a non-UDS port and the last client which used
the UDS port is no longer listening.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Because our interfaces include UNIX domain sockets, we are using
UNIX_PATH_MAX of 108 bytes for our interface names. Even though
IF_NAMESIZE is much smaller (16 bytes), there is nothing that
guarantees this. This patch adds a compile time sanity check that
tests whether the interface name will fit.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>