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] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRXIuckumra-3Y0L@shell.armlinux.org.uk>
Date: Thu, 13 Nov 2025 12:02:01 +0000
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
Cc: Andrew Lunn <andrew+netdev@...n.ch>,
	Florian Fainelli <florian.fainelli@...adcom.com>,
	Heiner Kallweit <hkallweit1@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Andrei Botila <andrei.botila@....nxp.com>,
	Richard Cochran <richardcochran@...il.com>,
	Andrew Lunn <andrew@...n.ch>, Simon Horman <horms@...nel.org>,
	Vladimir Oltean <vladimir.oltean@....com>,
	Jacob Keller <jacob.e.keller@...el.com>,
	Kory Maincent <kory.maincent@...tlin.com>,
	bcm-kernel-feedback-list@...adcom.com, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 2/9] phy: add hwtstamp_get callback to phy
 drivers

On Thu, Nov 13, 2025 at 11:32:00AM +0000, Vadim Fedorenko wrote:
> PHY devices had lack of hwtstamp_get callback even though most of them
> are tracking configuration info. Introduce new call back to
> mii_timestamper.
> 
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@...ux.dev>

As part of my Marvell PTP work, I have a similar patch, but it's
way simpler. Is this not sufficient?

__phy_hwtstamp_get() is called via phylib_stubs struct and
phy_hwtstamp_get(), dev_get_hwtstamp_phylib(), dev_get_hwtstamp(),
and dev_ifsioc().

Using the phylib ioctl handler means we're implementing a path that
is already marked as legacy - see dev_get_hwtstamp():

        if (!ops->ndo_hwtstamp_get)
                return dev_eth_ioctl(dev, ifr, SIOCGHWTSTAMP); /* legacy */

So, I think the below would be the preferred implementation.

8<===
From: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
Subject: [PATCH net-next] net: phy: add hwtstamp_get() method for mii
 timestampers

Add the missing hwtstamp_get() method for mii timestampers so PHYs can
report their configuration back to userspace.

Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
---
 drivers/net/phy/phy.c           | 3 +++
 include/linux/mii_timestamper.h | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 02da4a203ddd..b6fae9299b36 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -476,6 +476,9 @@ int __phy_hwtstamp_get(struct phy_device *phydev,
 	if (!phydev)
 		return -ENODEV;
 
+	if (phydev->mii_ts && phydev->mii_ts->hwtstamp_get)
+		return phydev->mii_ts->hwtstamp_get(phydev->mii_ts, config);
+
 	return -EOPNOTSUPP;
 }
 
diff --git a/include/linux/mii_timestamper.h b/include/linux/mii_timestamper.h
index 995db62570f9..b6485f602eb9 100644
--- a/include/linux/mii_timestamper.h
+++ b/include/linux/mii_timestamper.h
@@ -29,6 +29,8 @@ struct phy_device;
  *
  * @hwtstamp:	Handles SIOCSHWTSTAMP ioctl for hardware time stamping.
  *
+ * @hwtstamp_get: Handles SIOCGHWTSTAMP ioctl for hardware time stamping.
+ *
  * @link_state: Allows the device to respond to changes in the link
  *		state.  The caller invokes this function while holding
  *		the phy_device mutex.
@@ -55,6 +57,9 @@ struct mii_timestamper {
 			 struct kernel_hwtstamp_config *kernel_config,
 			 struct netlink_ext_ack *extack);
 
+	int  (*hwtstamp_get)(struct mii_timestamper *mii_ts,
+			     struct kernel_hwtstamp_config *kernel_config);
+
 	void (*link_state)(struct mii_timestamper *mii_ts,
 			   struct phy_device *phydev);
 
-- 
2.47.3

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