Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: alexander.duyck@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, horms@kernel.org,
	kernel-team@meta.com, kuba@kernel.org, pabeni@redhat.com
Subject: Re: [net PATCH 2/6] fbnic: Do not accumulate HW stats from failed register reads
Date: Tue, 17 Nov 2026 21:14:19 +0000	[thread overview]
Message-ID: <179495005990.3136.15414982968445441738@kernel.org> (raw)
In-Reply-To: <179460249371.8819.4646491882671802455.stgit@ahduyck-xeon-server.home.arpa>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix is incomplete: `fbnic_pcs_rsfec_stat_rd32()` in
  drivers/net/ethernet/meta/fbnic/fbnic_mac.c still adds failed reads…
- [Low] The commit message describes the failed-read symptom accurately
  only for the 64-bit counters.

--

fbnic: Do not accumulate HW stats from failed register reads

This commit changes the fbnic HW stats helpers so they skip updating the
running totals once a failed register read has disabled CSR access. The
check is added to fbnic_hw_stat_rd32(), fbnic_hw_stat_rd64(),
__fbnic_mac_stat_rd64() and fbnic_mac_stat_rd32().

> When a register read fails, as it does for every read once a DPC
> containment event takes the link down, the fbnic_rd32 function returns
> all ones and disables CSR access, so every later read also returns all
> ones until the device is recovered. A stats read in that window adds the
> difference between all ones and the last value to the total, which
> subtracts the counter's whole value since the last rebase.

[Severity: Low]
Does this description hold for the 32-bit counters?

In fbnic_hw_stat_rd32() and fbnic_mac_stat_rd32() the delta is computed
in u32:

	stat->value += new_reg_value - stat->u.old_reg_value_32;

When new_reg_value == 0xffffffff, this gives 0xffffffff - old. That value
is zero-extended and added to the u64 stat->value. So the 32-bit counters
(TMI/TTI/RPC/RXB drops, per-queue HW drops, 32-bit MAC stats) would jump
forward by nearly 2^32 instead of dropping.

Only the 64-bit helpers wrap the total downward, because fbnic_stat_rd64()
returns ~0ULL there. The code change looks correct for both widths. Could
the commit message also mention the forward jump in the 32-bit counters?

> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
> index 16271c717a5aa..2aacbf0a6af40 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c

[ ... ]

> @@ -417,6 +421,10 @@ static void fbnic_mac_stat_rd32(struct fbnic_dev *fbd, bool reset, u32 reg,
>  	u32 new_reg_value;
>  
>  	new_reg_value = rd32(fbd, reg);
> +	/* A failed read disables CSR access and returns all ones */
> +	if (!fbnic_present(fbd))
> +		return;
> +
>  	if (!reset)
>  		stat->value += new_reg_value - stat->u.old_reg_value_32;
>  	stat->u.old_reg_value_32 = new_reg_value;

[Severity: High]
Should fbnic_pcs_rsfec_stat_rd32() in this same file get the same check?

It reads the clear-on-read FEC/PCS counters and never calls
fbnic_present():

drivers/net/ethernet/meta/fbnic/fbnic_mac.c:fbnic_pcs_rsfec_stat_rd32() {
    ...
	pcs_rsfec_stat = rd32(fbd, reg) & 0xffff;
	pcs_rsfec_stat |= rd32(fbd, reg + 1) << 16;

	/* RFSEC registers clear themselves upon being read so there is no
	 * need to store the old_reg_value.
	 */
	if (!reset)
		stat->value += pcs_rsfec_stat;
}

After fbnic_rd32() clears uc_addr0, both reads return ~0U, so
pcs_rsfec_stat ends up as 0xffffffff. These counters have no baseline to
subtract. As a result, corrected_blocks, uncorrectable_blocks and every
SymbolErrorDuringCarrier lane would grow by about 4G on each stats poll
while the device is unreachable.

One path that reaches it:

fbnic_get_stats64()
  fbnic_get_hw_stats()
    __fbnic_get_hw_stats32()
      fbnic_get_phy_stats32()   /* reset == false */
        fbnic_mac_get_fec_stats() / fbnic_mac_get_pcs_stats()
          fbnic_pcs_rsfec_stat_rd32()

The service task reaches it the same way through fbnic_get_hw_stats32(),
and so does ethtool through fbnic_get_fec_stats().

dev_get_stats() does not check netif_device_present(). A read of
/proc/net/dev during a DPC/AER outage, or after fbnic_pm_suspend(), would
therefore hit this path.

fbnic_reset_hw_stats() calls these readers only with reset == true. That
skips the add but does not rewind stat->value, so the inflated totals
would remain after recovery.

Would adding the same "if (!fbnic_present(fbd)) return;" after the two
reads in fbnic_pcs_rsfec_stat_rd32() close this gap?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179460241885.8819.7179935130629202331.stgit%40ahduyck-xeon-server.home.arpa

  reply	other threads:[~2026-11-17 21:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 20:41 [net PATCH 0/6] fbnic: Follow-up fixes for the Tx idle check, HW stats and FW mailbox allocations Alexander Duyck
2026-11-13 20:41 ` [net PATCH 1/6] fbnic: Wait for in-flight PTP timestamps before treating Tx as idle Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko
2026-11-17 21:31     ` Alexander Duyck
2026-11-13 20:41 ` [net PATCH 2/6] fbnic: Do not accumulate HW stats from failed register reads Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko [this message]
2026-11-13 20:41 ` [net PATCH 3/6] fbnic: Cover all of the HW stats with the stats lock Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko
2026-11-13 20:41 ` [net PATCH 4/6] fbnic: Initialize and reset the HW stats before they can be read Alexander Duyck
2026-11-13 20:42 ` [net PATCH 5/6] fbnic: Stamp heartbeat and ownership requests after allocating them Alexander Duyck
2026-11-13 20:42 ` [net PATCH 6/6] fbnic: Allocate FW completions with kvzalloc Alexander Duyck

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=179495005990.3136.15414982968445441738@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexander.duyck@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --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