From: Lukasz Majewski <lukma@denx.de>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
davem@davemloft.net, Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Richard Cochran <richardcochran@gmail.com>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 4/4] net: mtip: The L2 switch driver for imx287
Date: Mon, 7 Apr 2025 11:42:39 +0200 [thread overview]
Message-ID: <20250407114239.193cd217@wsk> (raw)
In-Reply-To: <33394d5b-9a67-4acc-bdd1-bf43dc3bd8ab@lunn.ch>
[-- Attachment #1: Type: text/plain, Size: 3683 bytes --]
Hi Andrew,
> > +struct switch_enet_private *mtip_netdev_get_priv(const struct
> > net_device *ndev) +{
> > + if (ndev->netdev_ops == &mtip_netdev_ops)
> > + return netdev_priv(ndev);
> > +
> > + return NULL;
> > +}
>
> > +static bool mtip_port_dev_check(const struct net_device *ndev)
> > +{
> > + if (!mtip_netdev_get_priv(ndev))
> > + return false;
> > +
> > + return true;
> > +}
> > +
>
> Rearranging the code a bit to make my point....
>
> mtip_port_dev_check() tells us if this ndev is one of the ports of
> this switch.
>
> > +/* netdev notifier */
> > +static int mtip_netdevice_event(struct notifier_block *unused,
> > + unsigned long event, void *ptr)
> > +{
> > + struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
> > + struct netdev_notifier_changeupper_info *info;
> > + int ret = NOTIFY_DONE;
> > +
> > + if (!mtip_port_dev_check(ndev))
> > + return NOTIFY_DONE;
>
> We have received a notification about some interface. This filters out
> all but the switches interfaces.
>
> > +
> > + switch (event) {
> > + case NETDEV_CHANGEUPPER:
> > + info = ptr;
>
> CHANGERUPPER is that a netdev has been added or removed from a bridge,
> or some other sort of master device, e.g. a bond.
>
> > +
> > + if (netif_is_bridge_master(info->upper_dev)) {
> > + if (info->linking)
> > + ret = mtip_ndev_port_link(ndev,
> > +
> > info->upper_dev);
>
> Call mtip_ndev_port_link() has been added to some bridge.
>
> > +static int mtip_ndev_port_link(struct net_device *ndev,
> > + struct net_device *br_ndev)
> > +{
> > + struct mtip_ndev_priv *priv = netdev_priv(ndev);
> > + struct switch_enet_private *fep = priv->fep;
> > +
> > + dev_dbg(&ndev->dev, "%s: ndev: %s br: %s fep: 0x%x\n",
> > + __func__, ndev->name, br_ndev->name, (unsigned
> > int)fep); +
> > + /* Check if MTIP switch is already enabled */
> > + if (!fep->br_offload) {
> > + if (!priv->master_dev)
> > + priv->master_dev = br_ndev;
> > +
> > + fep->br_offload = 1;
> > + mtip_switch_dis_port_separation(fep);
> > + mtip_clear_atable(fep);
> > + }
>
> So lets consider
>
> ip link add br0 type bridge
> ip link add br1 type bridge
> ip link set dev lan1 master br0
>
> We create two bridges, and add the first port to one of the bridges.
>
> fep->br_offload should be False
> priv->master_dev should be NULL.
>
> So fep->br_offload is set to 1, priv->master_dev is set to br0 and the
> separation between the ports is removed.
>
> It seems like the hardware will now be bridging packets between the
> two interfaces, despite lan2 not being a member of any bridge....
>
> Now
>
> ip link set dev lan2 master br1
>
> I make the second port a member of some other bridge. fep->br_offload
> is True, so nothing happens.
>
> This is why i said this code needs expanding.
>
> If you look at other switch drivers, you will see each port keeps
> track of what bridge it has been joined to. There is then logic which
> iterates over the ports, finds which ports are members of the same
> bridge, and enables packets to flow between those ports.
>
> With only two ports, you can make some simplifications, but you should
> only disable the separation once both ports are the member of the same
> bridge.
>
I think that I do have your point. Thanks for the info.
> Andrew
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2025-04-07 9:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 10:31 [PATCH v3 0/4] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski
2025-03-31 10:31 ` [PATCH v3 1/4] dt-bindings: net: Add MTIP L2 switch description Lukasz Majewski
2025-03-31 18:13 ` Fabio Estevam
2025-03-31 19:11 ` Lukasz Majewski
2025-03-31 23:55 ` Rob Herring
2025-04-01 10:35 ` Lukasz Majewski
2025-04-01 23:03 ` Rob Herring
2025-04-02 9:09 ` Lukasz Majewski
2025-03-31 10:31 ` [PATCH v3 2/4] ARM: dts: nxp: mxs: Adjust the imx28.dtsi " Lukasz Majewski
2025-04-02 12:22 ` Andrew Lunn
2025-03-31 10:31 ` [PATCH v3 3/4] ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch Lukasz Majewski
2025-03-31 20:53 ` Stefan Wahren
2025-03-31 21:43 ` Lukasz Majewski
2025-03-31 10:31 ` [PATCH v3 4/4] net: mtip: The L2 switch driver for imx287 Lukasz Majewski
2025-04-02 12:47 ` Andrew Lunn
2025-04-06 21:24 ` Lukasz Majewski
2025-04-02 17:06 ` Andrew Lunn
2025-04-02 17:25 ` Andrew Lunn
2025-04-07 9:42 ` Lukasz Majewski [this message]
2025-03-31 17:10 ` [PATCH v3 0/4] net: mtip: Add support for MTIP imx287 L2 switch driver Jakub Kicinski
2025-03-31 19:11 ` Lukasz Majewski
2025-03-31 20:38 ` Stefan Wahren
2025-03-31 21:42 ` Lukasz Majewski
2025-04-01 16:33 ` Stefan Wahren
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=20250407114239.193cd217@wsk \
--to=lukma@denx.de \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).