mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"Jonathan Corbet" <corbet@lwn.net>
Cc: <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 v1 4/7] phy: introduce optional polling interface for PHY statistics
Date: Thu, 5 Dec 2024 09:14:08 +0100	[thread overview]
Message-ID: <87c2743c-1ee0-4c6c-b20d-e8e4a4141d43@intel.com> (raw)
In-Reply-To: <20241203075622.2452169-5-o.rempel@pengutronix.de>



On 12/3/2024 8:56 AM, Oleksij Rempel wrote:
> Add an optional polling interface for PHY statistics to simplify driver
> implementation. Drivers can request the PHYlib to handle the polling task by
> explicitly setting the `PHY_POLL_STATS` flag in their driver configuration.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>   drivers/net/phy/phy.c | 15 +++++++++++++++
>   include/linux/phy.h   |  6 ++++++
>   2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 0d20b534122b..b10ee9223fc9 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1346,6 +1346,18 @@ static int phy_enable_interrupts(struct phy_device *phydev)
>   	return phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
>   }
>   
> +/**
> + * phy_update_stats - update the PHY statistics
> + * @phydev: target phy_device struct
> + */

As this is newly intoduced function I would love to see the full
kdoc header, with information what the function returns, like here:

https://docs.kernel.org/doc-guide/kernel-doc.html#function-documentation

> +static int phy_update_stats(struct phy_device *phydev)
> +{
> +	if (!phydev->drv->update_stats)
> +		return 0;
> +
> +	return phydev->drv->update_stats(phydev);
> +}
> +
>   /**
>    * phy_request_interrupt - request and enable interrupt for a PHY device
>    * @phydev: target phy_device struct
> @@ -1415,6 +1427,9 @@ static enum phy_state_work _phy_state_machine(struct phy_device *phydev)
>   	case PHY_RUNNING:
>   		err = phy_check_link_status(phydev);
>   		func = &phy_check_link_status;
> +
> +		if (!err)
> +			err = phy_update_stats(phydev);
>   		break;
>   	case PHY_CABLETEST:
>   		err = phydev->drv->cable_test_get_status(phydev, &finished);
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index a6c47b0675af..21cd44d177d2 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -90,6 +90,7 @@ extern const int phy_10gbit_features_array[1];
>   #define PHY_RST_AFTER_CLK_EN	BIT(1)
>   #define PHY_POLL_CABLE_TEST	BIT(2)
>   #define PHY_ALWAYS_CALL_SUSPEND	BIT(3)
> +#define PHY_POLL_STATS		BIT(4)
>   #define MDIO_DEVICE_IS_PHY	BIT(31)
>   
>   /**
> @@ -1101,6 +1102,8 @@ struct phy_driver {
>   			      struct ethtool_phy_stats *stats);
>   	void (*get_link_stats)(struct phy_device *dev,
>   			       struct ethtool_link_ext_stats *link_stats);
> +	int (*update_stats)(struct phy_device *dev);
> +
>   	/** @get_sset_count: Number of statistic counters */
>   	int (*get_sset_count)(struct phy_device *dev);
>   	/** @get_strings: Names of the statistic counters */
> @@ -1591,6 +1594,9 @@ static inline bool phy_polling_mode(struct phy_device *phydev)
>   		if (phydev->drv->flags & PHY_POLL_CABLE_TEST)
>   			return true;
>   
> +	if (phydev->drv->update_stats && phydev->drv->flags & PHY_POLL_STATS)
> +		return true;
> +
>   	return phydev->irq == PHY_POLL;
>   }
>   


  reply	other threads:[~2024-12-05  8:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03  7:56 [PATCH net-next v1 0/7] Introduce unified and structured PHY Oleksij Rempel
2024-12-03  7:56 ` [PATCH net-next v1 1/7] net: ethtool: plumb PHY stats to PHY drivers Oleksij Rempel
2024-12-03  8:30   ` Maxime Chevallier
2024-12-05  7:45   ` Mateusz Polchlopek
2024-12-05 11:57   ` Russell King (Oracle)
2024-12-06  1:19     ` Jakub Kicinski
2024-12-06  9:11       ` Russell King (Oracle)
2024-12-06 16:13         ` Jakub Kicinski
2024-12-10 12:03   ` Simon Horman
2024-12-03  7:56 ` [PATCH net-next v1 2/7] net: ethtool: add support for structured PHY statistics Oleksij Rempel
2024-12-05 12:00   ` Russell King (Oracle)
2024-12-03  7:56 ` [PATCH net-next v1 3/7] phy: replace bitwise flag definitions with BIT() macro Oleksij Rempel
2024-12-05  2:50   ` David Laight
2024-12-05 11:13     ` Oleksij Rempel
2024-12-05 12:02   ` Russell King (Oracle)
2024-12-05 12:06     ` Russell King (Oracle)
2024-12-03  7:56 ` [PATCH net-next v1 4/7] phy: introduce optional polling interface for PHY statistics Oleksij Rempel
2024-12-05  8:14   ` Mateusz Polchlopek [this message]
2024-12-05 12:09     ` Russell King (Oracle)
2024-12-06 11:14       ` Oleksij Rempel
2024-12-03  7:56 ` [PATCH net-next v1 5/7] ethtool: add helper to prevent invalid statistics exposure to userspace Oleksij Rempel
2024-12-05  8:45   ` Mateusz Polchlopek
2024-12-03  7:56 ` [PATCH net-next v1 6/7] phy: dp83td510: add statistics support Oleksij Rempel
2024-12-05  8:43   ` Mateusz Polchlopek
2024-12-05  9:01     ` Marc Kleine-Budde
2024-12-05 10:32       ` Mateusz Polchlopek
2024-12-05 10:58       ` Oleksij Rempel
2024-12-05 12:15   ` Russell King (Oracle)
2024-12-03  7:56 ` [PATCH net-next v1 7/7] phy: dp83tg720: " Oleksij Rempel
2024-12-05 11:48 ` [PATCH net-next v1 0/7] Introduce unified and structured PHY Russell King (Oracle)

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=87c2743c-1ee0-4c6c-b20d-e8e4a4141d43@intel.com \
    --to=mateusz.polchlopek@intel.com \
    --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=kuba@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®