Message ID | 20220306085658.1943-5-gerhard@engleder-embedded.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ptp: Support hardware clocks with additional free running time | expand |
On Sun, Mar 06, 2022 at 09:56:56AM +0100, Gerhard Engleder wrote: > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index 2be263184d1e..2ec8d944a557 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -521,6 +521,8 @@ static inline bool skb_frag_must_loop(struct page *p) > * struct skb_shared_hwtstamps - hardware time stamps > * @hwtstamp: hardware time stamp transformed into duration > * since arbitrary point in time > + * @hwfreeruntstamp: hardware time stamp based on free running time > + * transformed into duration since arbitrary point in time > * > * Software time stamps generated by ktime_get_real() are stored in > * skb->tstamp. > @@ -533,6 +535,7 @@ static inline bool skb_frag_must_loop(struct page *p) > */ > struct skb_shared_hwtstamps { > ktime_t hwtstamp; > + ktime_t hwfreeruntstamp; You are adding eight bytes per frame for what is arguably an extreme niche case. I personally wouldn't mind, but expect push back from the rest of the world! Maybe this should hide behind a Kconfig option with default off. @davem, @kuba, what do you think? > }; > > /* Definitions for tx_flags in struct skb_shared_info */ > -- > 2.20.1 > Thanks, Richard
diff --git a/drivers/ptp/ptp_vclock.c b/drivers/ptp/ptp_vclock.c index 3715d75ee8bd..84f798a11bca 100644 --- a/drivers/ptp/ptp_vclock.c +++ b/drivers/ptp/ptp_vclock.c @@ -268,7 +268,10 @@ ktime_t ptp_convert_timestamp(const struct skb_shared_hwtstamps *hwtstamps, vclock = info_to_vclock(ptp->info); - ns = ktime_to_ns(hwtstamps->hwtstamp); + if (vclock->pclock->info->getfreeruntimex64) + ns = ktime_to_ns(hwtstamps->hwfreeruntstamp); + else + ns = ktime_to_ns(hwtstamps->hwtstamp); spin_lock_irqsave(&vclock->lock, flags); ns = timecounter_cyc2time(&vclock->tc, ns); diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 2be263184d1e..2ec8d944a557 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -521,6 +521,8 @@ static inline bool skb_frag_must_loop(struct page *p) * struct skb_shared_hwtstamps - hardware time stamps * @hwtstamp: hardware time stamp transformed into duration * since arbitrary point in time + * @hwfreeruntstamp: hardware time stamp based on free running time + * transformed into duration since arbitrary point in time * * Software time stamps generated by ktime_get_real() are stored in * skb->tstamp. @@ -533,6 +535,7 @@ static inline bool skb_frag_must_loop(struct page *p) */ struct skb_shared_hwtstamps { ktime_t hwtstamp; + ktime_t hwfreeruntstamp; }; /* Definitions for tx_flags in struct skb_shared_info */
Physical clocks are used for hardware time stamping. Also ptp vclocks support hardware time stamps. If a physical clock additionally supports a free running time and this time is used as base for ptp vclocks, then also hardware time stamps based on that free running time are required. Add hardware time stamp of additional free running time to skb_shared_hwtstamps and use it if physical clock supports an additional free running time. Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com> --- drivers/ptp/ptp_vclock.c | 5 ++++- include/linux/skbuff.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-)