From: Russell King <linux@armlinux.org.uk>
Date: Wed, 27 Nov 2019 11:45:20 +0000 (+0000)
Subject: kernel: move phylink patches from mvebu to generic
X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=a07638eb24b8310a35ea6c3b09f6db59bb31cd68;p=openwrt%2Fstaging%2Fblogic.git

kernel: move phylink patches from mvebu to generic

Move two phylink patches from mvebu to generic, so that everyone can
benefit from them.

Signed-off-by: Russell King <linux@armlinux.org.uk>
[jonas.gorski: add kernel version to file names]
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---

diff --git a/target/linux/generic/backport-4.19/700-v5.1-net-phylink-only-call-mac_config-during-resolve-when.patch b/target/linux/generic/backport-4.19/700-v5.1-net-phylink-only-call-mac_config-during-resolve-when.patch
new file mode 100644
index 000000000000..0e272ea891a4
--- /dev/null
+++ b/target/linux/generic/backport-4.19/700-v5.1-net-phylink-only-call-mac_config-during-resolve-when.patch
@@ -0,0 +1,44 @@
+From 6f3ea4e5b1f0867ec217f6101fcb89783ed905d7 Mon Sep 17 00:00:00 2001
+From: Russell King <rmk+kernel@armlinux.org.uk>
+Date: Sat, 9 Feb 2019 18:23:26 +0000
+Subject: [PATCH] net: phylink: only call mac_config() during resolve
+ when link is up
+
+There's little point calling mac_config() when the link is down.
+
+Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
+---
+ drivers/net/phy/phylink.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/phy/phylink.c
++++ b/drivers/net/phy/phylink.c
+@@ -339,6 +339,13 @@ static void phylink_mac_config(struct ph
+ 	pl->ops->mac_config(pl->netdev, pl->link_an_mode, state);
+ }
+ 
++static void phylink_mac_config_up(struct phylink *pl,
++				  const struct phylink_link_state *state)
++{
++	if (state->link)
++		phylink_mac_config(pl, state);
++}
++
+ static void phylink_mac_an_restart(struct phylink *pl)
+ {
+ 	if (pl->link_config.an_enabled &&
+@@ -442,12 +449,12 @@ static void phylink_resolve(struct work_
+ 		case MLO_AN_PHY:
+ 			link_state = pl->phy_state;
+ 			phylink_resolve_flow(pl, &link_state);
+-			phylink_mac_config(pl, &link_state);
++			phylink_mac_config_up(pl, &link_state);
+ 			break;
+ 
+ 		case MLO_AN_FIXED:
+ 			phylink_get_fixed_state(pl, &link_state);
+-			phylink_mac_config(pl, &link_state);
++			phylink_mac_config_up(pl, &link_state);
+ 			break;
+ 
+ 		case MLO_AN_INBAND:
diff --git a/target/linux/generic/backport-4.19/701-v5.2-net-phylink-ensure-inband-AN-works-correctly.patch b/target/linux/generic/backport-4.19/701-v5.2-net-phylink-ensure-inband-AN-works-correctly.patch
new file mode 100644
index 000000000000..746aca2e5ae5
--- /dev/null
+++ b/target/linux/generic/backport-4.19/701-v5.2-net-phylink-ensure-inband-AN-works-correctly.patch
@@ -0,0 +1,59 @@
+From 72f973f292b3eaaf451ebcd3253900d41f4ef24a Mon Sep 17 00:00:00 2001
+From: Russell King <rmk+kernel@armlinux.org.uk>
+Date: Fri, 25 Jan 2019 17:42:51 +0000
+Subject: [PATCH] net: phylink: ensure inband AN works correctly
+
+Do not update the link interface mode while the link is down to avoid
+spurious link interface changes.
+
+Always call mac_config if we have a PHY to propagate the pause mode
+settings to the MAC.
+
+Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
+---
+ drivers/net/phy/phylink.c | 37 +++++++++++++++----------------------
+ 1 file changed, 15 insertions(+), 22 deletions(-)
+
+--- a/drivers/net/phy/phylink.c
++++ b/drivers/net/phy/phylink.c
+@@ -459,28 +459,21 @@ static void phylink_resolve(struct work_
+ 
+ 		case MLO_AN_INBAND:
+ 			phylink_get_mac_state(pl, &link_state);
+-			if (pl->phydev) {
+-				bool changed = false;
+ 
+-				link_state.link = link_state.link &&
+-						  pl->phy_state.link;
++			/* If we have a phy, the "up" state is the union of
++			 * both the PHY and the MAC */
++			if (pl->phydev)
++				link_state.link &= pl->phy_state.link;
+ 
+-				if (pl->phy_state.interface !=
+-				    link_state.interface) {
+-					link_state.interface = pl->phy_state.interface;
+-					changed = true;
+-				}
++			/* Only update if the PHY link is up */
++			if (pl->phydev && pl->phy_state.link) {
++				link_state.interface = pl->phy_state.interface;
+ 
+-				/* Propagate the flow control from the PHY
+-				 * to the MAC. Also propagate the interface
+-				 * if changed.
+-				 */
+-				if (pl->phy_state.link || changed) {
+-					link_state.pause |= pl->phy_state.pause;
+-					phylink_resolve_flow(pl, &link_state);
+-
+-					phylink_mac_config(pl, &link_state);
+-				}
++				/* If we have a PHY, we need to update with
++				 * the pause mode bits. */
++				link_state.pause |= pl->phy_state.pause;
++				phylink_resolve_flow(pl, &link_state);
++				phylink_mac_config(pl, &link_state);
+ 			}
+ 			break;
+ 		}
diff --git a/target/linux/mvebu/patches-4.19/402-net-phylink-only-call-mac_config-during-resolve-when.patch b/target/linux/mvebu/patches-4.19/402-net-phylink-only-call-mac_config-during-resolve-when.patch
deleted file mode 100644
index 0e272ea891a4..000000000000
--- a/target/linux/mvebu/patches-4.19/402-net-phylink-only-call-mac_config-during-resolve-when.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 6f3ea4e5b1f0867ec217f6101fcb89783ed905d7 Mon Sep 17 00:00:00 2001
-From: Russell King <rmk+kernel@armlinux.org.uk>
-Date: Sat, 9 Feb 2019 18:23:26 +0000
-Subject: [PATCH] net: phylink: only call mac_config() during resolve
- when link is up
-
-There's little point calling mac_config() when the link is down.
-
-Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
----
- drivers/net/phy/phylink.c | 11 +++++++++--
- 1 file changed, 9 insertions(+), 2 deletions(-)
-
---- a/drivers/net/phy/phylink.c
-+++ b/drivers/net/phy/phylink.c
-@@ -339,6 +339,13 @@ static void phylink_mac_config(struct ph
- 	pl->ops->mac_config(pl->netdev, pl->link_an_mode, state);
- }
- 
-+static void phylink_mac_config_up(struct phylink *pl,
-+				  const struct phylink_link_state *state)
-+{
-+	if (state->link)
-+		phylink_mac_config(pl, state);
-+}
-+
- static void phylink_mac_an_restart(struct phylink *pl)
- {
- 	if (pl->link_config.an_enabled &&
-@@ -442,12 +449,12 @@ static void phylink_resolve(struct work_
- 		case MLO_AN_PHY:
- 			link_state = pl->phy_state;
- 			phylink_resolve_flow(pl, &link_state);
--			phylink_mac_config(pl, &link_state);
-+			phylink_mac_config_up(pl, &link_state);
- 			break;
- 
- 		case MLO_AN_FIXED:
- 			phylink_get_fixed_state(pl, &link_state);
--			phylink_mac_config(pl, &link_state);
-+			phylink_mac_config_up(pl, &link_state);
- 			break;
- 
- 		case MLO_AN_INBAND:
diff --git a/target/linux/mvebu/patches-4.19/403-net-phylink-ensure-inband-AN-works-correctly.patch b/target/linux/mvebu/patches-4.19/403-net-phylink-ensure-inband-AN-works-correctly.patch
deleted file mode 100644
index 746aca2e5ae5..000000000000
--- a/target/linux/mvebu/patches-4.19/403-net-phylink-ensure-inband-AN-works-correctly.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From 72f973f292b3eaaf451ebcd3253900d41f4ef24a Mon Sep 17 00:00:00 2001
-From: Russell King <rmk+kernel@armlinux.org.uk>
-Date: Fri, 25 Jan 2019 17:42:51 +0000
-Subject: [PATCH] net: phylink: ensure inband AN works correctly
-
-Do not update the link interface mode while the link is down to avoid
-spurious link interface changes.
-
-Always call mac_config if we have a PHY to propagate the pause mode
-settings to the MAC.
-
-Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
----
- drivers/net/phy/phylink.c | 37 +++++++++++++++----------------------
- 1 file changed, 15 insertions(+), 22 deletions(-)
-
---- a/drivers/net/phy/phylink.c
-+++ b/drivers/net/phy/phylink.c
-@@ -459,28 +459,21 @@ static void phylink_resolve(struct work_
- 
- 		case MLO_AN_INBAND:
- 			phylink_get_mac_state(pl, &link_state);
--			if (pl->phydev) {
--				bool changed = false;
- 
--				link_state.link = link_state.link &&
--						  pl->phy_state.link;
-+			/* If we have a phy, the "up" state is the union of
-+			 * both the PHY and the MAC */
-+			if (pl->phydev)
-+				link_state.link &= pl->phy_state.link;
- 
--				if (pl->phy_state.interface !=
--				    link_state.interface) {
--					link_state.interface = pl->phy_state.interface;
--					changed = true;
--				}
-+			/* Only update if the PHY link is up */
-+			if (pl->phydev && pl->phy_state.link) {
-+				link_state.interface = pl->phy_state.interface;
- 
--				/* Propagate the flow control from the PHY
--				 * to the MAC. Also propagate the interface
--				 * if changed.
--				 */
--				if (pl->phy_state.link || changed) {
--					link_state.pause |= pl->phy_state.pause;
--					phylink_resolve_flow(pl, &link_state);
--
--					phylink_mac_config(pl, &link_state);
--				}
-+				/* If we have a PHY, we need to update with
-+				 * the pause mode bits. */
-+				link_state.pause |= pl->phy_state.pause;
-+				phylink_resolve_flow(pl, &link_state);
-+				phylink_mac_config(pl, &link_state);
- 			}
- 			break;
- 		}