From patchwork Fri Nov 9 10:14:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miroslav Lichvar X-Patchwork-Id: 995419 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42rwxn6MwHz9sC7 for ; Fri, 9 Nov 2018 21:14:53 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727725AbeKITyq (ORCPT ); Fri, 9 Nov 2018 14:54:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50070 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727532AbeKITyq (ORCPT ); Fri, 9 Nov 2018 14:54:46 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06E992D2BCD; Fri, 9 Nov 2018 10:14:52 +0000 (UTC) Received: from holly.tpb.lab.eng.brq.redhat.com (holly.tpb.lab.eng.brq.redhat.com [10.43.134.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75E3A100194A; Fri, 9 Nov 2018 10:14:50 +0000 (UTC) From: Miroslav Lichvar To: netdev@vger.kernel.org Cc: Richard Cochran , Jacob Keller , Miroslav Lichvar , Marcelo Tosatti , Jeff Kirsher , Michael Chan Subject: [PATCH net-next 0/8] More accurate PHC<->system clock synchronization Date: Fri, 9 Nov 2018 11:14:41 +0100 Message-Id: <20181109101449.15398-1-mlichvar@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 09 Nov 2018 10:14:52 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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(-) Reviewed-by: Jacob Keller Acked-by: Richard Cochran