Richard Cochran e0580929f4 phc2sys: Fix frequency estimation when synchronizing a PHC to the system clock.
When synchronizing a PHC to the Linux system clock (CLOCK_REALTIME),
the phc2sys uses the sysoff method, reversing the master and slave
roles.

The offset between a master clock and a slave clock is given by

    offset = slave_ts - master_ts,

and the call to sysoff_measure() provides the 'offset' and 'slave_ts'
values.  The needed local time stamp on the 'master' is given by

    master_ts = slave_ts - offset,

but the code calcuates

    master_ts = slave_ts + offset.

When passed to the servo, the local time stamp is used to estimate the
frequency offset between the two clocks before starting the main
synchronization loop.  The effect of the bug may be seen with a simple
test.  Here is a sample output with the existing code.

    $ sudo testptp -d /dev/ptp1 -f 62400000
    frequency adjustment okay
    $ sudo ./phc2sys -m -q -c eth6 -s CLOCK_REALTIME -O0
    phc2sys[90221.239]: eth6 sys offset 191001318 s0 freq -62400000 delay   5547
    phc2sys[90222.239]: eth6 sys offset 253380897 s1 freq  +8265884 delay   5507
    phc2sys[90223.239]: eth6 sys offset  -8301685 s2 freq    -35801 delay   5487
    phc2sys[90224.239]: eth6 sys offset  -8297136 s2 freq  -2521757 delay   5531
    phc2sys[90225.239]: eth6 sys offset  -5806117 s2 freq  -2519879 delay   5542
    phc2sys[90226.239]: eth6 sys offset  -3317009 s2 freq  -1772606 delay   5495
    phc2sys[90227.240]: eth6 sys offset  -1575231 s2 freq  -1025931 delay   5505
    phc2sys[90228.240]: eth6 sys offset   -580249 s2 freq   -503518 delay   5524
    phc2sys[90229.240]: eth6 sys offset   -107770 s2 freq   -205114 delay   5519
    phc2sys[90230.240]: eth6 sys offset     66298 s2 freq    -63377 delay   5490
    phc2sys[90230.881]: eth6 sys offset     86942 s2 freq    -22844 delay   5495

And this is the output with the bug fix in place.

    $ sudo testptp -d /dev/ptp1 -f 62400000
    frequency adjustment okay
    $ sudo ./phc2sys -m -q -c eth6 -s CLOCK_REALTIME -O0
    phc2sys[90365.624]: eth6 sys offset 311912675 s0 freq -62400000 delay   5490
    phc2sys[90366.624]: eth6 sys offset 374292766 s1 freq  -31098 delay   5642
    phc2sys[90367.624]: eth6 sys offset     -3825 s2 freq  -34923 delay   5617
    phc2sys[90368.625]: eth6 sys offset         6 s2 freq  -32240 delay   5564
    phc2sys[90369.625]: eth6 sys offset      1241 s2 freq  -31003 delay   5605
    phc2sys[90370.625]: eth6 sys offset      1131 s2 freq  -30741 delay   5600
    phc2sys[90371.625]: eth6 sys offset       801 s2 freq  -30732 delay   5621
    phc2sys[90372.625]: eth6 sys offset       458 s2 freq  -30834 delay   5640
    phc2sys[90373.626]: eth6 sys offset       186 s2 freq  -30969 delay   5598
    phc2sys[90374.626]: eth6 sys offset       134 s2 freq  -30965 delay   5599
    phc2sys[90375.626]: eth6 sys offset        43 s2 freq  -31016 delay   5595
    phc2sys[90375.681]: eth6 sys offset       -32 s2 freq  -31078 delay   5541

This patch fixes the issue by correcting the calculation of the local
time stamp value.

Fixes: 8142da41b61f ("phc2sys: Use reversed sysoff when synchronizing to system clock.")
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Cliff Spradlin <cspradlin@google.com>
Tested-by: Vladimir Oltean <olteanv@gmail.com>
2019-12-25 10:26:04 -08:00
2018-10-04 19:38:19 -07:00
2013-10-27 08:24:01 +01:00
2013-10-27 08:24:01 +01:00
2013-02-06 14:42:12 +01:00
2018-10-04 19:38:19 -07:00
2018-11-01 20:17:50 -07:00
2018-07-01 22:10:06 -07:00
2013-10-30 21:43:37 +01:00
2013-10-30 21:54:07 +01:00
2013-10-30 21:54:07 +01:00
2011-11-12 18:59:13 +01:00
2018-10-04 19:38:19 -07:00
2018-03-27 22:26:32 -07:00
2015-03-27 10:58:04 +01:00
2018-03-07 07:55:51 -08:00
2013-10-30 21:43:37 +01:00
2019-07-05 20:08:41 -07:00
2013-10-30 21:54:07 +01:00
2014-05-06 20:08:59 +02:00
2019-07-05 20:41:11 -07:00
2018-07-05 23:54:26 -07:00
2019-07-05 20:08:41 -07:00
2018-10-04 19:38:19 -07:00
2019-07-05 20:08:41 -07:00
2018-04-19 07:41:11 -07:00
2019-05-08 21:29:48 -07:00
2019-05-08 21:29:48 -07:00
2019-07-05 20:44:18 -07:00
2018-09-30 18:52:56 -07:00
2013-02-09 10:09:25 +01:00
2013-02-09 10:09:25 +01:00
2018-03-07 07:55:51 -08:00
2015-03-27 10:58:04 +01:00
2019-09-10 20:56:30 -07:00
2018-07-01 22:10:07 -07:00
2018-08-12 14:08:43 -07:00

