All of lore.kernel.org
 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,
	Ioana Radulescu <ruxandra.radulescu@nxp.com>
Subject: [CFT 5/8] net: dpaa2-mac: use resolved link config in mac_link_up()
Date: Mon, 17 Feb 2020 17:24:16 +0000	[thread overview]
Message-ID: <E1j3k80-00072W-E5@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20200217172242.GZ25745@shell.armlinux.org.uk>

Convert the DPAA2 ethernet driver to use the finalised link parameters
in mac_link_up() rather than the parameters in mac_config(), which are
more suited to the needs of the DPAA2 MC firmware than those available
via mac_config().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 54 +++++++++++--------
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.h  |  1 +
 2 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 3a75c5b58f95..3ee236c5fc37 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -123,35 +123,16 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
 	struct dpmac_link_state *dpmac_state = &mac->state;
 	int err;
 
-	if (state->speed != SPEED_UNKNOWN)
-		dpmac_state->rate = state->speed;
-
-	if (state->duplex != DUPLEX_UNKNOWN) {
-		if (!state->duplex)
-			dpmac_state->options |= DPMAC_LINK_OPT_HALF_DUPLEX;
-		else
-			dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX;
-	}
-
 	if (state->an_enabled)
 		dpmac_state->options |= DPMAC_LINK_OPT_AUTONEG;
 	else
 		dpmac_state->options &= ~DPMAC_LINK_OPT_AUTONEG;
 
-	if (state->pause & MLO_PAUSE_RX)
-		dpmac_state->options |= DPMAC_LINK_OPT_PAUSE;
-	else
-		dpmac_state->options &= ~DPMAC_LINK_OPT_PAUSE;
-
-	if (!!(state->pause & MLO_PAUSE_RX) ^ !!(state->pause & MLO_PAUSE_TX))
-		dpmac_state->options |= DPMAC_LINK_OPT_ASYM_PAUSE;
-	else
-		dpmac_state->options &= ~DPMAC_LINK_OPT_ASYM_PAUSE;
-
 	err = dpmac_set_link_state(mac->mc_io, 0,
 				   mac->mc_dev->mc_handle, dpmac_state);
 	if (err)
-		netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err);
+		netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n",
+			   __func__, err);
 }
 
 static void dpaa2_mac_link_up(struct phylink_config *config,
@@ -165,10 +146,37 @@ static void dpaa2_mac_link_up(struct phylink_config *config,
 	int err;
 
 	dpmac_state->up = 1;
+
+	if (mac->if_link_type == DPMAC_LINK_TYPE_PHY) {
+		/* If the DPMAC is configured for PHY mode, we need
+		 * to pass the link parameters to the MC firmware.
+		 */
+		dpmac_state->rate = speed;
+
+		if (duplex == DUPLEX_HALF)
+			dpmac_state->options |= DPMAC_LINK_OPT_HALF_DUPLEX;
+		else if (duplex == DUPLEX_FULL)
+			dpmac_state->options &= ~DPMAC_LINK_OPT_HALF_DUPLEX;
+
+		/* This is lossy; the firmware really should take the pause
+		 * enablement status rather than pause/asym pause status.
+		 */
+		if (rx_pause)
+			dpmac_state->options |= DPMAC_LINK_OPT_PAUSE;
+		else
+			dpmac_state->options &= ~DPMAC_LINK_OPT_PAUSE;
+
+		if (rx_pause ^ tx_pause)
+			dpmac_state->options |= DPMAC_LINK_OPT_ASYM_PAUSE;
+		else
+			dpmac_state->options &= ~DPMAC_LINK_OPT_ASYM_PAUSE;
+	}
+
 	err = dpmac_set_link_state(mac->mc_io, 0,
 				   mac->mc_dev->mc_handle, dpmac_state);
 	if (err)
-		netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err);
+		netdev_err(mac->net_dev, "%s: dpmac_set_link_state() = %d\n",
+			   __func__, err);
 }
 
 static void dpaa2_mac_link_down(struct phylink_config *config,
@@ -241,6 +249,8 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 		goto err_close_dpmac;
 	}
 
