RFC net: pcs: Add generic PCS interface and Synopsys DW XPCS driver
Get series with b4
b4 am [email protected] change-id 20261028-rfc-net-pcs-driver-bbdb1b58ddffVersions newest first · linked by author and title
- v2 RFC Latest2 patches 0 repliesNew
- v1 RFC2 patches 3 repliesSuperseded
Changes in v2 from the cover letter
- Add a dedicated UCLASS_PCS instead of using UCLASS_MISC (Peter, Tom)
- Add SPDX headers and the Linux copyright (Tom)
- Add documentation: pcs.rst, pcs-xpcs.rst and the API page (Tom)
- Build the driver on sandbox, and add a sandbox PCS driver with dm
tests for the uclass (Tom, Peter)
- Replace the an_mode and speed fields of struct pcs_config with iface
and neg_mode
- Probe: do not compare the device ID with a fixed value, because it
holds the OUI set by the SoC integrator. Read it from the PCS MMD
instead of the PMA/PMD MMD, and log it at debug level
- Clause 37: set the restart bit together with the enable bit
- List the other in-tree users of the XPCS (Peter)
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | net: pcs: Add PCS uclass and generic interfacearch/ configs/ doc/ +13 more | +694 | 0 replies | |
| 2/2 | net: pcs: Add Synopsys DesignWare XPCS driverconfigs/ doc/ doc/ +4 more | +1088 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH RFC v2 0/2] net: pcs: Add generic PCS interface and Synopsys DW XPCS driver
This RFC adds a PCS (Physical Coding Sublayer) uclass and a driver for the Synopsys DesignWare Ethernet PCS (DW XPCS) that implements it. I would still like feedback on the interface and on how the driver is structured. The MAC glue for the MP201 SoC that uses this interface is posted as a separate RFC series right after this one, and links back to it.
Background
----------
On SoCs with a DW XPCS between the MAC and the SerDes, the MAC driver has to configure the PCS and read back its link and auto-negotiation state to bring up Ethernet links.
Why a PCS uclass
----------------
Today: every MAC driver has its own XPCS code
fsl_enetc_xpcs_phy.c --> XPCS registers
dwc_eth_qos_intel.c --> XPCS registers
sja1105.c --> XPCS registers
designware.c (NPCM8xx) --> XPCS registersWith this series: MAC drivers share one interface
MP201 MAC glue ----+
other MAC drivers -+--> PCS uclass --> DW XPCS driver
(may follow later)What is in the series
---------------------
1/2 net: pcs: Add PCS uclass and generic interface
UCLASS_PCS, include/pcs.h, documentation, a sandbox PCS driver and dm tests for the uclass
2/2 net: pcs: Add Synopsys DesignWare XPCS driver
Architecture
------------
Where the PCS sits in the hardware:
+---------------------------+
| CPU running U-Boot |
+---------------------------+
| |
| MMIO | MMIO ("indirect" window)
v v
+-------+ +---------+ +--------------+
| MAC |<------->| DW XPCS |<------->| PMA / SerDes |<--> link partner
+-------+ +---------+ +--------------+
MAC-PCS PMA
interface interfaceThe SerDes (PMA) is set up by the platform, not by this series.
How the software is layered:
+----------------------------------------------------+
| network core, Ethernet uclass (UCLASS_ETH) |
+----------------------------------------------------+
|
v
+----------------------------------------------------+
| MAC driver + SoC glue (follow-up: MP201) |
+----------------------------------------------------+
| include/pcs.h
================ added by this series ================
v
+----------------------------------------------------+
| PCS uclass (UCLASS_PCS) patch 1 |
+----------------------------------------------------+
| |
v v
+--------------------------+ +------------------------+
| DW XPCS driver (patch 2)| | sandbox PCS driver |
| "snps,dw-xpcs" binding | | for the dm tests (p. 1)|
+--------------------------+ +------------------------+Interface
---------
struct pcs_ops has set_config(), get_state() and disable(), with a wrapper for each in include/pcs.h. struct pcs_config selects the interface mode (iface) and the negotiation mode (neg_mode: none, in-band or out-of-band). struct pcs_state reports link, auto-negotiation status and speed. The semantics are documented in doc/develop/driver-model/pcs.rst.
Supported modes
---------------
iface neg_mode AN Mbps PHY_INTERFACE_MODE_1000BASEKX PCS_NEG_INBAND Clause 37 1000 PHY_INTERFACE_MODE_10GBASER PCS_NEG_NONE none 10000 PHY_INTERFACE_MODE_10GKR PCS_NEG_INBAND Clause 73 10000
Any other iface is rejected with -EINVAL, a wrong neg_mode for a supported iface with -EOPNOTSUPP. A rejected request leaves the PCS as it was.
Other users of the Synopsys XPCS in the tree
--------------------------------------------
The same IP is already programmed by hand in:
drivers/net/fsl_enetc_xpcs_phy.c NXP ENETC, over MDIO drivers/net/dwc_eth_qos_intel.c Intel mGBE, over MDIO drivers/net/sja1105.c NXP SJA1105/SJA1110, over SPI drivers/net/designware.c NPCM8xx only, MMIO (indirect page)
I did not convert the Airoha PCS driver, since I have no Airoha hardware to validate a conversion. The MP201 glue is the first in-tree user of this interface.
Origin of the code
------------------
The programming sequences (Clause 73 AN, 10GBASE-R and 1000BASE-KX) are written from the Synopsys DesignWare Ethernet PCS databook. The register and bit names and some small parts of the design are taken from the Linux drivers/net/pcs/pcs-xpcs*.c driver. The code is not based on the proposed Linux series. The Synopsys copyright from the Linux file is kept in the file header.
Testing
-------
Tested on the Synopsys VDK emulator: probe, pcs_set_config() for the three modes, pcs_get_state() and pcs_disable(). This covers the register programming sequence only. No packet I/O was tested, and it has not been tested on real hardware.
The uclass is covered by dm tests that use a sandbox PCS driver (ut dm pcs_*). The XPCS driver itself has no sandbox emulation. Builds on sandbox and qemu_arm64.
Not done
--------
- More interface modes. They are planned for the same driver, as further cases in the mode validation and mode programming of pcs-xpcs.c: 10G SFP+ (copper with auto-negotiation, and optical SR/LR/DR/ER), 2.5GBASE-KX, 2.5GBASE-X, 1000BASE-CR, USXGMII, HS-SGMII and SGMII.
- Clause 73 Next Pages
- MDIO access and the "direct" register mapping
- Clocks and the interrupt of the binding
- External PHY handling. How the PCS and an external PHY between it and the link partner are configured together (interface mode, and which side negotiates) is not designed yet. It is planned as a follow-up to this interface.
- PMA/SerDes initialisation, which must be done before pcs_set_config() (see doc/develop/driver-model/pcs-xpcs.rst)
Changes in v2:
- Add a dedicated UCLASS_PCS instead of using UCLASS_MISC (Peter, Tom)
- Add SPDX headers and the Linux copyright (Tom)
- Add documentation: pcs.rst, pcs-xpcs.rst and the API page (Tom)
- Build the driver on sandbox, and add a sandbox PCS driver with dm
tests for the uclass (Tom, Peter)
- Replace the an_mode and speed fields of struct pcs_config with iface
and neg_mode
- Probe: do not compare the device ID with a fixed value, because it
holds the OUI set by the SoC integrator. Read it from the PCS MMD
instead of the PMA/PMD MMD, and log it at debug level
- Clause 37: set the restart bit together with the enable bit
- List the other in-tree users of the XPCS (Peter)
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/
---
Akash Nair (2):
net: pcs: Add PCS uclass and generic interface
net: pcs: Add Synopsys DesignWare XPCS driver
arch/sandbox/dts/test.dts | 8 + configs/sandbox_defconfig | 3 + doc/api/index.rst | 1 + doc/api/pcs.rst | 11 + doc/develop/driver-model/index.rst | 2 + doc/develop/driver-model/pcs-xpcs.rst | 193 ++++++++ doc/develop/driver-model/pcs.rst | 225 +++++++++ drivers/net/Kconfig | 1 + drivers/net/Makefile | 1 + drivers/net/pcs/Kconfig | 34 ++ drivers/net/pcs/Makefile | 8 + drivers/net/pcs/pcs-sandbox.c | 91 ++++ drivers/net/pcs/pcs-uclass.c | 53 ++ drivers/net/pcs/pcs-xpcs.c | 878 ++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/pcs.h | 137 ++++++ test/dm/Makefile | 1 + test/dm/pcs.c | 133 +++++ 18 files changed, 1781 insertions(+)
---
base-commit: 42680af8d15bb49201b298ab5f62058051c13083
change-id: 20261028-rfc-net-pcs-driver-bbdb1b58ddff
Best regards,
Signature · 1 line
Akash Nair <[email protected]>