public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Harshitha Ramamurthy <hramamurthy@google.com>
To: netdev@vger.kernel.org
Cc: joshwash@google.com, hramamurthy@google.com,
	andrew+netdev@lunn.ch,  davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com,  richardcochran@gmail.com,
	jstultz@google.com, tglx@kernel.org,  sboyd@kernel.org,
	willemb@google.com, nktgrg@google.com, jfraker@google.com,
	 ziweixiao@google.com, maolson@google.com, jordanrhee@google.com,
	 thostet@google.com, alok.a.tiwari@oracle.com,
	pkaligineedi@google.com,  horms@kernel.org, dwmw2@infradead.org,
	jacob.e.keller@intel.com,  yyd@google.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next v5 0/3] gve: add support for PTP gettimex64
Date: Wed, 29 Apr 2026 01:28:16 +0000	[thread overview]
Message-ID: <20260429012819.3102675-1-hramamurthy@google.com> (raw)

From: Jordan Rhee <jordanrhee@google.com>

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@google.com/

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@google.com/

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@google.com/

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

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


             reply	other threads:[~2026-04-29  1:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29  1:28 Harshitha Ramamurthy [this message]
2026-04-29  1:28 ` [PATCH net-next v5 1/3] gve: skip error logging for retryable AdminQ commands Harshitha Ramamurthy
2026-04-29  1:28 ` [PATCH net-next v5 2/3] gve: make nic clock reads thread safe Harshitha Ramamurthy
2026-05-05 21:38   ` Jordan Rhee
2026-04-29  1:28 ` [PATCH net-next v5 3/3] gve: implement PTP gettimex64 Harshitha Ramamurthy
2026-05-05  8:08   ` Paolo Abeni
2026-05-05 18:22     ` Jordan Rhee
2026-05-05 18:53       ` Jordan Rhee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260429012819.3102675-1-hramamurthy@google.com \
    --to=hramamurthy@google.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dwmw2@infradead.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jfraker@google.com \
    --cc=jordanrhee@google.com \
    --cc=joshwash@google.com \
    --cc=jstultz@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maolson@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=nktgrg@google.com \
    --cc=pabeni@redhat.com \
    --cc=pkaligineedi@google.com \
    --cc=richardcochran@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@kernel.org \
    --cc=thostet@google.com \
    --cc=willemb@google.com \
    --cc=yyd@google.com \
    --cc=ziweixiao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox