Commit Graph

1139 Commits (3f5f5653d7966da8ba96d64fbf74aa472e9f078c)

Author SHA1 Message Date
Vedang Patel 3f5f5653d7 port: Add interval update mechanism.
This commit adds functionality to increase the sync and pdelay request
intervals once gptp synchronization has been achieved. This is useful
while running Automotive Profile where the network is usually static.

Here, we are assuming that the gPTP synchronization is achieved whenever
the last 'n' offsets calculated using the Sync messages are below a
certain threshold. Both, the number of offsets to consider and the offset
threshold are configurable.

In order to support the interval update, a new clock servo state
CLOCK_SERVO_STABLE has been added. The clock will transition to this
state whenever the above condition is satisfied. When this transition
occurs, the slave will send an "interval request" signaling message
asking the master to change the sync interval. It will also update the
pdelay request interval locally.

Four new config options have been added to provide this functionality:

- servo_offset_threshold: All the offset values being considered should
  be below this value.
- servo_num_offset_values: number of previously received offset values
  to consider.
- operLogSyncInterval: slave will ask the master to switch to this
  interval for sending sync messages when the offset stabilizes.
- operLogPdelayReqInterval: the slave will set this interval for pdelay
  request messages when the offset stabilizes.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2019-05-08 21:29:48 -07:00
Vedang Patel 78b4b780da clock: add APIs to access servo and servo_state
Make servo and it's current state available outside clock.c

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2019-05-08 21:29:48 -07:00
Vedang Patel 630ce719fc port: implement message interval request processing
This implements transmission and receipt of message interval requests.
Using this mechanism, a time-aware device can request change in sync,
link delay and announce intervals on the device connected on the other
end.

As part of the commit, we are also saving the initial values of Announce
and Sync Interval.

For more information look at sections 10.2.4.4, 10.3.9.5, 10.3.14, 10.4,
10.5.4 and 11.2.17 of 802.1AS standard

Please note that this commit does not implement logic related to
computeNeighborRateRatio and computeNeighborPropDelay flags mentioned in
Section 10.5.4.3.9 of 802.1AS Standard.

[ RC - memset the targetPortIdentity to all ones. ]

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-05-08 21:29:29 -07:00
Vedang Patel 888afcdbae port: Add logPdelayReqInterval.
It will be used to store the current value of Pdelay Request Interval.
It will be represented as power of two in seconds.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2019-05-08 21:29:29 -07:00
Vedang Patel 43085ab741 port: Separate unicast specific code from port_signaling_construct()
Make port_signaling_construct() to create a generic signaling
ptp_message. Move the unicast specific code to
port_signaling_uc_construct().

This is done to support the creation of Message Interval Request TLV (as
defined in 802.1AS Section 10.5.4.3). This TLV can be used to request
change in Announce Interval, Sync Interval or Link Delay Interval on a
remote system.

[ RC - fix trivial rebase conflict on top of targetPortIdentity check. ]

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-05-08 21:28:56 -07:00
Vedang Patel 705e5a32fa port: Make port_capable() accessible outside port.c
Make sure port_capable() can be accessed by the signaling construct in
port_signaling.c

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2019-05-08 21:21:30 -07:00
Richard Cochran b59a739d0f Ignore signaling messages on target port mismatch.
IEEE 1588 specifies dropping signaling messages if the
targetPortIdentity does not match the receiving port.  Up until now
the unicast code did check that field, but only for the unicast
transmission request and cancel operations.

