Skip to content

net: dsa: realtek: variants to drivers, interfaces to a common module

Luiz Angelo Daros de Luca lkml netdev 6 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected] change-id 20240127-realtek_reverse-1b6021490c85

Versions newest first

  1. v6 Latest11 patches 14 repliesApplied 11/11
  2. v511 patches 9 repliesSuperseded inferred link
  3. v411 patches 27 repliesSuperseded inferred link
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v38 patches31 repliesSuperseded inferred link
v27 patches29 repliesSuperseded inferred link
v17 patches26 repliesSuperseded

Changes in v6 from the cover letter

- Renamed realtek-dsa to realtek_dsa to match loaded module name
- More kdocs fixes
- Calls rtl83xx_remove on error after a successful rtl83xx_probe
- Use struct dsa_switch *ds instead of priv->ds
- Link to v5: https://lore.kernel.org/r/[email protected]

Patches in v6 All 11 applied

#Subject and filesSizeRepliesApplied
1/11net: dsa: realtek: drop cleanup from realtek_opsdrivers/net/dsa/realtek/realtek.h+0 -10 repliesApplied
2/11net: dsa: realtek: introduce REALTEK_DSA namespacedrivers/net/dsa/realtek/realtek-mdio.c drivers/net/dsa/realtek/realtek-smi.c drivers/net/dsa/realtek/rtl8365mb.c +2 more+15 -111 replyApplied
3/11net: dsa: realtek: convert variants into real driversdrivers/net/dsa/realtek/Kconfig drivers/net/dsa/realtek/realtek-mdio.c drivers/net/dsa/realtek/realtek-mdio.h +4 more+292 -731 replyApplied
4/11net: dsa: realtek: keep variant reference in realtek_privdrivers/net/dsa/realtek/realtek-mdio.c drivers/net/dsa/realtek/realtek-smi.c drivers/net/dsa/realtek/realtek.h+7 -121 replyApplied
5/11net: dsa: realtek: common rtl83xx moduledrivers/net/dsa/realtek/Makefile drivers/net/dsa/realtek/realtek-mdio.c drivers/net/dsa/realtek/realtek-smi.c +5 more+322 -2731 replyApplied
6/11net: dsa: realtek: merge rtl83xx and interface modules into realtek_dsadrivers/net/dsa/realtek/Kconfig drivers/net/dsa/realtek/Makefile drivers/net/dsa/realtek/realtek-mdio.c +2 more+12 -141 replyApplied
7/11net: dsa: realtek: get internal MDIO node by namedrivers/net/dsa/realtek/realtek-smi.c+1 -11 replyApplied
8/11net: dsa: realtek: clean user_mii_bus setupdrivers/net/dsa/realtek/realtek-smi.c+3 -101 replyApplied
9/11net: dsa: realtek: migrate user_mii_bus setup to realtek_dsadrivers/net/dsa/realtek/realtek-smi.c drivers/net/dsa/realtek/rtl83xx.c drivers/net/dsa/realtek/rtl83xx.h+70 -561 replyApplied
10/11net: dsa: realtek: use the same mii bus driver for both interfacesdrivers/net/dsa/realtek/realtek-mdio.c drivers/net/dsa/realtek/realtek-smi.c drivers/net/dsa/realtek/realtek.h +3 more+14 -971 replyApplied
11/11net: dsa: realtek: embed dsa_switch into realtek_privdrivers/net/dsa/realtek/realtek.h drivers/net/dsa/realtek/rtl8365mb.c drivers/net/dsa/realtek/rtl8366rb.c +1 more+19 -161 replyApplied

Reviews trailers per patch

All 11 patches have a Reviewed-by or Acked-by.

PatchAlvin ŠipragaFlorian FainelliLinus WalleijVladimir Oltean
SeriesT-b
1/11R-b R-b R-b R-b
2/11R-b R-b R-b
3/11R-b R-b
4/11R-b R-b R-b
5/11R-b
6/11R-b R-b R-b
7/11R-b R-b R-b
8/11R-b R-b
9/11R-b
10/11R-b R-b
11/11R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v6 thread

Cover letter [PATCH net-next v6 00/11] net: dsa: realtek: variants to drivers, interfaces to a common module

The current driver consists of two interface modules (SMI and MDIO) and two family/variant modules (RTL8365MB and RTL8366RB). The SMI and MDIO modules serve as the platform and MDIO drivers, respectively, calling functions from the variant modules. In this setup, one interface module can be loaded independently of the other, but both variants must be loaded (if not disabled at build time) for any type of interface. This approach doesn't scale well, especially with the addition of more switch variants (e.g., RTL8366B), leading to loaded but unused modules. Additionally, this also seems upside down, as the specific driver code normally depends on the more generic functions and not the other way around.

Each variant module was converted into real drivers, serving as both a platform driver (for switches connected using the SMI interface) and an MDIO driver (for MDIO-connected switches). The relationship between the variant and interface modules is reversed, with the variant module now calling both interface functions (if not disabled at build time). While in most devices only one interface is likely used, the interface code is significantly smaller than a variant module, consuming fewer resources than the previous code. With variant modules now functioning as real drivers, compatible strings are published only in a single variant module, preventing conflicts.

The patch series introduces a new common module for functions shared by both variants. This module also absorbs the two previous interface modules, as they would always be loaded anyway.

