Commit Graph

1184 Commits (605abc45dd63dc0dbf37fd6096267d1e8bdc144c)

Author SHA1 Message Date
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
Hangbin Liu 6d1e2a62bd rtnl: add function rtnl_get_ts_label to get interface ts_label info
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu 80bc4d4c2f rtnl: update function rtnl_link_status to get bond slave info
Update function rtnl_link_status to get bond slave info. Pass the slave index
to call back functions. i.e. port_link_status.

Also check the interface index of rtnl message in function rtnl_link_status.
Then we don't need to check it in port_link_status.

Add ifndef IFLA_BOND_MAX in case we build linuxptp on kernel before v3.13-rc1.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu 05bba46198 rtnl: update rtgenmsg to ifinfomsg when request link info
The previous function use general message and will dump all interfaces'
information. Now update with ifinfomsg so we could get specific interface's
information.

We still could get all interfaces' info if set device to NULL.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu 7e294a4d04 port: track interface info in port
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Hangbin Liu 9e744d9e8a config: add new element ts_label in struct interface
Add new element ts_label in struct interface to track real ts interface.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:17 -07:00
Miroslav Lichvar 17c9787b1d phc2sys: fix handling of multiple state changes.
When the master clock changed its state and then changed it back to the
original state before phc2sys could process the first change, e.g. SLAVE
-> UNCALIBRATED -> SLAVE after a clockcheck failure, the second change
was ignored because the new value was the same as the original state,
which wasn't updated for the first change yet. This caused phc2sys to be
stuck with a wrong state.

Fix phc2sys to check both the state and new_state variables of the clock.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2017-09-01 15:44:59 +02:00
Richard Cochran 14a97dc5da Remove redundant test on the UTC flags.
Now that we test the UTC flags in clock_update_slave(), the similar
code in clock_utc_correct() is redundant.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-08-23 20:36:56 +02:00
Richard Cochran fa575b60f6 Latch the UTC offset.
When acting as a slave, we accept the foreign master's advertised
TAI-UTC offset for as long as that master is present.  However, when
the master disappears, we fall back to the initial offset value.  As a
result of this behavior, when starting with an out of date initial
offset, losing a foreign master causes a sudden UTC offset error (in
phc2sys for example) in the range of whole seconds.

This patch fixes the issue by remembering the UTC offset when assuming
the slave role.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-08-23 20:36:56 +02:00
Richard Cochran 97e4242361 Simplify UTC tracking.
The clock code uses two different variables to store the TAI-UTC
offset.  One variable represents the compile time, configuration file,
or command line initial UTC offset, while the other is used when
taking on the GM role and is settable at run time.  However, making
this distinction makes no sense.  This patch simplifies and clarifies
the code by using a single variable for the offset.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-08-23 20:36:56 +02:00
Feras Daoud 7546434030 ptp4l: Add IPoIB interface support for ptp4l
The current implementation of ptp4l always assumes 6 octets MAC
address, which is correct for Ethernet interfaces but not for IPoIB
interfaces (that have 20 octets MAC), therefore running ptp4l over
IPoIB interface does not function correctly.

In Infiniband, every interface has three identifiers:
GUID, GID, and LID.
The GUID is similar in concept to a MAC address. From RFC4392:
The EUI-64 portion of a GID is referred to as the Global Unique
Identifier (GUID) and is the only persistent identifier of a port.

Therefore, to support IPoIB interfaces, the GUID of the port should
be used instead of the MAC.
This patch checks the interface type before creating the clock identity,
for Infiniband ports, it retrieves the GUID of the port using sysfs
and use it to create the clock identity.

sysfs method was chosen since the GUID is the 6 lsb bytes of
the 20 byte device address, and SIOCGIFHWADDR ioctl call returns
the 14 msb bytes of the device address, so it is not possible to
get the GUID using SIOCGIFHWADDR ioctl call.

[ RC: fixed trivial coding style error, space after switch keyword. ]

Signed-off-by: Feras Daoud <ferasda@mellanox.com>
Reviewed-by: Alex Vesker <valex@mellanox.com>
2017-08-10 10:42:16 +02:00
Hangbin Liu 7c3f9579f0 clock: remove hash table index2port
Remove index2port since we don't need it now.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-07-13 07:19:57 +02:00
Hangbin Liu 25ec8a3b4e clock: remove rtnl fd on clock
Remove rtnl fd on clock since we track the link status per port now.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-07-13 07:19:57 +02:00
Hangbin Liu c149a3dbc1 port: add FD_RTNL event to track per-port status
With rtnl socket we can track link status per port(except UDS port).

We can make sure we get the correct interface and latest status with function
port_link_status().

At the same time we need to set clock sde after link down. But we return
EV_FAULT_DETECTED in port_event(), which will not set clock sde. So we need
to set it in port_link_status().

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-07-13 07:19:57 +02:00
Hangbin Liu 17aa750a49 rtnl: replace obsolete RTMGRP_LINK with RTNLGRP_LINK for nl groups
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-07-13 07:19:57 +02:00
Hangbin Liu 46cc187e82 phc2sys: free clock device when exit
Since we called strdup() for clock device, we need free the memory
before exit.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-06-23 07:31:43 +02:00
Cliff Spradlin via Linuxptp-devel 6b18e12b9b phc2sys: Add described device to stats output
When phc2sys synced more than one ethernet interface, such as in a JBOD
boundary clock arrangement, it was unclear which interface a line of statistics
referred to.

Previous output:

phc2sys[583.098]: sys offset       -32 s2 freq +131974 delay   3871
phc2sys[583.098]: sys offset        33 s2 freq +125746 delay   4095
phc2sys[583.098]: sys offset       -73 s2 freq +125720 delay   4128
phc2sys[583.098]: sys offset       -19 s2 freq +133265 delay   3888
phc2sys[583.098]: sys offset         2 s2 freq +131986 delay   3920

Now:

phc2sys[583.098]: eth9 sys offset       -32 s2 freq +131974 delay   3871
phc2sys[583.098]: eth8 sys offset        33 s2 freq +125746 delay   4095
phc2sys[583.098]: eth7 sys offset       -73 s2 freq +125720 delay   4128
phc2sys[583.098]: eth6 sys offset       -19 s2 freq +133265 delay   3888
phc2sys[583.098]: eth1 sys offset         2 s2 freq +131986 delay   3920

Signed-off-by: Cliff Spradlin <cspradlin@google.com>
2017-06-19 08:14:40 +02:00
Brian Olson 7c6a9862fd added workaround for ticks being returned as zero from 2.6.32 kernel.
Signed-off-by: Brian Olson <brian@amergint.com>
2017-06-19 08:14:40 +02:00
Brian Olson ae28f5295f fixed include order to work around issue on RHEL 6.6
[ RC: Added comment explaining the ordering requirements. ]

Signed-off-by: Brian Olson <brian@amergint.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2017-06-19 08:13:40 +02:00