netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Vivien Didelot <vivien.didelot@gmail.com>
Subject: [PATCH net-next 05/10] net: dsa: mv88e6xxx: configure interface settings in mac_config
Date: Thu, 05 Mar 2020 12:42:26 +0000	[thread overview]
Message-ID: <E1j9ppa-00072F-H6@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20200305124139.GB25745@shell.armlinux.org.uk>

Only configure the interface settings in mac_config(), leaving the
speed and duplex settings to mac_link_up to deal with.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 67 +++++++++++++++++---------------
 1 file changed, 35 insertions(+), 32 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 483db9d133c3..3b0643654935 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -397,6 +397,28 @@ static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
 	mv88e6xxx_reg_unlock(chip);
 }
 
+static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
+					   int port, phy_interface_t interface)
+{
+	int err;
+
+	if (chip->info->ops->port_set_rgmii_delay) {
+		err = chip->info->ops->port_set_rgmii_delay(chip, port,
+							    interface);
+		if (err && err != -EOPNOTSUPP)
+			return err;
+	}
+
+	if (chip->info->ops->port_set_cmode) {
+		err = chip->info->ops->port_set_cmode(chip, port,
+						      interface);
+		if (err && err != -EOPNOTSUPP)
+			return err;
+	}
+
+	return 0;
+}
+
 int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
 			     int speed, int duplex, int pause,
 			     phy_interface_t mode)
@@ -451,19 +473,7 @@ int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
 			goto restore_link;
 	}
 
-	if (chip->info->ops->port_set_rgmii_delay) {
-		err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
-		if (err && err != -EOPNOTSUPP)
-			goto restore_link;
-	}
-
-	if (chip->info->ops->port_set_cmode) {
-		err = chip->info->ops->port_set_cmode(chip, port, mode);
-		if (err && err != -EOPNOTSUPP)
-			goto restore_link;
-	}
-
-	err = 0;
+	err = mv88e6xxx_port_config_interface(chip, port, mode);
 restore_link:
 	if (chip->info->ops->port_set_link(chip, port, link))
 		dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
@@ -603,33 +613,26 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
 				 const struct phylink_link_state *state)
 {
 	struct mv88e6xxx_chip *chip = ds->priv;
-	int speed, duplex, link, pause, err;
+	int err;
 
+	/* FIXME: is this the correct test? If we're in fixed mode on an
+	 * internal port, why should we process this any different from
+	 * PHY mode? On the other hand, the port may be automedia between
+	 * an internal PHY and the serdes...
+	 */
 	if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
 		return;
 
-	if (mode == MLO_AN_FIXED) {
-		link = LINK_FORCED_UP;
-		speed = state->speed;
-		duplex = state->duplex;
-	} else if (!mv88e6xxx_phy_is_internal(ds, port)) {
-		link = state->link;
-		speed = state->speed;
-		duplex = state->duplex;
-	} else {
-		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,
-				       state->interface);
+	/* FIXME: should we force the link down here - but if we do, how
+	 * do we restore the link force/unforce state? The driver layering
+	 * gets in the way.
+	 */
+	err = mv88e6xxx_port_config_interface(chip, port, state->interface);
 	mv88e6xxx_reg_unlock(chip);
 
 	if (err && err != -EOPNOTSUPP)
-		dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
+		dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
 }
 
 static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
-- 
2.20.1


  parent reply	other threads:[~2020-03-05 12:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 12:41 [PATCH net-next 0/10] net: dsa: improve serdes integration Russell King - ARM Linux admin
2020-03-05 12:42 ` [PATCH net-next 01/10] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant Russell King
2020-03-05 12:42 ` [PATCH net-next 02/10] net: mii: add linkmode_adv_to_mii_adv_x() Russell King
2020-03-05 12:42 ` [PATCH net-next 03/10] net: dsa: warn if phylink_mac_link_state returns error Russell King
2020-03-05 12:42 ` [PATCH net-next 04/10] net: dsa: mv88e6xxx: use BMCR definitions for serdes control register Russell King
2020-03-05 12:42 ` Russell King [this message]
2020-03-05 12:42 ` [PATCH net-next 06/10] net: dsa: mv88e6xxx: extend phylink to Serdes PHYs Russell King
2020-03-05 13:38   ` Marek Behun
2020-03-05 13:43     ` Russell King - ARM Linux admin
2020-03-05 12:42 ` [PATCH net-next 07/10] net: dsa: mv88e6xxx: fix Serdes link changes Russell King
2020-03-05 12:42 ` [PATCH net-next 08/10] net: dsa: mv88e6xxx: combine port_set_speed and port_set_duplex Russell King
2020-03-05 12:42 ` [PATCH net-next 09/10] net: dsa: mv88e6xxx: remove port_link_state functions Russell King
2020-03-05 12:42 ` [PATCH net-next 10/10] net: dsa: mv88e6xxx: use PHY_DETECT in mac_link_up/mac_link_down Russell King
2020-03-05 22:54 ` [PATCH net-next 0/10] net: dsa: improve serdes integration Andrew Lunn
2020-03-05 23:45   ` Russell King - ARM Linux admin
2020-03-06  0:27     ` Andrew Lunn
2020-03-06  1:13     ` Andrew Lunn
2020-03-06  3:57       ` Andrew Lunn
2020-03-06 10:39         ` Russell King - ARM Linux admin
2020-03-06 13:29           ` Andrew Lunn
2020-03-06 13:53           ` Marek Behun
2020-03-06 14:51             ` Andrew Lunn
2020-03-09  5:04 ` David Miller
2020-03-09  9:48   ` Russell King - ARM Linux admin
2020-03-09 12:40     ` Andrew Lunn
2020-03-09 12:50       ` Russell King - ARM Linux admin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1j9ppa-00072F-H6@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).