Skip to content

Commit fad5819

Browse files
Russell Kingdavem330
authored andcommitted
net: dsa: mv88e6xxx: fix in-band AN link establishment
If in-band negotiation or fixed-link modes are specified for a DSA port, the DSA code will force the link down during initialisation. For fixed-link mode, this is fine, as phylink will manage the link state. However, for in-band mode, phylink expects the PCS to detect link, which will not happen if the link is forced down. There is a related issue that in in-band mode, the link could come up while we are making configuration changes, so we should force the link down prior to reconfiguring the interface mode. This patch addresses both issues. Fixes: 3be98b2 ("net: dsa: Down cpu/dsa ports phylink will control") Signed-off-by: Russell King <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a463fa2 commit fad5819

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,11 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
664664
const struct phylink_link_state *state)
665665
{
666666
struct mv88e6xxx_chip *chip = ds->priv;
667+
struct mv88e6xxx_port *p;
667668
int err;
668669

670+
p = &chip->ports[port];
671+
669672
/* FIXME: is this the correct test? If we're in fixed mode on an
670673
* internal port, why should we process this any different from
671674
* PHY mode? On the other hand, the port may be automedia between
@@ -675,10 +678,14 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
675678
return;
676679

677680
mv88e6xxx_reg_lock(chip);
678-
/* FIXME: should we force the link down here - but if we do, how
679-
* do we restore the link force/unforce state? The driver layering
680-
* gets in the way.
681+
/* In inband mode, the link may come up at any time while the link
682+
* is not forced down. Force the link down while we reconfigure the
683+
* interface mode.
681684
*/
685+
if (mode == MLO_AN_INBAND && p->interface != state->interface &&
686+
chip->info->ops->port_set_link)
687+
chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
688+
682689
err = mv88e6xxx_port_config_interface(chip, port, state->interface);
683690
if (err && err != -EOPNOTSUPP)
684691
goto err_unlock;
@@ -691,6 +698,15 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
691698
if (err > 0)
692699
err = 0;
693700

701+
/* Undo the forced down state above after completing configuration
702+
* irrespective of its state on entry, which allows the link to come up.
703+
*/
704+
if (mode == MLO_AN_INBAND && p->interface != state->interface &&
705+
chip->info->ops->port_set_link)
706+
chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
707+
708+
p->interface = state->interface;
709+
694710
err_unlock:
695711
mv88e6xxx_reg_unlock(chip);
696712

drivers/net/dsa/mv88e6xxx/chip.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ struct mv88e6xxx_port {
232232
u64 atu_full_violation;
233233
u64 vtu_member_violation;
234234
u64 vtu_miss_violation;
235+
phy_interface_t interface;
235236
u8 cmode;
236237
bool mirror_ingress;
237238
bool mirror_egress;

0 commit comments

Comments
 (0)