Skip to content

Commit 4e98346

Browse files
Vadim Fedorenkopopcornmix
authored andcommitted
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> (cherry picked from commit f467777)
1 parent c9778b2 commit 4e98346

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

drivers/net/phy/phy.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ int __phy_hwtstamp_get(struct phy_device *phydev,
476476
if (!phydev)
477477
return -ENODEV;
478478

479+
if (phydev->mii_ts && phydev->mii_ts->hwtstamp_get)
480+
return phydev->mii_ts->hwtstamp_get(phydev->mii_ts, config);
481+
479482
return -EOPNOTSUPP;
480483
}
481484

include/linux/mii_timestamper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct phy_device;
2929
*
3030
* @hwtstamp: Handles SIOCSHWTSTAMP ioctl for hardware time stamping.
3131
*
32+
* @hwtstamp_get: Handles SIOCGHWTSTAMP ioctl for hardware time stamping.
33+
*
3234
* @link_state: Allows the device to respond to changes in the link
3335
* state. The caller invokes this function while holding
3436
* the phy_device mutex.
@@ -55,6 +57,9 @@ struct mii_timestamper {
5557
struct kernel_hwtstamp_config *kernel_config,
5658
struct netlink_ext_ack *extack);
5759

60+
int (*hwtstamp_get)(struct mii_timestamper *mii_ts,
61+
struct kernel_hwtstamp_config *kernel_config);
62+
5863
void (*link_state)(struct mii_timestamper *mii_ts,
5964
struct phy_device *phydev);
6065

net/core/dev_ioctl.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ int net_hwtstamp_validate(const struct kernel_hwtstamp_config *cfg)
249249
*
250250
* Helper for calling the default hardware provider timestamping.
251251
*
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.
256257
*/
257258
int dev_get_hwtstamp_phylib(struct net_device *dev,
258259
struct kernel_hwtstamp_config *cfg)

0 commit comments

Comments
 (0)