Re: [Linuxptp-devel] [PATCH 00/13] Prepare for sub-nanosecond timestamps

2018-03-01 Thread Michael Brown
On 01/03/18 06:40, Richard Cochran wrote: At first glance this series looks good. I expect to merge the first half or so, because we really do want the tmv_t operations to be used consistently. Regarding changing the implementation, I think we'll want to hold off on that until kernel support

[Linuxptp-devel] [PATCH RFC V2 04/11] clock: Introduce a method to obtain the last synchronization time.

2018-03-01 Thread Richard Cochran
The NetSync Monitor protocol will require us to report the time stamp of the last synchronization. This patch adds new the method. Signed-off-by: Richard Cochran --- clock.c | 5 + clock.h | 7 +++ 2 files changed, 12 insertions(+) diff --git a/clock.c

[Linuxptp-devel] [PATCH RFC V2 00/10] Multiple TLV support

2018-03-01 Thread Richard Cochran
We are going to need multiple TLV support soon rather than later, in order to support various unicast profiles for example. I want to get this in before adding any more TLV code, and so I'll rework the NSM support on top of this. This series removes the single TLV limitation. What PITA that

Re: [Linuxptp-devel] HWTSTAMP_TX_ONESTEP_SYNC Already Defined

2018-03-01 Thread Richard Cochran
(reposting this, because SF block me as a spammer!) On Tue, Feb 27, 2018 at 01:19:35PM -0500, Joey DiGiorgio wrote: > I tried commenting that section out in missing.h, but I was thinking > it should already be handled by the #ifndef Right. > and I've been having > issues getting Linux PTP

[Linuxptp-devel] [PATCH RFC V2 11/11] nsm: Implement the NetSync Monitor query.

2018-03-01 Thread Richard Cochran
This patch adds a new "NSM" program. The new code handles only one outstanding NSM command at a time. If and when all four event time stamps have arrived, the code prints the instantaneous estimated offset without any averaging or smoothing. Signed-off-by: Richard Cochran

[Linuxptp-devel] [PATCH RFC 09/10] port: Fix coding style.

2018-03-01 Thread Richard Cochran
We always but braces around 'if' blocks. Signed-off-by: Richard Cochran --- port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/port.c b/port.c index 263638c..2ee3ac6 100644 --- a/port.c +++ b/port.c @@ -2426,8 +2426,9 @@ int

[Linuxptp-devel] [PATCH RFC V2 00/11] NetSync Monitor support

2018-03-01 Thread Richard Cochran
This series adds support for Meinberg Funkuhren's NetSync Monitor (NSM) protocol. NSM allows a node with a local time reference (like a GM using GPS) to measure the offset of a given clock. In a nutshell, NSM works by having the node to be measured act like a unicast master clock on demand. 1.

[Linuxptp-devel] [PATCH RFC V2 09/10] msg: Remove the 'last_tlv' field.

2018-03-01 Thread Richard Cochran
All users have been converted to the TLV list, so remove the field. Signed-off-by: Richard Cochran --- msg.c | 1 - msg.h | 6 -- 2 files changed, 7 deletions(-) diff --git a/msg.c b/msg.c index 348b7b5..8bc14f8 100644 --- a/msg.c +++ b/msg.c @@ -462,7 +462,6 @@

[Linuxptp-devel] [PATCH RFC V2 06/10] pmc: Remove unused parameter.

2018-03-01 Thread Richard Cochran
The third parameter of the function, pmc_send(), is never used. This patch removes it. Signed-off-by: Richard Cochran --- pmc_common.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pmc_common.c b/pmc_common.c index 4ece489..91fffb3 100644

[Linuxptp-devel] [PATCH RFC 02/10] raw: Fix valgrind setsockopt warning.

2018-03-01 Thread Richard Cochran
Valgrind is nagging us, saying we pass uninitialized data through a setsockopt() call. This patch fixes the issue by clearing the entire passed structure. Signed-off-by: Richard Cochran --- raw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/raw.c b/raw.c index

[Linuxptp-devel] [PATCH RFC V2 08/11] port: Implement the NetSync Monitor protocol.

2018-03-01 Thread Richard Cochran
When NSM is enabled on a given port, that port always replies to a NSM delay request with a delay response, sync, and follow up, regardless of the current state of the port. Signed-off-by: Richard Cochran --- port.c | 132

