OSDN Git Service

net: add hwtstamping helpers for stackable net devices
authorMaxim Georgiev <glipus@gmail.com>
Tue, 1 Aug 2023 14:28:14 +0000 (17:28 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 3 Aug 2023 02:11:05 +0000 (19:11 -0700)
commite47d01fea663b1fe58d0a493efc9ed667f70242e
tree9d115be60517a47b19211f774c71e1e48a805125
parent66f7223039c0cef81221e9779520479895995815
net: add hwtstamping helpers for stackable net devices

The stackable net devices with hwtstamping support (vlan, macvlan,
bonding) only pass the hwtstamping ops to the lower (real) device.

These drivers are the first that need to be converted to the new
timestamping API, because if they aren't prepared to handle that,
then no real device driver cannot be converted to the new API either.

After studying what vlan_dev_ioctl(), macvlan_eth_ioctl() and
bond_eth_ioctl() have in common, here we propose two generic
implementations of ndo_hwtstamp_get() and ndo_hwtstamp_set() which
can be called by those 3 drivers, with "dev" being their lower device.

These helpers cover both cases, when the lower driver is converted to
the new API or unconverted.

We need some hacks in case of an unconverted driver, namely to stuff
some pointers in struct kernel_hwtstamp_config which shouldn't have
been there (since the new API isn't supposed to need it). These will
be removed when all drivers will have been converted to the new 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-3-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/net_tstamp.h
include/linux/netdevice.h
net/core/dev_ioctl.c