diff mbox series

[RFC,net-next,4/6] ptp: Support time stamps based on free running time

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

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5978 this patch: 5978
netdev/cc_maintainers warning 2 maintainers not CCed: keescook@chromium.org imagedong@tencent.com
netdev/build_clang success Errors and warnings before: 878 this patch: 878
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6129 this patch: 6129
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Gerhard Engleder March 6, 2022, 8:56 a.m. UTC
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(-)

Comments

Richard Cochran March 6, 2022, 4:42 p.m. UTC | #1
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 mbox series

Patch

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 */