freenode
Kernel & Low-Level

Phylink gets a firmware-node way to find Ethernet PCS blocks

Christian Marangi's proposal treats coding sublayers like clocks, so MACs can pick them up from device tree or ACPI even if the PCS driver arrives or leaves later.

Linux networking is being asked to stop treating the Ethernet physical coding sublayer as a private detail of the MAC driver. Christian Marangi has posted a phylink change that lets a PCS register itself through a firmware node, the same producer-consumer pattern clocks and PHYs already use, so a MAC can request the block described in device tree or ACPI instead of calling a driver-specific export.

The old assumption was that the PCS lived in the same driver as the MAC. That stopped holding once consumer SoCs started putting the coding sublayer outside the MAC, a pattern that has spread with 10 gigabit ports. MAC drivers filled the gap themselves, and phylink's selection callback became a dumping ground. Marangi's approach hands selection back to phylink: the MAC declares which interface modes need a dedicated PCS, firmware lists the handles, and phylink matches a provider that actually supports the mode. The older MAC-side selection path is treated as deprecated, and a driver cannot use both.

A second implementation, from a developer named Sean, had been in circulation. Marangi wrote that Sean agreed this one could be taken instead, provided the race he had hit was handled. That is what the late-attach and release path is for. If a PCS driver probes after the link is already up, or is removed while the link is running, phylink is notified, drops or adds that PCS, and recalculates what the port can advertise. A link torn down because its PCS disappeared can come back when the provider returns. Settings the user turned off through ethtool are kept across that detach and reattach, rather than being overwritten by a fresh capability calculation.

The first user is Airoha's AN7581. Its PCS driver covers Ethernet, PON, PCIe and USB serdes, including USXGMII, 10GBASE-R, 2500BASE-X, 1000BASE-X and SGMII, and the SoC's gigabit MAC ports gain phylink so an external PHY or an SFP cage can be attached through a pcs-handle. Daniel Golle co-developed the provider core. Marangi has also proposed listing himself as maintainer of the new Ethernet PCS subsystem.