Introduction

This software is an implementation of the Precision Time Protocol (PTP) according to IEEE standard 1588 for Linux. The dual design goals are to provide a robust implementation of the standard and to use the most relevant and modern Application Programming Interfaces (API) offered by the Linux kernel. Supporting legacy APIs and other platforms is not a goal.

License

The software is copyrighted by the authors and is licensed under the GNU General Public License. See the file, COPYING, for details of the license terms.

Features

  • Supports hardware and software time stamping via the Linux SO_TIMESTAMPING socket option.
  • Supports the Linux PTP Hardware Clock (PHC) subsystem by using the clock_gettime family of calls, including the clock_adjtimex system call.
  • Implements Boundary Clock (BC), Ordinary Clock (OC) and Transparent Clock (TC).
  • Transport over UDP/IPv4, UDP/IPv6, and raw Ethernet (Layer 2).
  • Supports IEEE 802.1AS-2011 in the role of end station.
  • Modular design allowing painless addition of new transports and clock servos.
  • Implements unicast operation.
  • Supports a number of profiles, including:

    • The automotive profile
    • The default 1588 profile.
    • The enterprise profile.
    • The telecom profiles G.8265.1, G.8275.1, and G.8275.2.
  • Supports the NetSync Monitor protocol.
  • Implements Peer to peer one-step.
  • Supports bonded, IPoIB, and vlan interfaces.

Getting the Code

You can download the latest released version at Source Forge.

http://sourceforge.net/projects/linuxptp/files/latest/download

The source code is managed using the git version control system. To get your own copy of the project sources, use the following command.

  git clone git://git.code.sf.net/p/linuxptp/code linuxptp

If the git protocol is blocked by your local area network, then you can use the alternative HTTP protocol instead.

  git clone http://git.code.sf.net/p/linuxptp/code linuxptp

System Requirements

In order to run this software, you need Linux kernel version 3.0 or newer. Check whether your network interface supports PTP with the following command.

  ethtool -T eth0

This command shows whether a MAC supports hardware or software time stamping. The following example output indicates support for hardware time stamping.

Time stamping parameters for eth6:
Capabilities:
        hardware-transmit     (SOF_TIMESTAMPING_TX_HARDWARE)
        software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
        hardware-receive      (SOF_TIMESTAMPING_RX_HARDWARE)
        software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
        software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
        hardware-raw-clock    (SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: 1
Hardware Transmit Timestamp Modes:
        off                   (HWTSTAMP_TX_OFF)
        on                    (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
        none                  (HWTSTAMP_FILTER_NONE)
        all                   (HWTSTAMP_FILTER_ALL)

The next example shows the case where the MAC only supports software time stamping. The ptp4l program requires either the -S command line argument or the time_stamping software configuration option when using such interfaces.

Time stamping parameters for enp6s0:
Capabilities:
        software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
        software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
        software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none

Note the software-transmit (SOF_TIMESTAMPING_TX_SOFTWARE) capability. If this is lacking, then the MAC cannot be used at all. However, adding this capability entails adding a single line of code to the device driver.

Installation

  1. Just type 'make'
  2. If you compiled your own kernel (and the headers are not installed into the system path), then you should set the KBUILD_OUTPUT environment variable as in the example, above.
  3. In order to install the programs and man pages into /usr/local, run the 'make install' target. You can change the installation directories by setttings the variables prefix, sbindir, mandir, and man8dir on the make command line.

Getting Involved

The software development is hosted at Source Forge.

https://sourceforge.net/projects/linuxptp/

Reporting Bugs

Please report any bugs or other issues with the software to the linuxptp-users mailing list.

https://lists.sourceforge.net/lists/listinfo/linuxptp-users

Development

If you would like to get involved in improving the software, please join the linuxptp-devel mailing list.

https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Submitting Patches

  1. Before submitting patches, please make sure that you are starting your work on the current HEAD of the git repository.
  2. Please checkout the CODING_STYLE.org file for guidelines on how to properly format your code.
  3. Describe your changes. Each patch will be reviewed, and the reviewers need to understand why you did what you did.
  4. Sign-Off each commit, so the changes can be properly attributed to you and you explicitely give your agreement for distribution under linuxptp's license. Signing-off is as simple as:

    git commit -s
    

    or by adding the following line (replace your real name and email) to your patch:

    Signed-off-by: Random J Developer <random@developer.example.org>
    
  5. Finally, send your patches via email to the linuxptp-devel mailing list, where they will be reviewed, and eventually be included in the official code base.

    git send-email --to linuxptp-devel@lists.sourceforge.net origin/master
    

Thanks

Thanks to AudioScience Inc for sponsoring the 8021.AS support.

Thanks to Exablaze for donating an ExaNIC X10

Thanks to Intel Corporation for donating four NICs, the 82574, 82580, 82599, and the i210.

Thanks to Meinberg Funkuhren for donating a LANTIME M1000.

Thanks to Moser Baer for sponsoring the Telecom Profiles and unicast support.

For testing I use an OTMC 100 grandmaster clock donated by OMICRON Lab.

Description
No description provided
Readme 1.4 MiB
Languages
C 90.5%
Roff 8.7%
Shell 0.4%
Makefile 0.4%