Commit Graph

952 Commits (7a2013360a72fddcceef26bee037ba57206f6eef)

Author SHA1 Message Date
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
Miroslav Lichvar bd5f3d09e7 sk: turn warnings about unexpected RX filter into debug messages.
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>
2018-02-19 09:47:13 -08:00
Miroslav Lichvar 303b08cbf5 clock: Don't forward management requests to UDS port.
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>
2018-01-01 20:11:42 -08:00
Richard Cochran dacf9dcd24 Add an acknowledgment in the readme for Meinberg.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-11-25 11:43:38 -08:00
Hangbin Liu 5ce04f9bf3 phc2sys: update '-s' option
Add description about bond interface.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-24 13:51:48 -07:00
Miroslav Lichvar 18daeb6b26 sk: don't leak socket when reading of IB GUID fails.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2017-10-16 06:51:27 -07:00
Richard Cochran 20a229e168 Add compile time sanity check for interface name lengths.
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>
2017-10-14 06:05:12 -07:00
Miroslav Lichvar d513ecac9c phc_ctl: fix adj command to accept negative offset.
When parsing the argument, the minimum value should be -DBL_MAX instead
of DBL_MIN, which is the smallest positive value.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2017-10-14 05:51:43 -07:00
Hangbin Liu 7092db3030 port: return timestamping iface in port properties
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu 8a349e557c phc2sys: re-create clock clkid and servo when phc index changed
When the clock device or phc index changed, the new phc device may have
different maximum adjustment. So we need to create a new clkid and servo
in clock_reinit().

At the same time, we should not only do clock_reinit() when the new state
is PS_MASTER. We also need to reinit clock after a failover in slave mode(
the new state is PS_SLAVE). We can do clock_reinit() even in PS_FAULTY so
we can finish adjust offset before come back to PS_LISTENING. So I removed
the check and let's do clock_reinit() whenever there is a new state.

And for servo reset, as Miroslav suggested, we will do it in these cases:
- the system clock is the new destination (master state)
- a PHC is the new destination (master state)
- a PHC is switched (in any state)

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu cb53238d5d phc2sys: split servo_add from function clock_add
We also need this part in clock_reinit() later. So split it out of
function clock_add().

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu 8923bcdf64 transport: pass struct interface to transport_open
Pass struct interface so we can use ts_iface in HW filter.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu 536a71031d ptp4l: use ts label to get ts info
Now the ts label will be either the bond active slave or the interface
name, which is the exactly interface we need to get ts info.

When the link down/up or there is a fail over and ts_label changed, the
phc index may also changed. So we need to check get new ts info and check
clock_required_modes. We will set the link to LINK_DOWN by force if
the new ts_label's timestamp do not support required mode.

If all good, then we set phc index to new one. Also sync clock interval
after switch phc.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu 1440f09384 clock: add clock_required_modes to obtain the required time stamping mode
Separate required_modes setting from clock_create so we can obtain the
required time stamping flags from other place.

Add enum timestamping in struct clock to store the time stamping mode.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu b65b1d5f3b port: update port link_status to enum
Besides link up and down, we may also receive other rtnl messages, like
bond slave changed info, which link state keeps the same.

So we should return EV_FAULT_CLEARED only when both LINK_UP and
LINK_STATE_CHANGED.

When the link state keep the same, we should return EV_NONE.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00