Skip to content

Commit e80ed97

Browse files
committed
Merge branch 'net-phylink-fix-pcs-without-autoneg'
Russell King says: ==================== net: phylink: fix PCS without autoneg 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. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 9eb8069 + e432ffc commit e80ed97

File tree

22 files changed

+87
-42
lines changed

22 files changed

+87
-42
lines changed

drivers/net/dsa/b53/b53_serdes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ static void b53_serdes_an_restart(struct phylink_pcs *pcs)
9999
SERDES_MII_BLK, reg);
100100
}
101101

102-
static void b53_serdes_get_state(struct phylink_pcs *pcs,
103-
struct phylink_link_state *state)
102+
static void b53_serdes_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
103+
struct phylink_link_state *state)
104104
{
105105
struct b53_device *dev = pcs_to_b53_pcs(pcs)->dev;
106106
u8 lane = pcs_to_b53_pcs(pcs)->lane;

drivers/net/dsa/mt7530.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,7 @@ static int mt753x_pcs_validate(struct phylink_pcs *pcs,
29942994
return 0;
29952995
}
29962996

2997-
static void mt7530_pcs_get_state(struct phylink_pcs *pcs,
2997+
static void mt7530_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
29982998
struct phylink_link_state *state)
29992999
{
30003000
struct mt7530_priv *priv = pcs_to_mt753x_pcs(pcs)->priv;

drivers/net/dsa/mv88e6xxx/pcs-6185.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static irqreturn_t mv88e6185_pcs_handle_irq(int irq, void *dev_id)
5555
}
5656

5757
static void mv88e6185_pcs_get_state(struct phylink_pcs *pcs,
58+
unsigned int neg_mode,
5859
struct phylink_link_state *state)
5960
{
6061
struct mv88e6185_pcs *mpcs = pcs_to_mv88e6185_pcs(pcs);

drivers/net/dsa/mv88e6xxx/pcs-6352.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static void marvell_c22_pcs_disable(struct phylink_pcs *pcs)
158158
}
159159

160160
static void marvell_c22_pcs_get_state(struct phylink_pcs *pcs,
161+
unsigned int neg_mode,
161162
struct phylink_link_state *state)
162163
{
163164
struct marvell_c22_pcs *mpcs = pcs_to_marvell_c22_pcs(pcs);

drivers/net/dsa/mv88e6xxx/pcs-639x.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ static int mv88e639x_sgmii_pcs_post_config(struct phylink_pcs *pcs,
257257
}
258258

259259
static void mv88e639x_sgmii_pcs_get_state(struct phylink_pcs *pcs,
260+
unsigned int neg_mode,
260261
struct phylink_link_state *state)
261262
{
262263
struct mv88e639x_pcs *mpcs = sgmii_pcs_to_mv88e639x_pcs(pcs);
@@ -395,6 +396,7 @@ static void mv88e639x_xg_pcs_disable(struct mv88e639x_pcs *mpcs)
395396
}
396397

397398
static void mv88e639x_xg_pcs_get_state(struct phylink_pcs *pcs,
399+
unsigned int neg_mode,
398400
struct phylink_link_state *state)
399401
{
400402
struct mv88e639x_pcs *mpcs = xg_pcs_to_mv88e639x_pcs(pcs);
@@ -889,14 +891,15 @@ static int mv88e6393x_xg_pcs_post_config(struct phylink_pcs *pcs,
889891
}
890892

891893
static void mv88e6393x_xg_pcs_get_state(struct phylink_pcs *pcs,
894+
unsigned int neg_mode,
892895
struct phylink_link_state *state)
893896
{
894897
struct mv88e639x_pcs *mpcs = xg_pcs_to_mv88e639x_pcs(pcs);
895898
u16 status, lp_status;
896899
int err;
897900

898901
if (state->interface != PHY_INTERFACE_MODE_USXGMII)
899-
return mv88e639x_xg_pcs_get_state(pcs, state);
902+
return mv88e639x_xg_pcs_get_state(pcs, neg_mode, state);
900903

901904
state->link = false;
902905

drivers/net/dsa/qca/qca8k-8xxx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ static struct qca8k_pcs *pcs_to_qca8k_pcs(struct phylink_pcs *pcs)
14911491
return container_of(pcs, struct qca8k_pcs, pcs);
14921492
}
14931493

1494-
static void qca8k_pcs_get_state(struct phylink_pcs *pcs,
1494+
static void qca8k_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
14951495
struct phylink_link_state *state)
14961496
{
14971497
struct qca8k_priv *priv = pcs_to_qca8k_pcs(pcs)->priv;

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ static void macb_usx_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
568568
}
569569

570570
static void macb_usx_pcs_get_state(struct phylink_pcs *pcs,
571+
unsigned int neg_mode,
571572
struct phylink_link_state *state)
572573
{
573574
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,
598599
return 0;
599600
}
600601

601-
static void macb_pcs_get_state(struct phylink_pcs *pcs,
602+
static void macb_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
602603
struct phylink_link_state *state)
603604
{
604605
state->link = 0;

drivers/net/ethernet/freescale/fman/fman_dtsec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,12 +755,12 @@ static struct fman_mac *pcs_to_dtsec(struct phylink_pcs *pcs)
755755
return container_of(pcs, struct fman_mac, pcs);
756756
}
757757

758-
static void dtsec_pcs_get_state(struct phylink_pcs *pcs,
758+
static void dtsec_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
759759
struct phylink_link_state *state)
760760
{
761761
struct fman_mac *dtsec = pcs_to_dtsec(pcs);
762762

763-
phylink_mii_c22_pcs_get_state(dtsec->tbidev, state);
763+
phylink_mii_c22_pcs_get_state(dtsec->tbidev, neg_mode, state);
764764
}
765765

766766
static int dtsec_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,

drivers/net/ethernet/marvell/mvneta.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3983,7 +3983,7 @@ static unsigned int mvneta_pcs_inband_caps(struct phylink_pcs *pcs,
39833983
return LINK_INBAND_DISABLE;
39843984
}
39853985

3986-
static void mvneta_pcs_get_state(struct phylink_pcs *pcs,
3986+
static void mvneta_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
39873987
struct phylink_link_state *state)
39883988
{
39893989
struct mvneta_port *pp = mvneta_pcs_to_port(pcs);

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6188,6 +6188,7 @@ static struct mvpp2_port *mvpp2_pcs_gmac_to_port(struct phylink_pcs *pcs)
61886188
}
61896189

61906190
static void mvpp2_xlg_pcs_get_state(struct phylink_pcs *pcs,
6191+
unsigned int neg_mode,
61916192
struct phylink_link_state *state)
61926193
{
61936194
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,
62476248
}
62486249

62496250
static void mvpp2_gmac_pcs_get_state(struct phylink_pcs *pcs,
6251+
unsigned int neg_mode,
62506252
struct phylink_link_state *state)
62516253
{
62526254
struct mvpp2_port *port = mvpp2_pcs_gmac_to_port(pcs);

drivers/net/ethernet/marvell/prestera/prestera_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ prestera_mac_select_pcs(struct phylink_config *config,
280280
}
281281

282282
static void prestera_pcs_get_state(struct phylink_pcs *pcs,
283+
unsigned int neg_mode,
283284
struct phylink_link_state *state)
284285
{
285286
struct prestera_port *port = container_of(pcs, struct prestera_port,

drivers/net/ethernet/meta/fbnic/fbnic_phylink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fbnic_pcs_to_net(struct phylink_pcs *pcs)
1515
}
1616

1717
static void
18-
fbnic_phylink_pcs_get_state(struct phylink_pcs *pcs,
18+
fbnic_phylink_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
1919
struct phylink_link_state *state)
2020
{
2121
struct fbnic_net *fbn = fbnic_pcs_to_net(pcs);

drivers/net/ethernet/microchip/lan966x/lan966x_main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ int lan966x_stats_init(struct lan966x *lan966x);
443443

444444
void lan966x_port_config_down(struct lan966x_port *port);
445445
void lan966x_port_config_up(struct lan966x_port *port);
446-
void lan966x_port_status_get(struct lan966x_port *port,
446+
void lan966x_port_status_get(struct lan966x_port *port, unsigned int neg_mode,
447447
struct phylink_link_state *state);
448448
int lan966x_port_pcs_set(struct lan966x_port *port,
449449
struct lan966x_port_config *config);

drivers/net/ethernet/microchip/lan966x/lan966x_phylink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ static struct lan966x_port *lan966x_pcs_to_port(struct phylink_pcs *pcs)
8888
}
8989

9090
static void lan966x_pcs_get_state(struct phylink_pcs *pcs,
91+
unsigned int neg_mode,
9192
struct phylink_link_state *state)
9293
{
9394
struct lan966x_port *port = lan966x_pcs_to_port(pcs);
9495

95-
lan966x_port_status_get(port, state);
96+
lan966x_port_status_get(port, neg_mode, state);
9697
}
9798

9899
static int lan966x_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,

drivers/net/ethernet/microchip/lan966x/lan966x_port.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ void lan966x_port_config_up(struct lan966x_port *port)
284284
lan966x_port_link_up(port);
285285
}
286286

287-
void lan966x_port_status_get(struct lan966x_port *port,
287+
void lan966x_port_status_get(struct lan966x_port *port, unsigned int neg_mode,
288288
struct phylink_link_state *state)
289289
{
290290
struct lan966x *lan966x = port->lan966x;
@@ -314,7 +314,7 @@ void lan966x_port_status_get(struct lan966x_port *port,
314314
bmsr |= BMSR_ANEGCOMPLETE;
315315

316316
lp_adv = DEV_PCS1G_ANEG_STATUS_LP_ADV_GET(val);
317-
phylink_mii_c22_pcs_decode_state(state, bmsr, lp_adv);
317+
phylink_mii_c22_pcs_decode_state(state, neg_mode, bmsr, lp_adv);
318318
} else {
319319
if (!state->link)
320320
return;

drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static struct sparx5_port *sparx5_pcs_to_port(struct phylink_pcs *pcs)
8989
return container_of(pcs, struct sparx5_port, phylink_pcs);
9090
}
9191

92-
static void sparx5_pcs_get_state(struct phylink_pcs *pcs,
92+
static void sparx5_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
9393
struct phylink_link_state *state)
9494
{
9595
struct sparx5_port *port = sparx5_pcs_to_port(pcs);

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2331,11 +2331,12 @@ static struct axienet_local *pcs_to_axienet_local(struct phylink_pcs *pcs)
23312331
}
23322332

23332333
static void axienet_pcs_get_state(struct phylink_pcs *pcs,
2334+
unsigned int neg_mode,
23342335
struct phylink_link_state *state)
23352336
{
23362337
struct mdio_device *pcs_phy = pcs_to_axienet_local(pcs)->pcs_phy;
23372338

2338-
phylink_mii_c22_pcs_get_state(pcs_phy, state);
2339+
phylink_mii_c22_pcs_get_state(pcs_phy, neg_mode, state);
23392340
}
23402341

23412342
static void axienet_pcs_an_restart(struct phylink_pcs *pcs)

drivers/net/pcs/pcs-lynx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void lynx_pcs_get_state_2500basex(struct mdio_device *pcs,
100100
state->duplex = DUPLEX_FULL;
101101
}
102102

103-
static void lynx_pcs_get_state(struct phylink_pcs *pcs,
103+
static void lynx_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
104104
struct phylink_link_state *state)
105105
{
106106
struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs);
@@ -109,7 +109,7 @@ static void lynx_pcs_get_state(struct phylink_pcs *pcs,
109109
case PHY_INTERFACE_MODE_1000BASEX:
110110
case PHY_INTERFACE_MODE_SGMII:
111111
case PHY_INTERFACE_MODE_QSGMII:
112-
phylink_mii_c22_pcs_get_state(lynx->mdio, state);
112+
phylink_mii_c22_pcs_get_state(lynx->mdio, neg_mode, state);
113113
break;
114114
case PHY_INTERFACE_MODE_2500BASEX:
115115
lynx_pcs_get_state_2500basex(lynx->mdio, state);

drivers/net/pcs/pcs-mtk-lynxi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ static unsigned int mtk_pcs_lynxi_inband_caps(struct phylink_pcs *pcs,
105105
}
106106

107107
static void mtk_pcs_lynxi_get_state(struct phylink_pcs *pcs,
108+
unsigned int neg_mode,
108109
struct phylink_link_state *state)
109110
{
110111
struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs);
@@ -114,7 +115,8 @@ static void mtk_pcs_lynxi_get_state(struct phylink_pcs *pcs,
114115
regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm);
115116
regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);
116117

117-
phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm),
118+
phylink_mii_c22_pcs_decode_state(state, neg_mode,
119+
FIELD_GET(SGMII_BMSR, bm),
118120
FIELD_GET(SGMII_LPA, adv));
119121
}
120122

drivers/net/pcs/pcs-xpcs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,
10301030
}
10311031

10321032
static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
1033+
unsigned int neg_mode,
10331034
struct phylink_link_state *state)
10341035
{
10351036
int lpa, bmsr;
@@ -1058,7 +1059,7 @@ static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
10581059
}
10591060
}
10601061

1061-
phylink_mii_c22_pcs_decode_state(state, bmsr, lpa);
1062+
phylink_mii_c22_pcs_decode_state(state, neg_mode, bmsr, lpa);
10621063
}
10631064

10641065
return 0;
@@ -1086,7 +1087,7 @@ static int xpcs_get_state_2500basex(struct dw_xpcs *xpcs,
10861087
return 0;
10871088
}
10881089

1089-
static void xpcs_get_state(struct phylink_pcs *pcs,
1090+
static void xpcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
10901091
struct phylink_link_state *state)
10911092
{
10921093
struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs);
@@ -1114,7 +1115,7 @@ static void xpcs_get_state(struct phylink_pcs *pcs,
11141115
"xpcs_get_state_c37_sgmii", ERR_PTR(ret));
11151116
break;
11161117
case DW_AN_C37_1000BASEX:
1117-
ret = xpcs_get_state_c37_1000basex(xpcs, state);
1118+
ret = xpcs_get_state_c37_1000basex(xpcs, neg_mode, state);
11181119
if (ret)
11191120
dev_err(&xpcs->mdiodev->dev, "%s returned %pe\n",
11201121
"xpcs_get_state_c37_1000basex", ERR_PTR(ret));

0 commit comments

Comments
 (0)