[Linuxptp-devel] [PATCH RFC 05/10] clock: Simplify management response logic.

2018-03-01 Thread Richard Cochran
The code uses a local variable for program flow control in a silly way. This patch simplifies the logic by using the common switch/case/default pattern instead. Signed-off-by: Richard Cochran --- clock.c | 38 +- 1 file changed, 13

[Linuxptp-devel] [PATCH RFC 06/10] clock: Fix coding style.

2018-03-01 Thread Richard Cochran
--- clock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clock.c b/clock.c index 069795a..427ca6c 100644 --- a/clock.c +++ b/clock.c @@ -335,11 +335,11 @@ static int clock_management_fill_response(struct clock *c, struct port *p,

[Linuxptp-devel] [PATCH RFC 00/10] CodingStyle and other minor fixes

2018-03-01 Thread Richard Cochran
I've been working on multiple TLV support, and I rebased the NSM series on top of that. Along the way I made a number of minor fixes. This series collects them all together. Richard Cochran (10): msg: Share a static global more globally. raw: Fix valgrind setsockopt warning. port: Clean up

[Linuxptp-devel] [PATCH RFC V2 07/10] port: Convert to the API for appending TLVs on the transmit path.

2018-03-01 Thread Richard Cochran
The current code uses an ad hoc method of appending TLVs. When constructing a message, the code computes the total PDU length by adding the message size to the TLV size. By using the new API, this patch simplifies message construction, letting each TLV add its own length to the total. As a

[Linuxptp-devel] [PATCH RFC 07/10] pmc: Fix white space errors.

2018-03-01 Thread Richard Cochran
We indent with tabs, not spaces. Signed-off-by: Richard Cochran --- pmc.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pmc.c b/pmc.c index af9cc63..49282a6 100644 --- a/pmc.c +++ b/pmc.c @@ -233,19 +233,19 @@ static void

[Linuxptp-devel] [PATCH RFC V2 08/10] msg: Use the TLV list on transmit.

2018-03-01 Thread Richard Cochran
Now that the list is in place and is used on all transmit paths, simply iterate through the list when converting to network byte order. Signed-off-by: Richard Cochran --- msg.c | 23 ++- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git

[Linuxptp-devel] [PATCH RFC V2 04/10] msg: Introduce method for appending multiple TLVs on transmit.

2018-03-01 Thread Richard Cochran
In order to support multiple TLVs, the transmit code must be able to append one TLV after another. This patch adds a method that checks whether there is room, allocates the TLV descriptor, sets the buffer pointer, and appends the descriptor to the list. Signed-off-by: Richard Cochran

[Linuxptp-devel] [PATCH RFC 01/10] msg: Share a static global more globally.

2018-03-01 Thread Richard Cochran
Any code that wants to call one_step() needs to link with the static global 'assume_two_step'. This patch moves that variable's definition from ptp4l.c to msg.c. Not only is that file the more natural choice (since the variable is used on msg.h) but also this allows other programs to call the

[Linuxptp-devel] [PATCH RFC V2 01/10] tlv: Implement a memory pool for TLV descriptors.

2018-03-01 Thread Richard Cochran
Signed-off-by: Richard Cochran --- msg.c | 3 +++ tlv.c | 32 tlv.h | 21 + 3 files changed, 56 insertions(+) diff --git a/msg.c b/msg.c index 6943431..52a59e7 100644 --- a/msg.c +++ b/msg.c @@ -213,6 +213,9 @@ void

[Linuxptp-devel] [PATCH v2 05/10] tmv: Add missing uses of tmv_to_nanoseconds()

2018-03-01 Thread Michael Brown
Signed-off-by: Michael Brown --- clock.c | 2 +- tsproc.c | 10 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clock.c b/clock.c index e4f939a..53d9c75 100644 --- a/clock.c +++ b/clock.c @@ -419,7 +419,7 @@ static int

[Linuxptp-devel] [PATCH v2 03/10] tmv: Add missing uses of tmv_is_zero()

2018-03-01 Thread Michael Brown
Signed-off-by: Michael Brown --- clock.c | 4 ++-- port.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clock.c b/clock.c index e733bdf..e4f939a 100644 --- a/clock.c +++ b/clock.c @@ -581,7 +581,7 @@ static enum servo_state

[Linuxptp-devel] [PATCH v2 02/10] tmv: Add missing uses of tmv_zero()

2018-03-01 Thread Michael Brown
Signed-off-by: Michael Brown --- mave.c | 2 +- tsproc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mave.c b/mave.c index fd09e5a..1a64f79 100644 --- a/mave.c +++ b/mave.c @@ -58,7 +58,7 @@ static void mave_reset(struct filter *filter)

[Linuxptp-devel] [PATCH v2 04/10] tmv: Add missing uses of tmv_dbl()

2018-03-01 Thread Michael Brown
Signed-off-by: Michael Brown --- tsproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsproc.c b/tsproc.c index 06c0184..b50c8e5 100644 --- a/tsproc.c +++ b/tsproc.c @@ -214,7 +214,7 @@ int tsproc_update_offset(struct tsproc *tsp, tmv_t *offset,

[Linuxptp-devel] [PATCH v2 07/10] tmv: Add tmv_sign()

2018-03-01 Thread Michael Brown
The sign of time values is tested in tsproc.c. Add an abstraction tmv_sign() to return the sign of a time value. Signed-off-by: Michael Brown --- tmv.h| 5 + tsproc.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tmv.h b/tmv.h index

[Linuxptp-devel] [PATCH RFC 03/10] port: Clean up coding style.

2018-03-01 Thread Richard Cochran
Re-arrange local variables into a more legible reverse Christmas tree. Signed-off-by: Richard Cochran --- port.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/port.c b/port.c index 6cc5dd0..76af2ae 100644 --- a/port.c +++ b/port.c @@

[Linuxptp-devel] [PATCH RFC 10/10] tlv: Fix coding style.

2018-03-01 Thread Richard Cochran
We are programming C, not Java, and so opening braces of a function belong on a line all by themselves. Signed-off-by: Richard Cochran --- tlv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tlv.c b/tlv.c index cef10a0..a5c2eb3 100644 ---

[Linuxptp-devel] [PATCH RFC V2 09/11] Add a configuration file option to enable the NetSync Monitor protocol.

2018-03-01 Thread Richard Cochran
Signed-off-by: Richard Cochran --- config.c| 1 + default.cfg | 1 + gPTP.cfg| 1 + port.c | 1 + ptp4l.8 | 12 +++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 56d1556..ba035ac 100644 ---

[Linuxptp-devel] [PATCH RFC V2 01/11] msg: Allow zero length TLVs.

2018-03-01 Thread Richard Cochran
The NetSync Monitor protocol features a TLV with a length of zero. Our input message parsing assumes that every TLV will have some sort of payload, and up until now this was true. This patch adjusts the parsing code to accept TLVs of length zero. Signed-off-by: Richard Cochran

[Linuxptp-devel] [PATCH RFC V2 10/11] util: Relocate utility functions from pmc.c.

2018-03-01 Thread Richard Cochran
The file, pmc.c, contains utility functions for printing out a port address structure. We will want to call these functions from pmc_common.c, and so this patch moves the utility functions where they belong. Signed-off-by: Richard Cochran --- pmc.c | 48

[Linuxptp-devel] [PATCH RFC 04/10] port: Simplify management response logic.

2018-03-01 Thread Richard Cochran
The code uses a local variable for program flow control in a silly way. This patch simplifies the logic by using the common switch/case/default pattern instead. Signed-off-by: Richard Cochran --- port.c | 35 ++- 1 file changed, 14

[Linuxptp-devel] [PATCH RFC V2 06/11] tlv: Introduce the NetSync Monitor TLVs.

2018-03-01 Thread Richard Cochran
This patch adds support for packing and unpacking the NSM TLVs. In addition, it introduces macros to make the ntoh/htoh boilerplate easier to read. The idea is to reduce the number of monstrous muti-line assignments like: pds->grandmasterClockQuality.offsetScaledLogVariance =

[Linuxptp-devel] [PATCH RFC V2 03/11] clock: Introduce a method to get the current dataset.

2018-03-01 Thread Richard Cochran
As part of the NetSync Monitor protocol, the port will need to have access to the current data set. This patch adds the appropriate function. Signed-off-by: Richard Cochran --- clock.c | 5 + clock.h | 7 +++ 2 files changed, 12 insertions(+) diff --git

[Linuxptp-devel] [PATCH RFC V2 02/11] msg: Allow tacking a TLV onto a delay request message.

2018-03-01 Thread Richard Cochran
This will be needed in order to support the NetSync Monitor protocol. Signed-off-by: Richard Cochran --- msg.c | 3 ++- msg.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/msg.c b/msg.c index 9038616..a36d4d0 100644 --- a/msg.c +++ b/msg.c @@

[Linuxptp-devel] [PATCH RFC V2 05/11] tmv: Add a method to convert to a struct Timestamp.

2018-03-01 Thread Richard Cochran
This will be needed in order to generate a TLV for the NSM protocol. Signed-off-by: Richard Cochran --- tmv.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/tmv.h b/tmv.h index 30b41ee..5d1e12b 100644 --- a/tmv.h +++ b/tmv.h @@ -96,6 +96,21 @@

[Linuxptp-devel] [PATCH RFC 08/10] pmc: Add missing break in switch/case.

2018-03-01 Thread Richard Cochran
Signed-off-by: Richard Cochran --- pmc_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pmc_common.c b/pmc_common.c index 447cf99..c1b0d3e 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -314,6 +314,7 @@ struct ptp_message *pmc_recv(struct pmc *pmc)

[Linuxptp-devel] [PATCH RFC V2 02/10] msg: Introduce a TLV list.

2018-03-01 Thread Richard Cochran
In order to support multiple TLVs per message, a list is needed. This patch adds the list to the message structure. This list will eventually replace the 'last_tlv' field. Signed-off-by: Richard Cochran --- msg.c | 16 msg.h | 5 + 2 files

[Linuxptp-devel] [PATCH v2 06/10] tmv: Generalise tmv_eq() to tmv_cmp()

2018-03-01 Thread Michael Brown
Time values are compared using an inequality test in mmedian.c Generalise tmv_eq() to tmv_cmp() (by analogy with memcmp()) and replace existing uses of tmv_eq(). Signed-off-by: Michael Brown --- clock.c | 2 +- mmedian.c | 3 ++- port.c| 2 +- tmv.h | 4 ++--

[Linuxptp-devel] [PATCH v2 09/10] tmv: Add converters for hardware timestamps

2018-03-01 Thread Michael Brown
Add converters between hardware timestamps and the internal representation, and remove code that directly manipulates the timespec within a hardware timestamp. Signed-off-by: Michael Brown --- clock.c | 6 ++ clock.h | 2 +- port.c | 69

[Linuxptp-devel] [PATCH v2 00/10] Prepare for sub-nanosecond timestamps

2018-03-01 Thread Michael Brown
>> Would you like me to respin a v2 series which contains only the patches that >> will not impose a speed penalty? > > Yes, please. Herewith the revised patch series. I've reworked a couple of the patches to fit with the focus of simply ensuring that tmv_t is used consistently across the

[Linuxptp-devel] [PATCH v2 01/10] clock: Pass floating point values to stats_add_value()

2018-03-01 Thread Michael Brown
Use tmv_dbl() to obtain the floating point value passed to stats_add_value() rather than relying on the existing implicit cast from the result of tmv_to_nanoseconds(). Signed-off-by: Michael Brown --- clock.c | 13 + 1 file changed, 5 insertions(+), 8

[Linuxptp-devel] [PATCH v2 08/10] tmv: Move struct hw_timestamp from msg.h to tmv.h

2018-03-01 Thread Michael Brown
The definition of struct hw_timestamp is not used anywhere in msg.c, but is used in various places that care about the internal time representation. Move this definition to tmv.h as a more natural home. Signed-off-by: Michael Brown --- msg.h | 13 - tmv.h |

[Linuxptp-devel] [PATCH v2 10/10] tmv: Convert tmv_t to a non-scalar type

2018-03-01 Thread Michael Brown
Enforce the use of the tmv_t wrapper functions by converting tmv_t from an int64_t to a struct containing an int64_t. Inspection of the disassembly shows that this change has essentially no impact on the resulting object code, at least for x86_64 with compiler optimisations enabled.