From: Jacob Keller <jacob.e.keller@intel.com>
To: Milena Olech <milena.olech@intel.com>,
<intel-wired-lan@lists.osuosl.org>
Cc: <netdev@vger.kernel.org>, <anthony.l.nguyen@intel.com>,
<przemyslaw.kitszel@intel.com>, Josh Hay <joshua.a.hay@intel.com>,
"Samuel Salin" <Samuel.salin@intel.com>
Subject: Re: [Intel-wired-lan] [PATCH v10 iwl-next 10/11] idpf: add Tx timestamp flows
Date: Tue, 8 Apr 2025 14:31:02 -0700 [thread overview]
Message-ID: <2fa01052-a090-42e2-8815-1a5fad2939fc@intel.com> (raw)
In-Reply-To: <20250408103240.30287-23-milena.olech@intel.com>
On 4/8/2025 3:31 AM, Milena Olech wrote:
> +/**
> + * idpf_ptp_tstamp_extend_32b_to_64b - Convert a 32b nanoseconds Tx or Rx
> + * timestamp value to 64b.
> + * @cached_phc_time: recently cached copy of PHC time
> + * @in_timestamp: Ingress/egress 32b nanoseconds timestamp value
> + *
> + * Hardware captures timestamps which contain only 32 bits of nominal
> + * nanoseconds, as opposed to the 64bit timestamps that the stack expects.
> + *
> + * Return: Tx timestamp value extended to 64 bits based on cached PHC time.
> + */
> +u64 idpf_ptp_tstamp_extend_32b_to_64b(u64 cached_phc_time, u32 in_timestamp)
> +{
> + s64 delta;
> +
> + delta = in_timestamp - lower_32_bits(cached_phc_time);
> +
> + return cached_phc_time + delta;
> +}
This logic looks quite different from what we did in ice and iavf, which
was based on the math from timecounters. It looks like you do check if
the value is too old which is good to verify. Perhaps I'm just
misunderstanding the math.
For clarity, here's what we have in ice:
> static u64 ice_ptp_extend_32b_ts(u64 cached_phc_time, u32 in_tstamp)
> {
> u32 delta, phc_time_lo;
> u64 ns;
>
> /* Extract the lower 32 bits of the PHC time */
> phc_time_lo = (u32)cached_phc_time;
>
> /* Calculate the delta between the lower 32bits of the cached PHC
> * time and the in_tstamp value
> */
> delta = (in_tstamp - phc_time_lo);
>
> /* Do not assume that the in_tstamp is always more recent than the
> * cached PHC time. If the delta is large, it indicates that the
> * in_tstamp was taken in the past, and should be converted
> * forward.
> */
> if (delta > (U32_MAX / 2)) {
> /* reverse the delta calculation here */
> delta = (phc_time_lo - in_tstamp);
> ns = cached_phc_time - delta;
> } else {
> ns = cached_phc_time + delta;
> }
>
> return ns;
> }
In particular, this ensures that we correctly handle the case where a
timestamp is captured just before an update to the cached PHC time.
Without that check, you can't guarantee that the timestamp is updated
correctly with lockess PHC updating.
With these checks, as long as the timestamp is recent, we can extend it
safely without worrying about whether the cached PHC time we are using
is slightly old or not. (As long as its no more than 2 seconds old).
Could you explain why this was changed for idpf?
Bonus points if we extracted this method into libie/libeth and shared it
across ice, idpf, and iavf, which I believe recently gained support for
timestamping as well.
next prev parent reply other threads:[~2025-04-08 21:31 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 10:30 [Intel-wired-lan] [PATCH v10 iwl-next 00/11] idpf: add initial PTP support Milena Olech
2025-04-08 10:30 ` Milena Olech
2025-04-08 10:30 ` [Intel-wired-lan] [PATCH v10 iwl-next 01/11] idpf: change the method for mailbox workqueue allocation Milena Olech
2025-04-08 10:30 ` Milena Olech
2025-04-08 21:01 ` [Intel-wired-lan] " Jacob Keller
2025-04-08 10:30 ` [Intel-wired-lan] [PATCH v10 iwl-next 02/11] idpf: add initial PTP support Milena Olech
2025-04-08 10:30 ` Milena Olech
2025-04-08 21:02 ` [Intel-wired-lan] " Jacob Keller
2025-04-08 10:30 ` [Intel-wired-lan] [PATCH v10 iwl-next 03/11] virtchnl: add PTP virtchnl definitions Milena Olech
2025-04-08 10:30 ` Milena Olech
2025-04-08 21:12 ` [Intel-wired-lan] " Jacob Keller
2025-04-09 11:51 ` Olech, Milena
2025-04-09 11:51 ` Olech, Milena
2025-04-09 18:11 ` Jacob Keller
2025-04-10 13:18 ` Olech, Milena
2025-04-10 13:18 ` Olech, Milena
2025-04-08 10:30 ` [Intel-wired-lan] [PATCH v10 iwl-next 04/11] idpf: move virtchnl structures to the header file Milena Olech
2025-04-08 10:30 ` Milena Olech
2025-04-08 21:12 ` [Intel-wired-lan] " Jacob Keller
2025-04-08 10:30 ` [Intel-wired-lan] [PATCH v10 iwl-next 05/11] idpf: negotiate PTP capabilities and get PTP clock Milena Olech
2025-04-08 10:30 ` Milena Olech
2025-04-08 21:15 ` [Intel-wired-lan] " Jacob Keller
2025-04-09 12:55 ` Olech, Milena
2025-04-09 12:55 ` Olech, Milena
2025-04-09 18:14 ` Jacob Keller
2025-04-08 10:30 ` [Intel-wired-lan] [PATCH v10 iwl-next 06/11] idpf: add mailbox access to read PTP clock time Milena Olech
2025-04-08 10:30 ` Milena Olech
2025-04-08 21:16 ` [Intel-wired-lan] " Jacob Keller
2025-04-09 13:01 ` Olech, Milena
2025-04-09 13:01 ` Olech, Milena
2025-04-08 21:17 ` Jacob Keller
2025-04-08 10:31 ` [Intel-wired-lan] [PATCH v10 iwl-next 07/11] idpf: add cross timestamping Milena Olech
2025-04-08 10:31 ` Milena Olech
2025-04-08 21:18 ` [Intel-wired-lan] " Jacob Keller
2025-04-08 10:31 ` [Intel-wired-lan] [PATCH v10 iwl-next 08/11] idpf: add PTP clock configuration Milena Olech
2025-04-08 10:31 ` Milena Olech
2025-04-08 21:20 ` [Intel-wired-lan] " Jacob Keller
2025-04-08 10:31 ` [Intel-wired-lan] [PATCH v10 iwl-next 09/11] idpf: add Tx timestamp capabilities negotiation Milena Olech
2025-04-08 10:31 ` Milena Olech
2025-04-08 21:23 ` [Intel-wired-lan] " Jacob Keller
2025-04-09 14:04 ` Olech, Milena
2025-04-09 14:04 ` Olech, Milena
2025-04-09 18:08 ` Jacob Keller
2025-04-10 14:11 ` Olech, Milena
2025-04-10 14:11 ` Olech, Milena
2025-04-10 15:36 ` Keller, Jacob E
2025-04-10 15:36 ` Keller, Jacob E
2025-04-08 10:31 ` [Intel-wired-lan] [PATCH v10 iwl-next 10/11] idpf: add Tx timestamp flows Milena Olech
2025-04-08 10:31 ` Milena Olech
2025-04-08 21:31 ` Jacob Keller [this message]
2025-04-10 13:28 ` [Intel-wired-lan] " Olech, Milena
2025-04-10 13:28 ` Olech, Milena
2025-04-08 10:31 ` [Intel-wired-lan] [PATCH v10 iwl-next 11/11] idpf: add support for Rx timestamping Milena Olech
2025-04-08 10:31 ` Milena Olech
2025-04-08 21:31 ` [Intel-wired-lan] " Jacob Keller
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=2fa01052-a090-42e2-8815-1a5fad2939fc@intel.com \
--to=jacob.e.keller@intel.com \
--cc=Samuel.salin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=joshua.a.hay@intel.com \
--cc=milena.olech@intel.com \
--cc=netdev@vger.kernel.org \
--cc=przemyslaw.kitszel@intel.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.