Skip to content

Commit

Permalink
net: vlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()
Browse files Browse the repository at this point in the history
8021q is one of the stackable net devices which pass the hardware
timestamping ops to the real device through ndo_eth_ioctl(). This
prevents converting any device driver to the new hwtimestamping API
without regressions.

Remove that limitation in the vlan driver by using the newly introduced
helpers for timestamping through lower devices, that handle both the new
and the old driver API.

Signed-off-by: Maxim Georgiev <glipus@gmail.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230801142824.1772134-4-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Maxim Georgiev authored and Jakub Kicinski committed Aug 3, 2023
1 parent e47d01f commit 65c9fde
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions net/8021q/vlan_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,26 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
return 0;
}

static int vlan_hwtstamp_get(struct net_device *dev,
struct kernel_hwtstamp_config *cfg)
{
struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;

return generic_hwtstamp_get_lower(real_dev, cfg);
}

static int vlan_hwtstamp_set(struct net_device *dev,
struct kernel_hwtstamp_config *cfg,
struct netlink_ext_ack *extack)
{
struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;

if (!net_eq(dev_net(dev), dev_net(real_dev)))
return -EOPNOTSUPP;

return generic_hwtstamp_set_lower(real_dev, cfg, extack);
}

static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
Expand All @@ -365,14 +385,9 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
ifrr.ifr_ifru = ifr->ifr_ifru;

switch (cmd) {
case SIOCSHWTSTAMP:
if (!net_eq(dev_net(dev), dev_net(real_dev)))
break;
fallthrough;
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
case SIOCGHWTSTAMP:
if (netif_device_present(real_dev) && ops->ndo_eth_ioctl)
err = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd);
break;
Expand Down Expand Up @@ -1081,6 +1096,8 @@ static const struct net_device_ops vlan_netdev_ops = {
.ndo_fix_features = vlan_dev_fix_features,
.ndo_get_iflink = vlan_dev_get_iflink,
.ndo_fill_forward_path = vlan_dev_fill_forward_path,
.ndo_hwtstamp_get = vlan_hwtstamp_get,
.ndo_hwtstamp_set = vlan_hwtstamp_set,
};

static void vlan_dev_free(struct net_device *dev)
Expand Down

0 comments on commit 65c9fde

Please sign in to comment.