All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, Simon Horman <horms@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH net-next v5 2/8] net: ethtool: plumb PHY stats to PHY drivers
Date: Tue, 7 Jan 2025 18:02:16 -0800	[thread overview]
Message-ID: <20250107180216.5802e941@kernel.org> (raw)
In-Reply-To: <20250106083301.1039850-3-o.rempel@pengutronix.de>

On Mon,  6 Jan 2025 09:32:55 +0100 Oleksij Rempel wrote:
> +	/**
> +	 * @get_link_stats: Retrieve link statistics.
> +	 * @dev: The PHY device for which the statistics are retrieved.
> +	 * @link_stats: structure where link-specific stats will be stored.
> +	 *
> +	 * Retrieves link-related statistics for the given PHY device. The input
> +	 * structure is pre-initialized with `ETHTOOL_STAT_NOT_SET`, and the
> +	 * driver must only modify members corresponding to supported
> +	 * statistics. Unmodified members will remain set to
> +	 * `ETHTOOL_STAT_NOT_SET` and will not be returned to userspace.
> +	 *
> +	 * Return: 0 on success or a negative error code on failure.

These get callbacks return void

> +	 */
> +	void (*get_link_stats)(struct phy_device *dev,
> +			       struct ethtool_link_ext_stats *link_stats);
>  	/** @get_sset_count: Number of statistic counters */
>  	int (*get_sset_count)(struct phy_device *dev);
>  	/** @get_strings: Names of the statistic counters */
> @@ -1777,6 +1810,49 @@ static inline bool phy_is_pseudo_fixed_link(struct phy_device *phydev)
>  	return phydev->is_pseudo_fixed_link;
>  }
>  
> +/**
> + * phy_ethtool_get_phy_stats - Retrieve standardized PHY statistics
> + * @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.
> + */
> +static inline 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
> + * @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.
> + */
> +static inline 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);
> +}

Do these have to be static inlines?

Seemds like it will just bloat the header, and make alignment more
painful.

  reply	other threads:[~2025-01-08  2:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06  8:32 [PATCH net-next v5 0/8] Introduce unified and structured PHY Oleksij Rempel
2025-01-06  8:32 ` [PATCH net-next v5 1/8] ethtool: linkstate: migrate linkstate functions to support multi-PHY setups Oleksij Rempel
2025-01-06  8:32 ` [PATCH net-next v5 2/8] net: ethtool: plumb PHY stats to PHY drivers Oleksij Rempel
2025-01-08  2:02   ` Jakub Kicinski [this message]
2025-01-08  9:08     ` Oleksij Rempel
2025-01-08 16:03       ` Andrew Lunn
2025-01-08 16:24         ` Maxime Chevallier
2025-01-08 17:47           ` Jakub Kicinski
2025-01-06  8:32 ` [PATCH net-next v5 3/8] net: ethtool: add support for structured PHY statistics Oleksij Rempel
2025-01-06  8:32 ` [PATCH net-next v5 4/8] Documentation: networking: update PHY error counter diagnostics in twisted pair guide Oleksij Rempel
2025-01-06  8:32 ` [PATCH net-next v5 5/8] net: phy: introduce optional polling interface for PHY statistics Oleksij Rempel
2025-01-06  8:32 ` [PATCH net-next v5 6/8] ethtool: add helper to prevent invalid statistics exposure to userspace Oleksij Rempel
2025-01-08  2:05   ` Jakub Kicinski
2025-01-06  8:33 ` [PATCH net-next v5 7/8] net: phy: dp83td510: add statistics support Oleksij Rempel
2025-01-06  8:33 ` [PATCH net-next v5 8/8] net: phy: dp83tg720: " Oleksij Rempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250107180216.5802e941@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.