From: Kory Maincent <kory.maincent@bootlin.com>
To: Michal Kubecek <mkubecek@suse.cz>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Andrew Lunn <andrew@lunn.ch>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Jason Xing <kernelxing@tencent.com>,
Russell King <linux@armlinux.org.uk>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Kory Maincent <kory.maincent@bootlin.com>
Subject: [PATCH ethtool 2/2] tsinfo: Add support for PTP hardware source
Date: Tue, 10 Jun 2025 14:50:02 +0200 [thread overview]
Message-ID: <20250610-feature_phc_source-v1-2-cbd1adef12aa@bootlin.com> (raw)
In-Reply-To: <20250610-feature_phc_source-v1-0-cbd1adef12aa@bootlin.com>
Add description of the PTP hardware source to indicate whether the
timestamp comes from a PHY or a MAC.
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
netlink/tsinfo.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/netlink/tsinfo.c b/netlink/tsinfo.c
index 187c3ad..fd528e5 100644
--- a/netlink/tsinfo.c
+++ b/netlink/tsinfo.c
@@ -52,6 +52,37 @@ int tsinfo_show_hwprov(const struct nlattr *nest)
return 0;
}
+const char *tsinfo_source_names(u32 val)
+{
+ switch (val) {
+ case HWTSTAMP_SOURCE_NETDEV:
+ return "MAC";
+ case HWTSTAMP_SOURCE_PHYLIB:
+ return "PHY";
+ default:
+ return "Unknown";
+ }
+}
+
+int tsinfo_show_source(const struct nlattr **tb)
+{
+ u32 val;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_TSINFO_HWTSTAMP_SOURCE]);
+ print_string(PRINT_ANY, "hwtstamp-source:",
+ "Hardware timestamp source: %s\n",
+ tsinfo_source_names(val));
+
+ if (!tb[ETHTOOL_A_TSINFO_HWTSTAMP_PHYINDEX])
+ return 0;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_TSINFO_HWTSTAMP_PHYINDEX]);
+ print_uint(PRINT_ANY, "hwtstamp-source-phyindex:",
+ "Hardware timestamp source PHY index: %d\n", val);
+
+ return 0;
+}
+
static int tsinfo_show_stats(const struct nlattr *nest)
{
const struct nlattr *tb[ETHTOOL_A_TS_STAT_MAX + 1] = {};
@@ -185,6 +216,9 @@ int tsinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data)
printf("none\n");
}
+ if (tb[ETHTOOL_A_TSINFO_HWTSTAMP_SOURCE])
+ tsinfo_show_source(tb);
+
ret = tsinfo_dump_list(nlctx, tb[ETHTOOL_A_TSINFO_TX_TYPES],
"Hardware Transmit Timestamp Modes", " none",
ETH_SS_TS_TX_TYPES);
--
2.43.0
prev parent reply other threads:[~2025-06-10 12:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 12:50 [PATCH ethtool 0/2] Add support for PTP hardware source Kory Maincent
2025-06-10 12:50 ` [PATCH ethtool 1/2] update UAPI header copies Kory Maincent
2025-06-10 12:50 ` Kory Maincent [this message]
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=20250610-feature_phc_source-v1-2-cbd1adef12aa@bootlin.com \
--to=kory.maincent@bootlin.com \
--cc=andrew@lunn.ch \
--cc=edumazet@google.com \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=willemdebruijn.kernel@gmail.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).