From: Jakub Kicinski <kuba@kernel.org>
To: eric.joyner@amd.com
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, brett.creeley@amd.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com
Subject: Re: [PATCH net-next v2 2/5] ionic: Get "link_down_count" ext link stat from firmware
Date: Fri, 8 May 2026 15:55:10 -0700 [thread overview]
Message-ID: <20260508225510.3420230-1-kuba@kernel.org> (raw)
In-Reply-To: <20260506043526.64301-3-eric.joyner@amd.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
ionic: Get "link_down_count" ext link stat from firmware
This commit replaces the driver-calculated software link down count with the
hardware count provided by the firmware in the extended link statistics. It
updates the ethtool callback to read the counter from the device's port_info
and removes the software tracking completely.
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> index 78a802eb159f0..af0c4cc8ad8e4 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> @@ -117,7 +117,8 @@ static void ionic_get_link_ext_stats(struct net_device *netdev,
> struct ionic_lif *lif = netdev_priv(netdev);
>
> if (lif->ionic->pdev->is_physfn)
> - stats->link_down_events = lif->link_down_count;
> + stats->link_down_events =
> + lif->ionic->idev.port_info->status.link_down_count;
Could this lead to a NULL pointer dereference?
If a PCI error triggers device recovery via .reset_prepare, the device stops
but the net_device remains registered. If the subsequent ionic_setup_one()
fails during .reset_done, port_info is explicitly freed and set to NULL.
Calling ethtool in this state would crash the kernel.
Other callbacks like ionic_get_link_ksettings() guard against this:
if (!idev->port_info) {
netdev_err(netdev, "port_info not initialized\n");
return -EOPNOTSUPP;
}
Does link_down_count also need a byte-order conversion?
The firmware-provided field link_down_count in struct ionic_port_status is
defined as a little-endian 16-bit integer (__le16). Assigning it directly
to stats->link_down_events without wrapping it in le16_to_cpu() will result
in incorrect statistic values on big-endian architectures.
next prev parent reply other threads:[~2026-05-08 22:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 4:35 [PATCH net-next v2 0/5] Expose more port stats to ethtool Eric Joyner
2026-05-06 4:35 ` [PATCH net-next v2 1/5] ionic: Small improvements in devcmd retry logic Eric Joyner
2026-05-08 22:55 ` Jakub Kicinski
2026-05-06 4:35 ` [PATCH net-next v2 2/5] ionic: Get "link_down_count" ext link stat from firmware Eric Joyner
2026-05-08 22:54 ` Jakub Kicinski
2026-05-08 22:55 ` Jakub Kicinski [this message]
2026-05-06 4:35 ` [PATCH net-next v2 3/5] ionic: Update ionic_if.h with new extra port stats structure Eric Joyner
2026-05-06 4:35 ` [PATCH net-next v2 4/5] ionic: Report rx_bits_phy stat to ethtool Eric Joyner
2026-05-06 4:35 ` [PATCH net-next v2 5/5] ionic: Add .get_fec_stats ethtool handler Eric Joyner
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=20260508225510.3420230-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.joyner@amd.com \
--cc=netdev@vger.kernel.org \
--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