net: dsa: yt922x: Add support for Motorcomm YT922x
Subsystems (3)
v3 cover net: dsa: yt922x: Add support for Motorcomm YT922x
Motorcomm YT922x is a series of ethernet switches including:
- YT9224: 4 * 2.5G UTPs and 2 serdes interface
This patch just add basic func for a working DSA switch.
v3:
1. Post the driver as a patchset.
2. Remove unnecessary macros.
3. Add mib_working to indicate whether the MIB has been initialized.
4. Fix any errors found
v2: https://lore.kernel.org/all/[email protected]
1. Seperate tag_yt922x into an individual file.
2. Fix the issues from the previous version.
3. Optimize the code style to keep it consistent with the existing code style.
v1: https://lore.kernel.org/all/[email protected]
1. Add basic functional interfaces for the YT922X DSA driver.
2. Although the DSA driver supports both YT922X and YT921X simultaneously, the original file names are still maintained for now;
the file naming may be optimized in the future.
3. Currently, the dsa_switch_ops structure is employed as the operational interface. In future phases, as functionality expands, the architecture will be refactored to introduce yt922x_dsa_ops, where chip-specific operations will be distinguished between YT922X and YT921X, following a design pattern commonly adopted by other existing multi-series DSA drivers.
4. A new thread(patch series) is created. Although a previous version was submitted, the changes are substantial, so the old version is not relevant for reference.
Kyle Switch (2):
net: dsa: tag_yt922x: add support for Motorcomm YT922x tags
net: dsa: Add support for Motorcomm YT922x
drivers/net/dsa/Kconfig | 7 +- drivers/net/dsa/Makefile | 2 +- drivers/net/dsa/yt921x.c | 821 ++++++++++++++++++++++++++++++++++++++- drivers/net/dsa/yt921x.h | 104 +++++ include/net/dsa.h | 2 + net/dsa/Kconfig | 6 + net/dsa/Makefile | 1 + net/dsa/tag_yt922x.c | 111 ++++++ 8 files changed, 1035 insertions(+), 19 deletions(-) create mode 100644 net/dsa/tag_yt922x.c
Signature · 1 line
2.25.1
PATCH v3 1/2 net: dsa: tag_yt922x: add support for Motorcomm YT922x tags
For the Motorcomm YT922x series, tag are supported, and with a default TPID(Tag Protocol Identifier) 0x9988, and the tag occupies 8 bytes.
--- include/net/dsa.h | 2 + net/dsa/Kconfig | 6 +++ net/dsa/Makefile | 1 + net/dsa/tag_yt922x.c | 111 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 net/dsa/tag_yt922x.c
include/net/dsa.h +2 -0
@@ -61,6 +61,7 @@ struct tc_action;#define DSA_TAG_PROTO_NETC_VALUE 33#define DSA_TAG_PROTO_KSZ8463_VALUE 34#define DSA_TAG_PROTO_MT7628_VALUE 35 +#define DSA_TAG_PROTO_YT922X_VALUE 36enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -99,6 +100,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_NETC =DSA_TAG_PROTO_NETC_VALUE ,DSA_TAG_PROTO_KSZ8463 =DSA_TAG_PROTO_KSZ8463_VALUE ,DSA_TAG_PROTO_MT7628 =DSA_TAG_PROTO_MT7628_VALUE , + DSA_TAG_PROTO_YT922X = DSA_TAG_PROTO_YT922X_VALUE, };struct dsa_switch ;
net/dsa/Kconfig +6 -0
@@ -227,4 +227,10 @@ config NET_DSA_TAG_YT921X Say Y or M if you want to enable support for tagging frames for Motorcomm YT921x switches. +config NET_DSA_TAG_YT922X + tristate "Tag driver for Motorcomm YT922x switches" + help + Say Y or M if you want to enable support for tagging frames for + Motorcomm YT922x switches. + endif
net/dsa/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o obj-$(CONFIG_NET_DSA_TAG_YT921X) += tag_yt921x.o +obj-$(CONFIG_NET_DSA_TAG_YT922X) += tag_yt922x.o # for tracing framework to find trace.h CFLAGS_trace.o := -I$(src)
net/dsa/tag_yt922x.c new file +111 -0
111 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 2/2 net: dsa: Add support for Motorcomm YT922x
In reply to Kyle SwitchMotorcomm YT922x is a series of ethernet switches including:
- YT9224: 4 * 2.5G UTPs and 2 serdes interface
This patch just add basic func for a working DSA switch.
--- drivers/net/dsa/Kconfig | 7 +- drivers/net/dsa/Makefile | 2 +- drivers/net/dsa/yt921x.c | 821 ++++++++++++++++++++++++++++++++++++++- drivers/net/dsa/yt921x.h | 104 +++++ 4 files changed, 915 insertions(+), 19 deletions(-)
drivers/net/dsa/Kconfig +4 -3
@@ -169,11 +169,12 @@ config NET_DSA_VITESSE_VSC73XX_PLATFORM and VSC7398 SparX integrated ethernet switches, connected over a CPU-attached address bus and work in memory-mapped I/O mode. -config NET_DSA_YT921X - tristate "Motorcomm YT9215 ethernet switch chip support" +config NET_DSA_YT92XX + tristate "Motorcomm YT9215 and YT9224 ethernet switch chip support" select NET_DSA_TAG_YT921X + select NET_DSA_TAG_YT922X select NET_IEEE8021Q_HELPERS if DCB help - This enables support for the Motorcomm YT9215 ethernet switch + This enables support for the Motorcomm YT9215 and YT9224 ethernet switch chip. endmenu
drivers/net/dsa/Makefile +1 -1
@@ -15,7 +15,7 @@ obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM) += vitesse-vsc73xx-platform.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o -obj-$(CONFIG_NET_DSA_YT921X) += yt921x.o +obj-$(CONFIG_NET_DSA_YT92XX) += yt921x.o obj-y += b53/ obj-y += hirschmann/ obj-y += lantiq/
drivers/net/dsa/yt921x.c +806 -15
937 lines not on this page · raw message
drivers/net/dsa/yt921x.h +104 -0
137 lines not on this page · raw message
Signature · 1 line
2.25.1
Andrew Lunn
maintainerRe: [PATCH v3 net-next 2/2] net: dsa: Add support for Motorcomm YT922x
Quoted 5 lines · Kyle Switch
Motorcomm YT922x is a series of ethernet switches including:
- YT9224: 4 * 2.5G UTPs and 2 serdes interface
This patch just add basic func for a working DSA switch.
I asked you to break this patch up. I want to see lots of little patches, each with a good commit messages, each obviously correct.
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
says you can have a patch series of up to 15 patches.
drivers/net/dsa/yt921x.c yt921x_intif_write(struct yt921x_priv *priv, int port, int reg, u16 val) · line 576
Quoted 11 lines
static int
yt921x_mbus_int_read(struct mii_bus *mbus, int port, int reg){drivers/net/dsa/yt921x.c +3
-1struct yt921x_priv *priv = mbus->priv; +int max_ports;u16 val;int res; -if (port >=YT921X_PORT_NUM ) + max_ports = priv->series_info->ports; +if (port >= max_ports)return U16_MAX ;
What did i say about this in my last review? This would make a good, simple patch, changing all YT921X_PORT_NUM to priv->series_info->ports.
You first need a simple patch which adds struct yt92xx_series and yt92xx_series_table[] with very minimal contents, only mode and name, for the existing device. And add the code to do the lookup and associate it to priv.
Then you can have a patch which adds .ports, and changes all YT921X_PORT_NUM to priv->series_info->ports.
Then you can add .num_lag_ids and change all those references.
Then you can add .ageing_time_FOO and change all those references.
Slowly make the existing code more generic by adding to struct yt92xx_series.
Andrew
---
pw-bot: cr
Re: [PATCH v3 net-next 2/2] net: dsa: Add support for Motorcomm YT922x
Quoted 35 lines · Andrew Lunn
Quoted 5 lines · Kyle Switch
Motorcomm YT922x is a series of ethernet switches including:
- YT9224: 4 * 2.5G UTPs and 2 serdes interface
This patch just add basic func for a working DSA switch.
I asked you to break this patch up. I want to see lots of little patches, each with a good commit messages, each obviously correct.
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
says you can have a patch series of up to 15 patches.
drivers/net/dsa/yt921x.c yt921x_intif_write(struct yt921x_priv *priv, int port, int reg, u16 val) · line 576
Quoted 11 lines
static int yt921x_mbus_int_read(struct mii_bus *mbus, int port, int reg) { struct yt921x_priv *priv = mbus->priv;drivers/net/dsa/yt921x.c +3
-1+int max_ports;u16 val;int res; -if (port >=YT921X_PORT_NUM ) + max_ports = priv->series_info->ports; +if (port >= max_ports)return U16_MAX ;What did i say about this in my last review? This would make a good, simple patch, changing all
YT921X_PORT_NUMtopriv->series_info->ports.You first need a simple patch which adds struct
yt92xx_seriesand yt92xx_series_table[] with very minimal contents, only mode and name, for the existing device. And add the code to do the lookup and associate it to priv.Then you can have a patch which adds .ports, and changes all
YT921X_PORT_NUMtopriv->series_info->ports.
Quoted 8 lines
Then you can add .num_lag_ids and change all those references.
Then you can add .ageing_time_FOO and change all those references.
Slowly make the existing code more generic by adding to struct
yt92xx_series.Andrew
Ans: We intend to split this patch into smaller functional pieces and submit them as separate commits.
I would also like to seek your advice on a design question.
For the yt92xx_series_info table, the maveall reference design invokes chip_detect() inside probe() to perform the matching lookup. However, in the existing yt921x DSA driver, chip_detect() is called within dsa_setup() instead.
We are considering two possible approaches:
1. Keep the code as-is and relocate the initialization of certain dsa_switch structure parameters into dsa_setup().
2. Refactor by moving chip_detect() into probe() to align with the reference design.
Which of these two approaches would you lean toward, and what are your considerations?
Quoted 2 lines
---
pw-bot: cr
Andrew Lunn
maintainerRe: [PATCH v3 net-next 2/2] net: dsa: Add support for Motorcomm YT922x
Quoted 6 lines
I would also like to seek your advice on a design question. For the
yt92xx_series_infotable, the maveall reference design invokeschip_detect()insideprobe()to perform the matching lookup. However, in the existing yt921x DSA driver,chip_detect()is called withindsa_setup()instead.
Quoted 8 lines
We are considering two possible approaches:
1. Keep the code as-is and relocate the initialization of certaindsa_switchstructure parameters intodsa_setup().
2. Refactor by movingchip_detect()intoprobe()to align with the reference design.Which of these two approaches would you lean toward, and what are your considerations?
There is some advantage in postponing as much as possible to later. The DSA design when used with MDIO to control the switch has a chicken/egg problem.
The conduit MAC driver probes, and first creates its MDIO bus. The bus is walked and the devices on the bus probe. Meaning the switch driver probes. At this time, if you can detect if the switch exists, cheaply, do it, so you can return -ENODEV. However, don't do anything expensive, because... the switch driver registers the switch with the DSA framework. The DSA core pokes around in the DT description and looks for the phandle to the conduit interface. It wants to take a reference on the interface, but finds it does not exist yet. So the DSA core returns -EPROBE_DEFER. The switch probe unwinds, and returns -EPROBE_DEFER.
The registration of the MDIO bus completes, without error, because bus and devices on the bus have different lifetimes. This allows the MAC driver to continue and it will eventually register the interface.
Sometime later the driver core will reprobe the switch, and this time it succeeds.
So avoid doing expensive things early in probe, because you will have to do it again later.
Andrew