mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 19:16:02 +02:00
net: don't require the hwtstamp NDOs when a PHY provides timestamping
Removing the legacy ioctl fallback made both hwtstamp NDOs mandatory. A
device that only timestamps in its PHY implements neither, so
SIOCSHWTSTAMP fails with EOPNOTSUPP before anything looks at the PHY and
PTP stops working there.
The check only ever picked the legacy path. That path is gone, so drop it
and test where the NDOs are actually called.
SIOCGHWTSTAMP is new here, not restored. The old path went through
phy_mii_ioctl(), which only handled SIOCSHWTSTAMP.
Such a device now returns -ENODEV while absent instead of -EOPNOTSUPP,
like the ones that do implement the NDOs.
Fixes: 5062245a5a ("net: remove legacy way to get/set HW timestamp config")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://patch.msgid.link/20260918095540.34286-1-nb@tipi-net.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
0346ec2f08
commit
3199557121
|
|
@ -276,19 +276,18 @@ int dev_get_hwtstamp_phylib(struct net_device *dev,
|
|||
if (phy_is_default_hwtstamp(dev->phydev))
|
||||
return phy_hwtstamp_get(dev->phydev, cfg);
|
||||
|
||||
if (!dev->netdev_ops->ndo_hwtstamp_get)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return dev->netdev_ops->ndo_hwtstamp_get(dev, cfg);
|
||||
}
|
||||
|
||||
static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
struct kernel_hwtstamp_config kernel_cfg = {};
|
||||
struct hwtstamp_config cfg;
|
||||
int err;
|
||||
|
||||
if (!ops->ndo_hwtstamp_get)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (!netif_device_present(dev))
|
||||
return -ENODEV;
|
||||
|
||||
|
|
@ -359,12 +358,18 @@ int dev_set_hwtstamp_phylib(struct net_device *dev,
|
|||
cfg->source = phy_ts ? HWTSTAMP_SOURCE_PHYLIB : HWTSTAMP_SOURCE_NETDEV;
|
||||
|
||||
if (phy_ts && dev->see_all_hwtstamp_requests) {
|
||||
if (!ops->ndo_hwtstamp_get)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
err = ops->ndo_hwtstamp_get(dev, &old_cfg);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!phy_ts || dev->see_all_hwtstamp_requests) {
|
||||
if (!ops->ndo_hwtstamp_set)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
err = ops->ndo_hwtstamp_set(dev, cfg, extack);
|
||||
if (err) {
|
||||
if (extack->_msg)
|
||||
|
|
@ -390,7 +395,6 @@ int dev_set_hwtstamp_phylib(struct net_device *dev,
|
|||
|
||||
static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
struct kernel_hwtstamp_config kernel_cfg = {};
|
||||
struct netlink_ext_ack extack = {};
|
||||
struct hwtstamp_config cfg;
|
||||
|
|
@ -413,9 +417,6 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)
|
|||
return err;
|
||||
}
|
||||
|
||||
if (!ops->ndo_hwtstamp_set)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (!netif_device_present(dev))
|
||||
return -ENODEV;
|
||||
|
||||
|
|
@ -441,15 +442,11 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)
|
|||
int generic_hwtstamp_get_lower(struct net_device *dev,
|
||||
struct kernel_hwtstamp_config *kernel_cfg)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
int err;
|
||||
|
||||
if (!netif_device_present(dev))
|
||||
return -ENODEV;
|
||||
|
||||
if (!ops->ndo_hwtstamp_get)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
netdev_lock_ops(dev);
|
||||
err = dev_get_hwtstamp_phylib(dev, kernel_cfg);
|
||||
netdev_unlock_ops(dev);
|
||||
|
|
@ -462,15 +459,11 @@ int generic_hwtstamp_set_lower(struct net_device *dev,
|
|||
struct kernel_hwtstamp_config *kernel_cfg,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
int err;
|
||||
|
||||
if (!netif_device_present(dev))
|
||||
return -ENODEV;
|
||||
|
||||
if (!ops->ndo_hwtstamp_set)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
netdev_lock_ops(dev);
|
||||
err = dev_set_hwtstamp_phylib(dev, kernel_cfg, extack);
|
||||
netdev_unlock_ops(dev);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user