Message ID | 20220403175544.26556-3-gerhard@engleder-embedded.com (mailing list archive) |
---|---|
State | Deferred |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ptp: Support hardware clocks with additional free running cycle counter | expand |
On Sun, Apr 03, 2022 at 07:55:41PM +0200, Gerhard Engleder wrote: > The free running cycle counter of physical clocks called cycles shall be > used for hardware timestamps to enable synchronisation. > > Introduce new flag SKBTX_HW_TSTAMP_USE_CYCLES, which signals driver to > provide a TX timestamp based on cycles if cycles are supported. > > Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com> > --- > include/linux/skbuff.h | 3 +++ > net/core/skbuff.c | 2 ++ > net/socket.c | 11 ++++++++++- > 3 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index 3a30cae8b0a5..aeb3ed4d6cf8 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -578,6 +578,9 @@ enum { > /* device driver is going to provide hardware time stamp */ > SKBTX_IN_PROGRESS = 1 << 2, > > + /* generate hardware time stamp based on cycles if supported */ > + SKBTX_HW_TSTAMP_USE_CYCLES = 1 << 3, > + > /* generate wifi status information (where possible) */ > SKBTX_WIFI_STATUS = 1 << 4, > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 10bde7c6db44..c0f8f1341c3f 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -4847,6 +4847,8 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb, > skb_shinfo(skb)->tx_flags |= skb_shinfo(orig_skb)->tx_flags & > SKBTX_ANY_TSTAMP; > skb_shinfo(skb)->tskey = skb_shinfo(orig_skb)->tskey; > + } else { > + skb_shinfo(skb)->tx_flags &= ~SKBTX_HW_TSTAMP_USE_CYCLES; Why is this needed? > } > > if (hwtstamps) Thanks, Richard
> > The free running cycle counter of physical clocks called cycles shall be > > used for hardware timestamps to enable synchronisation. > > > > Introduce new flag SKBTX_HW_TSTAMP_USE_CYCLES, which signals driver to > > provide a TX timestamp based on cycles if cycles are supported. > > > > Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com> > > --- > > include/linux/skbuff.h | 3 +++ > > net/core/skbuff.c | 2 ++ > > net/socket.c | 11 ++++++++++- > > 3 files changed, 15 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > > index 3a30cae8b0a5..aeb3ed4d6cf8 100644 > > --- a/include/linux/skbuff.h > > +++ b/include/linux/skbuff.h > > @@ -578,6 +578,9 @@ enum { > > /* device driver is going to provide hardware time stamp */ > > SKBTX_IN_PROGRESS = 1 << 2, > > > > + /* generate hardware time stamp based on cycles if supported */ > > + SKBTX_HW_TSTAMP_USE_CYCLES = 1 << 3, > > + > > /* generate wifi status information (where possible) */ > > SKBTX_WIFI_STATUS = 1 << 4, > > > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > > index 10bde7c6db44..c0f8f1341c3f 100644 > > --- a/net/core/skbuff.c > > +++ b/net/core/skbuff.c > > @@ -4847,6 +4847,8 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb, > > skb_shinfo(skb)->tx_flags |= skb_shinfo(orig_skb)->tx_flags & > > SKBTX_ANY_TSTAMP; > > skb_shinfo(skb)->tskey = skb_shinfo(orig_skb)->tskey; > > + } else { > > + skb_shinfo(skb)->tx_flags &= ~SKBTX_HW_TSTAMP_USE_CYCLES; > > Why is this needed? It prevents that SKBTX_HW_TSTAMP_USE_CYCLES is set due to the call of skb_clone(), when the timestamp is delivered back to the socket. It lowers the flag usage, but it is not absolutely needed. I could remove that code. Thank you! Gerhard
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 3a30cae8b0a5..aeb3ed4d6cf8 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -578,6 +578,9 @@ enum { /* device driver is going to provide hardware time stamp */ SKBTX_IN_PROGRESS = 1 << 2, + /* generate hardware time stamp based on cycles if supported */ + SKBTX_HW_TSTAMP_USE_CYCLES = 1 << 3, + /* generate wifi status information (where possible) */ SKBTX_WIFI_STATUS = 1 << 4, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 10bde7c6db44..c0f8f1341c3f 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4847,6 +4847,8 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb, skb_shinfo(skb)->tx_flags |= skb_shinfo(orig_skb)->tx_flags & SKBTX_ANY_TSTAMP; skb_shinfo(skb)->tskey = skb_shinfo(orig_skb)->tskey; + } else { + skb_shinfo(skb)->tx_flags &= ~SKBTX_HW_TSTAMP_USE_CYCLES; } if (hwtstamps) diff --git a/net/socket.c b/net/socket.c index 6887840682bb..03911a3d8b33 100644 --- a/net/socket.c +++ b/net/socket.c @@ -683,9 +683,18 @@ void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags) { u8 flags = *tx_flags; - if (tsflags & SOF_TIMESTAMPING_TX_HARDWARE) + if (tsflags & SOF_TIMESTAMPING_TX_HARDWARE) { flags |= SKBTX_HW_TSTAMP; + /* PTP hardware clocks can provide a free running cycle counter + * as a time base for virtual clocks. Tell driver to use the + * free running cycle counter for timestamp if socket is bound + * to virtual clock. + */ + if (tsflags & SOF_TIMESTAMPING_BIND_PHC) + flags |= SKBTX_HW_TSTAMP_USE_CYCLES; + } + if (tsflags & SOF_TIMESTAMPING_TX_SOFTWARE) flags |= SKBTX_SW_TSTAMP;
The free running cycle counter of physical clocks called cycles shall be used for hardware timestamps to enable synchronisation. Introduce new flag SKBTX_HW_TSTAMP_USE_CYCLES, which signals driver to provide a TX timestamp based on cycles if cycles are supported. Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com> --- include/linux/skbuff.h | 3 +++ net/core/skbuff.c | 2 ++ net/socket.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-)