From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: richardcochran@gmail.com, vinicius.gomes@intel.com,
yangbo.lu@nxp.com, davem@davemloft.net, kuba@kernel.org
Cc: mlichvar@redhat.com, netdev@vger.kernel.org,
Gerhard Engleder <gerhard@engleder-embedded.com>
Subject: [PATCH net-next v2 2/5] ptp: Request cycles for TX timestamp
Date: Sun, 3 Apr 2022 19:55:41 +0200 [thread overview]
Message-ID: <20220403175544.26556-3-gerhard@engleder-embedded.com> (raw)
In-Reply-To: <20220403175544.26556-1-gerhard@engleder-embedded.com>
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;
}
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;
--
2.20.1
next prev parent reply other threads:[~2022-04-03 17:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-03 17:55 [PATCH net-next v2 0/5] ptp: Support hardware clocks with additional free running cycle counter Gerhard Engleder
2022-04-03 17:55 ` [PATCH net-next v2 1/5] ptp: Add cycles support for virtual clocks Gerhard Engleder
2022-04-10 6:26 ` Richard Cochran
2022-04-10 12:32 ` Gerhard Engleder
2022-04-03 17:55 ` Gerhard Engleder [this message]
2022-04-10 6:47 ` [PATCH net-next v2 2/5] ptp: Request cycles for TX timestamp Richard Cochran
2022-04-10 12:40 ` Gerhard Engleder
2022-04-03 17:55 ` [PATCH net-next v2 3/5] ptp: Pass hwtstamp to ptp_convert_timestamp() Gerhard Engleder
2022-04-03 17:55 ` [PATCH net-next v2 4/5] ptp: Support late timestamp determination Gerhard Engleder
2022-04-10 7:29 ` Richard Cochran
2022-04-10 12:54 ` Gerhard Engleder
2022-04-10 13:42 ` Richard Cochran
2022-04-10 14:42 ` Gerhard Engleder
2022-04-12 19:24 ` Gerhard Engleder
2022-04-12 21:05 ` Vinicius Costa Gomes
2022-04-13 20:28 ` Gerhard Engleder
2022-04-12 21:46 ` Richard Cochran
2022-04-13 20:51 ` Gerhard Engleder
2022-04-14 6:36 ` Richard Cochran
2022-04-15 22:04 ` Gerhard Engleder
2022-04-16 16:58 ` Richard Cochran
2022-04-03 17:55 ` [PATCH net-next v2 5/5] tsnep: Add free running cycle counter support Gerhard Engleder
2022-04-06 23:04 ` [PATCH net-next v2 0/5] ptp: Support hardware clocks with additional free running cycle counter Richard Cochran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220403175544.26556-3-gerhard@engleder-embedded.com \
--to=gerhard@engleder-embedded.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=mlichvar@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=vinicius.gomes@intel.com \
--cc=yangbo.lu@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).