Add PCS core support
Subsystems (23)
Sean Anderson
reviewercover Add PCS core support
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patch 5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-8)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 9-10).
The last few patches add device links for pcs-handle to improve boot times, and add compatibles for all Lynx PCSs.
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this, pcs_get_by_fwnode_compat allows drivers to edit the devicetree to add appropriate compatibles.
This is technically a v3 (with [1,2] being v1 and v2, respectively), but there have been so many architectural changes that I didn't bother maintaining the series changelog. I think it is best to review this series independently of its past iterations. I submitted this as an RFC since net-next is closed, but I believe this series is fully tested and ready to be applied.
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
Sean Anderson (12):
dt-bindings: net: Add binding for Xilinx PCS
net: phylink: Support setting PCS link change callbacks
net: pcs: Add subsystem
net: pcs: lynx: Convert to an MDIO driver
net: phy: Export some functions
net: pcs: Add Xilinx PCS driver
net: axienet: Convert to use PCS subsystem
net: macb: Move most of mac_config to mac_prepare
net: macb: Support external PCSs
of: property: Add device link support for PCS
arm64: dts: Add compatible strings for Lynx PCSs
powerpc: dts: Add compatible strings for Lynx PCSs
Vladimir Oltean (1):
net: dsa: ocelot: suppress PHY device scanning on the internal MDIO
bus
.../devicetree/bindings/net/xilinx,pcs.yaml | 129 ++++ Documentation/networking/index.rst | 1 + Documentation/networking/kapi.rst | 4 + Documentation/networking/pcs.rst | 99 +++ MAINTAINERS | 8 + .../arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 48 +- .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 54 +- .../dts/freescale/qoriq-fman3-0-10g-0.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-10g-1.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-0.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-1.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-2.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-3.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-4.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-5.dtsi | 3 +- .../fsl/qoriq-fman3-0-10g-0-best-effort.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi | 3 +- .../fsl/qoriq-fman3-0-10g-1-best-effort.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi | 3 +- .../boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi | 3 +- drivers/net/dsa/ocelot/Kconfig | 4 + drivers/net/dsa/ocelot/felix_vsc9959.c | 15 +- drivers/net/dsa/ocelot/seville_vsc9953.c | 16 +- drivers/net/ethernet/altera/Kconfig | 2 + drivers/net/ethernet/altera/altera_tse_main.c | 7 +- drivers/net/ethernet/cadence/macb.h | 1 + drivers/net/ethernet/cadence/macb_main.c | 229 ++++-- drivers/net/ethernet/freescale/dpaa/Kconfig | 2 +- drivers/net/ethernet/freescale/dpaa2/Kconfig | 3 + .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 11 +- drivers/net/ethernet/freescale/enetc/Kconfig | 2 + .../net/ethernet/freescale/enetc/enetc_pf.c | 8 +- .../net/ethernet/freescale/enetc/enetc_pf.h | 1 - .../freescale/enetc/enetc_pf_common.c | 4 +- drivers/net/ethernet/freescale/fman/Kconfig | 4 +- .../net/ethernet/freescale/fman/fman_memac.c | 27 +- drivers/net/ethernet/stmicro/stmmac/Kconfig | 3 + .../ethernet/stmicro/stmmac/dwmac-socfpga.c | 6 +- drivers/net/ethernet/xilinx/Kconfig | 1 + drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 104 +-- drivers/net/pcs/Kconfig | 51 +- drivers/net/pcs/Makefile | 4 + drivers/net/pcs/core.c | 701 ++++++++++++++++++ drivers/net/pcs/pcs-lynx.c | 115 +-- drivers/net/pcs/pcs-xilinx.c | 481 ++++++++++++ drivers/net/phy/mdio_device.c | 1 + drivers/net/phy/phy_device.c | 3 +- drivers/net/phy/phylink.c | 24 +- drivers/of/property.c | 2 + include/linux/pcs-lynx.h | 13 +- include/linux/pcs-xilinx.h | 36 + include/linux/pcs.h | 122 +++ include/linux/phy.h | 1 + include/linux/phylink.h | 27 +- 70 files changed, 2104 insertions(+), 358 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/xilinx,pcs.yaml create mode 100644 Documentation/networking/pcs.rst create mode 100644 drivers/net/pcs/core.c create mode 100644 drivers/net/pcs/pcs-xilinx.c create mode 100644 include/linux/pcs-xilinx.h create mode 100644 include/linux/pcs.h
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerRFC PATCH 1/13 dt-bindings: net: Add binding for Xilinx PCS
This adds a binding for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE IP. This device is a soft device typically used to adapt between GMII and SGMII or 1000BASE-X (possbilty in combination with a serdes). pcs-modes reflects the modes available with the as configured when the device is synthesized. Multiple modes may be specified if dynamic reconfiguration is supported.
One PCS may contain "shared logic in core" which can be connected to other PCSs with "shared logic in example design." This primarily refers to clocking resources, allowing a reference clock to be shared by a bank of PCSs. To support this, if #clock-cells is defined then the PCS will register itself as a clock provider for other PCSs.
---
.../devicetree/bindings/net/xilinx,pcs.yaml | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/xilinx,pcs.yaml
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +129 -0
@@ -0,0 +1,129 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/xilinx,pcs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE IP + +maintainers: + - Sean Anderson <[email protected]> + +description: + This is a soft device which implements the PCS and (depending on + configuration) PMA layers of an IEEE Ethernet PHY. On the MAC side, it + implements GMII. It may have an attached SERDES (internal or external), or + may directly use LVDS IO resources. Depending on the configuration, it may + implement 1000BASE-X, SGMII, 2500BASE-X, or 2.5G SGMII. + + This device has a notion of "shared logic" such as reset and clocking + resources which must be shared between multiple PCSs using the same I/O + banks. Each PCS can be configured to have the shared logic in the "core" + (instantiated internally and made available to other PCSs) or in the "example + design" (provided by another PCS). PCSs with shared logic in the core are + reset controllers, and generally provide several resets for other PCSs in the + same bank. + +allOf: + - $ref: ethernet-controller.yaml# + +properties: + compatible: + contains: + const: xilinx,pcs-16.2 + + reg: + maxItems: 1 + + "#clock-cells": + const: 0 + description: + Register a clock representing the clocking resources shared with other + PCSs. + + clocks: + items: + - description: + The reference clock for the PCS. Depending on your setup, this may be + the gtrefclk, refclk, clk125m signal, or clocks from another PCS. + + clock-names: + const: refclk + + done-gpios: + maxItems: 1 + description: + GPIO connected to the reset-done output, if present. + + interrupts: + items: + - description: + The an_interrupt autonegotiation-complete interrupt. + + interrupt-names: + const: an + + pcs-modes: + description: + The interfaces that the PCS supports. + oneOf: + - const: sgmii + - const: 1000base-x + - const: 2500base-x + - items: + - const: sgmii + - const: 1000base-x + + reset-gpios: + maxItems: 1 + description: + GPIO connected to the reset input. + +required: + - compatible + - reg + - pcs-modes + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + pcs0: ethernet-pcs@0 { + #clock-cells = <0>; + compatible = "xlnx,pcs-16.2"; + reg = <0>; + clocks = <&si570>; + clock-names = "refclk"; + interrupts-extended = <&gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "an"; + reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + done-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + pcs-modes = "sgmii", "1000base-x"; + }; + + pcs1: ethernet-pcs@1 { + compatible = "xlnx,pcs-16.2"; + reg = <1>; + clocks = <&pcs0>; + clock-names = "refclk"; + interrupts-extended = <&gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "an"; + reset-gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + done-gpios = <&gpio 8 GPIO_ACTIVE_HIGH>; + pcs-modes = "sgmii", "1000base-x"; + }; + + pcs2: ethernet-pcs@2 { + compatible = "xlnx,pcs-16.2"; + reg = <2>; + pcs-modes = "sgmii"; + }; + };
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [RFC net-next PATCH 01/13] dt-bindings: net: Add binding for Xilinx PCS
Quoted 1 line · Sean Anderson
This adds a binding for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII
Incomplete review, since this is an RFC.
Please do not use "This commit/patch/change", but imperative mood. See longer explanation here:
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95
A nit, subject: drop second/last, redundant "binding for". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18
Quoted 47 lines
LogiCORE IP. This device is a soft device typically used to adapt between GMII and SGMII or 1000BASE-X (possbilty in combination with a serdes). pcs-modes reflects the modes available with the as configured when the device is synthesized. Multiple modes may be specified if dynamic reconfiguration is supported.
One PCS may contain "shared logic in core" which can be connected to other PCSs with "shared logic in example design." This primarily refers to clocking resources, allowing a reference clock to be shared by a bank of PCSs. To support this, if #clock-cells is defined then the PCS will register itself as a clock provider for other PCSs.
Signed-off-by Sean Anderson <[email protected]>---
.../devicetree/bindings/net/xilinx,pcs.yaml | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/xilinx,pcs.yamlDocumentation/devicetree/bindings/net/xilinx,pcs.yaml new file +22
-0@@ -0,0 +1,129 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/xilinx,pcs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE IP + +maintainers: + - Sean Anderson <[email protected]> + +description: + This is a soft device which implements the PCS and (depending on + configuration) PMA layers of an IEEE Ethernet PHY. On the MAC side, it + implements GMII. It may have an attached SERDES (internal or external), or + may directly use LVDS IO resources. Depending on the configuration, it may + implement 1000BASE-X, SGMII, 2500BASE-X, or 2.5G SGMII. + + This device has a notion of "shared logic" such as reset and clocking + resources which must be shared between multiple PCSs using the same I/O + banks. Each PCS can be configured to have the shared logic in the "core" + (instantiated internally and made available to other PCSs) or in the "example
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 32
Quoted 10 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +10
-0+ design" (provided by another PCS). PCSs with shared logic in the core are + reset controllers, and generally provide several resets for other PCSs in the + same bank. + +allOf: + - $ref: ethernet-controller.yaml# + +properties: + compatible: + contains:
From where did you get such syntax? What do you want to express?
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 33
Quoted 1 line
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +1
-0+ const: xilinx,pcs-16.2
What does the number mean?
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 42
Quoted 9 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +9
-0+ + reg: + maxItems: 1 + + "#clock-cells": + const: 0 + description: + Register a clock representing the clocking resources shared with other + PCSs.
Drop description, redundant.
Quoted 23 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +23
-0+ + clocks: + items: + - description: + The reference clock for the PCS. Depending on your setup, this may be + the gtrefclk, refclk, clk125m signal, or clocks from another PCS. + + clock-names: + const: refclk + + done-gpios: + maxItems: 1 + description: + GPIO connected to the reset-done output, if present. + + interrupts: + items: + - description: + The an_interrupt autonegotiation-complete interrupt. + + interrupt-names: + const: an +
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 75
Quoted 10 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +10
-0+ pcs-modes: + description: + The interfaces that the PCS supports. + oneOf: + - const: sgmii + - const: 1000base-x + - const: 2500base-x + - items: + - const: sgmii + - const: 1000base-x
This is confusing. Why fallbacks? Shouldn't this be just enum? And where is the type or constraints about number of items?
Quoted 15 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +15
-0+ + reset-gpios: + maxItems: 1 + description: + GPIO connected to the reset input. + +required: + - compatible + - reg + - pcs-modes + +additionalProperties: false + +examples: + - |
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 100
Quoted 10 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +10
-0+ #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + pcs0: ethernet-pcs@0 { + #clock-cells = <0>;
Follow DTS coding style. clock-cells are never the first property.
Quoted 11 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +11
-0+ compatible = "xlnx,pcs-16.2"; + reg = <0>; + clocks = <&si570>; + clock-names = "refclk"; + interrupts-extended = <&gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "an"; + reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + done-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + pcs-modes = "sgmii", "1000base-x"; + }; +
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 121
Quoted 10 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +10
-0+ pcs1: ethernet-pcs@1 { + compatible = "xlnx,pcs-16.2"; + reg = <1>; + clocks = <&pcs0>; + clock-names = "refclk"; + interrupts-extended = <&gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "an"; + reset-gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + done-gpios = <&gpio 8 GPIO_ACTIVE_HIGH>; + pcs-modes = "sgmii", "1000base-x";
Drop example, basically the same as previous.
Best regards,
Krzysztof
Re: [RFC net-next PATCH 01/13] dt-bindings: net: Add binding for Xilinx PCS
Quoted 11 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 75
Quoted 10 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +10
-0+ pcs-modes: + description: + The interfaces that the PCS supports. + oneOf: + - const: sgmii + - const: 1000base-x + - const: 2500base-x + - items: + - const: sgmii + - const: 1000base-x
Quoted 3 lines
This is confusing. Why fallbacks? Shouldn't this be just enum? And where is the type or constraints about number of items?
I just double checked now in dtschema and latest next - there is no such property.
Best regards,
Krzysztof
Sean Anderson
reviewerRe: [RFC net-next PATCH 01/13] dt-bindings: net: Add binding for Xilinx PCS
Quoted 12 lines · Krzysztof Kozlowski
Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +10
-0+ pcs-modes: + description: + The interfaces that the PCS supports. + oneOf: + - const: sgmii + - const: 1000base-x + - const: 2500base-x + - items: + - const: sgmii + - const: 1000base-x
Quoted 5 lines
Quoted 3 lines
This is confusing. Why fallbacks? Shouldn't this be just enum? And where is the type or constraints about number of items?
I just double checked now in dtschema and latest next - there is no such property.
OK, so you would prefer xlnx,pcs-modes?
--Sean
Sean Anderson
reviewerRe: [RFC net-next PATCH 01/13] dt-bindings: net: Add binding for Xilinx PCS
In reply to Krzysztof KozlowskiQuoted 4 lines · Krzysztof Kozlowski
Quoted 1 line · Sean Anderson
This adds a binding for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII
Incomplete review, since this is an RFC.
Only an RFC due to netdev's rules. I consider this patchset complete.
Quoted 60 lines
Please do not use "This commit/patch/change", but imperative mood. See longer explanation here:
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95A nit, subject: drop second/last, redundant "binding for". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18Quoted 51 lines
LogiCORE IP. This device is a soft device typically used to adapt between GMII and SGMII or 1000BASE-X (possbilty in combination with a serdes). pcs-modes reflects the modes available with the as configured when the device is synthesized. Multiple modes may be specified if dynamic reconfiguration is supported.
One PCS may contain "shared logic in core" which can be connected to other PCSs with "shared logic in example design." This primarily refers to clocking resources, allowing a reference clock to be shared by a bank of PCSs. To support this, if #clock-cells is defined then the PCS will register itself as a clock provider for other PCSs.
Signed-off-by Sean Anderson <[email protected]>---
.../devicetree/bindings/net/xilinx,pcs.yaml | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/xilinx,pcs.yamlDocumentation/devicetree/bindings/net/xilinx,pcs.yaml new file +26
-0@@ -0,0 +1,129 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/xilinx,pcs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII LogiCORE IP + +maintainers: + - Sean Anderson <[email protected]> + +description: + This is a soft device which implements the PCS and (depending on + configuration) PMA layers of an IEEE Ethernet PHY. On the MAC side, it + implements GMII. It may have an attached SERDES (internal or external), or + may directly use LVDS IO resources. Depending on the configuration, it may + implement 1000BASE-X, SGMII, 2500BASE-X, or 2.5G SGMII. + + This device has a notion of "shared logic" such as reset and clocking + resources which must be shared between multiple PCSs using the same I/O + banks. Each PCS can be configured to have the shared logic in the "core" + (instantiated internally and made available to other PCSs) or in the "example + design" (provided by another PCS). PCSs with shared logic in the core are + reset controllers, and generally provide several resets for other PCSs in the + same bank. +
Quoted 8 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 32
Quoted 6 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +6
-0+allOf: + - $ref: ethernet-controller.yaml# + +properties: + compatible: + contains:From where did you get such syntax? What do you want to express?
The compatible should contain this value, but we don't really care what else it contains. This aligns with how the kernel matches drivers to devices.
Quoted 3 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 33
Quoted 1 line
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +1
-0+ const: xilinx,pcs-16.2What does the number mean?
It's the version of the IP.
Quoted 40 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 42
Quoted 9 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +9
-0+ + reg: + maxItems: 1 + + "#clock-cells": + const: 0 + description: + Register a clock representing the clocking resources shared with other + PCSs.Drop description, redundant.
Quoted 28 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +28
-0+ + clocks: + items: + - description: + The reference clock for the PCS. Depending on your setup, this may be + the gtrefclk, refclk, clk125m signal, or clocks from another PCS. + + clock-names: + const: refclk + + done-gpios: + maxItems: 1 + description: + GPIO connected to the reset-done output, if present. + + interrupts: + items: + - description: + The an_interrupt autonegotiation-complete interrupt. + + interrupt-names: + const: an + + pcs-modes: + description: + The interfaces that the PCS supports. + oneOf: + - const: sgmii
Quoted 8 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 75
Quoted 5 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +5
-0+ - const: 1000base-x + - const: 2500base-x + - items: + - const: sgmii + - const: 1000base-xThis is confusing. Why fallbacks? Shouldn't this be just enum? And where is the type or constraints about number of items?
As stated in the commit message, multiple modes may be specified if dynamic reconfiguration is supported. So I want to allow
pcs-modes = "sgmii" pcs-modes = "1000base-x" pcs-modes = "2500base-x" pcs-modes = "sgmii", "1000base-x"
Quoted 19 lines
Quoted 19 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +19
-0+ + reset-gpios: + maxItems: 1 + description: + GPIO connected to the reset input. + +required: + - compatible + - reg + - pcs-modes + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> +
Quoted 8 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 100
Quoted 6 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +6
-0+ mdio { + #address-cells = <1>; + #size-cells = <0>; + + pcs0: ethernet-pcs@0 { + #clock-cells = <0>;Follow DTS coding style. clock-cells are never the first property.
Where is this documented?
Quoted 27 lines
Quoted 11 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +11
-0+ compatible = "xlnx,pcs-16.2"; + reg = <0>; + clocks = <&si570>; + clock-names = "refclk"; + interrupts-extended = <&gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "an"; + reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + done-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + pcs-modes = "sgmii", "1000base-x"; + }; +Documentation/devicetree/bindings/net/xilinx,pcs.yaml line 121
Quoted 10 lines
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +10
-0+ pcs1: ethernet-pcs@1 { + compatible = "xlnx,pcs-16.2"; + reg = <1>; + clocks = <&pcs0>; + clock-names = "refclk"; + interrupts-extended = <&gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "an"; + reset-gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + done-gpios = <&gpio 8 GPIO_ACTIVE_HIGH>; + pcs-modes = "sgmii", "1000base-x";Drop example, basically the same as previous.
Best regards,
Krzysztof
Sean Anderson
reviewerRFC PATCH 2/13 net: phylink: Support setting PCS link change callbacks
In reply to Sean AndersonSupport changing the link change callback, similar to how PHYs do it. This will allow the PCS wrapper to forward link changes to the wrapped PCS.
---
drivers/net/phy/phylink.c | 24 +++++++----------------- include/linux/phylink.h | 27 ++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 22 deletions(-)
drivers/net/phy/phylink.c +7 -17
@@ -1205,6 +1205,8 @@ static void phylink_pcs_neg_mode(struct phylink *pl, struct phylink_pcs *pcs, pl->act_link_an_mode = mode; } +static void pcs_change_callback (void *priv,bool up); +static void phylink_major_config (struct phylink *pl,bool restart,const struct phylink_link_state *state) {
@@ -1260,10 +1262,10 @@ static void phylink_major_config(struct phylink *pl, bool restart,phylink_pcs_disable (pl->pcs);if (pl->pcs) - pl->pcs->phylink =NULL ; - - pcs->phylink = pl; + pl->pcs->link_change_priv =NULL ; + pcs->link_change = pcs_change_callback; + pcs->link_change_priv = pl; pl->pcs = pcs; }
@@ -2333,25 +2335,13 @@ void phylink_mac_change(struct phylink *pl, bool up) }EXPORT_SYMBOL_GPL (phylink_mac_change); -/** -* phylink_pcs_change() - notify phylink of a change to PCS link state -* @pcs: pointer to &struct phylink_pcs -* @up: indicates whether the link is currently up. -* -* The PCS driver should call this when the state of its link changes -* (e.g. link failure, new negotiation results, etc.) Note: it should -* not determine "up" by reading the BMSR. If in doubt about the link -* state at interrupt time, then pass true if pcs_get_state() returns -* the latched link-down state, otherwise pass false. -*/ -void phylink_pcs_change (struct phylink_pcs *pcs,bool up) +static void pcs_change_callback (void *priv,bool up) { -struct phylink *pl = pcs->phylink; +struct phylink *pl = priv;if (pl)phylink_link_changed (pl, up,"pcs" ); } -EXPORT_SYMBOL_GPL (phylink_pcs_change);static irqreturn_t phylink_link_handler (int irq,void *data) {
include/linux/phylink.h +22 -5
@@ -441,7 +441,8 @@ struct phylink_pcs_ops;* @supported_interfaces: describing which PHY_INTERFACE_MODE_xxx * are supported by this PCS. * @ops: a pointer to the &struct phylink_pcs_ops structure -* @phylink: pointer to &struct phylink_config +* @link_change: callback for when the link changes +* @link_change_priv: first argument to @link_change * @poll: poll the PCS for link changes * @rxc_always_on: The MAC driver requires the reference clock * to always be on. Standalone PCS drivers which
@@ -451,13 +452,14 @@ struct phylink_pcs_ops;* This structure is designed to be embedded within the PCS private data, * and will be passed between phylink and the PCS. * -* The @phylink member is private to phylink and must not be touched by -* the PCS driver. +* @link_change, @link_change_priv, and @rxc_always_on will be filled in by +* phylink. */ struct phylink_pcs {DECLARE_PHY_INTERFACE_MASK (supported_interfaces);const struct phylink_pcs_ops *ops; -struct phylink *phylink; +void (*link_change)(void *priv,bool up); +void *link_change_priv;bool poll;bool rxc_always_on; };
@@ -699,7 +701,22 @@ int phylink_set_fixed_link(struct phylink *, const struct phylink_link_state *); void phylink_mac_change(struct phylink *, bool up); -void phylink_pcs_change (struct phylink_pcs *,bool up); +/** +* phylink_pcs_change() - notify phylink of a change to PCS link state +* @pcs: pointer to &struct phylink_pcs +* @up: indicates whether the link is currently up. +* +* The PCS driver should call this when the state of its link changes +* (e.g. link failure, new negotiation results, etc.) Note: it should +* not determine "up" by reading the BMSR. If in doubt about the link +* state at interrupt time, then pass true if pcs_get_state() returns +* the latched link-down state, otherwise pass false. +*/ +static inline void phylink_pcs_change (struct phylink_pcs *pcs,bool up) +{ +if (pcs->link_change) + pcs->link_change (pcs->link_change_priv, up); +}int phylink_pcs_pre_init (struct phylink *pl,struct phylink_pcs *pcs);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerRFC PATCH 3/13 net: pcs: Add subsystem
In reply to Sean AndersonThis adds support for getting PCS devices from the device tree. PCS drivers must first register with phylink_register_pcs. After that, MAC drivers may look up their PCS using phylink_get_pcs.
We wrap registered PCSs in another PCS. This wrapper PCS is refcounted and can outlive the wrapped PCS (such as if the wrapped PCS's driver is unbound). The wrapper forwards all PCS callbacks to the wrapped PCS, first checking to make sure the wrapped PCS still exists. This design was inspired by Bartosz Golaszewsk's talk at LPC [1].
pcs_get_by_fwnode_compat is a bit hairy, but it's necessary for compatibility with existing drivers, which often attach to (devicetree) nodes directly. We use the devicetree changeset system instead of adding a (secondary) software node because mdio_bus_match calls of_driver_match_device to match devices, and that function only works on devicetree nodes.
[1] https://lpc.events/event/17/contributions/1627/
---
Documentation/networking/index.rst | 1 + Documentation/networking/kapi.rst | 4 + Documentation/networking/pcs.rst | 99 ++++ MAINTAINERS | 2 + drivers/net/pcs/Kconfig | 12 + drivers/net/pcs/Makefile | 2 + drivers/net/pcs/core.c | 701 +++++++++++++++++++++++++++++ include/linux/pcs.h | 122 +++++ 8 files changed, 943 insertions(+) create mode 100644 Documentation/networking/pcs.rst create mode 100644 drivers/net/pcs/core.c create mode 100644 include/linux/pcs.h
Documentation/networking/index.rst +1 -0
@@ -30,6 +30,7 @@ Contents: page_pool phy sfp-phylink + pcs alias bridge snmp_counter
Documentation/networking/kapi.rst +4 -0
@@ -146,6 +146,10 @@ PHYLINK .. kernel-doc:: include/linux/phylink.h :internal: + :no-identifiers: phylink_pcs phylink_pcs_ops pcs_validate pcs_inband_caps + pcs_enable pcs_disable pcs_pre_config pcs_post_config pcs_get_state + pcs_config pcs_an_restart pcs_link_up pcs_disable_eee pcs_enable_eee + pcs_pre_init .. kernel-doc:: drivers/net/phy/phylink.c
Documentation/networking/pcs.rst new file +99 -0
99 lines not on this page · raw message
MAINTAINERS +2 -0
@@ -8644,6 +8644,7 @@ F: Documentation/ABI/testing/sysfs-class-net-phydev F: Documentation/devicetree/bindings/net/ethernet-phy.yaml F: Documentation/devicetree/bindings/net/mdio* F: Documentation/devicetree/bindings/net/qca,ar803x.yaml +F: Documentation/networking/pcs.rst F: Documentation/networking/phy.rst F: drivers/net/mdio/ F: drivers/net/mdio/acpi_mdio.c
@@ -8657,6 +8658,7 @@ F: include/linux/linkmode.h F: include/linux/mdio/*.h F: include/linux/mii.h F: include/linux/of_net.h +F: include/linux/pcs.h F: include/linux/phy.h F: include/linux/phy_fixed.h F: include/linux/phy_link_topology.h
drivers/net/pcs/Kconfig +12 -0
@@ -5,6 +5,18 @@ menu "PCS device drivers" +config PCS + bool "PCS subsystem" + help + This provides common helper functions for registering and looking up + Physical Coding Sublayer (PCS) devices. PCS devices translate between + different interface types. In some use cases, they may either + translate between different types of Medium-Independent Interfaces + (MIIs), such as translating GMII to SGMII. This allows using a fast + serial interface to talk to the phy which translates the MII to the + Medium-Dependent Interface. Alternatively, they may translate a MII + directly to an MDI, such as translating GMII to 1000Base-X. + config PCS_XPCS tristate "Synopsys DesignWare Ethernet XPCS" select PHYLINK
drivers/net/pcs/Makefile +2 -0
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux PCS drivers +obj-$(CONFIG_PCS) += core.o + pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-plat.o \ pcs-xpcs-nxp.o pcs-xpcs-wx.o
drivers/net/pcs/core.c new file +701 -0
701 lines not on this page · raw message
include/linux/pcs.h new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
2.35.1.1320.gc452695387.dirty
kernel test robot
build botRe: [RFC net-next PATCH 03/13] net: pcs: Add subsystem
kernel test robot noticed the following build warnings:
Hi Sean,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/dt-bindings-net-Add-binding-for-Xilinx-PCS/20250404-023209 base: net-next/main patch link: https://lore.kernel.org/r/20250403181907.1947517-4-sean.anderson%40linux.dev patch subject: [RFC net-next PATCH 03/13] net: pcs: Add subsystem config: loongarch-randconfig-001-20250404 (https://download.01.org/0day-ci/archive/20250404/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250404/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/net/pcs/core.c: In function 'pcs_unregister':
>> drivers/net/pcs/core.c:373:29: warning: variable 'wrapped' set but not used [-Wunused-but-set-variable]
373 | struct phylink_pcs *wrapped;
| ^~~~~~~vim +/wrapped +373 drivers/net/pcs/core.c
365
366 /**
367 * pcs_unregister() - unregister a PCS
368 * @pcs: a PCS previously registered with pcs_register()
369 */
370 void pcs_unregister(struct phylink_pcs *pcs)
371 {
372 struct pcs_wrapper *wrapper;
> 373 struct phylink_pcs *wrapped;
374
375 mutex_lock(&pcs_mutex);
376 list_for_each_entry(wrapper, &pcs_wrappers, list) {
377 if (wrapper->wrapped == pcs)
378 goto found;
379 }
380
381 mutex_unlock(&pcs_mutex);
382 WARN(1, "trying to unregister an already-unregistered PCS\n");
383 return;
384
385 found:
386 list_del(&wrapper->list);
387 wrapped = rcu_replace_pointer(wrapper->wrapped, NULL, true);
388 mutex_unlock(&pcs_mutex);
389 synchronize_srcu(&wrapper->ssp);
390
391 if (!wrapper->pcs.poll)
392 phylink_pcs_change(&wrapper->pcs, false);
393 if (refcount_dec_and_test(&wrapper->refcnt))
394 pcs_destroy(wrapper);
395 }
396 EXPORT_SYMBOL_GPL(pcs_unregister);
397
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Sean Anderson
reviewerRFC PATCH 4/13 net: dsa: ocelot: suppress PHY device scanning on the internal MDIO bus
In reply to Sean AndersonFrom: Vladimir Oltean <[email protected]>
This bus contains Lynx PCS devices, and if the lynx-pcs driver ever decided to call mdio_device_register(), it would fail due to mdiobus_scan() having created a dummy phydev for the same address (the PCS responds to standard clause 22 PHY ID registers and can therefore by autodetected by phylib which thinks it's a PHY).
On the Seville driver, things are a bit more complicated, since bus creation is handled by mscc_miim_setup() and that is shared with the dedicated mscc-miim driver. Suppress PHY scanning only for the Seville internal MDIO bus rather than for the whole mscc-miim driver, since we know that on NXP T1040, this bus only contains Lynx PCS devices.
---
drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++++ drivers/net/dsa/ocelot/seville_vsc9953.c | 5 +++++ 2 files changed, 9 insertions(+)
drivers/net/dsa/ocelot/felix_vsc9959.c +4 -0
@@ -1001,6 +1001,10 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot) bus->read_c45 = enetc_mdio_read_c45; bus->write_c45 = enetc_mdio_write_c45; bus->parent = dev; +/* Suppress PHY device creation in mdiobus_scan(), +* we have Lynx PCSs +*/ + bus->phy_mask = ~0 ; mdio_priv = bus->priv; mdio_priv->hw = hw;/* This gets added to imdio_regs, which already maps addresses
drivers/net/dsa/ocelot/seville_vsc9953.c +5 -0
@@ -901,6 +901,11 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)return rc; } +/* Suppress PHY device creation in mdiobus_scan(), +* we have Lynx PCSs +*/ + bus->phy_mask = ~0 ; +/* Needed in order to initialize the bus mutex lock */ rc =devm_of_mdiobus_register (dev, bus,NULL );if (rc <0 ) {
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerRFC PATCH 5/13 net: pcs: lynx: Convert to an MDIO driver
In reply to Sean AndersonThis converts the lynx PCS driver to a proper MDIO driver. This allows using a more conventional driver lifecycle (e.g. with a probe and remove). It will also make it easier to add interrupt support.
The existing helpers are converted to bind the MDIO driver instead of creating the PCS directly. As lynx_pcs_create_mdiodev creates the PCS device, we can just set the modalias. For lynx_pcs_create_fwnode, we try to get the PCS the usual way, and if that fails we edit the devicetree to add a compatible and reprobe the device.
---
drivers/net/dsa/ocelot/Kconfig | 4 + drivers/net/dsa/ocelot/felix_vsc9959.c | 11 +- drivers/net/dsa/ocelot/seville_vsc9953.c | 11 +- drivers/net/ethernet/altera/Kconfig | 2 + drivers/net/ethernet/altera/altera_tse_main.c | 7 +- drivers/net/ethernet/freescale/dpaa/Kconfig | 2 +- drivers/net/ethernet/freescale/dpaa2/Kconfig | 3 + .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 11 +- drivers/net/ethernet/freescale/enetc/Kconfig | 2 + .../net/ethernet/freescale/enetc/enetc_pf.c | 8 +- .../net/ethernet/freescale/enetc/enetc_pf.h | 1 - .../freescale/enetc/enetc_pf_common.c | 4 +- drivers/net/ethernet/freescale/fman/Kconfig | 4 +- .../net/ethernet/freescale/fman/fman_memac.c | 27 ++-- drivers/net/ethernet/stmicro/stmmac/Kconfig | 3 + .../ethernet/stmicro/stmmac/dwmac-socfpga.c | 6 +- drivers/net/pcs/Kconfig | 11 +- drivers/net/pcs/pcs-lynx.c | 115 ++++++++++-------- include/linux/pcs-lynx.h | 13 +- 19 files changed, 135 insertions(+), 110 deletions(-)
drivers/net/dsa/ocelot/Kconfig +4 -0
@@ -42,7 +42,9 @@ config NET_DSA_MSCC_FELIX select NET_DSA_TAG_OCELOT_8021Q select NET_DSA_TAG_OCELOT select FSL_ENETC_MDIO + select PCS select PCS_LYNX + select MDIO_DEVICE help This driver supports the VSC9959 (Felix) switch, which is embedded as a PCIe function of the NXP LS1028A ENETC RCiEP.
@@ -58,7 +60,9 @@ config NET_DSA_MSCC_SEVILLE select NET_DSA_MSCC_FELIX_DSA_LIB select NET_DSA_TAG_OCELOT_8021Q select NET_DSA_TAG_OCELOT + select PCS select PCS_LYNX + select MDIO_DEVICE help This driver supports the VSC9953 (Seville) switch, which is embedded as a platform device on the NXP T1040 SoC.
drivers/net/dsa/ocelot/felix_vsc9959.c +4 -7
@@ -12,6 +12,7 @@#include <net/tc_act/tc_gate.h> #include <soc/mscc/ocelot.h> #include <linux/dsa/ocelot.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <net/pkt_sched.h> #include <linux/iopoll.h>
@@ -1033,7 +1034,7 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)if (ocelot_port->phy_mode ==PHY_INTERFACE_MODE_INTERNAL )continue ; - phylink_pcs =lynx_pcs_create_mdiodev (felix->imdio, port); + phylink_pcs =lynx_pcs_create_mdiodev (dev, felix->imdio, port);if (IS_ERR (phylink_pcs))continue ;
@@ -1050,12 +1051,8 @@ static void vsc9959_mdio_bus_free(struct ocelot *ocelot)struct felix *felix =ocelot_to_felix (ocelot);int port; -for (port =0 ; port < ocelot->num_phys_ports; port++) { -struct phylink_pcs *phylink_pcs = felix->pcs[port]; - -if (phylink_pcs) -lynx_pcs_destroy (phylink_pcs); - } +for (port =0 ; port < ocelot->num_phys_ports; port++) +pcs_put (ocelot->dev, felix->pcs[port]);mdiobus_unregister (felix->imdio);mdiobus_free (felix->imdio); }
drivers/net/dsa/ocelot/seville_vsc9953.c +4 -7
@@ -10,6 +10,7 @@#include <linux/mdio/mdio-mscc-miim.h> #include <linux/mod_devicetable.h> #include <linux/of_mdio.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <linux/dsa/ocelot.h> #include <linux/iopoll.h>
@@ -926,7 +927,7 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)if (ocelot_port->phy_mode ==PHY_INTERFACE_MODE_INTERNAL )continue ; - phylink_pcs =lynx_pcs_create_mdiodev (felix->imdio, addr); + phylink_pcs =lynx_pcs_create_mdiodev (dev, felix->imdio, addr);if (IS_ERR (phylink_pcs))continue ;
@@ -943,12 +944,8 @@ static void vsc9953_mdio_bus_free(struct ocelot *ocelot)struct felix *felix =ocelot_to_felix (ocelot);int port; -for (port =0 ; port < ocelot->num_phys_ports; port++) { -struct phylink_pcs *phylink_pcs = felix->pcs[port]; - -if (phylink_pcs) -lynx_pcs_destroy (phylink_pcs); - } +for (port =0 ; port < ocelot->num_phys_ports; port++) +pcs_put (ocelot->dev, felix->pcs[port]);/* mdiobus_unregister and mdiobus_free handled by devres */ }
drivers/net/ethernet/altera/Kconfig +2 -0
@@ -5,7 +5,9 @@ config ALTERA_TSE depends on HAS_IOMEM select PHYLIB select PHYLINK + select PCS select PCS_LYNX + select MDIO_DEVICE select MDIO_REGMAP select REGMAP_MMIO help
drivers/net/ethernet/altera/altera_tse_main.c +4 -3
@@ -32,6 +32,7 @@#include <linux/of.h> #include <linux/of_mdio.h> #include <linux/of_net.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <linux/phy.h> #include <linux/platform_device.h>
@@ -1412,7 +1413,7 @@ static int altera_tse_probe(struct platform_device *pdev) goto err_init_pcs; } - priv->pcs =lynx_pcs_create_mdiodev (pcs_bus,0 ); + priv->pcs =lynx_pcs_create_mdiodev (&pdev->dev, pcs_bus,0 );if (IS_ERR (priv->pcs)) { ret =PTR_ERR (priv->pcs); goto err_init_pcs;
@@ -1444,7 +1445,7 @@ static int altera_tse_probe(struct platform_device *pdev)return 0 ; err_init_phylink: -lynx_pcs_destroy (priv->pcs); +pcs_put (&pdev->dev, priv->pcs); err_init_pcs:unregister_netdev (ndev); err_register_netdev:
@@ -1466,7 +1467,7 @@ static void altera_tse_remove(struct platform_device *pdev)altera_tse_mdio_destroy (ndev);unregister_netdev (ndev);phylink_destroy (priv->phylink); -lynx_pcs_destroy (priv->pcs); +pcs_put (&pdev->dev, priv->pcs);free_netdev (ndev); }
drivers/net/ethernet/freescale/dpaa/Kconfig +1 -1
@@ -3,7 +3,7 @@ menuconfig FSL_DPAA_ETH tristate "DPAA Ethernet" depends on FSL_DPAA && FSL_FMAN select PHYLINK - select PCS_LYNX + select MDIO_DEVICE help Data Path Acceleration Architecture Ethernet driver, supporting the Freescale QorIQ chips.
drivers/net/ethernet/freescale/dpaa2/Kconfig +3 -0
@@ -2,8 +2,11 @@ config FSL_DPAA2_ETH tristate "Freescale DPAA2 Ethernet" depends on FSL_MC_BUS && FSL_MC_DPIO + select OF_DYNAMIC select PHYLINK + select PCS select PCS_LYNX + select MDIO_DEVICE select FSL_XGMAC_MDIO select NET_DEVLINK help
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +4 -7
@@ -2,6 +2,7 @@/* Copyright 2019 NXP */ #include <linux/acpi.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <linux/phy/phy.h> #include <linux/property.h>
@@ -262,7 +263,7 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac,return 0 ; } - pcs =lynx_pcs_create_fwnode (node); + pcs =lynx_pcs_create_fwnode (&mac->mc_dev->dev, node);fwnode_handle_put (node);if (pcs ==ERR_PTR (-EPROBE_DEFER )) {
@@ -288,12 +289,8 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac,static void dpaa2_pcs_destroy (struct dpaa2_mac *mac) { -struct phylink_pcs *phylink_pcs = mac->pcs; - -if (phylink_pcs) { -lynx_pcs_destroy (phylink_pcs); - mac->pcs =NULL ; - } +pcs_put (&mac->mc_dev->dev, mac->pcs); + mac->pcs =NULL ; }static void dpaa2_mac_set_supported_interfaces (struct dpaa2_mac *mac)
drivers/net/ethernet/freescale/enetc/Kconfig +2 -0
@@ -24,7 +24,9 @@ config FSL_ENETC select FSL_ENETC_MDIO select NXP_ENETC_PF_COMMON select PHYLINK + select PCS select PCS_LYNX + select MDIO_DEVICE select DIMLIB help This driver supports NXP ENETC gigabit ethernet controller PCIe
drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 -7
@@ -34,12 +34,7 @@ static void enetc_pf_set_primary_mac_addr(struct enetc_hw *hw, int si,static struct phylink_pcs *enetc_pf_create_pcs (struct enetc_pf *pf,struct mii_bus *bus) { -return lynx_pcs_create_mdiodev (bus,0 ); -} - -static void enetc_pf_destroy_pcs (struct phylink_pcs *pcs) -{ -lynx_pcs_destroy (pcs); +return lynx_pcs_create_mdiodev (&pf->si->pdev->dev, bus,0 ); }static void enetc_set_vlan_promisc (struct enetc_hw *hw,char si_map)
@@ -1003,7 +998,6 @@ static const struct enetc_pf_ops enetc_pf_ops = { .set_si_primary_mac = enetc_pf_set_primary_mac_addr, .get_si_primary_mac = enetc_pf_get_primary_mac_addr, .create_pcs = enetc_pf_create_pcs, - .destroy_pcs = enetc_pf_destroy_pcs, .enable_psfp = enetc_psfp_enable, };
drivers/net/ethernet/freescale/enetc/enetc_pf.h +0 -1
@@ -42,7 +42,6 @@ struct enetc_pf_ops {void (*set_si_primary_mac)(struct enetc_hw *hw,int si,const u8 *addr);void (*get_si_primary_mac)(struct enetc_hw *hw,int si,u8 *addr);struct phylink_pcs *(*create_pcs)(struct enetc_pf *pf,struct mii_bus *bus); -void (*destroy_pcs)(struct phylink_pcs *pcs);int (*enable_psfp)(struct enetc_ndev_priv *priv); };
drivers/net/ethernet/freescale/enetc/enetc_pf_common.c +2 -2
@@ -4,6 +4,7 @@#include <linux/fsl/enetc_mdio.h> #include <linux/of_mdio.h> #include <linux/of_net.h> +#include <linux/pcs.h> #include "enetc_pf_common.h"
@@ -248,8 +249,7 @@ static int enetc_imdio_create(struct enetc_pf *pf)static void enetc_imdio_remove (struct enetc_pf *pf) { -if (pf->pcs && pf->ops->destroy_pcs) - pf->ops->destroy_pcs (pf->pcs); +pcs_put (&pf->si->pdev->dev, pf->pcs);if (pf->imdio) {mdiobus_unregister (pf->imdio);
drivers/net/ethernet/freescale/fman/Kconfig +3 -1
@@ -3,10 +3,12 @@ config FSL_FMAN tristate "FMan support" depends on FSL_SOC || ARCH_LAYERSCAPE || COMPILE_TEST select GENERIC_ALLOCATOR + select OF_DYNAMIC + select MDIO_DEVICE select PHYLINK + select PCS select PCS_LYNX select CRC32 - default n help Freescale Data-Path Acceleration Architecture Frame Manager (FMan) support
drivers/net/ethernet/freescale/fman/fman_memac.c +16 -11
@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/io.h> +#include <linux/pcs.h> #include <linux/pcs-lynx.h> #include <linux/phy.h> #include <linux/phy_fixed.h>
@@ -972,21 +973,23 @@ static int memac_init(struct fman_mac *memac)return 0 ; } -static void pcs_put (struct phylink_pcs *pcs) +static void memac_pcs_put (struct device *dev,struct phylink_pcs *pcs) {if (IS_ERR_OR_NULL (pcs))return ; -lynx_pcs_destroy (pcs); +pcs_put (dev, pcs); }static int memac_free (struct fman_mac *memac) { +struct device *dev = memac->dev_id->dev; +free_init_resources (memac); -pcs_put (memac->sgmii_pcs); -pcs_put (memac->qsgmii_pcs); -pcs_put (memac->xfi_pcs); +memac_pcs_put (dev, memac->sgmii_pcs); +memac_pcs_put (dev, memac->qsgmii_pcs); +memac_pcs_put (dev, memac->xfi_pcs);kfree (memac->memac_drv_param);kfree (memac);
@@ -1033,7 +1036,8 @@ static struct fman_mac *memac_config(struct mac_device *mac_dev,return memac; } -static struct phylink_pcs *memac_pcs_create (struct device_node *mac_node, +static struct phylink_pcs *memac_pcs_create (struct device *dev, +struct device_node *mac_node,int index) {struct device_node *node;
@@ -1043,7 +1047,7 @@ static struct phylink_pcs *memac_pcs_create(struct device_node *mac_node,if (!node)return ERR_PTR (-ENODEV ); - pcs =lynx_pcs_create_fwnode (of_fwnode_handle (node)); + pcs =lynx_pcs_create_fwnode (dev,of_fwnode_handle (node));of_node_put (node);return pcs;
@@ -1100,7 +1104,7 @@ int memac_initialization(struct mac_device *mac_dev, err =of_property_match_string (mac_node,"pcs-handle-names" ,"xfi" );if (err >=0 ) { - memac->xfi_pcs =memac_pcs_create (mac_node, err); + memac->xfi_pcs =memac_pcs_create (mac_dev->dev, mac_node, err);if (IS_ERR (memac->xfi_pcs)) { err =PTR_ERR (memac->xfi_pcs);dev_err_probe (mac_dev->dev, err,"missing xfi pcs\n" );
@@ -1112,7 +1116,8 @@ int memac_initialization(struct mac_device *mac_dev, err =of_property_match_string (mac_node,"pcs-handle-names" ,"qsgmii" );if (err >=0 ) { - memac->qsgmii_pcs =memac_pcs_create (mac_node, err); + memac->qsgmii_pcs =memac_pcs_create (mac_dev->dev, mac_node, + err);if (IS_ERR (memac->qsgmii_pcs)) { err =PTR_ERR (memac->qsgmii_pcs); dev_err_probe(mac_dev->dev, err,
@@ -1128,11 +1133,11 @@ int memac_initialization(struct mac_device *mac_dev,*/ err =of_property_match_string (mac_node,"pcs-handle-names" ,"sgmii" );if (err == -EINVAL || err == -ENODATA ) - pcs =memac_pcs_create (mac_node,0 ); + pcs =memac_pcs_create (mac_dev->dev, mac_node,0 );else if (err <0 ) goto _return_fm_mac_free;else - pcs =memac_pcs_create (mac_node, err); + pcs =memac_pcs_create (mac_dev->dev, mac_node, err);if (IS_ERR (pcs)) { err =PTR_ERR (pcs);
drivers/net/ethernet/stmicro/stmmac/Kconfig +3 -0
@@ -170,9 +170,12 @@ config DWMAC_SOCFPGA tristate "SOCFPGA dwmac support" default ARCH_INTEL_SOCFPGA depends on OF && (ARCH_INTEL_SOCFPGA || COMPILE_TEST) + select OF_DYNAMIC select MFD_SYSCON + select MDIO_DEVICE select MDIO_REGMAP select REGMAP_MMIO + select PCS select PCS_LYNX help Support for ethernet controller on Altera SOCFPGA
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +3 -3
@@ -8,6 +8,7 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_net.h> +#include <linux/pcs.h> #include <linux/phy.h> #include <linux/regmap.h> #include <linux/mdio/mdio-regmap.h>
@@ -415,7 +416,7 @@ static int socfpga_dwmac_pcs_init(struct stmmac_priv *priv)if (IS_ERR (pcs_bus))return PTR_ERR (pcs_bus); - pcs =lynx_pcs_create_mdiodev (pcs_bus,0 ); + pcs =lynx_pcs_create_mdiodev (priv->device, pcs_bus,0 );if (IS_ERR (pcs))return PTR_ERR (pcs);
@@ -425,8 +426,7 @@ static int socfpga_dwmac_pcs_init(struct stmmac_priv *priv)static void socfpga_dwmac_pcs_exit (struct stmmac_priv *priv) { -if (priv->hw->phylink_pcs) -lynx_pcs_destroy (priv->hw->phylink_pcs); +pcs_put (priv->device, priv->hw->phylink_pcs); } static struct phylink_pcs *socfpga_dwmac_select_pcs(struct stmmac_priv *priv,
drivers/net/pcs/Kconfig +8 -3
@@ -25,10 +25,15 @@ config PCS_XPCS DesignWare XPCS controllers. config PCS_LYNX - tristate + tristate "NXP Lynx PCS driver" + depends on PCS && MDIO_DEVICE help - This module provides helpers to phylink for managing the Lynx PCS - which is part of the Layerscape and QorIQ Ethernet SERDES. + This module provides driver support for the PCSs in Lynx 10g and 28g + SerDes devices. These devices are present in NXP QorIQ SoCs, + including the Layerscape series. + + If you want to use Ethernet on a QorIQ SoC, say "Y". If compiled as a + module, it will be called "pcs-lynx". config PCS_MTK_LYNXI tristate
drivers/net/pcs/pcs-lynx.c +64 -51
163 lines not on this page · raw message
include/linux/pcs-lynx.h +7 -6
@@ -6,12 +6,13 @@#ifndef __LINUX_PCS_LYNX_H#define __LINUX_PCS_LYNX_H -#include <linux/mdio.h> -#include <linux/phylink.h> +struct device ; +struct mii_bus ; +struct phylink_pcs ; -struct phylink_pcs *lynx_pcs_create_mdiodev (struct mii_bus *bus,int addr); -struct phylink_pcs *lynx_pcs_create_fwnode (struct fwnode_handle *node); - -void lynx_pcs_destroy (struct phylink_pcs *pcs); +struct phylink_pcs *lynx_pcs_create_mdiodev (struct device *dev, +struct mii_bus *bus,int addr); +struct phylink_pcs *lynx_pcs_create_fwnode (struct device *dev, +struct fwnode_handle *node);#endif /* __LINUX_PCS_LYNX_H */
Signature · 1 line
2.35.1.1320.gc452695387.dirty
kernel test robot
build botRe: [RFC net-next PATCH 05/13] net: pcs: lynx: Convert to an MDIO driver
kernel test robot noticed the following build warnings:
Hi Sean,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/dt-bindings-net-Add-binding-for-Xilinx-PCS/20250404-023209 base: net-next/main patch link: https://lore.kernel.org/r/20250403181907.1947517-6-sean.anderson%40linux.dev patch subject: [RFC net-next PATCH 05/13] net: pcs: lynx: Convert to an MDIO driver config: loongarch-randconfig-001-20250404 (https://download.01.org/0day-ci/archive/20250404/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250404/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/net/pcs/pcs-lynx.c:414:36: warning: 'lynx_properties' defined but not used [-Wunused-const-variable=]
414 | static const struct property_entry lynx_properties[] = {
| ^~~~~~~~~~~~~~~vim +/lynx_properties +414 drivers/net/pcs/pcs-lynx.c
413
> 414 static const struct property_entry lynx_properties[] = { 415 PROPERTY_ENTRY_STRING("compatible", "fsl,lynx-pcs"),
416 { },
417 };
418
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Sean Anderson
reviewerRFC PATCH 6/13 net: phy: Export some functions
In reply to Sean AndersonExport a few functions so they can be used outside the phy subsystem:
get_phy_c22_id is useful when probing MDIO devices which present a phy-like interface despite not using the Linux ethernet phy subsystem.
mdio_device_bus_match is useful when creating MDIO devices manually (e.g. on non-devicetree platforms).
---
drivers/net/phy/mdio_device.c | 1 + drivers/net/phy/phy_device.c | 3 ++- include/linux/phy.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/phy/mdio_device.c +1 -0
@@ -45,6 +45,7 @@ int mdio_device_bus_match(struct device *dev, const struct device_driver *drv)return strcmp (mdiodev->modalias, drv->name) ==0 ; } +EXPORT_SYMBOL_GPL (mdio_device_bus_match);struct mdio_device *mdio_device_create (struct mii_bus *bus,int addr) {
drivers/net/phy/phy_device.c +2 -1
@@ -859,7 +859,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,* valid, %-EIO on bus access error, or %-ENODEV if no device responds * or invalid ID. */ -static int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id) +int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id) {int phy_reg;
@@ -887,6 +887,7 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)return 0 ; } +EXPORT_SYMBOL_GPL (get_phy_c22_id);/* Extract the phy ID from the compatible string of the form * ethernet-phy-idAAAA.BBBB.
include/linux/phy.h +1 -0
@@ -1754,6 +1754,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,bool is_c45, struct phy_c45_device_ids *c45_ids);#if IS_ENABLED (CONFIG_PHYLIB ) +int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id);int fwnode_get_phy_id (struct fwnode_handle *fwnode,u32 *phy_id);struct mdio_device *fwnode_mdio_find_device (struct fwnode_handle *fwnode);struct phy_device *fwnode_phy_find_device (struct fwnode_handle *phy_fwnode);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [RFC net-next PATCH 06/13] net: phy: Export some functions
Quoted 54 lines · Sean Anderson
Export a few functions so they can be used outside the phy subsystem:
get_phy_c22_idis useful when probing MDIO devices which present a phy-like interface despite not using the Linux ethernet phy subsystem.
mdio_device_bus_matchis useful when creating MDIO devices manually (e.g. on non-devicetree platforms).Signed-off-by Sean Anderson <[email protected]>---
drivers/net/phy/mdio_device.c | 1 + drivers/net/phy/phy_device.c | 3 ++- include/linux/phy.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)drivers/net/phy/mdio_device.c +1
-0@@ -45,6 +45,7 @@ int mdio_device_bus_match(struct device *dev, const struct device_driver *drv)return strcmp (mdiodev->modalias, drv->name) ==0 ; } +EXPORT_SYMBOL_GPL (mdio_device_bus_match);struct mdio_device *mdio_device_create (struct mii_bus *bus,int addr) {drivers/net/phy/phy_device.c +2
-1@@ -859,7 +859,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,* valid, %-EIO on bus access error, or %-ENODEV if no device responds * or invalid ID. */ -static int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id) +int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id) {int phy_reg;@@ -887,6 +887,7 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)return 0 ; } +EXPORT_SYMBOL_GPL (get_phy_c22_id);/* Extract the phy ID from the compatible string of the form * ethernet-phy-idAAAA.BBBB. include/linux/phy.h +0
-0
include/linux/phy.h struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, · line 1757
Quoted 4 lines
include/linux/phy.h +1
-0@@ -1754,6 +1754,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,bool is_c45, struct phy_c45_device_ids *c45_ids);#if IS_ENABLED (CONFIG_PHYLIB ) +int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id);
Seems like you will need to provide an empty inline stub for when CONFIG_PHYLIB=n?
Signature · 1 line
Florian
Sean Anderson
reviewerRe: [RFC net-next PATCH 06/13] net: phy: Export some functions
Quoted 48 lines · Florian Fainelli
Quoted 47 lines · Sean Anderson
Export a few functions so they can be used outside the phy subsystem:
get_phy_c22_idis useful when probing MDIO devices which present a phy-like interface despite not using the Linux ethernet phy subsystem.
mdio_device_bus_matchis useful when creating MDIO devices manually (e.g. on non-devicetree platforms).Signed-off-by Sean Anderson <[email protected]>---
drivers/net/phy/mdio_device.c | 1 + drivers/net/phy/phy_device.c | 3 ++- include/linux/phy.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)drivers/net/phy/mdio_device.c +1
-0@@ -45,6 +45,7 @@ int mdio_device_bus_match(struct device *dev, const struct device_driver *drv)return strcmp (mdiodev->modalias, drv->name) ==0 ; } +EXPORT_SYMBOL_GPL (mdio_device_bus_match);struct mdio_device *mdio_device_create (struct mii_bus *bus,int addr) {drivers/net/phy/phy_device.c +1
-1@@ -859,7 +859,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,* valid, %-EIO on bus access error, or %-ENODEV if no device responds * or invalid ID. */ -static int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id) +int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id) {int phy_reg; @@ -887,6 +887,7 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)return 0;}
drivers/net/phy/phy_device.c +1
-0+EXPORT_SYMBOL_GPL (get_phy_c22_id);/* Extract the phy ID from the compatible string of the form * ethernet-phy-idAAAA.BBBB. include/linux/phy.h +0
-1--- a/include/linux/phy.h
Quoted 8 lines
include/linux/phy.h struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, · line 1757
Quoted 6 lines
+++
b/include/linux/phy.hinclude/linux/phy.h +1
-0@@ -1754,6 +1754,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,bool is_c45, struct phy_c45_device_ids *c45_ids);#if IS_ENABLED (CONFIG_PHYLIB ) +int get_phy_c22_id (struct mii_bus *bus,int addr,u32 *phy_id);Seems like you will need to provide an empty inline stub for when
CONFIG_PHYLIB=n?
The only user (CONFIG_PCS_XILINX) selects CONFIG_PHYLINK which selects CONFIG_PHYLIB. So I don't think this can occur yet.
--Sean
Sean Anderson
reviewerRFC PATCH 7/13 net: pcs: Add Xilinx PCS driver
In reply to Sean AndersonThis adds support for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. This is a soft device which converts between GMII and either SGMII, 1000Base-X, or 2500Base-X. If configured correctly, it can also switch between SGMII and 1000BASE-X at runtime. Thoretically this is also possible for 2500Base-X, but that requires reconfiguring the serdes. The exact capabilities depend on synthesis parameters, so they are read from the devicetree.
This device has a c22-compliant PHY interface, so for the most part we can just use the phylink helpers. This device supports an interrupt which is triggered on autonegotiation completion. I'm not sure how useful this is, since we can never detect a link down (in the PCS).
This device supports sharing some logic between different implementations of the device. In this case, one device contains the "shared logic" and the clocks are connected to other devices. To coordinate this, one device registers a clock that the other devices can request. The clock is enabled in the probe function by releasing the device from reset. There are no othe software controls, so the clock ops are empty.
Later in this series, we will convert the Xilinx AXI Ethernet driver to use this PCS. To help out, we provide a compatibility function to bind this driver in the event the MDIO device has no compatible.
---
MAINTAINERS | 6 + drivers/net/pcs/Kconfig | 28 ++ drivers/net/pcs/Makefile | 2 + drivers/net/pcs/pcs-xilinx.c | 481 +++++++++++++++++++++++++++++++++++ include/linux/pcs-xilinx.h | 36 +++ 5 files changed, 553 insertions(+) create mode 100644 drivers/net/pcs/pcs-xilinx.c create mode 100644 include/linux/pcs-xilinx.h
MAINTAINERS +6 -0
@@ -26160,6 +26160,12 @@ L: [email protected] S: Orphan F: drivers/net/ethernet/xilinx/ll_temac* +XILINX PCS DRIVER +M: Sean Anderson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/xilinx,pcs.yaml +F: drivers/net/pcs/pcs-xilinx.c + XILINX PWM DRIVER M: Sean Anderson <[email protected]> S: Maintained
drivers/net/pcs/Kconfig +28 -0
@@ -50,4 +50,32 @@ config PCS_RZN1_MIIC on RZ/N1 SoCs. This PCS converts MII to RMII/RGMII or can be set in pass-through mode for MII. +config PCS_ALTERA_TSE + tristate + help + This module provides helper functions for the Altera Triple Speed + Ethernet SGMII PCS, that can be found on the Intel Socfpga family. + +config PCS_XILINX + depends on OF + depends on GPIOLIB + depends on COMMON_CLK + depends on PCS + select MDIO_DEVICE + select PHYLINK + default XILINX_AXI_EMAC + tristate "Xilinx PCS driver" + help + PCS driver for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device. + This device can either act as a PCS+PMA for 1000BASE-X or 2500BASE-X, + or as a GMII-to-SGMII bridge. It can also switch between 1000BASE-X + and SGMII dynamically if configured correctly when synthesized. + Typical applications use this device on an FPGA connected to a GEM or + TEMAC on the GMII side. The other side is typically connected to + on-device gigabit transceivers, off-device SERDES devices using TBI, + or LVDS IO resources directly. + + To compile this driver as a module, choose M here: the module + will be called pcs-xilinx. + endmenu
drivers/net/pcs/Makefile +2 -0
@@ -10,3 +10,5 @@ obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o obj-$(CONFIG_PCS_MTK_LYNXI) += pcs-mtk-lynxi.o obj-$(CONFIG_PCS_RZN1_MIIC) += pcs-rzn1-miic.o +obj-$(CONFIG_PCS_ALTERA_TSE) += pcs-altera-tse.o +obj-$(CONFIG_PCS_XILINX) += pcs-xilinx.o
drivers/net/pcs/pcs-xilinx.c new file +481 -0
481 lines not on this page · raw message
include/linux/pcs-xilinx.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2024 Sean Anderson <[email protected]> +*/ + +#ifndef PCS_XILINX_H +#define PCS_XILINX_H + +#include <linux/err.h> + +struct device ; +struct phylink_pcs ; + +#ifdef CONFIG_PCS_XILINX +/** +* axienet_xilinx_pcs_get() - Compatibility function for the AXI Ethernet driver +* @dev: The MAC device +* @interfaces: The interfaces to use as a fallback +* +* This is a helper function for the AXI Ethernet driver to ensure backwards +* compatibility with device trees which do not include compatible strings for +* the PCS. It should not be used by new code. +* +* Return: a PCS, or an error pointer +*/ +struct phylink_pcs *axienet_xilinx_pcs_get (struct device *dev, +const unsigned long *interfaces); +#else +static inline struct phylink_pcs * +axienet_xilinx_pcs_get (struct device *dev,const unsigned long *interfaces) +{ +return ERR_PTR (-ENODEV ); +} +#endif + +#endif /* PCS_XILINX_H */
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Russell King (Oracle)
maintainerRe: [RFC net-next PATCH 07/13] net: pcs: Add Xilinx PCS driver
Quoted 19 lines · Sean Anderson
drivers/net/pcs/pcs-xilinx.c new file +19
-0+static int xilinx_pcs_validate (struct phylink_pcs *pcs, +unsigned long *supported, +const struct phylink_link_state *state) +{ +__ETHTOOL_DECLARE_LINK_MODE_MASK (xilinx_supported) = {0 }; + +phylink_set_port_modes (xilinx_supported); +phylink_set (xilinx_supported, Autoneg); +phylink_set (xilinx_supported, Pause); +phylink_set (xilinx_supported, Asym_Pause); +switch (state->interface) { +case PHY_INTERFACE_MODE_SGMII : +/* Half duplex not supported */ + phylink_set(xilinx_supported, 10baseT_Full); + phylink_set(xilinx_supported, 100baseT_Full); + phylink_set(xilinx_supported, 1000baseT_Full); +break ; +case PHY_INTERFACE_MODE_1000BASEX : + phylink_set(xilinx_supported, 1000baseX_Full);
drivers/net/pcs/pcs-xilinx.c line 157
Quoted 10 lines
drivers/net/pcs/pcs-xilinx.c new file +10
-0+break ; +case PHY_INTERFACE_MODE_2500BASEX : + phylink_set(xilinx_supported, 2500baseX_Full); +break ; +default : +return -EINVAL ; + } + +linkmode_and (supported, supported, xilinx_supported); +return 0 ;
You can not assume that an interface mode implies any particular media. For example, you can not assume that just because you have SGMII, that the only supported media is BaseT. This has been a fundamental principle in phylink's validation since day one.
Phylink documentation for the pcs_validate() callback states:
* Validate the interface mode, and advertising's autoneg bit, removing any
* media ethtool link modes that would not be supportable from the supported
* mask. Phylink will propagate the changes to the advertising mask. See the
* &struct phylink_mac_ops validate() method.
and if we look at the MAC ops validate (before it was removed):
- * Clear bits in the @supported and @state->advertising masks that
- * are not supportable by the MAC.
- *
- * Note that the PHY may be able to transform from one connection
- * technology to another, so, eg, don't clear 1000BaseX just
- * because the MAC is unable to BaseX mode. This is more about
- * clearing unsupported speeds and duplex settings. The port modes
- * should not be cleared; phylink_set_port_modes() will help with this.
PHYs can and do take SGMII and provide both BaseT and BaseX or BaseR connections. A PCS that is not directly media facing can not dictate the link modes.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Sean Anderson
reviewerRe: [RFC net-next PATCH 07/13] net: pcs: Add Xilinx PCS driver
Quoted 54 lines · Russell King (Oracle)
Quoted 19 lines · Sean Anderson
drivers/net/pcs/pcs-xilinx.c new file +19
-0+static int xilinx_pcs_validate (struct phylink_pcs *pcs, +unsigned long *supported, +const struct phylink_link_state *state) +{ +__ETHTOOL_DECLARE_LINK_MODE_MASK (xilinx_supported) = {0 }; + +phylink_set_port_modes (xilinx_supported); +phylink_set (xilinx_supported, Autoneg); +phylink_set (xilinx_supported, Pause); +phylink_set (xilinx_supported, Asym_Pause); +switch (state->interface) { +case PHY_INTERFACE_MODE_SGMII : +/* Half duplex not supported */ + phylink_set(xilinx_supported, 10baseT_Full); + phylink_set(xilinx_supported, 100baseT_Full); + phylink_set(xilinx_supported, 1000baseT_Full); +break ; +case PHY_INTERFACE_MODE_1000BASEX : + phylink_set(xilinx_supported, 1000baseX_Full);drivers/net/pcs/pcs-xilinx.c line 157
Quoted 10 lines
drivers/net/pcs/pcs-xilinx.c new file +10
-0+break ; +case PHY_INTERFACE_MODE_2500BASEX : + phylink_set(xilinx_supported, 2500baseX_Full); +break ; +default : +return -EINVAL ; + } + +linkmode_and (supported, supported, xilinx_supported); +return 0 ;You can not assume that an interface mode implies any particular media. For example, you can not assume that just because you have SGMII, that the only supported media is BaseT. This has been a fundamental principle in phylink's validation since day one.
Phylink documentation for the
pcs_validate()callback states:* Validate the interface mode, and advertising's autoneg bit, removing any
* media ethtool link modes that would not be supportable from the supported
* mask. Phylink will propagate the changes to the advertising mask. See the
* &structphylink_mac_opsvalidate()method.and if we look at the MAC ops validate (before it was removed):
- * Clear bits in the @supported and @state->advertising masks that
- * are not supportable by the MAC.
- *
- * Note that the PHY may be able to transform from one connection
- * technology to another, so, eg, don't clear 1000BaseX just
- * because the MAC is unable to BaseX mode. This is more about
- * clearing unsupported speeds and duplex settings. The port modes
- * should not be cleared;phylink_set_port_modes()will help with this.
Quoted 4 lines
PHYs can and do take SGMII and provide both BaseT and BaseX or BaseR connections. A PCS that is not directly media facing can not dictate the link modes.
OK, how about this:
static int xilinx_pcs_validate(struct phylink_pcs *pcs,
unsigned long *supported, const struct phylink_link_state *state)
{
__ETHTOOL_DECLARE_LINK_MODE_MASK(xilinx_supported) = { 0 };
unsigned long caps = phy_caps_from_interface(state->interface);
phylink_set_port_modes(xilinx_supported);
phylink_set(xilinx_supported, Autoneg);
phylink_set(xilinx_supported, Pause);
phylink_set(xilinx_supported, Asym_Pause);
/* Half duplex not supported */
caps &= ~(LINK_CAPA_10HD | LINK_CAPA_100HD | LINK_CAPA_1000HD);
phy_caps_linkmodes(caps, xilinx_supported);
linkmode_and(supported, supported, xilinx_supported);
return 0;
}--Sean
Sean Anderson
reviewerRFC PATCH 8/13 net: axienet: Convert to use PCS subsystem
In reply to Sean AndersonConvert the AXI Ethernet driver to use the PCS subsystem, including the new Xilinx PCA/PMA driver. Unfortunately, we must use a helper to work with bare MDIO nodes without a compatible.
---
drivers/net/ethernet/xilinx/Kconfig | 1 + drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 104 ++++-------------- drivers/net/pcs/Kconfig | 1 - 4 files changed, 22 insertions(+), 88 deletions(-)
drivers/net/ethernet/xilinx/Kconfig +1 -0
@@ -27,6 +27,7 @@ config XILINX_AXI_EMAC tristate "Xilinx 10/100/1000 AXI Ethernet support" depends on HAS_IOMEM depends on XILINX_DMA + select OF_DYNAMIC if PCS_XILINX select PHYLINK select DIMLIB help
drivers/net/ethernet/xilinx/xilinx_axienet.h +1 -3
@@ -473,7 +473,6 @@ struct skbuf_dma_descriptor {* @dev: Pointer to device structure * @phylink: Pointer to phylink instance * @phylink_config: phylink configuration settings -* @pcs_phy: Reference to PCS/PMA PHY if used * @pcs: phylink pcs structure for PCS PHY * @switch_x_sgmii: Whether switchable 1000BaseX/SGMII mode is enabled in the core * @axi_clk: AXI4-Lite bus clock
@@ -553,8 +552,7 @@ struct axienet_local {struct phylink *phylink;struct phylink_config phylink_config; -struct mdio_device *pcs_phy; -struct phylink_pcs pcs; +struct phylink_pcs *pcs;bool switch_x_sgmii;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +20 -84
142 lines not on this page · raw message
drivers/net/pcs/Kconfig +0 -1
@@ -63,7 +63,6 @@ config PCS_XILINX depends on PCS select MDIO_DEVICE select PHYLINK - default XILINX_AXI_EMAC tristate "Xilinx PCS driver" help PCS driver for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device.
Signature · 1 line
2.35.1.1320.gc452695387.dirty
kernel test robot
build botRe: [RFC net-next PATCH 08/13] net: axienet: Convert to use PCS subsystem
kernel test robot noticed the following build errors:
Hi Sean,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Sean-Anderson/dt-bindings-net-Add-binding-for-Xilinx-PCS/20250404-023209 base: net-next/main patch link: https://lore.kernel.org/r/20250403181907.1947517-9-sean.anderson%40linux.dev patch subject: [RFC net-next PATCH 08/13] net: axienet: Convert to use PCS subsystem config: i386-buildonly-randconfig-001-20250404 (https://download.01.org/0day-ci/archive/20250404/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250404/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "pcs_put" [drivers/net/ethernet/xilinx/xilinx_emac.ko] undefined!
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Sean Anderson
reviewerRFC PATCH 9/13 net: macb: Move most of mac_config to mac_prepare
In reply to Sean Andersonmac_prepare is called every time the interface is changed, so we can do all of our configuration there, instead of in mac_config. This will be useful for the next patch where we will set the PCS bit based on whether we are using our internal PCS. No functional change intended.
---
drivers/net/ethernet/cadence/macb_main.c | 209 ++++++++++++++--------- drivers/net/pcs/Kconfig | 1 + 2 files changed, 133 insertions(+), 77 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +132 -77
@@ -549,19 +549,91 @@ static void macb_set_tx_clk(struct macb *bp, int speed)netdev_err (bp->dev,"adjusting tx_clk failed.\n" ); } -static void macb_usx_pcs_link_up (struct phylink_pcs *pcs,unsigned int neg_mode, -phy_interface_t interface,int speed, -int duplex) -{ - struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs); -u32 config; - - config =gem_readl (bp,USX_CONTROL ); - config =GEM_BFINS (SERDES_RATE ,MACB_SERDES_RATE_10G , config); - config =GEM_BFINS (USX_CTRL_SPEED ,HS_SPEED_10000M , config); - config &= ~(GEM_BIT (TX_SCR_BYPASS ) |GEM_BIT (RX_SCR_BYPASS )); - config |=GEM_BIT (TX_EN ); -gem_writel (bp,USX_CONTROL , config); +static void macb_pcs_get_state (struct phylink_pcs *pcs, +struct phylink_link_state *state) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); + +phylink_mii_c22_pcs_decode_state (state,gem_readl (bp,PCSSTS ), +gem_readl (bp,PCSANLPBASE )); +} + +/** +* macb_pcs_config_an() - Configure autonegotiation settings for PCSs +* @bp - The macb to operate on +* @neg_mode - The autonegotiation mode +* @interface - The interface to use +* @advertising - The advertisement mask +* +* This provides common configuration for PCS autonegotiation. +* +* Context: Call with @bp->lock held. +* Return: 1 if any registers were changed; 0 otherwise +*/ +static int macb_pcs_config_an (struct macb *bp,unsigned int neg_mode, +phy_interface_t interface, +const unsigned long *advertising) +{ +bool changed = false; +int old, new; + + old =gem_readl (bp,PCSANADV ); + new =phylink_mii_c22_pcs_encode_advertisement (interface, advertising); +if (new != -EINVAL && old != new) { + changed = true; +gem_writel (bp,PCSANADV , new); + } + + old = new =gem_readl (bp,PCSCNTRL ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) + new |=BMCR_ANENABLE ; +else + new &= ~BMCR_ANENABLE ; +if (old != new) { + changed = true; +gem_writel (bp,PCSCNTRL , new); + } +return changed; +} + +static int macb_pcs_config (struct phylink_pcs *pcs,unsigned int mode, +phy_interface_t interface, +const unsigned long *advertising, +bool permit_pause_to_mac) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); +bool changed = false; +unsigned long flags; +u32 old, new; + +spin_lock_irqsave (&bp->lock, flags); + old = new =gem_readl (bp,NCFGR ); + new |=GEM_BIT (SGMIIEN ); +if (old != new) { + changed = true; +gem_writel (bp,NCFGR , new); + } + +if (macb_pcs_config_an (bp, mode, interface, advertising)) + changed = true; + +spin_unlock_irqrestore (&bp->lock, flags); +return changed; +} + +static void macb_pcs_an_restart (struct phylink_pcs *pcs) +{ + struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); +u32 bmcr; +unsigned long flags; + +spin_lock_irqsave (&bp->lock, flags); + + bmcr =gem_readl (bp,PCSCNTRL ); + bmcr |=BMCR_ANENABLE ; +gem_writel (bp,PCSCNTRL , bmcr); + +spin_lock_irqsave (&bp->lock, flags); } static void macb_usx_pcs_get_state(struct phylink_pcs *pcs,
@@ -589,45 +661,60 @@ static int macb_usx_pcs_config(struct phylink_pcs *pcs, bool permit_pause_to_mac) { struct macb *bp = container_of(pcs, struct macb, phylink_usx_pcs); +unsigned long flags; +bool changed; +u16 old, new; -gem_writel (bp,USX_CONTROL ,gem_readl (bp,USX_CONTROL ) | -GEM_BIT (SIGNAL_OK )); +spin_lock_irqsave (&bp->lock, flags); +if (macb_pcs_config_an (bp, neg_mode, interface, advertising)) + changed = true; -return 0 ; -} + old = new =gem_readl (bp,USX_CONTROL ); + new |=GEM_BIT (SIGNAL_OK ); +if (old != new) { + changed = true; +gem_writel (bp,USX_CONTROL , new); + } -static void macb_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode, -struct phylink_link_state *state) -{ - state->link =0 ; -} + old = new =gem_readl (bp,USX_CONTROL ); + new =GEM_BFINS (SERDES_RATE ,MACB_SERDES_RATE_10G , new); + new =GEM_BFINS (USX_CTRL_SPEED ,HS_SPEED_10000M , new); + new &= ~(GEM_BIT (TX_SCR_BYPASS ) |GEM_BIT (RX_SCR_BYPASS )); + new |=GEM_BIT (TX_EN ); +if (old != new) { + changed = true; +gem_writel (bp,USX_CONTROL , new); + } -static void macb_pcs_an_restart (struct phylink_pcs *pcs) -{ -/* Not supported */ -} - -static int macb_pcs_config (struct phylink_pcs *pcs, -unsigned int neg_mode, -phy_interface_t interface, -const unsigned long *advertising, -bool permit_pause_to_mac) -{ -return 0 ; +spin_unlock_irqrestore (&bp->lock, flags); +return changed; }static const struct phylink_pcs_ops macb_phylink_usx_pcs_ops = { .pcs_get_state = macb_usx_pcs_get_state, .pcs_config = macb_usx_pcs_config, - .pcs_link_up = macb_usx_pcs_link_up, };static const struct phylink_pcs_ops macb_phylink_pcs_ops = { .pcs_get_state = macb_pcs_get_state, - .pcs_an_restart = macb_pcs_an_restart, .pcs_config = macb_pcs_config, + .pcs_an_restart = macb_pcs_an_restart, }; +static struct phylink_pcs *macb_mac_select_pcs (struct phylink_config *config, +phy_interface_t interface) +{ +struct net_device *ndev =to_net_dev (config->dev); +struct macb *bp =netdev_priv (ndev); + +if (interface ==PHY_INTERFACE_MODE_10GBASER ) +return &bp->phylink_usx_pcs; +else if (interface ==PHY_INTERFACE_MODE_SGMII ) +return &bp->phylink_sgmii_pcs; +else +return NULL ; +} +static void macb_mac_config (struct phylink_config *config,unsigned int mode,const struct phylink_link_state *state) {
@@ -646,18 +733,14 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,if (state->interface ==PHY_INTERFACE_MODE_RMII ) ctrl |=MACB_BIT (RM9200_RMII ); }else if (macb_is_gem (bp)) { - ctrl &= ~(GEM_BIT (SGMIIEN ) |GEM_BIT (PCSSEL )); - ncr &= ~GEM_BIT (ENABLE_HS_MAC ); - -if (state->interface ==PHY_INTERFACE_MODE_SGMII ) { - ctrl |=GEM_BIT (SGMIIEN ) |GEM_BIT (PCSSEL ); - }else if (state->interface ==PHY_INTERFACE_MODE_10GBASER ) { +if (macb_mac_select_pcs (config, state->interface)) ctrl |=GEM_BIT (PCSSEL ); - ncr |=GEM_BIT (ENABLE_HS_MAC ); - }else if (bp->caps &MACB_CAPS_MIIONRGMII && - bp->phy_interface ==PHY_INTERFACE_MODE_MII ) { +else + ctrl &= ~GEM_BIT (PCSSEL ); + +if (bp->caps &MACB_CAPS_MIIONRGMII && + bp->phy_interface ==PHY_INTERFACE_MODE_MII ) ncr |=MACB_BIT (MIIONRGMII ); - } }/* Apply the new configuration, if any */
@@ -667,22 +750,6 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,if (old_ncr ^ ncr)macb_or_gem_writel (bp,NCR , ncr); -/* Disable AN for SGMII fixed link configuration, enable otherwise. -* Must be written after PCSSEL is set in NCFGR, -* otherwise writes will not take effect. -*/ -if (macb_is_gem (bp) && state->interface ==PHY_INTERFACE_MODE_SGMII ) { -u32 pcsctrl, old_pcsctrl; - - old_pcsctrl =gem_readl (bp,PCSCNTRL ); -if (mode ==MLO_AN_FIXED ) - pcsctrl = old_pcsctrl & ~GEM_BIT (PCSAUTONEG ); -else - pcsctrl = old_pcsctrl |GEM_BIT (PCSAUTONEG ); -if (old_pcsctrl != pcsctrl) -gem_writel (bp,PCSCNTRL , pcsctrl); - } -spin_unlock_irqrestore (&bp->lock, flags); }
@@ -735,10 +802,12 @@ static void macb_mac_link_up(struct phylink_config *config,if (!(bp->caps &MACB_CAPS_MACB_IS_EMAC )) { ctrl &= ~MACB_BIT (PAE );if (macb_is_gem (bp)) { - ctrl &= ~GEM_BIT (GBE ); + ctrl &= ~(GEM_BIT (GBE ) |GEM_BIT (ENABLE_HS_MAC ));if (speed ==SPEED_1000 ) ctrl |=GEM_BIT (GBE ); +else if (speed ==SPEED_10000 ) + ctrl |=GEM_BIT (ENABLE_HS_MAC ); }if (rx_pause)
@@ -776,20 +845,6 @@ static void macb_mac_link_up(struct phylink_config *config,netif_tx_wake_all_queues (ndev); } -static struct phylink_pcs *macb_mac_select_pcs (struct phylink_config *config, -phy_interface_t interface) -{ -struct net_device *ndev =to_net_dev (config->dev); -struct macb *bp =netdev_priv (ndev); - -if (interface ==PHY_INTERFACE_MODE_10GBASER ) -return &bp->phylink_usx_pcs; -else if (interface ==PHY_INTERFACE_MODE_SGMII ) -return &bp->phylink_sgmii_pcs; -else -return NULL ; -} -static const struct phylink_mac_ops macb_phylink_ops = { .mac_select_pcs = macb_mac_select_pcs, .mac_config = macb_mac_config,
drivers/net/pcs/Kconfig +1 -0
@@ -63,6 +63,7 @@ config PCS_XILINX depends on PCS select MDIO_DEVICE select PHYLINK + default XILINX_AXI_EMAC tristate "Xilinx PCS driver" help PCS driver for the Xilinx 1G/2.5G Ethernet PCS/PMA or SGMII device.
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerRFC PATCH 10/13 net: macb: Support external PCSs
In reply to Sean AndersonThis adds support for external PCSs. For example, the Xilinx UltraScale+ processor exposes its GMII interface to the FPGA fabric. This fabric may implement PCS to convert GMII to a serial interface such as SGMII or 1000BASE-X. When present, the external PCS takes precedence over the internal PCSs.
---
drivers/net/ethernet/cadence/macb.h | 1 + drivers/net/ethernet/cadence/macb_main.c | 30 ++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-)
drivers/net/ethernet/cadence/macb.h +1 -0
@@ -1291,6 +1291,7 @@ struct macb {struct phylink_config phylink_config;struct phylink_pcs phylink_usx_pcs;struct phylink_pcs phylink_sgmii_pcs; +struct phylink_pcs *phylink_ext_pcs;u32 caps;unsigned int dma_burst_length;
drivers/net/ethernet/cadence/macb_main.c +26 -4
@@ -21,6 +21,7 @@#include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/dma-mapping.h> +#include <linux/pcs.h> #include <linux/platform_device.h> #include <linux/phylink.h> #include <linux/of.h>
@@ -549,12 +550,12 @@ static void macb_set_tx_clk(struct macb *bp, int speed)netdev_err (bp->dev,"adjusting tx_clk failed.\n" ); } -static void macb_pcs_get_state (struct phylink_pcs *pcs, +static void macb_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) { struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); -phylink_mii_c22_pcs_decode_state (state,gem_readl (bp,PCSSTS ), +phylink_mii_c22_pcs_decode_state (state, neg_mode,gem_readl (bp,PCSSTS ),gem_readl (bp,PCSANLPBASE )); }
@@ -707,7 +708,10 @@ static struct phylink_pcs *macb_mac_select_pcs(struct phylink_config *config,struct net_device *ndev =to_net_dev (config->dev);struct macb *bp =netdev_priv (ndev); -if (interface ==PHY_INTERFACE_MODE_10GBASER ) +if (bp->phylink_ext_pcs && +test_bit (interface, bp->phylink_ext_pcs->supported_interfaces)) +return bp->phylink_ext_pcs; +else if (interface ==PHY_INTERFACE_MODE_10GBASER )return &bp->phylink_usx_pcs;else if (interface ==PHY_INTERFACE_MODE_SGMII )return &bp->phylink_sgmii_pcs;
@@ -733,7 +737,10 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,if (state->interface ==PHY_INTERFACE_MODE_RMII ) ctrl |=MACB_BIT (RM9200_RMII ); }else if (macb_is_gem (bp)) { -if (macb_mac_select_pcs (config, state->interface)) +struct phylink_pcs *pcs =macb_mac_select_pcs (config, + state->interface); + +if (pcs && pcs != bp->phylink_ext_pcs) ctrl |=GEM_BIT (PCSSEL );else ctrl &= ~GEM_BIT (PCSSEL );
@@ -907,6 +914,14 @@ static int macb_mii_probe(struct net_device *dev) bp->phylink_sgmii_pcs.ops = &macb_phylink_pcs_ops; bp->phylink_usx_pcs.ops = &macb_phylink_usx_pcs_ops; + bp->phylink_ext_pcs =pcs_get_by_fwnode_optional (&bp->pdev->dev, + bp->pdev->dev.fwnode, +NULL ); +if (IS_ERR (bp->phylink_ext_pcs)) +return dev_err_probe (&bp->pdev->dev, +PTR_ERR (bp->phylink_ext_pcs), +"Could not get external PCS\n" ); + bp->phylink_config.dev = &dev->dev; bp->phylink_config.type =PHYLINK_NETDEV ; bp->phylink_config.mac_managed_pm = true;
@@ -924,6 +939,11 @@ static int macb_mii_probe(struct net_device *dev)__set_bit (PHY_INTERFACE_MODE_RMII , bp->phylink_config.supported_interfaces); +if (bp->phylink_ext_pcs) +phy_interface_or (bp->phylink_config.supported_interfaces, + bp->phylink_config.supported_interfaces, + bp->phylink_ext_pcs->supported_interfaces); +/* Determine what modes are supported */ if (macb_is_gem (bp) && (bp->caps &MACB_CAPS_GIGABIT_MODE_AVAILABLE )) { bp->phylink_config.mac_capabilities |=MAC_1000FD ;
@@ -950,6 +970,7 @@ static int macb_mii_probe(struct net_device *dev)if (IS_ERR (bp->phylink)) {netdev_err (dev,"Could not create a phylink instance (%ld)\n" ,PTR_ERR (bp->phylink)); +pcs_put (&bp->pdev->dev, bp->phylink_ext_pcs);return PTR_ERR (bp->phylink); }
@@ -5462,6 +5483,7 @@ static void macb_remove(struct platform_device *pdev) bp->rx_clk, bp->tsu_clk);pm_runtime_set_suspended (&pdev->dev); } +pcs_put (&pdev->dev, bp->phylink_ext_pcs);phylink_destroy (bp->phylink);free_netdev (dev); }
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Russell King (Oracle)
maintainerRe: [RFC net-next PATCH 10/13] net: macb: Support external PCSs
drivers/net/ethernet/cadence/macb_main.c static void macb_set_tx_clk(struct macb *bp, int speed) · line 559
Quoted 9 lines · Sean Anderson
drivers/net/ethernet/cadence/macb_main.c +2
-2-static void macb_pcs_get_state (struct phylink_pcs *pcs, +static void macb_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) { struct macb *bp = container_of(pcs, struct macb, phylink_sgmii_pcs); -phylink_mii_c22_pcs_decode_state (state,gem_readl (bp,PCSSTS ), +phylink_mii_c22_pcs_decode_state (state, neg_mode,gem_readl (bp,PCSSTS ),gem_readl (bp,PCSANLPBASE ));
Looks like this should be in the previous patch.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Sean Anderson
reviewerRFC PATCH 11/13 of: property: Add device link support for PCS
In reply to Sean AndersonThis adds device link support for PCS devices, providing better probe ordering.
---
drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/property.c +2 -0
@@ -1379,6 +1379,7 @@ DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells") DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") +DEFINE_SIMPLE_PROP(pcs_handle, "pcs-handle", NULL)static struct device_node *parse_gpios (struct device_node *np,const char *prop_name,int index)
@@ -1535,6 +1536,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { .parse_prop = parse_post_init_providers, .fwlink_flags = FWLINK_FLAG_IGNORE, }, + { .parse_prop = parse_pcs_handle, }, {} };
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [RFC net-next PATCH 11/13] of: property: Add device link support for PCS
Quoted 23 lines · Sean Anderson
This adds device link support for PCS devices, providing better probe ordering.
Signed-off-by Sean Anderson <[email protected]>---
drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+)drivers/of/property.c +1
-0@@ -1379,6 +1379,7 @@ DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells") DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") +DEFINE_SIMPLE_PROP(pcs_handle, "pcs-handle", NULL)static struct device_node *parse_gpios (struct device_node *np,const char *prop_name,int index)
drivers/of/property.c static const struct supplier_bindings of_supplier_bindings[] = { · line 1539
Quoted 4 lines
drivers/of/property.c +1
-0@@ -1535,6 +1536,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { .parse_prop = parse_post_init_providers, .fwlink_flags = FWLINK_FLAG_IGNORE, }, + { .parse_prop = parse_pcs_handle, },
Can you add this in the right order please? All the simple ones come before the SUFFIX ones so that it's less expensive/fewer comparisons before you parse the simple properties.
-Saravana
Quoted 6 lines
drivers/of/property.c +0
-1{} }; --2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerRe: [RFC net-next PATCH 11/13] of: property: Add device link support for PCS
Quoted 21 lines · Saravana Kannan
Quoted 20 lines · Sean Anderson
This adds device link support for PCS devices, providing better probe ordering.
Signed-off-by Sean Anderson <[email protected]>---
drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+)drivers/of/property.c +1
-0@@ -1379,6 +1379,7 @@ DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells") DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") +DEFINE_SIMPLE_PROP (pcs_handle,"pcs-handle" ,NULL )
Quoted 11 lines
drivers/of/property.c static const struct supplier_bindings of_supplier_bindings[] = { · line 1539
Quoted 7 lines
drivers/of/property.c +1
-0static struct device_node *parse_gpios (struct device_node *np,const char *prop_name,int index)@@ -1535,6 +1536,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { .parse_prop = parse_post_init_providers, .fwlink_flags = FWLINK_FLAG_IGNORE, }, + { .parse_prop = parse_pcs_handle, },Can you add this in the right order please? All the simple ones come before the SUFFIX ones so that it's less expensive/fewer comparisons before you parse the simple properties.
Ah, I couldn't figure out what the intended order was so I just stuck it at the end.
--Sean
Sean Anderson
reviewerRFC PATCH 12/13 arm64: dts: Add compatible strings for Lynx PCSs
In reply to Sean AndersonThis adds appropriate compatible strings for Lynx PCSs on arm64 QorIQ platforms. This also changes the node name to avoid warnings from ethernet-phy.yaml.
---
.../arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 48 +++++++++++------ .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 54 ++++++++++++------- .../dts/freescale/qoriq-fman3-0-10g-0.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-10g-1.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-0.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-1.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-2.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-3.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-4.dtsi | 3 +- .../dts/freescale/qoriq-fman3-0-1g-5.dtsi | 3 +- 10 files changed, 84 insertions(+), 42 deletions(-)
arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi +32 -16
@@ -554,7 +554,8 @@ pcs_mdio1: mdio@8c07000 { #size-cells = <0>; status = "disabled"; - pcs1: ethernet-phy@0 { + pcs1: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -567,7 +568,8 @@ pcs_mdio2: mdio@8c0b000 { #size-cells = <0>; status = "disabled"; - pcs2: ethernet-phy@0 { + pcs2: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -580,7 +582,8 @@ pcs_mdio3: mdio@8c0f000 { #size-cells = <0>; status = "disabled"; - pcs3: ethernet-phy@0 { + pcs3: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -593,7 +596,8 @@ pcs_mdio4: mdio@8c13000 { #size-cells = <0>; status = "disabled"; - pcs4: ethernet-phy@0 { + pcs4: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -606,7 +610,8 @@ pcs_mdio5: mdio@8c17000 { #size-cells = <0>; status = "disabled"; - pcs5: ethernet-phy@0 { + pcs5: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -619,7 +624,8 @@ pcs_mdio6: mdio@8c1b000 { #size-cells = <0>; status = "disabled"; - pcs6: ethernet-phy@0 { + pcs6: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -632,7 +638,8 @@ pcs_mdio7: mdio@8c1f000 { #size-cells = <0>; status = "disabled"; - pcs7: ethernet-phy@0 { + pcs7: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -645,7 +652,8 @@ pcs_mdio8: mdio@8c23000 { #size-cells = <0>; status = "disabled"; - pcs8: ethernet-phy@0 { + pcs8: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -658,7 +666,8 @@ pcs_mdio9: mdio@8c27000 { #size-cells = <0>; status = "disabled"; - pcs9: ethernet-phy@0 { + pcs9: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -671,7 +680,8 @@ pcs_mdio10: mdio@8c2b000 { #size-cells = <0>; status = "disabled"; - pcs10: ethernet-phy@0 { + pcs10: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -684,7 +694,8 @@ pcs_mdio11: mdio@8c2f000 { #size-cells = <0>; status = "disabled"; - pcs11: ethernet-phy@0 { + pcs11: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -697,7 +708,8 @@ pcs_mdio12: mdio@8c33000 { #size-cells = <0>; status = "disabled"; - pcs12: ethernet-phy@0 { + pcs12: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -710,7 +722,8 @@ pcs_mdio13: mdio@8c37000 { #size-cells = <0>; status = "disabled"; - pcs13: ethernet-phy@0 { + pcs13: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -723,7 +736,8 @@ pcs_mdio14: mdio@8c3b000 { #size-cells = <0>; status = "disabled"; - pcs14: ethernet-phy@0 { + pcs14: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -736,7 +750,8 @@ pcs_mdio15: mdio@8c3f000 { #size-cells = <0>; status = "disabled"; - pcs15: ethernet-phy@0 { + pcs15: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
@@ -749,7 +764,8 @@ pcs_mdio16: mdio@8c43000 { #size-cells = <0>; status = "disabled"; - pcs16: ethernet-phy@0 { + pcs16: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0>; }; };
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi +36 -18
162 lines not on this page · raw message
arch/arm64/boot/dts/freescale/qoriq-fman3-0-10g-0.dtsi +2 -1
@@ -36,7 +36,8 @@ mdio@f1000 { compatible = "fsl,fman-memac-mdio"; reg = <0xf1000 0x1000>; - pcsphy6: ethernet-phy@0 { + pcsphy6: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/arm64/boot/dts/freescale/qoriq-fman3-0-10g-1.dtsi +2 -1
@@ -36,7 +36,8 @@ mdio@f3000 { compatible = "fsl,fman-memac-mdio"; reg = <0xf3000 0x1000>; - pcsphy7: ethernet-phy@0 { + pcsphy7: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/arm64/boot/dts/freescale/qoriq-fman3-0-1g-0.dtsi +2 -1
@@ -35,7 +35,8 @@ mdio@e1000 { compatible = "fsl,fman-memac-mdio"; reg = <0xe1000 0x1000>; - pcsphy0: ethernet-phy@0 { + pcsphy0: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/arm64/boot/dts/freescale/qoriq-fman3-0-1g-1.dtsi +2 -1
@@ -35,7 +35,8 @@ mdio@e3000 { compatible = "fsl,fman-memac-mdio"; reg = <0xe3000 0x1000>; - pcsphy1: ethernet-phy@0 { + pcsphy1: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/arm64/boot/dts/freescale/qoriq-fman3-0-1g-2.dtsi +2 -1
@@ -35,7 +35,8 @@ mdio@e5000 { compatible = "fsl,fman-memac-mdio"; reg = <0xe5000 0x1000>; - pcsphy2: ethernet-phy@0 { + pcsphy2: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/arm64/boot/dts/freescale/qoriq-fman3-0-1g-3.dtsi +2 -1
@@ -35,7 +35,8 @@ mdio@e7000 { compatible = "fsl,fman-memac-mdio"; reg = <0xe7000 0x1000>; - pcsphy3: ethernet-phy@0 { + pcsphy3: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/arm64/boot/dts/freescale/qoriq-fman3-0-1g-4.dtsi +2 -1
@@ -35,7 +35,8 @@ mdio@e9000 { compatible = "fsl,fman-memac-mdio"; reg = <0xe9000 0x1000>; - pcsphy4: ethernet-phy@0 { + pcsphy4: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/arm64/boot/dts/freescale/qoriq-fman3-0-1g-5.dtsi +2 -1
@@ -34,7 +34,8 @@ mdio@eb000 { compatible = "fsl,fman-memac-mdio"; reg = <0xeb000 0x1000>; - pcsphy5: ethernet-phy@0 { + pcsphy5: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerRFC PATCH 13/13 powerpc: dts: Add compatible strings for Lynx PCSs
In reply to Sean AndersonThis adds appropriate compatible strings for Lynx PCSs on PowerPC QorIQ platforms. This also changes the node name to avoid warnings from ethernet-phy.yaml.
---
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0-best-effort.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1-best-effort.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi | 3 ++- 20 files changed, 40 insertions(+), 20 deletions(-)
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0-best-effort.dtsi +2 -1
@@ -66,7 +66,8 @@ mdio@e1000 { reg = <0xe1000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy0: ethernet-phy@0 { + pcsphy0: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi +2 -1
@@ -70,7 +70,8 @@ mdio@f1000 { reg = <0xf1000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy6: ethernet-phy@0 { + pcsphy6: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1-best-effort.dtsi +2 -1
@@ -73,7 +73,8 @@ mdio@e3000 { reg = <0xe3000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy1: ethernet-phy@0 { + pcsphy1: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi +2 -1
@@ -70,7 +70,8 @@ mdio@f3000 { reg = <0xf3000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy7: ethernet-phy@0 { + pcsphy7: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-2.dtsi +2 -1
@@ -38,7 +38,8 @@ mdio@e1000 { reg = <0xe1000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy0: ethernet-phy@0 { + pcsphy0: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-3.dtsi +2 -1
@@ -38,7 +38,8 @@ mdio@e3000 { reg = <0xe3000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy1: ethernet-phy@0 { + pcsphy1: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi +2 -1
@@ -62,7 +62,8 @@ mdio@e1000 { reg = <0xe1000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy0: ethernet-phy@0 { + pcsphy0: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi +2 -1
@@ -69,7 +69,8 @@ mdio@e3000 { reg = <0xe3000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy1: ethernet-phy@0 { + pcsphy1: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi +2 -1
@@ -69,7 +69,8 @@ mdio@e5000 { reg = <0xe5000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy2: ethernet-phy@0 { + pcsphy2: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi +2 -1
@@ -69,7 +69,8 @@ mdio@e7000 { reg = <0xe7000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy3: ethernet-phy@0 { + pcsphy3: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi +2 -1
@@ -62,7 +62,8 @@ mdio@e9000 { reg = <0xe9000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy4: ethernet-phy@0 { + pcsphy4: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi +2 -1
@@ -69,7 +69,8 @@ mdio@eb000 { reg = <0xeb000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy5: ethernet-phy@0 { + pcsphy5: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi +2 -1
@@ -70,7 +70,8 @@ mdio@f1000 { reg = <0xf1000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy14: ethernet-phy@0 { + pcsphy14: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi +2 -1
@@ -70,7 +70,8 @@ mdio@f3000 { reg = <0xf3000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy15: ethernet-phy@0 { + pcsphy15: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi +2 -1
@@ -62,7 +62,8 @@ mdio@e1000 { reg = <0xe1000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy8: ethernet-phy@0 { + pcsphy8: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi +2 -1
@@ -69,7 +69,8 @@ mdio@e3000 { reg = <0xe3000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy9: ethernet-phy@0 { + pcsphy9: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi +2 -1
@@ -69,7 +69,8 @@ mdio@e5000 { reg = <0xe5000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy10: ethernet-phy@0 { + pcsphy10: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi +2 -1
@@ -69,7 +69,8 @@ mdio@e7000 { reg = <0xe7000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy11: ethernet-phy@0 { + pcsphy11: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi +2 -1
@@ -62,7 +62,8 @@ mdio@e9000 { reg = <0xe9000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy12: ethernet-phy@0 { + pcsphy12: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi +2 -1
@@ -69,7 +69,8 @@ mdio@eb000 { reg = <0xeb000 0x1000>; fsl,erratum-a011043; /* must ignore read errors */ - pcsphy13: ethernet-phy@0 { + pcsphy13: ethernet-pcs@0 { + compatible = "fsl,lynx-pcs"; reg = <0x0>; }; };
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Quoted 8 lines · On Thu, 3 Apr 2025 14:18:54 -0400 Sean Anderson <[email protected]>…
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patch 5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-8)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 9-10).
Quoted 7 lines
The last few patches add device links for pcs-handle to improve boot times, and add compatibles for all Lynx PCSs.
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this,
pcs_get_by_fwnode_compatallows drivers to edit the devicetree to add appropriate compatibles.
I don't dive into your patch series and I don't know if you have heard about it but Christian Marangi is currently working on fwnode for PCS:
https://lore.kernel.org/netdev/[email protected]
Maybe you should sync with him!
Regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Sean Anderson
reviewerQuoted 19 lines · Kory Maincent
Quoted 8 lines · On Thu, 3 Apr 2025 14:18:54 -0400 Sean Anderson <[email protected]>…
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patch 5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-8)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 9-10).Quoted 7 lines
The last few patches add device links for pcs-handle to improve boot times, and add compatibles for all Lynx PCSs.
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this,
pcs_get_by_fwnode_compatallows drivers to edit the devicetree to add appropriate compatibles.
Quoted 5 lines
I don't dive into your patch series and I don't know if you have heard about it but Christian Marangi is currently working on fwnode for PCS:
https://lore.kernel.org/netdev/[email protected]Maybe you should sync with him!
I saw that series and made some comments. He is CC'd on this one.
I think this approach has two advantages:
- It completely solves the problem of the PCS being unregistered while the netdev (or whatever) is up
- I have designed the interface to make it easy to convert existing drivers that may not be able to use the "standard" probing process (because they have to support other devicetree structures for backwards-compatibility).
--Sean
Il giorno lun 7 apr 2025 alle ore 18:33 Sean Anderson <[email protected]> ha scritto:
Quoted 29 lines · Kory Maincent
Quoted 19 lines
Quoted 8 lines · On Thu, 3 Apr 2025 14:18:54 -0400 Sean Anderson <[email protected]>…
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patch 5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-8)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 9-10).Quoted 7 lines
The last few patches add device links for pcs-handle to improve boot times, and add compatibles for all Lynx PCSs.
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this,
pcs_get_by_fwnode_compatallows drivers to edit the devicetree to add appropriate compatibles.Quoted 5 lines
I don't dive into your patch series and I don't know if you have heard about it but Christian Marangi is currently working on fwnode for PCS:
https://lore.kernel.org/netdev/[email protected]Maybe you should sync with him!
I saw that series and made some comments. He is CC'd on this one.
Quoted 9 lines
I think this approach has two advantages:
- It completely solves the problem of the PCS being unregistered while the netdev (or whatever) is up
- I have designed the interface to make it easy to convert existing drivers that may not be able to use the "standard" probing process (because they have to support other devicetree structures for backwards-compatibility).
I notice this and it's my fault for taking too long to post v2 of the PCS patch. There was also this idea of entering the wrapper hell but I scrapped that early as I really feel it's a workaround to the current problem present for PCS handling.
And the real problem IMHO is that currently PCS handling is fragile and with too many assumptions. With Daniel we also discussed backwards-compatibility. (mainly needed for mt7621 and mt7986 (for mediatek side those are the 2 that slipped in before it was correctly complained that things were taking a bad path)
We feel v2 permits correct support of old implementations.
The ""legacy"" implementation pose the assumption that PCS is never removed (unless the MAC driver is removed)
That fits v2 where a MAC has to initially provide a list of PCS to phylink instance.
With this implementation, a MAC can manually parse whatever PCS node structure is in place and fill the PCS.
As really the "late" removal/addition of a PCS can only be supported with fwnode implementation as dedicated PCS driver will make use of that.
I honestly hope we can skip having to enter the wrapper hell. Anyway I also see you made REALLY GOOD documentation. Would be ideal to collaborate for that. Anyway it's up to net maintainers on what path to follow.
Just my 2 cent on the PCS topic.
Sean Anderson
reviewerQuoted 41 lines · Christian Marangi (Ansuel)
Il giorno lun 7 apr 2025 alle ore 18:33 Sean Anderson <[email protected]> ha scritto:
Quoted 29 lines · Kory Maincent
Quoted 19 lines
Quoted 8 lines · On Thu, 3 Apr 2025 14:18:54 -0400 Sean Anderson <[email protected]>…
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patch 5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-8)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 9-10).Quoted 7 lines
The last few patches add device links for pcs-handle to improve boot times, and add compatibles for all Lynx PCSs.
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this,
pcs_get_by_fwnode_compatallows drivers to edit the devicetree to add appropriate compatibles.Quoted 5 lines
I don't dive into your patch series and I don't know if you have heard about it but Christian Marangi is currently working on fwnode for PCS:
https://lore.kernel.org/netdev/[email protected]Maybe you should sync with him!
I saw that series and made some comments. He is CC'd on this one.
Quoted 9 lines
I think this approach has two advantages:
- It completely solves the problem of the PCS being unregistered while the netdev (or whatever) is up
- I have designed the interface to make it easy to convert existing drivers that may not be able to use the "standard" probing process (because they have to support other devicetree structures for backwards-compatibility).
Quoted 4 lines
I notice this and it's my fault for taking too long to post v2 of the PCS patch. There was also this idea of entering the wrapper hell but I scrapped that early as I really feel it's a workaround to the current problem present for PCS handling.
It's no workaround. The fundamental problem is that drivers can become unbound at any time, and we cannot make consumers drop their references. Every subsystem must deal with this reality, or suffer from user-after-free bugs. See [1-3] for discussion of this problem in relation to PCSs and PHYs, and [4] for more discussion of my approach.
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
[3] https://lore.kernel.org/netdev/[email protected]/
[3] https://lpc.events/event/17/contributions/1627/
Quoted 11 lines
And the real problem IMHO is that currently PCS handling is fragile and with too many assumptions. With Daniel we also discussed backwards-compatibility. (mainly needed for mt7621 and mt7986 (for mediatek side those are the 2 that slipped in before it was correctly complained that things were taking a bad path)
We feel v2 permits correct support of old implementations.
The ""legacy"" implementation pose the assumption that PCS is never removed (unless the MAC driver is removed)
That fits v2 where a MAC has to initially provide a list of PCS to phylink instance.
And what happens when the driver is unbound from the device and suddenly a PCS on that list is free'd memory but is in active use by a netdev?
Quoted 5 lines
With this implementation, a MAC can manually parse whatever PCS node structure is in place and fill the PCS.
As really the "late" removal/addition of a PCS can only be supported with fwnode implementation as dedicated PCS driver will make use of that.
I agree that a "cells" approach would require this, but
- There are no in-tree examples of where this is necessary
- I think this would be easy to add when necessary
Quoted 1 line
I honestly hope we can skip having to enter the wrapper hell.
Unfortunately, this is required by the kernel driver model :l
Quoted 1 line
Anyway I also see you made REALLY GOOD documentation.
Thanks. One of my peeves is subsystems that have zero docs...
Quoted 4 lines
Would be ideal to
collaborate for that. Anyway it's up to net maintainers on what path to follow.Just my 2 cent on the PCS topic.
--Sean
Il giorno lun 7 apr 2025 alle ore 19:00 Sean Anderson <[email protected]> ha scritto:
Quoted 65 lines · Christian Marangi (Ansuel)
Quoted 41 lines
Il giorno lun 7 apr 2025 alle ore 18:33 Sean Anderson <[email protected]> ha scritto:
Quoted 29 lines · Kory Maincent
Quoted 19 lines
Quoted 8 lines · On Thu, 3 Apr 2025 14:18:54 -0400 Sean Anderson <[email protected]>…
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patch 5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-8)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 9-10).Quoted 7 lines
The last few patches add device links for pcs-handle to improve boot times, and add compatibles for all Lynx PCSs.
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this,
pcs_get_by_fwnode_compatallows drivers to edit the devicetree to add appropriate compatibles.Quoted 5 lines
I don't dive into your patch series and I don't know if you have heard about it but Christian Marangi is currently working on fwnode for PCS:
https://lore.kernel.org/netdev/[email protected]Maybe you should sync with him!
I saw that series and made some comments. He is CC'd on this one.
Quoted 9 lines
I think this approach has two advantages:
- It completely solves the problem of the PCS being unregistered while the netdev (or whatever) is up
- I have designed the interface to make it easy to convert existing drivers that may not be able to use the "standard" probing process (because they have to support other devicetree structures for backwards-compatibility).Quoted 4 lines
I notice this and it's my fault for taking too long to post v2 of the PCS patch. There was also this idea of entering the wrapper hell but I scrapped that early as I really feel it's a workaround to the current problem present for PCS handling.
It's no workaround. The fundamental problem is that drivers can become unbound at any time, and we cannot make consumers drop their references. Every subsystem must deal with this reality, or suffer from user-after-free bugs. See [1-3] for discussion of this problem in relation to PCSs and PHYs, and [4] for more discussion of my approach.
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
[3] https://lore.kernel.org/netdev/[email protected]/
[3] https://lpc.events/event/17/contributions/1627/Quoted 6 lines
And the real problem IMHO is that currently PCS handling is fragile and with too many assumptions. With Daniel we also discussed backwards-compatibility. (mainly needed for mt7621 and mt7986 (for mediatek side those are the 2 that slipped in before it was correctly complained that things were taking a bad path)
Quoted 9 lines
Quoted 5 lines
We feel v2 permits correct support of old implementations.
The ""legacy"" implementation pose the assumption that PCS is never removed (unless the MAC driver is removed)
That fits v2 where a MAC has to initially provide a list of PCS to phylink instance.And what happens when the driver is unbound from the device and suddenly a PCS on that list is free'd memory but is in active use by a netdev?
driver bug for not correctly implementing the removal task.
The approach is remove as provider and call phylink removal phase under rtnl lock.
We tested this with unbind, that is actually the main problem we are trying to address
and works correctly.
Quoted 11 lines
Quoted 5 lines
With this implementation, a MAC can manually parse whatever PCS node structure is in place and fill the PCS.
As really the "late" removal/addition of a PCS can only be supported with fwnode implementation as dedicated PCS driver will make use of that.
I agree that a "cells" approach would require this, but
- There are no in-tree examples of where this is necessary
- I think this would be easy to add when necessary
There are no in-tree cause only now we are starting to support complex configuration with multiple PCS placed outside the MAC.
I feel it's better to define a standard API for them now before we permit even more MAC driver to implement custom property and have to address tons of workaround for compatibility.
Quoted 14 lines
Quoted 1 line
I honestly hope we can skip having to enter the wrapper hell.
Unfortunately, this is required by the kernel driver model :l
Quoted 1 line
Anyway I also see you made REALLY GOOD documentation.
Thanks. One of my peeves is subsystems that have zero docs...
Quoted 4 lines
Would be ideal to
collaborate for that. Anyway it's up to net maintainers on what path to follow.Just my 2 cent on the PCS topic.
--Sean
Quoted 7 lines · Christian Marangi (Ansuel)
Il giorno lun 7 apr 2025 alle ore 19:00 Sean Anderson
Quoted 5 lines
I agree that a "cells" approach would require this, but
- There are no in-tree examples of where this is necessary
- I think this would be easy to add when necessary
Quoted 6 lines
There are no in-tree cause only now we are starting to support complex configuration with multiple PCS placed outside the MAC.
I feel it's better to define a standard API for them now before we permit even more MAC driver to implement custom property and have to address tons of workaround for compatibility.
Qualcomm's PCS driver will require offering multiple phylink_pcs by a single device/of_node. So while it's true that there is currently no in-tree user for that, that very user is already knocking on our doors.
See
https://patchwork.kernel.org/project/netdevbpf/list/?series=931658&state=*
Sean Anderson
reviewerQuoted 15 lines · Daniel Golle
Quoted 7 lines · Christian Marangi (Ansuel)
Il giorno lun 7 apr 2025 alle ore 19:00 Sean Anderson
Quoted 5 lines
I agree that a "cells" approach would require this, but
- There are no in-tree examples of where this is necessary
- I think this would be easy to add when necessaryQuoted 6 lines
There are no in-tree cause only now we are starting to support complex configuration with multiple PCS placed outside the MAC.
I feel it's better to define a standard API for them now before we permit even more MAC driver to implement custom property and have to address tons of workaround for compatibility.
Quoted 6 lines
Qualcomm's PCS driver will require offering multiple
phylink_pcsby a single device/of_node. So while it's true that there is currently no in-tree user for that, that very user is already knocking on our doors.See
https://patchwork.kernel.org/project/netdevbpf/list/?series=931658&state=*
OK, but I still think this is quite easy to add.
--Sean
Sean Anderson
reviewerQuoted 15 lines · Daniel Golle
Quoted 7 lines · Christian Marangi (Ansuel)
Il giorno lun 7 apr 2025 alle ore 19:00 Sean Anderson
Quoted 5 lines
I agree that a "cells" approach would require this, but
- There are no in-tree examples of where this is necessary
- I think this would be easy to add when necessaryQuoted 6 lines
There are no in-tree cause only now we are starting to support complex configuration with multiple PCS placed outside the MAC.
I feel it's better to define a standard API for them now before we permit even more MAC driver to implement custom property and have to address tons of workaround for compatibility.
Quoted 6 lines
Qualcomm's PCS driver will require offering multiple
phylink_pcsby a single device/of_node. So while it's true that there is currently no in-tree user for that, that very user is already knocking on our doors.See
https://patchwork.kernel.org/project/netdevbpf/list/?series=931658&state=*
OK, but you have separate nodes for each PCS? So maybe the best thing is to allow customizing the fwnode? E.g. something like
pcs_register_fwnode(struct device *dev, struct phylink_pcs *pcs, struct fwnode_handle *fwnode)
--Sean
Sean Anderson
reviewerQuoted 77 lines · Christian Marangi (Ansuel)
Il giorno lun 7 apr 2025 alle ore 19:00 Sean Anderson <[email protected]> ha scritto:
Quoted 65 lines · Christian Marangi (Ansuel)
Quoted 41 lines
Il giorno lun 7 apr 2025 alle ore 18:33 Sean Anderson <[email protected]> ha scritto:
Quoted 29 lines · Kory Maincent
Quoted 19 lines
Quoted 8 lines · On Thu, 3 Apr 2025 14:18:54 -0400 Sean Anderson <[email protected]>…
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patch 5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-8)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 9-10).Quoted 7 lines
The last few patches add device links for pcs-handle to improve boot times, and add compatibles for all Lynx PCSs.
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this,
pcs_get_by_fwnode_compatallows drivers to edit the devicetree to add appropriate compatibles.Quoted 5 lines
I don't dive into your patch series and I don't know if you have heard about it but Christian Marangi is currently working on fwnode for PCS:
https://lore.kernel.org/netdev/[email protected]Maybe you should sync with him!
I saw that series and made some comments. He is CC'd on this one.
Quoted 9 lines
I think this approach has two advantages:
- It completely solves the problem of the PCS being unregistered while the netdev (or whatever) is up
- I have designed the interface to make it easy to convert existing drivers that may not be able to use the "standard" probing process (because they have to support other devicetree structures for backwards-compatibility).Quoted 4 lines
I notice this and it's my fault for taking too long to post v2 of the PCS patch. There was also this idea of entering the wrapper hell but I scrapped that early as I really feel it's a workaround to the current problem present for PCS handling.
It's no workaround. The fundamental problem is that drivers can become unbound at any time, and we cannot make consumers drop their references. Every subsystem must deal with this reality, or suffer from user-after-free bugs. See [1-3] for discussion of this problem in relation to PCSs and PHYs, and [4] for more discussion of my approach.
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
[3] https://lore.kernel.org/netdev/[email protected]/
[3] https://lpc.events/event/17/contributions/1627/Quoted 6 lines
And the real problem IMHO is that currently PCS handling is fragile and with too many assumptions. With Daniel we also discussed backwards-compatibility. (mainly needed for mt7621 and mt7986 (for mediatek side those are the 2 that slipped in before it was correctly complained that things were taking a bad path)
Quoted 9 lines
Quoted 5 lines
We feel v2 permits correct support of old implementations.
The ""legacy"" implementation pose the assumption that PCS is never removed (unless the MAC driver is removed)
That fits v2 where a MAC has to initially provide a list of PCS to phylink instance.And what happens when the driver is unbound from the device and suddenly a PCS on that list is free'd memory but is in active use by a netdev?
Quoted 7 lines
driver bug for not correctly implementing the removal task.
The approach is remove as provider and call phylink removal phase under rtnl lock.
We tested this with unbind, that is actually the main problem we are trying to address
and works correctly.
OK, so this is a different approach since your last submission. Please CC me on your series.
- Fundamentally this is going to make backwards compatibility very difficult, since your approach cannot work with mac_select_pcs. How are you going to handle the case of MAC-internal PCSs? Are you going to make them create a swnode and bind to it just to create a PCS for e.g. MMIO registers? And how is the MAC supposed to know how to select the PCS? From what I can tell you don't even notify the MAC about which PCS it's using.
I considered an approach like this, where the phylink would be in the driver's seat (so to speak), but I decided not to persue it due to the problems listed above. A lot of PCSs are tightly-integrated with their MACs, so it does not make sense to introduce this little coupling. I think it is better to let the MAC select the PCS e.g. based on the phy interface. This tends to be a few lines of code for the MAC and saves so much complexity in phylink.
I think you should try doing the macb and lynx conversions for your approach. It will make the above problems obvious.
- Your approach is very intrusive. There are lots of changes all over phylink across several patches and it is hard to verify all the assumptions. Whereas a wrapper keeps everything contained to one file, and most of the functions can be evaluated independently.
--Sean
Quoted 20 lines · On Mon, 7 Apr 2025 12:33:28 -0400 Sean Anderson <[email protected]> wrote:
Quoted 19 lines · Kory Maincent
Quoted 15 lines · On Thu, 3 Apr 2025 14:18:54 -0400 Sean Anderson <[email protected]>…
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
- The Lynx PCS (and all of its users) is converted to this system (patch 5)
- The Xilinx PCS is broken out from the AXI Ethernet driver (patches 6-8)
- The Cadence MACB driver is converted to support external PCSs (namely the Xilinx PCS) (patches 9-10).The last few patches add device links for pcs-handle to improve boot times, and add compatibles for all Lynx PCSs.
Care has been taken to ensure backwards-compatibility. The main source of this is that many PCS devices lack compatibles and get detected as PHYs. To address this,
pcs_get_by_fwnode_compatallows drivers to edit the devicetree to add appropriate compatibles.
Quoted 7 lines
Quoted 5 lines
I don't dive into your patch series and I don't know if you have heard about it but Christian Marangi is currently working on fwnode for PCS:
https://lore.kernel.org/netdev/[email protected]Maybe you should sync with him!
I saw that series and made some comments. He is CC'd on this one.
Oh indeed, you have replied on his v1, sorry I missed it. It seems he forgot to add you in CC in the v2.
Quoted 8 lines
I think this approach has two advantages:
- It completely solves the problem of the PCS being unregistered while the netdev (or whatever) is up
- I have designed the interface to make it easy to convert existing drivers that may not be able to use the "standard" probing process (because they have to support other devicetree structures for backwards-compatibility).
Ok, thanks for the clarification!
I was working on the axienet driver to add support for the 10G version that's why I discovered your series.
Regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com