net: dsa: Plug in PHYLINK support
cover net: dsa: Plug in PHYLINK support
Hi all,
This patch series replaces the existing PHYLIB integration with PHYLINK which is a superior solution since we need to support a collection of fixed links, integrated PHYs, SFP, non-pluggable SFPs etc.
I am expecting quite a lot of breakage, for a number of reasons:
- PHYLINK does not create a PHY device for fixed links (MLO_AN_FIXED), which means that user-facing port (not DSA, not CPU) need to be explicitly handled with phylink_mac_ops now
- only been able to test this on a limited number of platforms, and not the ZII devel B/C boards yet
Please test and report!
Florian Fainelli (2):
net: dsa: Plug in PHYLINK support
net: dsa: bcm_sf2: Kick PHYLINK upon link interrupts
drivers/net/dsa/bcm_sf2.c | 29 +++-- include/net/dsa.h | 23 +++- net/dsa/Kconfig | 1 + net/dsa/dsa_priv.h | 9 -- net/dsa/slave.c | 294 +++++++++++++++++++++++++++------------------- 5 files changed, 210 insertions(+), 146 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/2 net: dsa: Plug in PHYLINK support
Add support for PHYLINK within the DSA subsystem in order to support more complex devices such as pluggable and non-pluggable SFP modules, 10G PHYs, and traditional PHYs. Using PHYLINK allows us to drop some amount of complexity we had while dealing with fixed and non-fixed PHYs using Device Tree.
Because PHYLINK separates the Ethernet MAC/port configuration into different stages, we let switch drivers implement those, and for now, we maintain functionality by calling dsa_slave_adjust_link() for most of these operations.
--- drivers/net/dsa/bcm_sf2.c | 11 +- include/net/dsa.h | 23 +++- net/dsa/Kconfig | 1 + net/dsa/dsa_priv.h | 9 -- net/dsa/slave.c | 294 +++++++++++++++++++++++++++------------------- 5 files changed, 198 insertions(+), 140 deletions(-)
drivers/net/dsa/bcm_sf2.c +5 -6
@@ -16,6 +16,7 @@#include <linux/platform_device.h> #include <linux/phy.h> #include <linux/phy_fixed.h> +#include <linux/phylink.h> #include <linux/mii.h> #include <linux/of.h> #include <linux/of_irq.h>
@@ -563,7 +564,7 @@ static void bcm_sf2_sw_adjust_link(struct dsa_switch *ds, int port, }static void bcm_sf2_sw_fixed_link_update (struct dsa_switch *ds,int port, -struct fixed_phy_status *status) +struct phylink_link_state *status) {struct bcm_sf2_priv *priv =bcm_sf2_to_priv (ds);u32 duplex, pause, offset;
@@ -611,13 +612,11 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,core_writel (priv, reg, offset);if ((pause & (1 << port)) && - (pause & (1 << (port +PAUSESTS_TX_PAUSE_SHIFT )))) { - status->asym_pause =1 ; - status->pause =1 ; - } + (pause & (1 << (port +PAUSESTS_TX_PAUSE_SHIFT )))) + status->pause |=MLO_PAUSE_TXRX_MASK ;if (pause & (1 << port)) - status->pause =1 ; + status->pause |=MLO_PAUSE_RX ; }static void bcm_sf2_enable_acb (struct dsa_switch *ds)
include/net/dsa.h +22 -1
@@ -25,6 +25,7 @@struct tc_action ;struct phy_device ;struct fixed_phy_status ; +struct phylink_link_state ;enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =0 ,
@@ -197,6 +198,7 @@ struct dsa_port {u8 stp_state;struct net_device *bridge_dev;struct devlink_port devlink_port; +struct phylink *pl;/* * Original copy of the master netdev ethtool_ops */
@@ -348,8 +350,25 @@ struct dsa_switch_ops {*/ void (*adjust_link)(struct dsa_switch *ds,int port,struct phy_device *phydev); +/* +* PHYLINK integration +*/ +void (*phylink_validate)(struct dsa_switch *ds,int port, +unsigned long *supported, +struct phylink_link_state *state); +int (*phylink_mac_link_state)(struct dsa_switch *ds,int port, +struct phylink_link_state *state); +void (*phylink_mac_config)(struct dsa_switch *ds,int port, +unsigned int mode, +const struct phylink_link_state *state); +void (*phylink_mac_an_restart)(struct dsa_switch *ds,int port); +void (*phylink_mac_link_down)(struct dsa_switch *ds,int port, +unsigned int mode); +void (*phylink_mac_link_up)(struct dsa_switch *ds,int port, +unsigned int mode, +struct phy_device *phydev);void (*fixed_link_update)(struct dsa_switch *ds,int port, -struct fixed_phy_status *st); +struct phylink_link_state *st);/* * ethtool hardware statistics.
@@ -568,4 +587,6 @@ static inline int call_dsa_notifiers(unsigned long val, struct net_device *dev,#define BRCM_TAG_GET_PORT (v) ((v) >> 8)#define BRCM_TAG_GET_QUEUE (v) ((v) & 0xff) +void dsa_port_phylink_mac_change (struct dsa_switch *ds,int port,bool up); +#endif
net/dsa/Kconfig +1 -0
@@ -10,6 +10,7 @@ config NET_DSA depends on BRIDGE || BRIDGE=n select NET_SWITCHDEV select PHYLIB + select PHYLINK ---help--- Say Y if you want to enable support for the hardware switches supported by the Distributed Switch Architecture.
net/dsa/dsa_priv.h +0 -9
@@ -75,15 +75,6 @@ struct dsa_slave_priv {/* DSA port data, such as switch, port index, etc. */ struct dsa_port *dp; -/* -* The phylib phy_device pointer for the PHY connected -* to this port. -*/ -phy_interface_t phy_interface; -int old_link; -int old_pause; -int old_duplex; -#ifdef CONFIG_NET_POLL_CONTROLLER struct netpoll *netpoll;#endif
net/dsa/slave.c +170 -124
468 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH 2/2 net: dsa: bcm_sf2: Kick PHYLINK upon link interrupts
In reply to Florian FainelliIn order to signal MoCA port link interrupts the same way we used to do (through polling a fixed PHY and having an fixed_link_update callback run), we just need to call phylink_mac_change() when that happens, and have our custom fixed_link_update callback run to obtain the link state.
--- drivers/net/dsa/bcm_sf2.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/dsa/bcm_sf2.c +12 -6
@@ -307,7 +307,8 @@ static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,static irqreturn_t bcm_sf2_switch_0_isr (int irq,void *dev_id) { -struct bcm_sf2_priv *priv = dev_id; +struct dsa_switch *ds = dev_id; +struct bcm_sf2_priv *priv =bcm_sf2_to_priv (ds); priv->irq0_stat =intrl2_0_readl (priv,INTRL2_CPU_STATUS ) & ~priv->irq0_mask;
@@ -318,16 +319,21 @@ static irqreturn_t bcm_sf2_switch_0_isr(int irq, void *dev_id)static irqreturn_t bcm_sf2_switch_1_isr (int irq,void *dev_id) { -struct bcm_sf2_priv *priv = dev_id; +struct dsa_switch *ds = dev_id; +struct bcm_sf2_priv *priv =bcm_sf2_to_priv (ds); priv->irq1_stat =intrl2_1_readl (priv,INTRL2_CPU_STATUS ) & ~priv->irq1_mask;intrl2_1_writel (priv, priv->irq1_stat,INTRL2_CPU_CLEAR ); -if (priv->irq1_stat &P_LINK_UP_IRQ (P7_IRQ_OFF )) +if (priv->irq1_stat &P_LINK_UP_IRQ (P7_IRQ_OFF )) { priv->port_sts[7 ].link =1 ; -if (priv->irq1_stat &P_LINK_DOWN_IRQ (P7_IRQ_OFF )) +dsa_port_phylink_mac_change (ds,7 , true); + } +if (priv->irq1_stat &P_LINK_DOWN_IRQ (P7_IRQ_OFF )) { priv->port_sts[7 ].link =0 ; +dsa_port_phylink_mac_change (ds,7 , false); + }return IRQ_HANDLED ; }
@@ -1060,14 +1066,14 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)bcm_sf2_intr_disable (priv); ret =devm_request_irq (&pdev->dev, priv->irq0, bcm_sf2_switch_0_isr,0 , -"switch_0" , priv); +"switch_0" , ds);if (ret <0 ) {pr_err ("failed to request switch_0 IRQ\n" ); goto out_mdio; } ret =devm_request_irq (&pdev->dev, priv->irq1, bcm_sf2_switch_1_isr,0 , -"switch_1" , priv); +"switch_1" , ds);if (ret <0 ) {pr_err ("failed to request switch_1 IRQ\n" ); goto out_mdio;
Signature · 1 line
2.14.1
Quoted 8 lines · Florian Fainelli
Hi all,
This patch series replaces the existing PHYLIB integration with PHYLINK which is a superior solution since we need to support a collection of fixed links, integrated PHYs, SFP, non-pluggable SFPs etc.
I am expecting quite a lot of breakage, for a number of reasons:
Quoted 8 lines
- PHYLINK does not create a PHY device for fixed links (
MLO_AN_FIXED), which means that user-facing port (not DSA, not CPU) need to be explicitly handled withphylink_mac_opsnow- only been able to test this on a limited number of platforms, and not the ZII devel B/C boards yet
Please test and report!
The good news is that it almost works on the ZII Rev C with the SFF modules, but there's a few issues that need solving:
1. s/WARN_ON(!lockdep_rtnl_is_held())/ASSERT_RTNL()/ in phylink.c - probably wouldn't have been noticed if it wasn't for the lockdep splat with DSA's interrupt handling during boot that's been there since -rc1. (Andrew mentioned that it's known, so I haven't reported that.)
2. ports without a phy but with sfp cause the "no phy at" and "failed to connect to port" message - I think we need a way for DSA to know whether it should be attempting to attach a PHY.
3. We need mv88e6xxx to implement at least phylink_mac_link_state() so that SFPs report sane ethtool information. It also needs to implement phylink_mac_config() so that the link can be appropriately configured to the module's capabilities, and phylink_validate() to do the jiggery for choosing between 1000base-X vs 2500base-X mode if the DSA switches can't automatically select the appropriate one.
With a few hacks for the above, I can get TX_DISABLE on the SFF2 module to follow the interface up/down status, but as I say more work is needed so that mv88e6xxx works with the phylink callbacks for the SFF modules to be properly supported.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up
Andrew Lunn
maintainerQuoted 5 lines
1. s/WARN_ON(!lockdep_rtnl_is_held())/ASSERT_RTNL()/ in
phylink.c- probably wouldn't have been noticed if it wasn't for the lockdep splat with DSA's interrupt handling during boot that's been there since -rc1. (Andrew mentioned that it's known, so I haven't reported that.)
Hi Russell
https://lkml.org/lkml/2017/12/2/260
This should fix that splat. I hope it will get picked up at some point. It is probably getting on time to repost it.
Andrew
Hi
Den 15. des. 2017 01:28, skrev Florian Fainelli:
Quoted 6 lines
Hi all,
This patch series replaces the existing PHYLIB integration with PHYLINK which is a superior solution since we need to support a collection of fixed links, integrated PHYs, SFP, non-pluggable SFPs etc.
Quoted 6 lines
I am expecting quite a lot of breakage, for a number of reasons:
- PHYLINK does not create a PHY device for fixed links (
MLO_AN_FIXED), which means that user-facing port (not DSA, not CPU) need to be explicitly handled withphylink_mac_opsnow
FWIW: We (zenitel) does not use fixed-link on user-port. I gave the patches a spin on our board with lan9303. As expected: no breakage.
Egil