net: phylink: fix PCS without autoneg
Subsystems (23)
Russell King (Oracle)
maintainerv2 cover net: phylink: fix PCS without autoneg
Hi,
Eric Woudstra reported that a PCS attached using 2500base-X does not see link when phylink is using in-band mode, but autoneg is disabled, despite there being a valid 2500base-X signal being received. We have these settings:
act_link_an_mode = MLO_AN_INBAND pcs_neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED
Eric diagnosed it to phylink_decode_c37_word() setting state->link false because the full-duplex bit isn't set in the non-existent link partner advertisement word (which doesn't exist because in-band autoneg is disabled!)
The test in phylink_mii_c22_pcs_decode_state() is supposed to catch this state, but since we converted PCS to use neg_mode, testing the Autoneg in the local advertisement is no longer sufficient - we need to be looking at the neg_mode, which currently isn't provided.
We need to provide this via the .pcs_get_state() method, and this will require modifying all PCS implementations to add the extra argument to this method.
Patch 1 uses the PCS neg_mode in phylink_mac_pcs_get_state() to correct the now obsolute usage of the Autoneg bit in the advertisement.
Patch 2 passes neg_mode into the .pcs_get_state() method, and updates all users.
Patch 3 adds neg_mode as an argument to the various clause 22 state decoder functions in phylink, modifying drivers to pass the neg_mode through.
Patch 4 makes use of phylink_mii_c22_pcs_decode_state() rather than using the Autoneg bit in the advertising field.
Patch 5 may be required for Eric's case - it ensures that we report the correct state for interface types that we support only one set of modes for when autoneg is disabled.
Changes in v2:
- Add test for NULL pcs in patch 1
I haven't added Eric's t-b because I used a different fix in patch 1.
drivers/net/dsa/b53/b53_serdes.c | 4 +- drivers/net/dsa/mt7530.c | 2 +- drivers/net/dsa/mv88e6xxx/pcs-6185.c | 1 + drivers/net/dsa/mv88e6xxx/pcs-6352.c | 1 + drivers/net/dsa/mv88e6xxx/pcs-639x.c | 5 +- drivers/net/dsa/qca/qca8k-8xxx.c | 2 +- drivers/net/ethernet/cadence/macb_main.c | 3 +- drivers/net/ethernet/freescale/fman/fman_dtsec.c | 4 +- drivers/net/ethernet/marvell/mvneta.c | 2 +- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 + .../net/ethernet/marvell/prestera/prestera_main.c | 1 + drivers/net/ethernet/meta/fbnic/fbnic_phylink.c | 2 +- .../net/ethernet/microchip/lan966x/lan966x_main.h | 2 +- .../ethernet/microchip/lan966x/lan966x_phylink.c | 3 +- .../net/ethernet/microchip/lan966x/lan966x_port.c | 4 +- .../net/ethernet/microchip/sparx5/sparx5_phylink.c | 2 +- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 3 +- drivers/net/pcs/pcs-lynx.c | 4 +- drivers/net/pcs/pcs-mtk-lynxi.c | 4 +- drivers/net/pcs/pcs-xpcs.c | 7 +-- drivers/net/phy/phylink.c | 60 ++++++++++++++++------ include/linux/phylink.h | 11 ++-- 22 files changed, 87 insertions(+), 42 deletions(-)
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!
PATCH v2 1/5 net: phylink: use pcs_neg_mode in phylink_mac_pcs_get_state()
As in-band AN no longer just depends on MLO_AN_INBAND + Autoneg bit, we need to take account of the pcs_neg_mode when deciding how to initialise the speed, duplex and pause state members before calling into the .pcs_neg_mode() method. Add this.
--- drivers/net/phy/phylink.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/net/phy/phylink.c +16 -6
@@ -1492,12 +1492,24 @@ static int phylink_change_inband_advert(struct phylink *pl)static void phylink_mac_pcs_get_state (struct phylink *pl,struct phylink_link_state *state) { +struct phylink_pcs *pcs; +bool autoneg; +linkmode_copy (state->advertising, pl->link_config.advertising);linkmode_zero (state->lp_advertising); state->interface = pl->link_config.interface; state->rate_matching = pl->link_config.rate_matching; -if (linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, - state->advertising)) { + state->an_complete =0 ; + state->link =1 ; + + pcs = pl->pcs; +if (!pcs || pcs->neg_mode) + autoneg = pl->pcs_neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ; +else + autoneg =linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, + state->advertising); + +if (autoneg) { state->speed =SPEED_UNKNOWN ; state->duplex =DUPLEX_UNKNOWN ; state->pause =MLO_PAUSE_NONE ;
@@ -1506,11 +1518,9 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, state->duplex = pl->link_config.duplex; state->pause = pl->link_config.pause; } - state->an_complete =0 ; - state->link =1 ; -if (pl->pcs) - pl->pcs->ops->pcs_get_state (pl->pcs, state); +if (pcs) + pcs->ops->pcs_get_state (pcs, state);else state->link =0 ; }
Signature · 1 line
2.30.2
PATCH v2 2/5 net: phylink: pass neg_mode into .pcs_get_state() method
In reply to Russell King (Oracle)Pass the current neg_mode into the .pcs_get_state() method. Update all users of phylink PCS.
--- drivers/net/dsa/b53/b53_serdes.c | 4 ++-- drivers/net/dsa/mt7530.c | 2 +- drivers/net/dsa/mv88e6xxx/pcs-6185.c | 1 + drivers/net/dsa/mv88e6xxx/pcs-6352.c | 1 + drivers/net/dsa/mv88e6xxx/pcs-639x.c | 5 ++++- drivers/net/dsa/qca/qca8k-8xxx.c | 2 +- drivers/net/ethernet/cadence/macb_main.c | 3 ++- drivers/net/ethernet/freescale/fman/fman_dtsec.c | 2 +- drivers/net/ethernet/marvell/mvneta.c | 2 +- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 ++ drivers/net/ethernet/marvell/prestera/prestera_main.c | 1 + drivers/net/ethernet/meta/fbnic/fbnic_phylink.c | 2 +- drivers/net/ethernet/microchip/lan966x/lan966x_phylink.c | 1 + drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c | 2 +- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 1 + drivers/net/pcs/pcs-lynx.c | 2 +- drivers/net/pcs/pcs-mtk-lynxi.c | 1 + drivers/net/pcs/pcs-xpcs.c | 2 +- drivers/net/phy/phylink.c | 2 +- include/linux/phylink.h | 8 ++++++-- 20 files changed, 31 insertions(+), 15 deletions(-)
drivers/net/dsa/b53/b53_serdes.c +2 -2
@@ -99,8 +99,8 @@ static void b53_serdes_an_restart(struct phylink_pcs *pcs) SERDES_MII_BLK, reg); } -static void b53_serdes_get_state (struct phylink_pcs *pcs, -struct phylink_link_state *state) +static void b53_serdes_get_state (struct phylink_pcs *pcs,unsigned int neg_mode, +struct phylink_link_state *state) {struct b53_device *dev =pcs_to_b53_pcs (pcs)->dev;u8 lane =pcs_to_b53_pcs (pcs)->lane;
drivers/net/dsa/mt7530.c +1 -1
@@ -2994,7 +2994,7 @@ static int mt753x_pcs_validate(struct phylink_pcs *pcs,return 0 ; } -static void mt7530_pcs_get_state (struct phylink_pcs *pcs, +static void mt7530_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) {struct mt7530_priv *priv =pcs_to_mt753x_pcs (pcs)->priv;
drivers/net/dsa/mv88e6xxx/pcs-6185.c +1 -0
@@ -55,6 +55,7 @@ static irqreturn_t mv88e6185_pcs_handle_irq(int irq, void *dev_id) }static void mv88e6185_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct mv88e6185_pcs *mpcs =pcs_to_mv88e6185_pcs (pcs);
drivers/net/dsa/mv88e6xxx/pcs-6352.c +1 -0
@@ -158,6 +158,7 @@ static void marvell_c22_pcs_disable(struct phylink_pcs *pcs) }static void marvell_c22_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct marvell_c22_pcs *mpcs =pcs_to_marvell_c22_pcs (pcs);
drivers/net/dsa/mv88e6xxx/pcs-639x.c +4 -1
@@ -257,6 +257,7 @@ static int mv88e639x_sgmii_pcs_post_config(struct phylink_pcs *pcs, }static void mv88e639x_sgmii_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct mv88e639x_pcs *mpcs =sgmii_pcs_to_mv88e639x_pcs (pcs);
@@ -395,6 +396,7 @@ static void mv88e639x_xg_pcs_disable(struct mv88e639x_pcs *mpcs) }static void mv88e639x_xg_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct mv88e639x_pcs *mpcs =xg_pcs_to_mv88e639x_pcs (pcs);
@@ -889,6 +891,7 @@ static int mv88e6393x_xg_pcs_post_config(struct phylink_pcs *pcs, }static void mv88e6393x_xg_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct mv88e639x_pcs *mpcs =xg_pcs_to_mv88e639x_pcs (pcs);
@@ -896,7 +899,7 @@ static void mv88e6393x_xg_pcs_get_state(struct phylink_pcs *pcs,int err;if (state->interface !=PHY_INTERFACE_MODE_USXGMII ) -return mv88e639x_xg_pcs_get_state (pcs, state); +return mv88e639x_xg_pcs_get_state (pcs, neg_mode, state); state->link = false;
drivers/net/dsa/qca/qca8k-8xxx.c +1 -1
@@ -1491,7 +1491,7 @@ static struct qca8k_pcs *pcs_to_qca8k_pcs(struct phylink_pcs *pcs) return container_of(pcs, struct qca8k_pcs, pcs); } -static void qca8k_pcs_get_state (struct phylink_pcs *pcs, +static void qca8k_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) {struct qca8k_priv *priv =pcs_to_qca8k_pcs (pcs)->priv;
drivers/net/ethernet/cadence/macb_main.c +2 -1
@@ -568,6 +568,7 @@ static void macb_usx_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, }static void macb_usx_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_usx_pcs);
@@ -598,7 +599,7 @@ static int macb_usx_pcs_config(struct phylink_pcs *pcs,return 0 ; } -static void macb_pcs_get_state (struct phylink_pcs *pcs, +static void macb_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) { state->link =0 ;
drivers/net/ethernet/freescale/fman/fman_dtsec.c +1 -1
@@ -755,7 +755,7 @@ static struct fman_mac *pcs_to_dtsec(struct phylink_pcs *pcs) return container_of(pcs, struct fman_mac, pcs); } -static void dtsec_pcs_get_state (struct phylink_pcs *pcs, +static void dtsec_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) {struct fman_mac *dtsec =pcs_to_dtsec (pcs);
drivers/net/ethernet/marvell/mvneta.c +1 -1
@@ -3983,7 +3983,7 @@ static unsigned int mvneta_pcs_inband_caps(struct phylink_pcs *pcs,return LINK_INBAND_DISABLE ; } -static void mvneta_pcs_get_state (struct phylink_pcs *pcs, +static void mvneta_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) {struct mvneta_port *pp =mvneta_pcs_to_port (pcs);
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -0
@@ -6188,6 +6188,7 @@ static struct mvpp2_port *mvpp2_pcs_gmac_to_port(struct phylink_pcs *pcs) }static void mvpp2_xlg_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct mvpp2_port *port =mvpp2_pcs_xlg_to_port (pcs);
@@ -6247,6 +6248,7 @@ static unsigned int mvpp2_gmac_pcs_inband_caps(struct phylink_pcs *pcs, }static void mvpp2_gmac_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct mvpp2_port *port =mvpp2_pcs_gmac_to_port (pcs);
drivers/net/ethernet/marvell/prestera/prestera_main.c +1 -0
@@ -280,6 +280,7 @@ prestera_mac_select_pcs(struct phylink_config *config, }static void prestera_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) { struct prestera_port *port = container_of(pcs, struct prestera_port,
drivers/net/ethernet/meta/fbnic/fbnic_phylink.c +1 -1
@@ -15,7 +15,7 @@ fbnic_pcs_to_net(struct phylink_pcs *pcs) }static void -fbnic_phylink_pcs_get_state (struct phylink_pcs *pcs, +fbnic_phylink_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) {struct fbnic_net *fbn =fbnic_pcs_to_net (pcs);
drivers/net/ethernet/microchip/lan966x/lan966x_phylink.c +1 -0
@@ -88,6 +88,7 @@ static struct lan966x_port *lan966x_pcs_to_port(struct phylink_pcs *pcs) }static void lan966x_pcs_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct lan966x_port *port =lan966x_pcs_to_port (pcs);
drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c +1 -1
@@ -89,7 +89,7 @@ static struct sparx5_port *sparx5_pcs_to_port(struct phylink_pcs *pcs) return container_of(pcs, struct sparx5_port, phylink_pcs); } -static void sparx5_pcs_get_state (struct phylink_pcs *pcs, +static void sparx5_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) {struct sparx5_port *port =sparx5_pcs_to_port (pcs);
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -0
@@ -2331,6 +2331,7 @@ static struct axienet_local *pcs_to_axienet_local(struct phylink_pcs *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;
drivers/net/pcs/pcs-lynx.c +1 -1
@@ -100,7 +100,7 @@ static void lynx_pcs_get_state_2500basex(struct mdio_device *pcs, state->duplex =DUPLEX_FULL ; } -static void lynx_pcs_get_state (struct phylink_pcs *pcs, +static void lynx_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) {struct lynx_pcs *lynx =phylink_pcs_to_lynx (pcs);
drivers/net/pcs/pcs-mtk-lynxi.c +1 -0
@@ -105,6 +105,7 @@ static unsigned int mtk_pcs_lynxi_inband_caps(struct phylink_pcs *pcs, }static void mtk_pcs_lynxi_get_state (struct phylink_pcs *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {struct mtk_pcs_lynxi *mpcs =pcs_to_mtk_pcs_lynxi (pcs);
drivers/net/pcs/pcs-xpcs.c +1 -1
@@ -1086,7 +1086,7 @@ static int xpcs_get_state_2500basex(struct dw_xpcs *xpcs,return 0 ; } -static void xpcs_get_state (struct phylink_pcs *pcs, +static void xpcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs);
drivers/net/phy/phylink.c +1 -1
@@ -1520,7 +1520,7 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, }if (pcs) - pcs->ops->pcs_get_state (pcs, state); + pcs->ops->pcs_get_state (pcs, pl->pcs_neg_mode, state);else state->link =0 ; }
include/linux/phylink.h +6 -2
@@ -446,7 +446,7 @@ struct phylink_pcs_ops { phy_interface_t interface);int (*pcs_post_config)(struct phylink_pcs *pcs,phy_interface_t interface); -void (*pcs_get_state)(struct phylink_pcs *pcs, +void (*pcs_get_state)(struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state); int (*pcs_config)(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface,
@@ -505,6 +505,7 @@ void pcs_disable(struct phylink_pcs *pcs);/** * pcs_get_state() - Read the current inband link state from the hardware * @pcs: a pointer to a &struct phylink_pcs. +* @neg_mode: link negotiation mode (PHYLINK_PCS_NEG_xxx) * @state: a pointer to a &struct phylink_link_state. * * Read the current inband link state from the MAC PCS, reporting the
@@ -513,8 +514,11 @@ void pcs_disable(struct phylink_pcs *pcs);* negotiation completion state in @state->an_complete, and link up state * in @state->link. If possible, @state->lp_advertising should also be * populated. +* +* Note that the @neg_mode parameter is always the PHYLINK_PCS_NEG_xxx +* state, not MLO_AN_xxx. */ -void pcs_get_state (struct phylink_pcs *pcs, +void pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state);/**
Signature · 1 line
2.30.2
PATCH v2 3/5 net: phylink: pass neg_mode into c22 state decoder
In reply to Russell King (Oracle)Pass the current neg_mode into phylink_mii_c22_pcs_get_state() and phylink_mii_c22_pcs_decode_state(). Update all users of phylink PCS that use these functions.
--- drivers/net/ethernet/freescale/fman/fman_dtsec.c | 2 +- drivers/net/ethernet/microchip/lan966x/lan966x_main.h | 2 +- drivers/net/ethernet/microchip/lan966x/lan966x_phylink.c | 2 +- drivers/net/ethernet/microchip/lan966x/lan966x_port.c | 4 ++-- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +- drivers/net/pcs/pcs-lynx.c | 2 +- drivers/net/pcs/pcs-mtk-lynxi.c | 3 ++- drivers/net/pcs/pcs-xpcs.c | 5 +++-- drivers/net/phy/phylink.c | 7 +++++-- include/linux/phylink.h | 3 ++- 10 files changed, 19 insertions(+), 13 deletions(-)
drivers/net/ethernet/freescale/fman/fman_dtsec.c +1 -1
@@ -760,7 +760,7 @@ static void dtsec_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode, {struct fman_mac *dtsec =pcs_to_dtsec (pcs); -phylink_mii_c22_pcs_get_state (dtsec->tbidev, state); +phylink_mii_c22_pcs_get_state (dtsec->tbidev, neg_mode, state); } static int dtsec_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
drivers/net/ethernet/microchip/lan966x/lan966x_main.h +1 -1
@@ -443,7 +443,7 @@ int lan966x_stats_init(struct lan966x *lan966x);void lan966x_port_config_down (struct lan966x_port *port);void lan966x_port_config_up (struct lan966x_port *port); -void lan966x_port_status_get (struct lan966x_port *port, +void lan966x_port_status_get (struct lan966x_port *port,unsigned int neg_mode,struct phylink_link_state *state);int lan966x_port_pcs_set (struct lan966x_port *port,struct lan966x_port_config *config);
drivers/net/ethernet/microchip/lan966x/lan966x_phylink.c +1 -1
@@ -93,7 +93,7 @@ static void lan966x_pcs_get_state(struct phylink_pcs *pcs, {struct lan966x_port *port =lan966x_pcs_to_port (pcs); -lan966x_port_status_get (port, state); +lan966x_port_status_get (port, neg_mode, state); } static int lan966x_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
drivers/net/ethernet/microchip/lan966x/lan966x_port.c +2 -2
@@ -284,7 +284,7 @@ void lan966x_port_config_up(struct lan966x_port *port)lan966x_port_link_up (port); } -void lan966x_port_status_get (struct lan966x_port *port, +void lan966x_port_status_get (struct lan966x_port *port,unsigned int neg_mode,struct phylink_link_state *state) {struct lan966x *lan966x = port->lan966x;
@@ -314,7 +314,7 @@ void lan966x_port_status_get(struct lan966x_port *port, bmsr |=BMSR_ANEGCOMPLETE ; lp_adv =DEV_PCS1G_ANEG_STATUS_LP_ADV_GET (val); -phylink_mii_c22_pcs_decode_state (state, bmsr, lp_adv); +phylink_mii_c22_pcs_decode_state (state, neg_mode, bmsr, lp_adv); }else {if (!state->link)return ;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -1
@@ -2336,7 +2336,7 @@ static void axienet_pcs_get_state(struct phylink_pcs *pcs, {struct mdio_device *pcs_phy =pcs_to_axienet_local (pcs)->pcs_phy; -phylink_mii_c22_pcs_get_state (pcs_phy, state); +phylink_mii_c22_pcs_get_state (pcs_phy, neg_mode, state); }static void axienet_pcs_an_restart (struct phylink_pcs *pcs)
drivers/net/pcs/pcs-lynx.c +1 -1
@@ -109,7 +109,7 @@ static void lynx_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,case PHY_INTERFACE_MODE_1000BASEX :case PHY_INTERFACE_MODE_SGMII :case PHY_INTERFACE_MODE_QSGMII : -phylink_mii_c22_pcs_get_state (lynx->mdio, state); +phylink_mii_c22_pcs_get_state (lynx->mdio, neg_mode, state);break ;case PHY_INTERFACE_MODE_2500BASEX :lynx_pcs_get_state_2500basex (lynx->mdio, state);
drivers/net/pcs/pcs-mtk-lynxi.c +2 -1
@@ -115,7 +115,8 @@ static void mtk_pcs_lynxi_get_state(struct phylink_pcs *pcs,regmap_read (mpcs->regmap,SGMSYS_PCS_CONTROL_1 , &bm);regmap_read (mpcs->regmap,SGMSYS_PCS_ADVERTISE , &adv); -phylink_mii_c22_pcs_decode_state (state,FIELD_GET (SGMII_BMSR , bm), +phylink_mii_c22_pcs_decode_state (state, neg_mode, +FIELD_GET (SGMII_BMSR , bm),FIELD_GET (SGMII_LPA , adv)); }
drivers/net/pcs/pcs-xpcs.c +3 -2
@@ -1030,6 +1030,7 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, }static int xpcs_get_state_c37_1000basex (struct dw_xpcs *xpcs, +unsigned int neg_mode,struct phylink_link_state *state) {int lpa, bmsr;
@@ -1058,7 +1059,7 @@ static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs, } } -phylink_mii_c22_pcs_decode_state (state, bmsr, lpa); +phylink_mii_c22_pcs_decode_state (state, neg_mode, bmsr, lpa); }return 0 ;
@@ -1114,7 +1115,7 @@ static void xpcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode, "xpcs_get_state_c37_sgmii", ERR_PTR(ret));break ;case DW_AN_C37_1000BASEX : - ret =xpcs_get_state_c37_1000basex (xpcs, state); + ret =xpcs_get_state_c37_1000basex (xpcs, neg_mode, state);if (ret)dev_err (&xpcs->mdiodev->dev,"%s returned %pe\n" ,"xpcs_get_state_c37_1000basex" ,ERR_PTR (ret));
drivers/net/phy/phylink.c +5 -2
@@ -3860,6 +3860,7 @@ static void phylink_decode_usgmii_word(struct phylink_link_state *state,/** * phylink_mii_c22_pcs_decode_state() - Decode MAC PCS state from MII registers * @state: a pointer to a &struct phylink_link_state. +* @neg_mode: link negotiation mode (PHYLINK_PCS_NEG_xxx) * @bmsr: The value of the %MII_BMSR register * @lpa: The value of the %MII_LPA register *
@@ -3872,7 +3873,7 @@ static void phylink_decode_usgmii_word(struct phylink_link_state *state,* accessing @bmsr and @lpa cannot be done with MDIO directly. */ void phylink_mii_c22_pcs_decode_state (struct phylink_link_state *state, -u16 bmsr,u16 lpa) +unsigned int neg_mode,u16 bmsr,u16 lpa) { state->link = !!(bmsr &BMSR_LSTATUS ); state->an_complete = !!(bmsr &BMSR_ANEGCOMPLETE );
@@ -3910,6 +3911,7 @@ EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_decode_state);/** * phylink_mii_c22_pcs_get_state() - read the MAC PCS state * @pcs: a pointer to a &struct mdio_device. +* @neg_mode: link negotiation mode (PHYLINK_PCS_NEG_xxx) * @state: a pointer to a &struct phylink_link_state. * * Helper for MAC PCS supporting the 802.3 clause 22 register set for
@@ -3922,6 +3924,7 @@ EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_decode_state);* structure. */ void phylink_mii_c22_pcs_get_state (struct mdio_device *pcs, +unsigned int neg_mode,struct phylink_link_state *state) {int bmsr, lpa;
@@ -3933,7 +3936,7 @@ void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,return ; } -phylink_mii_c22_pcs_decode_state (state, bmsr, lpa); +phylink_mii_c22_pcs_decode_state (state, neg_mode, bmsr, lpa); }EXPORT_SYMBOL_GPL (phylink_mii_c22_pcs_get_state);
include/linux/phylink.h +2 -1
@@ -693,8 +693,9 @@ static inline int phylink_get_link_timer_ns(phy_interface_t interface) }void phylink_mii_c22_pcs_decode_state (struct phylink_link_state *state, -u16 bmsr,u16 lpa); +unsigned int neg_mode,u16 bmsr,u16 lpa);void phylink_mii_c22_pcs_get_state (struct mdio_device *pcs, +unsigned int neg_mode,struct phylink_link_state *state);int phylink_mii_c22_pcs_encode_advertisement (phy_interface_t interface,const unsigned long *advertising);
Signature · 1 line
2.30.2
PATCH v2 4/5 net: phylink: use neg_mode in phylink_mii_c22_pcs_decode_state()
In reply to Russell King (Oracle)Rather than using the state of the Autoneg bit, which is unreliable with the new PCS neg mode support, use the passed neg_mode to decide whether to decode the link partner advertisement data.
--- drivers/net/phy/phylink.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/phy/phylink.c +8 -4
@@ -3877,11 +3877,15 @@ void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state, { state->link = !!(bmsr &BMSR_LSTATUS ); state->an_complete = !!(bmsr &BMSR_ANEGCOMPLETE ); -/* If there is no link or autonegotiation is disabled, the LP advertisement -* data is not meaningful, so don't go any further. + +/* If the link is down, the advertisement data is undefined. */ +if (!state->link) +return ; + +/* If in-band is disabled, then the advertisement data is not +* meaningful. */ -if (!state->link || !linkmode_test_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, - state->advertising)) +if (neg_mode !=PHYLINK_PCS_NEG_INBAND_ENABLED )return ;switch (state->interface) {
Signature · 1 line
2.30.2
PATCH v2 5/5 net: phylink: provide fixed state for 1000base-X and 2500base-X
In reply to Russell King (Oracle)When decoding clause 22 state, if in-band is disabled and using either 1000base-X or 2500base-X, rather than reporting link-down, we know the speed, and we only support full duplex. Pause modes taken from XPCS.
This fixes a problem reported by Eric Woudstra.
--- drivers/net/phy/phylink.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/net/phy/phylink.c +19 -10
@@ -3882,27 +3882,36 @@ void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,if (!state->link)return ; -/* If in-band is disabled, then the advertisement data is not -* meaningful. -*/ -if (neg_mode !=PHYLINK_PCS_NEG_INBAND_ENABLED ) -return ; -switch (state->interface) {case PHY_INTERFACE_MODE_1000BASEX : -phylink_decode_c37_word (state, lpa,SPEED_1000 ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) { +phylink_decode_c37_word (state, lpa,SPEED_1000 ); + }else { + state->speed =SPEED_1000 ; + state->duplex =DUPLEX_FULL ; + state->pause |=MLO_PAUSE_TX |MLO_PAUSE_RX ; + }break ;case PHY_INTERFACE_MODE_2500BASEX : -phylink_decode_c37_word (state, lpa,SPEED_2500 ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) { +phylink_decode_c37_word (state, lpa,SPEED_2500 ); + }else { + state->speed =SPEED_2500 ; + state->duplex =DUPLEX_FULL ; + state->pause |=MLO_PAUSE_TX |MLO_PAUSE_RX ; + }break ;case PHY_INTERFACE_MODE_SGMII :case PHY_INTERFACE_MODE_QSGMII : -phylink_decode_sgmii_word (state, lpa); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) +phylink_decode_sgmii_word (state, lpa);break ; +case PHY_INTERFACE_MODE_QUSGMII : -phylink_decode_usgmii_word (state, lpa); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) +phylink_decode_usgmii_word (state, lpa);break ;default :
Signature · 1 line
2.30.2
Hello Russell,
Quoted 37 lines · On Mon, 13 Jan 2025 09:22:15 +0000 "Russell King (Oracle)"…
Hi,
Eric Woudstra reported that a PCS attached using 2500base-X does not see link when phylink is using in-band mode, but autoneg is disabled, despite there being a valid 2500base-X signal being received. We have these settings:
act_link_an_mode=MLO_AN_INBANDpcs_neg_mode=PHYLINK_PCS_NEG_INBAND_DISABLEDEric diagnosed it to
phylink_decode_c37_word()settingstate->linkfalse because the full-duplex bit isn't set in the non-existent link partner advertisement word (which doesn't exist because in-band autoneg is disabled!)The test in
phylink_mii_c22_pcs_decode_state()is supposed to catch this state, but since we converted PCS to useneg_mode, testing the Autoneg in the local advertisement is no longer sufficient - we need to be looking at theneg_mode, which currently isn't provided.We need to provide this via the .pcs_get_state() method, and this will require modifying all PCS implementations to add the extra argument to this method.
Patch 1 uses the PCS
neg_modeinphylink_mac_pcs_get_state()to correct the now obsolute usage of the Autoneg bit in the advertisement.Patch 2 passes
neg_modeinto the .pcs_get_state() method, and updates all users.Patch 3 adds
neg_modeas an argument to the various clause 22 state decoder functions in phylink, modifying drivers to pass theneg_modethrough.Patch 4 makes use of
phylink_mii_c22_pcs_decode_state()rather than using the Autoneg bit in the advertising field.
Quoted 8 lines
Patch 5 may be required for Eric's case - it ensures that we report the correct state for interface types that we support only one set of modes for when autoneg is disabled.
Changes in v2:
- Add test for NULL pcs in patch 1I haven't added Eric's t-b because I used a different fix in patch 1.
I stumbled on that issue last friday as well, with a MCBin and a device I'm working on, using 1000BaseX with autoneg disabled. I didn't get time to investigate back then, but reading this series it was definitely that exact problem I was facing.
I missed your V1 and I just tested that V2, the problem is gone :) Thanks !
The code LGTM to the best of my knowledge, so
Thanks,
Maxime
Vladimir Oltean
maintainerRe: [PATCH net-next v2 5/5] net: phylink: provide fixed state for 1000base-X and 2500base-X
In reply to Russell King (Oracle)Quoted 37 lines · Russell King (Oracle)
When decoding clause 22 state, if in-band is disabled and using either 1000base-X or 2500base-X, rather than reporting link-down, we know the speed, and we only support full duplex. Pause modes taken from XPCS.
This fixes a problem reported by Eric Woudstra.
Signed-off-by Russell King (Oracle) <[email protected]>--- drivers/net/phy/phylink.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)drivers/net/phy/phylink.c +7
-7@@ -3882,27 +3882,36 @@ void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,if (!state->link)return ; -/* If in-band is disabled, then the advertisement data is not -* meaningful. -*/ -if (neg_mode !=PHYLINK_PCS_NEG_INBAND_ENABLED ) -return ; -switch (state->interface) {case PHY_INTERFACE_MODE_1000BASEX : -phylink_decode_c37_word (state, lpa,SPEED_1000 ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) { +phylink_decode_c37_word (state, lpa,SPEED_1000 ); + }else { + state->speed =SPEED_1000 ; + state->duplex =DUPLEX_FULL ; + state->pause |=MLO_PAUSE_TX |MLO_PAUSE_RX ; + }break ;
drivers/net/phy/phylink.c void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state, · line 3904
Quoted 10 lines
drivers/net/phy/phylink.c +7
-1case PHY_INTERFACE_MODE_2500BASEX : -phylink_decode_c37_word (state, lpa,SPEED_2500 ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) { +phylink_decode_c37_word (state, lpa,SPEED_2500 ); + }else { + state->speed =SPEED_2500 ; + state->duplex =DUPLEX_FULL ; + state->pause |=MLO_PAUSE_TX |MLO_PAUSE_RX ; + }break ;
Are the "else" branches necessary, given the "else" branch from phylink_mac_pcs_get_state?
static void phylink_mac_pcs_get_state(struct phylink *pl,
struct phylink_link_state *state)
{
struct phylink_pcs *pcs;
bool autoneg;
linkmode_copy(state->advertising, pl->link_config.advertising);
linkmode_zero(state->lp_advertising);
state->interface = pl->link_config.interface;
state->rate_matching = pl->link_config.rate_matching;
state->an_complete = 0;
state->link = 1;
pcs = pl->pcs;
if (!pcs || pcs->neg_mode)
autoneg = pl->pcs_neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED;
else
autoneg = linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
state->advertising);
if (autoneg) {
state->speed = SPEED_UNKNOWN;
state->duplex = DUPLEX_UNKNOWN;
state->pause = MLO_PAUSE_NONE;
} else { |
state->speed = pl->link_config.speed; |
state->duplex = pl->link_config.duplex; | this
state->pause = pl->link_config.pause; |
} |
if (pcs)
pcs->ops->pcs_get_state(pcs, pl->pcs_neg_mode, state);
else
state->link = 0;
}Russell King (Oracle)
maintainerRe: [PATCH net-next v2 5/5] net: phylink: provide fixed state for 1000base-X and 2500base-X
Quoted 73 lines · Vladimir Oltean
Quoted 37 lines · Russell King (Oracle)
When decoding clause 22 state, if in-band is disabled and using either 1000base-X or 2500base-X, rather than reporting link-down, we know the speed, and we only support full duplex. Pause modes taken from XPCS.
This fixes a problem reported by Eric Woudstra.
Signed-off-by Russell King (Oracle) <[email protected]>--- drivers/net/phy/phylink.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)drivers/net/phy/phylink.c +7
-7@@ -3882,27 +3882,36 @@ void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,if (!state->link)return ; -/* If in-band is disabled, then the advertisement data is not -* meaningful. -*/ -if (neg_mode !=PHYLINK_PCS_NEG_INBAND_ENABLED ) -return ; -switch (state->interface) {case PHY_INTERFACE_MODE_1000BASEX : -phylink_decode_c37_word (state, lpa,SPEED_1000 ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) { +phylink_decode_c37_word (state, lpa,SPEED_1000 ); + }else { + state->speed =SPEED_1000 ; + state->duplex =DUPLEX_FULL ; + state->pause |=MLO_PAUSE_TX |MLO_PAUSE_RX ; + }break ;drivers/net/phy/phylink.c void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state, · line 3904
Quoted 10 lines
drivers/net/phy/phylink.c +7
-1case PHY_INTERFACE_MODE_2500BASEX : -phylink_decode_c37_word (state, lpa,SPEED_2500 ); +if (neg_mode ==PHYLINK_PCS_NEG_INBAND_ENABLED ) { +phylink_decode_c37_word (state, lpa,SPEED_2500 ); + }else { + state->speed =SPEED_2500 ; + state->duplex =DUPLEX_FULL ; + state->pause |=MLO_PAUSE_TX |MLO_PAUSE_RX ; + }break ;Are the "else" branches necessary, given the "else" branch from
phylink_mac_pcs_get_state?static void phylink_mac_pcs_get_state(struct phylink *pl,
structphylink_link_state*state){ struct phylink_pcs *pcs; bool autoneg; linkmode_copy(state->advertising, pl->link_config.advertising); linkmode_zero(state->lp_advertising); state->interface = pl->link_config.interface; state->rate_matching = pl->link_config.rate_matching; state->an_complete = 0; state->link = 1; pcs = pl->pcs; if (!pcs || pcs->neg_mode) autoneg = pl->pcs_neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED; else autoneg = linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, state->advertising); if (autoneg) {
Quoted 8 lines
state->speed = SPEED_UNKNOWN;
state->duplex = DUPLEX_UNKNOWN;
state->pause = MLO_PAUSE_NONE;
} else { |
state->speed = pl->link_config.speed; |
state->duplex = pl->link_config.duplex; | this
state->pause = pl->link_config.pause; |
} |This is fine for cases where ethtool is used to turn autoneg off, but not if we're in in-band mode and the PCS/PHY have decided to have autoneg off - in that case, nothing sets pl->link_config.* to anything sensible.
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!
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 13 Jan 2025 09:22:15 +0000 you wrote:
Hi,
Eric Woudstra reported that a PCS attached using 2500base-X does not see link when phylink is using in-band mode, but autoneg is disabled, despite there being a valid 2500base-X signal being received. We have these settings:
[...]
Here is the summary with links:
- [net-next,v2,1/5] net: phylink: use pcs_neg_mode in phylink_mac_pcs_get_state()
https://git.kernel.org/netdev/net-next/c/0f1396d24658 - [net-next,v2,2/5] net: phylink: pass neg_mode into .pcs_get_state() method https://git.kernel.org/netdev/net-next/c/c6739623c91b - [net-next,v2,3/5] net: phylink: pass neg_mode into c22 state decoder https://git.kernel.org/netdev/net-next/c/7e3cb4e874ab - [net-next,v2,4/5] net: phylink: use neg_mode in phylink_mii_c22_pcs_decode_state() https://git.kernel.org/netdev/net-next/c/60a331fff5e8 - [net-next,v2,5/5] net: phylink: provide fixed state for 1000base-X and 2500base-X https://git.kernel.org/netdev/net-next/c/e432ffc14b17
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html