From: Jens Emil Schulz Ostergaard <jensemil.schulzostergaard@microchip.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <UNGLinuxDriver@microchip.com>, <andrew@lunn.ch>,
<olteanv@gmail.com>, <davem@davemloft.net>, <edumazet@google.com>,
<pabeni@redhat.com>, <horms@kernel.org>, <robh@kernel.org>,
<krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<woojung.huh@microchip.com>, <linux@armlinux.org.uk>,
<Steen.Hegelund@microchip.com>, <daniel.machon@microchip.com>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<devicetree@vger.kernel.org>
Subject: Re: [PATCH net-next v4 7/9] net: dsa: lan9645x: add mac table integration
Date: Tue, 12 May 2026 09:42:29 +0200 [thread overview]
Message-ID: <d7cf71e13ea9a343fe8a285642c00a000c519d96.camel@microchip.com> (raw)
In-Reply-To: <20260506014614.1616825-1-kuba@kernel.org>
On Tue, 2026-05-05 at 18:46 -0700, Jakub Kicinski wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
> net: dsa: lan9645x: add mac table integration
>
> This patch adds MAC table support and hooks it into the DSA FDB callbacks
> (port_fdb_add, port_fdb_del, port_fdb_dump, port_fast_age), along with a
> port-filtered flush path and a GET_NEXT-based dump helper.
>
> > 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 000000000000..7ae23d3464f8
> > --- /dev/null
> > +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_mac.c
>
> [ ... ]
>
> > +void lan9645x_mac_init(struct lan9645x *lan9645x)
> > +{
> > + u32 val;
> > +
> > + mutex_init(&lan9645x->mact_lock);
> > +
> > + /* Clear the MAC table */
> > + lan_wr(ANA_MACACCESS_MAC_TABLE_CMD_SET(CMD_INIT),
> > + lan9645x, ANA_MACACCESS);
> > +
> > + if (lan9645x_rd_poll_timeout(lan9645x, ANA_MACACCESS, val,
> > + ANA_MACACCESS_MAC_TABLE_CMD_GET(val) ==
> > + CMD_IDLE))
> > + dev_err(lan9645x->dev, "mac init timeout\n");
> > +}
>
> Should lan9645x_mac_init() propagate the CMD_INIT timeout instead of
> logging and returning?
>
> It is declared void and the only timeout handling is a dev_err(). The
> caller in lan9645x_setup() invokes it without a return value and then
> proceeds to configure flooding PGIDs, per-port CPU forwarding, and
> register the dsa_switch_ops callbacks (.port_fdb_add, .port_fdb_del,
> .port_fast_age, .port_fdb_dump) while the MAC table command engine may
> still be busy.
>
> For comparison, lan9645x_vlan_init() (called just above in setup) treats
> the structurally identical clear-table timeout as fatal:
>
> lan_wr(ANA_VLANACCESS_VLAN_TBL_CMD_SET(VLANACCESS_CMD_INIT),
> lan9645x, ANA_VLANACCESS);
>
> err = lan9645x_vlan_wait_for_completion(lan9645x);
> if (err) {
> dev_err(lan9645x->dev, "Vlan clear table failed\n");
> return err;
> }
>
> Would returning an int from lan9645x_mac_init() and checking it in
> lan9645x_setup() be more consistent?
>
Yes I think that is a good idea, I will return an error here.
> [ ... ]
>
> > +int lan9645x_mact_dsa_dump(struct lan9645x *lan9645x, int port,
> > + dsa_fdb_dump_cb_t *cb, void *data)
> > +{
> > + u8 mac[ETH_ALEN] __aligned(2);
> > + u32 mach, macl, maca;
> > + int err = 0;
> > + u32 autoage;
> > + u64 addr;
> > + u16 vid;
> > + u8 type;
>
> [ ... ]
>
> > + type = ANA_MACACCESS_ENTRYTYPE_GET(maca);
> > + mach = lan_rd(lan9645x, ANA_MACHDATA);
> > + macl = lan_rd(lan9645x, ANA_MACLDATA);
> > +
> > + if (ANA_MACACCESS_DEST_IDX_GET(maca) == port &&
> > + type == ENTRYTYPE_NORMAL) {
> > + addr = (u64)ANA_MACHDATA_MACHDATA_GET(mach) << 32 |
> > + macl;
> > + u64_to_ether_addr(addr, mac);
> > + vid = ANA_MACHDATA_VID_GET(mach);
> > + if (vid > VLAN_MAX)
> > + vid = 0;
> > +
> > + err = cb(mac, vid, false, data);
> > + if (err)
> > + break;
> > + }
> > + }
>
> Does this filter cause user-added FDB entries to be invisible to
> 'bridge fdb show'?
>
> lan9645x_fdb_add() unconditionally programs entries as ENTRYTYPE_LOCKED:
>
> return lan9645x_mact_learn(lan9645x, dest, addr, vid, ENTRYTYPE_LOCKED);
>
> but the dump above only reports entries matching ENTRYTYPE_NORMAL, so any
> entry installed via 'bridge fdb add dev swpN <mac> self [static]' is
> present in hardware and not reported through port_fdb_dump.
>
> For NTF_SELF entries the DSA core path
> (net/dsa/user.c:dsa_user_port_fdb_do_dump) depends on port_fdb_dump to
> surface entries that are not tracked in the bridge software FDB.
>
> Separately, the callback hardcodes is_static=false for every reported
> entry:
>
> err = cb(mac, vid, false, data);
>
> If the ENTRYTYPE_LOCKED filter is relaxed, would is_static need to be
> derived from the entry type, similar to ocelot_fdb_dump() in
> drivers/net/ethernet/mscc/ocelot.c which uses
> (entry.type == ENTRYTYPE_LOCKED)?
This is intentional, we only dump the dynamically learned entries which
the network stack can not know about. The static entries are already
reported, for instance
bridge fdb add dev swpN <mac> self
will show up on the conduit, and get programmed toward the CPU_PORT in
hardware.
Including these would duplicate entries in bridge fdb show. I will add
a comment about this.
>
> > diff --git a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> > index c99189ce586e..b21e1bf25b0c 100644
> > --- a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> > +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> > @@ -139,6 +140,7 @@ static int lan9645x_setup(struct dsa_switch *ds)
> > err = lan9645x_vlan_init(lan9645x);
> > if (err)
> > return err;
> > + lan9645x_mac_init(lan9645x);
>
> Related to the lan9645x_mac_init() comment above, should this call
> check a return value and abort setup on failure rather than continuing
> to register switch ops with a potentially wedged MAC table engine?
>
Yes I will add this.
> [ ... ]
>
> > +static int lan9645x_fdb_add(struct dsa_switch *ds, int port,
> > + const unsigned char *addr, u16 vid,
> > + struct dsa_db db)
> > +{
> > + struct net_device *br = lan9645x_db2bridge(db);
> > + struct dsa_port *dp = dsa_to_port(ds, port);
> > + struct lan9645x *lan9645x = ds->priv;
> > + int dest;
> > +
> > + if (IS_ERR(br))
> > + return PTR_ERR(br);
> > +
> > + if (dsa_port_is_cpu(dp) && !br &&
> > + dsa_fdb_present_in_other_db(ds, port, addr, vid, db))
> > + return 0;
> > +
> > + if (!vid)
> > + vid = lan9645x_vlan_unaware_pvid(!!br);
> > +
> > + dest = dsa_port_is_cpu(dp) ? PGID_CPU : port;
> > +
> > + return lan9645x_mact_learn(lan9645x, dest, addr, vid, ENTRYTYPE_LOCKED);
> > +}
>
> See the question above about lan9645x_mact_dsa_dump() filtering on
> ENTRYTYPE_NORMAL: entries created here with ENTRYTYPE_LOCKED do not
> appear to be reported by port_fdb_dump.
But they are reported by other means already, so we try to avoid the
duplication.
next prev parent reply other threads:[~2026-05-12 7:42 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 9:34 [PATCH net-next v4 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-04-30 9:34 ` [PATCH net-next v4 1/9] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-06 1:45 ` Jakub Kicinski
2026-05-12 6:28 ` Jens Emil Schulz Ostergaard
2026-04-30 9:34 ` [PATCH net-next v4 2/9] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-04-30 9:34 ` [PATCH net-next v4 3/9] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-04-30 9:34 ` [PATCH net-next v4 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-06 1:45 ` Jakub Kicinski
2026-05-12 7:15 ` Jens Emil Schulz Ostergaard
2026-04-30 9:34 ` [PATCH net-next v4 5/9] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-05-06 1:46 ` Jakub Kicinski
2026-05-12 7:24 ` Jens Emil Schulz Ostergaard
2026-04-30 9:34 ` [PATCH net-next v4 6/9] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-05-06 1:46 ` Jakub Kicinski
2026-05-12 7:29 ` Jens Emil Schulz Ostergaard
2026-04-30 9:34 ` [PATCH net-next v4 7/9] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-05-06 1:46 ` Jakub Kicinski
2026-05-12 7:42 ` Jens Emil Schulz Ostergaard [this message]
2026-04-30 9:34 ` [PATCH net-next v4 8/9] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-05-06 1:46 ` Jakub Kicinski
2026-05-12 7:45 ` Jens Emil Schulz Ostergaard
2026-04-30 9:34 ` [PATCH net-next v4 9/9] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-05-06 1:46 ` Jakub Kicinski
2026-05-06 1:48 ` Jakub Kicinski
2026-05-12 8:47 ` Jens Emil Schulz Ostergaard
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=d7cf71e13ea9a343fe8a285642c00a000c519d96.camel@microchip.com \
--to=jensemil.schulzostergaard@microchip.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--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 \
--cc=robh@kernel.org \
--cc=woojung.huh@microchip.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