On Mon, Mar 07, 2022 at 06:54:19PM +0100, Gerhard Engleder wrote:
ktime_to_cycles uses hwtstamp as key for the cache lookup. As long as
the PHC is monotonic, the key is unique. If the time of the PHC is set, then
the cache would be invalidated. I'm afraid that setting the PHC could lead to
wrong or missing timestamps. Setting the PHC in hardware, timestamp
generation in hardware, and cache invalidation in software would need to
be synchronized somehow.
You can avoid errors even with a time jump:
Make a variant (union) of skb_shared_hwtstamps to allow driver to
provide an address or cookie instead of ktime_t. Set a flag in the
skbuff to signal this.
Let the Rx path check the flag and fetch the time stamp by callback
with the address/cookie.
Thanks,
Richard