lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250109152159.GI7706@kernel.org>
Date: Thu, 9 Jan 2025 15:21:59 +0000
From: Simon Horman <horms@...nel.org>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Andrew Lunn <andrew+netdev@...n.ch>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Jonathan Corbet <corbet@....net>, kernel@...gutronix.de,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	Russell King <linux@...linux.org.uk>,
	Maxime Chevallier <maxime.chevallier@...tlin.com>,
	linux-doc@...r.kernel.org
Subject: Re: [PATCH net-next v6 2/7] net: ethtool: plumb PHY stats to PHY
 drivers

On Thu, Jan 09, 2025 at 10:44:52AM +0100, Oleksij Rempel wrote:
> From: Jakub Kicinski <kuba@...nel.org>
> 
> Introduce support for standardized PHY statistics reporting in ethtool
> by extending the PHYLIB framework. Add the functions
> phy_ethtool_get_phy_stats() and phy_ethtool_get_link_ext_stats() to
> provide a consistent interface for retrieving PHY-level and
> link-specific statistics. These functions are used within the ethtool
> implementation to avoid direct access to the phy_device structure
> outside of the PHYLIB framework.
> 
> A new structure, ethtool_phy_stats, is introduced to standardize PHY
> statistics such as packet counts, byte counts, and error counters.
> Drivers are updated to include callbacks for retrieving PHY and
> link-specific statistics, ensuring values are explicitly set only for
> supported fields, initialized with ETHTOOL_STAT_NOT_SET to avoid
> ambiguity.
> 
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>

...

> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index e4b04cdaa995..e629c3b1a940 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -615,6 +615,49 @@ int phy_ethtool_get_stats(struct phy_device *phydev,
>  }
>  EXPORT_SYMBOL(phy_ethtool_get_stats);
>  
> +/**
> + * phy_ethtool_get_phy_stats - Retrieve standardized PHY statistics

nit: __phy_ethtool_get_phy_stats

> + * @phydev: Pointer to the PHY device
> + * @phy_stats: Pointer to ethtool_eth_phy_stats structure
> + * @phydev_stats: Pointer to ethtool_phy_stats structure
> + *
> + * Fetches PHY statistics using a kernel-defined interface for consistent
> + * diagnostics. Unlike phy_ethtool_get_stats(), which allows custom stats,
> + * this function enforces a standardized format for better interoperability.
> + */
> +void __phy_ethtool_get_phy_stats(struct phy_device *phydev,
> +				 struct ethtool_eth_phy_stats *phy_stats,
> +				 struct ethtool_phy_stats *phydev_stats)
> +{
> +	if (!phydev->drv || !phydev->drv->get_phy_stats)
> +		return;
> +
> +	mutex_lock(&phydev->lock);
> +	phydev->drv->get_phy_stats(phydev, phy_stats, phydev_stats);
> +	mutex_unlock(&phydev->lock);
> +}
> +
> +/**
> + * phy_ethtool_get_link_ext_stats - Retrieve extended link statistics for a PHY

nit: __phy_ethtool_get_link_ext_stats

> + * @phydev: Pointer to the PHY device
> + * @link_stats: Pointer to the structure to store extended link statistics
> + *
> + * Populates the ethtool_link_ext_stats structure with link down event counts
> + * and additional driver-specific link statistics, if available.
> + */
> +void __phy_ethtool_get_link_ext_stats(struct phy_device *phydev,
> +				      struct ethtool_link_ext_stats *link_stats)
> +{
> +	link_stats->link_down_events = READ_ONCE(phydev->link_down_events);
> +
> +	if (!phydev->drv || !phydev->drv->get_link_stats)
> +		return;
> +
> +	mutex_lock(&phydev->lock);
> +	phydev->drv->get_link_stats(phydev, link_stats);
> +	mutex_unlock(&phydev->lock);
> +}
> +
>  /**
>   * phy_ethtool_get_plca_cfg - Get PLCA RS configuration
>   * @phydev: the phy_device struct

...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