Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: add hwtstamp_get callback to phy drivers

PHY devices had lack of hwtstamp_get callback even though most of them
are tracking configuration info. Introduce new call back to
mii_timestamper.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20251124181151.277256-3-vadim.fedorenko@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vadim Fedorenko and committed by
Jakub Kicinski
f467777e 6aac2aa2

+13 -4
+3
drivers/net/phy/phy.c
··· 478 478 if (!phydev) 479 479 return -ENODEV; 480 480 481 + if (phydev->mii_ts && phydev->mii_ts->hwtstamp_get) 482 + return phydev->mii_ts->hwtstamp_get(phydev->mii_ts, config); 483 + 481 484 return -EOPNOTSUPP; 482 485 } 483 486
+5
include/linux/mii_timestamper.h
··· 29 29 * 30 30 * @hwtstamp_set: Handles SIOCSHWTSTAMP ioctl for hardware time stamping. 31 31 * 32 + * @hwtstamp_get: Handles SIOCGHWTSTAMP ioctl for hardware time stamping. 33 + * 32 34 * @link_state: Allows the device to respond to changes in the link 33 35 * state. The caller invokes this function while holding 34 36 * the phy_device mutex. ··· 56 54 int (*hwtstamp_set)(struct mii_timestamper *mii_ts, 57 55 struct kernel_hwtstamp_config *kernel_config, 58 56 struct netlink_ext_ack *extack); 57 + 58 + int (*hwtstamp_get)(struct mii_timestamper *mii_ts, 59 + struct kernel_hwtstamp_config *kernel_config); 59 60 60 61 void (*link_state)(struct mii_timestamper *mii_ts, 61 62 struct phy_device *phydev);
+5 -4
net/core/dev_ioctl.c
··· 249 249 * 250 250 * Helper for calling the default hardware provider timestamping. 251 251 * 252 - * Note: phy_mii_ioctl() only handles SIOCSHWTSTAMP (not SIOCGHWTSTAMP), and 253 - * there only exists a phydev->mii_ts->hwtstamp() method. So this will return 254 - * -EOPNOTSUPP for phylib for now, which is still more accurate than letting 255 - * the netdev handle the GET request. 252 + * Note: phy_mii_ioctl() only handles SIOCSHWTSTAMP (not SIOCGHWTSTAMP), but 253 + * phydev->mii_ts has both hwtstamp_get() and hwtstamp_set() methods. So this 254 + * will return -EOPNOTSUPP for phylib only if hwtstamp_get() is not 255 + * implemented for now, which is still more accurate than letting the netdev 256 + * handle the GET request. 256 257 */ 257 258 int dev_get_hwtstamp_phylib(struct net_device *dev, 258 259 struct kernel_hwtstamp_config *cfg)