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: linux-doc@vger•kernel.org,
Thomas Petazzoni <thomas.petazzoni@bootlin•com>,
Ioana Ciornei <ioana.ciornei@nxp•com>,
linux-stm32@st-md-mailman•stormreply.com,
Jonathan Corbet <corbet@lwn•net>,
Michal Simek <michal.simek@xilinx•com>,
Jose Abreu <joabreu@synopsys•com>,
Jakub Kicinski <kuba@kernel•org>,
Mark Lee <Mark-MC.Lee@mediatek•com>,
Sean Wang <sean.wang@mediatek•com>,
Alexandre Torgue <alexandre.torgue@st•com>,
Hauke Mehrtens <hauke@hauke-m•de>,
Radhey Shyam Pandey <radhey.shyam.pandey@xilinx•com>,
linux-mediatek@lists•infradead.org,
John Crispin <john@phrozen•org>,
Matthias Brugger <matthias.bgg@gmail•com>,
Giuseppe Cavallaro <peppe.cavallaro@st•com>,
linux-arm-kernel@lists•infradead.org, netdev@vger•kernel.org,
Vivien Didelot <vivien.didelot@gmail•com>,
Maxime Coquelin <mcoquelin.stm32@gmail•com>,
Vladimir Oltean <olteanv@gmail•com>,
"David S. Miller" <davem@davemloft•net>,
Felix Fietkau <nbd@nbd•name>
Subject: [PATCH net-next v2 3/8] net: mv88e6xxx: use resolved link config in mac_link_up()
Date: Wed, 26 Feb 2020 10:23:51 +0000 [thread overview]
Message-ID: <E1j6tr5-0003GN-JK@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20200226102312.GX25745@shell.armlinux.org.uk>
Use the resolved link configuration to set the MAC configuration when
mac_link_up() for non-internal-PHY ports.
Signed-off-by: Russell King <rmk+kernel@armlinux•org.uk>
---
drivers/net/dsa/mv88e6xxx/chip.c | 75 +++++++++++++++++++++++++-------
1 file changed, 59 insertions(+), 16 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index fef3b5e0b291..4a4173e63fa5 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -632,25 +632,30 @@ static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
}
-static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
+static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
+ unsigned int mode,
+ phy_interface_t interface)
{
struct mv88e6xxx_chip *chip = ds->priv;
- int err;
+ const struct mv88e6xxx_ops *ops;
+ int err = 0;
- mv88e6xxx_reg_lock(chip);
- err = chip->info->ops->port_set_link(chip, port, link);
- mv88e6xxx_reg_unlock(chip);
+ ops = chip->info->ops;
- if (err)
- dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
-}
+ /* Internal PHYs propagate their configuration directly to the MAC.
+ * External PHYs depend on whether the PPU is enabled for this port.
+ * FIXME: we should be using the PPU enable state here. What about
+ * an automedia port?
+ */
+ if (!mv88e6xxx_phy_is_internal(ds, port) && ops->port_set_link) {
+ mv88e6xxx_reg_lock(chip);
+ err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
+ mv88e6xxx_reg_unlock(chip);
-static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
- unsigned int mode,
- phy_interface_t interface)
-{
- if (mode == MLO_AN_FIXED)
- mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
+ if (err)
+ dev_err(chip->dev,
+ "p%d: failed to force MAC link down\n", port);
+ }
}
static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
@@ -659,8 +664,46 @@ static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
int speed, int duplex,
bool tx_pause, bool rx_pause)
{
- if (mode == MLO_AN_FIXED)
- mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
+ struct mv88e6xxx_chip *chip = ds->priv;
+ const struct mv88e6xxx_ops *ops;
+ int err = 0;
+
+ ops = chip->info->ops;
+
+ /* Internal PHYs propagate their configuration directly to the MAC.
+ * External PHYs depend on whether the PPU is enabled for this port.
+ * FIXME: we should be using the PPU enable state here. What about
+ * an automedia port?
+ */
+ if (!mv88e6xxx_phy_is_internal(ds, port)) {
+ mv88e6xxx_reg_lock(chip);
+ /* FIXME: for an automedia port, should we force the link
+ * down here - what if the link comes up due to "other" media
+ * while we're bringing the port up, how is the exclusivity
+ * handled in the Marvell hardware? E.g. port 4 on 88E6532
+ * shared between internal PHY and Serdes.
+ */
+ if (ops->port_set_speed) {
+ err = ops->port_set_speed(chip, port, speed);
+ if (err && err != -EOPNOTSUPP)
+ goto error;
+ }
+
+ if (ops->port_set_duplex) {
+ err = ops->port_set_duplex(chip, port, duplex);
+ if (err && err != -EOPNOTSUPP)
+ goto error;
+ }
+
+ if (ops->port_set_link)
+ err = ops->port_set_link(chip, port, LINK_FORCED_UP);
+error:
+ mv88e6xxx_reg_unlock(chip);
+
+ if (err && err != -EOPNOTSUPP)
+ dev_err(ds->dev,
+ "p%d: failed to configure MAC link up\n", port);
+ }
}
static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-02-26 10:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 10:23 [PATCH net-next v2 0/8] rework phylink interface for split MAC/PCS support Russell King - ARM Linux admin
2020-02-26 10:23 ` [PATCH net-next v2 1/8] net: phylink: propagate resolved link config via mac_link_up() Russell King
2020-02-26 11:06 ` Vladimir Oltean
2020-02-26 11:55 ` Russell King - ARM Linux admin
2020-02-26 13:00 ` Vladimir Oltean
2020-02-26 13:36 ` Russell King - ARM Linux admin
2020-02-26 18:21 ` Vladimir Oltean
2020-02-26 18:22 ` Vladimir Oltean
2020-02-26 18:25 ` Russell King - ARM Linux admin
2020-02-26 18:32 ` Ioana Ciornei
2020-02-26 19:11 ` Russell King - ARM Linux admin
2020-02-26 10:23 ` [PATCH net-next v2 2/8] net: dsa: " Russell King
2020-02-26 10:23 ` Russell King [this message]
2020-02-26 10:23 ` [PATCH net-next v2 4/8] net: axienet: use resolved link config in mac_link_up() Russell King
2020-02-26 10:24 ` [PATCH net-next v2 5/8] net: dpaa2-mac: " Russell King
2020-02-26 10:24 ` [PATCH net-next v2 6/8] net: macb: " Russell King
2020-02-26 10:24 ` [PATCH net-next v2 7/8] net: mvneta: " Russell King
2020-02-26 10:24 ` [PATCH net-next v2 8/8] net: mvpp2: " Russell King
2020-02-27 20:02 ` [PATCH net-next v2 0/8] rework phylink interface for split MAC/PCS support David Miller
2020-02-27 22:13 ` 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=E1j6tr5-0003GN-JK@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux$(echo .)org.uk \
--cc=Mark-MC.Lee@mediatek$(echo .)com \
--cc=alexandre.torgue@st$(echo .)com \
--cc=andrew@lunn$(echo .)ch \
--cc=corbet@lwn$(echo .)net \
--cc=davem@davemloft$(echo .)net \
--cc=f.fainelli@gmail$(echo .)com \
--cc=hauke@hauke-m$(echo .)de \
--cc=hkallweit1@gmail$(echo .)com \
--cc=ioana.ciornei@nxp$(echo .)com \
--cc=joabreu@synopsys$(echo .)com \
--cc=john@phrozen$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-doc@vger$(echo .)kernel.org \
--cc=linux-mediatek@lists$(echo .)infradead.org \
--cc=linux-stm32@st-md-mailman$(echo .)stormreply.com \
--cc=matthias.bgg@gmail$(echo .)com \
--cc=mcoquelin.stm32@gmail$(echo .)com \
--cc=michal.simek@xilinx$(echo .)com \
--cc=nbd@nbd$(echo .)name \
--cc=netdev@vger$(echo .)kernel.org \
--cc=olteanv@gmail$(echo .)com \
--cc=peppe.cavallaro@st$(echo .)com \
--cc=radhey.shyam.pandey@xilinx$(echo .)com \
--cc=sean.wang@mediatek$(echo .)com \
--cc=thomas.petazzoni@bootlin$(echo .)com \
--cc=vivien.didelot@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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