RE: [PATCH v2 2/4] net: Expose available time stamping layers to user space.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Köry Maincent wrote:
> From: Richard Cochran <richardcochran@xxxxxxxxx>
> 
> 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@xxxxxxxxx>
> Signed-off-by: Kory Maincent <kory.maincent@xxxxxxxxxxx>
> ---
> 
> 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@xxxxxxxxx>
> +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@xxxxxxxxx>
> +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);



[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux