Commit fad58190 authored by Russell King's avatar Russell King Committed by David S. Miller

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: 3be98b2d ("net: dsa: Down cpu/dsa ports phylink will control")
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a463fa2c
...@@ -664,8 +664,11 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, ...@@ -664,8 +664,11 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
const struct phylink_link_state *state) const struct phylink_link_state *state)
{ {
struct mv88e6xxx_chip *chip = ds->priv; struct mv88e6xxx_chip *chip = ds->priv;
struct mv88e6xxx_port *p;
int err; int err;
p = &chip->ports[port];
/* FIXME: is this the correct test? If we're in fixed mode on an /* FIXME: is this the correct test? If we're in fixed mode on an
* internal port, why should we process this any different from * internal port, why should we process this any different from
* PHY mode? On the other hand, the port may be automedia between * 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, ...@@ -675,10 +678,14 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
return; return;
mv88e6xxx_reg_lock(chip); mv88e6xxx_reg_lock(chip);
/* FIXME: should we force the link down here - but if we do, how /* In inband mode, the link may come up at any time while the link
* do we restore the link force/unforce state? The driver layering * is not forced down. Force the link down while we reconfigure the
* gets in the way. * interface mode.
*/ */
if (mode == MLO_AN_INBAND && p->interface != state->interface &&
chip->info->ops->port_set_link)
chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
err = mv88e6xxx_port_config_interface(chip, port, state->interface); err = mv88e6xxx_port_config_interface(chip, port, state->interface);
if (err && err != -EOPNOTSUPP) if (err && err != -EOPNOTSUPP)
goto err_unlock; goto err_unlock;
...@@ -691,6 +698,15 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, ...@@ -691,6 +698,15 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
if (err > 0) if (err > 0)
err = 0; err = 0;
/* Undo the forced down state above after completing configuration
* irrespective of its state on entry, which allows the link to come up.
*/
if (mode == MLO_AN_INBAND && p->interface != state->interface &&
chip->info->ops->port_set_link)
chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
p->interface = state->interface;
err_unlock: err_unlock:
mv88e6xxx_reg_unlock(chip); mv88e6xxx_reg_unlock(chip);
......
...@@ -232,6 +232,7 @@ struct mv88e6xxx_port { ...@@ -232,6 +232,7 @@ struct mv88e6xxx_port {
u64 atu_full_violation; u64 atu_full_violation;
u64 vtu_member_violation; u64 vtu_member_violation;
u64 vtu_miss_violation; u64 vtu_miss_violation;
phy_interface_t interface;
u8 cmode; u8 cmode;
bool mirror_ingress; bool mirror_ingress;
bool mirror_egress; bool mirror_egress;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment