mbox series

[net-next,0/8] More accurate PHC<->system clock synchronization

Message ID 20181109101449.15398-1-mlichvar@redhat.com
Headers show
Series More accurate PHC<->system clock synchronization | expand

Message

Miroslav Lichvar Nov. 9, 2018, 10:14 a.m. UTC
RFC->v1:
- added new patches
- separated PHC timestamp from ptp_system_timestamp
- fixed memory leak in PTP_SYS_OFFSET_EXTENDED
- changed PTP_SYS_OFFSET_EXTENDED to work with array of arrays
- fixed PTP_SYS_OFFSET_EXTENDED to break correctly from loop
- fixed timecounter updates in drivers
- split gettimex in igb driver
- fixed ptp_read_* functions to be available without
  CONFIG_PTP_1588_CLOCK

This series enables a more accurate synchronization between PTP hardware
clocks and the system clock.

The first two patches are minor cleanup/bug fixes.

The third patch adds an extended version of the PTP_SYS_OFFSET ioctl,
which returns three timestamps for each measurement. The idea is to
shorten the interval between the system timestamps to contain just the
reading of the lowest register of the PHC in order to reduce the error
in the measured offset and get a smaller upper bound on the maximum
error.

The fourth patch deprecates the original gettime function.

The remaining patches update the gettime function in order to support
the new ioctl in the e1000e, igb, ixgbe, and tg3 drivers.

Tests with few different NICs in different machines show that:
- with an I219 (e1000e) the measured delay was reduced from 2500 to 1300
  ns and the error in the measured offset, when compared to the cross
  timestamping supported by the driver, was reduced by a factor of 5
- with an I210 (igb) the delay was reduced from 5100 to 1700 ns
- with an I350 (igb) the delay was reduced from 2300 to 750 ns
- with an X550 (ixgbe) the delay was reduced from 1950 to 650 ns
- with a BCM5720 (tg3) the delay was reduced from 2400 to 1200 ns


Miroslav Lichvar (8):
  ptp: reorder declarations in ptp_ioctl()
  ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl
  ptp: add PTP_SYS_OFFSET_EXTENDED ioctl
  ptp: deprecate gettime64() in favor of gettimex64()
  e1000e: extend PTP gettime function to read system clock
  igb: extend PTP gettime function to read system clock
  ixgbe: extend PTP gettime function to read system clock
  tg3: extend PTP gettime function to read system clock

 drivers/net/ethernet/broadcom/tg3.c          | 19 ++++--
 drivers/net/ethernet/intel/e1000e/e1000.h    |  3 +
 drivers/net/ethernet/intel/e1000e/netdev.c   | 42 ++++++++++---
 drivers/net/ethernet/intel/e1000e/ptp.c      | 16 +++--
 drivers/net/ethernet/intel/igb/igb_ptp.c     | 65 +++++++++++++++++---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 54 +++++++++++++---
 drivers/ptp/ptp_chardev.c                    | 55 ++++++++++++++---
 drivers/ptp/ptp_clock.c                      |  5 +-
 include/linux/ptp_clock_kernel.h             | 33 ++++++++++
 include/uapi/linux/ptp_clock.h               | 12 ++++
 10 files changed, 253 insertions(+), 51 deletions(-)

Comments

Keller, Jacob E Nov. 9, 2018, 6:12 p.m. UTC | #1
> -----Original Message-----
> From: Miroslav Lichvar [mailto:mlichvar@redhat.com]
> Sent: Friday, November 09, 2018 2:15 AM
> To: netdev@vger.kernel.org
> Cc: Richard Cochran <richardcochran@gmail.com>; Keller, Jacob E
> <jacob.e.keller@intel.com>; Miroslav Lichvar <mlichvar@redhat.com>; Marcelo
> Tosatti <mtosatti@redhat.com>; Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>;
> Michael Chan <michael.chan@broadcom.com>
> Subject: [PATCH net-next 0/8] More accurate PHC<->system clock synchronization
> 
> RFC->v1:
> - added new patches
> - separated PHC timestamp from ptp_system_timestamp
> - fixed memory leak in PTP_SYS_OFFSET_EXTENDED
> - changed PTP_SYS_OFFSET_EXTENDED to work with array of arrays
> - fixed PTP_SYS_OFFSET_EXTENDED to break correctly from loop
> - fixed timecounter updates in drivers
> - split gettimex in igb driver
> - fixed ptp_read_* functions to be available without
>   CONFIG_PTP_1588_CLOCK
> 
> This series enables a more accurate synchronization between PTP hardware
> clocks and the system clock.

Thanks for doing this, Miroslav!

> 
> The first two patches are minor cleanup/bug fixes.
> 
> The third patch adds an extended version of the PTP_SYS_OFFSET ioctl,
> which returns three timestamps for each measurement. The idea is to
> shorten the interval between the system timestamps to contain just the
> reading of the lowest register of the PHC in order to reduce the error
> in the measured offset and get a smaller upper bound on the maximum
> error.
> 
> The fourth patch deprecates the original gettime function.
> 
> The remaining patches update the gettime function in order to support
> the new ioctl in the e1000e, igb, ixgbe, and tg3 drivers.
> 
> Tests with few different NICs in different machines show that:
> - with an I219 (e1000e) the measured delay was reduced from 2500 to 1300
>   ns and the error in the measured offset, when compared to the cross
>   timestamping supported by the driver, was reduced by a factor of 5
> - with an I210 (igb) the delay was reduced from 5100 to 1700 ns
> - with an I350 (igb) the delay was reduced from 2300 to 750 ns
> - with an X550 (ixgbe) the delay was reduced from 1950 to 650 ns
> - with a BCM5720 (tg3) the delay was reduced from 2400 to 1200 ns
> 

Impressive results!

For the main portions and the Intel driver changes this is

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

Regards,
Jake

> 
> Miroslav Lichvar (8):
>   ptp: reorder declarations in ptp_ioctl()
>   ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl
>   ptp: add PTP_SYS_OFFSET_EXTENDED ioctl
>   ptp: deprecate gettime64() in favor of gettimex64()
>   e1000e: extend PTP gettime function to read system clock
>   igb: extend PTP gettime function to read system clock
>   ixgbe: extend PTP gettime function to read system clock
>   tg3: extend PTP gettime function to read system clock
> 
>  drivers/net/ethernet/broadcom/tg3.c          | 19 ++++--
>  drivers/net/ethernet/intel/e1000e/e1000.h    |  3 +
>  drivers/net/ethernet/intel/e1000e/netdev.c   | 42 ++++++++++---
>  drivers/net/ethernet/intel/e1000e/ptp.c      | 16 +++--
>  drivers/net/ethernet/intel/igb/igb_ptp.c     | 65 +++++++++++++++++---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 54 +++++++++++++---
>  drivers/ptp/ptp_chardev.c                    | 55 ++++++++++++++---
>  drivers/ptp/ptp_clock.c                      |  5 +-
>  include/linux/ptp_clock_kernel.h             | 33 ++++++++++
>  include/uapi/linux/ptp_clock.h               | 12 ++++
>  10 files changed, 253 insertions(+), 51 deletions(-)
> 
> --
> 2.17.2
David Miller Nov. 9, 2018, 11:28 p.m. UTC | #2
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Fri,  9 Nov 2018 11:14:41 +0100

> RFC->v1:
> - added new patches
> - separated PHC timestamp from ptp_system_timestamp
> - fixed memory leak in PTP_SYS_OFFSET_EXTENDED
> - changed PTP_SYS_OFFSET_EXTENDED to work with array of arrays
> - fixed PTP_SYS_OFFSET_EXTENDED to break correctly from loop
> - fixed timecounter updates in drivers
> - split gettimex in igb driver
> - fixed ptp_read_* functions to be available without
>   CONFIG_PTP_1588_CLOCK
> 
> This series enables a more accurate synchronization between PTP hardware
> clocks and the system clock.
 ...

This series looks good to me but I want to give Richard an opportunity to
review it first.
Kirsher, Jeffrey T Nov. 9, 2018, 11:33 p.m. UTC | #3
On Fri, 2018-11-09 at 15:28 -0800, David Miller wrote:
> From: Miroslav Lichvar <mlichvar@redhat.com>
> Date: Fri,  9 Nov 2018 11:14:41 +0100
> 
> > RFC->v1:
> > - added new patches
> > - separated PHC timestamp from ptp_system_timestamp
> > - fixed memory leak in PTP_SYS_OFFSET_EXTENDED
> > - changed PTP_SYS_OFFSET_EXTENDED to work with array of arrays
> > - fixed PTP_SYS_OFFSET_EXTENDED to break correctly from loop
> > - fixed timecounter updates in drivers
> > - split gettimex in igb driver
> > - fixed ptp_read_* functions to be available without
> >   CONFIG_PTP_1588_CLOCK
> > 
> > This series enables a more accurate synchronization between PTP
> > hardware
> > clocks and the system clock.
>  ...
> 
> This series looks good to me but I want to give Richard an opportunity to
> review it first.

Dave, I also do not want to hold this series up by picking up patches 5, 6
and 7 (Intel drivers) so please apply the entire series after Richard
provides his review.
David Miller Nov. 10, 2018, 12:55 a.m. UTC | #4
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Fri, 09 Nov 2018 15:33:10 -0800

> On Fri, 2018-11-09 at 15:28 -0800, David Miller wrote:
>> From: Miroslav Lichvar <mlichvar@redhat.com>
>> Date: Fri,  9 Nov 2018 11:14:41 +0100
>> 
>> > RFC->v1:
>> > - added new patches
>> > - separated PHC timestamp from ptp_system_timestamp
>> > - fixed memory leak in PTP_SYS_OFFSET_EXTENDED
>> > - changed PTP_SYS_OFFSET_EXTENDED to work with array of arrays
>> > - fixed PTP_SYS_OFFSET_EXTENDED to break correctly from loop
>> > - fixed timecounter updates in drivers
>> > - split gettimex in igb driver
>> > - fixed ptp_read_* functions to be available without
>> >   CONFIG_PTP_1588_CLOCK
>> > 
>> > This series enables a more accurate synchronization between PTP
>> > hardware
>> > clocks and the system clock.
>>  ...
>> 
>> This series looks good to me but I want to give Richard an opportunity to
>> review it first.
> 
> Dave, I also do not want to hold this series up by picking up patches 5, 6
> and 7 (Intel drivers) so please apply the entire series after Richard
> provides his review.

Ok, will do.
Richard Cochran Nov. 10, 2018, 1:44 a.m. UTC | #5
On Fri, Nov 09, 2018 at 03:28:46PM -0800, David Miller wrote:
> This series looks good to me but I want to give Richard an opportunity to
> review it first.

The series is good to go.

Acked-by: Richard Cochran <richardcochran@gmail.com>
David Miller Nov. 10, 2018, 3:44 a.m. UTC | #6
From: Richard Cochran <richardcochran@gmail.com>
Date: Fri, 9 Nov 2018 17:44:31 -0800

> On Fri, Nov 09, 2018 at 03:28:46PM -0800, David Miller wrote:
>> This series looks good to me but I want to give Richard an opportunity to
>> review it first.
> 
> The series is good to go.
> 
> Acked-by: Richard Cochran <richardcochran@gmail.com>

Great, series applied to net-next, thanks everyone.