Changes between Version 5 and Version 6 of timesync


Ignore:
Timestamp:
12/06/2018 07:35:05 PM (4 years ago)
Author:
Cale Collins
Comment:

converted page from HTML to WIKI, added new section for OcteonTX

Legend:

Unmodified
Added
Removed
Modified
  • timesync

    v5 v6  
    1 {{{#!html
     1= Linux Time Syncrhronization
    22
    3 <h1 id="LinuxTimeSyncrhronization"><b style="color:#000;background:#66ffff">Linux Time Syncrhronization</b></h1>
    4 <p>
    53Many applications in factory automation, test and measurement, and telecommunications require very close time synchronization. The usage case for this is often scenarios where they have multiple boards transmitting on the same RF channel and they want to synchronize the system clocks to a precision that allows the boards to Time Division Multiplex (TDM) the use of the transmitters so they are not producing collisions and thus maximizing RF throughput as this is the most efficient way of utilizing available bandwidth.
    6 </p>
    7 <p>
     4
    85There are two common solutions to this problem:
    9 </p>
    10 <ul><li><a class="wiki" href="/wiki/linux/timesync#ieee1588-ptp">IEEE 1588 Precision Time Protocol (PTP)</a> - uses Ethernet frames
    11 </li><li><a class="wiki" href="/wiki/linux/timesync#gps-pps">GPS Pulse-Per-Seconds</a> - uses GPS information
    12 </li></ul><p>
    13 <span class="wikianchor" id="ieee1588-ptp"></span>
    14 </p>
    15 <h2 id="TimesynchronizationviaIEEE1588PrecisionTimeProtocolPTPEthernet">Time synchronization via IEEE 1588 Precision Time Protocol (PTP) (Ethernet)</h2>
    16 <p>
     6
     7IEEE 1588 Precision Time Protocol - uses Ethernet frames
     8GPS Pulse-Per-Seconds - uses GPS information
     9
     10= Time synchronization via IEEE 1588 Precision Time Protocol (PTP) (Ethernet)
     11
    1712The purpose of the IEEE 1588 Precision Time Protocol (PTP) is to synchronize the time between different nodes on an Ethernet network.
    18 </p>
    19 <p>
     13
    2014The Linux kernel has IEEE 1588 PTP support for a handful of ethernet devices that offer this feature including the Freescale IMX6 FEC which is used as eth0 on the majority of the Gateworks Ventana boards including the GW51xx, GW52xx, GW53xx, and GW54xx (Note GW5520 does not use the IMX6 FEC and instead provides 2x full GigE capable PCIe based MAC/PHY devices so it lacks IEEE 1588 hardware support).
    21 </p>
    22 <p>
     15
    2316In hardware PTP the ethernet MAC is responsible for getting and setting the timestamps to remove latency of the queuing and network stack which provides the best accuracy.
    24 </p>
    25 <p>
    26 The <a class="ext-link" href="http://linuxptp.sourceforge.net/"><span class="icon">​</span>Linux PTP</a> project is an implementation of the IEEE 1588 for Linux featuring:
    27 </p>
    28 <ul><li>Supports hardware and software time stamping via the Linux SO_TIMESTAMPING socket option.
    29 </li><li>Supports the Linux PTP Hardware Clock (PHC) subsystem by using the clock_gettime family of calls, including the new clock_adjtimex system call.
    30 </li><li>Implements Boundary Clock (BC) and Ordinary Clock (OC).
    31 </li><li>Transport over UDP/IPv4, UDP/IPv6, and raw Ethernet (Layer 2).
    32 </li><li>Supports IEEE 802.1AS-2011 in the role of end station.
    33 </li><li>Modular design allowing painless addition of new transports and clock servos.
    34 </li></ul><p>
     17
     18The http://linuxptp.sourceforge.net/ project is an implementation of the IEEE 1588 for Linux featuring:
     19
     20* Supports hardware and software time stamping via the Linux SO_TIMESTAMPING socket option.
     21* Supports the Linux PTP Hardware Clock (PHC) subsystem by using the clock_gettime family of calls, including the new clock_adjtimex system call.
     22* Implements Boundary Clock (BC) and Ordinary Clock (OC).
     23* Transport over UDP/IPv4, UDP/IPv6, and raw Ethernet (Layer 2).
     24* Supports IEEE 802.1AS-2011 in the role of end station.
     25* Modular design allowing painless addition of new transports and clock servos.
     26
    3527The linuxptp package is installed on the Gateworks Ventana Yocto v1.8 BSP.
    36 </p>
    37 <p>
     28
    3829Example usage on a GW54xx:
    39 </p>
    40 <ul><li>master:
    41 <pre class="wiki">root@ventana:~# ptp4l -i eth0 -m
     30
     31master:
     32{{{#!bash
     33root@ventana:~# ptp4l -i eth0 -m
    4234ptp4l[112.404]: selected /dev/ptp0 as PTP clock
    4335ptp4l[112.409]: driver changed our HWTSTAMP options
     
    4941ptp4l[120.065]: selected best master clock 00d012.fffe.13f09d
    5042ptp4l[120.065]: assuming the grand master role
    51 </pre><ul><li>the ptp4l tries to use hardware time stamping by default, otherwise you can use the '-H' to force hardware timestamping, or '-S' to force software timestamping
    52 </li><li>the -m parameter tells ptp4l to output messages to the console
    53 </li><li>no master was found so this target became the master
    54 </li></ul></li><li>slave:
    55 <pre class="wiki">ptp4l[228.234]: selected /dev/ptp0 as PTP clock
     43}}}
     44 * the ptp4l tries to use hardware time stamping by default, otherwise you can use the '-H' to force hardware timestamping, or '-S' to force software timestamping
     45 * the -m parameter tells ptp4l to output messages to the console
     46 * no master was found so this target became the master
     47slave:
     48{{{#!bash
     49selected /dev/ptp0 as PTP clock
    5650ptp4l[228.239]: driver changed our HWTSTAMP options
    5751ptp4l[228.239]: tx_type   1 not 1
     
    7165ptp4l[241.995]: master offset        -53 s2 freq   -5046 path delay      2372
    7266ptp4l[242.995]: master offset       -129 s2 freq   -5138 path delay      2341
    73 </pre></li><li>this was started after the master, so it found the master and became a slave
    74 </li></ul><p>
     67}}}
     68* this was started after the master, so it found the master and became a slave
     69
    7570References:
    76 </p>
    77 <ul><li><a class="ext-link" href="http://events.linuxfoundation.org/sites/events/files/slides/lcjp14_ichikawa_0.pdf"><span class="icon">​</span>Introduction to linuxptp</a>
    78 </li><li><a class="ext-link" href="http://linuxptp.sourceforge.net/"><span class="icon">​</span>Linux PTP Project</a>
    79 <ul><li><a class="ext-link" href="http://sourceforge.net/p/linuxptp/code/ci/master/tree/"><span class="icon">​</span>Linux PTP code</a>
    80 </li></ul></li><li><a class="ext-link" href="https://github.com/torvalds/linux/blob/master/Documentation/ptp/ptp.txt"><span class="icon">​</span>Linux PTP Documentation</a>
    81 <ul><li><a class="ext-link" href="https://github.com/torvalds/linux/blob/master/Documentation/ABI/testing/sysfs-ptp"><span class="icon">​</span>sysfs API</a>
    82 </li><li><a class="ext-link" href="https://github.com/torvalds/linux/blob/master/Documentation/ptp/testptp.c"><span class="icon">​</span>userspace test program</a>
    83 </li></ul></li><li><a class="ext-link" href="http://www.ixxat.com/introduction_ieee_1588_en.html"><span class="icon">​</span>IEEE 1588 PTP Introduction</a>
    84 </li><li><a class="ext-link" href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Configuring_PTP_Using_ptp4l.html"><span class="icon">​</span>Configuring PTP Using ptp4l</a>
    85 </li></ul><p>
    86 <span class="wikianchor" id="gps-pps"></span>
    87 </p>
    88 <h1 id="TimesynchronizationviaPPSPulse-Per-SecondGPS">Time synchronization via PPS (Pulse-Per-Second) (GPS)</h1>
    89 <p>
     71
     72* [http://events.linuxfoundation.org/sites/events/files/slides/lcjp14_ichikawa_0.pdf Introduction to linuxPTP]
     73* [http://linuxptp.sourceforge.net/ Linux PTP Project]
     74 * [http://sourceforge.net/p/linuxptp/code/ci/master/tree/ Linux PTP code]
     75* [https://github.com/torvalds/linux/blob/master/Documentation/ptp/ptp.txt Linux PTP Documentation]
     76 * [https://github.com/torvalds/linux/blob/master/Documentation/ABI/testing/sysfs-ptp sysfs API]
     77 * [https://github.com/torvalds/linux/blob/master/Documentation/ptp/testptp.c userspace test program]
     78* [http://www.ixxat.com/introduction_ieee_1588_en.html IEEE 1588 PTP Introduction]
     79* [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Configuring_PTP_Using_ptp4l.html Configuring PTP Using ptp4l]
     80
     81= Time synchronization via PPS (Pulse-Per-Second) (GPS)</h1>
     82
    9083One handy feature of an on-board GPS is that it can deliver Pulse-Per-Second (PPS) signal. This signal can be used to get a high-precision time reference that an application can use to adjust system clock time. Common use is to configure the Network Time Protocol Daemon (NTPD) with a PPS source to obtain a wallclock-time with sub-millisecond synchronization to UTC.
    91 </p>
    92 <p>
    93 See <a class="wiki" href="/wiki/gps#pps">the GPS page</a> for more info
    94 </p>
    95 </div>
     84
     85See [wiki:/gps#pps the GPS page] for more info.
     86
     87= Octeon TX IEEE 1588
     88
     89From CN80xx refrence manual:
     90
     91The CN80XX hardware supports very accurate timestamping in the PTP, BGX, GTI,
     92and NIC blocks. This timestamping is suitable for use in IEEE 1588 Precision Time
     93Protocol (PTP) or other purposes.
     94
     95The CN80XX outbound timestamping hardware captures timestamps, but cannot
     96insert the timestamp into any outgoing packets. Using IEEE 1588 vernacular, this
     97means that the CN80XX outbound timestamping hardware is most useful when
     98implementing a two-step clock, not a one-step clock, for PTP event messages sent
     99from CN80XX. After the hardware captures the timestamp for the outgoing 1588
     100event message and delivers it to software, the 1588 software running on the CN80XX
     101may need to send the timestamp to required recipients in a subsequent 1588 general
     102message as a second step.
     103
     104NIC has no specific mode supporting PTP timestamping, but contains a number of
     105features to compensate for the PTP timestamp introduced by BGX when it is
     106timestamping.
     107When BGX is in the receive-timestamp mode, NIC receives the timestamp plus
     108packet from the BGX. NIC packet parsing is able to skip over the received
     109timestamps (NIC_PF_PKIND(0..15)_CFG[HDR_SL]). NIC MAXERR, MINERR, and
     110LENERR checks can compensate for the additional header, since the MAXERR and
     111MINERR byte counts are programmable, and the programmed value can easily be
     112increased by 8. The LENERR check already compensates based on the skip value.
     113NIC makes the timestamp available for software with every packet. The timestamp
     114can be present in the completion-queue entry and/or the receive buffer in L2/DRAM
     115for software, depending on NIC configuration. The software will likely use the
     116timestamp when IEEE 1588 event messages arrive. For other packets, the software
     117may choose to discard or ignore the timestamp that is present with every packet in
     118this mode.
     119
     120[[Image(cavium-octeon-tx-block-diagram.jpg, width=600)]]
    96121
    97122