From: Jens Emil Schulz Ostergaard <jensemil.schulzostergaard@microchip.com>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: <UNGLinuxDriver@microchip.com>, Andrew Lunn <andrew@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Woojung Huh <woojung.huh@microchip.com>,
Russell King <linux@armlinux.org.uk>,
"Steen Hegelund" <Steen.Hegelund@microchip.com>,
Daniel Machon <daniel.machon@microchip.com>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<devicetree@vger.kernel.org>
Subject: Re: [PATCH net-next 5/8] net: dsa: lan9645x: add bridge support
Date: Mon, 9 Mar 2026 13:09:53 +0100 [thread overview]
Message-ID: <1d70dd8d53f976d5f189d4154049129ef0df0c38.camel@microchip.com> (raw)
In-Reply-To: <20260303145130.rbp3qycr3eh5ifcp@skbuf>
On Tue, 2026-03-03 at 16:51 +0200, Vladimir Oltean wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> On Tue, Mar 03, 2026 at 01:22:31PM +0100, Jens Emil Schulz Østergaard wrote:
> > Add support for hardware offloading of the bridge. We support a single
> > bridge device.
> >
> > Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
> > Signed-off-by: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
> > ---
> > drivers/net/dsa/microchip/lan9645x/lan9645x_main.c | 196 +++++++++++++++++++++
> > drivers/net/dsa/microchip/lan9645x/lan9645x_main.h | 11 ++
> > drivers/net/dsa/microchip/lan9645x/lan9645x_port.c | 2 +
> > 3 files changed, 209 insertions(+)
> >
> > diff --git a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> > index 739013f049d0..b6efaf669a3f 100644
> > --- a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> > +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
> > @@ -171,6 +171,8 @@ static int lan9645x_setup(struct dsa_switch *ds)
> > return err;
> > }
> >
> > + mutex_init(&lan9645x->fwd_domain_lock);
> > +
> > /* Link Aggregation Mode: NETDEV_LAG_HASH_L2 */
> > lan_wr(ANA_AGGR_CFG_AC_SMAC_ENA |
> > ANA_AGGR_CFG_AC_DMAC_ENA,
> > @@ -288,6 +290,192 @@ static void lan9645x_port_phylink_get_caps(struct dsa_switch *ds, int port,
> > lan9645x_phylink_get_caps(ds->priv, port, config);
> > }
> >
> > +static int lan9645x_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
> > +{
> > + u32 age_secs = max(1, msecs / 1000 / 2);
>
> s/1000/MSEC_PER_SEC/
>
I will change this.
> > + struct lan9645x *lan9645x = ds->priv;
> > +
> > + /* Entry is must suffer two aging scans before it is removed, so an
>
> "An entry must suffer (...), so it is aged"
I will change this.
>
> > + * entry is aged after 2*AGE_PERIOD, and the unit is in seconds.
> > + * An age period of 0 disables automatic aging.
> > + */
> > + lan_rmw(ANA_AUTOAGE_AGE_PERIOD_SET(age_secs),
> > + ANA_AUTOAGE_AGE_PERIOD,
> > + lan9645x, ANA_AUTOAGE);
> > + return 0;
> > +}
> > +
> > +static int lan9645x_port_pre_bridge_flags(struct dsa_switch *ds, int port,
> > + struct switchdev_brport_flags flags,
> > + struct netlink_ext_ack *extack)
> > +{
> > + if (flags.mask &
> > + ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD))
> > + return -EINVAL;
> > +
> > + return 0;
> > +}
> > +
> > +static void lan9645x_port_pgid_set(struct lan9645x *lan9645x, u16 pgid,
> > + int chip_port, bool enabled)
> > +{
> > + u32 reg_msk, port_msk;
> > +
> > + WARN_ON(chip_port > CPU_PORT);
> > +
> > + port_msk = ANA_PGID_PGID_SET(enabled ? BIT(chip_port) : 0);
> > + reg_msk = ANA_PGID_PGID_SET(BIT(chip_port));
> > +
> > + lan_rmw(port_msk, reg_msk, lan9645x, ANA_PGID(pgid));
> > +}
> > +
> > +static void lan9645x_port_set_learning(struct lan9645x *lan9645x, int port,
> > + bool enabled)
> > +{
> > + struct lan9645x_port *p;
> > +
> > + lan_rmw(ANA_PORT_CFG_LEARN_ENA_SET(enabled), ANA_PORT_CFG_LEARN_ENA,
> > + lan9645x, ANA_PORT_CFG(port));
>
> Actually, the port may be in an STP state where learning shouldn't be
> enabled, when this function is called. Enabling the "learning" bridge
> port flag shouldn't change that.
>
Thank you, I will check stp_state before writing to HW, similar to
set_stp_state.
> > +
> > + p = lan9645x_to_port(lan9645x, port);
> > + p->learn_ena = enabled;
> > +}
> > +
> > +static int lan9645x_port_bridge_flags(struct dsa_switch *ds, int port,
> > + struct switchdev_brport_flags f,
> > + struct netlink_ext_ack *extack)
> > +{
> > + struct lan9645x *l = ds->priv;
>
> Could we have some consistency in variable naming throughout the driver,
> at least for the main private structure? I don't have an issue with it
> being called l, it's just that I would prefer it being called the same
> everywhere.
>
I will use lan9645x everywhere.
> > +
> > + if (WARN_ON(port == l->npi))
> > + return -EINVAL;
> > +
> > + if (f.mask & BR_LEARNING)
> > + lan9645x_port_set_learning(l, port, !!(f.val & BR_LEARNING));
> > +
> > + if (f.mask & BR_FLOOD)
> > + lan9645x_port_pgid_set(l, PGID_UC, port, !!(f.val & BR_FLOOD));
> > +
> > + if (f.mask & BR_MCAST_FLOOD) {
> > + bool ena = !!(f.val & BR_MCAST_FLOOD);
> > +
> > + lan9645x_port_pgid_set(l, PGID_MC, port, ena);
> > + lan9645x_port_pgid_set(l, PGID_MCIPV4, port, ena);
> > + lan9645x_port_pgid_set(l, PGID_MCIPV6, port, ena);
> > + }
> > +
> > + if (f.mask & BR_BCAST_FLOOD)
> > + lan9645x_port_pgid_set(l, PGID_BC, port,
> > + !!(f.val & BR_BCAST_FLOOD));
> > +
> > + return 0;
> > +}
> > diff --git a/drivers/net/dsa/microchip/lan9645x/lan9645x_port.c b/drivers/net/dsa/microchip/lan9645x/lan9645x_port.c
> > index 038868ae0a32..b60c64458957 100644
> > --- a/drivers/net/dsa/microchip/lan9645x/lan9645x_port.c
> > +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_port.c
> > @@ -15,6 +15,8 @@ int lan9645x_port_init(struct lan9645x *lan9645x, int port)
> > ANA_PORT_CFG_LEARN_ENA,
> > lan9645x, ANA_PORT_CFG(p->chip_port));
> >
> > + p->learn_ena = false;
> > +
>
> This is already zero-initialized memory.
Removed.
>
> > lan9645x_port_set_maxlen(lan9645x, port, ETH_DATA_LEN);
> >
> > lan9645x_phylink_port_down(lan9645x, port);
> >
> > --
> > 2.52.0
> >
Thanks,
Emil
next prev parent reply other threads:[~2026-03-09 12:10 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 12:22 [PATCH net-next 0/8] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-03-03 12:22 ` [PATCH net-next 1/8] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-03-03 14:13 ` Andrew Lunn
2026-03-03 15:58 ` Jens Emil Schulz Ostergaard
2026-03-04 15:14 ` Andrew Lunn
2026-03-05 12:59 ` Jens Emil Schulz Ostergaard
2026-03-03 16:11 ` Vladimir Oltean
2026-03-05 13:53 ` Jens Emil Schulz Ostergaard
2026-03-04 15:23 ` Andrew Lunn
2026-03-05 13:01 ` Jens Emil Schulz Ostergaard
2026-03-03 12:22 ` [PATCH net-next 2/8] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-03-03 13:22 ` Vladimir Oltean
2026-03-03 16:00 ` Jens Emil Schulz Ostergaard
2026-03-03 14:18 ` Andrew Lunn
2026-03-03 19:04 ` Conor Dooley
2026-03-04 15:57 ` Jens Emil Schulz Ostergaard
2026-03-05 12:57 ` Jens Emil Schulz Ostergaard
2026-03-05 18:31 ` Conor Dooley
2026-03-06 15:08 ` Jens Emil Schulz Ostergaard
2026-03-06 15:20 ` Conor Dooley
2026-03-18 14:19 ` Jens Emil Schulz Ostergaard
2026-03-18 17:18 ` Conor Dooley
2026-03-18 17:20 ` Conor Dooley
2026-03-18 17:26 ` Christian Marangi
2026-03-24 10:31 ` Jens Emil Schulz Ostergaard
2026-03-04 15:55 ` Jens Emil Schulz Ostergaard
2026-03-03 18:49 ` Conor Dooley
2026-03-04 15:58 ` Jens Emil Schulz Ostergaard
2026-03-03 18:56 ` Conor Dooley
2026-03-04 16:10 ` Jens Emil Schulz Ostergaard
2026-03-04 16:14 ` Vladimir Oltean
2026-03-04 19:06 ` Conor Dooley
2026-03-05 13:08 ` Jens Emil Schulz Ostergaard
2026-03-03 12:22 ` [PATCH net-next 3/8] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-03-03 12:22 ` [PATCH net-next 4/8] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-03-03 14:15 ` Vladimir Oltean
2026-03-04 14:37 ` Jens Emil Schulz Ostergaard
2026-03-04 15:58 ` Russell King (Oracle)
2026-03-05 14:24 ` Jens Emil Schulz Ostergaard
2026-03-05 14:58 ` Andrew Lunn
2026-03-05 15:10 ` Vladimir Oltean
2026-03-05 16:54 ` Alexander Stein
2026-03-05 17:37 ` Andrew Lunn
2026-03-06 15:03 ` Jens Emil Schulz Ostergaard
2026-03-06 16:33 ` Andrew Lunn
2026-03-09 12:01 ` Jens Emil Schulz Ostergaard
2026-03-06 14:22 ` Russell King (Oracle)
2026-03-06 21:03 ` Jakub Kicinski
2026-03-03 12:22 ` [PATCH net-next 5/8] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-03-03 14:20 ` Vladimir Oltean
2026-03-03 16:08 ` Jens Emil Schulz Ostergaard
2026-03-03 16:17 ` Vladimir Oltean
2026-03-05 13:14 ` Jens Emil Schulz Ostergaard
2026-03-03 14:51 ` Vladimir Oltean
2026-03-09 12:09 ` Jens Emil Schulz Ostergaard [this message]
2026-03-03 12:22 ` [PATCH net-next 6/8] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-03-03 14:59 ` Vladimir Oltean
2026-03-04 14:40 ` Jens Emil Schulz Ostergaard
2026-03-04 14:52 ` Vladimir Oltean
2026-03-03 12:22 ` [PATCH net-next 7/8] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-03-03 15:27 ` Vladimir Oltean
2026-03-04 15:23 ` Jens Emil Schulz Ostergaard
2026-03-04 15:34 ` Andrew Lunn
2026-03-05 13:17 ` Jens Emil Schulz Ostergaard
2026-03-03 12:22 ` [PATCH net-next 8/8] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-03-03 16:01 ` Vladimir Oltean
2026-03-03 20:21 ` Andrew Lunn
2026-03-04 15:51 ` Jens Emil Schulz Ostergaard
2026-03-04 15:50 ` 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=1d70dd8d53f976d5f189d4154049129ef0df0c38.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