Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jensemil.schulzostergaard@microchip.com
Cc: UNGLinuxDriver@microchip.com, andrew@lunn.ch, olteanv@gmail.com,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, linux@armlinux.org.uk,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 3/5] net: dsa: lan9645x: add mac table integration
Date: Wed, 25 Nov 2026 08:58:27 +0000	[thread overview]
Message-ID: <179559710763.3135.13351843539834779917@kernel.org> (raw)
In-Reply-To: <20261124-dsa-lan9645x-add-vlan-and-bridge-offload-v1-3-b930a1dae700@microchip.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] __lan9645x_mact_learn() in
  drivers/net/dsa/microchip/lan9645x/lan9645x_mac.c decides whether a…

--

net: dsa: lan9645x: add mac table integration

This commit adds MAC table support to the lan9645x DSA driver and wires
up port_fast_age, port_fdb_dump, port_fdb_add and port_fdb_del. It also
enables FDB isolation and assisted learning on the CPU port. A CPU learn
failure flagged in ANA_ANEVENTS.CPU_LEARN_FAILED is reported as -ENOSPC.

> diff --git a/drivers/net/dsa/microchip/lan9645x/lan9645x_mac.c b/drivers/net/dsa/microchip/lan9645x/lan9645x_mac.c
> new file mode 100644
> index 0000000000000..9da03d0369f5d
> --- /dev/null
> +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_mac.c

[ ... ]

> +static int __lan9645x_mact_learn(struct lan9645x *lan9645x, int port,
> +				 const unsigned char mac[ETH_ALEN],
> +				 unsigned int vid,
> +				 enum macaccess_entry_type type,
> +				 bool cpu_copy)
> +{
> +	int err;
> +
> +	lockdep_assert_held(&lan9645x->mact_lock);
> +
> +	lan9645x_mac_select(lan9645x, mac, vid);
> +
> +	lan_wr(ANA_MACACCESS_VALID_SET(1) |
> +	       ANA_MACACCESS_DEST_IDX_SET(port) |
> +	       ANA_MACACCESS_MAC_CPU_COPY_SET(cpu_copy) |
> +	       ANA_MACACCESS_ENTRYTYPE_SET(type) |
> +	       ANA_MACACCESS_MAC_TABLE_CMD_SET(CMD_LEARN),
> +	       lan9645x, ANA_MACACCESS);
> +
> +	err = lan9645x_mac_wait_for_completion(lan9645x, NULL);
> +	if (err)
> +		return err;
> +
> +	if (ANA_ANEVENTS_CPU_LEARN_FAILED_GET(lan_rd(lan9645x, ANA_ANEVENTS))) {
> +		lan_wr(ANA_ANEVENTS_CPU_LEARN_FAILED, lan9645x, ANA_ANEVENTS);
> +		return -ENOSPC;
> +	}

[Severity: Low]
Could a stale CPU_LEARN_FAILED bit cause a spurious -ENOSPC here?

CPU_LEARN_FAILED is a sticky write-one-to-clear bit. The only
unconditional clear is in lan9645x_mac_init(), after CMD_INIT. The only
other clear is on this failure path. Nothing clears the bit before
CMD_LEARN is written to ANA_MACACCESS.

Two cases can leave the bit set:

  - An earlier learn takes the early return because
    lan9645x_mac_wait_for_completion() timed out or got a read error.
    That skips the ANEVENTS check. If the learn later finishes in
    hardware and fails, the bit stays set.

  - The lan_rd() or lan_wr() of ANA_ANEVENTS fails. Both only
    WARN_ON_ONCE on regmap errors.

The next, unrelated learn under mact_lock would then see the stale bit,
clear it and return -ENOSPC. The hardware will still have installed the
new LOCKED entry.

For host addresses on the CPU port, the chain is:

  lan9645x_fdb_add()
    lan9645x_mact_learn()
      __lan9645x_mact_learn()  -> -ENOSPC

Because of that error, dsa_port_do_fdb_add() does not record the
address. A later delete gets -ENOENT from dsa_mac_addr_find() and never
calls .port_fdb_del. The LOCKED entry that points at PGID_CPU would stay
in the MAC table. It never ages out and it takes one of the four buckets
in its row.

The mdb code added later in the series ("net: dsa: lan9645x: add mdb
management") goes through the same lan9645x_mact_learn() path.

Would it help to write ANA_ANEVENTS_CPU_LEARN_FAILED just before issuing
CMD_LEARN? Then the bit would only reflect the current command.

> +
> +	return 0;
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124-dsa-lan9645x-add-vlan-and-bridge-offload-v1-0-b930a1dae700%40microchip.com

  reply	other threads:[~2026-11-25  8:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  8:57 [PATCH net-next 0/5] net: dsa: lan9645x: add VLAN and bridge offload Jens Emil Schulz Østergaard
2026-11-24  8:57 ` [PATCH net-next 1/5] net: dsa: lan9645x: add the analyzer event register Jens Emil Schulz Østergaard
2026-11-24  8:57 ` [PATCH net-next 2/5] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-11-24  8:57 ` [PATCH net-next 3/5] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-11-25  8:58   ` netdev-bot+sashiko [this message]
2026-11-24  8:57 ` [PATCH net-next 4/5] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-11-25  8:58   ` netdev-bot+sashiko
2026-11-24  8:57 ` [PATCH net-next 5/5] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-11-25  8:58   ` netdev-bot+sashiko

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=179559710763.3135.13351843539834779917@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jensemil.schulzostergaard@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --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