diff mbox series

net: dsa: mv88e6xxx: Allow MAC configuration for ports with internal PHY

Message ID 20200622183443.3355240-1-daniel@zonque.org
State New
Headers show
Series net: dsa: mv88e6xxx: Allow MAC configuration for ports with internal PHY | expand

Commit Message

Daniel Mack June 22, 2020, 6:34 p.m. UTC
Ports with internal PHYs that are not in 'fixed-link' mode are currently
only set up once at startup with a static config. Attempts to change the
link speed or duplex settings are currently prevented by an early bail
in mv88e6xxx_mac_config(). As the default config forces the speed to
1000M, setups with reduced link speed on such ports are unsupported.

Change that, and allow the configuration of all ports with the passed
settings.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
Russell,

This changes the behaviour implemented in c9a2356f35409a ("net:
dsa: mv88e6xxx: add PHYLINK support"). Do you recall why your code
didn't touch the MLO_AN_PHY mode links in the first place?

 drivers/net/dsa/mv88e6xxx/chip.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 2f993e673ec74..5452490dbe9d5 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -471,13 +471,6 @@  int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
 	return err;
 }
 
-static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
-{
-	struct mv88e6xxx_chip *chip = ds->priv;
-
-	return port < chip->info->num_internal_phys;
-}
-
 static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
 				       unsigned long *mask,
 				       struct phylink_link_state *state)
@@ -605,23 +598,24 @@  static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
 	struct mv88e6xxx_chip *chip = ds->priv;
 	int speed, duplex, link, pause, err;
 
-	if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
-		return;
+	speed = state->speed;
+	duplex = state->duplex;
+	pause = !!phylink_test(state->advertising, Pause);
 
-	if (mode == MLO_AN_FIXED) {
-		link = LINK_FORCED_UP;
-		speed = state->speed;
-		duplex = state->duplex;
-	} else if (!mv88e6xxx_phy_is_internal(ds, port)) {
+	switch (mode) {
+	case MLO_AN_PHY:
 		link = state->link;
-		speed = state->speed;
-		duplex = state->duplex;
-	} else {
+		break;
+
+	case MLO_AN_FIXED:
+		link = LINK_FORCED_UP;
+		break;
+
+	default:
 		speed = SPEED_UNFORCED;
 		duplex = DUPLEX_UNFORCED;
 		link = LINK_UNFORCED;
 	}
-	pause = !!phylink_test(state->advertising, Pause);
 
 	mv88e6xxx_reg_lock(chip);
 	err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,