[PATCH net-next v5 0/3] gve: add support for PTP gettimex64

From: Harshitha Ramamurthy

Date: Tue Apr 28 2026 - 21:29:19 EST


From: Jordan Rhee <jordanrhee@xxxxxxxxxx>

This patch series adds support to obtain near-simultaneous NIC and
system timestamps with gettimex64. This enables daemons like
chrony and phc2sys to synchronize the system clock to the NIC clock.

GVE does not have direct register access to the NIC hardware clock, so
it must issue an AdminQ command to read the NIC clock. Due to relatively
high latency of AQ commands (~100us), it is necessary for the hypervisor
to sample the system time sandwich inside the AQ command.

The first two patches pave the way for the PTP implementation by
quieting excessive logging and refactoring an existing routine for
thread safety.

This table shows a comparison in chrony tracking statistics between
the typical implementation pattern for gettimex64(), which is to call
ptp_read_system_prets() / ptp_read_system_postts(), and the
implementation in this patchset, which is to use the TSC values from
the device. The RMS offset is nearly 4 orders of magnitude smaller in
the chosen implementation.

| | TSC from VM | TSC from device (this patchset) |
| --------------- | --------------------- | ------------------------------- |
| System time | 0.000000005 s slow | 0.000000001 s fast |
| Last offset | +0.000005606 seconds | +0.000000001 seconds |
| RMS offset | 0.000009020 seconds | 0.000000002 seconds |
| Frequency | 4.115 ppm fast | 0.362 ppm fast |
| Residual freq | +2.515 ppm | +0.000 ppm |
| Skew | 18.480 ppm | 0.001 ppm |
| Root delay | 0.000000001 seconds | 0.000000001 seconds |
| Root dispersion | 0.000081905 seconds | 0.000001169 seconds |
| Update interval | 0.5 seconds | 0.5 seconds |
| Leap status | Normal | Normal |


---
Changelog:
V5:
- Reformulate retry loop in terms of total timeout instead of retry
count (Jakub Kicinski)
- Link to v4: https://lore.kernel.org/netdev/20260406234002.3610542-1-hramamurthy@xxxxxxxxxx/

V4:
- Call out change to dev_err_ratelimited() in patch 1 commit message (Jacob Keller)
- Ensure only one log is emitted when command returns GVE_ADMINQ_COMMAND_UNSET (Jacob Keller)
- Link to v3: https://lore.kernel.org/netdev/20260403194427.1830609-1-hramamurthy@xxxxxxxxxx/

V3:
- Take system time snapshot inside the mutex
- Return -EOPNOTSUPP if cross-timestamp is requested on an arch other
than x86 or arm64
- Fix initialization to only register PTP clock once all data is
initialized
- Link to v2: https://lore.kernel.org/netdev/20260326224527.1044097-1-hramamurthy@xxxxxxxxxx/

V2:
- Fixed compilation warning on ARM by casting to u64
- Link to v1: https://lore.kernel.org/netdev/20260323234829.3185051-1-hramamurthy@xxxxxxxxxx/
---

Ankit Garg (1):
gve: make nic clock reads thread safe

Jordan Rhee (2):
gve: skip error logging for retryable AdminQ commands
gve: implement PTP gettimex64

drivers/net/ethernet/google/gve/gve.h | 12 +-
drivers/net/ethernet/google/gve/gve_adminq.c | 27 +-
drivers/net/ethernet/google/gve/gve_adminq.h | 4 +-
drivers/net/ethernet/google/gve/gve_ethtool.c | 3 +-
drivers/net/ethernet/google/gve/gve_ptp.c | 316 +++++++++++++-----
5 files changed, 267 insertions(+), 95 deletions(-)


base-commit: 790ead9394860e7d70c5e0e50a35b243e909a618
--
2.54.0.545.g6539524ca2-goog