Article View: linux.kernel.netdev
Article #26438Re: [PATCH net-next v4] net: dsa: motorcomm: Add limited ACL flow statistics support
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 14:49
Date: Thu, 03 Dec 2026 14:49
213 lines
15357 bytes
15357 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
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] Non-skip_sw flower rules that explicitly ask for immediate HW
stats can end up with no counter, no trap and no warning.
- [Low] The patch adds a new limited hardware pool of YT921X_FLOWSTAT_NUM
(64) flow counters, tracked in priv->flowstats_map, but does not…
- [Low] yt921x_acl_add() now writes the extack text "No more flowstats,
HW stats disabled" as a success-path warning when the counter pool is…
--
net: dsa: motorcomm: Add limited ACL flow statistics support
This adds .cls_flower_stats() support using the 64 hardware flow
counters, which are assigned to flower ACL rules when that is possible.
skip_sw rules whose stats configuration cannot be met are rejected. A
non-skip_sw rule that explicitly asks for stats is trapped to software
when no counter is left.
> diff --git a/drivers/net/dsa/motorcomm/chip.h b/drivers/net/dsa/motorcomm/chip.h
> index fc315f1d8f87b..fe6cf03a09c8e 100644
> --- a/drivers/net/dsa/motorcomm/chip.h
> +++ b/drivers/net/dsa/motorcomm/chip.h
> @@ -424,6 +424,8 @@ enum yt921x_fdb_entry_status {
> /* Custom meters only, not including dedicated port meters (11) */
> #define YT921X_METER_NUM 64
>
> +#define YT921X_FLOWSTAT_NUM 64
> +
[Severity: Low]
Should this new pool also be exposed as a devlink resource? The ACL and
meters pools are listed in yt921x_devlink_resources[] in
drivers/net/dsa/motorcomm/devlink.c, with yt921x_devlink_occ_get_acl()
and yt921x_devlink_occ_get_meter(). There is no entry for flowstats.
tc uses hw_stats any by default. This check in
yt921x_acl_rule_ext_parse_flow_action() is true for any:
} else if (act->hw_stats & FLOW_ACTION_HW_STATS_IMMEDIATE) {
ruleext->stat_applicable = true;
So rules that never asked for stats also use up counters. After 64 of
them, explicit immediate skip_sw rules fail. Non-skip_sw rules are
changed from a hardware redirect to a CPU trap, with no extack message.
Users currently have no way to see the pool occupancy.
> #define YT921X_LAG_NUM 2
> #define YT921X_LAG_PORT_NUM 4
[ ... ]
> diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c
> index e3f057ed580f5..043269f41fbcb 100644
> --- a/drivers/net/dsa/motorcomm/tc.c
> +++ b/drivers/net/dsa/motorcomm/tc.c
[ ... ]
> @@ -1052,6 +1069,21 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
> goto fallback;
> }
>
> + if (act->hw_stats & FLOW_ACTION_HW_STATS_DISABLED) {
> + stat_veto = true;
> + } else if (act->hw_stats & FLOW_ACTION_HW_STATS_IMMEDIATE) {
> + ruleext->stat_applicable = true;
> + ruleext->stat_required |= act->hw_stats !=
> + FLOW_ACTION_HW_STATS_ANY;
> + } else if (!cls->common.skip_sw) {
> + /* Keep the rule offloaded, just without a counter */
> + stat_veto = true;
> + } else {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Unsupported action HW stats type");
> + return -EOPNOTSUPP;
> + }
> +
> switch (act->id) {
> case FLOW_ACTION_ACCEPT:
> action[2] |= YT921X_ACL_ACTc_FWD_EN |
> @@ -1059,6 +1091,9 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
> terminal = true;
> break;
> case FLOW_ACTION_DROP:
> + /* FLOWSTAT only counts passed frames */
> + stat_veto = true;
> +
> action[2] |= YT921X_ACL_ACTc_FWD_EN |
> YT921X_ACL_ACTc_FWD_REDIR;
> terminal = true;
[ ... ]
> @@ -1143,7 +1182,24 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
> break;
> }
>
> + /* Software counts frames for non-skip_sw rules; a hardware counter
> + * would double count those. Do not assign a counter if the frames may
> + * flow to CPU.
> + */
> + if (!cls->common.skip_sw && !redir)
> + stat_veto = true;
> + if (stat_veto)
> + ruleext->stat_applicable = false;
> + /* Do not reject non-skip_sw rules for hw_stats, see above */
> + if (cls->common.skip_sw && ruleext->stat_required &&
> + !ruleext->stat_applicable) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "HW stats not available for rules that may drop frames");
> + return -EOPNOTSUPP;
> + }
[Severity: Medium]
What happens to a non-skip_sw rule that explicitly asks for immediate
stats and then gets vetoed? For example:
tc filter add dev swp0 ingress flower ... action drop hw_stats immediate
The IMMEDIATE branch sets stat_applicable and stat_required. The
FLOW_ACTION_DROP case then sets stat_veto, and that clears
stat_applicable. The check above only covers skip_sw rules, so the
function returns 0 with stat_required set and stat_applicable clear.
In yt921x_acl_add(), the trap fallback can only be reached when
stat_applicable is true:
if (!ruleext->stat_applicable) {
statid = YT921X_FLOWSTAT_NUM;
} else {
...
} else if (ruleext->stat_required) {
...
use_trap = true;
So the rule goes into hardware as a drop without FLOWSTAT_EN, with no
trap and no extack message. The software flower never sees the frames.
yt921x_dsa_cls_flower_stats()->yt921x_acl_stat() returns -EOPNOTSUPP
because FLOWSTAT_EN is clear.
Won't such a rule always report 0 packets, even though it asked for
immediate stats?
The other veto sources seem to lead to the same result. Examples are a
non-skip_sw police plus redirect rule with hw_stats immediate, DISABLED
or DELAYED hw_stats on another action, and the !redir check after the
loop.
Could this case trap to software, as the pool exhaustion case already
does? If not, could it at least set an extack warning?
[ ... ]
> @@ -1467,6 +1570,42 @@ yt921x_acl_add(struct yt921x_priv *priv,
> }
> }
>
> + if (!ruleext->stat_applicable) {
> + statid = YT921X_FLOWSTAT_NUM;
> + } else {
> + statid = find_first_zero_bit(priv->flowstats_map,
> + YT921X_FLOWSTAT_NUM);
> + if (statid < YT921X_FLOWSTAT_NUM) {
[ ... ]
> + } else if (ruleext->stat_required) {
> + if (!ruleext->r.sw_assisted) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "No more flowstats, but HW stats requested");
> + return -EOPNOTSUPP;
> + }
> + use_trap = true;
> + } else {
> + NL_SET_ERR_MSG_MOD(extack,
> + "No more flowstats, HW stats disabled");
> + }
> + }
> +
> /* Prepare acl block ctrlblk */
> blkid = entid / YT921X_ACL_ENT_PER_BLK;
> binid = entid % YT921X_ACL_ENT_PER_BLK;
[Severity: Low]
This warning goes into extack before several steps in yt921x_acl_add()
that can still fail:
- kvzalloc_obj() returning NULL (-ENOMEM)
- kvmemdup() returning NULL (-ENOMEM)
- yt921x_reg_write(priv, YT921X_ACL_PORT, ctrl) failing
- yt921x_acl_commit() failing
None of these paths set their own extack message.
If one of them fails, won't userspace get the error code together with
"No more flowstats, HW stats disabled"? That would suggest the rule was
offloaded without a counter, when it was not offloaded at all.
Could the warning be set only after the rule has been committed?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202140644.3402265-1-mmyangfl%40gmail.com
Technical Details
Message-ID:
<179630937217.3146.12818780227379034154@kernel.org>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376679-linux-kernel-netdev=dewy.ruReferences:
<20261202140644.3402265-1-mmyangfl@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376679-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4] net: dsa: motorcomm: Add limited ACL flow statistics support Date: Thu, 03 Dec 2026 14:49:32 +0000 Organization: Usenet Network Message-ID: <179630937217.3146.12818780227379034154@kernel.org> References: <20261202140644.3402265-1-mmyangfl@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2518002"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:GVuR41Dw36L9S9iTd4PfHAGn9Ic= sha256:nFlUPQOqTBlUJjMATZNyp0lFheFzIbNqclP2g1ilKaY= sha1:I0HBWDWYtE254Fkf5PTRoJlQogU= sha256:Caf/nfxYKjZwYvlozXDWpOT+SgMHRCvRF+hqwwLr4wY= 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 5C7C6117990; Thu, 3 Dec 2026 17:49:49 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.74 X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.24, 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 Cy4x4O1y6mXr; Thu, 3 Dec 2026 17:49:46 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376679-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id E5721117970; Thu, 3 Dec 2026 17:49:37 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 3B99B6033AC; Thu, 3 Dec 2026 14:49:37 +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=1796309374; b=Eyqkbac56zUc0Q29IOr4P0qs4wQncJYMn4gqO4ZqpoetGuOxDmaKjBUhGWV5P0Y6j2VD ybCv6VJrS5RQ9lZNPefxmrl6IXf+PSBePQFGxE7T2UHdSuraDTlo0skXkjz4hxkxW81oX I+l1vXuxFM0UlkTDGo/iI2tO2OaeOaJKHFLcooh2SUTNvuOnAjidZF+PhCQ9hYiG972tI 4H3hB2+kXkiQ5sMszGqY9E9hfOsQwZnfShj+w7BbbeqN8WDqHyTzCap1Wu+df7qn37sE6 ms07ryf6ZMZtYIKzaK0QJVXQncOiEbGlxMlVjpXcywtGAp/gx76INCM0KwjLR/QymvQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309374; 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=QW+eb7tcU26ggg8Z2r5Xoy3t2zf7S1MV42Xtgk6mOhU=; b=NzLtl+uVVPFvtJQL+WcI/6sBOBKTRcrKVGtHG5cTyvwmdb49r30ioFHNmOhK2RjTNsv5 uXS3u+zRFgnpZD9XFuP4ti+rbk4p17yQ/EA3uLpHacI8ka9kg3lovytjQM9oG4FgNuH86 ypPmzZGkThB5stQsOCICP9YditYRztpQsxhaV3Kmw5nR2IjP1k9zA6pzoO5Lx9Cq2117W tIBPNaC+WloNksXPFZ2XMQO8IrZ8w2JapsHN4uSrDyVWPwP8fLX/RtI+kUMO91Ltm+KGU aeyfZro4QnWV/KTQGWUUwpiMcX6jsDubKIhBcIDKH9aUMh7pqBHPpENHipJldT9sENw== 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=oqfpjfd4; 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 A00C9606A334; Thu, 3 Dec 2026 14:49:34 +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=oqfpjfd4 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=1796309373; b=F6VQwht92QPrrWgOPLmDpfmO0TggF4NZkvuiLs9ELKrX8lyxLQOSlNRA+FmHOesCyZSS KS8Vf7ak34hzP/1ybnZ4r2LJofeQBDVz8pz2qOkBZbiga/iTBQeFSqX090skAKNcrOjsc MCpd2xzo77fLe7779ssgfTA+qcGA047K4CMABitcbJUOKJI7Ul2qst32zcOuAvV7veyYX Cg28cGP+THXHQMEbHbAP/RIxOrhYFjEIkmOl7fR5eATeR/Xs279pZJL8ZK55o5AOi9bdJ Wmw1NP+kmAqW/UqlT0GylVD520mqODS7K8rO6BjYzrjiphFcq5UI7D1Gi5nvgkUtG3g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309373; 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=QW+eb7tcU26ggg8Z2r5Xoy3t2zf7S1MV42Xtgk6mOhU=; b=bhhTvUzc4vkHNTHFoTx9fBRFesyrmodVg+n/38J9QJL/1jlZPMVlRoxmcg3+41mnD8mh 8qU1C3sEDtwZ5QZ71Ywz25VjUp0gXLGlg1/uMw3gkaQ0PrTC9VkuLPa/zLQ1Y40/FBh/p jznyKmqlCYLDj3ZzWkqM7tAyqYwpQ6/dkgW9OSI1FLbz60Ip2/bEXHbIYNrkwPBCt4Nl2 kFzM8/iZz/RB/vyF9Nb0wy0xQpD78cRB7eELxXVW52SH4xRqAYYL6aC9q4aBxkHgL5wWA dpmvlUtReis1T4idi4uzE8V09FI22YxL1FCJA//Lm6RF+Pml3ht3Evo/KFe/BpPKS3Q== 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=oqfpjfd4; 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 BB0ED606A322 for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 14:49:33 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A16D61F000C1; Thu, 3 Dec 2026 14:49:32 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796309373; bh=QW+eb7tcU26ggg8Z2r5Xoy3t2zf7S1MV42Xtgk6mOhU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=oqfpjfd4WeIDg1/4APjytQ9dC/xLghk3LTjpZjb8VZfsh9mChSGBjRuEcsAeZx9FN uH6Z8oruVeoFFJ1loG+fkzzKe3Z2wsxS8qhA1UKfEmDB5VPDgXY91bAN5088IYCe+1 U1KFhKmfxo2eVwWK5DzYoLtj0P59o6PJIrOyO+Y7rg0yJNYN8xy35sA4HSjG9RrUvX wVxd8Eb+FLiiUkhmujqwpqIgl/GQPzvRLFChJ7nXOomH89wDBTgXmPVw8EKzTNb5X/ Km5JN+IoBqOAxZ+N57LdIoXKHsj2z9PY5y5qAlUdFT2jaj4eU0pFh9tMvF5PRqelww IfOGVMmsMe40Q== X-Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com X-In-Reply-To: <20261202140644.3402265-1-mmyangfl@gmail.com> 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