Re: [Linuxptp-devel] More fun with i210 EXTTS: measure some PPS against a reference PPS
On 5 Mar 2020 at 17:01, Jacob Keller wrote: > On 3/5/2020 1:11 AM, Frantisek Rysanek wrote: > > And another sideways question is: in the i210 hardware, there's a > > register called SYSTIMR, supposedly holding the fraction of a > > nanosecond (= sub-nanosecond resolution). And this register is > > ignored by the igb driver in Linux - first and foremost because the > > internal timestamping infrastructure only supports nanosecond > > resolution. I know that a "ns fraction" field is present in the PTP > > frames, but everybody except the White Rabbit just leave that field > > empty (all zeroes). I'm wondering if this SYSTIMR register in the > > i210 hardware has some practical use, or is always zero, or what. > > Well for my practical purposes, the SYSTIMR does not get reflected in > > the two AUXSTMP registers - so I can probably just ignore SYSTIMR > > too. > > So, the SYSTIMR field is not "used" directly, but it holds and maintains > fractional nanoseconds. When you adjust the increment value slightly, > these get added to the SYSTIMR field of the system time. As that slowly > increments and eventually overflows, it will then increment the SYSTIML > register. > > Essentially we always round down by cutting off SYSTIMR. > Mr. Keller thanks for your polite explanation :-) I have to say that the i210 is a very nice piece of silicon to play with :-) I'm aware that at 1 GHz / fractions of a ns, it takes some cunning design to make a synth with this kind of fine adjustment, immediate response and nanosecond resolution, with hardly any jitter/phase noise. It's a job well done. The fact that timestamping external events is granular at 8 ns ("only") does not offend me. I'm aware that it's difficult to run counters and atomic latches that fast. I've read something about WhiteRabbit's phase detector, called the DDMTD - which supposedly can measure phase differences down to the picosecond range. If I understand correctly, that comparator block depends on having isochronous clocks (the reference and the measured input) much faster than 1PPS and hinges on down-mixing those clocks, then phase comparison and statistics (filtering) to arrive at that fine-grained result. Hence also WhiteRabbit's dependence on SyncE, and the BC-only nature of their PTP-aware switches... I understand that this is what it takes to run time-sync over a WAN at ns/sub-ns level preecision... Frank Rysanek ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] More fun with i210 EXTTS: measure some PPS against a reference PPS
Just a snippet of a funny observation: I've discovered the config parameter "clock_servo nullf" . Very good - that answes another need I had: to let the PHC freewheel along the ultimate external reference (10MHz -> PLL_synth -> 25 MHz from the PTP GM out of band), and let ptp4l do the talk and calculate the delays and offsets that it can obsereve on the network. It seems to work fine. On a real-wold network I may also need to raise the bar for step-wise adjustment (for this measurement to proceed unhampered). Just to test if it works, I've tried L2 multicast through an old D-Link DGS-1216T. It does work, the (p)delay is about 2 microseconds. The switch does let both P2P Pdelay and E2E Delay through just fine. And the funny point is: while the E2E transactions result in no asymmetry, the P2P transactions result in about +60 nanoseconds of additional asymmetry. That's curious... That's over two metallic gigabit hops. For comparison, straight against the GM, I have about 7 or 10 ns of (p)delay and about -20 ns of asymmetry, which may well correspond to the length of my PPS cabling (that I use to pre-settle the PHC). Yes I'm having fun with my toys :-D Frank ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] More fun with i210 EXTTS: measure some PPS against a reference PPS
On 6 Mar 2020 at 16:42, linuxptp-devel wrote: > And the funny point is: while the E2E transactions result in no > asymmetry, the P2P transactions result in about +60 nanoseconds > of additional asymmetry. That's curious... > ...actually I should've quoted that as -60 nanoseconds. In addition to the -20 ns on a direct connection. The total hovers around -80 ns offset. Frank ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] [PATCH] phc2sys: Notify kernel if clock is not in sync
On Thu, Mar 05, 2020 at 08:29:03AM +0100, Miroslav Lichvar wrote: > > I'd stick with the meaning "the clock has is believed to have an error > larger than 16 seconds". With ptp4l/phc2sys, if someone needs to check > if the clock was updated in the last X seconds, they can check the > maxerror value if it's not larger than X * 500us. No need to set the > UNSYNC flag. Okay, I trust your judgement on this, and I am reverting that commit. Thanks, Richard ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] [RFC V2] Add IEEE 802.1AS-2011 time-aware bridge support
On Wed, Feb 19, 2020 at 01:52:28AM +, Y.b. Lu wrote: > May I know your opinion on time-aware bridge support? I would like to see someone carefully review them. I'm especially interested in having the new code conform to the new standard (which I haven't read yet). Could you possibly arrange to have this tested at the UNH lab? Passing the conformance tests would be a strong reason for merging. Thanks, Richard ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 6/6] Provide a method to convert a tmv_t into a timespec.
Currently there is a method to convert a timespec into a tmv_t, but not the other way round. This patch adds the missing function in anticipation of a new feature that will need this conversion. Signed-off-by: Richard Cochran --- tmv.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/tmv.h b/tmv.h index cca4da7..f4a1a22 100644 --- a/tmv.h +++ b/tmv.h @@ -143,6 +143,16 @@ static inline tmv_t timespec_to_tmv(struct timespec ts) return t; } +static inline struct timespec tmv_to_timespec(tmv_t t) +{ + struct timespec ts; + + ts.tv_sec = t.ns / NS_PER_SEC; + ts.tv_nsec = t.ns % NS_PER_SEC; + + return ts; +} + static inline tmv_t timestamp_to_tmv(struct timestamp ts) { tmv_t t; -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 1/6] clock: Safely remove event subscribers from list.
When updating and potentially removing event subscribers, the code uses the simple list traversal macro. As a result, the list will become corrupted whenever a subscriber is removed. This patch fixes the issue by using the appropriate macro. Fixes: 5104e3e56b59 ("Event subscribing") Signed-off-by: Richard Cochran Reported-by: Michael Walle --- clock.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clock.c b/clock.c index 1668383..6f9cc21 100644 --- a/clock.c +++ b/clock.c @@ -145,9 +145,9 @@ static void remove_subscriber(struct clock_subscriber *s) static void clock_update_subscription(struct clock *c, struct ptp_message *req, uint8_t *bitmask, uint16_t duration) { - struct clock_subscriber *s; - int i, remove = 1; + struct clock_subscriber *s, *tmp; struct timespec now; + int i, remove = 1; for (i = 0; i < EVENT_BITMASK_CNT; i++) { if (bitmask[i]) { @@ -156,12 +156,11 @@ static void clock_update_subscription(struct clock *c, struct ptp_message *req, } } - LIST_FOREACH(s, &c->subscribers, list) { + LIST_FOREACH_SAFE(s, &c->subscribers, list, tmp) { if (pid_eq(&s->targetPortIdentity, &req->header.sourcePortIdentity)) { - /* Found, update the transport address and event -* mask. */ if (!remove) { + /* Update transport address and event mask. */ s->addr = req->address; memcpy(s->events, bitmask, EVENT_BITMASK_CNT); clock_gettime(CLOCK_MONOTONIC, &now); -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 5/6] Add PHC methods for querying and configuring the pin functionality.
In anticipation of support for external time stamping in PHC devices, this patch adds wrapper functions around the pin functionality. Signed-off-by: Richard Cochran --- phc.c | 30 -- phc.h | 21 + 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/phc.c b/phc.c index a90d13e..1df2edd 100644 --- a/phc.c +++ b/phc.c @@ -16,7 +16,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include +#include #include #include #include @@ -24,8 +26,6 @@ #include #include -#include - #include "phc.h" /* @@ -100,6 +100,32 @@ int phc_max_adj(clockid_t clkid) return max; } +int phc_number_pins(clockid_t clkid) +{ + struct ptp_clock_caps caps; + + if (phc_get_caps(clkid, &caps)) { + return 0; + } +#ifdef HAVE_PIN_SETFUNC + return caps.n_pins; +#else + return 0; +#endif +} + +int phc_pin_setfunc(clockid_t clkid, struct ptp_pin_desc *desc) +{ + int err = -EOPNOTSUPP; +#ifdef HAVE_PIN_SETFUNC + err = ioctl(CLOCKID_TO_FD(clkid), PTP_PIN_SETFUNC2, desc); + if (err) { + fprintf(stderr, PTP_PIN_SETFUNC_FAILED "\n"); + } +#endif + return err; +} + int phc_has_pps(clockid_t clkid) { struct ptp_clock_caps caps; diff --git a/phc.h b/phc.h index c0c5996..4dbc374 100644 --- a/phc.h +++ b/phc.h @@ -46,6 +46,27 @@ void phc_close(clockid_t clkid); */ int phc_max_adj(clockid_t clkid); +/** + * Queries the number of programmable pins of a PTP hardware clock device. + * + * @param clkid A clock ID obtained using phc_open(). + * + * @return The number of pins supported by the clock. + */ +int phc_number_pins(clockid_t clkid); + +/** + * Configures a pin of a PTP hardware clock device. + * + * @param clkid A clock ID obtained using phc_open(). + * + * @param desc Pointer to a pin descriptor with the 'index', 'func', + * and 'chan' fields set. + * + * @return Zero on success, non-zero otherwise. + */ +int phc_pin_setfunc(clockid_t clkid, struct ptp_pin_desc *desc); + /** * Checks whether the given PTP hardware clock device supports PPS output. * -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 0/6] Clean up in preparation for GrandMaster support.
I have been preparing Balint Ferencz's ts2phc program for review on this list. The present series presents a mixture of fixes and new code in support of the upcoming GrandMaster features. Patches 1-3 are random fixes found along the way. Patches 4-6 add new helper code, preparing for GM support. Richard Cochran (6): clock: Safely remove event subscribers from list. Remove the unfinished SNMP code. Balance the posix clock open function with a close method. Add definitions for PTP pin ioctls for backwards kernel compatibility. Add PHC methods for querying and configuring the pin functionality. Provide a method to convert a tmv_t into a timespec. clock.c | 9 +-- makefile| 14 missing.h | 44 ++- phc.c | 30 +++- phc.h | 21 ++ phc2sys.c | 2 +- phc_ctl.c | 1 + snmp4lptp.8 | 119 -- snmp4lptp.c | 192 snmp4lptp_mib.h | 30 snmpflg.sh | 42 --- tmv.h | 10 +++ util.c | 8 ++ util.h | 6 ++ 14 files changed, 122 insertions(+), 406 deletions(-) delete mode 100644 snmp4lptp.8 delete mode 100644 snmp4lptp.c delete mode 100644 snmp4lptp_mib.h delete mode 100755 snmpflg.sh -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 3/6] Balance the posix clock open function with a close method.
The one user of the function, posix_clock_open(), simply open codes the closing call to phc_close(). This patch provides a method to balance closing and opening of a posix clock. In addition, the phc_ctl program never explicitly closed the opened clock, and so this patch adds the missing call. Signed-off-by: Richard Cochran --- phc2sys.c | 2 +- phc_ctl.c | 1 + util.c| 8 util.h| 6 ++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/phc2sys.c b/phc2sys.c index c0b7b3d..64bdf26 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -341,7 +341,7 @@ static void clock_reinit(struct node *node, struct clock *clock, int new_state) if (clkid == CLOCK_INVALID) return; - phc_close(clock->clkid); + posix_clock_close(clock->clkid); clock->clkid = clkid; clock->phc_index = phc_index; diff --git a/phc_ctl.c b/phc_ctl.c index e55af59..149ee9e 100644 --- a/phc_ctl.c +++ b/phc_ctl.c @@ -531,6 +531,7 @@ int main(int argc, char *argv[]) /* pass the remaining arguments to the run_cmds loop */ result = run_cmds(clkid, cmdc, cmdv); + posix_clock_close(clkid); if (result < -1) { /* show usage when command fails */ usage(progname); diff --git a/util.c b/util.c index 43d6224..296dd59 100644 --- a/util.c +++ b/util.c @@ -190,6 +190,14 @@ char *portaddr2str(struct PortAddress *addr) return buf; } +void posix_clock_close(clockid_t clock) +{ + if (clock == CLOCK_REALTIME) { + return; + } + phc_close(clock); +} + clockid_t posix_clock_open(const char *device, int *phc_index) { struct sk_ts_info ts_info; diff --git a/util.h b/util.h index 11e0935..6e104ea 100644 --- a/util.h +++ b/util.h @@ -110,6 +110,12 @@ char *pid2str(struct PortIdentity *id); char *portaddr2str(struct PortAddress *addr); +/** + * Closes a dynamic posix clock. + * @param clock A clock ID obtained via posix_clock_close(). + */ +void posix_clock_close(clockid_t clock); + /** * Opens a dynamic posix clock by name. * @param device The PHC character device or network interface to open. -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 4/6] Add definitions for PTP pin ioctls for backwards kernel compatibility.
Upcoming functionality will need to configure the input and output pins of PHC devices. However, this requires fairly recent kernel support. This patch adds the needed definitions for compiling with older kernel headers. In addition, kernel v5.4 introduced a second set of ioctls for the ancillary PTP Hardware Clock functionality. The original ioctls failed to enforce the various flags and reversed fields, but the second version has fixed the issues. Going forward, our user space PTP stack ought to use the newer ioctls (if available) from day one. Signed-off-by: Richard Cochran --- missing.h | 44 +++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/missing.h b/missing.h index 8f92079..310c4b3 100644 --- a/missing.h +++ b/missing.h @@ -23,9 +23,10 @@ #ifndef HAVE_MISSING_H #define HAVE_MISSING_H -#include +#include #include #include +#include #include #ifndef ADJ_TAI @@ -60,6 +61,47 @@ enum { }; #endif +#ifdef PTP_EXTTS_REQUEST2 +#define PTP_EXTTS_REQUEST_FAILED "PTP_EXTTS_REQUEST2 failed: %m" +#else +#define PTP_EXTTS_REQUEST_FAILED "PTP_EXTTS_REQUEST failed: %m" +#define PTP_EXTTS_REQUEST2 PTP_EXTTS_REQUEST +#endif + +#ifdef PTP_PEROUT_REQUEST2 +#define PTP_PEROUT_REQUEST_FAILED "PTP_PEROUT_REQUEST2 failed: %m" +#else +#define PTP_PEROUT_REQUEST_FAILED "PTP_PEROUT_REQUEST failed: %m" +#define PTP_PEROUT_REQUEST2 PTP_PEROUT_REQUEST +#endif + +#ifdef PTP_PIN_SETFUNC + +#define HAVE_PIN_SETFUNC + +#ifdef PTP_PIN_SETFUNC2 +#define PTP_PIN_SETFUNC_FAILED "PTP_PIN_SETFUNC2 failed: %m" +#else +#define PTP_PIN_SETFUNC_FAILED "PTP_PIN_SETFUNC failed: %m" +#define PTP_PIN_SETFUNC2 PTP_PIN_SETFUNC +#endif + +#else /*PTP_PIN_SETFUNC*/ +enum ptp_pin_function { + PTP_PF_NONE, + PTP_PF_EXTTS, + PTP_PF_PEROUT, + PTP_PF_PHYSYNC, +}; +struct ptp_pin_desc { + char name[64]; + unsigned int index; + unsigned int func; + unsigned int chan; + unsigned int rsv[5]; +}; +#endif /*!PTP_PIN_SETFUNC*/ + #ifndef LIST_FOREACH_SAFE #defineLIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = LIST_FIRST((head));\ -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 2/6] Remove the unfinished SNMP code.
Unfortunately the SNMP code still has issues like not passing the valgrind test, and no one is able to finish this up right now. This patch removes the SNMP program so that the upcoming release does not contain unfinished work, potentially misleading end users about the scope and completeness of the features. Signed-off-by: Richard Cochran --- makefile| 14 snmp4lptp.8 | 119 -- snmp4lptp.c | 192 snmp4lptp_mib.h | 30 snmpflg.sh | 42 --- 5 files changed, 397 deletions(-) delete mode 100644 snmp4lptp.8 delete mode 100644 snmp4lptp.c delete mode 100644 snmp4lptp_mib.h delete mode 100755 snmpflg.sh diff --git a/makefile b/makefile index e1dd3fa..a23945a 100644 --- a/makefile +++ b/makefile @@ -38,16 +38,9 @@ SRC = $(OBJECTS:.o=.c) DEPEND = $(OBJECTS:.o=.d) srcdir := $(dir $(lastword $(MAKEFILE_LIST))) incdefs := $(shell $(srcdir)/incdefs.sh) -snmpflg:= $(shell $(srcdir)/snmpflg.sh) version := $(shell $(srcdir)/version.sh $(srcdir)) VPATH = $(srcdir) -ifneq (,$(findstring -DHAVE_NET_SNMP,$(snmpflg))) -PRG+= snmp4lptp -OBJECTS+= snmp4lptp.o -snmplib:= $(shell net-snmp-config --netsnmp-agent-libs) -endif - prefix = /usr/local sbindir= $(prefix)/sbin mandir = $(prefix)/man @@ -71,13 +64,6 @@ hwstamp_ctl: hwstamp_ctl.o version.o phc_ctl: phc_ctl.o phc.o sk.o util.o clockadj.o sysoff.o print.o version.o -snmp4lptp: config.o hash.o interface.o msg.o phc.o pmc_common.o print.o sk.o \ - snmp4lptp.o tlv.o $(TRANSP) util.o - $(CC) $^ $(LDFLAGS) $(LOADLIBES) $(LDLIBS) $(snmplib) -o $@ - -snmp4lptp.o: snmp4lptp.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(snmpflg) -c $< - timemaster: phc.o print.o rtnl.o sk.o timemaster.o util.o version.o version.o: .version version.sh $(filter-out version.d,$(DEPEND)) diff --git a/snmp4lptp.8 b/snmp4lptp.8 deleted file mode 100644 index 7dda4d0..000 --- a/snmp4lptp.8 +++ /dev/null @@ -1,119 +0,0 @@ -.TH SNMP4LPTP 8 "September 2018" "linuxptp" -.SH NAME -snmp4lptp - SNMP sub agent - -.SH SYNOPSIS -.B snmp4lptp -[ -.BI \-f " config-file" -] [ -.B \-m -] [ -.B \-q -] [ -.I long-options -] - -.SH DESCRIPTION -.B snmp4lptp -is an implementation of a sub agent for handling SNMP requests on -the device running ptp4l. Via the UDS port, the sub agent retrieves -management information from ptp4l and translates the information to -or from an SNMP-specific form. - -.SH OPTIONS -.TP -.BI \-f " file" -Specify the path to the \fBsnmp4lptp\fR configuration file. -.TP -.B \-h -Display a help message. -.TP -.B \-m -Print messages to the standard output. -.TP -.B \-q -Don't send messages to the system logger. - -.SH LONG OPTIONS - -Each and every configuration file option (see below in sections -.BR PROGRAM\ OPTIONS -and -.BR PORT\ OPTIONS ) -may also appear -as a "long" style command line argument. For example, the transportSpecific -option may be set using either of these two forms: - -.RS -\f(CW\-\-transportSpecific 1 \-\-transportSpecific=1\fP -.RE - -Option values given on the command line override values in the global -section of the configuration file (which, in turn, overrides default -values). - -.SH CONFIGURATION FILE - -The configuration file is divided into sections. Each section starts with a -line containing its name enclosed in brackets and it follows with settings. -Each setting is placed on a separate line, it contains the name of the -option and the value separated by whitespace characters. Empty lines and lines -starting with # are ignored. - -The global section (indicated as -.BR [global] ) -sets the global program options as well as the default port specific options. -Other sections are port specific sections and they override the default port -options. The name of the section is the name of the configured port (e.g. -.BR [eth0] -). Currently no port specific options other than default are considered. - -.SH PROGRAM OPTIONS -.TP -.B domainNumber -The domain attribute of the local clock. -The default is 0. -.TP -.B logging_level -The maximum logging level of messages which should be printed. -The default is 6 (LOG_INFO). -.TP -.B message_tag -The tag which is added to all messages printed to the standard output or system -log. -The default is an empty string (which cannot be set in the configuration file -as the option requires an argument). -.TP -.B use_syslog -Print messages to the system log if enabled. -The default is 1 (enabled). -.TP -.B verbose -Print messages to the standard output if enabled. -The default is 0 (disabled). -.TP -.B uds_address -Specifies the address of the server's UNIX domain socket. -The default is /var/run/ptp4l. - -.SH PORT OPTIONS -.TP -.B transportSpecific -The transport specific field. Must be in the range 0 to 255. -The default is 0. - -.SH WARNING - -Be cautious when the same configuration file is used for both ptp4l -and snmp4lptp. Keep in mind that values