iavf_ptp_ex...2b_timestamp(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

iavf_ptp_extend_32b_timestamp β€” Convert a 32b nanoseconds timestamp to 64b nanoseconds.

okay bestie, quick vibe check: we're in the Kernel API Manual, and this page is all about taking a teeny-tiny 32-bit nanoseconds timestamp and extending it into the 64-bit one the stack expects. ✨

✨ SYNOPSIS ✨

u64 iavf_ptp_extend_32b_timestamp (u64 cached_phc_time , u32 in_tstamp
);

πŸŽ€ ARGUMENTS πŸŽ€

  • cached_phc_time β€” recently cached copy of PHC time
  • in_tstamp β€” Ingress/egress 32b nanoseconds timestamp value

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the situation, bestie: hardware captures timestamps that contain only 32 bits of nominal nanoseconds, as opposed to the 64bit timestamps that the stack expects. 😭

To extend the 32bit nanosecond timestamp, we use this algorithm and these assumptions:

  1. Have a recently cached copy of the PHC time.
  2. Assume that the in_tstamp was captured 2^31 nanoseconds (~2.1 seconds) before or after the PHC time was captured.
  3. Calculate the delta between the cached time and the timestamp.
  4. If the delta is smaller than 2^31 nanoseconds, then the timestamp was captured after the PHC time. In this case, the full timestamp is just the cached PHC time plus the delta.
  5. Otherwise, if the delta is larger than 2^31 nanoseconds, then the timestamp was captured before the PHC time, i.e. because the PHC cache was updated after the timestamp was captured by hardware. In this case, the full timestamp is the cached time minus the inverse delta.

This algorithm works even if the PHC time was updated after a Tx timestamp was requested, but before the Tx timestamp event was reported from hardware. πŸ”₯

This calculation primarily relies on keeping the cached PHC time up to date. If the timestamp was captured more than 2^31 nanoseconds after the PHC time, it is possible that the lower 32bits of PHC time have overflowed more than once, and we might generate an incorrect timestamp. ⚠️

This is prevented by (a) periodically updating the cached PHC time once a second, and (b) discarding any Tx timestamp packet if it has waited for a timestamp for more than one second. 🫢

🌸 RETURN 🌸

extended timestamp (to 64b). πŸ’…

🌈 SEE ALSO 🌈

Kernel file ./drivers/net/ethernet/intel/iavf/iavf_ptp.c


That's the whole page, bestie. Source/version is ./drivers/net/ethernet/intel/iavf, and the date is October 2026 β€” go forth and extend those timestamps, periodt. πŸ’–

πŸ“¦ where this page comes from