All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v5 net-next 5/9] net: dsa: netc: initialize the group bitmap of ETT and ECT
Date: Fri, 12 Jun 2026 02:13:12 +0000	[thread overview]
Message-ID: <20260612021313.0C5651F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260611021458.2629145-6-wei.fang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ETT/ECT table group size calculation incorrectly uses the number of available ports rather than total physical hardware ports, leading to cross-group table entry overlap and corruption when some ports are unused.
--

commit fef50c5cec2c9c640a1d7dda90141b99f16c02ff
Author: Wei Fang <wei.fang@nxp.com>

net: dsa: netc: initialize the group bitmap of ETT and ECT

Initializes the group index bitmaps for the Egress Treatment Table (ETT) and
Egress Count Table (ECT) based on hardware capabilities. The bitmap size is
calculated by dividing total hardware entries by the number of available ports
for software allocation management.

> diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c
> index fa7dd307ce130..d4475ad7ed6c2 100644
> --- a/drivers/net/dsa/netc/netc_main.c
> +++ b/drivers/net/dsa/netc/netc_main.c
[ ... ]
> +static u32 netc_num_available_ports(struct netc_switch *priv)
> +{
> +	struct dsa_port *dp;
> +	u32 num_ports = 0;
> +
> +	dsa_switch_for_each_available_port(dp, priv->ds)
> +		num_ports++;
> +
> +	return num_ports;
> +}
> +
> +static int netc_init_ntmp_bitmap_sizes(struct netc_switch *priv)
> +{
> +	u32 num_ports = netc_num_available_ports(priv);
> +	struct netc_switch_regs *regs = &priv->regs;
> +	struct ntmp_user *ntmp = &priv->ntmp;
> +	u32 val;
> +
> +	if (!num_ports)
> +		return -EINVAL;
> +
> +	val = netc_base_rd(regs, NETC_ETTCAPR);
> +	ntmp->ett_bitmap_size = NETC_GET_NUM_ENTRIES(val) / num_ports;

[Severity: High]
Does calculating the group size based on the number of available ports rather
than the total physical hardware ports create an issue if some ports are
disabled?

If a board has disabled ports, this will produce a smaller group size. Since
the hardware inherently uses the uncompressed physical port ID to index into
the ETT/ECT during packet egress, could this lead to cross-group table
overlap?

For example, if port 1 is disabled on a 4-port switch, the group size becomes
3. If software programs port 3's configuration at base + 2, but the hardware
accesses base + 3 on packet egress, won't this overlap with the start of the
next group, potentially applying incorrect egress treatments?

> +	if (!ntmp->ett_bitmap_size)
> +		return -EINVAL;
> +
> +	val = netc_base_rd(regs, NETC_ECTCAPR);
> +	ntmp->ect_bitmap_size = NETC_GET_NUM_ENTRIES(val) / num_ports;

[Severity: High]
Similarly, will using the available ports count here cause the same cross-group
boundary overlap issue for the ECT group size during hardware accesses?

> +	if (!ntmp->ect_bitmap_size)
> +		return -EINVAL;
> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260611021458.2629145-1-wei.fang@oss.nxp.com?part=5

  reply	other threads:[~2026-06-12  2:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  2:14 [PATCH v5 net-next 0/9] net: dsa: netc: add bridge mode support wei.fang
2026-06-11  2:14 ` [PATCH v5 net-next 1/9] net: enetc: add interfaces to manage dynamic FDB entries wei.fang
2026-06-11  2:14 ` [PATCH v5 net-next 2/9] net: enetc: add "Update" and "Delete" operations to VLAN filter table wei.fang
2026-06-11  2:14 ` [PATCH v5 net-next 3/9] net: enetc: add interfaces to manage egress treatment table wei.fang
2026-06-11  2:14 ` [PATCH v5 net-next 4/9] net: enetc: add "Update" operation to the egress count table wei.fang
2026-06-11  2:14 ` [PATCH v5 net-next 5/9] net: dsa: netc: initialize the group bitmap of ETT and ECT wei.fang
2026-06-12  2:13   ` sashiko-bot [this message]
2026-06-12  2:29     ` Wei Fang (OSS)
2026-06-11  2:14 ` [PATCH v5 net-next 6/9] net: enetc: add helpers to set/clear table bitmap wei.fang
2026-06-11  2:14 ` [PATCH v5 net-next 7/9] net: dsa: netc: add VLAN filter table and egress treatment management wei.fang
2026-06-12  2:13   ` sashiko-bot
2026-06-12  2:38     ` Wei Fang (OSS)
2026-06-11  2:14 ` [PATCH v5 net-next 8/9] net: dsa: netc: add bridge mode support wei.fang
2026-06-11  2:14 ` [PATCH v5 net-next 9/9] net: dsa: netc: implement dynamic FDB entry ageing wei.fang

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=20260612021313.0C5651F00A3F@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wei.fang@oss.nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.