Add PCS core support
Subsystems (22)
Sean Anderson
reviewerv3 cover 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).
To build documentation without errors, this series requires commit de258fa8ca8d ("scripts: kernel-doc: fix parsing function-like typedefs (again)"), currently applied to docs-next [1].
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.
There is another series [2] with the same goal by Christian Marangi. In comparison, I believe this series
- Implements a simpler and more-robust method of PCS access.
- Provides a more-direct upgrade path for existing MAC and PCS drivers.
[1] https://lore.kernel.org/all/e0abb103c73a96d76602d909f60ab8fd6e2fd0bd.1744106242.git.mchehab+huawei@kernel.org/
[2] https://lore.kernel.org/netdev/[email protected]/
Changes in v3:
- Add '>' modifier for paragraph to description
- Adjust axienet_xilinx_pcs_get for changes to pcs_find_fwnode API
- Drop patches destined for other trees, as they have either already been applied or are no longer necessary.
- Edit description to reference clocks instead of resets
- Remove support for #pcs-cells. Upon further investigation, the requested functionality can be accomplished by specifying the PCS's fwnode manually.
- Select PCS_XILINX unconditionally
Changes in v2:
- Add fallbacks for pcs_get* and pcs_put
- Add support for #pcs-cells
- Change base compatible to just xlnx,pcs
- Change compatible to just xlnx,pcs
- Defer devicetree updates for another series
- Drop #clock-cells description
- Drop PCS_ALTERA_TSE which was accidentally added while rebasing
- Move #clock-cells after compatible
- Move update to macb_pcs_get_state to previous patch
- Remove outdated comment
- Remove second example
- Remove unused variable
- Remove unused variable lynx_properties
- Rename pcs-modes to xlnx,pcs-modes
- Reorder pcs_handle to come before suffix props
- Reword commit message
- Rework xilinx_pcs_validate to just clear out half-duplex modes instead of constraining modes based on the interface.
Sean Anderson (10):
dt-bindings: net: Add 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
Vladimir Oltean (1):
net: dsa: ocelot: suppress PHY device scanning on the internal MDIO
bus
.../devicetree/bindings/net/xilinx,pcs.yaml | 114 +++ Documentation/networking/index.rst | 1 + Documentation/networking/kapi.rst | 4 + Documentation/networking/pcs.rst | 102 +++ MAINTAINERS | 8 + 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 | 7 + drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 104 +-- drivers/net/pcs/Kconfig | 44 +- drivers/net/pcs/Makefile | 4 + drivers/net/pcs/core.c | 690 ++++++++++++++++++ drivers/net/pcs/pcs-lynx.c | 110 +-- drivers/net/pcs/pcs-xilinx.c | 477 ++++++++++++ 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 | 15 + include/linux/pcs.h | 193 +++++ include/linux/phy.h | 1 + include/linux/phylink.h | 27 +- 40 files changed, 1997 insertions(+), 296 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
reviewerPATCH v3 1/11 dt-bindings: net: Add Xilinx PCS
Add 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.
---
Changes in v3:
- Add '>' modifier for paragraph to description
- Edit description to reference clocks instead of resets
Changes in v2:
- Change base compatible to just xlnx,pcs
- Drop #clock-cells description
- Move #clock-cells after compatible
- Remove second example
- Rename pcs-modes to xlnx,pcs-modes
- Reword commit message
.../devicetree/bindings/net/xilinx,pcs.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/xilinx,pcs.yaml
Documentation/devicetree/bindings/net/xilinx,pcs.yaml new file +114 -0
@@ -0,0 +1,114 @@ +# 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 provide + a clock for other PCSs in the same bank. + +properties: + compatible: + items: + - const: xlnx,pcs-16.2 + - const: xlnx,pcs + + reg: + maxItems: 1 + + "#clock-cells": + const: 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 + + xlnx,pcs-modes: + description: + The interfaces that the PCS supports. Multiple interfaces may be + specified if dynamic reconfiguration is enabled. + 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 + - xlnx,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 { + compatible = "xlnx,pcs-16.2", "xlnx,pcs"; + reg = <0>; + #clock-cells = <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>; + xlnx,pcs-modes = "sgmii", "1000base-x"; + }; + + pcs1: ethernet-pcs@1 { + compatible = "xlnx,pcs-16.2", "xlnx,pcs"; + reg = <1>; + xlnx,pcs-modes = "sgmii"; + clocks = <&pcs0>; + clock-names = "refclk"; + }; + };
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v3 2/11 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.
---
(no changes since v1)
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
reviewerPATCH v3 3/11 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 Golaszewski'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/
---
Changes in v3:
- Remove support for #pcs-cells. Upon further investigation, the requested functionality can be accomplished by specifying the PCS's fwnode manually.
Changes in v2:
- Add fallbacks for pcs_get* and pcs_put
- Add support for #pcs-cells
- Remove outdated comment
- Remove unused variable
Documentation/networking/index.rst | 1 + Documentation/networking/kapi.rst | 4 + Documentation/networking/pcs.rst | 102 +++++ MAINTAINERS | 2 + drivers/net/pcs/Kconfig | 12 + drivers/net/pcs/Makefile | 2 + drivers/net/pcs/core.c | 690 +++++++++++++++++++++++++++++ include/linux/pcs.h | 193 ++++++++ 8 files changed, 1006 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 +102 -0
102 lines not on this page · raw message
MAINTAINERS +2 -0
@@ -8771,6 +8771,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
@@ -8784,6 +8785,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 +690 -0
690 lines not on this page · raw message
include/linux/pcs.h new file +193 -0
193 lines not on this page · raw message
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v3 4/11 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.
---
(no changes since v1)
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
reviewerPATCH v3 5/11 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.
---
Changes in v3:
- Call devm_pcs_register instead of devm_pcs_register_provider
Changes in v2:
- Add support for #pcs-cells
- Remove unused variable lynx_properties
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 | 110 ++++++++++-------- include/linux/pcs-lynx.h | 13 ++- 19 files changed, 130 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 +59 -51
158 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
Sean Anderson
reviewerPATCH v3 6/11 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).
At the moment the only (future) user of these functions selects PHYLIB, so we do not need fallbacks for when CONFIG_PHYLIB=n.
---
(no changes since v1)
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
@@ -899,7 +899,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;
@@ -927,6 +927,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
Sean Anderson
reviewerPATCH v3 7/11 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.
---
Changes in v3:
- Adjust axienet_xilinx_pcs_get for changes to pcs_find_fwnode API
- Call devm_pcs_register instead of devm_pcs_register_provider
Changes in v2:
- Add support for #pcs-cells
- Change compatible to just xlnx,pcs
- Drop PCS_ALTERA_TSE which was accidentally added while rebasing
- Rework xilinx_pcs_validate to just clear out half-duplex modes instead of constraining modes based on the interface.
MAINTAINERS | 6 + drivers/net/pcs/Kconfig | 21 ++ drivers/net/pcs/Makefile | 2 + drivers/net/pcs/pcs-xilinx.c | 477 +++++++++++++++++++++++++++++++++++ include/linux/pcs-xilinx.h | 15 ++ 5 files changed, 521 insertions(+) create mode 100644 drivers/net/pcs/pcs-xilinx.c create mode 100644 include/linux/pcs-xilinx.h
MAINTAINERS +6 -0
@@ -26454,6 +26454,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 +21 -0
@@ -50,4 +50,25 @@ 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_XILINX + depends on OF + depends on GPIOLIB + depends on COMMON_CLK + depends on PCS + select MDIO_DEVICE + select PHYLINK + 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 +477 -0
477 lines not on this page · raw message
include/linux/pcs-xilinx.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2024 Sean Anderson <[email protected]> +*/ + +#ifndef PCS_XILINX_H +#define PCS_XILINX_H + +struct device ; +struct phylink_pcs ; + +struct phylink_pcs *axienet_xilinx_pcs_get (struct device *dev, +const unsigned long *interfaces); + +#endif /* PCS_XILINX_H */
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v3 8/11 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.
---
Changes in v3:
- Select PCS_XILINX unconditionally
drivers/net/ethernet/xilinx/Kconfig | 7 ++ drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 104 ++++-------------- 3 files changed, 28 insertions(+), 87 deletions(-)
drivers/net/ethernet/xilinx/Kconfig +7 -0
@@ -25,8 +25,15 @@ config XILINX_EMACLITE config XILINX_AXI_EMAC tristate "Xilinx 10/100/1000 AXI Ethernet support" + depends on COMMON_CLK + depends on GPIOLIB depends on HAS_IOMEM + depends on OF + depends on PCS depends on XILINX_DMA + select MDIO_DEVICE + select OF_DYNAMIC + select 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
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v3 9/11 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.
---
(no changes since v2)
Changes in v2:
- Fix docs for macb_pcs_config_an
- Include change to macb_pcs_get_state which was previously in the next patch
drivers/net/ethernet/cadence/macb_main.c | 209 ++++++++++++++--------- 1 file changed, 132 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,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, neg_mode,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,
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerPATCH v3 10/11 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.
---
(no changes since v2)
Changes in v2:
- Move update to macb_pcs_get_state to previous patch
drivers/net/ethernet/cadence/macb.h | 1 + drivers/net/ethernet/cadence/macb_main.c | 26 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 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 +24 -2
@@ -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>
@@ -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
Sean Anderson
reviewerPATCH v3 11/11 of: property: Add device link support for PCS
This adds device link support for PCS devices, providing better probe ordering.
---
(no changes since v2)
Changes in v2:
- Reorder pcs_handle to come before suffix props
drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/property.c +2 -0
@@ -1377,6 +1377,7 @@ DEFINE_SIMPLE_PROP(post_init_providers, "post-init-providers", NULL) DEFINE_SIMPLE_PROP(access_controllers, "access-controllers", "#access-controller-cells") DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells") DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL) +DEFINE_SIMPLE_PROP(pcs_handle, "pcs-handle", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)DEFINE_SUFFIX_PROP (gpio,"-gpio" ,"#gpio-cells" )
@@ -1528,6 +1529,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_interrupts, }, { .parse_prop = parse_interrupt_map, }, { .parse_prop = parse_access_controllers, }, + { .parse_prop = parse_pcs_handle, }, { .parse_prop = parse_regulators, }, { .parse_prop = parse_gpio, }, { .parse_prop = parse_gpios, },
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Sean Anderson
reviewerRe: [net-next PATCH v3 03/11] net: pcs: Add subsystem
In reply to Sean AndersonQuoted 28 lines · Sean Anderson
include/linux/pcs.h new file +28
-0+#else /* CONFIG_PCS */ +static inline void pcs_put (struct device *dev,struct phylink_pcs *handle) +{ +} + +static inline struct phylink_pcs *pcs_get (struct device *dev,const char *id) +{ +return -EOPNOTSUPP ; +} + +static inline struct phylink_pcs *pcs_get_optional (struct device *dev, +const char *id) +{ +return NULL ; +} + +static inline struct phylink_pcs +*pcs_get_by_fwnode (struct device *dev,struct fwnode_handle *fwnode, +const char *id) +{ +return -EOPNOTSUPP ; +} + +static inline struct phylink_pcs +*pcs_get_by_fwnode_optional (struct device *dev,struct fwnode_handle *fwnode, +const char *id) +{ +return NULL ;
include/linux/pcs.h line 193
Quoted 10 lines
include/linux/pcs.h new file +10
-0+} + +static inline struct phylink_pcs *pcs_get_by_dev (struct device *dev, +const struct device *pcs_dev) +{ +return -EOPNOTSUPP ; +} +#endif + +#endif /* PCS_H */
These should be wrapped with ERR_PTR. Will fix for v4.
--Sean
Simon Horman
reviewerRe: [net-next PATCH v3 03/11] net: pcs: Add subsystem
In reply to Sean AndersonQuoted 17 lines · Sean Anderson
This 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 usingphylink_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 Golaszewski's talk at LPC [1].
pcs_get_by_fwnode_compatis 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 becausemdio_bus_matchcallsof_driver_match_deviceto match devices, and that function only works on devicetree nodes.
Quoted 3 lines
[1] https://lpc.events/event/17/contributions/1627/
Signed-off-by Sean Anderson <[email protected]>
Hi Sean,
Overall this looks quite clean to me.
Please find minor some nits flagged by tooling below.
Quoted 7 lines
drivers/net/pcs/core.c new file +7
-0+/** +* struct pcs_wrapper - Wrapper for a registered PCS +* @pcs: the wrapping PCS +* @refcnt: refcount for the wrapper +* @list: list head for pcs_wrappers +* @dev: the device associated with this PCS +* @fwnode: this PCS's firmware node; typically @dev.fwnode
drivers/net/pcs/core.c line 42
Quoted 10 lines
drivers/net/pcs/core.c new file +10
-0+* @wrapped: the backing PCS +*/ +struct pcs_wrapper { +struct phylink_pcs pcs; +refcount_t refcnt; +struct list_head list; +struct device *dev; +struct fwnode_handle *fwnode; +struct phylink_pcs *wrapped; +};
I think that wrapped needs an __rcu annotation.
Flagged by Sparse.
...
drivers/net/pcs/core.c line 175
Quoted 4 lines
drivers/net/pcs/core.c new file +4
-0+static int pcs_post_config (struct phylink_pcs *pcs, +phy_interface_t interface) +{ +struct pcs_wrapper *wrapper =pcs_to_wrapper (pcs);
The line above dereferences pcs.
drivers/net/pcs/core.c line 182
Quoted 7 lines
drivers/net/pcs/core.c new file +7
-0+struct phylink_pcs *wrapped; +int ret, idx; + + idx =srcu_read_lock (&pcs_srcu); + + wrapped =srcu_dereference (wrapper->wrapped, &pcs_srcu); +if (pcs && wrapped->ops->pcs_post_config)
But here it is assumed that pcs may be NULL.
This does not seem consistent.
Flagged by Smatch.
Quoted 7 lines
drivers/net/pcs/core.c new file +7
-0+ ret = wrapped->ops->pcs_post_config (wrapped, interface); + else + ret =0 ; + +srcu_read_unlock (&pcs_srcu, idx); +return ret; +}
...
drivers/net/pcs/core.c line 378
Quoted 11 lines
drivers/net/pcs/core.c new file +11
-0+/** +* pcs_unregister() - unregister a PCS +* @pcs: a PCS previously registered with pcs_register() +*/ +void pcs_unregister (struct phylink_pcs *pcs) +{ +struct pcs_wrapper *wrapper; + +mutex_lock (&pcs_mutex); +list_for_each_entry (wrapper, &pcs_wrappers, list) { +if (wrapper->wrapped == pcs)
Assuming that rcu_access_pointer() works with srcu, I think that this should be:
if (rcu_access_pointer(wrapper->wrapped) == pcs)
Also flagged by Sparse
Quoted 20 lines
drivers/net/pcs/core.c new file +20
-0+ goto found; + } + +mutex_unlock (&pcs_mutex); +WARN (1 ,"trying to unregister an already-unregistered PCS\n" ); +return ; + +found: +list_del (&wrapper->list); +mutex_unlock (&pcs_mutex); + +put_device (wrapper->dev); +fwnode_handle_put (wrapper->fwnode); +rcu_replace_pointer (wrapper->wrapped,NULL , true); +synchronize_srcu (&pcs_srcu); + +if (!wrapper->pcs.poll) +phylink_pcs_change (&wrapper->pcs, false); +if (refcount_dec_and_test (&wrapper->refcnt)) +kfree (wrapper);
drivers/net/pcs/core.c line 408
Quoted 10 lines
drivers/net/pcs/core.c new file +10
-0+} +EXPORT_SYMBOL_GPL (pcs_unregister); + +static void devm_pcs_unregister (void *pcs) +{ +pcs_unregister (pcs); +} + +/** +* devm_pcs_register - resource managed pcs_register()
nit: devm_pcs_register_full
Flagged by W=1 builds, and ./scripts/kernel-doc -none
Quoted 11 lines
+ * @dev: device that is registering this PCS
+ * @fwnode: The PCS's firmware node; typically @dev.fwnode
+ * @pcs: the PCS to register
+ *
+ * Managedpcs_register(). For PCSs registered by this function,
+ *pcs_unregister()is automatically called on driver detach. See
+ *pcs_register()for more information.
+ *
+ * Return: 0 on success, or -errno on failure
+ */
+int devm_pcs_register_full(struct device *dev, structfwnode_handle*fwnode,
...
Quoted 14 lines
drivers/net/pcs/core.c new file +14
-0+/** +* pcs_find_fwnode() - Find a PCS's fwnode +* @mac_node: The fwnode referencing the PCS +* @id: The name of the PCS to get. May be %NULL to get the first PCS. +* @fallback: An optional fallback property to use if pcs-handle is absent +* @optional: Whether the PCS is optional +* +* Find a PCS's fwnode, as referenced by @mac_node. This fwnode can later be +* used with _pcs_get_tail() to get the actual PCS. ``pcs-handle-names`` is +* used to match @id, then the fwnode is found using ``pcs-handle``. +* +* This function is internal to the PCS subsystem from a consumer +* point-of-view. However, it may be used to implement fallbacks for legacy +* behavior in PCS providers.
drivers/net/pcs/core.c line 506
Quoted 10 lines
drivers/net/pcs/core.c new file +10
-0+* +* Return: %NULL if @optional is set and the PCS cannot be found. Otherwise, +* * returns a PCS if found or an error pointer on failure. +*/ +struct fwnode_handle *pcs_find_fwnode (const struct fwnode_handle *mac_node, +const char *id,const char *fallback, +bool optional) +{ +int index; +struct fwnode_handle *pcs_fwnode;
Reverse xmas tree here please.
Edward Cree's xmastree tool can be helpful:
https://github.com/ecree-solarflare/xmastree
Quoted 25 lines
drivers/net/pcs/core.c new file +25
-0+ +if (!mac_node) +return optional ?NULL :ERR_PTR (-ENODEV ); + +if (id) + index =fwnode_property_match_string (mac_node, +"pcs-handle-names" , id); +else + index =0 ; + +if (index <0 ) { +if (optional && (index == -EINVAL || index == -ENODATA )) +return NULL ; +return ERR_PTR (index); + } + +/* First try pcs-handle, and if that doesn't work try the fallback */ + pcs_fwnode =fwnode_find_reference (mac_node,"pcs-handle" , index); +if (PTR_ERR (pcs_fwnode) == -ENOENT && fallback) + pcs_fwnode =fwnode_find_reference (mac_node, fallback, index); +if (optional && !id &&PTR_ERR (pcs_fwnode) == -ENOENT ) +return NULL ; +return pcs_fwnode; +} +EXPORT_SYMBOL_GPL (pcs_find_fwnode);
...
Simon Horman
reviewerRe: [net-next PATCH v3 03/11] net: pcs: Add subsystem
In reply to Sean AndersonQuoted 17 lines · Sean Anderson
This 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 usingphylink_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 Golaszewski's talk at LPC [1].
pcs_get_by_fwnode_compatis 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 becausemdio_bus_matchcallsof_driver_match_deviceto match devices, and that function only works on devicetree nodes.
Quoted 3 lines
[1] https://lpc.events/event/17/contributions/1627/
Signed-off-by Sean Anderson <[email protected]>
Hi Sean,
I noticed a few build problems after sending my previous email.
I was able to exercise them using variants of the following to generate small configs. I include this here in case it is useful to you.
make tinyconfig
cat >> .config << __EOF__CONFIG_MODULES=yCONFIG_NET=yCONFIG_NETDEVICES=yCONFIG_PCS=yCONFIG_PHYLIB=m__EOF__
cat >> .config << __EOF__CONFIG_OF=yCONFIG_OF_UNITTEST=yCONFIG_OF_DYNAMIC=y__EOF__
yes "" | make oldconfig
...
Quoted 1 line
drivers/net/pcs/core.c +0
-0
...
Quoted 23 lines
drivers/net/pcs/core.c +23
-0+/** +* _pcs_get() - Get a PCS from a fwnode property +* @dev: The device to get a PCS for +* @fwnode: The fwnode to find the PCS with +* @id: The name of the PCS to get. May be %NULL to get the first PCS. +* @fallback: An optional fallback property to use if pcs-handle is absent +* @optional: Whether the PCS is optional +* +* Find a PCS referenced by @mac_node and return a reference to it. Every call +* to _pcs_get_by_fwnode() must be balanced with one to pcs_put(). +* +* Return: a PCS if found, %NULL if not, or an error pointer on failure +*/ +struct phylink_pcs *_pcs_get (struct device *dev,struct fwnode_handle *fwnode, +const char *id,const char *fallback, +bool optional) +{ +struct fwnode_handle *pcs_fwnode; +struct phylink_pcs *pcs; + + pcs_fwnode =pcs_find_fwnode (fwnode, id, fallback, optional); +if (IS_ERR (pcs_fwnode)) +return ERR_CAST (pcs_fwnode);
drivers/net/pcs/core.c line 565
Quoted 10 lines
drivers/net/pcs/core.c +10
-0+ + pcs =_pcs_get_tail (dev, pcs_fwnode,NULL ); +fwnode_handle_put (pcs_fwnode); +return pcs; +} +EXPORT_SYMBOL_GPL (_pcs_get); + +static __maybe_unused void of_changeset_cleanup (void *data) +{ +struct of_changeset *ocs = data;
Code in pcs_get_by_fwnode_compat is conditionally compiled
based on CONFIG_OF_DYNAMIC. I think that is needed here too, because of_changeset_revert() doesn't exist unless CONFIG_OF_DYNAMIC is set.
Quoted 66 lines
drivers/net/pcs/core.c +66
-0+ +if (WARN (of_changeset_revert (ocs), +"could not revert changeset; leaking memory\n" )) +return ; + +of_changeset_destroy (ocs); +kfree (ocs); +} + +/** +* pcs_get_by_fwnode_compat() - Get a PCS with a compatibility fallback +* @dev: The device requesting the PCS +* @fwnode: The &struct fwnode_handle of the PCS itself +* @fixup: Callback to fix up @fwnode for compatibility +* @data: Passed to @fixup +* +* This function looks up a PCS and retries on failure after fixing up @fwnode. +* It is intended to assist in backwards-compatible behavior for drivers that +* used to create a PCS directly from a &struct device_node. This function +* should NOT be used in new drivers. +* +* @fixup modifies a devicetree changeset to create any properties necessary to +* bind the PCS's &struct device_node. At the very least, it should use +* of_changeset_add_prop_string() to add a compatible property. +* +* Note that unlike pcs_get_by_fwnode, @fwnode is the &struct fwnode_handle of +* the PCS itself, and not that of the requesting device. @fwnode could be +* looked up with pcs_find_fwnode() or determined by some other means for +* compatibility. +* +* Return: A PCS on success or an error pointer on failure +*/ +struct phylink_pcs * +pcs_get_by_fwnode_compat (struct device *dev,struct fwnode_handle *fwnode, +int (*fixup)(struct of_changeset *ocs, +struct device_node *np,void *data), +void *data) +{ +#ifdef CONFIG_OF_DYNAMIC +struct mdio_device *mdiodev; +struct of_changeset *ocs; +struct phylink_pcs *pcs; +struct device_node *np; +struct device *pcsdev; +int err; + +/* First attempt */ + pcs =_pcs_get_tail (dev, fwnode,NULL ); +if (PTR_ERR (pcs) != -EPROBE_DEFER ) +return pcs; + +/* No luck? Maybe there's no compatible... */ + np =to_of_node (fwnode); +if (!np ||of_property_present (np,"compatible" )) +return pcs; + +/* OK, let's try fixing things up */ +pr_warn ("%pOF is missing a compatible\n" , np); + ocs =kmalloc (sizeof (*ocs),GFP_KERNEL ); +if (!ocs) +return ERR_PTR (-ENOMEM ); + +of_changeset_init (ocs); + err =fixup (ocs, np, data); +if (err) + goto err_ocs;
drivers/net/pcs/core.c line 641
Quoted 10 lines
drivers/net/pcs/core.c +10
-0+ + err =of_changeset_apply (ocs); +if (err) + goto err_ocs; + + err =devm_add_action_or_reset (dev, of_changeset_cleanup, ocs); +if (err) +return ERR_PTR (err); + + mdiodev =fwnode_mdio_find_device (fwnode);
fwnode_mdio_find_device() is unavailable for linking if PHYLIB is a module (and PCS is built-in).
Quoted 28 lines
drivers/net/pcs/core.c +28
-0+if (mdiodev) { +/* Clear that pesky PHY flag so we can match PCS drivers */ +device_lock (&mdiodev->dev); + mdiodev->flags &= ~MDIO_DEVICE_FLAG_PHY ; +device_unlock (&mdiodev->dev); + pcsdev = &mdiodev->dev; + }else { + pcsdev =get_device (fwnode->dev); +if (!pcsdev) +return ERR_PTR (-EPROBE_DEFER ); + } + + err =device_reprobe (pcsdev); +put_device (pcsdev); +if (err) +return ERR_PTR (err); + +return _pcs_get_tail (dev, fwnode,NULL ); + +err_ocs: +of_changeset_destroy (ocs); +kfree (ocs); +return ERR_PTR (err); +#else +return _pcs_get_tail (dev, fwnode,NULL ); +#endif +} +EXPORT_SYMBOL_GPL (pcs_get_by_fwnode_compat);
...
Russell King (Oracle)
maintainerQuoted 2 lines · Sean Anderson
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
As per previous, unless I respond (this response not included) then I haven't had time to look at it - and today is total ratshit so, not today.
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
reviewerHi Russell,
Quoted 7 lines · Russell King (Oracle)
Quoted 2 lines · Sean Anderson
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
As per previous, unless I respond (this response not included) then I haven't had time to look at it - and today is total ratshit so, not today.
Sorry if I resent this too soon. I had another look at the request for #pcs-cells [1], and determined that a simpler approach would be possible. So I wanted to resend with that change since it would let me drop the fwnode_property_get_reference_optional_args patches.
--Sean
Sean Anderson
reviewerRe: [net-next PATCH v3 03/11] net: pcs: Add subsystem
In reply to Simon HormanQuoted 47 lines · Simon Horman
Quoted 17 lines · Sean Anderson
This 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 usingphylink_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 Golaszewski's talk at LPC [1].
pcs_get_by_fwnode_compatis 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 becausemdio_bus_matchcallsof_driver_match_deviceto match devices, and that function only works on devicetree nodes.Quoted 3 lines
[1] https://lpc.events/event/17/contributions/1627/
Signed-off-by Sean Anderson <[email protected]>Hi Sean,
Overall this looks quite clean to me.
Please find minor some nits flagged by tooling below.Quoted 7 lines
drivers/net/pcs/core.c new file +7
-0+/** +* struct pcs_wrapper - Wrapper for a registered PCS +* @pcs: the wrapping PCS +* @refcnt: refcount for the wrapper +* @list: list head for pcs_wrappers +* @dev: the device associated with this PCS +* @fwnode: this PCS's firmware node; typically @dev.fwnode drivers/net/pcs/core.c line 42
Quoted 10 lines
drivers/net/pcs/core.c new file +10
-0+* @wrapped: the backing PCS +*/ +struct pcs_wrapper { +struct phylink_pcs pcs; +refcount_t refcnt; +struct list_head list; +struct device *dev; +struct fwnode_handle *fwnode; +struct phylink_pcs *wrapped; +};I think that wrapped needs an
__rcuannotation.
Quoted 3 lines
Flagged by Sparse.
...
Will add.
Quoted 18 lines
drivers/net/pcs/core.c line 175
Quoted 4 lines
drivers/net/pcs/core.c new file +4
-0+static int pcs_post_config (struct phylink_pcs *pcs, +phy_interface_t interface) +{ +struct pcs_wrapper *wrapper =pcs_to_wrapper (pcs);The line above dereferences pcs.
drivers/net/pcs/core.c line 182
Quoted 7 lines
drivers/net/pcs/core.c new file +7
-0+struct phylink_pcs *wrapped; +int ret, idx; + + idx =srcu_read_lock (&pcs_srcu); + + wrapped =srcu_dereference (wrapper->wrapped, &pcs_srcu); +if (pcs && wrapped->ops->pcs_post_config)But here it is assumed that pcs may be NULL.
This does not seem consistent.
Quoted 1 line
Flagged by Smatch.
This should be if(wrapped && ...
Quoted 25 lines
Quoted 7 lines
drivers/net/pcs/core.c new file +7
-0+ ret = wrapped->ops->pcs_post_config (wrapped, interface); + else + ret =0 ; + +srcu_read_unlock (&pcs_srcu, idx); +return ret; +}...
drivers/net/pcs/core.c line 378
Quoted 11 lines
drivers/net/pcs/core.c new file +11
-0+/** +* pcs_unregister() - unregister a PCS +* @pcs: a PCS previously registered with pcs_register() +*/ +void pcs_unregister (struct phylink_pcs *pcs) +{ +struct pcs_wrapper *wrapper; + +mutex_lock (&pcs_mutex); +list_for_each_entry (wrapper, &pcs_wrappers, list) { +if (wrapper->wrapped == pcs)Assuming that
rcu_access_pointer()works with srcu, I think that this should be:
Quoted 3 lines
if (rcu_access_pointer(wrapper->wrapped) == pcs)Also flagged by Sparse
OK
Quoted 33 lines
Quoted 20 lines
drivers/net/pcs/core.c new file +20
-0+ goto found; + } + +mutex_unlock (&pcs_mutex); +WARN (1 ,"trying to unregister an already-unregistered PCS\n" ); +return ; + +found: +list_del (&wrapper->list); +mutex_unlock (&pcs_mutex); + +put_device (wrapper->dev); +fwnode_handle_put (wrapper->fwnode); +rcu_replace_pointer (wrapper->wrapped,NULL , true); +synchronize_srcu (&pcs_srcu); + +if (!wrapper->pcs.poll) +phylink_pcs_change (&wrapper->pcs, false); +if (refcount_dec_and_test (&wrapper->refcnt)) +kfree (wrapper);drivers/net/pcs/core.c line 408
Quoted 10 lines
drivers/net/pcs/core.c new file +10
-0+} +EXPORT_SYMBOL_GPL (pcs_unregister); + +static void devm_pcs_unregister (void *pcs) +{ +pcs_unregister (pcs); +} + +/** +* devm_pcs_register - resource managed pcs_register() nit:
devm_pcs_register_full
Quoted 1 line
Flagged by W=1 builds, and
./scripts/kernel-doc-none
OK
Quoted 32 lines
Quoted 11 lines
+ * @dev: device that is registering this PCS
+ * @fwnode: The PCS's firmware node; typically @dev.fwnode
+ * @pcs: the PCS to register
+ *
+ * Managedpcs_register(). For PCSs registered by this function,
+ *pcs_unregister()is automatically called on driver detach. See
+ *pcs_register()for more information.
+ *
+ * Return: 0 on success, or -errno on failure
+ */
+int devm_pcs_register_full(struct device *dev, structfwnode_handle*fwnode,...
Quoted 18 lines
+/**
+ *pcs_find_fwnode()- Find a PCS's fwnode
+ * @mac_node: The fwnode referencing the PCS
+ * @id: The name of the PCS to get. May be %NULL to get the first PCS.
+ * @fallback: An optional fallback property to use if pcs-handle is absent
+ * @optional: Whether the PCS is optional
+ *
+ * Find a PCS's fwnode, as referenced by @mac_node. This fwnode can later be
+ * used with_pcs_get_tail()to get the actual PCS. ``pcs-handle-names`` is
+ * used to match @id, then the fwnode is found using ``pcs-handle``.
+ *
+ * This function is internal to the PCS subsystem from a consumer
+ * point-of-view. However, it may be used to implement fallbacks for legacy
+ * behavior in PCS providers.
+ *
+ * Return: %NULL if @optional is set and the PCS cannot be found. Otherwise,
+ * * returns a PCS if found or an error pointer on failure.
+ */
Quoted 8 lines
drivers/net/pcs/core.c line 506
Quoted 6 lines
drivers/net/pcs/core.c new file +6
-0+struct fwnode_handle *pcs_find_fwnode (const struct fwnode_handle *mac_node, +const char *id,const char *fallback, +bool optional) +{ +int index; +struct fwnode_handle *pcs_fwnode;Reverse xmas tree here please.
OK
Quoted 2 lines
Edward Cree's xmastree tool can be helpful:
https://github.com/ecree-solarflare/xmastree
I wonder if we could get this into checkpatch...
Thanks for the review.
--Sean
Sean Anderson
reviewerRe: [net-next PATCH v3 03/11] net: pcs: Add subsystem
In reply to Simon HormanQuoted 45 lines · Simon Horman
Quoted 17 lines · Sean Anderson
This 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 usingphylink_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 Golaszewski's talk at LPC [1].
pcs_get_by_fwnode_compatis 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 becausemdio_bus_matchcallsof_driver_match_deviceto match devices, and that function only works on devicetree nodes.Quoted 3 lines
[1] https://lpc.events/event/17/contributions/1627/
Signed-off-by Sean Anderson <[email protected]>Hi Sean,
I noticed a few build problems after sending my previous email.
I was able to exercise them using variants of the following to generate small configs. I include this here in case it is useful to you.
make tinyconfig
cat >> .config <<
__EOF__CONFIG_MODULES=yCONFIG_NET=yCONFIG_NETDEVICES=yCONFIG_PCS=yCONFIG_PHYLIB=m__EOF__cat >> .config <<
__EOF__CONFIG_OF=yCONFIG_OF_UNITTEST=yCONFIG_OF_DYNAMIC=y__EOF__
Quoted 7 lines
yes "" | make oldconfig
...
Quoted 1 line
drivers/net/pcs/core.c +0
-0...
Thanks, I was able to reproduce/fix these issues.
How did you find these? By inspection?
I often end up missing build issues like this because I mostly test with everything enabled.
--Sean
Quoted 148 lines
Quoted 23 lines
drivers/net/pcs/core.c +23
-0+/** +* _pcs_get() - Get a PCS from a fwnode property +* @dev: The device to get a PCS for +* @fwnode: The fwnode to find the PCS with +* @id: The name of the PCS to get. May be %NULL to get the first PCS. +* @fallback: An optional fallback property to use if pcs-handle is absent +* @optional: Whether the PCS is optional +* +* Find a PCS referenced by @mac_node and return a reference to it. Every call +* to _pcs_get_by_fwnode() must be balanced with one to pcs_put(). +* +* Return: a PCS if found, %NULL if not, or an error pointer on failure +*/ +struct phylink_pcs *_pcs_get (struct device *dev,struct fwnode_handle *fwnode, +const char *id,const char *fallback, +bool optional) +{ +struct fwnode_handle *pcs_fwnode; +struct phylink_pcs *pcs; + + pcs_fwnode =pcs_find_fwnode (fwnode, id, fallback, optional); +if (IS_ERR (pcs_fwnode)) +return ERR_CAST (pcs_fwnode);drivers/net/pcs/core.c line 565
Quoted 10 lines
drivers/net/pcs/core.c +10
-0+ + pcs =_pcs_get_tail (dev, pcs_fwnode,NULL ); +fwnode_handle_put (pcs_fwnode); +return pcs; +} +EXPORT_SYMBOL_GPL (_pcs_get); + +static __maybe_unused void of_changeset_cleanup (void *data) +{ +struct of_changeset *ocs = data;Code in
pcs_get_by_fwnode_compatis conditionally compiled
based onCONFIG_OF_DYNAMIC. I think that is needed here too, becauseof_changeset_revert()doesn't exist unlessCONFIG_OF_DYNAMICis set.Quoted 66 lines
drivers/net/pcs/core.c +66
-0+ +if (WARN (of_changeset_revert (ocs), +"could not revert changeset; leaking memory\n" )) +return ; + +of_changeset_destroy (ocs); +kfree (ocs); +} + +/** +* pcs_get_by_fwnode_compat() - Get a PCS with a compatibility fallback +* @dev: The device requesting the PCS +* @fwnode: The &struct fwnode_handle of the PCS itself +* @fixup: Callback to fix up @fwnode for compatibility +* @data: Passed to @fixup +* +* This function looks up a PCS and retries on failure after fixing up @fwnode. +* It is intended to assist in backwards-compatible behavior for drivers that +* used to create a PCS directly from a &struct device_node. This function +* should NOT be used in new drivers. +* +* @fixup modifies a devicetree changeset to create any properties necessary to +* bind the PCS's &struct device_node. At the very least, it should use +* of_changeset_add_prop_string() to add a compatible property. +* +* Note that unlike pcs_get_by_fwnode, @fwnode is the &struct fwnode_handle of +* the PCS itself, and not that of the requesting device. @fwnode could be +* looked up with pcs_find_fwnode() or determined by some other means for +* compatibility. +* +* Return: A PCS on success or an error pointer on failure +*/ +struct phylink_pcs * +pcs_get_by_fwnode_compat (struct device *dev,struct fwnode_handle *fwnode, +int (*fixup)(struct of_changeset *ocs, +struct device_node *np,void *data), +void *data) +{ +#ifdef CONFIG_OF_DYNAMIC +struct mdio_device *mdiodev; +struct of_changeset *ocs; +struct phylink_pcs *pcs; +struct device_node *np; +struct device *pcsdev; +int err; + +/* First attempt */ + pcs =_pcs_get_tail (dev, fwnode,NULL ); +if (PTR_ERR (pcs) != -EPROBE_DEFER ) +return pcs; + +/* No luck? Maybe there's no compatible... */ + np =to_of_node (fwnode); +if (!np ||of_property_present (np,"compatible" )) +return pcs; + +/* OK, let's try fixing things up */ +pr_warn ("%pOF is missing a compatible\n" , np); + ocs =kmalloc (sizeof (*ocs),GFP_KERNEL ); +if (!ocs) +return ERR_PTR (-ENOMEM ); + +of_changeset_init (ocs); + err =fixup (ocs, np, data); +if (err) + goto err_ocs;drivers/net/pcs/core.c line 641
Quoted 10 lines
drivers/net/pcs/core.c +10
-0+ + err =of_changeset_apply (ocs); +if (err) + goto err_ocs; + + err =devm_add_action_or_reset (dev, of_changeset_cleanup, ocs); +if (err) +return ERR_PTR (err); + + mdiodev =fwnode_mdio_find_device (fwnode);
fwnode_mdio_find_device()is unavailable for linking if PHYLIB is a module (and PCS is built-in).Quoted 28 lines
drivers/net/pcs/core.c +28
-0+if (mdiodev) { +/* Clear that pesky PHY flag so we can match PCS drivers */ +device_lock (&mdiodev->dev); + mdiodev->flags &= ~MDIO_DEVICE_FLAG_PHY ; +device_unlock (&mdiodev->dev); + pcsdev = &mdiodev->dev; + }else { + pcsdev =get_device (fwnode->dev); +if (!pcsdev) +return ERR_PTR (-EPROBE_DEFER ); + } + + err =device_reprobe (pcsdev); +put_device (pcsdev); +if (err) +return ERR_PTR (err); + +return _pcs_get_tail (dev, fwnode,NULL ); + +err_ocs: +of_changeset_destroy (ocs); +kfree (ocs); +return ERR_PTR (err); +#else +return _pcs_get_tail (dev, fwnode,NULL ); +#endif +} +EXPORT_SYMBOL_GPL (pcs_get_by_fwnode_compat);...
Russell King (Oracle)
maintainerQuoted 7 lines · Sean Anderson
Hi Russell,
Quoted 4 lines · Russell King (Oracle)
Quoted 2 lines · Sean Anderson
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
Quoted 8 lines
Quoted 3 lines
As per previous, unless I respond (this response not included) then I haven't had time to look at it - and today is total ratshit so, not today.
Sorry if I resent this too soon. I had another look at the request for #pcs-cells [1], and determined that a simpler approach would be possible. So I wanted to resend with that change since it would let me drop the
fwnode_property_get_reference_optional_argspatches.
Please can you send them as RFC so I don't feel the pressure to say something before they get merged (remember, non-RFC patches to netdev get queued up in patchwork for merging.)
Thanks.
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
reviewerQuoted 12 lines · Russell King (Oracle)
Quoted 11 lines · Sean Anderson
Hi Russell,
Quoted 7 lines · Russell King (Oracle)
Quoted 2 lines · Sean Anderson
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
As per previous, unless I respond (this response not included) then I haven't had time to look at it - and today is total ratshit so, not today.
Quoted 8 lines
Quoted 4 lines
Sorry if I resent this too soon. I had another look at the request for #pcs-cells [1], and determined that a simpler approach would be possible. So I wanted to resend with that change since it would let me drop the
fwnode_property_get_reference_optional_argspatches.Please can you send them as RFC so I don't feel the pressure to say something before they get merged (remember, non-RFC patches to netdev get queued up in patchwork for merging.)
This series is marked "changes requested" in patchwork, so I don't think it should get merged automatically. I won't send a v4 until you've had a chance to review it.
--Sean
RE: [net-next PATCH v3 08/11] net: axienet: Convert to use PCS subsystem
In reply to Sean Anderson[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 20 lines
-----Original Message-----
From: Sean Anderson <[email protected]>
Sent: Wednesday, April 16, 2025 1:03 AM
To: [email protected]; Andrew Lunn <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Russell King <[email protected]>
Cc: [email protected]; Christian Marangi <[email protected]>; linux- [email protected]; Kory Maincent <[email protected]>; Heiner Kallweit <[email protected]>; Sean Anderson <[email protected]>; Gupta, Suraj <[email protected]>; Simek, Michal <[email protected]>; Pandey, Radhey Shyam <[email protected]>; Robert Hancock <[email protected]>; [email protected]
Subject: [net-next PATCH v3 08/11] net: axienet: Convert to use PCS subsystemCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 7 lines
Convert 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.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Suraj Gupta <[email protected]>
Tested with ZynqMP AXI 1G ethernet design. Ping works fine, and netperf numbers are as expected.
Quoted 209 lines
---
Changes in v3:
- SelectPCS_XILINXunconditionallydrivers/net/ethernet/xilinx/Kconfig | 7 ++ drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 104 ++++-------------- 3 files changed, 28 insertions(+), 87 deletions(-)drivers/net/ethernet/xilinx/Kconfig +7
-0@@ -25,8 +25,15 @@ config XILINX_EMACLITE config XILINX_AXI_EMAC tristate "Xilinx 10/100/1000 AXI Ethernet support" + depends on COMMON_CLK + depends on GPIOLIB depends on HAS_IOMEM + depends on OF + depends on PCS depends on XILINX_DMA + select MDIO_DEVICE + select OF_DYNAMIC + select PCS_XILINX select PHYLINK select DIMLIB helpdrivers/net/ethernet/xilinx/xilinx_axienet.h +0
-1@@ -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 clockdrivers/net/ethernet/xilinx/xilinx_axienet.h +1
-2@@ -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 +2
-55@@ -35,6 +35,8 @@#include <linux/platform_device.h> #include <linux/skbuff.h> #include <linux/math64.h> +#include <linux/pcs.h> +#include <linux/pcs-xilinx.h> #include <linux/phy.h> #include <linux/mii.h> #include <linux/ethtool.h> @@ -2519,63 +2521,6 @@ static const struct ethtool_ops axienet_ethtool_ops = { .get_rmon_stats = axienet_ethtool_get_rmon_stats, }; -static struct axienet_local *pcs_to_axienet_local(struct phylink_pcs *pcs) -{ - return container_of(pcs, struct axienet_local, pcs); -} - -static void axienet_pcs_get_state (struct phylink_pcs *pcs, -unsigned int neg_mode, -struct phylink_link_state *state) -{ -struct mdio_device *pcs_phy =pcs_to_axienet_local (pcs)->pcs_phy; - -phylink_mii_c22_pcs_get_state (pcs_phy, neg_mode, state); -} - -static void axienet_pcs_an_restart(struct phylink_pcs *pcs) -{ -struct mdio_device *pcs_phy =pcs_to_axienet_local (pcs)->pcs_phy; - -phylink_mii_c22_pcs_an_restart (pcs_phy); -} - -static int axienet_pcs_config (struct phylink_pcs *pcs,unsigned int neg_mode, -phy_interface_t interface, -const unsigned long *advertising, -bool permit_pause_to_mac) -{ -struct mdio_device *pcs_phy =pcs_to_axienet_local (pcs)->pcs_phy; -struct net_device *ndev =pcs_to_axienet_local (pcs)->ndev; -struct axienet_local *lp =netdev_priv (ndev); -int ret; - -if (lp->switch_x_sgmii) { - ret =mdiodev_write (pcs_phy,XLNX_MII_STD_SELECT_REG , - interface ==PHY_INTERFACE_MODE_SGMII ? -XLNX_MII_STD_SELECT_SGMII :0 ); -if (ret <0 ) { -netdev_warn (ndev, -"Failed to switch PHY interface: %d\n" , - ret); -return ret; - } - } - - ret =phylink_mii_c22_pcs_config (pcs_phy, interface, advertising, - neg_mode); -if (ret <0 ) -netdev_warn (ndev,"Failed to configure PCS: %d\n" , ret); - -return ret; -} - -static const struct phylink_pcs_ops axienet_pcs_ops = { - .pcs_get_state = axienet_pcs_get_state, - .pcs_config = axienet_pcs_config, - .pcs_an_restart = axienet_pcs_an_restart, -}; -static struct phylink_pcs *axienet_mac_select_pcs (struct phylink_config *config, phy_interface_t interface) { @@ -2583,8 +2528,8@@ static struct
phylink_pcs*axienet_mac_select_pcs(structphylink_config*config,struct axienet_local *lp = netdev_priv(ndev); if (interface == PHY_INTERFACE_MODE_1000BASEX ||drivers/net/ethernet/xilinx/xilinx_axienet_main.c +19
-22- interface == PHY_INTERFACE_MODE_SGMII) -return &lp->pcs; + interface == PHY_INTERFACE_MODE_SGMII) +return lp->pcs;return NULL ; }@@ -3056,28 +3001,23 @@ static int axienet_probe(struct platform_device *pdev)if (lp->phy_mode ==PHY_INTERFACE_MODE_SGMII || lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) { - np =of_parse_phandle (pdev->dev.of_node,"pcs-handle" ,0 ); -if (!np) { -/* Deprecated: Always use "pcs-handle" for pcs_phy. -* Falling back to "phy-handle" here is only for -* backward compatibility with old device trees. -*/ - np =of_parse_phandle (pdev->dev.of_node,"phy-handle" ,0 ); - } -if (!np) { - dev_err(&pdev->dev, "pcs-handle (preferred) or phy-handle required for 1000BaseX/SGMII\n"); - ret = -EINVAL; - goto cleanup_mdio; - } - lp->pcs_phy =of_mdio_find_device (np); -if (!lp->pcs_phy) { - ret = -EPROBE_DEFER ; -of_node_put (np); +DECLARE_PHY_INTERFACE_MASK (interfaces); + +phy_interface_zero (interfaces); +if (lp->switch_x_sgmii || + lp->phy_mode ==PHY_INTERFACE_MODE_SGMII ) +__set_bit (PHY_INTERFACE_MODE_SGMII , interfaces); +if (lp->switch_x_sgmii || + lp->phy_mode ==PHY_INTERFACE_MODE_1000BASEX ) +__set_bit (PHY_INTERFACE_MODE_1000BASEX , + interfaces); + + lp->pcs =axienet_xilinx_pcs_get (&pdev->dev, interfaces); +if (IS_ERR (lp->pcs)) { + ret =PTR_ERR (lp->pcs); +dev_err_probe (&pdev->dev, ret, + "could not get PCS for + 1000BASE-X/SGMII\n"); goto cleanup_mdio; } -of_node_put (np); - lp->pcs.ops = &axienet_pcs_ops; - lp->pcs.poll = true; } lp->phylink_config.dev = &ndev->dev; @@ -3115,8 +3055,6 @@ static int
axienet_probe(struct platform_device *pdev)phylink_destroy(lp->phylink);
cleanup_mdio:drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-6-if (lp->pcs_phy) -put_device (&lp->pcs_phy->dev);if (lp->mii_bus)axienet_mdio_teardown (lp); cleanup_clk:@@ -3139,9 +3077,7 @@ static void axienet_remove(struct platform_device *pdev)if (lp->phylink)phylink_destroy (lp->phylink); -if (lp->pcs_phy) -put_device (&lp->pcs_phy->dev); - +pcs_put (&pdev->dev, lp->pcs);axienet_mdio_teardown (lp);clk_bulk_disable_unprepare (XAE_NUM_MISC_CLOCKS , lp->misc_clks); --2.35.1.1320.gc452695387.dirty
Simon Horman
reviewerRe: [net-next PATCH v3 03/11] net: pcs: Add subsystem
In reply to Sean AndersonQuoted 54 lines · Sean Anderson
Quoted 45 lines · Simon Horman
Quoted 17 lines · Sean Anderson
This 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 usingphylink_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 Golaszewski's talk at LPC [1].
pcs_get_by_fwnode_compatis 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 becausemdio_bus_matchcallsof_driver_match_deviceto match devices, and that function only works on devicetree nodes.Quoted 3 lines
[1] https://lpc.events/event/17/contributions/1627/
Signed-off-by Sean Anderson <[email protected]>Hi Sean,
I noticed a few build problems after sending my previous email.
I was able to exercise them using variants of the following to generate small configs. I include this here in case it is useful to you.
make tinyconfig
cat >> .config <<
__EOF__CONFIG_MODULES=yCONFIG_NET=yCONFIG_NETDEVICES=yCONFIG_PCS=yCONFIG_PHYLIB=m__EOF__cat >> .config <<
__EOF__CONFIG_OF=yCONFIG_OF_UNITTEST=yCONFIG_OF_DYNAMIC=y__EOF__Quoted 7 lines
yes "" | make oldconfig
...
Quoted 1 line
drivers/net/pcs/core.c +0
-0...
Quoted 6 lines
Thanks, I was able to reproduce/fix these issues.
How did you find these? By inspection?
I often end up missing build issues like this because I mostly test with everything enabled.
Hi Sean,
The issue regarding fwnode_mdio_find_device and PHYLIB as a module came up with an automated allmodconfig W=1 build.
I came across the other issue, regarding CONFIG_OF_DYNAMIC, while investigating the PHYLIB issue. Basically running allmodconfig takes ages on my development machine. So I wanted to try coming up with a small config, based on tinyconfig, that would reproduce the PHYLIB issue. And on the way there - as you can see artifacts of in the configuration commands above - I hit the CONFIG_OF_DYNAMIC issue.
My take on this is that it's good to test allmodconfig, although the build can take ages. Especially if there is any risk of link failures. And, as for other cases, perhaps there are standard ones that are worth exercising, like with/without IPv6 support (probably not relevant to this patchset). But otherwise I think we get down to waiting for the bots (or someone on the ML) to happen to come across a broken (random?) configuration.
...
Sean Anderson
reviewerHi Russell,
Quoted 18 lines · Sean Anderson
Quoted 17 lines · Russell King (Oracle)
Quoted 15 lines · Sean Anderson
Hi Russell,
Quoted 7 lines · Russell King (Oracle)
Quoted 2 lines · Sean Anderson
This series adds support for creating PCSs as devices on a bus with a driver (patch 3). As initial users,
As per previous, unless I respond (this response not included) then I haven't had time to look at it - and today is total ratshit so, not today.
Sorry if I resent this too soon. I had another look at the request for #pcs-cells [1], and determined that a simpler approach would be possible. So I wanted to resend with that change since it would let me drop the
fwnode_property_get_reference_optional_argspatches.
Quoted 7 lines
Quoted 3 lines
Please can you send them as RFC so I don't feel the pressure to say something before they get merged (remember, non-RFC patches to netdev get queued up in patchwork for merging.)
This series is marked "changes requested" in patchwork, so I don't think it should get merged automatically. I won't send a v4 until you've had a chance to review it.
Any chance you could review this series in the next week or so? I would like to send v4 in time to be reviewed before net-next closes later this month.
--Sean
Vladimir Oltean
maintainerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
In reply to Sean AndersonHello Sean,
Quoted 7 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +0
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP
drivers/net/pcs/pcs-lynx.c line 8
Quoted 10 lines
drivers/net/pcs/pcs-lynx.c +5
-2+// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */ -MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );
What's the idea with the license change for this code?
Sean Anderson
reviewerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
Quoted 16 lines · Vladimir Oltean
Hello Sean,
Quoted 13 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +3
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */
Quoted 6 lines
drivers/net/pcs/pcs-lynx.c EXPORT_SYMBOL(lynx_pcs_create_mdiodev); · line 443
Quoted 4 lines
drivers/net/pcs/pcs-lynx.c +2
-2-MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );What's the idea with the license change for this code?
I would like to license my contributions under the GPL in order to ensure that they remain free software.
--Sean
Vladimir Oltean
maintainerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
Quoted 24 lines · Sean Anderson
Quoted 16 lines · Vladimir Oltean
Hello Sean,
Quoted 13 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +3
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */ Quoted 6 lines
drivers/net/pcs/pcs-lynx.c EXPORT_SYMBOL(lynx_pcs_create_mdiodev); · line 443
Quoted 4 lines
drivers/net/pcs/pcs-lynx.c +2
-2-MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );What's the idea with the license change for this code?
Quoted 4 lines
I would like to license my contributions under the GPL in order to ensure that they remain free software.
--Sean
But in the process, you are relicensing code which is not yours. Do you have agreement from the copyright owners of this file that the license can be changed?
Sean Anderson
reviewerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
Quoted 25 lines · Vladimir Oltean
Quoted 24 lines · Sean Anderson
Quoted 22 lines · Vladimir Oltean
Hello Sean,
Quoted 7 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +0
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP drivers/net/pcs/pcs-lynx.c line 8
Quoted 10 lines
drivers/net/pcs/pcs-lynx.c +5
-2+// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */ -MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );What's the idea with the license change for this code?
Quoted 8 lines
Quoted 4 lines
I would like to license my contributions under the GPL in order to ensure that they remain free software.
--Sean
But in the process, you are relicensing code which is not yours. Do you have agreement from the copyright owners of this file that the license can be changed?
I'm not relicensing anything. It's already (GPL OR BSD-3-Clause). I'm just choosing not to license my contributions under BSD-3-Clause.
--Sean
Vladimir Oltean
maintainerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
Quoted 31 lines · Sean Anderson
Quoted 30 lines · Vladimir Oltean
Quoted 28 lines · Sean Anderson
Quoted 16 lines · Vladimir Oltean
Hello Sean,
Quoted 13 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +3
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */ Quoted 6 lines
drivers/net/pcs/pcs-lynx.c EXPORT_SYMBOL(lynx_pcs_create_mdiodev); · line 443
Quoted 4 lines
drivers/net/pcs/pcs-lynx.c +2
-2-MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );What's the idea with the license change for this code?
I would like to license my contributions under the GPL in order to ensure that they remain free software.
--Sean
Quoted 8 lines
Quoted 3 lines
But in the process, you are relicensing code which is not yours. Do you have agreement from the copyright owners of this file that the license can be changed?
I'm not relicensing anything. It's already (GPL OR BSD-3-Clause). I'm just choosing not to license my contributions under BSD-3-Clause.
--Sean
You will need to explain that better, because what I see is that the "BSD-3-Clause" portion of the license has disappeared and that applies file-wide, not just to your contribution.
Sean Anderson
reviewerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
Quoted 36 lines · Vladimir Oltean
Quoted 35 lines · Sean Anderson
Quoted 33 lines · Vladimir Oltean
Quoted 24 lines · Sean Anderson
Quoted 16 lines · Vladimir Oltean
Hello Sean,
Quoted 13 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +3
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */ Quoted 6 lines
drivers/net/pcs/pcs-lynx.c EXPORT_SYMBOL(lynx_pcs_create_mdiodev); · line 443
Quoted 4 lines
drivers/net/pcs/pcs-lynx.c +2
-2-MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );What's the idea with the license change for this code?
Quoted 4 lines
I would like to license my contributions under the GPL in order to ensure that they remain free software.
--Sean
But in the process, you are relicensing code which is not yours. Do you have agreement from the copyright owners of this file that the license can be changed?
Quoted 8 lines
Quoted 4 lines
I'm not relicensing anything. It's already (GPL OR BSD-3-Clause). I'm just choosing not to license my contributions under BSD-3-Clause.
--Sean
You will need to explain that better, because what I see is that the "BSD-3-Clause" portion of the license has disappeared and that applies file-wide, not just to your contribution.
But I also have the option to just use the GPL-2.0+ license. When you have an SPDX like (GPL-2.0+ OR BSD-3-Clause) that means the authors gave permission to relicense it as
- BSD-3-Clause
- GPL-2.0+
- GPL-2.0+ OR BSD-3-Clause
- GPL-2.0
- GPL-2.0 OR BSD-3-Clause
- GPL-3.0
- GPL-3.0 OR BSD-3-Clause
- GPL-4.0 (if it ever happens)
I want my contributions to remain free software, so I don't want to allow someone to take the BSD-3-Clause option (without the GPL).
--Sean
Re: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
In reply to Vladimir OlteanQuoted 25 lines · Vladimir Oltean
Quoted 24 lines · Sean Anderson
Quoted 22 lines · Vladimir Oltean
Hello Sean,
Quoted 7 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +0
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP drivers/net/pcs/pcs-lynx.c line 8
Quoted 10 lines
drivers/net/pcs/pcs-lynx.c +5
-2+// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */ -MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );What's the idea with the license change for this code?
Quoted 9 lines
Quoted 4 lines
I would like to license my contributions under the GPL in order to ensure that they remain free software.
--Sean
But in the process, you are relicensing code which is not yours. Do you have agreement from the copyright owners of this file that the license can be changed?
I think there is a misunderstanding here.
Of course the licence for the file remains dual BSD-3-Clause and GPL-2.0+ up to the change Sean wants to contribute. However, as he only permits GPL-2.0+ the file after applying the change would then only be covered by GPL-2.0+ and no longer by BSD-3-Clause. Legally speaking there is no need to ask any of the previous authors for permission because they already agreed on having the code under GPL-2.0+ **OR** BSD-3-Clause, which means that everyone is free to distribute it under GPL-2.0+ (which is already the case when distributing it along with the Linux Kernel, obviously). Only netdev maintainers need to agree to drop the BSD-3-Clause licence **from future versions including his changes**, and there are obviously reasons for and against that.
Andrew Lunn
maintainerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
In reply to Sean AndersonQuoted 17 lines
Quoted 3 lines
You will need to explain that better, because what I see is that the "BSD-3-Clause" portion of the license has disappeared and that applies file-wide, not just to your contribution.
But I also have the option to just use the GPL-2.0+ license. When you have an SPDX like (GPL-2.0+ OR BSD-3-Clause) that means the authors gave permission to relicense it as
- BSD-3-Clause
- GPL-2.0+
- GPL-2.0+ OR BSD-3-Clause
- GPL-2.0
- GPL-2.0 OR BSD-3-Clause
- GPL-3.0
- GPL-3.0 OR BSD-3-Clause
- GPL-4.0 (if it ever happens)
Quoted 2 lines
I want my contributions to remain free software, so I don't want to allow someone to take the BSD-3-Clause option (without the GPL).
Please can you give us a summary of the licenses of this file over its complete history. Maybe it started out as GPL, and somebody wanted their parts to be under BSD, and so added the BSD parts?
Andrew
Vladimir Oltean
maintainerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
In reply to Daniel GolleHi Daniel,
Quoted 38 lines · Daniel Golle
Quoted 25 lines · Vladimir Oltean
Quoted 24 lines · Sean Anderson
Quoted 22 lines · Vladimir Oltean
Hello Sean,
Quoted 7 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +0
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP drivers/net/pcs/pcs-lynx.c line 8
Quoted 10 lines
drivers/net/pcs/pcs-lynx.c +5
-2+// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */ -MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );What's the idea with the license change for this code?
Quoted 9 lines
Quoted 4 lines
I would like to license my contributions under the GPL in order to ensure that they remain free software.
--Sean
But in the process, you are relicensing code which is not yours. Do you have agreement from the copyright owners of this file that the license can be changed?
I think there is a misunderstanding here.
Quoted 10 lines
Of course the licence for the file remains dual BSD-3-Clause and GPL-2.0+ up to the change Sean wants to contribute. However, as he only permits GPL-2.0+ the file after applying the change would then only be covered by GPL-2.0+ and no longer by BSD-3-Clause. Legally speaking there is no need to ask any of the previous authors for permission because they already agreed on having the code under GPL-2.0+ **OR** BSD-3-Clause, which means that everyone is free to distribute it under GPL-2.0+ (which is already the case when distributing it along with the Linux Kernel, obviously). Only netdev maintainers need to agree to drop the BSD-3-Clause licence **from future versions including his changes**, and there are obviously reasons for and against that.
Thanks for the clarification on the legal aspect, all clear.
Vladimir Oltean
maintainerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
In reply to Sean AndersonQuoted 59 lines · Sean Anderson
Quoted 36 lines · Vladimir Oltean
Quoted 35 lines · Sean Anderson
Quoted 33 lines · Vladimir Oltean
Quoted 24 lines · Sean Anderson
Quoted 16 lines · Vladimir Oltean
Hello Sean,
Quoted 13 lines · Sean Anderson
drivers/net/pcs/pcs-lynx.c +3
-2@@ -1,11 +1,15 @@ -// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) -/* Copyright 2020 NXP +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2022 Sean Anderson <[email protected]> +* Copyright 2020 NXP * Lynx PCS MDIO helpers */ Quoted 6 lines
drivers/net/pcs/pcs-lynx.c line 8
Quoted 4 lines
drivers/net/pcs/pcs-lynx.c +2
-2-MODULE_DESCRIPTION ("NXP Lynx PCS phylink library" ); -MODULE_LICENSE ("Dual BSD/GPL" ); +MODULE_DESCRIPTION ("NXP Lynx PCS phylink driver" ); +MODULE_LICENSE ("GPL" );What's the idea with the license change for this code?
Quoted 4 lines
I would like to license my contributions under the GPL in order to ensure that they remain free software.
--Sean
But in the process, you are relicensing code which is not yours. Do you have agreement from the copyright owners of this file that the license can be changed?
Quoted 8 lines
Quoted 4 lines
I'm not relicensing anything. It's already (GPL OR BSD-3-Clause). I'm just choosing not to license my contributions under BSD-3-Clause.
--Sean
You will need to explain that better, because what I see is that the "BSD-3-Clause" portion of the license has disappeared and that applies file-wide, not just to your contribution.
But I also have the option to just use the GPL-2.0+ license. When you have an SPDX like (GPL-2.0+ OR BSD-3-Clause) that means the authors gave permission to relicense it as
- BSD-3-Clause
- GPL-2.0+
- GPL-2.0+ OR BSD-3-Clause
- GPL-2.0
- GPL-2.0 OR BSD-3-Clause
- GPL-3.0
- GPL-3.0 OR BSD-3-Clause
- GPL-4.0 (if it ever happens)
Quoted 4 lines
I want my contributions to remain free software, so I don't want to allow someone to take the BSD-3-Clause option (without the GPL).
--Sean
Bottom line, I've checked and I don't think any of our planned future contributions to this driver is going to be impacted by the removal of the dual license option, thanks for asking.
Sean Anderson
reviewerRe: [net-next PATCH v3 05/11] net: pcs: lynx: Convert to an MDIO driver
In reply to Andrew LunnHi Andrew,
Quoted 17 lines · Andrew Lunn
Quoted 17 lines
Quoted 3 lines
You will need to explain that better, because what I see is that the "BSD-3-Clause" portion of the license has disappeared and that applies file-wide, not just to your contribution.
But I also have the option to just use the GPL-2.0+ license. When you have an SPDX like (GPL-2.0+ OR BSD-3-Clause) that means the authors gave permission to relicense it as
- BSD-3-Clause
- GPL-2.0+
- GPL-2.0+ OR BSD-3-Clause
- GPL-2.0
- GPL-2.0 OR BSD-3-Clause
- GPL-3.0
- GPL-3.0 OR BSD-3-Clause
- GPL-4.0 (if it ever happens)
Quoted 6 lines
Quoted 2 lines
I want my contributions to remain free software, so I don't want to allow someone to take the BSD-3-Clause option (without the GPL).
Please can you give us a summary of the licenses of this file over its complete history. Maybe it started out as GPL, and somebody wanted their parts to be under BSD, and so added the BSD parts?
This is the original license added in commit 0da4c3d393e4 ("net: phy:
add Lynx PCS module").
--Sean