This patch moves the target port identity check so that it applies to
each and every received signaling message.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-05-08 21:21:24 -07:00
Richard Cochran cc54cdef27 Update the unciast discovery options sections of the man page.
Ever since commit d88b4ff229 ("util: Added IPv6 support in help
funtions addreq and str2addr"), the unicast master table supports
entries with IPv6 addresses.  This patch updates the man page to
reflect this fact.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-05-08 21:19:08 -07:00
Miroslav Lichvar dd30b3a0d9 util: Fix addreq() to not read past addresses.
Fix the length of compared data to be the size of the IPv4/IPv6 address.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-03-25 06:25:07 -07:00
Miroslav Lichvar 86723cfc6a pmc: Don't leak memory when msg_tlv_append() fails.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-03-25 06:25:07 -07:00
Hangbin Liu 51d76bdfb7 port: should check the new phc_index before switching
In logic, when we want to switch phc, we should check if the new phc
index is valid instead of checking the previous one.

In reality, if we use linux team interface with activebackup mode. As
teamd is a userspace tool, it sets the new slave as active port after
receiving link change message. If we set current active port down and
another slave up. There is a race that we receive the new slave's link
up message while active port(ts_index) is still the old one. This means
we may use a link down interface as ts_index and get phc_index with -1.

If we update the p->phc_index to -1, there will be no possibility to
change it back to other value as we swith phc only when p->phc_index >= 0.

With this fix, we will not switch phc_index until receiving the real
active port(p->iface->ts_info.phc_index >= 0) update message.

Reported-by: Miroslav Lichvar <mlichvar@redhat.com>
Fixes: 536a71031d ("ptp4l: use ts label to get ts info")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2019-03-25 06:25:07 -07:00
David Mirabito via Linuxptp-devel 6b61ba29c7 Avoid fault when receiving zero length packets
The manpage for recvmsg says -1 will be returned on error, Zero indicates an
"orderly shutdown", presumably only in case of stream sockets.
Further, UNIX Network Programming, Vol 1 says ".. a return value of 0 from
recvfrom is acceptable for a datagram protocol"

Such packets have been observed in the wild, aimed at PTP's multicast
address and port, possibly related to malformed management queries.

Patch to properly check return from recvmesg and not trigger the fault
codepath. Instead, such packets are treated as "Bad Message" the same as
non-zero but still too-short UDP payloads.

Signed-off-by: David Mirabito <davidjm@arista.com>
2019-03-25 06:25:07 -07:00
Richard Cochran 1b7a1e2cda ptp4l: Remove bogus command line option.
Commit c8107c8d ("config: Add a configuration option for TC mode.")
added a new TC mode.  An early version of the patch series included a
new '-t' command line option, but this was dropped considering the
fact that long options are always available.  IOW the TC user can
simply add '--clock_type=P2P_TC' to the command line, making the
single dash option redundant.

This patch fixes the misleading usage message by removing the
non-existing option.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-03-25 06:04:40 -07:00
Richard Cochran 32e34d5da3 Simplify the systems requirements section of the readme file.
Now that PTP support support is well established, remove the text that
attempts to explain the (at the time) incomplete kernel support.  Instead
just give a couple of ethtool examples.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-02-24 19:26:36 -08:00
Richard Cochran 47a4fd040b Update the features listed in the readme file.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-02-24 19:22:33 -08:00
Richard Cochran 36624a4345 Add an acknowledgment in the readme for Moser Baer.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-02-24 19:03:50 -08:00
Miroslav Lichvar 6d50817dc0 port: Prevent undefined shift operations in msg_current().
Adjust checks of logMessageInterval in received packet to prevent 1 of
type int being shifted by values >= 31.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-01-28 20:55:30 -08:00
Miroslav Lichvar 3c7e4947e4 phc2sys: Fix crash when trying to synchronize unadjustable clock.
A clock that cannot be adjusted has no servo. Check if a servo is
present before updating the clock.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-01-06 20:50:40 -08:00
Miroslav Lichvar 8142da41b6 phc2sys: Use reversed sysoff when synchronizing to system clock.
If synchronizing a PHC to the system clock, use one of the
PTP_SYS_OFFSET ioctls (if supported) to measure the offset between the
two clocks. Negate the offset and switch the timestamp before passing
them to the servo.

This makes the synchronization between PHC and system clock symmetric.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-01-06 20:50:40 -08:00
Miroslav Lichvar 68a9011c9d sysoff: Add support for PTP_SYS_OFFSET_EXTENDED ioctl.
This is a more accurate variant of the the PTP_SYS_OFFSET ioctl, which
will probably be supported in future kernel versions.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-01-06 20:50:40 -08:00
Miroslav Lichvar 192b8e315c sysoff: Add support for PTP_SYS_OFFSET_PRECISE ioctl.
This ioctl uses cross timestamping for a more accurate measurement of
the offset. It is supported on some onboard Intel NICs using the e1000e
driver and a virtual PHC with the ptp_kvm driver.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-01-06 20:50:40 -08:00
Miroslav Lichvar 93baf34adb sysoff: Extend API for different sysoff methods.
The kernel supports different PTP_SYS_OFFSET* ioctls. Use the sysoff
enum to allow selecting between them in sysoff_measure().

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-01-06 20:50:40 -08:00
Miroslav Lichvar c0e49c7088 sysoff: Initialize data for ioctl(PTP_SYS_OFFSET).
This fixes valgrind errors.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-01-06 20:50:40 -08:00
Anders Selhammer 14ac29b059 tmv: Avoid overflow when byte shift in tmv_to_TimeInterval
Added check so that convertion from a positive tmv not result in a negative TimeInterval and vice versa.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2019-01-06 20:09:39 -08:00
Miroslav Lichvar d663a483c4 Fix building with new kernel headers.
net_tstamp.h in recent kernel versions requires time.h for clockid_t.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-01-06 19:56:25 -08:00
Anders Selhammer 1a4f6a26ce msg: Added const flag in msg_type
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2019-01-06 19:47:51 -08:00
Dimitrios Katsaros a5da8c4b71 Added support for opening POSIX clock devices
I have reduced the requirements for the -p option to accept
any type of device. With this it should be possible to use
ptp4l to syncronize any clock device that implements the kernel
POSIX clock interface.

[ RC - Initialize struct timex. ]

Signed-off-by: Dimitrios Katsaros <patcherwork@gmail.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-01-06 19:41:45 -08:00
Vedang Patel d1ce07d5cb port: Fix for inhibit_announce.
When inhibit_announce is set, ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES event is
still sent once every state change. Avoid this by explicitly sending
EV_NONE instead.

[ RC - Simplify and keep all of the timer's state maintenance. ]

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-01-06 17:35:37 -08:00
Richard Cochran 563c52b833 Allow ignoring source port identity in end to end mode.
The "inhibit_announce" and "ignore_source_id" options were introduced
in order to support the automotive profile.  That profile happens to
specify using the peer to peer delay mechanism, but there is no reason
to restrict them to that mechanism.  As it now stands, enabling these
two options prevents E2E slaves from synchronizing.  This patch fixes
the issue by checking the "ignore_source_id" option when accepting E2E
delay response messages.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-01-06 17:34:31 -08:00
Cliff Spradlin via Linuxptp-devel e27cc2d8a8 Include missing headers.
Signed-off-by: Cliff Spradlin <cspradlin@google.com>
Change-Id: If0fd08df74e1cf108978266cd77768df4b49fb1f
2018-11-01 20:17:50 -07:00
Cliff Spradlin via Linuxptp-devel 2c3a501fc3 Use llabs() instead of fabs() for integers.
Change-Id: I64cf1d4e1728c31ced40aff865d66b5b4356560f
Signed-off-by: Cliff Spradlin <cspradlin@google.com>
2018-11-01 20:17:50 -07:00
Anders Selhammer 80b1d25dfd sk: Added address family as inargument in sk_set_priority
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-11-01 20:17:50 -07:00
Anders Selhammer d88b4ff229 util: Added IPv6 support in help funtions addreq and str2addr
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-11-01 20:17:50 -07:00
Anders Selhammer 8f2f9bbcab port: correction of port name used port_open
Correction of fault introduced in "Add BMCA config option."

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
Reviewed-by: Vedang Patel <vedang.patel@intel.com>
2018-11-01 20:07:55 -07:00
Vedang Patel 4d251d8358 Add example configuration for Automotive Profile.
This commit adds example for configuring master and slave devices that
support features from the Automotive Profile.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2018-10-04 19:38:19 -07:00
Vedang Patel d58b1080bc Add ignore_source_id config option.
This config option will skip the source port identity verification in
the Sync and Follow_up messages. This option is needed when the announce
messages are disabled because the slave cannot know the identity of
master without announce messages.

This is required by Automotive Profile as part of skipping the Best
Master Clock Algorithm (BMCA).

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2018-10-04 19:38:19 -07:00
Vedang Patel 1cbeec80cd Add inhibit_announce config option.
This option will accomplish 2 things. On the master, it will stop the
announce messages being sent (by disabling FD_MANNO_TIMER timer). On
slave, it will not configure announce message timeouts (by disabling
FD_ANNOUNCE_TIMEOUT timer).

This config option is needed for the Automotive profile as part of
skipping the Best Master Clock Algorithm (BMCA).

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2018-10-04 19:38:19 -07:00
Vedang Patel 83be05256b Add BMCA config option.
This adds config option to specify static roles for master and slave
in the Best Master Clock Algorithm. This is the case for Automotive
Profile where networks are mostly static and role for each device is
known in advance.

masterOnly and slaveOnly will be used to determine the roles for the
devices. Since masterOnly is a per-port config and slaveOnly is a global
config option, role assignment will be slightly odd in case of bridges.
If slaveOnly is set to 1, all the ports will be in slave roles except
for the ones where masterOnly is set to 1. These ports will assume the
master role.

Two new FSMs which will be used for master and slave roles for this
config option have also been added.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2018-10-04 19:38:19 -07:00
Vedang Patel 3f764aec6a port: Add configurable option to set asCapable.
If set to 'true', this unconditionally sets the asCapable variable. The
usual checks will be applied to asCapable if it is set to 'auto'. The
default value is 'auto'.

This config option is needed by the Automotive Profile. The master will
be able to send out Sync Message as soon as the daemon is started.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2018-10-04 19:38:19 -07:00
Vedang Patel 386fc3ed89 clock: Add NULL check for best clock in clock_update_slave()
This scenario will only be encountered when the clock transitions to the
slave state without knowing who the master is.

This will result in a segfault for BMCA with designated master and slave
states (to be added in upcoming patches).

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2018-10-04 19:38:19 -07:00
Vedang Patel 4910055bd7 port: Add condition to check fc.
If foreign clock is NULL, both the clocks are obviously not equal. So,
return 0 in that case.

The above condition (fc == NULL) is not currently encountered. It will
be encoutered in the next few patches which implement static roles for
master and slave.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
2018-10-04 19:38:19 -07:00
Miroslav Lichvar 78a720f2b3 timemaster: Allow ptp4l-specific sections in [ptp4l.conf].
Remove > from beginning of lines specified in the *.conf sections in
order to allow a ptp4l-specific section (e.g. [unicast_master_table]) to
be included there.

After inserting the lines to the generated ptp4l.conf, switch back to
the [global] section.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-09-30 18:54:31 -07:00
Miroslav Lichvar 241d8a064e unicast: Process timeouts equal to current time.
Don't postpone processing of a timeout if it is equal to the current
time. This prevents an infinite loop with a simulated clock.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2018-09-30 18:54:31 -07:00
Ethel Nilsson 2b00608278 snmp4lptp: added snmp4lptp.8
Signed-off-by: Ethel Nilsson <ethel.nilsson@est.tech>
2018-09-30 18:52:56 -07:00
Anders Selhammer 57b98c216a Add possibility to set clockIdentity
Currently the clockIdentity is generated from the mac address of the first
interface/port in config file. This patch add the possibility to set it in
config file.
The reason is if the stack is restarted with a different set of ports, it
may be circumstances when clockIdentity needs to be equal as before
restart even if the port setup is different.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-09-30 18:45:52 -07:00
Anders Selhammer 1173e774dd Introduce the maxStepsRemoved attribute
Add attribute maxStepsRemoved which is included in IEEE1588-2017 (v2.1)
It is an optional attribute which can decide if an Announce message is
considered in the operation of the BMCA or not.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-09-30 18:39:39 -07:00
Erez Geva 399907db7f config: Add hardware time stamp filter setting mode
Add global option for the hardware time stamp setting.
The function could:
Normally set the filters as the PTP daemon require.
Check that the filters are proper but do not change them.
Full, set the RX filter to all and the TX filter as the PTP daemon require.

[ RC: added missing extern keyword and fixed indentation. ]

Signed-off-by: Erez Geva <erez.geva.ext@siemens.com>
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2018-09-30 18:38:00 -07:00
Anders Selhammer 1d0832b2f5 snmp4lptp: Added function for data collection from ptp4l program.
General function to use for sending signals for data collection
from ptp4l program.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-09-07 09:45:40 -07:00
Anders Selhammer 68dcd10673 snmp4lptp: Added communication to ptp4l via the UDS port.
UDS transport is configured using pmc_common functions.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-09-07 09:44:52 -07:00
Anders Selhammer b2f2c9e02d snmp4lptp: Add snmp sub agent for linuxptp
The sub agent use net-snmp library and AgentX protocol for the
communication towards the snmp master agent.
snmpd.c should only include general setup needed for handling snmp.
Supported MIBs should be implemented in separate files.
Makefile will include snmpd if libsnmp is available during compilation.
configs/snmpd.conf should be placed in /etc/snmp/

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-09-07 09:44:52 -07:00