+	mac->if_link_type = attr.link_type;
+
 	dpmac_node = dpaa2_mac_get_node(attr.id);
 	if (!dpmac_node) {
 		netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id);
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
index 4da8079b9155..2130d9c7d40e 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
@@ -20,6 +20,7 @@ struct dpaa2_mac {
 	struct phylink_config phylink_config;
 	struct phylink *phylink;
 	phy_interface_t if_mode;
+	enum dpmac_link_type if_link_type;
 };
 
 bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev,
-- 
2.20.1


  parent reply	other threads:[~2020-02-17 17:25 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 17:22 [CFT 0/8] rework phylink interface for split MAC/PCS support Russell King - ARM Linux admin
2020-02-17 17:22 ` Russell King - ARM Linux admin
2020-02-17 17:22 ` Russell King - ARM Linux admin
2020-02-17 17:23 ` [CFT 1/8] net: phylink: propagate resolved link config via mac_link_up() Russell King
2020-02-17 17:23   ` Russell King
2020-02-17 18:03   ` Matthew Wilcox
2020-02-17 18:03     ` Matthew Wilcox
2020-02-17 18:03     ` Matthew Wilcox
2020-02-17 18:48     ` Russell King - ARM Linux admin
2020-02-17 18:48       ` Russell King - ARM Linux admin
2020-02-17 18:48       ` Russell King - ARM Linux admin
2020-02-17 21:54   ` Florian Fainelli
2020-02-17 21:54     ` Florian Fainelli
2020-02-17 21:54     ` Florian Fainelli
2020-02-18  1:53     ` Russell King - ARM Linux admin
2020-02-18  1:53       ` Russell King - ARM Linux admin
2020-02-18  1:53       ` Russell King - ARM Linux admin
2020-02-17 17:23 ` [CFT 2/8] net: dsa: " Russell King
2020-02-17 17:23   ` Russell King
2020-02-17 17:24 ` [CFT 3/8] net: mv88e6xxx: use resolved link config in mac_link_up() Russell King
2020-02-17 17:24 ` [CFT 4/8] net: axienet: " Russell King
2020-02-20 10:29   ` Russell King - ARM Linux admin
2020-02-20 10:29     ` Russell King - ARM Linux admin
2020-02-24 12:24   ` Andre Przywara
2020-02-24 12:24     ` Andre Przywara
2020-02-24 13:01     ` Russell King - ARM Linux admin
2020-02-24 13:01       ` Russell King - ARM Linux admin
2020-02-17 17:24 ` Russell King [this message]
2020-02-18 10:34   ` [CFT 5/8] net: dpaa2-mac: " Russell King - ARM Linux admin
2020-02-18 10:42     ` Ioana Ciornei
2020-02-20 10:20       ` Russell King - ARM Linux admin
2020-02-17 17:24 ` [CFT 6/8] net: macb: " Russell King
2020-02-19 14:30   ` Alexandre Belloni
2020-02-20 10:18     ` Russell King - ARM Linux admin
2020-02-20 12:38       ` Andrew Lunn
2020-02-20 12:44         ` Russell King - ARM Linux admin
2020-02-21 20:25         ` Russell King - ARM Linux admin
2020-02-24 13:15       ` Russell King - ARM Linux admin
2020-02-24 14:37         ` Alexandre Belloni
2020-02-17 17:24 ` [CFT 7/8] net: mvneta: " Russell King
2020-02-17 17:24 ` [CFT 8/8] net: mvpp2: " Russell King
2020-02-17 17:33 ` [CFT 0/8] rework phylink interface for split MAC/PCS support Andrew Lunn
2020-02-17 17:33   ` Andrew Lunn
2020-02-17 17:33   ` Andrew Lunn
2020-02-17 18:51   ` Russell King - ARM Linux admin
2020-02-17 18:51     ` Russell King - ARM Linux admin
2020-02-17 18:51     ` Russell King - ARM Linux admin
2020-02-18 10:29     ` Russell King - ARM Linux admin
2020-02-18 10:29       ` Russell King - ARM Linux admin
2020-02-18 10:29       ` Russell King - ARM Linux admin
2020-06-21 14:33 ` Russell King - ARM Linux admin
2020-06-21 19:37   ` Vladimir Oltean
2020-06-21 20:02     ` Russell King - ARM Linux admin
2020-06-21 21:17       ` Florian Fainelli

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=E1j3k80-00072W-E5@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=ruxandra.radulescu@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.