🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18105

Re: [net PATCH 2/6] fbnic: Do not accumulate HW stats from failed register reads

#18105
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 21:14
118 lines
12489 bytes
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
Technical Details
Message-ID: <179495005990.3136.15414982968445441738@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365613-linux-kernel-netdev=dewy.ru
References: <179460249371.8819.4646491882671802455.stgit@ahduyck-xeon-server.home.arpa>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365613-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179495005990.3136.15414982968445441738@kernel.org>
References: <179460249371.8819.4646491882671802455.stgit@ahduyck-xeon-server.home.arpa>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2428997"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8WOnpZ9uN5OJdtNH4efZuMopDuU= sha256:5pI/lPFiMgv38rG4XItTO5mWpZFDuCIBMX/ZW4cByYU=
	sha1:R8hgL4tD/qZv8KII0JtFqD3kx4c= sha256:EVoYCEujp+a2Z7jT8XZrxByvCgYvsWuFLXWmSvJO2uE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id A4E43115085; Wed, 18 Nov 2026 00:14:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id sDIdEWpxyq06;
	Wed, 18 Nov 2026 00:14:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365613-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 67BB3115088; Wed, 18 Nov 2026 00:14:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id B3CD547DA4; Tue, 17 Nov 2026 21:14:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794950062;
	b=fCGU0BBRdifQJ/CTa9R9iR7DgPLb4KwzvF9dTbDlYZ9Yx2CZjPBIPttzz/EIgqvpwFDj
	 2jzlBbG1ZOUzw373cWSvU4L9zl6Rjx7/3z7vj0StZr1mfJrhImMMraneOmCBQZ0VydiUB
	 DFoo6Ng0Z/y85L9AIAQepxgdJgVC+v6oEp+hUV2fpDW9h701v9Fmb/pqMuGNtTqyAJgUt
	 rmCr0G72pMPnBlIEpDC1ZqYHfKMg9uTDtfjl3G4jzHgIuf4tyKVYL4F59TAuClqtzKgoW
	 5A//Sh0SDQVrZF/SyplWuNpX3z+uwMKwwUy6y48Ei9Nhfc4jeACJVezMwcp/vQgnwFA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794950062;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=TcpFUjEcAbKNKX1+Kz1Nz7s9gX1dNDQMX7S3PRCPz44=;
	b=rBDqH5eJnOLRHEIJze/FzPYF6N0JTfUvGph4/iVFiGVMd67HfzgY4s+DQF71pCTnNifw
	 gTzy7sq5liVSEVcFmRnVVyP0uj4YPAKpkdkb3gXBh84vt0ov+Ib8uS/kM5ti2Gaxonf9+
	 gqnHDqAiqwDCAT59Ym3++zZqMhER7Db4Pb4gLTMI1HyhkxL6Gj8GnGChuI0+irQanqW+M
	 Xoq1N7TfZFRFXvD21a6KM6FEXSGnmS2gVGCjX2E219CuZ4Fc1ZUTt4yUak9ppxT+3qpxh
	 ms75b1IGQPR8k+TghzIFQ+jxZ1FpWi4XPGu7fmT2YbWP1I2KgwIhj665UjxaYW5M58A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UabMZzBb;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 02F9E606A31C;
	Tue, 17 Nov 2026 21:14:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UabMZzBb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794950061;
	b=0amkrrFt+FJDyunt8zUcNI8IOjfaPWbRx3ZX81ksK4Ao5Y9eLMPmFIxzfv6Qn4IFihPc
	 JVIxVtKLYVmmuysYj6eszVW9OZ83GzdaycuixHnE9BKvp64A/dD458Mae/jvsL0/Mzaqs
	 qmWnIIEI9tsgYiADZ8BdwB82uUdl4m6yPwn3+pkoCMbJZFBTq+RBw4MsbpZ7R/6Mfr3zh
	 1wCsY226RPlM4GdU71VsJTEogM6Mg2eqbZUpmY2XciWbTiYZwHPpFflqZSnTnvywuIeuL
	 ZrTLRBYlGFhwK2kKTyjB79t+fEsn0OOpxL3Lx/CTfzFyn/VrbysFsjrqeYbTqOOkeBg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794950061;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=TcpFUjEcAbKNKX1+Kz1Nz7s9gX1dNDQMX7S3PRCPz44=;
	b=h+6pKjrm/Uxq7sgrLYBkgojovkeGPOJx2ognId6pZ5cbQlqXXJkLJ90b3UBn11/wJlwX
	 kiN0ArGFk2bR/8qmAD4RcW33HfhiwMh+oZXfC1CTq/K81Ovx2hGWHhwzVO5OEBgqbjdvF
	 iTmTssObIn6q3985CBaCGygBTD2QJQ6d36YdEUo31MFlGrCunxEX/EyrBXJe+8JP3lKvr
	 qVs2Md7e/6MpM1QOdk/uLwpjW7cci/cCaom8ROHrfmu2icT/gF+HZZHxx8gnTG0KF9NNr
	 klY1cBcJfmTSvyVq3qGUhlKuCJ7ONC5TPG0bQedhbjBK2LGVdZHW9oHwG52bh6RkJDw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UabMZzBb;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23CE3606A334
	for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 21:14:21 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FC0D1F000C4;
	Tue, 17 Nov 2026 21:14:20 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794950060;
	bh=TcpFUjEcAbKNKX1+Kz1Nz7s9gX1dNDQMX7S3PRCPz44=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=UabMZzBb8bXiFkATDfhjF8FI8uNKBN/kJmMa5x+zXfaVkuL3BxLhY9N5SY2QAiWxc
	 WTdcC7D/viMKcvv2dmKgEknub1FP833b5YuP9fFb0s3LwS3ayNH8ySHqfAV98XN5UZ
	 FfeGMZ9pGDjVEwSa6/BthCmldBadw7qCVEDtvLVcqpxnrzT/0YRwSsJJ2XYT2dnxG3
	 HQ6vRmd3u7e+ykw3iidC7hjnUEwNyeaNE2ezIBfZHpT/Ds3Zfe1FAXmZ85RpMYmAvs
	 3qUPa7Q0tmKPdA5lF2nCIuwjSllYJx40NxmrauoANE/0kCmmiPtd+0cSqp2MuQ930M
	 7t4ta+Q2VVzDg==
X-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
X-In-Reply-To: <179460249371.8819.4646491882671802455.stgit@ahduyck-xeon-server.home.arpa>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list