All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Jakub Kicinski <kuba@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	"Mark Bloch" <mbloch@nvidia.com>, <netdev@vger.kernel.org>,
	<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Carolina Jubran <cjubran@nvidia.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: Re: [PATCH net-next 0/3] Support exposing raw cycle counters in PTP and mlx5
Date: Tue, 29 Jul 2025 16:33:28 -0700	[thread overview]
Message-ID: <86471b96-fb30-450f-9934-ec76851791ea@intel.com> (raw)
In-Reply-To: <20250718162945.0c170473@kernel.org>


[-- Attachment #1.1: Type: text/plain, Size: 3097 bytes --]



On 7/18/2025 4:29 PM, Jakub Kicinski wrote:
> On Tue, 15 Jul 2025 08:15:30 +0300 Tariq Toukan wrote:
>> This patch series introduces support for exposing the raw free-running
>> cycle counter of PTP hardware clocks. Some telemetry and low-level
>> logging use cycle counter timestamps rather than nanoseconds.
>> Currently, there is no generic interface to correlate these raw values
>> with system time.
>>
>> To address this, the series introduces two new ioctl commands that
>> allow userspace to query the device's raw cycle counter together with
>> host time:
>>
>>  - PTP_SYS_OFFSET_PRECISE_CYCLES
>>
>>  - PTP_SYS_OFFSET_EXTENDED_CYCLES
>>
>> These commands work like their existing counterparts but return the
>> device timestamp in cycle units instead of real-time nanoseconds.
>>
>> This can also be useful in the XDP fast path: if a driver inserts the
>> raw cycle value into metadata instead of a real-time timestamp, it can
>> avoid the overhead of converting cycles to time in the kernel. Then
>> userspace can resolve the cycle-to-time mapping using this ioctl when
>> needed.
>>
>> Adds the new PTP ioctls and integrates support in ptp_ioctl():
>> - ptp: Add ioctl commands to expose raw cycle counter values
>>
>> Support for exposing raw cycles in mlx5:
>> - net/mlx5: Extract MTCTR register read logic into helper function
>> - net/mlx5: Support getcyclesx and getcrosscycles
> 
> It'd be great to an Ack from Thomas or Richard on this (or failing that
> at least other vendors?) Seems like we have a number of parallel
> efforts to extend the PTP uAPI, I'm not sure how they all square
> against each other, TBH.
> 
> Full thread for folks I CCed in:
> https://lore.kernel.org/all/1752556533-39218-1-git-send-email-tariqt@nvidia.com/
> 

I agree with Jakub about the need to properly explain the use cases and
goals in the commit and cover letter. AFAIK there are no current public
APIs for reporting cycles to userspace, so this really only makes sense
with something like DPDK. Even the XDP related helpers expect nanosecond
units now. Its unclear if we will need other parts of the APIs to also
handle cycles, or if simple ability to get the current cycles is sufficient.

The API also doesn't directly provide a way to query the expected or
nominal relationship between cycles and clock time.

If you try to just use PTP_SYS_OFFSET_EXTENDED_CYCLES to compare a
cycles value to a clock value to adjust a timestamp, that requires that
some other process is keeping CLOCK_REALTIME and the PHC clock
synchronized. When handled within the driver, the software typically has
an assumption about the relationship based on expected frequencies.
Thus, a conversion from cycles to time uses this relationship.

You don't appear to expose that relationship through the API, which
means you can only infer it either by knowing the device, or by assuming
CLOCK_REALTIME is already synchronized with the PHC?

I guess userspace could also simply build its own equivalent of the
struct timecounter using this API.. hmm.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  parent reply	other threads:[~2025-07-29 23:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-15  5:15 [PATCH net-next 0/3] Support exposing raw cycle counters in PTP and mlx5 Tariq Toukan
2025-07-15  5:15 ` [PATCH net-next 1/3] ptp: Add ioctl commands to expose raw cycle counter values Tariq Toukan
2025-07-15  5:15 ` [PATCH net-next 2/3] net/mlx5: Extract MTCTR register read logic into helper function Tariq Toukan
2025-07-15  5:15 ` [PATCH net-next 3/3] net/mlx5: Support getcyclesx and getcrosscycles Tariq Toukan
2025-07-17 10:55   ` Paolo Abeni
2025-07-17 15:56     ` Carolina Jubran
2025-07-18  9:09       ` Paolo Abeni
2025-07-18 23:29 ` [PATCH net-next 0/3] Support exposing raw cycle counters in PTP and mlx5 Jakub Kicinski
2025-07-21 17:14   ` Thomas Gleixner
2025-07-29 23:33   ` Jacob Keller [this message]
2025-07-31 19:05     ` Carolina Jubran
2025-07-22  0:09 ` Jakub Kicinski
2025-07-29  6:57   ` Carolina Jubran
2025-07-29 22:40     ` Jakub Kicinski
2025-07-31 19:03       ` Carolina Jubran
2025-08-01 20:23         ` Jakub Kicinski

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=86471b96-fb30-450f-9934-ec76851791ea@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=cjubran@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=tglx@linutronix.de \
    --cc=vladimir.oltean@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.