[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230929023721.1610484-1-maheshb@google.com>
Date: Thu, 28 Sep 2023 19:37:21 -0700
From: Mahesh Bandewar <maheshb@...gle.com>
To: Netdev <netdev@...r.kernel.org>, Linux <linux-kernel@...r.kernel.org>,
David Miller <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>
Cc: Jonathan Corbet <corbet@....net>, Don Hatchett <hatch@...gle.com>, Yuliang Li <yuliangli@...gle.com>,
Mahesh Bandewar <mahesh@...dewar.net>, Mahesh Bandewar <maheshb@...gle.com>
Subject: [PATCH 0/4] add ptp_gettimex64any() API
The current API to get the sandwich TS for the master-PTP clock read
supports only the sys-time sandwich. This is not really suitable for
all the use cases of sandwich TS needs. Ideally it should
allow a choice of a timebase to use for ts-sandwich need. Updating
the existing API [gettimex64()] is not an option since it would
break compatibility.
About the name - This is a superset of current gettimex64. Since
the timebase for gettimex64 is fixed and is only 'sys-time / real-time'.
I'm appending "any" to add the choice factor. so gettimex64any() would
give you eXtended time with sandwitch TS of a timebase of your choice.
If there is a better name, I won't mind changing.
The timebase options are -
CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW, & RAW_CYCLES
Since the ioctl() returns 'stuct ptp_clock_time *', the RAW_CYCLES are
converted into sec = 10^9 cycles, nsec = remainder-cycles basically
ns_to_timespec64. Caller can convert the value into raw-cycles
by using calculations similar to timespec64_to_ns()
The CLOCK_REALTIME option is equivalent of using current gettimex64()
method.
The first patch adds the ktime_get_cycles64() method to support
RAW-CYCLES option. The other timebases already have supporting
methods available.
The second patch adds this new PTP method while the third patch adds the
ioctl support for this method.
The last patch in the series updates the selftest to exercise this new
method.
Mahesh Bandewar (4):
time: add ktime_get_cycles64() api
ptp: add ptp_gettimex64any() support
ptp: add ioctl interface for ptp_gettimex64any()
selftes/ptp: extend test to include ptp_gettimex64any()
drivers/ptp/ptp_chardev.c | 34 ++++++++++++
include/linux/ptp_clock_kernel.h | 57 +++++++++++++++++++
include/linux/timekeeping.h | 1 +
include/uapi/linux/ptp_clock.h | 22 ++++++++
kernel/time/timekeeping.c | 24 ++++++++
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/ptp/testptp.c | 79 ++++++++++++++++++++++++++-
7 files changed, 216 insertions(+), 2 deletions(-)
--
2.42.0.582.g8ccd20d70d-goog
Powered by blists - more mailing lists