openwrt/target/linux/realtek/files-6.18/drivers/net
Jonas Jelonek 15593de376
realtek: pcs: derive SerDes link count from DT at probe time
Previously, sds->num_of_links was incremented from rtpcs_create() as
each DSA port bound its phylink_pcs. The count therefore relied on a
temporal contract (DSA must finish enumerating before pcs_config runs)
and on rtpcs_create() being the single chokepoint for all consumers.

Replace this with a probe-time scan of pcs-handle references in the
live OF tree: for every available consumer node carrying a pcs-handle
property pointing at one of our SerDes subnodes, bump that SerDes'
num_of_links. After the scan, the count is final regardless of when
or whether DSA later calls in.

To allow of_parse_phandle_with_args() to walk the property correctly,
add #pcs-cells = <0> to every serdes@N node in the 838x/839x/930x/931x
.dtsi files. A future cell-bearing form remains possible without
touching the scan.

Over-references (DT pointing more consumers at one SerDes than the
hardware can carry) are clamped at RTPCS_MAX_LINKS_PER_SDS and warned
about, but do not fail probe — the correctly-wired ports on that
SerDes still come up, and only the surplus reference is dropped.

The bounds check and the bare ++ in rtpcs_create() become redundant
under the scan-driven count and are removed.

This decouples num_of_links from DSA call ordering and is a prereq
for migrating to fwnode_pcs providers, where rtpcs_create() goes away
as the centralised counter.

Link: https://github.com/openwrt/openwrt/pull/23484
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
2026-05-23 11:02:15 +02:00
..
dsa/rtl83xx realtek: support configurable LED interface mode on RTL930x 2026-05-03 01:32:52 +02:00
ethernet realtek: eth: rename netdev/ndev variables to dev 2026-05-21 12:19:47 +02:00
mdio realtek: mdio: convert to scoped_guard() 2026-05-21 12:10:27 +02:00
pcs realtek: pcs: derive SerDes link count from DT at probe time 2026-05-23 11:02:15 +02:00
phy/realtek realtek: phy: add 100base-FX mode to RTL8214FC 2026-05-05 13:16:08 +02:00