Kernel proposal gives Ethernet PCS its own firmware-node API
Christian Marangi's phylink changes would let coding-sublayer drivers probe and disappear independently of the MAC.
Christian Marangi has proposed a firmware-node API so Linux can treat an Ethernet physical coding sublayer as its own device, rather than as a private piece of the MAC driver that owns the port.
PCS blocks sit between the MAC and the rest of the physical layer. They handle framing, scrambling, and encoding, and they talk to a serdes that may face fiber, a backplane, or a separate PHY. Early phylink code assumed the PCS lived in the same driver as the MAC. That assumption has been breaking as 10-gigabit parts, including consumer SoCs, put the PCS outside the MAC. Drivers have papered over the gap with exported symbols and ad hoc phylink handling.
The proposal, posted for the networking tree and co-developed with Daniel Golle, copies the producer-consumer pattern already used for clocks and PHYs. A PCS driver registers as a provider against its firmware node. A MAC looks up the blocks described by a pcs-handle property in device tree or ACPI, including the case where the PCS has not probed yet. Phylink, not the MAC, would then pick a PCS for the requested interface. The older MAC callback that selects a PCS is treated as deprecated; a driver must use one approach or the other, not both.
The same mechanism is meant to survive the PCS coming and going. If a provider is removed, phylink drops the matching PCS, refreshes the interfaces it claims to support, and forces a reconfiguration so a live link is not left pointing at a gone device. If the provider appears later, the PCS is attached and a link that was torn down can come back. A use-after-free that Sean Anderson had flagged is closed by protecting the back-pointer from a PCS into phylink, so a late link-change notification cannot touch a freed phylink instance. Anderson had a competing design and, according to Marangi, agreed this one could be used if that race was handled.
Marangi also adds an optional PCS link-down operation for hardware that must reset state when the MAC drops the link, documents the subsystem, and lists himself as its maintainer. A binding for the Airoha AN7581, which exposes several PCS instances for Ethernet, PON, PCIe, and USB serdes modes, has a review from Rob Herring. Maxime Chevallier has tested and reviewed parts of the work.