Article View: linux.kernel.netdev
Article #16137Re: [PATCH net-next 05/15] net: airoha: update stats on flow deletion
From: netdev-bot+sashiko
Date: Sat, 14 Nov 2026 03:23
Date: Sat, 14 Nov 2026 03:23
129 lines
12719 bytes
12719 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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).
- [Medium] airoha_ppe_flow_update_stats()
(drivers/net/ethernet/airoha/airoha_ppe.c, ~1288-1303) computes…
- [Low] In airoha_ppe_flow_offload_destroy() the final counters are
sampled by airoha_ppe_flow_update_stats() (line 1315) before the…
--
net: airoha: update stats on flow deletion
This commit moves the stats collection code out of
airoha_ppe_flow_offload_stats() into a new helper,
airoha_ppe_flow_update_stats(). The helper is also called from
airoha_ppe_flow_offload_destroy(), so the final counters are reported on
flow deletion, as introduced by "netfilter: flowtable: retrieve stats on
flow deletion".
> diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
> index f5369c45766d2..af8c7fe9b7f09 100644
> --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> @@ -1285,6 +1285,23 @@ static int airoha_ppe_flow_offload_replace(struct airoha_eth *eth,
> return err;
> }
>
> +static void airoha_ppe_flow_update_stats(struct airoha_eth *eth,
> + struct flow_cls_offload *f,
> + struct airoha_flow_table_entry *e)
> +{
> + u32 idle = airoha_ppe_entry_idle_time(eth->ppe, e);
> +
> + f->stats.lastused = jiffies - idle * HZ;
> + if (e->hash != 0xffff) {
> + struct airoha_foe_stats64 stats = {};
> +
> + airoha_ppe_foe_entry_get_stats(eth->ppe, e->hash, &stats);
> + f->stats.pkts += (stats.packets - e->stats.packets);
> + f->stats.bytes += (stats.bytes - e->stats.bytes);
> + e->stats = stats;
[Severity: Medium]
Can these subtractions wrap if the entry was re-bound after the last stats
read?
Every time the driver commits a binding, it resets the hardware/NPU counter
slot to zero:
airoha_ppe_foe_insert_entry()
airoha_ppe_foe_commit_entry(ppe, &e->data, hash, rx_wlan)
airoha_ppe_foe_flow_stats_update()
airoha_ppe_foe_flow_stat_entry_reset()
memset_io(&npu->stats[index], 0, sizeof(*npu->stats));
memset(&ppe->foe_stats[index], 0, sizeof(*ppe->foe_stats));
e->stats is not cleared on that path. Its only writer is the assignment
above.
Suppose the FOE entry goes UNBIND, either through hardware aging or
because the slot was overwritten. airoha_ppe_foe_insert_entry() then
re-binds it and sets e->hash = hash. The next call here computes
small - old_total in u64, which gives a value near 2^64.
On the DESTROY path, flow_offload_update_stats() passes that value to
nf_ct_acct_add(), which takes unsigned int packets/bytes. The conntrack
counters would then jump by roughly 2^32 - old_total.
The stale baseline already affected the periodic FLOW_CLS_STATS path. But
nf_flow_offload_gc_step() never sends FLOW_CLS_STATS for a flow that has
been torn down. A re-bind between teardown and the DESTROY work used to
go unreported. With this patch it becomes the flow's final accounting
value.
Should e->stats be reset wherever e is recommitted and the hardware counter
is zeroed?
> + }
> +}
> +
> static int airoha_ppe_flow_offload_destroy(struct airoha_eth *eth,
> struct flow_cls_offload *f)
> {
> @@ -1295,6 +1312,7 @@ static int airoha_ppe_flow_offload_destroy(struct airoha_eth *eth,
> if (!e)
> return -ENOENT;
>
> + airoha_ppe_flow_update_stats(eth, f, e);
> airoha_ppe_foe_flow_remove_entry(eth->ppe, e);
[Severity: Low]
Could the final stats miss packets that the hardware forwards between
these two calls?
The counters are read without ppe_lock while the FOE entry is still BIND,
so the PPE keeps forwarding and counting. After that,
airoha_ppe_foe_flow_remove_entry() takes ppe_lock and does:
airoha_ppe_foe_remove_flow()
e->data.ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE, AIROHA_FOE_STATE_INVALID);
airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash, false)
airoha_ppe_foe_flow_stats_update()
airoha_ppe_foe_flow_stat_entry_reset()
airoha_ppe_foe_commit_sram_entry()
Packets counted after the snapshot and before the reset are lost. So are
packets counted after the reset and before the SRAM write that
invalidates the entry.
The window is small. Since the goal here is accurate final counters,
would it be better to invalidate the hardware entry first, then read and
reset the counter, all under ppe_lock?
> rhashtable_remove_fast(ð->flow_table, &e->node,
> airoha_flow_table_params);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113031251.2437074-2-pablo%40netfilter.org
Technical Details
Message-ID:
<179462662336.2199510.7109174272716218011@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363069-linux-kernel-netdev=dewy.ruReferences:
<20261113031251.2437074-6-pablo@netfilter.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363069-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 05/15] net: airoha: update stats on flow deletion Date: Sat, 14 Nov 2026 03:23:43 +0000 Organization: Usenet Network Message-ID: <179462662336.2199510.7109174272716218011@kernel.org> References: <20261113031251.2437074-6-pablo@netfilter.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1499478"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:85iAbso9Yy4agH/IR3Pv3mwfd6Q= sha256:OUqf9C+FIglx5W0NNZyyb5/74+yiNqwhJlF09/wxXA4= sha1:YVwpnBdmbRhP2IbeI2ge2u8hPkc= sha256:xYZ2jmHwghpUXsMsClokSWdLCWlE7iVLXCXDO6Doass= 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 712B1114751; Sat, 14 Nov 2026 06:24:17 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 yi4WrmrmbxzK; Sat, 14 Nov 2026 06:24:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363069-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 3775611474F; Sat, 14 Nov 2026 06:24:05 +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 6E5AA63F17; Sat, 14 Nov 2026 03:24:01 +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=1794626625; b=QlrH7qAX+BdNRr4J4nRGquOqsKzjw9nqnK21Sq7xqB8Ee9QVft+IlbLOZ8K+zkoeidwi stK3zPKS7BeAJDvqFmWB8iyojo3AhpzjRgMinMUhVSTMVfw6hrAaSPloH/TI/pry3gzNx UkiRYTuRwRmI4DD0/8MQd1EncAprad+0kuPMC8uYdikgLDNQDkarIGosV4IqeV42F08Ms XMNwaR7oIa+br/3wx+oExk+IUqT0ttcgvbZXY+sU2m1xAD00bnuaS6vyogqAMBA0CUV9l sPYRllkGZqCIjmWuEXf5cQuQyzWbgRzYMBK4qrt8qwGNATHAK8mi12W0Gm55v4bDDPg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794626625; 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=ywTZNUzdDeYFYSzCQUyskO5KI+1kN5G5m4XRolGTxVo=; b=Wvv9po2c5b5mZntx0KMRQT0BKU3u1BYYBhf+uGAyN8UMTgIGjPPOEQ2H22Mo0Q/Sgssq /f0+hOlA2EGkQAqS2M/gqDs4eKOS2oSrMFYOYhYS9GGImgyzTPvgVISI0P/7f9tZxXlRJ 2WxM42HL4YfLXAUQGlE7TVlmj2DOpmAnTmH2xYv6I3T1Z2jAm/GpFhlMupkyNVwU6/k12 EvKKcp2BUvJQYL6iXmt4Hlzr9EC9ZoychU3ocXG/z84aMFJXotpioRMrVKTtkX9hZZ/Fg 7cE9zNZb5kiD0s8iB2ydV75NB5y8NQm9Q2kH5Dt6X8/wxxkj5VJKAhq+gbNAAYBjOpA== 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=I3H+8dab; 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 45648606A33A; Sat, 14 Nov 2026 03:23:45 +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=I3H+8dab 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=1794626624; b=ahMZUplJTjt+bV9PgIh6vhDnsCbAlUgkO9dL0DSTGrmT0vs4U+l6C2+el7liNtHrMH3s Du77ztscXlGAvIkd06g6ZH6NJN5NnY9ZliIariEE0F84io3HA5j9ZcaFUSOl0LCMGl11v U7/miDYJJpz3PSqkrzGI2OBQO90sD6uTSOyVouUKgc2kcy02dYplXksFRNx8Qt3lfEzuA jjJYEFMOveO2qGC9XcXHfC44QLlP27pn+ETUZj8x/9oVhTvzrmdeTokcKnA797DVLb6Yt CIvHBPHBcqs+ms58eOT4gk3b6UJSPghzlu9sYY2TsrQRrwNRRYWuw2eZCrGM/pcBjBQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794626624; 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=ywTZNUzdDeYFYSzCQUyskO5KI+1kN5G5m4XRolGTxVo=; b=kesa48ruH+nfpNWsgIry6KEtWGWgN89qCoL0oX/tRNIbm6H/lKWBvKMRzlTAQ1yAa22H fQAIdCH57Cbcgnhqpy1a6a/3m5UU3JUG6/xcMhY7ECCLQVhnksa+PmT9eyeCLUJDjM7Jj v/xHhstHYwfz6GrGeAtjPCjhFp+WSfjzA3VP9fEIdxo03vIwz1txAS0sQvJFTWVYm/n6u iUWlDBUsa6cWu/0kw2Gbytv5taV7WmfpyzwLcpf0iUFTPt3Fuh/98s76LUYyxOPgxLk3a ino0XafcY0TPwC++OhJpR8c+IxZF8s0tFCo9QUc1isa+LohMLvGRMjyjgqS60xQltVw== 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=I3H+8dab; 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 667B2606A89E; Sat, 14 Nov 2026 03:23:44 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEE181F000C8; Sat, 14 Nov 2026 03:23:43 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794626624; bh=ywTZNUzdDeYFYSzCQUyskO5KI+1kN5G5m4XRolGTxVo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=I3H+8dabKM/Th3RCB38PFFfWg8EenAPhtxiTkLO+mPHvvrpnVJnSVg3cu1fD28049 zh9/9Pz7R7Vl5jR0lhtWExIRCkGY+rkjsltjgfQHNMq3Ur2COqGk+OiWhL9woyntry xMiC9+/q9awhQZgFqGpMvV8ens3/V+O6SrYLcsFzRAruA5kHSl63r2p6nWjNZ28LtZ BYMXnE8l2C2LEIs9vIG/jyyufdKhruOGoGsU+KoJY3ogVfcGqxF61aN99HO0omBRS7 9ZtSUP4CbttTcNbJauQUZ9s3Ov+i6mxrqXOgADvQK29lyRHz89J+J6i+rgw/tmzm9a ZKt9mbLax1qhg== X-Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg X-In-Reply-To: <20261113031251.2437074-6-pablo@netfilter.org> X-sashiko-severity: Medium 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