lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250610-feature_phc_source-v1-2-cbd1adef12aa@bootlin.com>
Date: Tue, 10 Jun 2025 14:50:02 +0200
From: Kory Maincent <kory.maincent@...tlin.com>
To: Michal Kubecek <mkubecek@...e.cz>, Eric Dumazet <edumazet@...gle.com>, 
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, 
 Andrew Lunn <andrew@...n.ch>, 
 Willem de Bruijn <willemdebruijn.kernel@...il.com>, 
 Jason Xing <kernelxing@...cent.com>, Russell King <linux@...linux.org.uk>, 
 Maxime Chevallier <maxime.chevallier@...tlin.com>, 
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>, netdev@...r.kernel.org, 
 linux-kernel@...r.kernel.org, Kory Maincent <kory.maincent@...tlin.com>
Subject: [PATCH ethtool 2/2] tsinfo: Add support for PTP hardware source

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@...tlin.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