The series relocates the user MII driver from realtek-smi to rtl83xx. It is now used by MDIO-connected switches instead of the generic DSA driver. There's a change in how this driver locates the MDIO node. It now only searches for a child node named "mdio".

The dsa_switch in realtek_priv->ds is now embedded in the struct. It is always in use and avoids dynamic memory allocation.

Testing has been performed with an RTL8367S (rtl8365mb) using MDIO interface and an RTL8366RB (rtl8366) with SMI interface.

Luiz

---

Changes in v2:
- Renamed realtek_common module to realtek-dsa.
- Removed the warning when the MDIO node is not named "mdio."
- ds->user_mii_bus is only assigned if all user ports do not have a phy-handle.
- of_node_put is now back to the driver remove method.
- Renamed realtek_common_probe_{pre,post} to realtek_common_{probe,register_switch}.
- Added some comments for realtek_common_{probe,register_switch}.
- Using dev_err_probe whenever possible.
- Embedded priv->ds into realtek_priv, removing its dynamic allocation.
- Fixed realtek-common.h macros.
- Save and check the return value in functions, even when it is the last one.
- Added the #if expression as a comment to #else and #endif in header files.
- Unregister the platform and the MDIO driver in the reverse order they are registered.
- Unregister the first driver if the second one failed to register.
- Added the revert patch for "net: dsa: OF-ware slave_mii_bus."
- Link to v1: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Look for the MDIO bus searching for a child node named "mdio" instead of the compatible string.
- Removed the check for a phy-handle in ports. ds->user_mii_bus will not be used anymore.
- Dropped comments for realtek_common_{probe,register_switch}.
- Fixed a compile error in "net: dsa: OF-ware slave_mii_bus".
- Used the wrapper realtek_smi_driver_register instead of platform_driver_register.
- Link to v2: https://lore.kernel.org/r/[email protected]/

Changes in v4:
- Changed Makefile to use ifdef instead of dynamic variable names.
- Added comments for all exported symbols.
- Migrated exported symbols to REALTEK_DSA namespace.
- renamed realtek_common to rtl83xx.
- put the mdio node just after registration and not in driver remove.
- rtl83xx_probe now receives a struct with regmap read/write functions and build regmap_config dynamically.
- pulled into a new patch the realtek_priv change from "common realtek-dsa module".
- pulled into a new patch the user_mii_bus setup changes from "migrate user_mii_bus setup to realtek-dsa".
- removed the revert "net: dsa: OF-ware slave_mii_bus" patch from the series.
- Link to v3: https://lore.kernel.org/r/[email protected]/

Changes in v5:
- Removed empty line at the end of files
- Multiple kdoc fixes
- added rtl83xx_unregister_switch and rtl83xx_shutdown
- moved include <linux/regmap.h> from rtl83xx.h to rtl83xx.c
- moved dev_set_drvdata to the end of rtl83xx_probe()
- changed mii_user bus is name to devicename(switch):user_mii
- Link to v4: https://lore.kernel.org/all/[email protected]/

Changes in v6:
- Renamed realtek-dsa to realtek_dsa to match loaded module name
- More kdocs fixes
- Calls rtl83xx_remove on error after a successful rtl83xx_probe
- Use struct dsa_switch *ds instead of priv->ds
- Link to v5: https://lore.kernel.org/r/[email protected]

---
Luiz Angelo Daros de Luca (11):
net: dsa: realtek: drop cleanup from realtek_ops
net: dsa: realtek: introduce REALTEK_DSA namespace
net: dsa: realtek: convert variants into real drivers
net: dsa: realtek: keep variant reference in realtek_priv
net: dsa: realtek: common rtl83xx module
net: dsa: realtek: merge rtl83xx and interface modules into realtek_dsa
net: dsa: realtek: get internal MDIO node by name
net: dsa: realtek: clean user_mii_bus setup
net: dsa: realtek: migrate user_mii_bus setup to realtek_dsa
net: dsa: realtek: use the same mii bus driver for both interfaces
net: dsa: realtek: embed dsa_switch into realtek_priv

 drivers/net/dsa/realtek/Kconfig        |  20 +--
 drivers/net/dsa/realtek/Makefile       |  13 +-
 drivers/net/dsa/realtek/realtek-mdio.c | 205 ++++++----------------
 drivers/net/dsa/realtek/realtek-mdio.h |  48 ++++++
 drivers/net/dsa/realtek/realtek-smi.c  | 279 +++++++-----------------------
 drivers/net/dsa/realtek/realtek-smi.h  |  48 ++++++
 drivers/net/dsa/realtek/realtek.h      |  12 +-
 drivers/net/dsa/realtek/rtl8365mb.c    | 128 ++++++++------
 drivers/net/dsa/realtek/rtl8366-core.c |  22 +--
 drivers/net/dsa/realtek/rtl8366rb.c    | 119 +++++++------
 drivers/net/dsa/realtek/rtl83xx.c      | 303 +++++++++++++++++++++++++++++++++
 drivers/net/dsa/realtek/rtl83xx.h      |  22 +++
 12 files changed, 705 insertions(+), 514 deletions(-)

---
base-commit: 2121c43f88f593eea51d483bedd638cb0623c7e2
change-id: 20240127-realtek_reverse-1b6021490c85

Best regards,

Signature · 1 line
Luiz Angelo Daros de Luca <[email protected]>