net: Expose available time stamping layers to user space.
Subsystems (3)
RFC PATCH 2/4 net: Expose available time stamping layers to user space.
Time stamping on network packets may happen either in the MAC or in the PHY, but not both. In preparation for making the choice selectable, expose both the current and available layers via sysfs.
In accordance with the kernel implementation as it stands, the current layer will always read as "phy" when a PHY time stamping device is present. Future patches will allow changing the current layer administratively.
--- .../ABI/testing/sysfs-class-net-timestamping | 17 ++++++ drivers/net/phy/phy_device.c | 2 + include/linux/netdevice.h | 10 ++++ net/core/net-sysfs.c | 60 +++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-net-timestamping
Documentation/ABI/testing/sysfs-class-net-timestamping new file +17 -0
@@ -0,0 +1,17 @@ +What: /sys/class/net/<iface>/available_timestamping_providers +Date: January 2022 +Contact: Richard Cochran <[email protected]> +Description: + Enumerates the available providers for SO_TIMESTAMPING. + The possible values are: + - "mac" The MAC provides time stamping. + - "phy" The PHY or MII device provides time stamping. + +What: /sys/class/net/<iface>/current_timestamping_provider +Date: January 2022 +Contact: Richard Cochran <[email protected]> +Description: + Show the current SO_TIMESTAMPING provider. + The possible values are: + - "mac" The MAC provides time stamping. + - "phy" The PHY or MII device provides time stamping.
drivers/net/phy/phy_device.c +2 -0
@@ -1415,6 +1415,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, phydev->phy_link_change = phy_link_change;if (dev) { + dev->selected_timestamping_layer =PHY_TIMESTAMPING ; phydev->attached_dev = dev; dev->phydev = phydev;
@@ -1727,6 +1728,7 @@ void phy_detach(struct phy_device *phydev)phy_suspend (phydev);if (dev) { + dev->selected_timestamping_layer =MAC_TIMESTAMPING ; phydev->attached_dev->phydev =NULL ; phydev->attached_dev =NULL ; }
include/linux/netdevice.h +10 -0
@@ -1687,6 +1687,11 @@ enum netdev_ml_priv_type { ML_PRIV_CAN, }; +enum timestamping_layer { +MAC_TIMESTAMPING , +PHY_TIMESTAMPING , +}; +/** * struct net_device - The DEVICE structure. *
@@ -1927,6 +1932,9 @@ enum netdev_ml_priv_type {* * @threaded: napi threaded mode is enabled * +* @selected_timestamping_layer: Tracks whether the MAC or the PHY +* performs packet time stamping. +* * @net_notifier_list: List of per-net netdev notifier block * that follow this device when it is moved * to another network namespace.
@@ -2263,6 +2271,8 @@ struct net_device { unsigned wol_enabled:1; unsigned threaded:1; +enum timestamping_layer selected_timestamping_layer; +struct list_head net_notifier_list;#if IS_ENABLED (CONFIG_MACSEC )
net/core/net-sysfs.c +60 -0
72 lines not on this page · raw message
Signature · 1 line
2.20.1
Russell King (Oracle)
reviewerQuoted 10 lines · Richard Cochran
Time stamping on network packets may happen either in the MAC or in the PHY, but not both. In preparation for making the choice selectable, expose both the current and available layers via sysfs.
In accordance with the kernel implementation as it stands, the current layer will always read as "phy" when a PHY time stamping device is present. Future patches will allow changing the current layer administratively.
Signed-off-by Richard Cochran <[email protected]>
Did you mean to introduce "selected_timestamping_layer" in this patch - it appears to be a write only variable.
As it stands, it gets set to indicate PHY mode just by a network driver binding to a PHY. If this gets used based on that decision to direct where get_ts_info() goes, then this will break mvpp2 PTP.
I suggest that the introduction of "selected_timestamping_layer" is moved to the patch where it's actually used for a better review.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
kernel test robot
build botreproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross #…
Hi Richard,
[FYI, it's a private test report for your RFC patch.] [auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Richard-Cochran/Make-MAC-PHY-time-stamping-selectable/20220104-072717 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 3d694552fd8fe502e7ffd22ffa0e085bfd73b19a config: arc-buildonly-randconfig-r001-20220104 (https://download.01.org/0day-ci/archive/20220104/202201041705.Qy6C7VUP-lkp(a)intel.com/config) compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c7ffd872b92c08c5ffdb864da31410adb78f6a17
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Richard-Cochran/Make-MAC-PHY-time-stamping-selectable/20220104-072717 git checkout c7ffd872b92c08c5ffdb864da31410adb78f6a17
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
net/core/net-sysfs.c: In function 'available_timestamping_providers_show':
>> net/core/net-sysfs.c:625:35: warning: variable 'ops' set but not used [-Wunused-but-set-variable]
625 | const struct ethtool_ops *ops;
| ^~~
net/core/net-sysfs.c: In function 'current_timestamping_provider_show':
net/core/net-sysfs.c:655:35: warning: variable 'ops' set but not used [-Wunused-but-set-variable]
655 | const struct ethtool_ops *ops;
| ^~~vim +/ops +625 net/core/net-sysfs.c
620
621 static ssize_t available_timestamping_providers_show(struct device *dev,
622 struct device_attribute *attr,
623 char *buf)
624 {
> 625 const struct ethtool_ops *ops;
626 struct net_device *netdev;
627 struct phy_device *phydev;
628 int ret = 0;
629
630 netdev = to_net_dev(dev);
631 phydev = netdev->phydev;
632 ops = netdev->ethtool_ops;
633
634 if (!rtnl_trylock())
635 return restart_syscall();
636
637 ret += sprintf(buf, "%s\n", "mac");
638 buf += 4;
639
640 if (phy_has_tsinfo(phydev)) {
641 ret += sprintf(buf, "%s\n", "phy");
642 buf += 4;
643 }
644
645 rtnl_unlock();
646
647 return ret;
648 }
649 static DEVICE_ATTR_RO(available_timestamping_providers);
650
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org