net: Add support for Synopsys DesignWare XPCS
Subsystems (6)
PATCH 1/8 net: stmmac: selftests: Do not fail if PHY is not attached
In reply to Jose AbreuIf a PHY is not attached, we can still run the tests with MAC loopback mode. Return -EOPNOTSUPP error code in PHY loopback test so that global status is not a failure.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1 -1
@@ -380,7 +380,7 @@ static int stmmac_test_phy_loopback(struct stmmac_priv *priv)int ret;if (!priv->dev->phydev) -return -EBUSY ; +return -EOPNOTSUPP ; ret =phy_loopback (priv->dev->phydev, true);if (ret)
Signature · 1 line
2.7.4
PATCH 6/8 net: phylink: Test if MAC/PCS support Autoneg
In reply to Jose AbreuWe may have cases where MAC or PCS do not support Autoneg. Check if it is supported after validate callback is called.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/phy/phylink.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/phy/phylink.c +3 -0
@@ -340,6 +340,9 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode) "failed to validate link configuration for in-band status\n");return -EINVAL ; } + +/* Check if MAC/PCS also supports Autoneg. */ + pl->link_config.an_enabled =phylink_test (pl->supported, Autoneg); }return 0 ;
Signature · 1 line
2.7.4
PATCH 7/8 net: phy: Add Synopsys DesignWare XPCS MDIO module
In reply to Jose AbreuSynopsys DesignWare XPCS is an MMD that can manage link status, auto-negotiation, link training, ...
In this commit we add basic support for XPCS using USXGMII interface and Clause 73 Auto-negotiation.
This is highly tied with PHYLINK and can't be used without it. A given ethernet driver can use the provided callbacks to add the support for XPCS.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- MAINTAINERS | 7 + drivers/net/phy/Kconfig | 6 + drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-xpcs.c | 612 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mdio-xpcs.h | 41 +++ 5 files changed, 667 insertions(+) create mode 100644 drivers/net/phy/mdio-xpcs.c create mode 100644 include/linux/mdio-xpcs.h
MAINTAINERS +7 -0
@@ -16111,6 +16111,13 @@ L: [email protected] S: Supported F: drivers/net/ethernet/synopsys/ +SYNOPSYS DESIGNWARE ETHERNET XPCS DRIVER +M: Jose Abreu <[email protected]> +L: [email protected] +S: Supported +F: drivers/net/phy/mdio-xpcs.c +F: include/linux/mdio-xpcs.h + SYNOPSYS DESIGNWARE I2C DRIVER M: Jarkko Nikula <[email protected]> R: Andy Shevchenko <[email protected]>
drivers/net/phy/Kconfig +6 -0
@@ -214,6 +214,12 @@ config MDIO_XGENE This module provides a driver for the MDIO busses found in the APM X-Gene SoC's. +config MDIO_XPCS + tristate "Synopsys DesignWare XPCS controller" + help + This module provides helper functions for Synopsys DesignWare XPCS + controllers. + endif endif
drivers/net/phy/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o obj-$(CONFIG_MDIO_THUNDER) += mdio-thunder.o obj-$(CONFIG_MDIO_XGENE) += mdio-xgene.o +obj-$(CONFIG_MDIO_XPCS) += mdio-xpcs.o obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += mii_timestamper.o
drivers/net/phy/mdio-xpcs.c new file +612 -0
612 lines not on this page · raw message
include/linux/mdio-xpcs.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 3/8 net: stmmac: Fallback to dev_fwnode() if needed
In reply to Jose AbreuWhen CONFIG_OF is not enabled, of_fwnode_handle() will return NULL, even though we can have a FW handle from a given device.
Fallback to dev_fwnode() helper if needed.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -0
@@ -1043,6 +1043,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) priv->phylink_config.dev = &priv->dev->dev; priv->phylink_config.type =PHYLINK_NETDEV ; +if (!fwnode) + fwnode =dev_fwnode (priv->device); + phylink =phylink_create (&priv->phylink_config, fwnode, mode, &stmmac_phylink_mac_ops);if (IS_ERR (phylink))
Signature · 1 line
2.7.4
PATCH 2/8 net: stmmac: Switch to linkmode_and()/linkmode_andnot()
In reply to Jose AbreuUse the linkmode_and()/linkmode_andnot() helpers to simplify the code.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -8
@@ -858,14 +858,11 @@ static void stmmac_validate(struct phylink_config *config, phylink_set(mask, 1000baseT_Half); } -bitmap_and (supported, supported, mac_supported, - __ETHTOOL_LINK_MODE_MASK_NBITS); -bitmap_andnot (supported, supported, mask, - __ETHTOOL_LINK_MODE_MASK_NBITS); -bitmap_and (state->advertising, state->advertising, mac_supported, - __ETHTOOL_LINK_MODE_MASK_NBITS); -bitmap_andnot (state->advertising, state->advertising, mask, - __ETHTOOL_LINK_MODE_MASK_NBITS); +linkmode_and (supported, supported, mac_supported); +linkmode_andnot (supported, supported, mask); + +linkmode_and (state->advertising, state->advertising, mac_supported); +linkmode_andnot (state->advertising, state->advertising, mask); } static void stmmac_mac_pcs_get_state(struct phylink_config *config,
Signature · 1 line
2.7.4
PATCH 5/8 net: phylink: Add missing Backplane speeds
In reply to Jose AbreuUSXGMII also supports these missing backplane speeds.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/phy/phylink.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/phy/phylink.c +2 -0
@@ -312,11 +312,13 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode) phylink_set(pl->supported, 1000baseT_Half); phylink_set(pl->supported, 1000baseT_Full); phylink_set(pl->supported, 1000baseX_Full); + phylink_set(pl->supported, 1000baseKX_Full); phylink_set(pl->supported, 2500baseT_Full); phylink_set(pl->supported, 2500baseX_Full); phylink_set(pl->supported, 5000baseT_Full); phylink_set(pl->supported, 10000baseT_Full); phylink_set(pl->supported, 10000baseKR_Full); + phylink_set(pl->supported, 10000baseKX4_Full); phylink_set(pl->supported, 10000baseCR_Full); phylink_set(pl->supported, 10000baseSR_Full); phylink_set(pl->supported, 10000baseLR_Full);
Signature · 1 line
2.7.4
cover net: Add support for Synopsys DesignWare XPCS
This adds support for Synopsys DesignWare XPCS in net subsystem and integrates it into stmmac.
At 1/8, we start by removing the limitation of stmmac selftests that needed a PHY to pass all the tests.
Then at 2/8 we use some helpers in stmmac so that some code can be simplified.
At 3/8, we fallback to dev_fwnode() so that PCI based setups wich may not have CONFIG_OF can still use FW node.
At 4/8, we adapt stmmac to the new PHYLINK changes as suggested by Russell King.
We proceed by doing changes in PHYLINK in order to support XPCS: At 5/8 we add some missing speeds that USXGMII supports and at 6/8 we check if Autoneg is supported after initial parameters are validated.
Support for XPCS is finally introduced at 7/8, along with the usage of it in stmmac driver at 8/8.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Jose Abreu (8):
net: stmmac: selftests: Do not fail if PHY is not attached
net: stmmac: Switch to linkmode_and()/linkmode_andnot()
net: stmmac: Fallback to dev_fwnode() if needed
net: stmmac: Use resolved link config in mac_link_up()
net: phylink: Add missing Backplane speeds
net: phylink: Test if MAC/PCS support Autoneg
net: phy: Add Synopsys DesignWare XPCS MDIO module
net: stmmac: Integrate it with DesignWare XPCS
MAINTAINERS | 7 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 1 + drivers/net/ethernet/stmicro/stmmac/common.h | 3 + drivers/net/ethernet/stmicro/stmmac/hwif.h | 12 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 96 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 27 + .../net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- drivers/net/phy/Kconfig | 6 + drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-xpcs.c | 612 +++++++++++++++++++++ drivers/net/phy/phylink.c | 5 + include/linux/mdio-xpcs.h | 41 ++ include/linux/stmmac.h | 1 + 13 files changed, 771 insertions(+), 43 deletions(-) create mode 100644 drivers/net/phy/mdio-xpcs.c create mode 100644 include/linux/mdio-xpcs.h
Signature · 1 line
2.7.4
PATCH 8/8 net: stmmac: Integrate it with DesignWare XPCS
Adds all the necessary logic so that stmmac can be used with Synopsys DesignWare XPCS.
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/Kconfig | 1 + drivers/net/ethernet/stmicro/stmmac/common.h | 3 +++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 12 ++++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 ++++++++++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 27 +++++++++++++++++++++++ include/linux/stmmac.h | 1 + 6 files changed, 58 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +1 -0
@@ -3,6 +3,7 @@ config STMMAC_ETH tristate "STMicroelectronics Multi-Gigabit Ethernet driver" depends on HAS_IOMEM && HAS_DMA select MII + select MDIO_XPCS select PAGE_POOL select PHYLINK select CRC32
drivers/net/ethernet/stmicro/stmmac/common.h +3 -0
@@ -15,6 +15,7 @@#include <linux/netdevice.h> #include <linux/stmmac.h> #include <linux/phy.h> +#include <linux/mdio-xpcs.h> #include <linux/module.h> #if IS_ENABLED (CONFIG_VLAN_8021Q )#define STMMAC_VLAN_TAG_USED
@@ -446,6 +447,8 @@ struct mac_device_info {const struct stmmac_hwtimestamp *ptp;const struct stmmac_tc_ops *tc;const struct stmmac_mmc_ops *mmc; +const struct mdio_xpcs_ops *xpcs; +struct mdio_xpcs_args xpcs_args;struct mii_regs mii;/* MII register Addresses */ struct mac_link link;void __iomem *pcsr;/* vpointer to device CSRs */
drivers/net/ethernet/stmicro/stmmac/hwif.h +12 -0
@@ -577,6 +577,18 @@ struct stmmac_mmc_ops { #define stmmac_mmc_read(__priv, __args...) \ stmmac_do_void_callback(__priv, mmc, read, __args) +/* XPCS callbacks */ +#define stmmac_xpcs_validate(__priv, __args...) \ + stmmac_do_callback(__priv, xpcs, validate, __args) +#define stmmac_xpcs_config(__priv, __args...) \ + stmmac_do_callback(__priv, xpcs, config, __args) +#define stmmac_xpcs_get_state(__priv, __args...) \ + stmmac_do_callback(__priv, xpcs, get_state, __args) +#define stmmac_xpcs_link_up(__priv, __args...) \ + stmmac_do_callback(__priv, xpcs, link_up, __args) +#define stmmac_xpcs_probe(__priv, __args...) \ + stmmac_do_callback(__priv, xpcs, probe, __args) +struct stmmac_regs_off {u32 ptp_off;u32 mmc_off;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +14 -2
@@ -863,18 +863,26 @@ static void stmmac_validate(struct phylink_config *config,linkmode_and (state->advertising, state->advertising, mac_supported);linkmode_andnot (state->advertising, state->advertising, mask); + +/* If PCS is supported, check which modes it supports. */ +stmmac_xpcs_validate (priv, &priv->hw->xpcs_args, supported, state); }static void stmmac_mac_pcs_get_state (struct phylink_config *config,struct phylink_link_state *state) { +struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); + state->link =0 ; +stmmac_xpcs_get_state (priv, &priv->hw->xpcs_args, state); }static void stmmac_mac_config (struct phylink_config *config,unsigned int mode,const struct phylink_link_state *state) { -/* Nothing for now. */ +struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); + +stmmac_xpcs_config (priv, &priv->hw->xpcs_args, state); }static void stmmac_mac_an_restart (struct phylink_config *config)
@@ -902,6 +910,8 @@ static void stmmac_mac_link_up(struct phylink_config *config,struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev));u32 ctrl; +stmmac_xpcs_link_up (priv, &priv->hw->xpcs_args, speed, interface); + ctrl =readl (priv->ioaddr +MAC_CTRL_REG ); ctrl &= ~priv->hw->link.speed_mask;
@@ -1042,6 +1052,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) priv->phylink_config.dev = &priv->dev->dev; priv->phylink_config.type =PHYLINK_NETDEV ; + priv->phylink_config.pcs_poll = true;if (!fwnode) fwnode =dev_fwnode (priv->device);
@@ -2689,7 +2700,8 @@ static int stmmac_open(struct net_device *dev)int ret;if (priv->hw->pcs !=STMMAC_PCS_TBI && - priv->hw->pcs !=STMMAC_PCS_RTBI ) { + priv->hw->pcs !=STMMAC_PCS_RTBI && + priv->hw->xpcs ==NULL ) { ret =stmmac_init_phy (dev);if (ret) { netdev_err(priv->dev,
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +27 -0
@@ -382,6 +382,14 @@ int stmmac_mdio_register(struct net_device *ndev) max_addr =PHY_MAX_ADDR ; } +if (mdio_bus_data->has_xpcs) { + priv->hw->xpcs =mdio_xpcs_get_ops (); +if (!priv->hw->xpcs) { + err = -ENODEV ; + goto bus_register_fail; + } + } +if (mdio_bus_data->needs_reset) new_bus->reset = &stmmac_mdio_reset;
@@ -433,6 +441,25 @@ int stmmac_mdio_register(struct net_device *ndev) found =1 ; } +/* Try to probe the XPCS by scanning all addresses. */ +if (priv->hw->xpcs) { +struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args; +int ret, mode = priv->plat->phy_interface; + max_addr =PHY_MAX_ADDR ; + + xpcs->bus = new_bus; + +for (addr =0 ; addr < max_addr; addr++) { + xpcs->addr = addr; + + ret =stmmac_xpcs_probe (priv, xpcs, mode); +if (!ret) { + found =1 ; +break ; + } + } + } +if (!found && !mdio_node) {dev_warn (dev,"No PHY found\n" );mdiobus_unregister (new_bus);
include/linux/stmmac.h +1 -0
@@ -80,6 +80,7 @@struct stmmac_mdio_bus_data {unsigned int phy_mask; +unsigned int has_xpcs;int *irqs;int probed_phy_irq;bool needs_reset;
Signature · 1 line
2.7.4
PATCH 4/8 net: stmmac: Use resolved link config in mac_link_up()
In reply to Jose AbreuConvert the stmmac ethernet driver to use the finalised link parameters in mac_link_up() rather than the parameters in mac_config().
---
Cc: Giuseppe Cavallaro <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Jose Abreu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Florian Fainelli <[email protected]>
Cc: Heiner Kallweit <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 66 +++++++++++------------ 1 file changed, 33 insertions(+), 33 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +33 -33
@@ -874,14 +874,39 @@ static void stmmac_mac_pcs_get_state(struct phylink_config *config,static void stmmac_mac_config (struct phylink_config *config,unsigned int mode,const struct phylink_link_state *state) { +/* Nothing for now. */ +} + +static void stmmac_mac_an_restart (struct phylink_config *config) +{ +/* Not Supported */ +} + +static void stmmac_mac_link_down (struct phylink_config *config, +unsigned int mode,phy_interface_t interface) +{ +struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); + +stmmac_mac_set (priv, priv->ioaddr, false); + priv->eee_active = false; +stmmac_eee_init (priv); +stmmac_set_eee_pls (priv, priv->hw, false); +} + +static void stmmac_mac_link_up (struct phylink_config *config, +struct phy_device *phy, +unsigned int mode,phy_interface_t interface, +int speed,int duplex, +bool tx_pause,bool rx_pause) +{struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev));u32 ctrl; ctrl =readl (priv->ioaddr +MAC_CTRL_REG ); ctrl &= ~priv->hw->link.speed_mask; -if (state->interface ==PHY_INTERFACE_MODE_USXGMII ) { -switch (state->speed) { +if (interface ==PHY_INTERFACE_MODE_USXGMII ) { +switch (speed) {case SPEED_10000 : ctrl |= priv->hw->link.xgmii.speed10000;break ;
@@ -895,7 +920,7 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,return ; } }else { -switch (state->speed) { +switch (speed) {case SPEED_2500 : ctrl |= priv->hw->link.speed2500;break ;
@@ -913,46 +938,21 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, } } - priv->speed = state->speed; + priv->speed = speed;if (priv->plat->fix_mac_speed) - priv->plat->fix_mac_speed (priv->plat->bsp_priv, state->speed); + priv->plat->fix_mac_speed (priv->plat->bsp_priv, speed); -if (!state->duplex) +if (!duplex) ctrl &= ~priv->hw->link.duplex;else ctrl |= priv->hw->link.duplex;/* Flow Control operation */ -if (state->pause) -stmmac_mac_flow_ctrl (priv, state->duplex); +if (tx_pause && rx_pause) +stmmac_mac_flow_ctrl (priv, duplex);writel (ctrl, priv->ioaddr +MAC_CTRL_REG ); -} - -static void stmmac_mac_an_restart (struct phylink_config *config) -{ -/* Not Supported */ -} - -static void stmmac_mac_link_down (struct phylink_config *config, -unsigned int mode,phy_interface_t interface) -{ -struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); - -stmmac_mac_set (priv, priv->ioaddr, false); - priv->eee_active = false; -stmmac_eee_init (priv); -stmmac_set_eee_pls (priv, priv->hw, false); -} - -static void stmmac_mac_link_up (struct phylink_config *config, -struct phy_device *phy, -unsigned int mode,phy_interface_t interface, -int speed,int duplex, -bool tx_pause,bool rx_pause) -{ -struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev));stmmac_mac_set (priv, priv->ioaddr, true);if (phy && priv->dma_cap.eee) {
Signature · 1 line
2.7.4
David Miller
maintainerFrom: Jose Abreu <[email protected]>
Date: Mon, 9 Mar 2020 09:36:19 +0100
Quoted 15 lines
This adds support for Synopsys DesignWare XPCS in net subsystem and integrates it into stmmac.
At 1/8, we start by removing the limitation of stmmac selftests that needed a PHY to pass all the tests.
Then at 2/8 we use some helpers in stmmac so that some code can be simplified.
At 3/8, we fallback to
dev_fwnode()so that PCI based setups wich may not haveCONFIG_OFcan still use FW node.At 4/8, we adapt stmmac to the new PHYLINK changes as suggested by Russell King.
Quoted 6 lines
We proceed by doing changes in PHYLINK in order to support XPCS: At 5/8 we add some missing speeds that USXGMII supports and at 6/8 we check if Autoneg is supported after initial parameters are validated.
Support for XPCS is finally introduced at 7/8, along with the usage of it in stmmac driver at 8/8.
Series applied, thank you.
Russell King - ARM Linux admin
maintainerRe: [PATCH net-next 7/8] net: phy: Add Synopsys DesignWare XPCS MDIO module
In reply to Jose AbreuHi Jose,
I just tripped over a bug while grepping for something else and reading a bit of this driver:
Quoted 36 lines · Jose Abreu
drivers/net/phy/mdio-xpcs.c new file +36
-0+static int xpcs_read_lpa (struct mdio_xpcs_args *xpcs, +struct phylink_link_state *state) +{ +int ret; + + ret =xpcs_read (xpcs,MDIO_MMD_AN ,MDIO_STAT1 ); +if (ret <0 ) +return ret; + +if (!(ret &MDIO_AN_STAT1_LPABLE )) { +phylink_clear (state->lp_advertising, Autoneg); +return 0 ; + } + +phylink_set (state->lp_advertising, Autoneg); + +/* Clause 73 outcome */ + ret =xpcs_read (xpcs,MDIO_MMD_AN ,DW_SR_AN_LP_ABL3 ); +if (ret <0 ) +return ret; + +if (ret &DW_C73_2500KX ) + phylink_set(state->lp_advertising, 2500baseX_Full); + + ret =xpcs_read (xpcs,MDIO_MMD_AN ,DW_SR_AN_LP_ABL2 ); +if (ret <0 ) +return ret; + +if (ret &DW_C73_1000KX ) + phylink_set(state->lp_advertising, 1000baseKX_Full); +if (ret &DW_C73_10000KX4 ) + phylink_set(state->lp_advertising, 10000baseKX4_Full); +if (ret &DW_C73_10000KR ) + phylink_set(state->lp_advertising, 10000baseKR_Full); + + ret =xpcs_read (xpcs,MDIO_MMD_AN ,DW_SR_AN_LP_ABL1 );
drivers/net/phy/mdio-xpcs.c line 447
Quoted 10 lines
drivers/net/phy/mdio-xpcs.c new file +10
-0+if (ret <0 ) +return ret; + +if (ret &DW_C73_PAUSE ) +phylink_set (state->lp_advertising, Pause); +if (ret &DW_C73_ASYM_PAUSE ) +phylink_set (state->lp_advertising, Asym_Pause); + +linkmode_and (state->lp_advertising, state->lp_advertising, + state->advertising);
This is incorrect - you should not mask the link partner's advertisement with our advertisement like this; consider the table in 802.3 for resolving the pause modes, where simply doing a bitwise-and operation between the two advertisements would severely restrict the resulting resolution to either symmetric pause or nothing at all.
You want to do this when you resolve the speed, but only _temporarily_ in order to resolve the speed - you do not want to write back the result to state->lp_advertising.
You may wish to fix that.
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC for 0.8m (est. 1762m) line in suburbia: sync at 13.1Mbps down 424kbps up
RE: [PATCH net-next 7/8] net: phy: Add Synopsys DesignWare XPCS MDIO module
From: Russell King - ARM Linux admin <[email protected]>
Date: Jun/05/2020, 18:10:34 (UTC+00:00)
Quoted 9 lines
This is incorrect - you should not mask the link partner's advertisement with our advertisement like this; consider the table in 802.3 for resolving the pause modes, where simply doing a bitwise-and operation between the two advertisements would severely restrict the resulting resolution to either symmetric pause or nothing at all.
You want to do this when you resolve the speed, but only _temporarily_ in order to resolve the speed - you do not want to write back the result to
state->lp_advertising.
Thanks for bringing this up. Indeed I believe I did this in order to resolve the speed, as you said.
Quoted 1 line
You may wish to fix that.
Added to the list of my pending fixes. Thanks!
---
Thanks,
Jose Miguel Abreu