From: Lukasz Majewski <lukma@denx.de>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Madalin Bucur <madalin.bucur@oss.nxp.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Joakim Zhang <qiangqing.zhang@nxp.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
netdev@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Mark Einon <mark.einon@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC 2/3] net: Provide switchdev driver for NXP's More Than IP L2 switch
Date: Thu, 24 Jun 2021 12:53:04 +0200 [thread overview]
Message-ID: <20210624125304.36636a44@ktm> (raw)
In-Reply-To: <YNOTKl7ZKk8vhcMR@lunn.ch>
[-- Attachment #1: Type: text/plain, Size: 4389 bytes --]
Hi Andrew,
> > > Using volatile is generally wrong. Why do you need it?
> >
> > This was the code, which I took from the legacy driver. I will
> > adjust it.
>
> It is called 'vendor crap' for a reason.
:-)
>
> > > > + for_each_available_child_of_node(p, port) {
> > > > + if (of_property_read_u32(port, "reg",
> > > > &port_num))
> > > > + continue;
> > > > +
> > > > + priv->n_ports = port_num;
> > > > +
> > > > + fep_np = of_parse_phandle(port, "phy-handle",
> > > > 0);
> > >
> > > As i said, phy-handle points to a phy. It minimum, you need to
> > > call this mac-handle. But that then makes this switch driver very
> > > different to every other switch driver.
> >
> > Other drivers (DSA for example) use "ethernet" or "link" properties.
> > Maybe those can be reused?
>
> Not really. They have well known meanings and they are nothing like
> what you are trying to do. You need a new name. Maybe 'mac-handle'?
Ok.
>
>
> > > > + pdev = of_find_device_by_node(fep_np);
> > > > + ndev = platform_get_drvdata(pdev);
> > > > + priv->fep[port_num - 1] = netdev_priv(ndev);
> > > >
> > >
> > > What happens when somebody puts reg=<42>; in DT?
> >
> > I do guess that this will break the code.
> >
> > However, DSA DT descriptions also rely on the exact numbering [1]
> > (via e.g. reg property) of the ports. I've followed this paradigm.
>
> DSA does a range check:
>
> for_each_available_child_of_node(ports, port) {
> err = of_property_read_u32(port, "reg", ®);
> if (err)
> goto out_put_node;
>
> if (reg >= ds->num_ports) {
> dev_err(ds->dev, "port %pOF index %u exceeds
> num_ports (%zu)\n", port, reg, ds->num_ports);
> err = -EINVAL;
> goto out_put_node;
> }
>
Ok.
> > > I would say, your basic structure needs to change, to make it more
> > > like other switchdev drivers. You need to replace the two FEC
> > > device instances with one switchdev driver.
> >
> > I've used the cpsw_new.c as the example.
> >
> > > The switchdev driver will then
> > > instantiate the two netdevs for the two external MACs.
> >
> > Then there is a question - what about eth[01], which already
> > exists?
>
> They don't exist. cpsw_new is not used at the same time as cpsw, it
> replaces it. This new driver would replace the FEC driver.
I see.
> cpsw_new
> makes use of some of the code in the cpsw driver to implement two
> netdevs. This new FEC switch driver would do the same, make use of
> some of the low level code, e.g. for DMA access, MDIO bus, etc.
I'm not sure if the imx28 switch is similar to one from TI (cpsw-3g)
- it looks to me that the bypass mode for both seems to be very
different. For example, on NXP when switch is disabled we need to
handle two DMA[01]. When it is enabled, only one is used. The approach
with two DMAs is best handled with FEC driver instantiation.
>
> > To be honest - such driver for L2 switch already has been forward
> > ported by me [2] to v4.19.
>
> Which is fine, you can do whatever you want in your own fork. But for
> mainline, we need a clean architecture.
This code is a forward port of vendor's (Freescale) old driver. It uses
the _wrong_ approach, but it can (still) be used in production after
some adjustments.
> I'm not convinced your code is
> that clean,
The code from [2] needs some vendor ioctl based tool (or hardcode) to
configure the switch.
> and how well future features can be added. Do you have
> support for VLANS? Adding and removing entries to the lookup tables?
> How will IGMP snooping work? How will STP work?
This can be easily added with serving netstack hooks (as it is already
done with cpsw_new) in the new switchdev based version [3] (based on
v5.12).
>
> Andrew
Links:
[3] -
https://source.denx.de/linux/linux-imx28-l2switch/-/commits/imx28-v5.12-L2-upstream-switchdev-RFC_v1
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
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:[~2021-06-24 10:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210622144111.19647-1-lukma@denx.de>
[not found] ` <20210622144111.19647-2-lukma@denx.de>
[not found] ` <YNH3mb9fyBjLf0fj@lunn.ch>
2021-06-22 20:51 ` [RFC 1/3] ARM: dts: imx28: Add description for L2 switch on XEA board Lukasz Majewski
2021-06-23 13:17 ` Andrew Lunn
2021-06-23 15:26 ` Lukasz Majewski
2021-06-24 0:36 ` Florian Fainelli
2021-06-24 2:19 ` Joakim Zhang
2021-06-24 11:21 ` Lukasz Majewski
2021-06-25 8:28 ` Joakim Zhang
2021-06-25 10:18 ` Lukasz Majewski
2021-06-24 11:03 ` Lukasz Majewski
[not found] ` <20210622144111.19647-4-lukma@denx.de>
[not found] ` <YNH9YvjqbcHMaUFw@lunn.ch>
2021-06-23 7:48 ` [RFC 3/3] net: imx: Adjust fec_main.c to provide support for L2 switch Lukasz Majewski
[not found] ` <20210622144111.19647-3-lukma@denx.de>
[not found] ` <YNH7vS9FgvEhz2fZ@lunn.ch>
[not found] ` <20210623133704.334a84df@ktm>
[not found] ` <YNOTKl7ZKk8vhcMR@lunn.ch>
2021-06-24 10:53 ` Lukasz Majewski [this message]
2021-06-24 13:34 ` [RFC 2/3] net: Provide switchdev driver for NXP's More Than IP " Andrew Lunn
2021-06-24 14:35 ` Lukasz Majewski
2021-06-24 16:11 ` Andrew Lunn
2021-06-25 9:59 ` Lukasz Majewski
2021-06-25 14:40 ` Andrew Lunn
2021-06-28 12:05 ` Lukasz Majewski
2021-06-28 12:48 ` Vladimir Oltean
2021-06-28 14:13 ` Lukasz Majewski
2021-06-28 14:23 ` Vladimir Oltean
2021-06-29 8:09 ` Lukasz Majewski
2021-06-29 9:30 ` Vladimir Oltean
2021-06-29 12:01 ` Lukasz Majewski
2021-06-28 13:23 ` Andrew Lunn
2021-06-28 14:14 ` Lukasz Majewski
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=20210624125304.36636a44@ktm \
--to=lukma@denx.de \
--cc=andrew@lunn.ch \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=madalin.bucur@oss.nxp.com \
--cc=mark.einon@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=olteanv@gmail.com \
--cc=qiangqing.zhang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox