[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <640289453cd8b_cc8e20837@willemb.c.googlers.com.notmuch>
Date: Fri, 03 Mar 2023 18:56:53 -0500
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Köry Maincent <kory.maincent@...tlin.com>,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
linux-omap@...r.kernel.org
Cc: Michael Walle <michael@...le.cc>,
Richard Cochran <richardcochran@...il.com>,
Kory Maincent <kory.maincent@...tlin.com>,
thomas.petazzoni@...tlin.com, Jay Vosburgh <j.vosburgh@...il.com>,
Veaceslav Falico <vfalico@...il.com>,
Andy Gospodarek <andy@...yhouse.net>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Joakim Zhang <qiangqing.zhang@....com>,
Vladimir Oltean <vladimir.oltean@....com>,
Claudiu Manoil <claudiu.manoil@....com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
UNGLinuxDriver@...rochip.com,
Grygorii Strashko <grygorii.strashko@...com>,
Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Minghao Chi <chi.minghao@....com.cn>,
Guangbin Huang <huangguangbin2@...wei.com>,
Jie Wang <wangjie125@...wei.com>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
Sven Eckelmann <sven@...fation.org>,
Wang Yufen <wangyufen@...wei.com>,
Oleksij Rempel <linux@...pel-privat.de>,
Alexandru Tachici <alexandru.tachici@...log.com>
Subject: RE: [PATCH v2 2/4] net: Expose available time stamping layers to user
space.
Köry Maincent wrote:
> From: Richard Cochran <richardcochran@...il.com>
>
> 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 <richardcochran@...il.com>
> Signed-off-by: Kory Maincent <kory.maincent@...tlin.com>
> ---
>
> Notes:
> Changes in v2:
> - Move the introduction of selected_timestamping_layer variable in next
> patch.
>
> .../ABI/testing/sysfs-class-net-timestamping | 17 ++++++
> net/core/net-sysfs.c | 60 +++++++++++++++++++
> 2 files changed, 77 insertions(+)
> create mode 100644 Documentation/ABI/testing/sysfs-class-net-timestamping
>
> diff --git a/Documentation/ABI/testing/sysfs-class-net-timestamping b/Documentation/ABI/testing/sysfs-class-net-timestamping
> new file mode 100644
> index 000000000000..529c3a6eb607
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-class-net-timestamping
> @@ -0,0 +1,17 @@
> +What: /sys/class/net/<iface>/available_timestamping_providers
> +Date: January 2022
> +Contact: Richard Cochran <richardcochran@...il.com>
> +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 <richardcochran@...il.com>
> +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.
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 8409d41405df..26095634fb31 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -620,6 +620,64 @@ static ssize_t threaded_store(struct device *dev,
> }
> static DEVICE_ATTR_RW(threaded);
>
> +static ssize_t available_timestamping_providers_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + const struct ethtool_ops *ops;
> + struct net_device *netdev;
> + struct phy_device *phydev;
> + int ret = 0;
> +
> + netdev = to_net_dev(dev);
> + phydev = netdev->phydev;
> + ops = netdev->ethtool_ops;
> +
> + if (!rtnl_trylock())
> + return restart_syscall();
> +
> + ret += sprintf(buf, "%s\n", "mac");
> + buf += 4;
> +
Should advertising mac be subject to having ops->get_ts_info?
> + if (phy_has_tsinfo(phydev)) {
> + ret += sprintf(buf, "%s\n", "phy");
> + buf += 4;
> + }
> +
> + rtnl_unlock();
> +
> + return ret;
> +}
> +static DEVICE_ATTR_RO(available_timestamping_providers);
Powered by blists - more mailing lists