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>
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>
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>
[ RC - Correct the punctuation and abbreviation. ]
Signed-off-by: Peter Schneider <peter@psch.de>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
[ 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>
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>
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>
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>
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>
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>
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>
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>