netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, andrew@lunn.ch, saeedm@nvidia.com,
	corbet@lwn.net, michael.chan@broadcom.com,
	huangguangbin2@huawei.com, chenhao288@hisilicon.com,
	moshet@nvidia.com, linux@rempel-privat.de,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH net-next] ethtool: linkstate: add a statistic for PHY down events
Date: Wed, 26 Oct 2022 09:40:32 +0200	[thread overview]
Message-ID: <20221026074032.GF8675@pengutronix.de> (raw)
In-Reply-To: <20221026020948.1913777-1-kuba@kernel.org>

Hi Jakub,

On Tue, Oct 25, 2022 at 07:09:48PM -0700, Jakub Kicinski wrote:
> The previous attempt to augment carrier_down (see Link)
> was not met with much enthusiasm so let's do the simple
> thing of exposing what some devices already maintain.
> Add a common ethtool statistic for link going down.
> Currently users have to maintain per-driver mapping
> to extract the right stat from the vendor-specific ethtool -S
> stats. carrier_down does not fit the bill because it counts
> a lot of software related false positives.
> 
> Add the statistic to the extended link state API to steer
> vendors towards implementing all of it.
> 
> Implement for bnxt. mlx5 and (possibly) enic also have
> a counter for this but I leave the implementation to their
> maintainers.
> 
> Link: https://lore.kernel.org/r/20220520004500.2250674-1-kuba@kernel.org
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: corbet@lwn.net
> CC: michael.chan@broadcom.com
> CC: huangguangbin2@huawei.com
> CC: chenhao288@hisilicon.com
> CC: moshet@nvidia.com
> CC: linux@rempel-privat.de
> CC: linux-doc@vger.kernel.org
> ---
>  Documentation/networking/ethtool-netlink.rst  |  1 +
>  .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 15 +++++++++++++++
>  include/linux/ethtool.h                       | 14 ++++++++++++++
>  include/uapi/linux/ethtool_netlink.h          |  2 ++
>  net/ethtool/linkstate.c                       | 19 ++++++++++++++++++-
>  5 files changed, 50 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst
> index d578b8bcd8a4..5454aa6c013c 100644
> --- a/Documentation/networking/ethtool-netlink.rst
> +++ b/Documentation/networking/ethtool-netlink.rst
> @@ -491,6 +491,7 @@ any attributes.
>    ``ETHTOOL_A_LINKSTATE_SQI_MAX``       u32     Max support SQI value
>    ``ETHTOOL_A_LINKSTATE_EXT_STATE``     u8      link extended state
>    ``ETHTOOL_A_LINKSTATE_EXT_SUBSTATE``  u8      link extended substate
> +  ``ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT``  u64     count of link down events
>    ====================================  ======  ============================
>  
>  For most NIC drivers, the value of ``ETHTOOL_A_LINKSTATE_LINK`` returns
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> index cc89e5eabcb9..d5957ed00759 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> @@ -4112,6 +4112,20 @@ static void bnxt_get_rmon_stats(struct net_device *dev,
>  	*ranges = bnxt_rmon_ranges;
>  }
>  
> +static void bnxt_get_link_ext_stats(struct net_device *dev,
> +				    struct ethtool_link_ext_stats *stats)
> +{
> +	struct bnxt *bp = netdev_priv(dev);
> +	u64 *rx;
> +
> +	if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT))
> +		return;
> +
> +	rx = bp->rx_port_stats_ext.sw_stats;
> +	stats->LinkDownEvents =
> +		*(rx + BNXT_RX_STATS_EXT_OFFSET(link_down_events));
> +}
> +

s/LinkDownEvents/link_down_events.

What is the best way to implement it on devices without dedicated HW
counter? I assume in most cases only PHY driver would not real state of
link.

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2022-10-26  7:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26  2:09 [PATCH net-next] ethtool: linkstate: add a statistic for PHY down events Jakub Kicinski
2022-10-26  7:40 ` Oleksij Rempel [this message]
2022-10-26 12:58   ` Andrew Lunn
2022-10-26 16:11   ` Jakub Kicinski
2022-10-26 12:19 ` Andrew Lunn
2022-10-26 16:10   ` Jakub Kicinski
2022-10-26 21:32     ` Andrew Lunn

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=20221026074032.GF8675@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=andrew@lunn.ch \
    --cc=chenhao288@hisilicon.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=huangguangbin2@huawei.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=michael.chan@broadcom.com \
    --cc=moshet@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.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;
as well as URLs for NNTP newsgroup(s).