From 4bbd9b73634710bc0783e632f085f63b9209f392b56df396c5a7d32b639cf131 Mon Sep 17 00:00:00 2001 From: Jiri Bohac Date: Thu, 29 Jun 2017 15:28:40 +0000 Subject: [PATCH] osc copypac from project:home:LPechacek package:linuxptp revision:1 OBS-URL: https://build.opensuse.org/package/show/network:time/linuxptp?expand=0&rev=1 --- .gitattributes | 23 ++++++ linuxptp-1.8.tgz | 3 + linuxptp-howto.txt | 192 +++++++++++++++++++++++++++++++++++++++++++++ linuxptp.changes | 74 +++++++++++++++++ linuxptp.firewall | 8 ++ linuxptp.spec | 112 ++++++++++++++++++++++++++ phc2sys.service | 11 +++ ptp4l.service | 10 +++ sysconfig.phc2sys | 9 +++ sysconfig.ptp4l | 9 +++ 10 files changed, 451 insertions(+) create mode 100644 .gitattributes create mode 100644 linuxptp-1.8.tgz create mode 100644 linuxptp-howto.txt create mode 100644 linuxptp.changes create mode 100644 linuxptp.firewall create mode 100644 linuxptp.spec create mode 100644 phc2sys.service create mode 100644 ptp4l.service create mode 100644 sysconfig.phc2sys create mode 100644 sysconfig.ptp4l diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/linuxptp-1.8.tgz b/linuxptp-1.8.tgz new file mode 100644 index 0000000..23fc43f --- /dev/null +++ b/linuxptp-1.8.tgz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa8e00f6ec73cefa7bb313dce7f60dfe5eb9e2bde3353594e9ac18edc93e5165 +size 147764 diff --git a/linuxptp-howto.txt b/linuxptp-howto.txt new file mode 100644 index 0000000..0e652f8 --- /dev/null +++ b/linuxptp-howto.txt @@ -0,0 +1,192 @@ +How to Set Up a PTP Network Using Linux PTP and SUSE® Linux Enterprise +====================================================================== + March 2014 + +Scope +----- +This how-to guide provides a conceptual overview of Linux PTP (Precision Time +Protocol) and explains the basic setup of a PTP network consisting of a single +Ethernet segment using Linux PTP and SUSE Linux Enterprise. + +Why Precision Time Protocol? +---------------------------- +Precision Time Protocol (PTP) provides accurate clock synchronization across a +local group of hosts. As opposed to Network Time Protocol (NTP), it does not +aim at minimizing a host's difference from official world time but tries to +minimize the difference from other hosts in the group. Traditionally, the task +of precise synchronization in a group has been achieved with GPS time +synchronization at each host or a central clock synchronizing the hosts via +specialized hardware. PTP offers comparable accuracy using Ethernet based +hardware, assuming stable network latencies and symmetric transport delays. + +About the Linux Implementation of PTP +------------------------------------- +Linux PTP takes advantage of the hardware support implemented in some network +interface cards (NICs). In addition, this implementation can work with some +NICs that do not provide hardware PTP facilities. However, the necessary +functionality is implemented in their hardware drivers. + +There are three components of the PTP software: + * The in-kernel PTP support, consisting of the kernel PTP subsystem, + pulse-per-second subsystem and NIC driver code changes necessary for time + stamping passing packets + * Daemon for synchronizing the NIC's clock and system clock needed in + hardware time stamping setup + * Daemon for implementing the protocol itself, which does the time + calculations and responds to the inquiries from other hosts + +The Beginning +------------- +First, we need to check what type of time stamping the NIC in question does. +That can be determined using ethtool utility with option -T. Example output is +as follows: +# ethtool -T enp4s0f1 +Time stamping parameters for enp4s0f1: +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: 3 +Hardware Transmit Timestamp Modes: + off (HWTSTAMP_TX_OFF) + on (HWTSTAMP_TX_ON) +Hardware Receive Filter Modes: + none (HWTSTAMP_FILTER_NONE) + ptpv1-l4-sync (HWTSTAMP_FILTER_PTP_V1_L4_SYNC) + ptpv1-l4-delay-req (HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) + ptpv2-l4-sync (HWTSTAMP_FILTER_PTP_V2_L4_SYNC) + ptpv2-l4-delay-req (HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) + ptpv2-l2-sync (HWTSTAMP_FILTER_PTP_V2_L2_SYNC) + ptpv2-l2-delay-req (HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) + ptpv2-event (HWTSTAMP_FILTER_PTP_V2_EVENT) + +For us the most important section is Capabilities. That shows the card in the +example can do both hardware time stamping (“hardware-transmit” and +“hardware-receive”) using hardware clock (“hardware-raw-clock“) and software +time stamping using kernel system clock (“software-transmit“, +“software-receive“ and “software-system-clock“). + +Cards that support only software time stamping display only the “software-“ +capabilities and none of the “hardware-“ ones. The time stamping mode will +later be needed for configuring the user space daemon. + +The User Space Daemons +---------------------- +The daemons are primarily configured via options in /etc/sysconfig/ptp4l and +/etc/sysconfig/phc2sys. These files control what options will be provided to +the two daemons: the protocol daemon, called ptp4l and the synchronization +daemon, called phc2sys. Apart from /etc/sysconfig/ there is the /etc/ptp4l.conf +configuration file controlling further behavior of the protocol daemon. + +Configuring Linux PTP with Hardware Time Stamping +------------------------------------------------- +The hardware time stamping setup includes an independent clock running on the +network card. This independent clock is used for timing calculations in PTP. + +The NIC PTP clock is synchronized to the system clock by the phc2sys daemon. +Therefore, in this setup you always need to enable the phc2sys service. The +NIC clock synchronization daemon phc2sys always synchronizes clocks in one +direction, for example, slave clock to master clock. This is important when +configuring a group master. + +For a group master, you usually need to synchronize the group to its system +clock, which itself is synchronized to a precise time using NTP, for example. +In this scenario the options for phc2sys will be “-s CLOCK_REALTIME -c ethX -w” +where CLOCK_REALTIME is a special string recognized by phc2sys corresponding to +the system clock, and ethX corresponds to the network interface that is +connected with the PTP clock. For a PTP slave host the configuration is simpler +and involves only telling phc2sys which network interface is associated with +the slave PTP clock. Having the system clock as master is the default here, so +the options are like “-s ethX -w” + +You might have noticed “-w” in the example options above. That is connected +with the fact that the PTP clock is running in International Atomic Time (TAI), +which is not the Coordinated Universal Time (UTC) used by system clock. There +is a certain offset between these time scales. The “-w” option ensures the +offset between TAI and UTC is read from the ptp4l daemon. See the phc2sys(8) +manual page for more details about time scale usage. + +No extra options need to be passed to ptp4l as hardware time stamping is the +default. The option string in /etc/sysconfig/ptp4l will typically look like +“-i ethX -f /etc/ptp4l.conf” where ethX is a placeholder for the actual +interface name. + +Configuring Linux PTP with Software Time Stamping +------------------------------------------------- +With software time stamping the situation is simpler. There is no independent +PTP clock to be synchronized, so phc2sys is not in use and the phc2sys service +can be disabled. + +The only change that must be made is telling ptp4l that the NIC in question +uses software time stamping mode. That can be accomplished by using “-S” in +OPTIONS in /etc/sysconfig/ptp4l. Therefore, the typical option string +will look like “-i ethX -f /etc/ptp4l.conf -S” where ethX is again a +placeholder for the actual interface name. + +When there is a PTP group master using software time stamping, the time +announced to the network is not using native PTP time scale. That may cause +interoperability issues with third-party PTP solutions and should be taken into +account when designing the system. + +Configuring the Group Master +---------------------------- +In every group there is one master clock, and the other hosts run slave clocks. +The election of group master is done automatically based on the host's clock +parameters. Most important is the host priority value in the PTP domain. + +As there is a difference in the system setup for slave clocks and master +clocks, the group master should be selected by the system administrator, and +its priority value should prioritize it over other hosts in the group. That +should be done by setting the lower priority1 value in /etc/ptp4l.conf. + +Domains and Transport Mechanisms +-------------------------------- +It is possible for multiple PTP host groups to share a single Ethernet segment. +These groups can be separated by setting different values for the domainNumber +in /etc/ptp4l.conf. Hosts belonging to one group share the same value of +domainNumber. + +There are also different transport options for PTP packets over Ethernet. PTP +messages can be encapsulated either in UDP4 (which is the default), UDP6 or +directly into Ethernet frames. The transport mechanism can be selected either +via command line option to ptp4l or in the /etc/ptp4l.conf configuration file. +See the ptp4l(8) manual page for more details. + +Examples of Configurations +-------------------------- +Configuration examples in this section are not full configuration files but +rather minimal list of changes that should be done to the indicated files. The +string ethX always stands for the actual network interface name in your setup. + +Slave clock using software time stamping: +/etc/sysconfig/ptp4l: + OPTIONS=”-f /etc/ptp4l.conf -i ethX” +No changes made to the distribution /etc/ptp4l.conf. + +Slave clock using hardware time stamping: +/etc/sysconfig/ptp4l: + OPTIONS=”-f /etc/ptp4l.conf -i ethX” +/etc/sysconfig/phc2sys: + OPTIONS=”-s ethX -w” +No changes made to the distribution /etc/ptp4l.conf. + +Master clock using hardware time stamping: +/etc/sysconfig/ptp4l: + OPTIONS=”-f /etc/ptp4l.conf -i ethX” +/etc/sysconfig/phc2sys: + OPTIONS=”-s CLOCK_REALTIME -c ethX -w” +/etc/ptp4l.conf: + priority1 127 + +Master clock using software time stamping, not generally recommended: +/etc/sysconfig/ptp4l: + OPTIONS=”-f /etc/ptp4l.conf -i ethX” +/etc/ptp4l.conf: + priority1 127 + +(C) 2014 SUSE LLC. All Rights Reserved. SUSE and the SUSE logo are registered +trademarks of SUSE LLC in the United States and other countries. All +third-party trademarks are the property of their respective owners. diff --git a/linuxptp.changes b/linuxptp.changes new file mode 100644 index 0000000..054c889 --- /dev/null +++ b/linuxptp.changes @@ -0,0 +1,74 @@ +------------------------------------------------------------------- +Thu May 25 12:20:17 UTC 2017 - lpechacek@suse.com + +- upgraded to 1.8 +- new tools: timemaster, phc_ctl + +------------------------------------------------------------------- +Wed Sep 3 01:41:37 CEST 2014 - ro@suse.de + +- sanitize release line in specfile + +------------------------------------------------------------------- +Thu Mar 27 12:16:20 UTC 2014 - lpechacek@suse.com + +- updated How To to mention ethtool (bnc#865358) + +------------------------------------------------------------------- +Wed Mar 26 16:51:51 CET 2014 - jbohac@suse.cz + +- convert to systemd (bnc#865355) + - two separate services (ptp4l and phc2sys) instead of linuxptp + - two separate config files: + /etc/syscconfig/ptp4l and /etc/sysconfig/phc2sys instead of + /etc/sysconfig/linuxptp + +------------------------------------------------------------------- +Tue Feb 18 18:59:56 CET 2014 - jbohac@suse.cz + +- upgraded to 1.4 +- fixed FSF address in init file + +------------------------------------------------------------------- +Fri Jul 26 10:12:08 UTC 2013 - lpechacek@suse.com + +- added Linux PTP Howto + +------------------------------------------------------------------- +Thu Jun 6 09:26:54 UTC 2013 - lpechacek@suse.com + +- adjusted sysconfig defaults to match changes made to phc2sys + behavior + +------------------------------------------------------------------- +Wed Jun 5 16:00:18 CEST 2013 - jbohac@suse.cz + +- upgraded to 1.2.git74e70372 + +------------------------------------------------------------------- +Tue Apr 23 16:50:16 CEST 2013 - jbohac@suse.cz + +- upgraded to 1.2 + +------------------------------------------------------------------- +Mon Mar 25 15:44:25 UTC 2013 - lpechacek@suse.com + +- reviewed by Security (bnc#809336) + +------------------------------------------------------------------- +Fri Mar 15 11:23:35 UTC 2013 - cfarrell@suse.com + +- license update: GPL-2.0+ + No indication of a GPL version 2 only license. Also, use SPDX format + where possible + +------------------------------------------------------------------- +Wed Mar 6 10:44:35 UTC 2013 - lpechacek@suse.com + +- upgraded to 1.1 + +------------------------------------------------------------------- +Fri Feb 15 05:37:47 UTC 2013 - lpechacek@suse.com + +- initial packaging + diff --git a/linuxptp.firewall b/linuxptp.firewall new file mode 100644 index 0000000..7114e18 --- /dev/null +++ b/linuxptp.firewall @@ -0,0 +1,8 @@ +## Name: Precision Time Protocol v2 +## Description: Ports needed for PTPv2 over UDP +# +# For a more detailed description of the individual variables see +# the comments for FW_SERVICES_EXT_* in /etc/sysconfig/SuSEfirewall2 +# + +UDP="ptp-general ptp-event" diff --git a/linuxptp.spec b/linuxptp.spec new file mode 100644 index 0000000..f77824b --- /dev/null +++ b/linuxptp.spec @@ -0,0 +1,112 @@ +# +# spec file for package linuxptp +# +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + + +Name: linuxptp +Version: 1.8 +Release: 0 +Summary: Precision Time Protocol v2 daemon +License: GPL-2.0+ +Group: Productivity/Networking/Other +Url: http://linuxptp.sourceforge.net/ +Source0: linuxptp-%{version}.tgz +Source1: ptp4l.service +Source2: sysconfig.ptp4l +Source3: linuxptp.firewall +Source4: linuxptp-howto.txt +Source5: phc2sys.service +Source6: sysconfig.phc2sys +BuildRequires: kernel-source +BuildRequires: systemd +PreReq: %fillup_prereq +Provides: ptp-timekeeping +BuildRoot: %{_tmppath}/%{name}-%{version}-build +%{?systemd_requires} + +%description +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. + +%prep +%setup0 -q + +%build +export EXTRA_CFLAGS="$RPM_OPT_FLAGS -Iusr/include" + +# take missing header files form kernel sources +make -C /usr/src/linux headers_install O=$PWD + +make %{?_smp_mflags} + +cp %{SOURCE4} . + +%install +make prefix=%{buildroot}/usr mandir=%{buildroot}/%{_mandir} install + +%__install -Dm 644 %{SOURCE1} %{buildroot}/%{_unitdir}/ptp4l.service +%__install -Dm 644 %{SOURCE5} %{buildroot}/%{_unitdir}/phc2sys.service +ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcptp4l +ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcphc2sys + +%__install -Dm 644 default.cfg %{buildroot}/%{_sysconfdir}/ptp4l.conf + +%__install -Dm 644 %{SOURCE2} %{buildroot}/var/adm/fillup-templates/sysconfig.ptp4l +%__install -Dm 644 %{SOURCE6} %{buildroot}/var/adm/fillup-templates/sysconfig.phc2sys + +%__install -Dm 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/linuxptp + +%pre +%service_add_pre ptp4l.service phc2sys.service + +%post +%{fillup_only -n ptp4l} +%{fillup_only -n phc2sys} +%service_add_post ptp4l.service phc2sys.service + +%preun +%service_del_preun ptp4l.service phc2sys.service + +%postun +%service_del_postun ptp4l.service phc2sys.service + +%files +%defattr(-,root,root) +%{_unitdir}/ptp4l.service +%{_unitdir}/phc2sys.service +%{_sbindir}/rcptp4l +%{_sbindir}/rcphc2sys +%config %{_sysconfdir}/ptp4l.conf +%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/linuxptp +%{_sbindir}/hwstamp_ctl +%{_sbindir}/phc2sys +%{_sbindir}/phc_ctl +%{_sbindir}/pmc +%{_sbindir}/ptp4l +%{_sbindir}/timemaster +%{_mandir}/man8/hwstamp_ctl.8.gz +%{_mandir}/man8/phc2sys.8.gz +%{_mandir}/man8/phc_ctl.8.gz +%{_mandir}/man8/pmc.8.gz +%{_mandir}/man8/ptp4l.8.gz +%{_mandir}/man8/timemaster.8.gz +/var/adm/fillup-templates/sysconfig.ptp4l +/var/adm/fillup-templates/sysconfig.phc2sys +%doc README.org COPYING linuxptp-howto.txt + +%changelog diff --git a/phc2sys.service b/phc2sys.service new file mode 100644 index 0000000..23fe47b --- /dev/null +++ b/phc2sys.service @@ -0,0 +1,11 @@ +[Unit] +Description=PTP: Synchronize two clocks +After=ntpdate.service + +[Service] +Type=simple +EnvironmentFile=-/etc/sysconfig/phc2sys +ExecStart=/usr/sbin/phc2sys $OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/ptp4l.service b/ptp4l.service new file mode 100644 index 0000000..c97665c --- /dev/null +++ b/ptp4l.service @@ -0,0 +1,10 @@ +[Unit] +Description=PTP: Boundary/Ordinary Clock + +[Service] +Type=simple +EnvironmentFile=-/etc/sysconfig/ptp4l +ExecStart=/usr/sbin/ptp4l $OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/sysconfig.phc2sys b/sysconfig.phc2sys new file mode 100644 index 0000000..b2105ed --- /dev/null +++ b/sysconfig.phc2sys @@ -0,0 +1,9 @@ +## Path: Network/LinuxPTP +## Description: Precision Time Protocol (PTP): phc2sys settings +## Type: string +## Default: "-s eth0 -w" +## ServiceRestart: phc2sys +# +# Arguments when starting phc2sys(8). +# +OPTIONS="-s eth0 -w" diff --git a/sysconfig.ptp4l b/sysconfig.ptp4l new file mode 100644 index 0000000..c3c35ef --- /dev/null +++ b/sysconfig.ptp4l @@ -0,0 +1,9 @@ +## Path: Network/LinuxPTP +## Description: Precision Time Protocol (PTP): ptp4l settings +## Type: string +## Default: "-i eth0 -f /etc/ptp4l.conf" +## ServiceRestart: ptp4l +# +# Arguments when starting ptp4l(8). +# +OPTIONS="-i eth0 -f /etc/ptp4l.conf"