From 139acfae24fc4796176650f1effc1064c4b024f1 Mon Sep 17 00:00:00 2001 From: Josef Schlehofer <josef.schlehofer@nic.cz> Date: Tue, 29 Nov 2022 14:25:09 +0100 Subject: [PATCH] patches/openwrt: Turris SFP and HALNy: remove backported patches --- .../0024-Two-more-patches-for-HALNy-SFP.patch | 151 -- ...support-for-HALNy-GPON-SFP-and-other.patch | 619 --------- ...-supported-interfaces-bitmap-to-5.15.patch | 260 ---- ...kport-mvneta-phylink-updates-to-5.15.patch | 1233 ----------------- ...generic-phylink-validation-series-to.patch | 453 +----- ...convert-two-dsa-drivers-to-phylink_g.patch | 341 +---- ...bu-add-support-for-Turris-SFP-module.patch | 258 ++-- 7 files changed, 150 insertions(+), 3165 deletions(-) delete mode 100644 patches/openwrt/a-new-kernel-5.15/0024-Two-more-patches-for-HALNy-SFP.patch delete mode 100644 patches/openwrt/a-new-kernel-5.15/0024-kernel-5.15-Add-support-for-HALNy-GPON-SFP-and-other.patch delete mode 100644 patches/openwrt/wip/0012-TurrisSFP-1-kernel-Backport-supported-interfaces-bitmap-to-5.15.patch delete mode 100644 patches/openwrt/wip/0012-TurrisSFP-2-kernel-Backport-mvneta-phylink-updates-to-5.15.patch diff --git a/patches/openwrt/a-new-kernel-5.15/0024-Two-more-patches-for-HALNy-SFP.patch b/patches/openwrt/a-new-kernel-5.15/0024-Two-more-patches-for-HALNy-SFP.patch deleted file mode 100644 index e2c90eb9a..000000000 --- a/patches/openwrt/a-new-kernel-5.15/0024-Two-more-patches-for-HALNy-SFP.patch +++ /dev/null @@ -1,151 +0,0 @@ -From 7d0a21c7b5bcf752d1b830b4b211c3aaaded644e Mon Sep 17 00:00:00 2001 -From: Josef Schlehofer <pepe.schlehofer@gmail.com> -Date: Thu, 1 Sep 2022 08:26:57 +0200 -Subject: [PATCH] Two more patches for HALNy SFP - ---- - .../115-net-sfp-redo-soft-state-polling.patch | 84 +++++++++++++++++++ - ...change-HALNy-to-ignore-hardware-pins.patch | 40 +++++++++ - 2 files changed, 124 insertions(+) - create mode 100644 target/linux/generic/pending-5.15/115-net-sfp-redo-soft-state-polling.patch - create mode 100644 target/linux/generic/pending-5.15/116-net-sfp-change-HALNy-to-ignore-hardware-pins.patch - -diff --git a/target/linux/generic/pending-5.15/115-net-sfp-redo-soft-state-polling.patch b/target/linux/generic/pending-5.15/115-net-sfp-redo-soft-state-polling.patch -new file mode 100644 -index 0000000000..8b7adeaa10 ---- /dev/null -+++ b/target/linux/generic/pending-5.15/115-net-sfp-redo-soft-state-polling.patch -@@ -0,0 +1,84 @@ -+From f2721c55176d31ff46d06bcfa512b97ada701ef7 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Fri, 26 Aug 2022 08:48:20 +0100 -+Subject: [PATCH 1/2] net: sfp: redo soft state polling -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+--- -+ drivers/net/phy/sfp.c | 35 ++++++++++++++++++++++++----------- -+ 1 file changed, 24 insertions(+), 11 deletions(-) -+ -+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c -+index 277292e2ed35..8db84e0dbc04 100644 -+--- a/drivers/net/phy/sfp.c -++++ b/drivers/net/phy/sfp.c -+@@ -234,6 +234,7 @@ struct sfp { -+ bool need_poll; -+ -+ struct mutex st_mutex; /* Protects state */ -++ unsigned int state_ignore_hw_mask; -+ unsigned int state_soft_mask; -+ unsigned int state; -+ struct delayed_work poll; -+@@ -623,17 +624,18 @@ static void sfp_soft_set_state(struct sfp *sfp, unsigned int state) -+ static void sfp_soft_start_poll(struct sfp *sfp) -+ { -+ const struct sfp_eeprom_id *id = &sfp->id; -++ unsigned int mask = 0; -+ -+ sfp->state_soft_mask = 0; -+- if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_DISABLE && -+- !sfp->gpio[GPIO_TX_DISABLE]) -+- sfp->state_soft_mask |= SFP_F_TX_DISABLE; -+- if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_FAULT && -+- !sfp->gpio[GPIO_TX_FAULT]) -+- sfp->state_soft_mask |= SFP_F_TX_FAULT; -+- if (id->ext.enhopts & SFP_ENHOPTS_SOFT_RX_LOS && -+- !sfp->gpio[GPIO_LOS]) -+- sfp->state_soft_mask |= SFP_F_LOS; -++ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_DISABLE) -++ mask |= SFP_F_TX_DISABLE; -++ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_TX_FAULT) -++ mask |= SFP_F_TX_FAULT; -++ if (id->ext.enhopts & SFP_ENHOPTS_SOFT_RX_LOS) -++ mask |= SFP_F_LOS; -++ -++ // Poll the soft state for hardware pins we want to ignore -++ sfp->state_soft_mask = sfp->state_ignore_hw_mask & mask; -+ -+ if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) && -+ !sfp->need_poll) -+@@ -647,10 +649,12 @@ static void sfp_soft_stop_poll(struct sfp *sfp) -+ -+ static unsigned int sfp_get_state(struct sfp *sfp) -+ { -++ unsigned int soft = sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT); -+ unsigned int state = sfp->get_state(sfp); -+ -+- if (state & SFP_F_PRESENT && -+- sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT)) -++ state &= ~sfp->state_ignore_hw_mask; -++ -++ if (state & SFP_F_PRESENT && soft) -+ state |= sfp_soft_get_state(sfp); -+ -+ return state; -+@@ -2064,6 +2068,15 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) -+ if (ret < 0) -+ return ret; -+ -++ /* Initialise state bits to ignore from hardware */ -++ sfp->state_ignore_hw_mask = 0; -++ if (!sfp->gpio[GPIO_TX_DISABLE]) -++ sfp->state_ignore_hw_mask |= SFP_F_TX_DISABLE; -++ if (!sfp->gpio[GPIO_TX_FAULT]) -++ sfp->state_ignore_hw_mask |= SFP_F_TX_FAULT; -++ if (!sfp->gpio[GPIO_LOS]) -++ sfp->state_ignore_hw_mask |= SFP_F_LOS; -++ -+ sfp->module_t_start_up = T_START_UP; -+ -+ sfp->tx_fault_ignore = false; -+-- -+2.34.1 -+ -diff --git a/target/linux/generic/pending-5.15/116-net-sfp-change-HALNy-to-ignore-hardware-pins.patch b/target/linux/generic/pending-5.15/116-net-sfp-change-HALNy-to-ignore-hardware-pins.patch -new file mode 100644 -index 0000000000..11b3e31656 ---- /dev/null -+++ b/target/linux/generic/pending-5.15/116-net-sfp-change-HALNy-to-ignore-hardware-pins.patch -@@ -0,0 +1,40 @@ -+From 8852f9aa3c1ae0c58a64b8517f11ae62309b84ad Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Fri, 26 Aug 2022 08:48:25 +0100 -+Subject: [PATCH 2/2] net: sfp: change HALNy to ignore hardware pins -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+--- -+ drivers/net/phy/sfp.c | 14 +------------- -+ 1 file changed, 1 insertion(+), 13 deletions(-) -+ -+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c -+index 8db84e0dbc04..1df5d5008ab2 100644 -+--- a/drivers/net/phy/sfp.c -++++ b/drivers/net/phy/sfp.c -+@@ -321,21 +321,9 @@ static void sfp_fixup_ignore_tx_fault(struct sfp *sfp) -+ sfp->tx_fault_ignore = true; -+ } -+ -+-static void sfp_fixup_inverted_los(struct sfp *sfp) -+-{ -+- const __be16 los_inverted = cpu_to_be16(SFP_OPTIONS_LOS_INVERTED); -+- const __be16 los_normal = cpu_to_be16(SFP_OPTIONS_LOS_NORMAL); -+- -+- sfp->id.ext.options &= ~los_normal; -+- sfp->id.ext.options |= los_inverted; -+-} -+- -+ static void sfp_fixup_halny_gsfp(struct sfp *sfp) -+ { -+- /* LOS is inverted */ -+- sfp_fixup_inverted_los(sfp); -+- /* TX fault might be inverted, but we don't know for certain. */ -+- sfp_fixup_ignore_tx_fault(sfp); -++ sfp->state_ignore_hw_mask |= SFP_F_TX_FAULT | SFP_F_LOS; -+ } -+ -+ static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, -+-- -+2.34.1 -+ --- -2.34.1 - diff --git a/patches/openwrt/a-new-kernel-5.15/0024-kernel-5.15-Add-support-for-HALNy-GPON-SFP-and-other.patch b/patches/openwrt/a-new-kernel-5.15/0024-kernel-5.15-Add-support-for-HALNy-GPON-SFP-and-other.patch deleted file mode 100644 index 8e16b61bc..000000000 --- a/patches/openwrt/a-new-kernel-5.15/0024-kernel-5.15-Add-support-for-HALNy-GPON-SFP-and-other.patch +++ /dev/null @@ -1,619 +0,0 @@ -From ff0b52972da8e3049de4066e6d9dab2fbb2d23a6 Mon Sep 17 00:00:00 2001 -From: Josef Schlehofer <pepe.schlehofer@gmail.com> -Date: Fri, 26 Aug 2022 16:21:44 +0200 -Subject: [PATCH] kernel: 5.15: Add support for HALNy-GPON-SFP and other fixes - -It was reported on Turris forum [1] that HALNy-GPON-SFP module does not -work as it should with kernel 5.15. Russel King prepared this patch -series, which should hopefully fix this issue. - -Before sending this to OpenWrt, it needs to tested with Turris Omnia. - -[1] https://forum.turris.cz/t/hbl-turrisos-6-0-alpha2-halny-hl-gsfp-sfp-gpon-stick-problems/17547 ---- - ...t-sfp-move-quirk-handling-into-sfp.c.patch | 299 ++++++++++++++++++ - ...move-Alcatel-Lucent-3FE46541AA-fixup.patch | 75 +++++ - ...12-net-sfp-move-Huawei-MA5671A-fixup.patch | 52 +++ - ...t-sfp-add-support-for-HALNy-GPON-SFP.patch | 93 ++++++ - ...t-sfp-add-support-for-HALNy-GPON-SFP.patch | 42 +++ - 5 files changed, 561 insertions(+) - create mode 100644 target/linux/generic/pending-5.15/110-net-sfp-move-quirk-handling-into-sfp.c.patch - create mode 100644 target/linux/generic/pending-5.15/111-net-sfp-move-Alcatel-Lucent-3FE46541AA-fixup.patch - create mode 100644 target/linux/generic/pending-5.15/112-net-sfp-move-Huawei-MA5671A-fixup.patch - create mode 100644 target/linux/generic/pending-5.15/113-net-sfp-add-support-for-HALNy-GPON-SFP.patch - create mode 100644 target/linux/generic/pending-5.15/114-fixup-net-sfp-add-support-for-HALNy-GPON-SFP.patch - -diff --git a/target/linux/generic/pending-5.15/110-net-sfp-move-quirk-handling-into-sfp.c.patch b/target/linux/generic/pending-5.15/110-net-sfp-move-quirk-handling-into-sfp.c.patch -new file mode 100644 -index 0000000000..fa7480458b ---- /dev/null -+++ b/target/linux/generic/pending-5.15/110-net-sfp-move-quirk-handling-into-sfp.c.patch -@@ -0,0 +1,299 @@ -+From cb3a4e33a0415f84736734e77fb2d6c1a5fab1d7 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Fri, 26 Aug 2022 08:43:30 +0100 -+Subject: [PATCH 1/4] net: sfp: move quirk handling into sfp.c -+ -+We need to handle more quirks than just those which affect the link -+modes of the module. Move the quirk lookup into sfp.c, and pass the -+quirk to sfp-bus.c -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+--- -+ drivers/net/phy/sfp-bus.c | 98 ++------------------------------------- -+ drivers/net/phy/sfp.c | 94 ++++++++++++++++++++++++++++++++++++- -+ drivers/net/phy/sfp.h | 9 +++- -+ 3 files changed, 104 insertions(+), 97 deletions(-) -+ -+diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c -+index 4369d6249e7b..267182d32bd5 100644 -+--- a/drivers/net/phy/sfp-bus.c -++++ b/drivers/net/phy/sfp-bus.c -+@@ -10,12 +10,6 @@ -+ -+ #include "sfp.h" -+ -+-struct sfp_quirk { -+- const char *vendor; -+- const char *part; -+- void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes); -+-}; -+- -+ /** -+ * struct sfp_bus - internal representation of a sfp bus -+ */ -+@@ -38,93 +32,6 @@ struct sfp_bus { -+ bool started; -+ }; -+ -+-static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, -+- unsigned long *modes) -+-{ -+- phylink_set(modes, 2500baseX_Full); -+-} -+- -+-static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id, -+- unsigned long *modes) -+-{ -+- /* Ubiquiti U-Fiber Instant module claims that support all transceiver -+- * types including 10G Ethernet which is not truth. So clear all claimed -+- * modes and set only one mode which module supports: 1000baseX_Full. -+- */ -+- phylink_zero(modes); -+- phylink_set(modes, 1000baseX_Full); -+-} -+- -+-static const struct sfp_quirk sfp_quirks[] = { -+- { -+- // Alcatel Lucent G-010S-P can operate at 2500base-X, but -+- // incorrectly report 2500MBd NRZ in their EEPROM -+- .vendor = "ALCATELLUCENT", -+- .part = "G010SP", -+- .modes = sfp_quirk_2500basex, -+- }, { -+- // Alcatel Lucent G-010S-A can operate at 2500base-X, but -+- // report 3.2GBd NRZ in their EEPROM -+- .vendor = "ALCATELLUCENT", -+- .part = "3FE46541AA", -+- .modes = sfp_quirk_2500basex, -+- }, { -+- // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd -+- // NRZ in their EEPROM -+- .vendor = "HUAWEI", -+- .part = "MA5671A", -+- .modes = sfp_quirk_2500basex, -+- }, { -+- // Lantech 8330-262D-E can operate at 2500base-X, but -+- // incorrectly report 2500MBd NRZ in their EEPROM -+- .vendor = "Lantech", -+- .part = "8330-262D-E", -+- .modes = sfp_quirk_2500basex, -+- }, { -+- .vendor = "UBNT", -+- .part = "UF-INSTANT", -+- .modes = sfp_quirk_ubnt_uf_instant, -+- }, -+-}; -+- -+-static size_t sfp_strlen(const char *str, size_t maxlen) -+-{ -+- size_t size, i; -+- -+- /* Trailing characters should be filled with space chars */ -+- for (i = 0, size = 0; i < maxlen; i++) -+- if (str[i] != ' ') -+- size = i + 1; -+- -+- return size; -+-} -+- -+-static bool sfp_match(const char *qs, const char *str, size_t len) -+-{ -+- if (!qs) -+- return true; -+- if (strlen(qs) != len) -+- return false; -+- return !strncmp(qs, str, len); -+-} -+- -+-static const struct sfp_quirk *sfp_lookup_quirk(const struct sfp_eeprom_id *id) -+-{ -+- const struct sfp_quirk *q; -+- unsigned int i; -+- size_t vs, ps; -+- -+- vs = sfp_strlen(id->base.vendor_name, ARRAY_SIZE(id->base.vendor_name)); -+- ps = sfp_strlen(id->base.vendor_pn, ARRAY_SIZE(id->base.vendor_pn)); -+- -+- for (i = 0, q = sfp_quirks; i < ARRAY_SIZE(sfp_quirks); i++, q++) -+- if (sfp_match(q->vendor, id->base.vendor_name, vs) && -+- sfp_match(q->part, id->base.vendor_pn, ps)) -+- return q; -+- -+- return NULL; -+-} -+- -+ /** -+ * sfp_parse_port() - Parse the EEPROM base ID, setting the port type -+ * @bus: a pointer to the &struct sfp_bus structure for the sfp module -+@@ -786,12 +693,13 @@ void sfp_link_down(struct sfp_bus *bus) -+ } -+ EXPORT_SYMBOL_GPL(sfp_link_down); -+ -+-int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id) -++int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id, -++ const struct sfp_quirk *quirk) -+ { -+ const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); -+ int ret = 0; -+ -+- bus->sfp_quirk = sfp_lookup_quirk(id); -++ bus->sfp_quirk = quirk; -+ -+ if (ops && ops->module_insert) -+ ret = ops->module_insert(bus->upstream, id); -+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c -+index 028a5df5c538..7be9eb47c40f 100644 -+--- a/drivers/net/phy/sfp.c -++++ b/drivers/net/phy/sfp.c -+@@ -252,6 +252,8 @@ struct sfp { -+ unsigned int module_t_start_up; -+ bool tx_fault_ignore; -+ -++ const struct sfp_quirk *quirk; -++ -+ #if IS_ENABLED(CONFIG_HWMON) -+ struct sfp_diag diag; -+ struct delayed_work hwmon_probe; -+@@ -308,6 +310,93 @@ static const struct of_device_id sfp_of_match[] = { -+ }; -+ MODULE_DEVICE_TABLE(of, sfp_of_match); -+ -++static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, -++ unsigned long *modes) -++{ -++ linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, modes); -++} -++ -++static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id, -++ unsigned long *modes) -++{ -++ /* Ubiquiti U-Fiber Instant module claims that support all transceiver -++ * types including 10G Ethernet which is not truth. So clear all claimed -++ * modes and set only one mode which module supports: 1000baseX_Full. -++ */ -++ linkmode_zero(modes); -++ linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, modes); -++} -++ -++static const struct sfp_quirk sfp_quirks[] = { -++ { -++ // Alcatel Lucent G-010S-P can operate at 2500base-X, but -++ // incorrectly report 2500MBd NRZ in their EEPROM -++ .vendor = "ALCATELLUCENT", -++ .part = "G010SP", -++ .modes = sfp_quirk_2500basex, -++ }, { -++ // Alcatel Lucent G-010S-A can operate at 2500base-X, but -++ // report 3.2GBd NRZ in their EEPROM -++ .vendor = "ALCATELLUCENT", -++ .part = "3FE46541AA", -++ .modes = sfp_quirk_2500basex, -++ }, { -++ // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd -++ // NRZ in their EEPROM -++ .vendor = "HUAWEI", -++ .part = "MA5671A", -++ .modes = sfp_quirk_2500basex, -++ }, { -++ // Lantech 8330-262D-E can operate at 2500base-X, but -++ // incorrectly report 2500MBd NRZ in their EEPROM -++ .vendor = "Lantech", -++ .part = "8330-262D-E", -++ .modes = sfp_quirk_2500basex, -++ }, { -++ .vendor = "UBNT", -++ .part = "UF-INSTANT", -++ .modes = sfp_quirk_ubnt_uf_instant, -++ }, -++}; -++ -++static size_t sfp_strlen(const char *str, size_t maxlen) -++{ -++ size_t size, i; -++ -++ /* Trailing characters should be filled with space chars */ -++ for (i = 0, size = 0; i < maxlen; i++) -++ if (str[i] != ' ') -++ size = i + 1; -++ -++ return size; -++} -++ -++static bool sfp_match(const char *qs, const char *str, size_t len) -++{ -++ if (!qs) -++ return true; -++ if (strlen(qs) != len) -++ return false; -++ return !strncmp(qs, str, len); -++} -++ -++static const struct sfp_quirk *sfp_lookup_quirk(const struct sfp_eeprom_id *id) -++{ -++ const struct sfp_quirk *q; -++ unsigned int i; -++ size_t vs, ps; -++ -++ vs = sfp_strlen(id->base.vendor_name, ARRAY_SIZE(id->base.vendor_name)); -++ ps = sfp_strlen(id->base.vendor_pn, ARRAY_SIZE(id->base.vendor_pn)); -++ -++ for (i = 0, q = sfp_quirks; i < ARRAY_SIZE(sfp_quirks); i++, q++) -++ if (sfp_match(q->vendor, id->base.vendor_name, vs) && -++ sfp_match(q->part, id->base.vendor_pn, ps)) -++ return q; -++ -++ return NULL; -++} -++ -+ static unsigned long poll_jiffies; -+ -+ static unsigned int sfp_gpio_get_state(struct sfp *sfp) -+@@ -1952,6 +2041,8 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) -+ else -+ sfp->tx_fault_ignore = false; -+ -++ sfp->quirk = sfp_lookup_quirk(&id); -++ -+ return 0; -+ } -+ -+@@ -2063,7 +2154,8 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event) -+ break; -+ -+ /* Report the module insertion to the upstream device */ -+- err = sfp_module_insert(sfp->sfp_bus, &sfp->id); -++ err = sfp_module_insert(sfp->sfp_bus, &sfp->id, -++ sfp->quirk); -+ if (err < 0) { -+ sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); -+ break; -+diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h -+index 27226535c72b..03f1d47fe6ca 100644 -+--- a/drivers/net/phy/sfp.h -++++ b/drivers/net/phy/sfp.h -+@@ -6,6 +6,12 @@ -+ -+ struct sfp; -+ -++struct sfp_quirk { -++ const char *vendor; -++ const char *part; -++ void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes); -++}; -++ -+ struct sfp_socket_ops { -+ void (*attach)(struct sfp *sfp); -+ void (*detach)(struct sfp *sfp); -+@@ -23,7 +29,8 @@ int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev); -+ void sfp_remove_phy(struct sfp_bus *bus); -+ void sfp_link_up(struct sfp_bus *bus); -+ void sfp_link_down(struct sfp_bus *bus); -+-int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id); -++int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id, -++ const struct sfp_quirk *quirk); -+ void sfp_module_remove(struct sfp_bus *bus); -+ int sfp_module_start(struct sfp_bus *bus); -+ void sfp_module_stop(struct sfp_bus *bus); -+-- -+2.34.1 -+ -diff --git a/target/linux/generic/pending-5.15/111-net-sfp-move-Alcatel-Lucent-3FE46541AA-fixup.patch b/target/linux/generic/pending-5.15/111-net-sfp-move-Alcatel-Lucent-3FE46541AA-fixup.patch -new file mode 100644 -index 0000000000..56716ca2a0 ---- /dev/null -+++ b/target/linux/generic/pending-5.15/111-net-sfp-move-Alcatel-Lucent-3FE46541AA-fixup.patch -@@ -0,0 +1,75 @@ -+From d189313ed65a21a425889664abc5e7c4646a00ba Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Fri, 26 Aug 2022 08:43:35 +0100 -+Subject: [PATCH 2/4] net: sfp: move Alcatel Lucent 3FE46541AA fixup -+ -+Add a new fixup mechanism to the SFP quirks, and use it for this -+module. -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+--- -+ drivers/net/phy/sfp.c | 14 +++++++++----- -+ drivers/net/phy/sfp.h | 1 + -+ 2 files changed, 10 insertions(+), 5 deletions(-) -+ -+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c -+index 7be9eb47c40f..900b10887c3f 100644 -+--- a/drivers/net/phy/sfp.c -++++ b/drivers/net/phy/sfp.c -+@@ -310,6 +310,11 @@ static const struct of_device_id sfp_of_match[] = { -+ }; -+ MODULE_DEVICE_TABLE(of, sfp_of_match); -+ -++static void sfp_fixup_long_startup(struct sfp *sfp) -++{ -++ sfp->module_t_start_up = T_START_UP_BAD_GPON; -++} -++ -+ static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, -+ unsigned long *modes) -+ { -+@@ -340,6 +345,7 @@ static const struct sfp_quirk sfp_quirks[] = { -+ .vendor = "ALCATELLUCENT", -+ .part = "3FE46541AA", -+ .modes = sfp_quirk_2500basex, -++ .fixup = sfp_fixup_long_startup, -+ }, { -+ // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd -+ // NRZ in their EEPROM -+@@ -2029,11 +2035,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) -+ if (ret < 0) -+ return ret; -+ -+- if (!memcmp(id.base.vendor_name, "ALCATELLUCENT ", 16) && -+- !memcmp(id.base.vendor_pn, "3FE46541AA ", 16)) -+- sfp->module_t_start_up = T_START_UP_BAD_GPON; -+- else -+- sfp->module_t_start_up = T_START_UP; -++ sfp->module_t_start_up = T_START_UP; -+ -+ if (!memcmp(id.base.vendor_name, "HUAWEI ", 16) && -+ !memcmp(id.base.vendor_pn, "MA5671A ", 16)) -+@@ -2042,6 +2044,8 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) -+ sfp->tx_fault_ignore = false; -+ -+ sfp->quirk = sfp_lookup_quirk(&id); -++ if (sfp->quirk && sfp->quirk->fixup) -++ sfp->quirk->fixup(sfp); -+ -+ return 0; -+ } -+diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h -+index 03f1d47fe6ca..7ad06deae76c 100644 -+--- a/drivers/net/phy/sfp.h -++++ b/drivers/net/phy/sfp.h -+@@ -10,6 +10,7 @@ struct sfp_quirk { -+ const char *vendor; -+ const char *part; -+ void (*modes)(const struct sfp_eeprom_id *id, unsigned long *modes); -++ void (*fixup)(struct sfp *sfp); -+ }; -+ -+ struct sfp_socket_ops { -+-- -+2.34.1 -+ -diff --git a/target/linux/generic/pending-5.15/112-net-sfp-move-Huawei-MA5671A-fixup.patch b/target/linux/generic/pending-5.15/112-net-sfp-move-Huawei-MA5671A-fixup.patch -new file mode 100644 -index 0000000000..416f3a3a6a ---- /dev/null -+++ b/target/linux/generic/pending-5.15/112-net-sfp-move-Huawei-MA5671A-fixup.patch -@@ -0,0 +1,52 @@ -+From a9e957e4da9f28797663b162e0bdd0147ace7853 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Fri, 26 Aug 2022 08:43:40 +0100 -+Subject: [PATCH 3/4] net: sfp: move Huawei MA5671A fixup -+ -+Move this module over to the new fixup mechanism. -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+--- -+ drivers/net/phy/sfp.c | 12 +++++++----- -+ 1 file changed, 7 insertions(+), 5 deletions(-) -+ -+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c -+index 900b10887c3f..db922d27ee79 100644 -+--- a/drivers/net/phy/sfp.c -++++ b/drivers/net/phy/sfp.c -+@@ -315,6 +315,11 @@ static void sfp_fixup_long_startup(struct sfp *sfp) -+ sfp->module_t_start_up = T_START_UP_BAD_GPON; -+ } -+ -++static void sfp_fixup_ignore_tx_fault(struct sfp *sfp) -++{ -++ sfp->tx_fault_ignore = true; -++} -++ -+ static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, -+ unsigned long *modes) -+ { -+@@ -352,6 +357,7 @@ static const struct sfp_quirk sfp_quirks[] = { -+ .vendor = "HUAWEI", -+ .part = "MA5671A", -+ .modes = sfp_quirk_2500basex, -++ .fixup = sfp_fixup_ignore_tx_fault, -+ }, { -+ // Lantech 8330-262D-E can operate at 2500base-X, but -+ // incorrectly report 2500MBd NRZ in their EEPROM -+@@ -2037,11 +2043,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) -+ -+ sfp->module_t_start_up = T_START_UP; -+ -+- if (!memcmp(id.base.vendor_name, "HUAWEI ", 16) && -+- !memcmp(id.base.vendor_pn, "MA5671A ", 16)) -+- sfp->tx_fault_ignore = true; -+- else -+- sfp->tx_fault_ignore = false; -++ sfp->tx_fault_ignore = false; -+ -+ sfp->quirk = sfp_lookup_quirk(&id); -+ if (sfp->quirk && sfp->quirk->fixup) -+-- -+2.34.1 -+ -diff --git a/target/linux/generic/pending-5.15/113-net-sfp-add-support-for-HALNy-GPON-SFP.patch b/target/linux/generic/pending-5.15/113-net-sfp-add-support-for-HALNy-GPON-SFP.patch -new file mode 100644 -index 0000000000..e66bcb7748 ---- /dev/null -+++ b/target/linux/generic/pending-5.15/113-net-sfp-add-support-for-HALNy-GPON-SFP.patch -@@ -0,0 +1,93 @@ -+From 9490075c53cec3925039d2b1c5afc4507e772660 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Fri, 26 Aug 2022 08:43:45 +0100 -+Subject: [PATCH 4/4] net: sfp: add support for HALNy GPON SFP -+ -+Add a quirk for the HALNy HL-GSFP module, which appears to have an -+inverted RX_LOS signal, and possibly uses TX_FAULT as an inverted -+host-link status signal. As we can't be certain about the modules -+use of TX_FAULT, we ignore it. -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+--- -+ drivers/net/phy/sfp-bus.c | 2 +- -+ drivers/net/phy/sfp.c | 29 ++++++++++++++++++++++++++--- -+ 2 files changed, 27 insertions(+), 4 deletions(-) -+ -+diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c -+index 267182d32bd5..4566348a6d05 100644 -+--- a/drivers/net/phy/sfp-bus.c -++++ b/drivers/net/phy/sfp-bus.c -+@@ -283,7 +283,7 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, -+ phylink_set(modes, 2500baseX_Full); -+ } -+ -+- if (bus->sfp_quirk) -++ if (bus->sfp_quirk && bus->sfp_quirk->modes) -+ bus->sfp_quirk->modes(id, modes); -+ -+ bitmap_or(support, support, modes, __ETHTOOL_LINK_MODE_MASK_NBITS); -+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c -+index db922d27ee79..2ebc577bfc56 100644 -+--- a/drivers/net/phy/sfp.c -++++ b/drivers/net/phy/sfp.c -+@@ -320,6 +320,23 @@ static void sfp_fixup_ignore_tx_fault(struct sfp *sfp) -+ sfp->tx_fault_ignore = true; -+ } -+ -++static void sfp_fixup_inverted_los(struct sfp *sfp) -++{ -++ const __be16 los_inverted = cpu_to_be16(SFP_OPTIONS_LOS_INVERTED); -++ const __be16 los_normal = cpu_to_be16(SFP_OPTIONS_LOS_NORMAL); -++ -++ sfp->id.ext.options &= ~los_normal; -++ sfp->id.ext.options |= los_inverted; -++} -++ -++static void sfp_fixup_hanly_gsfp(struct sfp *sfp) -++{ -++ /* LOS is inverted */ -++ sfp_fixup_inverted_los(sfp); -++ /* TX fault might be inverted, but we don't know for certain. */ -++ sfp_fixup_ignore_tx_fault(sfp); -++} -++ -+ static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, -+ unsigned long *modes) -+ { -+@@ -351,6 +368,10 @@ static const struct sfp_quirk sfp_quirks[] = { -+ .part = "3FE46541AA", -+ .modes = sfp_quirk_2500basex, -+ .fixup = sfp_fixup_long_startup, -++ }, { -++ .vendor = "HANLy", -++ .part = "HL-GSFP", -++ .fixup = sfp_fixup_hanly_gsfp, -+ }, { -+ // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd -+ // NRZ in their EEPROM -+@@ -368,16 +389,18 @@ static const struct sfp_quirk sfp_quirks[] = { -+ .vendor = "UBNT", -+ .part = "UF-INSTANT", -+ .modes = sfp_quirk_ubnt_uf_instant, -+- }, -++ } -+ }; -+ -+ static size_t sfp_strlen(const char *str, size_t maxlen) -+ { -+ size_t size, i; -+ -+- /* Trailing characters should be filled with space chars */ -++ /* Trailing characters should be filled with space chars, but -++ * some manufacturers can't read SFF-8472 and use NUL. -++ */ -+ for (i = 0, size = 0; i < maxlen; i++) -+- if (str[i] != ' ') -++ if (str[i] != ' ' && str[i] != '\0') -+ size = i + 1; -+ -+ return size; -+-- -+2.34.1 -+ -diff --git a/target/linux/generic/pending-5.15/114-fixup-net-sfp-add-support-for-HALNy-GPON-SFP.patch b/target/linux/generic/pending-5.15/114-fixup-net-sfp-add-support-for-HALNy-GPON-SFP.patch -new file mode 100644 -index 0000000000..99ca247366 ---- /dev/null -+++ b/target/linux/generic/pending-5.15/114-fixup-net-sfp-add-support-for-HALNy-GPON-SFP.patch -@@ -0,0 +1,42 @@ -+From 6dc810804bb2fa91d9972601c209471fab852509 Mon Sep 17 00:00:00 2001 -+From: Josef Schlehofer <pepe.schlehofer@gmail.com> -+Date: Fri, 26 Aug 2022 20:50:51 +0200 -+Subject: [PATCH] fixup! net: sfp: add support for HALNy GPON SFP -+ -+There are a few typos, which was reported by Orest Worhacz -+(@AreYouLoco), which needs to be fixed. -+ -+SFP is detected as -+[ 9.607535] sfp sfp: module HALNy HL-GSFP rev V1.0 sn HALN1010493c dc 20150525 -+--- -+ drivers/net/phy/sfp.c | 6 +++--- -+ 1 file changed, 3 insertions(+), 3 deletions(-) -+ -+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c -+index 2ebc577bfc56..277292e2ed35 100644 -+--- a/drivers/net/phy/sfp.c -++++ b/drivers/net/phy/sfp.c -+@@ -329,7 +329,7 @@ static void sfp_fixup_inverted_los(struct sfp *sfp) -+ sfp->id.ext.options |= los_inverted; -+ } -+ -+-static void sfp_fixup_hanly_gsfp(struct sfp *sfp) -++static void sfp_fixup_halny_gsfp(struct sfp *sfp) -+ { -+ /* LOS is inverted */ -+ sfp_fixup_inverted_los(sfp); -+@@ -369,9 +369,9 @@ static const struct sfp_quirk sfp_quirks[] = { -+ .modes = sfp_quirk_2500basex, -+ .fixup = sfp_fixup_long_startup, -+ }, { -+- .vendor = "HANLy", -++ .vendor = "HALNy", -+ .part = "HL-GSFP", -+- .fixup = sfp_fixup_hanly_gsfp, -++ .fixup = sfp_fixup_halny_gsfp, -+ }, { -+ // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd -+ // NRZ in their EEPROM -+-- -+2.34.1 -+ --- -2.34.1 - diff --git a/patches/openwrt/wip/0012-TurrisSFP-1-kernel-Backport-supported-interfaces-bitmap-to-5.15.patch b/patches/openwrt/wip/0012-TurrisSFP-1-kernel-Backport-supported-interfaces-bitmap-to-5.15.patch deleted file mode 100644 index 3849ddbd2..000000000 --- a/patches/openwrt/wip/0012-TurrisSFP-1-kernel-Backport-supported-interfaces-bitmap-to-5.15.patch +++ /dev/null @@ -1,260 +0,0 @@ -From d9c01f5a6f1d775199be90f634f69974d36f2d63 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <marek.behun@nic.cz> -Date: Fri, 23 Sep 2022 11:52:35 +0200 -Subject: [PATCH 1/9] kernel: Backport supported interfaces bitmap to 5.15 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This backports Russell King's series phy-supported-interfaces-bitmap: - 8e20f591f204 ("net: phy: add phy_interface_t bitmap support") - 38c310eb46f5 ("net: phylink: add MAC phy_interface_t bitmap") - d25f3a74f30a ("net: phylink: use supported_interfaces for phylink validation") - -The original cover letter said: - Introduce supported interfaces bitmap - - This series introduces a new bitmap to allow us to indicate which - phy_interface_t modes are supported. - - Currently, phylink will call ->validate with PHY_INTERFACE_MODE_NA to - request all link mode capabilities from the MAC driver before choosing - an interface to use. This leads in some cases to some rather hairly - code. This can be simplified if phylink is aware of the interface modes - that the MAC supports, and it can instead walk those modes, calling - ->validate for each one, and combining the results. - - This series merely introduces the support; there is no change of - behaviour until MAC drivers populate their supported_interfaces bitmap. - -Signed-off-by: Marek BehĂşn <marek.behun@nic.cz> ---- - ...y-add-phy_interface_t-bitmap-support.patch | 66 +++++++++++ - ...ylink-add-MAC-phy_interface_t-bitmap.patch | 29 +++++ - ...supported_interfaces-for-phylink-val.patch | 105 ++++++++++++++++++ - 3 files changed, 200 insertions(+) - create mode 100644 target/linux/generic/backport-5.15/775-v5.16-1-net-phy-add-phy_interface_t-bitmap-support.patch - create mode 100644 target/linux/generic/backport-5.15/775-v5.16-2-net-phylink-add-MAC-phy_interface_t-bitmap.patch - create mode 100644 target/linux/generic/backport-5.15/775-v5.16-3-net-phylink-use-supported_interfaces-for-phylink-val.patch - -diff --git a/target/linux/generic/backport-5.15/775-v5.16-1-net-phy-add-phy_interface_t-bitmap-support.patch b/target/linux/generic/backport-5.15/775-v5.16-1-net-phy-add-phy_interface_t-bitmap-support.patch -new file mode 100644 -index 0000000000..69f6a5d48a ---- /dev/null -+++ b/target/linux/generic/backport-5.15/775-v5.16-1-net-phy-add-phy_interface_t-bitmap-support.patch -@@ -0,0 +1,66 @@ -+From 8e20f591f204f8db7f1182918f8e2285d3f589e0 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Tue, 26 Oct 2021 11:06:01 +0100 -+Subject: [PATCH 1/3] net: phy: add phy_interface_t bitmap support -+ -+Add support for a bitmap for phy interface modes, which includes: -+- a macro to declare the interface bitmap -+- an inline helper to zero the interface bitmap -+- an inline helper to detect an empty interface bitmap -+- inline helpers to do a bitwise AND and OR operations on two interface -+ bitmaps -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ include/linux/phy.h | 34 ++++++++++++++++++++++++++++++++++ -+ 1 file changed, 34 insertions(+) -+ -+diff --git a/include/linux/phy.h b/include/linux/phy.h -+index 04e90423fa88..96e43fbb2dd8 100644 -+--- a/include/linux/phy.h -++++ b/include/linux/phy.h -+@@ -155,6 +155,40 @@ typedef enum { -+ PHY_INTERFACE_MODE_MAX, -+ } phy_interface_t; -+ -++/* PHY interface mode bitmap handling */ -++#define DECLARE_PHY_INTERFACE_MASK(name) \ -++ DECLARE_BITMAP(name, PHY_INTERFACE_MODE_MAX) -++ -++static inline void phy_interface_zero(unsigned long *intf) -++{ -++ bitmap_zero(intf, PHY_INTERFACE_MODE_MAX); -++} -++ -++static inline bool phy_interface_empty(const unsigned long *intf) -++{ -++ return bitmap_empty(intf, PHY_INTERFACE_MODE_MAX); -++} -++ -++static inline void phy_interface_and(unsigned long *dst, const unsigned long *a, -++ const unsigned long *b) -++{ -++ bitmap_and(dst, a, b, PHY_INTERFACE_MODE_MAX); -++} -++ -++static inline void phy_interface_or(unsigned long *dst, const unsigned long *a, -++ const unsigned long *b) -++{ -++ bitmap_or(dst, a, b, PHY_INTERFACE_MODE_MAX); -++} -++ -++static inline void phy_interface_set_rgmii(unsigned long *intf) -++{ -++ __set_bit(PHY_INTERFACE_MODE_RGMII, intf); -++ __set_bit(PHY_INTERFACE_MODE_RGMII_ID, intf); -++ __set_bit(PHY_INTERFACE_MODE_RGMII_RXID, intf); -++ __set_bit(PHY_INTERFACE_MODE_RGMII_TXID, intf); -++} -++ -+ /* -+ * phy_supported_speeds - return all speeds currently supported by a PHY device -+ */ -+-- -+2.35.1 -+ -diff --git a/target/linux/generic/backport-5.15/775-v5.16-2-net-phylink-add-MAC-phy_interface_t-bitmap.patch b/target/linux/generic/backport-5.15/775-v5.16-2-net-phylink-add-MAC-phy_interface_t-bitmap.patch -new file mode 100644 -index 0000000000..2141a3c609 ---- /dev/null -+++ b/target/linux/generic/backport-5.15/775-v5.16-2-net-phylink-add-MAC-phy_interface_t-bitmap.patch -@@ -0,0 +1,29 @@ -+From 38c310eb46f5f80213a92093af11af270c209a76 Mon Sep 17 00:00:00 2001 -+From: Russell King <rmk+kernel@armlinux.org.uk> -+Date: Tue, 26 Oct 2021 11:06:06 +0100 -+Subject: [PATCH 2/3] net: phylink: add MAC phy_interface_t bitmap -+ -+Add a phy_interface_t bitmap so the MAC driver can specifiy which PHY -+interface modes it supports. -+ -+Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ include/linux/phylink.h | 1 + -+ 1 file changed, 1 insertion(+) -+ -+diff --git a/include/linux/phylink.h b/include/linux/phylink.h -+index f7b5ed06a815..bc4b866cd99b 100644 -+--- a/include/linux/phylink.h -++++ b/include/linux/phylink.h -+@@ -76,6 +76,7 @@ struct phylink_config { -+ bool ovr_an_inband; -+ void (*get_fixed_state)(struct phylink_config *config, -+ struct phylink_link_state *state); -++ DECLARE_PHY_INTERFACE_MASK(supported_interfaces); -+ }; -+ -+ /** -+-- -+2.35.1 -+ -diff --git a/target/linux/generic/backport-5.15/775-v5.16-3-net-phylink-use-supported_interfaces-for-phylink-val.patch b/target/linux/generic/backport-5.15/775-v5.16-3-net-phylink-use-supported_interfaces-for-phylink-val.patch -new file mode 100644 -index 0000000000..fad5044571 ---- /dev/null -+++ b/target/linux/generic/backport-5.15/775-v5.16-3-net-phylink-use-supported_interfaces-for-phylink-val.patch -@@ -0,0 +1,105 @@ -+From d25f3a74f30aace819163dfa54f2a4b8ca1dc932 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Tue, 26 Oct 2021 11:06:11 +0100 -+Subject: [PATCH 3/3] net: phylink: use supported_interfaces for phylink -+ validation -+ -+If the network device supplies a supported interface bitmap, we can use -+that during phylink's validation to simplify MAC drivers in two ways by -+using the supported_interfaces bitmap to: -+ -+1. reject unsupported interfaces before calling into the MAC driver. -+2. generate the set of all supported link modes across all supported -+ interfaces (used mainly for SFP, but also some 10G PHYs.) -+ -+Suggested-by: Sean Anderson <sean.anderson@seco.com> -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ drivers/net/phy/phylink.c | 36 ++++++++++++++++++++++++++++++++++++ -+ include/linux/phylink.h | 12 ++++++++++-- -+ 2 files changed, 46 insertions(+), 2 deletions(-) -+ -+diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c -+index 14c7d73790b4..6da245dacca4 100644 -+--- a/drivers/net/phy/phylink.c -++++ b/drivers/net/phy/phylink.c -+@@ -155,9 +155,45 @@ static const char *phylink_an_mode_str(unsigned int mode) -+ return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; -+ } -+ -++static int phylink_validate_any(struct phylink *pl, unsigned long *supported, -++ struct phylink_link_state *state) -++{ -++ __ETHTOOL_DECLARE_LINK_MODE_MASK(all_adv) = { 0, }; -++ __ETHTOOL_DECLARE_LINK_MODE_MASK(all_s) = { 0, }; -++ __ETHTOOL_DECLARE_LINK_MODE_MASK(s); -++ struct phylink_link_state t; -++ int intf; -++ -++ for (intf = 0; intf < PHY_INTERFACE_MODE_MAX; intf++) { -++ if (test_bit(intf, pl->config->supported_interfaces)) { -++ linkmode_copy(s, supported); -++ -++ t = *state; -++ t.interface = intf; -++ pl->mac_ops->validate(pl->config, s, &t); -++ linkmode_or(all_s, all_s, s); -++ linkmode_or(all_adv, all_adv, t.advertising); -++ } -++ } -++ -++ linkmode_copy(supported, all_s); -++ linkmode_copy(state->advertising, all_adv); -++ -++ return phylink_is_empty_linkmode(supported) ? -EINVAL : 0; -++} -++ -+ static int phylink_validate(struct phylink *pl, unsigned long *supported, -+ struct phylink_link_state *state) -+ { -++ if (!phy_interface_empty(pl->config->supported_interfaces)) { -++ if (state->interface == PHY_INTERFACE_MODE_NA) -++ return phylink_validate_any(pl, supported, state); -++ -++ if (!test_bit(state->interface, -++ pl->config->supported_interfaces)) -++ return -EINVAL; -++ } -++ -+ pl->mac_ops->validate(pl->config, supported, state); -+ -+ return phylink_is_empty_linkmode(supported) ? -EINVAL : 0; -+diff --git a/include/linux/phylink.h b/include/linux/phylink.h -+index bc4b866cd99b..f037470b6fb3 100644 -+--- a/include/linux/phylink.h -++++ b/include/linux/phylink.h -+@@ -67,6 +67,8 @@ enum phylink_op_type { -+ * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND -+ * @get_fixed_state: callback to execute to determine the fixed link state, -+ * if MAC link is at %MLO_AN_FIXED mode. -++ * @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx -++ * are supported by the MAC/PCS. -+ */ -+ struct phylink_config { -+ struct device *dev; -+@@ -134,8 +136,14 @@ struct phylink_mac_ops { -+ * based on @state->advertising and/or @state->speed and update -+ * @state->interface accordingly. See phylink_helper_basex_speed(). -+ * -+- * When @state->interface is %PHY_INTERFACE_MODE_NA, phylink expects the -+- * MAC driver to return all supported link modes. -++ * When @config->supported_interfaces has been set, phylink will iterate -++ * over the supported interfaces to determine the full capability of the -++ * MAC. The validation function must not print errors if @state->interface -++ * is set to an unexpected value. -++ * -++ * When @config->supported_interfaces is empty, phylink will call this -++ * function with @state->interface set to %PHY_INTERFACE_MODE_NA, and -++ * expects the MAC driver to return all supported link modes. -+ * -+ * If the @state->interface mode is not supported, then the @supported -+ * mask must be cleared. -+-- -+2.35.1 -+ --- -2.35.1 - diff --git a/patches/openwrt/wip/0012-TurrisSFP-2-kernel-Backport-mvneta-phylink-updates-to-5.15.patch b/patches/openwrt/wip/0012-TurrisSFP-2-kernel-Backport-mvneta-phylink-updates-to-5.15.patch deleted file mode 100644 index 2a1abd5b6..000000000 --- a/patches/openwrt/wip/0012-TurrisSFP-2-kernel-Backport-mvneta-phylink-updates-to-5.15.patch +++ /dev/null @@ -1,1233 +0,0 @@ -From 30dce46ace422111d513009f6511c817adad4ae2 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <marek.behun@nic.cz> -Date: Fri, 23 Sep 2022 12:00:13 +0200 -Subject: [PATCH 2/9] kernel: Backport mvneta-phylink updates to 5.15 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This backports Russell King's patch series mvneta-phylink from 5.16 - fdedb695e6a8 ("net: mvneta: populate supported_interfaces member") - d9ca72807ecb ("net: mvneta: remove interface checks in mvneta_validate()") - 099cbfa286ab ("net: mvneta: drop use of phylink_helper_basex_speed()") -and also it's dependency by Sean Anderson - 4973056cceac ("net: convert users of bitmap_foo() to linkmode_foo()") - -The original cover letter said: - Convert mvneta to phylink supported_interfaces - - This patch series converts mvneta to use phylinks supported_interfaces - bitmap to simplify the validate() implementation. The patches: - - 1) Add the supported interface modes the supported_interfaces bitmap. - 2) Removes the checks for the interface type being supported from - the validate callback - 3) Removes the now unnecessary checks and call to - phylink_helper_basex_speed() to support switching between - 1000base-X and 2500base-X for SFPs - - (3) becomes possible because when asking the MAC for its complete - support, we walk all supported interfaces which will include 1000base-X - and 2500base-X only if the comphy is present. - -Signed-off-by: Marek BehĂşn <marek.behun@nic.cz> ---- - ...-users-of-bitmap_foo-to-linkmode_foo.patch | 1009 +++++++++++++++++ - ...populate-supported_interfaces-member.patch | 53 + - ...e-interface-checks-in-mvneta_validat.patch | 40 + - ...op-use-of-phylink_helper_basex_speed.patch | 60 + - 4 files changed, 1162 insertions(+) - create mode 100644 target/linux/generic/backport-5.15/776-v5.16-1-net-convert-users-of-bitmap_foo-to-linkmode_foo.patch - create mode 100644 target/linux/generic/backport-5.15/776-v5.16-2-net-mvneta-populate-supported_interfaces-member.patch - create mode 100644 target/linux/generic/backport-5.15/776-v5.16-3-net-mvneta-remove-interface-checks-in-mvneta_validat.patch - create mode 100644 target/linux/generic/backport-5.15/776-v5.16-4-net-mvneta-drop-use-of-phylink_helper_basex_speed.patch - -diff --git a/target/linux/generic/backport-5.15/776-v5.16-1-net-convert-users-of-bitmap_foo-to-linkmode_foo.patch b/target/linux/generic/backport-5.15/776-v5.16-1-net-convert-users-of-bitmap_foo-to-linkmode_foo.patch -new file mode 100644 -index 0000000000..23d6f893a5 ---- /dev/null -+++ b/target/linux/generic/backport-5.15/776-v5.16-1-net-convert-users-of-bitmap_foo-to-linkmode_foo.patch -@@ -0,0 +1,1009 @@ -+From 1cd141887a4d4576e6cbfebf8b1445b2be768900 Mon Sep 17 00:00:00 2001 -+From: Sean Anderson <sean.anderson@seco.com> -+Date: Fri, 22 Oct 2021 18:41:04 -0400 -+Subject: [PATCH 1/4] net: convert users of bitmap_foo() to linkmode_foo() -+ -+This converts instances of -+ bitmap_foo(args..., __ETHTOOL_LINK_MODE_MASK_NBITS) -+to -+ linkmode_foo(args...) -+ -+I manually fixed up some lines to prevent them from being excessively -+long. Otherwise, this change was generated with the following semantic -+patch: -+ -+// Generated with -+// echo linux/linkmode.h > includes -+// git grep -Flf includes include/ | cut -f 2- -d / | cat includes - \ -+// | sort | uniq | tee new_includes | wc -l && mv new_includes includes -+// and repeating until the number stopped going up -+@i@ -+@@ -+ -+( -+ #include <linux/acpi_mdio.h> -+| -+ #include <linux/brcmphy.h> -+| -+ #include <linux/dsa/loop.h> -+| -+ #include <linux/dsa/sja1105.h> -+| -+ #include <linux/ethtool.h> -+| -+ #include <linux/ethtool_netlink.h> -+| -+ #include <linux/fec.h> -+| -+ #include <linux/fs_enet_pd.h> -+| -+ #include <linux/fsl/enetc_mdio.h> -+| -+ #include <linux/fwnode_mdio.h> -+| -+ #include <linux/linkmode.h> -+| -+ #include <linux/lsm_audit.h> -+| -+ #include <linux/mdio-bitbang.h> -+| -+ #include <linux/mdio.h> -+| -+ #include <linux/mdio-mux.h> -+| -+ #include <linux/mii.h> -+| -+ #include <linux/mii_timestamper.h> -+| -+ #include <linux/mlx5/accel.h> -+| -+ #include <linux/mlx5/cq.h> -+| -+ #include <linux/mlx5/device.h> -+| -+ #include <linux/mlx5/driver.h> -+| -+ #include <linux/mlx5/eswitch.h> -+| -+ #include <linux/mlx5/fs.h> -+| -+ #include <linux/mlx5/port.h> -+| -+ #include <linux/mlx5/qp.h> -+| -+ #include <linux/mlx5/rsc_dump.h> -+| -+ #include <linux/mlx5/transobj.h> -+| -+ #include <linux/mlx5/vport.h> -+| -+ #include <linux/of_mdio.h> -+| -+ #include <linux/of_net.h> -+| -+ #include <linux/pcs-lynx.h> -+| -+ #include <linux/pcs/pcs-xpcs.h> -+| -+ #include <linux/phy.h> -+| -+ #include <linux/phy_led_triggers.h> -+| -+ #include <linux/phylink.h> -+| -+ #include <linux/platform_data/bcmgenet.h> -+| -+ #include <linux/platform_data/xilinx-ll-temac.h> -+| -+ #include <linux/pxa168_eth.h> -+| -+ #include <linux/qed/qed_eth_if.h> -+| -+ #include <linux/qed/qed_fcoe_if.h> -+| -+ #include <linux/qed/qed_if.h> -+| -+ #include <linux/qed/qed_iov_if.h> -+| -+ #include <linux/qed/qed_iscsi_if.h> -+| -+ #include <linux/qed/qed_ll2_if.h> -+| -+ #include <linux/qed/qed_nvmetcp_if.h> -+| -+ #include <linux/qed/qed_rdma_if.h> -+| -+ #include <linux/sfp.h> -+| -+ #include <linux/sh_eth.h> -+| -+ #include <linux/smsc911x.h> -+| -+ #include <linux/soc/nxp/lpc32xx-misc.h> -+| -+ #include <linux/stmmac.h> -+| -+ #include <linux/sunrpc/svc_rdma.h> -+| -+ #include <linux/sxgbe_platform.h> -+| -+ #include <net/cfg80211.h> -+| -+ #include <net/dsa.h> -+| -+ #include <net/mac80211.h> -+| -+ #include <net/selftests.h> -+| -+ #include <rdma/ib_addr.h> -+| -+ #include <rdma/ib_cache.h> -+| -+ #include <rdma/ib_cm.h> -+| -+ #include <rdma/ib_hdrs.h> -+| -+ #include <rdma/ib_mad.h> -+| -+ #include <rdma/ib_marshall.h> -+| -+ #include <rdma/ib_pack.h> -+| -+ #include <rdma/ib_pma.h> -+| -+ #include <rdma/ib_sa.h> -+| -+ #include <rdma/ib_smi.h> -+| -+ #include <rdma/ib_umem.h> -+| -+ #include <rdma/ib_umem_odp.h> -+| -+ #include <rdma/ib_verbs.h> -+| -+ #include <rdma/iw_cm.h> -+| -+ #include <rdma/mr_pool.h> -+| -+ #include <rdma/opa_addr.h> -+| -+ #include <rdma/opa_port_info.h> -+| -+ #include <rdma/opa_smi.h> -+| -+ #include <rdma/opa_vnic.h> -+| -+ #include <rdma/rdma_cm.h> -+| -+ #include <rdma/rdma_cm_ib.h> -+| -+ #include <rdma/rdmavt_cq.h> -+| -+ #include <rdma/rdma_vt.h> -+| -+ #include <rdma/rdmavt_qp.h> -+| -+ #include <rdma/rw.h> -+| -+ #include <rdma/tid_rdma_defs.h> -+| -+ #include <rdma/uverbs_ioctl.h> -+| -+ #include <rdma/uverbs_named_ioctl.h> -+| -+ #include <rdma/uverbs_std_types.h> -+| -+ #include <rdma/uverbs_types.h> -+| -+ #include <soc/mscc/ocelot.h> -+| -+ #include <soc/mscc/ocelot_ptp.h> -+| -+ #include <soc/mscc/ocelot_vcap.h> -+| -+ #include <trace/events/ib_mad.h> -+| -+ #include <trace/events/rdma_core.h> -+| -+ #include <trace/events/rdma.h> -+| -+ #include <trace/events/rpcrdma.h> -+| -+ #include <uapi/linux/ethtool.h> -+| -+ #include <uapi/linux/ethtool_netlink.h> -+| -+ #include <uapi/linux/mdio.h> -+| -+ #include <uapi/linux/mii.h> -+) -+ -+@depends on i@ -+expression list args; -+@@ -+ -+( -+- bitmap_zero(args, __ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_zero(args) -+| -+- bitmap_copy(args, __ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_copy(args) -+| -+- bitmap_and(args, __ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_and(args) -+| -+- bitmap_or(args, __ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_or(args) -+| -+- bitmap_empty(args, ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_empty(args) -+| -+- bitmap_andnot(args, __ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_andnot(args) -+| -+- bitmap_equal(args, __ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_equal(args) -+| -+- bitmap_intersects(args, __ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_intersects(args) -+| -+- bitmap_subset(args, __ETHTOOL_LINK_MODE_MASK_NBITS) -++ linkmode_subset(args) -+) -+ -+Add missing linux/mii.h include to mellanox. -DaveM -+ -+Signed-off-by: Sean Anderson <sean.anderson@seco.com> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ drivers/net/dsa/b53/b53_common.c | 6 ++---- -+ drivers/net/dsa/bcm_sf2.c | 8 +++---- -+ drivers/net/dsa/hirschmann/hellcreek.c | 6 ++---- -+ drivers/net/dsa/lantiq_gswip.c | 14 ++++++------- -+ drivers/net/dsa/microchip/ksz8795.c | 8 +++---- -+ drivers/net/dsa/mv88e6xxx/chip.c | 5 ++--- -+ drivers/net/dsa/ocelot/felix_vsc9959.c | 8 +++---- -+ drivers/net/dsa/ocelot/seville_vsc9953.c | 8 +++---- -+ drivers/net/dsa/qca/ar9331.c | 10 ++++----- -+ drivers/net/dsa/sja1105/sja1105_main.c | 7 +++---- -+ drivers/net/dsa/xrs700x/xrs700x.c | 8 +++---- -+ drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 8 +++---- -+ drivers/net/ethernet/atheros/ag71xx.c | 8 +++---- -+ drivers/net/ethernet/cadence/macb_main.c | 11 +++++----- -+ .../net/ethernet/freescale/enetc/enetc_pf.c | 8 +++---- -+ .../net/ethernet/huawei/hinic/hinic_ethtool.c | 10 ++++----- -+ .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 5 ++--- -+ drivers/net/ethernet/marvell/mvneta.c | 10 ++++----- -+ .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 7 +++---- -+ .../marvell/octeontx2/nic/otx2_ethtool.c | 5 ++--- -+ drivers/net/ethernet/marvell/pxa168_eth.c | 3 +-- -+ .../net/ethernet/mellanox/mlx4/en_ethtool.c | 21 +++++++------------ -+ .../microchip/sparx5/sparx5_phylink.c | 7 +++---- -+ drivers/net/ethernet/mscc/ocelot_net.c | 7 +++---- -+ .../ethernet/pensando/ionic/ionic_ethtool.c | 3 +-- -+ .../net/ethernet/xilinx/xilinx_axienet_main.c | 8 +++---- -+ drivers/net/pcs/pcs-xpcs.c | 2 +- -+ drivers/net/phy/sfp-bus.c | 2 +- -+ net/ethtool/ioctl.c | 7 +++---- -+ 29 files changed, 87 insertions(+), 133 deletions(-) -+ -+diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c -+index a967de4fcc90..b32f25b42323 100644 -+--- a/drivers/net/dsa/b53/b53_common.c -++++ b/drivers/net/dsa/b53/b53_common.c -+@@ -1343,10 +1343,8 @@ void b53_phylink_validate(struct dsa_switch *ds, int port, -+ phylink_set(mask, 100baseT_Full); -+ } -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ -+ phylink_helper_basex_speed(state); -+ } -+diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c -+index d76b2377d66e..564f797a32aa 100644 -+--- a/drivers/net/dsa/bcm_sf2.c -++++ b/drivers/net/dsa/bcm_sf2.c -+@@ -686,7 +686,7 @@ static void bcm_sf2_sw_validate(struct dsa_switch *ds, int port, -+ state->interface != PHY_INTERFACE_MODE_GMII && -+ state->interface != PHY_INTERFACE_MODE_INTERNAL && -+ state->interface != PHY_INTERFACE_MODE_MOCA) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ if (port != core_readl(priv, CORE_IMP0_PRT_ID)) -+ dev_err(ds->dev, -+ "Unsupported interface: %d for port %d\n", -+@@ -714,10 +714,8 @@ static void bcm_sf2_sw_validate(struct dsa_switch *ds, int port, -+ phylink_set(mask, 100baseT_Half); -+ phylink_set(mask, 100baseT_Full); -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port, -+diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c -+index 950a54ec4b59..b2bab460d2e9 100644 -+--- a/drivers/net/dsa/hirschmann/hellcreek.c -++++ b/drivers/net/dsa/hirschmann/hellcreek.c -+@@ -1476,10 +1476,8 @@ static void hellcreek_phylink_validate(struct dsa_switch *ds, int port, -+ else -+ phylink_set(mask, 1000baseT_Full); -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static int -+diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c -+index 2240a3d35122..4599e958fa05 100644 -+--- a/drivers/net/dsa/lantiq_gswip.c -++++ b/drivers/net/dsa/lantiq_gswip.c -+@@ -1452,10 +1452,8 @@ static void gswip_phylink_set_capab(unsigned long *supported, -+ phylink_set(mask, 100baseT_Half); -+ phylink_set(mask, 100baseT_Full); -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static void gswip_xrx200_phylink_validate(struct dsa_switch *ds, int port, -+@@ -1483,7 +1481,7 @@ static void gswip_xrx200_phylink_validate(struct dsa_switch *ds, int port, -+ goto unsupported; -+ break; -+ default: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ dev_err(ds->dev, "Unsupported port: %i\n", port); -+ return; -+ } -+@@ -1493,7 +1491,7 @@ static void gswip_xrx200_phylink_validate(struct dsa_switch *ds, int port, -+ return; -+ -+ unsupported: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ dev_err(ds->dev, "Unsupported interface '%s' for port %d\n", -+ phy_modes(state->interface), port); -+ } -+@@ -1523,7 +1521,7 @@ static void gswip_xrx300_phylink_validate(struct dsa_switch *ds, int port, -+ goto unsupported; -+ break; -+ default: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ dev_err(ds->dev, "Unsupported port: %i\n", port); -+ return; -+ } -+@@ -1533,7 +1531,7 @@ static void gswip_xrx300_phylink_validate(struct dsa_switch *ds, int port, -+ return; -+ -+ unsupported: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ dev_err(ds->dev, "Unsupported interface '%s' for port %d\n", -+ phy_modes(state->interface), port); -+ } -+diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c -+index c5142f86a3c7..43fc3087aeb3 100644 -+--- a/drivers/net/dsa/microchip/ksz8795.c -++++ b/drivers/net/dsa/microchip/ksz8795.c -+@@ -1542,15 +1542,13 @@ static void ksz8_validate(struct dsa_switch *ds, int port, -+ phylink_set(mask, 100baseT_Half); -+ phylink_set(mask, 100baseT_Full); -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ -+ return; -+ -+ unsupported: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ dev_err(ds->dev, "Unsupported interface: %s, port: %d\n", -+ phy_modes(state->interface), port); -+ } -+diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c -+index cad98ab421d7..d2751f73246b 100644 -+--- a/drivers/net/dsa/mv88e6xxx/chip.c -++++ b/drivers/net/dsa/mv88e6xxx/chip.c -+@@ -683,9 +683,8 @@ static void mv88e6xxx_validate(struct dsa_switch *ds, int port, -+ if (chip->info->ops->phylink_validate) -+ chip->info->ops->phylink_validate(chip, port, mask, state); -+ -+- bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ -+ /* We can only operate at 2500BaseX or 1000BaseX. If requested -+ * to advertise both, only report advertising at 2500BaseX. -+diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c -+index 5ba7e5c820dd..aa3b7655a89f 100644 -+--- a/drivers/net/dsa/ocelot/felix_vsc9959.c -++++ b/drivers/net/dsa/ocelot/felix_vsc9959.c -+@@ -944,7 +944,7 @@ static void vsc9959_phylink_validate(struct ocelot *ocelot, int port, -+ -+ if (state->interface != PHY_INTERFACE_MODE_NA && -+ state->interface != ocelot_port->phy_mode) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+@@ -966,10 +966,8 @@ static void vsc9959_phylink_validate(struct ocelot *ocelot, int port, -+ phylink_set(mask, 2500baseX_Full); -+ } -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port, -+diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c -+index 05e4e75c0107..40d6d1f2c724 100644 -+--- a/drivers/net/dsa/ocelot/seville_vsc9953.c -++++ b/drivers/net/dsa/ocelot/seville_vsc9953.c -+@@ -1000,7 +1000,7 @@ static void vsc9953_phylink_validate(struct ocelot *ocelot, int port, -+ -+ if (state->interface != PHY_INTERFACE_MODE_NA && -+ state->interface != ocelot_port->phy_mode) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+@@ -1019,10 +1019,8 @@ static void vsc9953_phylink_validate(struct ocelot *ocelot, int port, -+ phylink_set(mask, 2500baseX_Full); -+ } -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static int vsc9953_prevalidate_phy_mode(struct ocelot *ocelot, int port, -+diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c -+index 5d476f452396..c39de2a4c1fe 100644 -+--- a/drivers/net/dsa/qca/ar9331.c -++++ b/drivers/net/dsa/qca/ar9331.c -+@@ -522,7 +522,7 @@ static void ar9331_sw_phylink_validate(struct dsa_switch *ds, int port, -+ goto unsupported; -+ break; -+ default: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ dev_err(ds->dev, "Unsupported port: %i\n", port); -+ return; -+ } -+@@ -536,15 +536,13 @@ static void ar9331_sw_phylink_validate(struct dsa_switch *ds, int port, -+ phylink_set(mask, 100baseT_Half); -+ phylink_set(mask, 100baseT_Full); -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ -+ return; -+ -+ unsupported: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ dev_err(ds->dev, "Unsupported interface: %d, port: %d\n", -+ state->interface, port); -+ } -+diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c -+index 1a2a7536ff8a..3e33d3b6fc59 100644 -+--- a/drivers/net/dsa/sja1105/sja1105_main.c -++++ b/drivers/net/dsa/sja1105/sja1105_main.c -+@@ -1360,7 +1360,7 @@ static void sja1105_phylink_validate(struct dsa_switch *ds, int port, -+ */ -+ if (state->interface != PHY_INTERFACE_MODE_NA && -+ sja1105_phy_mode_mismatch(priv, port, state->interface)) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+@@ -1380,9 +1380,8 @@ static void sja1105_phylink_validate(struct dsa_switch *ds, int port, -+ phylink_set(mask, 2500baseX_Full); -+ } -+ -+- bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static int -+diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c -+index cf363d5a3002..e79a336c6eb2 100644 -+--- a/drivers/net/dsa/xrs700x/xrs700x.c -++++ b/drivers/net/dsa/xrs700x/xrs700x.c -+@@ -457,7 +457,7 @@ static void xrs700x_phylink_validate(struct dsa_switch *ds, int port, -+ phylink_set(mask, 1000baseT_Full); -+ break; -+ default: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ dev_err(ds->dev, "Unsupported port: %i\n", port); -+ return; -+ } -+@@ -468,10 +468,8 @@ static void xrs700x_phylink_validate(struct dsa_switch *ds, int port, -+ phylink_set(mask, 10baseT_Full); -+ phylink_set(mask, 100baseT_Full); -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static void xrs700x_mac_link_up(struct dsa_switch *ds, int port, -+diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c -+index bafc51c34e0b..94879cf8b420 100644 -+--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c -++++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c -+@@ -369,9 +369,8 @@ static int xgbe_set_link_ksettings(struct net_device *netdev, -+ __ETHTOOL_LINK_MODE_MASK_NBITS, cmd->link_modes.advertising, -+ __ETHTOOL_LINK_MODE_MASK_NBITS, lks->link_modes.supported); -+ -+- bitmap_and(advertising, -+- cmd->link_modes.advertising, lks->link_modes.supported, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(advertising, cmd->link_modes.advertising, -++ lks->link_modes.supported); -+ -+ if ((cmd->base.autoneg == AUTONEG_ENABLE) && -+ bitmap_empty(advertising, __ETHTOOL_LINK_MODE_MASK_NBITS)) { -+@@ -384,8 +383,7 @@ static int xgbe_set_link_ksettings(struct net_device *netdev, -+ pdata->phy.autoneg = cmd->base.autoneg; -+ pdata->phy.speed = speed; -+ pdata->phy.duplex = cmd->base.duplex; -+- bitmap_copy(lks->link_modes.advertising, advertising, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_copy(lks->link_modes.advertising, advertising); -+ -+ if (cmd->base.autoneg == AUTONEG_ENABLE) -+ XGBE_SET_ADV(lks, Autoneg); -+diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c -+index 416a5c99db5a..d754bfc4f18f 100644 -+--- a/drivers/net/ethernet/atheros/ag71xx.c -++++ b/drivers/net/ethernet/atheros/ag71xx.c -+@@ -1082,14 +1082,12 @@ static void ag71xx_mac_validate(struct phylink_config *config, -+ phylink_set(mask, 1000baseX_Full); -+ } -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ -+ return; -+ unsupported: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ } -+ -+ static void ag71xx_mac_pcs_get_state(struct phylink_config *config, -+diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c -+index 3ca3f9d0fd9b..c6f28b084646 100644 -+--- a/drivers/net/ethernet/cadence/macb_main.c -++++ b/drivers/net/ethernet/cadence/macb_main.c -+@@ -523,21 +523,21 @@ static void macb_validate(struct phylink_config *config, -+ state->interface != PHY_INTERFACE_MODE_SGMII && -+ state->interface != PHY_INTERFACE_MODE_10GBASER && -+ !phy_interface_mode_is_rgmii(state->interface)) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+ if (!macb_is_gem(bp) && -+ (state->interface == PHY_INTERFACE_MODE_GMII || -+ phy_interface_mode_is_rgmii(state->interface))) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+ if (state->interface == PHY_INTERFACE_MODE_10GBASER && -+ !(bp->caps & MACB_CAPS_HIGH_SPEED && -+ bp->caps & MACB_CAPS_PCS)) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+@@ -576,9 +576,8 @@ static void macb_validate(struct phylink_config *config, -+ phylink_set(mask, 1000baseT_Half); -+ } -+ out: -+- bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static void macb_usx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, -+diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c -+index d522bd5c90b4..1c318a932460 100644 -+--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c -++++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c -+@@ -940,7 +940,7 @@ static void enetc_pl_mac_validate(struct phylink_config *config, -+ state->interface != PHY_INTERFACE_MODE_2500BASEX && -+ state->interface != PHY_INTERFACE_MODE_USXGMII && -+ !phy_interface_mode_is_rgmii(state->interface)) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+@@ -963,10 +963,8 @@ static void enetc_pl_mac_validate(struct phylink_config *config, -+ phylink_set(mask, 2500baseX_Full); -+ } -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static void enetc_pl_mac_config(struct phylink_config *config, -+diff --git a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c -+index b431c300ef1b..a85667078b72 100644 -+--- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c -++++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c -+@@ -322,12 +322,10 @@ static int hinic_get_link_ksettings(struct net_device *netdev, -+ } -+ } -+ -+- bitmap_copy(link_ksettings->link_modes.supported, -+- (unsigned long *)&settings.supported, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_copy(link_ksettings->link_modes.advertising, -+- (unsigned long *)&settings.advertising, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_copy(link_ksettings->link_modes.supported, -++ (unsigned long *)&settings.supported); -++ linkmode_copy(link_ksettings->link_modes.advertising, -++ (unsigned long *)&settings.advertising); -+ -+ return 0; -+ } -+diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c -+index beda8e0ef7d4..8362822316a9 100644 -+--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c -++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c -+@@ -467,9 +467,8 @@ static int ixgbe_set_link_ksettings(struct net_device *netdev, -+ * this function does not support duplex forcing, but can -+ * limit the advertising of the adapter to the specified speed -+ */ -+- if (!bitmap_subset(cmd->link_modes.advertising, -+- cmd->link_modes.supported, -+- __ETHTOOL_LINK_MODE_MASK_NBITS)) -++ if (!linkmode_subset(cmd->link_modes.advertising, -++ cmd->link_modes.supported)) -+ return -EINVAL; -+ -+ /* only allow one speed at a time if no autoneg */ -+diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c -+index 7eb13fbf58e3..f2e959997e48 100644 -+--- a/drivers/net/ethernet/marvell/mvneta.c -++++ b/drivers/net/ethernet/marvell/mvneta.c -+@@ -3862,14 +3862,14 @@ static void mvneta_validate(struct phylink_config *config, -+ */ -+ if (phy_interface_mode_is_8023z(state->interface)) { -+ if (!phylink_test(state->advertising, Autoneg)) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ } else if (state->interface != PHY_INTERFACE_MODE_NA && -+ state->interface != PHY_INTERFACE_MODE_QSGMII && -+ state->interface != PHY_INTERFACE_MODE_SGMII && -+ !phy_interface_mode_is_rgmii(state->interface)) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+@@ -3898,10 +3898,8 @@ static void mvneta_validate(struct phylink_config *config, -+ phylink_set(mask, 100baseT_Full); -+ } -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ -+ /* We can only operate at 2500BaseX or 1000BaseX. If requested -+ * to advertise both, only report advertising at 2500BaseX. -+diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c -+index 2baa909290b3..c963115558cb 100644 -+--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c -++++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c -+@@ -6347,15 +6347,14 @@ static void mvpp2_phylink_validate(struct phylink_config *config, -+ goto empty_set; -+ } -+ -+- bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ -+ phylink_helper_basex_speed(state); -+ return; -+ -+ empty_set: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ } -+ -+ static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode, -+diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c -+index dbfa3bc39e34..4c882ceaeb1f 100644 -+--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c -++++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c -+@@ -1168,9 +1168,8 @@ static int otx2_set_link_ksettings(struct net_device *netdev, -+ otx2_get_link_ksettings(netdev, &cur_ks); -+ -+ /* Check requested modes against supported modes by hardware */ -+- if (!bitmap_subset(cmd->link_modes.advertising, -+- cur_ks.link_modes.supported, -+- __ETHTOOL_LINK_MODE_MASK_NBITS)) -++ if (!linkmode_subset(cmd->link_modes.advertising, -++ cur_ks.link_modes.supported)) -+ return -EINVAL; -+ -+ mutex_lock(&mbox->lock); -+diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c -+index fab53c9b8380..572061164f1f 100644 -+--- a/drivers/net/ethernet/marvell/pxa168_eth.c -++++ b/drivers/net/ethernet/marvell/pxa168_eth.c -+@@ -977,8 +977,7 @@ static int pxa168_init_phy(struct net_device *dev) -+ cmd.base.phy_address = pep->phy_addr; -+ cmd.base.speed = pep->phy_speed; -+ cmd.base.duplex = pep->phy_duplex; -+- bitmap_copy(cmd.link_modes.advertising, PHY_BASIC_FEATURES, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_copy(cmd.link_modes.advertising, PHY_BASIC_FEATURES); -+ cmd.base.autoneg = AUTONEG_ENABLE; -+ -+ if (cmd.base.speed != 0) -+diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c -+index c3cffb32fb06..4be2bc8f74f1 100644 -+--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c -++++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c -+@@ -39,6 +39,7 @@ -+ #include <linux/in.h> -+ #include <net/ip.h> -+ #include <linux/bitmap.h> -++#include <linux/mii.h> -+ -+ #include "mlx4_en.h" -+ #include "en_port.h" -+@@ -643,10 +644,8 @@ static unsigned long *ptys2ethtool_link_mode(struct ptys2ethtool_config *cfg, -+ unsigned int i; \ -+ cfg = &ptys2ethtool_map[reg_]; \ -+ cfg->speed = speed_; \ -+- bitmap_zero(cfg->supported, \ -+- __ETHTOOL_LINK_MODE_MASK_NBITS); \ -+- bitmap_zero(cfg->advertised, \ -+- __ETHTOOL_LINK_MODE_MASK_NBITS); \ -++ linkmode_zero(cfg->supported); \ -++ linkmode_zero(cfg->advertised); \ -+ for (i = 0 ; i < ARRAY_SIZE(modes) ; ++i) { \ -+ __set_bit(modes[i], cfg->supported); \ -+ __set_bit(modes[i], cfg->advertised); \ -+@@ -702,10 +701,8 @@ static void ptys2ethtool_update_link_modes(unsigned long *link_modes, -+ int i; -+ for (i = 0; i < MLX4_LINK_MODES_SZ; i++) { -+ if (eth_proto & MLX4_PROT_MASK(i)) -+- bitmap_or(link_modes, link_modes, -+- ptys2ethtool_link_mode(&ptys2ethtool_map[i], -+- report), -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_or(link_modes, link_modes, -++ ptys2ethtool_link_mode(&ptys2ethtool_map[i], report)); -+ } -+ } -+ -+@@ -716,11 +713,9 @@ static u32 ethtool2ptys_link_modes(const unsigned long *link_modes, -+ u32 ptys_modes = 0; -+ -+ for (i = 0; i < MLX4_LINK_MODES_SZ; i++) { -+- if (bitmap_intersects( -+- ptys2ethtool_link_mode(&ptys2ethtool_map[i], -+- report), -+- link_modes, -+- __ETHTOOL_LINK_MODE_MASK_NBITS)) -++ ulong *map_mode = ptys2ethtool_link_mode(&ptys2ethtool_map[i], -++ report); -++ if (linkmode_intersects(map_mode, link_modes)) -+ ptys_modes |= 1 << i; -+ } -+ return ptys_modes; -+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c b/drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c -+index af70e2795125..fb74752de0ca 100644 -+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c -++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c -+@@ -92,12 +92,11 @@ static void sparx5_phylink_validate(struct phylink_config *config, -+ } -+ break; -+ default: -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+- bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static void sparx5_phylink_mac_config(struct phylink_config *config, -+diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c -+index c08c56e07b1d..6a8e391ecadd 100644 -+--- a/drivers/net/ethernet/mscc/ocelot_net.c -++++ b/drivers/net/ethernet/mscc/ocelot_net.c -+@@ -1509,7 +1509,7 @@ static void vsc7514_phylink_validate(struct phylink_config *config, -+ -+ if (state->interface != PHY_INTERFACE_MODE_NA && -+ state->interface != ocelot_port->phy_mode) { -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ -+@@ -1528,9 +1528,8 @@ static void vsc7514_phylink_validate(struct phylink_config *config, -+ phylink_set(mask, 2500baseT_Full); -+ phylink_set(mask, 2500baseX_Full); -+ -+- bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static void vsc7514_phylink_mac_config(struct phylink_config *config, -+diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c -+index 3de1a03839e2..620fc13b5781 100644 -+--- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c -++++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c -+@@ -228,8 +228,7 @@ static int ionic_get_link_ksettings(struct net_device *netdev, -+ break; -+ } -+ -+- bitmap_copy(ks->link_modes.advertising, ks->link_modes.supported, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_copy(ks->link_modes.advertising, ks->link_modes.supported); -+ -+ ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER); -+ ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS); -+diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c -+index fbbbcfe0e891..4cf0994f624c 100644 -+--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c -++++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c -+@@ -1565,7 +1565,7 @@ static void axienet_validate(struct phylink_config *config, -+ netdev_warn(ndev, "Cannot use PHY mode %s, supported: %s\n", -+ phy_modes(state->interface), -+ phy_modes(lp->phy_mode)); -+- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(supported); -+ return; -+ } -+ } -+@@ -1598,10 +1598,8 @@ static void axienet_validate(struct phylink_config *config, -+ break; -+ } -+ -+- bitmap_and(supported, supported, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -+- bitmap_and(state->advertising, state->advertising, mask, -+- __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -+ } -+ -+ static void axienet_mac_pcs_get_state(struct phylink_config *config, -+diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c -+index fd4cbf8a55ad..ec75cf81c3af 100644 -+--- a/drivers/net/pcs/pcs-xpcs.c -++++ b/drivers/net/pcs/pcs-xpcs.c -+@@ -646,7 +646,7 @@ void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported, -+ if (state->interface == PHY_INTERFACE_MODE_NA) -+ return; -+ -+- bitmap_zero(xpcs_supported, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(xpcs_supported); -+ -+ compat = xpcs_find_compat(xpcs->id, state->interface); -+ -+diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c -+index 4566348a6d05..0a9099c77694 100644 -+--- a/drivers/net/phy/sfp-bus.c -++++ b/drivers/net/phy/sfp-bus.c -+@@ -286,7 +286,7 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, -+ if (bus->sfp_quirk && bus->sfp_quirk->modes) -+ bus->sfp_quirk->modes(id, modes); -+ -+- bitmap_or(support, support, modes, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_or(support, support, modes); -+ -+ phylink_set(support, Autoneg); -+ phylink_set(support, Pause); -+diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c -+index e4983f473a3c..b4aa3bbcf3c7 100644 -+--- a/net/ethtool/ioctl.c -++++ b/net/ethtool/ioctl.c -+@@ -335,7 +335,7 @@ EXPORT_SYMBOL(ethtool_intersect_link_masks); -+ void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, -+ u32 legacy_u32) -+ { -+- bitmap_zero(dst, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(dst); -+ dst[0] = legacy_u32; -+ } -+ EXPORT_SYMBOL(ethtool_convert_legacy_u32_to_link_mode); -+@@ -350,11 +350,10 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, -+ if (__ETHTOOL_LINK_MODE_MASK_NBITS > 32) { -+ __ETHTOOL_DECLARE_LINK_MODE_MASK(ext); -+ -+- bitmap_zero(ext, __ETHTOOL_LINK_MODE_MASK_NBITS); -++ linkmode_zero(ext); -+ bitmap_fill(ext, 32); -+ bitmap_complement(ext, ext, __ETHTOOL_LINK_MODE_MASK_NBITS); -+- if (bitmap_intersects(ext, src, -+- __ETHTOOL_LINK_MODE_MASK_NBITS)) { -++ if (linkmode_intersects(ext, src)) { -+ /* src mask goes beyond bit 31 */ -+ retval = false; -+ } -+-- -+2.35.1 -+ -diff --git a/target/linux/generic/backport-5.15/776-v5.16-2-net-mvneta-populate-supported_interfaces-member.patch b/target/linux/generic/backport-5.15/776-v5.16-2-net-mvneta-populate-supported_interfaces-member.patch -new file mode 100644 -index 0000000000..b755bd79a9 ---- /dev/null -+++ b/target/linux/generic/backport-5.15/776-v5.16-2-net-mvneta-populate-supported_interfaces-member.patch -@@ -0,0 +1,53 @@ -+From c7c29985c548c24efe90e337c575b475bc5e8c13 Mon Sep 17 00:00:00 2001 -+From: Russell King <rmk+kernel@armlinux.org.uk> -+Date: Wed, 27 Oct 2021 10:03:43 +0100 -+Subject: [PATCH 2/4] net: mvneta: populate supported_interfaces member -+ -+Populate the phy_interface_t bitmap for the Marvell mvneta driver with -+interfaces modes supported by the MAC. -+ -+Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ drivers/net/ethernet/marvell/mvneta.c | 25 +++++++++++++++++++++++++ -+ 1 file changed, 25 insertions(+) -+ -+diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c -+index f2e959997e48..1056b4845ec4 100644 -+--- a/drivers/net/ethernet/marvell/mvneta.c -++++ b/drivers/net/ethernet/marvell/mvneta.c -+@@ -5308,6 +5308,31 @@ static int mvneta_probe(struct platform_device *pdev) -+ -+ pp->phylink_config.dev = &dev->dev; -+ pp->phylink_config.type = PHYLINK_NETDEV; -++ phy_interface_set_rgmii(pp->phylink_config.supported_interfaces); -++ __set_bit(PHY_INTERFACE_MODE_QSGMII, -++ pp->phylink_config.supported_interfaces); -++ if (comphy) { -++ /* If a COMPHY is present, we can support any of the serdes -++ * modes and switch between them. -++ */ -++ __set_bit(PHY_INTERFACE_MODE_SGMII, -++ pp->phylink_config.supported_interfaces); -++ __set_bit(PHY_INTERFACE_MODE_1000BASEX, -++ pp->phylink_config.supported_interfaces); -++ __set_bit(PHY_INTERFACE_MODE_2500BASEX, -++ pp->phylink_config.supported_interfaces); -++ } else if (phy_mode == PHY_INTERFACE_MODE_2500BASEX) { -++ /* No COMPHY, with only 2500BASE-X mode supported */ -++ __set_bit(PHY_INTERFACE_MODE_2500BASEX, -++ pp->phylink_config.supported_interfaces); -++ } else if (phy_mode == PHY_INTERFACE_MODE_1000BASEX || -++ phy_mode == PHY_INTERFACE_MODE_SGMII) { -++ /* No COMPHY, we can switch between 1000BASE-X and SGMII */ -++ __set_bit(PHY_INTERFACE_MODE_1000BASEX, -++ pp->phylink_config.supported_interfaces); -++ __set_bit(PHY_INTERFACE_MODE_SGMII, -++ pp->phylink_config.supported_interfaces); -++ } -+ -+ phylink = phylink_create(&pp->phylink_config, pdev->dev.fwnode, -+ phy_mode, &mvneta_phylink_ops); -+-- -+2.35.1 -+ -diff --git a/target/linux/generic/backport-5.15/776-v5.16-3-net-mvneta-remove-interface-checks-in-mvneta_validat.patch b/target/linux/generic/backport-5.15/776-v5.16-3-net-mvneta-remove-interface-checks-in-mvneta_validat.patch -new file mode 100644 -index 0000000000..14c34f2e0e ---- /dev/null -+++ b/target/linux/generic/backport-5.15/776-v5.16-3-net-mvneta-remove-interface-checks-in-mvneta_validat.patch -@@ -0,0 +1,40 @@ -+From 10639f59c410911bb4a14e903d109dd426f2858c Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Wed, 27 Oct 2021 10:03:48 +0100 -+Subject: [PATCH 3/4] net: mvneta: remove interface checks in mvneta_validate() -+ -+As phylink checks the interface mode against the supported_interfaces -+bitmap, we no longer need to validate the interface mode in the -+validation function. Remove this to simplify it. -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ drivers/net/ethernet/marvell/mvneta.c | 11 ++--------- -+ 1 file changed, 2 insertions(+), 9 deletions(-) -+ -+diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c -+index 1056b4845ec4..c13d4beb570f 100644 -+--- a/drivers/net/ethernet/marvell/mvneta.c -++++ b/drivers/net/ethernet/marvell/mvneta.c -+@@ -3860,15 +3860,8 @@ static void mvneta_validate(struct phylink_config *config, -+ * "Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ... -+ * When <PortType> = 1 (1000BASE-X) this field must be set to 1." -+ */ -+- if (phy_interface_mode_is_8023z(state->interface)) { -+- if (!phylink_test(state->advertising, Autoneg)) { -+- linkmode_zero(supported); -+- return; -+- } -+- } else if (state->interface != PHY_INTERFACE_MODE_NA && -+- state->interface != PHY_INTERFACE_MODE_QSGMII && -+- state->interface != PHY_INTERFACE_MODE_SGMII && -+- !phy_interface_mode_is_rgmii(state->interface)) { -++ if (phy_interface_mode_is_8023z(state->interface) && -++ !phylink_test(state->advertising, Autoneg)) { -+ linkmode_zero(supported); -+ return; -+ } -+-- -+2.35.1 -+ -diff --git a/target/linux/generic/backport-5.15/776-v5.16-4-net-mvneta-drop-use-of-phylink_helper_basex_speed.patch b/target/linux/generic/backport-5.15/776-v5.16-4-net-mvneta-drop-use-of-phylink_helper_basex_speed.patch -new file mode 100644 -index 0000000000..0b8fbbdeca ---- /dev/null -+++ b/target/linux/generic/backport-5.15/776-v5.16-4-net-mvneta-drop-use-of-phylink_helper_basex_speed.patch -@@ -0,0 +1,60 @@ -+From 0e09bb9ae49bcb121c353861f440e7a9ede3b378 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Wed, 27 Oct 2021 10:03:53 +0100 -+Subject: [PATCH 4/4] net: mvneta: drop use of phylink_helper_basex_speed() -+ -+Now that we have a better method to select SFP interface modes, we -+no longer need to use phylink_helper_basex_speed() in a driver's -+validation function, and we can also get rid of our hack to indicate -+both 1000base-X and 2500base-X if the comphy is present to make that -+work. Remove this hack and use of phylink_helper_basex_speed(). -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ drivers/net/ethernet/marvell/mvneta.c | 12 +++--------- -+ 1 file changed, 3 insertions(+), 9 deletions(-) -+ -+diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c -+index c13d4beb570f..51fe2de0215e 100644 -+--- a/drivers/net/ethernet/marvell/mvneta.c -++++ b/drivers/net/ethernet/marvell/mvneta.c -+@@ -3851,8 +3851,6 @@ static void mvneta_validate(struct phylink_config *config, -+ unsigned long *supported, -+ struct phylink_link_state *state) -+ { -+- struct net_device *ndev = to_net_dev(config->dev); -+- struct mvneta_port *pp = netdev_priv(ndev); -+ __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; -+ -+ /* We only support QSGMII, SGMII, 802.3z and RGMII modes. -+@@ -3874,11 +3872,12 @@ static void mvneta_validate(struct phylink_config *config, -+ phylink_set(mask, Pause); -+ -+ /* Half-duplex at speeds higher than 100Mbit is unsupported */ -+- if (pp->comphy || state->interface != PHY_INTERFACE_MODE_2500BASEX) { -++ if (state->interface != PHY_INTERFACE_MODE_2500BASEX) { -+ phylink_set(mask, 1000baseT_Full); -+ phylink_set(mask, 1000baseX_Full); -+ } -+- if (pp->comphy || state->interface == PHY_INTERFACE_MODE_2500BASEX) { -++ -++ if (state->interface == PHY_INTERFACE_MODE_2500BASEX) { -+ phylink_set(mask, 2500baseT_Full); -+ phylink_set(mask, 2500baseX_Full); -+ } -+@@ -3893,11 +3892,6 @@ static void mvneta_validate(struct phylink_config *config, -+ -+ linkmode_and(supported, supported, mask); -+ linkmode_and(state->advertising, state->advertising, mask); -+- -+- /* We can only operate at 2500BaseX or 1000BaseX. If requested -+- * to advertise both, only report advertising at 2500BaseX. -+- */ -+- phylink_helper_basex_speed(state); -+ } -+ -+ static void mvneta_mac_pcs_get_state(struct phylink_config *config, -+-- -+2.35.1 -+ --- -2.35.1 - diff --git a/patches/openwrt/wip/0012-TurrisSFP-5-kernel-Backport-generic-phylink-validation-series-to.patch b/patches/openwrt/wip/0012-TurrisSFP-5-kernel-Backport-generic-phylink-validation-series-to.patch index af8d6e659..142804861 100644 --- a/patches/openwrt/wip/0012-TurrisSFP-5-kernel-Backport-generic-phylink-validation-series-to.patch +++ b/patches/openwrt/wip/0012-TurrisSFP-5-kernel-Backport-generic-phylink-validation-series-to.patch @@ -34,451 +34,10 @@ The original cover letter said: Signed-off-by: Marek BehĂşn <marek.behun@nic.cz> --- - ...-add-generic-validate-implementation.patch | 348 ++++++++++++++++++ - ...-mvneta-use-phylink_generic_validate.patch | 77 ++++ ...t-mvpp2-use-phylink_generic_validate.patch | 107 ++++++ 3 files changed, 532 insertions(+) - create mode 100644 target/linux/generic/backport-5.15/780-v5.16-1-net-phylink-add-generic-validate-implementation.patch - create mode 100644 target/linux/generic/backport-5.15/780-v5.16-2-net-mvneta-use-phylink_generic_validate.patch create mode 100644 target/linux/generic/backport-5.15/780-v5.16-3-net-mvpp2-use-phylink_generic_validate.patch -diff --git a/target/linux/generic/backport-5.15/780-v5.16-1-net-phylink-add-generic-validate-implementation.patch b/target/linux/generic/backport-5.15/780-v5.16-1-net-phylink-add-generic-validate-implementation.patch -new file mode 100644 -index 0000000000..22a25f426f ---- /dev/null -+++ b/target/linux/generic/backport-5.15/780-v5.16-1-net-phylink-add-generic-validate-implementation.patch -@@ -0,0 +1,348 @@ -+From 792d0a8e185e3ef101e2644503a0828246c8a5b3 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Mon, 15 Nov 2021 10:00:27 +0000 -+Subject: [PATCH 1/3] net: phylink: add generic validate implementation -+ -+Add a generic validate() implementation using the supported_interfaces -+and a bitmask of MAC pause/speed/duplex capabilities. This allows us -+to entirely eliminate many driver private validate() implementations. -+ -+We expose the underlying phylink_get_linkmodes() function so that -+drivers which have special needs can still benefit from conversion. -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ drivers/net/phy/phylink.c | 252 ++++++++++++++++++++++++++++++++++++++ -+ include/linux/phylink.h | 31 +++++ -+ 2 files changed, 283 insertions(+) -+ -+diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c -+index 0720f05ecb02..3e1d7dea616d 100644 -+--- a/drivers/net/phy/phylink.c -++++ b/drivers/net/phy/phylink.c -+@@ -167,6 +167,258 @@ static const char *phylink_an_mode_str(unsigned int mode) -+ return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; -+ } -+ -++static void phylink_caps_to_linkmodes(unsigned long *linkmodes, -++ unsigned long caps) -++{ -++ if (caps & MAC_SYM_PAUSE) -++ __set_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes); -++ -++ if (caps & MAC_ASYM_PAUSE) -++ __set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, linkmodes); -++ -++ if (caps & MAC_10HD) -++ __set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, linkmodes); -++ -++ if (caps & MAC_10FD) -++ __set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, linkmodes); -++ -++ if (caps & MAC_100HD) { -++ __set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100baseFX_Half_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_100FD) { -++ __set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100baseFX_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_1000HD) -++ __set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, linkmodes); -++ -++ if (caps & MAC_1000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_1000baseT1_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_2500FD) { -++ __set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_5000FD) -++ __set_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, linkmodes); -++ -++ if (caps & MAC_10000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_10000baseR_FEC_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_10000baseCR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_10000baseSR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_10000baseLR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_10000baseER_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_25000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_25000baseCR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_25000baseKR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_25000baseSR_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_40000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_50000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_50000baseKR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_50000baseSR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_50000baseCR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT, -++ linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_50000baseDR_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_56000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_100000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT, -++ linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseKR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseSR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseCR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseLR2_ER2_FR2_Full_BIT, -++ linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseDR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseKR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseSR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseLR_ER_FR_Full_BIT, -++ linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseCR_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_100000baseDR_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_200000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_200000baseKR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseSR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseLR4_ER4_FR4_Full_BIT, -++ linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseDR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseKR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseSR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseLR2_ER2_FR2_Full_BIT, -++ linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseDR2_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_200000baseCR2_Full_BIT, linkmodes); -++ } -++ -++ if (caps & MAC_400000FD) { -++ __set_bit(ETHTOOL_LINK_MODE_400000baseKR8_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseSR8_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseLR8_ER8_FR8_Full_BIT, -++ linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseDR8_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseCR8_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseKR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseSR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseLR4_ER4_FR4_Full_BIT, -++ linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseDR4_Full_BIT, linkmodes); -++ __set_bit(ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT, linkmodes); -++ } -++} -++ -++/** -++ * phylink_get_linkmodes() - get acceptable link modes -++ * @linkmodes: ethtool linkmode mask (must be already initialised) -++ * @interface: phy interface mode defined by &typedef phy_interface_t -++ * @mac_capabilities: bitmask of MAC capabilities -++ * -++ * Set all possible pause, speed and duplex linkmodes in @linkmodes that -++ * are supported by the @interface mode and @mac_capabilities. @linkmodes -++ * must have been initialised previously. -++ */ -++void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, -++ unsigned long mac_capabilities) -++{ -++ unsigned long caps = MAC_SYM_PAUSE | MAC_ASYM_PAUSE; -++ -++ switch (interface) { -++ case PHY_INTERFACE_MODE_USXGMII: -++ caps |= MAC_10000FD | MAC_5000FD | MAC_2500FD; -++ fallthrough; -++ -++ case PHY_INTERFACE_MODE_RGMII_TXID: -++ case PHY_INTERFACE_MODE_RGMII_RXID: -++ case PHY_INTERFACE_MODE_RGMII_ID: -++ case PHY_INTERFACE_MODE_RGMII: -++ case PHY_INTERFACE_MODE_QSGMII: -++ case PHY_INTERFACE_MODE_SGMII: -++ case PHY_INTERFACE_MODE_GMII: -++ caps |= MAC_1000HD | MAC_1000FD; -++ fallthrough; -++ -++ case PHY_INTERFACE_MODE_REVRMII: -++ case PHY_INTERFACE_MODE_RMII: -++ case PHY_INTERFACE_MODE_REVMII: -++ case PHY_INTERFACE_MODE_MII: -++ caps |= MAC_10HD | MAC_10FD; -++ fallthrough; -++ -++ case PHY_INTERFACE_MODE_100BASEX: -++ caps |= MAC_100HD | MAC_100FD; -++ break; -++ -++ case PHY_INTERFACE_MODE_TBI: -++ case PHY_INTERFACE_MODE_MOCA: -++ case PHY_INTERFACE_MODE_RTBI: -++ case PHY_INTERFACE_MODE_1000BASEX: -++ caps |= MAC_1000HD; -++ fallthrough; -++ case PHY_INTERFACE_MODE_TRGMII: -++ caps |= MAC_1000FD; -++ break; -++ -++ case PHY_INTERFACE_MODE_2500BASEX: -++ caps |= MAC_2500FD; -++ break; -++ -++ case PHY_INTERFACE_MODE_5GBASER: -++ caps |= MAC_5000FD; -++ break; -++ -++ case PHY_INTERFACE_MODE_XGMII: -++ case PHY_INTERFACE_MODE_RXAUI: -++ case PHY_INTERFACE_MODE_XAUI: -++ case PHY_INTERFACE_MODE_10GBASER: -++ case PHY_INTERFACE_MODE_10GKR: -++ caps |= MAC_10000FD; -++ break; -++ -++ case PHY_INTERFACE_MODE_25GBASER: -++ caps |= MAC_25000FD; -++ break; -++ -++ case PHY_INTERFACE_MODE_XLGMII: -++ caps |= MAC_40000FD; -++ break; -++ -++ case PHY_INTERFACE_MODE_INTERNAL: -++ caps |= ~0; -++ break; -++ -++ case PHY_INTERFACE_MODE_NA: -++ case PHY_INTERFACE_MODE_MAX: -++ case PHY_INTERFACE_MODE_SMII: -++ break; -++ } -++ -++ phylink_caps_to_linkmodes(linkmodes, caps & mac_capabilities); -++} -++EXPORT_SYMBOL_GPL(phylink_get_linkmodes); -++ -++/** -++ * phylink_generic_validate() - generic validate() callback implementation -++ * @config: a pointer to a &struct phylink_config. -++ * @supported: ethtool bitmask for supported link modes. -++ * @state: a pointer to a &struct phylink_link_state. -++ * -++ * Generic implementation of the validate() callback that MAC drivers can -++ * use when they pass the range of supported interfaces and MAC capabilities. -++ * This makes use of phylink_get_linkmodes(). -++ */ -++void phylink_generic_validate(struct phylink_config *config, -++ unsigned long *supported, -++ struct phylink_link_state *state) -++{ -++ __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; -++ -++ phylink_set_port_modes(mask); -++ phylink_set(mask, Autoneg); -++ phylink_get_linkmodes(mask, state->interface, config->mac_capabilities); -++ -++ linkmode_and(supported, supported, mask); -++ linkmode_and(state->advertising, state->advertising, mask); -++} -++EXPORT_SYMBOL_GPL(phylink_generic_validate); -++ -+ static int phylink_validate_any(struct phylink *pl, unsigned long *supported, -+ struct phylink_link_state *state) -+ { -+diff --git a/include/linux/phylink.h b/include/linux/phylink.h -+index f037470b6fb3..3563820a1765 100644 -+--- a/include/linux/phylink.h -++++ b/include/linux/phylink.h -+@@ -20,6 +20,29 @@ enum { -+ MLO_AN_PHY = 0, /* Conventional PHY */ -+ MLO_AN_FIXED, /* Fixed-link mode */ -+ MLO_AN_INBAND, /* In-band protocol */ -++ -++ MAC_SYM_PAUSE = BIT(0), -++ MAC_ASYM_PAUSE = BIT(1), -++ MAC_10HD = BIT(2), -++ MAC_10FD = BIT(3), -++ MAC_10 = MAC_10HD | MAC_10FD, -++ MAC_100HD = BIT(4), -++ MAC_100FD = BIT(5), -++ MAC_100 = MAC_100HD | MAC_100FD, -++ MAC_1000HD = BIT(6), -++ MAC_1000FD = BIT(7), -++ MAC_1000 = MAC_1000HD | MAC_1000FD, -++ MAC_2500FD = BIT(8), -++ MAC_5000FD = BIT(9), -++ MAC_10000FD = BIT(10), -++ MAC_20000FD = BIT(11), -++ MAC_25000FD = BIT(12), -++ MAC_40000FD = BIT(13), -++ MAC_50000FD = BIT(14), -++ MAC_56000FD = BIT(15), -++ MAC_100000FD = BIT(16), -++ MAC_200000FD = BIT(17), -++ MAC_400000FD = BIT(18), -+ }; -+ -+ static inline bool phylink_autoneg_inband(unsigned int mode) -+@@ -69,6 +92,7 @@ enum phylink_op_type { -+ * if MAC link is at %MLO_AN_FIXED mode. -+ * @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx -+ * are supported by the MAC/PCS. -++ * @mac_capabilities: MAC pause/speed/duplex capabilities. -+ */ -+ struct phylink_config { -+ struct device *dev; -+@@ -79,6 +103,7 @@ struct phylink_config { -+ void (*get_fixed_state)(struct phylink_config *config, -+ struct phylink_link_state *state); -+ DECLARE_PHY_INTERFACE_MASK(supported_interfaces); -++ unsigned long mac_capabilities; -+ }; -+ -+ /** -+@@ -442,6 +467,12 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, -+ phy_interface_t interface, int speed, int duplex); -+ #endif -+ -++void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface, -++ unsigned long mac_capabilities); -++void phylink_generic_validate(struct phylink_config *config, -++ unsigned long *supported, -++ struct phylink_link_state *state); -++ -+ struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, -+ phy_interface_t iface, -+ const struct phylink_mac_ops *mac_ops); -+-- -+2.35.1 -+ -diff --git a/target/linux/generic/backport-5.15/780-v5.16-2-net-mvneta-use-phylink_generic_validate.patch b/target/linux/generic/backport-5.15/780-v5.16-2-net-mvneta-use-phylink_generic_validate.patch -new file mode 100644 -index 0000000000..af0e06fc0f ---- /dev/null -+++ b/target/linux/generic/backport-5.15/780-v5.16-2-net-mvneta-use-phylink_generic_validate.patch -@@ -0,0 +1,77 @@ -+From 50ba86adc61e95d49215c1c089697190a2666e3a Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Mon, 15 Nov 2021 10:00:32 +0000 -+Subject: [PATCH 2/3] net: mvneta: use phylink_generic_validate() -+ -+Convert mvneta to use phylink_generic_validate() for the bulk of its -+validate() implementation. This network adapter has a restriction -+that for 802.3z links, autonegotiation must be enabled. -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ drivers/net/ethernet/marvell/mvneta.c | 34 ++++----------------------- -+ 1 file changed, 4 insertions(+), 30 deletions(-) -+ -+diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c -+index 51fe2de0215e..191eef5c26a7 100644 -+--- a/drivers/net/ethernet/marvell/mvneta.c -++++ b/drivers/net/ethernet/marvell/mvneta.c -+@@ -3851,8 +3851,6 @@ static void mvneta_validate(struct phylink_config *config, -+ unsigned long *supported, -+ struct phylink_link_state *state) -+ { -+- __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; -+- -+ /* We only support QSGMII, SGMII, 802.3z and RGMII modes. -+ * When in 802.3z mode, we must have AN enabled: -+ * "Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ... -+@@ -3864,34 +3862,7 @@ static void mvneta_validate(struct phylink_config *config, -+ return; -+ } -+ -+- /* Allow all the expected bits */ -+- phylink_set(mask, Autoneg); -+- phylink_set_port_modes(mask); -+- -+- /* Asymmetric pause is unsupported */ -+- phylink_set(mask, Pause); -+- -+- /* Half-duplex at speeds higher than 100Mbit is unsupported */ -+- if (state->interface != PHY_INTERFACE_MODE_2500BASEX) { -+- phylink_set(mask, 1000baseT_Full); -+- phylink_set(mask, 1000baseX_Full); -+- } -+- -+- if (state->interface == PHY_INTERFACE_MODE_2500BASEX) { -+- phylink_set(mask, 2500baseT_Full); -+- phylink_set(mask, 2500baseX_Full); -+- } -+- -+- if (!phy_interface_mode_is_8023z(state->interface)) { -+- /* 10M and 100M are only supported in non-802.3z mode */ -+- phylink_set(mask, 10baseT_Half); -+- phylink_set(mask, 10baseT_Full); -+- phylink_set(mask, 100baseT_Half); -+- phylink_set(mask, 100baseT_Full); -+- } -+- -+- linkmode_and(supported, supported, mask); -+- linkmode_and(state->advertising, state->advertising, mask); -++ phylink_generic_validate(config, supported, state); -+ } -+ -+ static void mvneta_mac_pcs_get_state(struct phylink_config *config, -+@@ -5295,6 +5266,9 @@ static int mvneta_probe(struct platform_device *pdev) -+ -+ pp->phylink_config.dev = &dev->dev; -+ pp->phylink_config.type = PHYLINK_NETDEV; -++ pp->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_10 | -++ MAC_100 | MAC_1000FD | MAC_2500FD; -++ -+ phy_interface_set_rgmii(pp->phylink_config.supported_interfaces); -+ __set_bit(PHY_INTERFACE_MODE_QSGMII, -+ pp->phylink_config.supported_interfaces); -+-- -+2.35.1 -+ diff --git a/target/linux/generic/backport-5.15/780-v5.16-3-net-mvpp2-use-phylink_generic_validate.patch b/target/linux/generic/backport-5.15/780-v5.16-3-net-mvpp2-use-phylink_generic_validate.patch new file mode 100644 index 0000000000..a41299d778 @@ -517,7 +76,7 @@ index 0000000000..a41299d778 +@@ -6273,52 +6270,7 @@ static void mvpp2_phylink_validate(struct phylink_config *config, + !phylink_test(state->advertising, Autoneg)) + goto empty_set; -+ ++ +- phylink_set(mask, Autoneg); +- phylink_set_port_modes(mask); +- @@ -566,7 +125,7 @@ index 0000000000..a41299d778 +- linkmode_and(state->advertising, state->advertising, mask); ++ phylink_generic_validate(config, supported, state); + return; -+ ++ + empty_set: +@@ -6913,12 +6865,20 @@ static int mvpp2_port_probe(struct platform_device *pdev, + if (!mvpp2_use_acpi_compat_mode(port_fwnode)) { @@ -578,7 +137,7 @@ index 0000000000..a41299d778 ++ if (port->priv->global_tx_fc) ++ port->phylink_config.mac_capabilities |= ++ MAC_SYM_PAUSE | MAC_ASYM_PAUSE; -+ ++ + if (mvpp2_port_supports_xlg(port)) { + __set_bit(PHY_INTERFACE_MODE_10GBASER, + port->phylink_config.supported_interfaces); @@ -587,11 +146,11 @@ index 0000000000..a41299d778 ++ port->phylink_config.mac_capabilities |= ++ MAC_10000FD; + } -+ ++ + if (mvpp2_port_supports_rgmii(port)) -+-- ++-- +2.35.1 + --- +-- 2.35.1 diff --git a/patches/openwrt/wip/0012-TurrisSFP-6-kernel-Backport-convert-two-dsa-drivers-to-phylink_g.patch b/patches/openwrt/wip/0012-TurrisSFP-6-kernel-Backport-convert-two-dsa-drivers-to-phylink_g.patch index 832c4df93..36c454857 100644 --- a/patches/openwrt/wip/0012-TurrisSFP-6-kernel-Backport-convert-two-dsa-drivers-to-phylink_g.patch +++ b/patches/openwrt/wip/0012-TurrisSFP-6-kernel-Backport-convert-two-dsa-drivers-to-phylink_g.patch @@ -37,326 +37,15 @@ The original cover letter said: Signed-off-by: Marek BehĂşn <marek.behun@nic.cz> --- - ...populate-supported_interfaces-member.patch | 72 +++++++ - ...net-dsa-consolidate-phylink-creation.patch | 158 ++++++++++++++ ...phylink_get_interfaces-with-phylink_.patch | 58 ++++++ ...port-use-of-phylink_generic_validate.patch | 46 ++++ ...k-convert-to-phylink_generic_validat.patch | 78 +++++++ ...-convert-to-phylink_generic_validate.patch | 196 ++++++++++++++++++ 6 files changed, 608 insertions(+) - create mode 100644 target/linux/generic/backport-5.15/781-v5.17-1-net-dsa-populate-supported_interfaces-member.patch - create mode 100644 target/linux/generic/backport-5.15/781-v5.17-2-net-dsa-consolidate-phylink-creation.patch - create mode 100644 target/linux/generic/backport-5.15/781-v5.17-3-net-dsa-replace-phylink_get_interfaces-with-phylink_.patch create mode 100644 target/linux/generic/backport-5.15/781-v5.17-4-net-dsa-support-use-of-phylink_generic_validate.patch create mode 100644 target/linux/generic/backport-5.15/781-v5.17-5-net-dsa-hellcreek-convert-to-phylink_generic_validat.patch create mode 100644 target/linux/generic/backport-5.15/781-v5.17-6-net-dsa-lantiq-convert-to-phylink_generic_validate.patch -diff --git a/target/linux/generic/backport-5.15/781-v5.17-1-net-dsa-populate-supported_interfaces-member.patch b/target/linux/generic/backport-5.15/781-v5.17-1-net-dsa-populate-supported_interfaces-member.patch -new file mode 100644 -index 0000000000..d4bcbb3eaa ---- /dev/null -+++ b/target/linux/generic/backport-5.15/781-v5.17-1-net-dsa-populate-supported_interfaces-member.patch -@@ -0,0 +1,72 @@ -+From e89cf45caa992df5baee7ce07431d9598ac1defc Mon Sep 17 00:00:00 2001 -+From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org> -+Date: Thu, 28 Oct 2021 18:00:14 +0100 -+Subject: [PATCH 1/6] net: dsa: populate supported_interfaces member -+MIME-Version: 1.0 -+Content-Type: text/plain; charset=UTF-8 -+Content-Transfer-Encoding: 8bit -+ -+Add a new DSA switch operation, phylink_get_interfaces, which should -+fill in which PHY_INTERFACE_MODE_* are supported by given port. -+ -+Use this before phylink_create() to fill phylinks supported_interfaces -+member, allowing phylink to determine which PHY_INTERFACE_MODEs are -+supported. -+ -+Signed-off-by: Marek BehĂşn <kabel@kernel.org> -+[tweaked patch and description to add more complete support -- rmk] -+Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Signed-off-by: David S. Miller <davem@davemloft.net> -+--- -+ include/net/dsa.h | 2 ++ -+ net/dsa/port.c | 4 ++++ -+ net/dsa/slave.c | 4 ++++ -+ 3 files changed, 10 insertions(+) -+ -+diff --git a/include/net/dsa.h b/include/net/dsa.h -+index 206ff3c4ce47..77d0d9a8e2ab 100644 -+--- a/include/net/dsa.h -++++ b/include/net/dsa.h -+@@ -636,6 +636,8 @@ struct dsa_switch_ops { -+ /* -+ * PHYLINK integration -+ */ -++ void (*phylink_get_interfaces)(struct dsa_switch *ds, int port, -++ unsigned long *supported_interfaces); -+ void (*phylink_validate)(struct dsa_switch *ds, int port, -+ unsigned long *supported, -+ struct phylink_link_state *state); -+diff --git a/net/dsa/port.c b/net/dsa/port.c -+index a21015d6bd36..d1502403aeb8 100644 -+--- a/net/dsa/port.c -++++ b/net/dsa/port.c -+@@ -1172,6 +1172,10 @@ static int dsa_port_phylink_register(struct dsa_port *dp) -+ dp->pl_config.type = PHYLINK_DEV; -+ dp->pl_config.pcs_poll = ds->pcs_poll; -+ -++ if (ds->ops->phylink_get_interfaces) -++ ds->ops->phylink_get_interfaces(ds, dp->index, -++ dp->pl_config.supported_interfaces); -++ -+ dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), -+ mode, &dsa_port_phylink_mac_ops); -+ if (IS_ERR(dp->pl)) { -+diff --git a/net/dsa/slave.c b/net/dsa/slave.c -+index 4d581bd22cd5..525140370950 100644 -+--- a/net/dsa/slave.c -++++ b/net/dsa/slave.c -+@@ -1837,6 +1837,10 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) -+ dp->pl_config.poll_fixed_state = true; -+ } -+ -++ if (ds->ops->phylink_get_interfaces) -++ ds->ops->phylink_get_interfaces(ds, dp->index, -++ dp->pl_config.supported_interfaces); -++ -+ dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), mode, -+ &dsa_port_phylink_mac_ops); -+ if (IS_ERR(dp->pl)) { -+-- -+2.35.1 -+ -diff --git a/target/linux/generic/backport-5.15/781-v5.17-2-net-dsa-consolidate-phylink-creation.patch b/target/linux/generic/backport-5.15/781-v5.17-2-net-dsa-consolidate-phylink-creation.patch -new file mode 100644 -index 0000000000..26606a5ada ---- /dev/null -+++ b/target/linux/generic/backport-5.15/781-v5.17-2-net-dsa-consolidate-phylink-creation.patch -@@ -0,0 +1,158 @@ -+From b4668037f74e9f105675fd4dc7da468702d3ea18 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Tue, 30 Nov 2021 13:09:55 +0000 -+Subject: [PATCH 2/6] net: dsa: consolidate phylink creation -+MIME-Version: 1.0 -+Content-Type: text/plain; charset=UTF-8 -+Content-Transfer-Encoding: 8bit -+ -+The code in port.c and slave.c creating the phylink instance is very -+similar - let's consolidate this into a single function. -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Reviewed-by: Marek BehĂşn <kabel@kernel.org> -+Reviewed-by: Andrew Lunn <andrew@lunn.ch> -+Signed-off-by: Jakub Kicinski <kuba@kernel.org> -+--- -+ net/dsa/dsa_priv.h | 2 +- -+ net/dsa/port.c | 44 ++++++++++++++++++++++++++++---------------- -+ net/dsa/slave.c | 19 +++---------------- -+ 3 files changed, 32 insertions(+), 33 deletions(-) -+ -+diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h -+index f0963d85b134..4a18e874779b 100644 -+--- a/net/dsa/dsa_priv.h -++++ b/net/dsa/dsa_priv.h -+@@ -267,13 +267,13 @@ int dsa_port_mrp_add_ring_role(const struct dsa_port *dp, -+ const struct switchdev_obj_ring_role_mrp *mrp); -+ int dsa_port_mrp_del_ring_role(const struct dsa_port *dp, -+ const struct switchdev_obj_ring_role_mrp *mrp); -++int dsa_port_phylink_create(struct dsa_port *dp); -+ int dsa_port_link_register_of(struct dsa_port *dp); -+ void dsa_port_link_unregister_of(struct dsa_port *dp); -+ int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr); -+ void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr); -+ int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast); -+ void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast); -+-extern const struct phylink_mac_ops dsa_port_phylink_mac_ops; -+ -+ static inline bool dsa_port_offloads_bridge_port(struct dsa_port *dp, -+ const struct net_device *dev) -+diff --git a/net/dsa/port.c b/net/dsa/port.c -+index d1502403aeb8..4d227c503837 100644 -+--- a/net/dsa/port.c -++++ b/net/dsa/port.c -+@@ -1076,7 +1076,7 @@ static void dsa_port_phylink_mac_link_up(struct phylink_config *config, -+ speed, duplex, tx_pause, rx_pause); -+ } -+ -+-const struct phylink_mac_ops dsa_port_phylink_mac_ops = { -++static const struct phylink_mac_ops dsa_port_phylink_mac_ops = { -+ .validate = dsa_port_phylink_validate, -+ .mac_pcs_get_state = dsa_port_phylink_mac_pcs_get_state, -+ .mac_config = dsa_port_phylink_mac_config, -+@@ -1085,6 +1085,30 @@ const struct phylink_mac_ops dsa_port_phylink_mac_ops = { -+ .mac_link_up = dsa_port_phylink_mac_link_up, -+ }; -+ -++int dsa_port_phylink_create(struct dsa_port *dp) -++{ -++ struct dsa_switch *ds = dp->ds; -++ phy_interface_t mode; -++ int err; -++ -++ err = of_get_phy_mode(dp->dn, &mode); -++ if (err) -++ mode = PHY_INTERFACE_MODE_NA; -++ -++ if (ds->ops->phylink_get_interfaces) -++ ds->ops->phylink_get_interfaces(ds, dp->index, -++ dp->pl_config.supported_interfaces); -++ -++ dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), -++ mode, &dsa_port_phylink_mac_ops); -++ if (IS_ERR(dp->pl)) { -++ pr_err("error creating PHYLINK: %ld\n", PTR_ERR(dp->pl)); -++ return PTR_ERR(dp->pl); -++ } -++ -++ return 0; -++} -++ -+ static int dsa_port_setup_phy_of(struct dsa_port *dp, bool enable) -+ { -+ struct dsa_switch *ds = dp->ds; -+@@ -1161,27 +1185,15 @@ static int dsa_port_phylink_register(struct dsa_port *dp) -+ { -+ struct dsa_switch *ds = dp->ds; -+ struct device_node *port_dn = dp->dn; -+- phy_interface_t mode; -+ int err; -+ -+- err = of_get_phy_mode(port_dn, &mode); -+- if (err) -+- mode = PHY_INTERFACE_MODE_NA; -+- -+ dp->pl_config.dev = ds->dev; -+ dp->pl_config.type = PHYLINK_DEV; -+ dp->pl_config.pcs_poll = ds->pcs_poll; -+ -+- if (ds->ops->phylink_get_interfaces) -+- ds->ops->phylink_get_interfaces(ds, dp->index, -+- dp->pl_config.supported_interfaces); -+- -+- dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), -+- mode, &dsa_port_phylink_mac_ops); -+- if (IS_ERR(dp->pl)) { -+- pr_err("error creating PHYLINK: %ld\n", PTR_ERR(dp->pl)); -+- return PTR_ERR(dp->pl); -+- } -++ err = dsa_port_phylink_create(dp); -++ if (err) -++ return err; -+ -+ err = phylink_of_phy_connect(dp->pl, port_dn, 0); -+ if (err && err != -ENODEV) { -+diff --git a/net/dsa/slave.c b/net/dsa/slave.c -+index 525140370950..0520b4a2d898 100644 -+--- a/net/dsa/slave.c -++++ b/net/dsa/slave.c -+@@ -1817,14 +1817,9 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) -+ struct dsa_port *dp = dsa_slave_to_port(slave_dev); -+ struct device_node *port_dn = dp->dn; -+ struct dsa_switch *ds = dp->ds; -+- phy_interface_t mode; -+ u32 phy_flags = 0; -+ int ret; -+ -+- ret = of_get_phy_mode(port_dn, &mode); -+- if (ret) -+- mode = PHY_INTERFACE_MODE_NA; -+- -+ dp->pl_config.dev = &slave_dev->dev; -+ dp->pl_config.type = PHYLINK_NETDEV; -+ -+@@ -1837,17 +1832,9 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) -+ dp->pl_config.poll_fixed_state = true; -+ } -+ -+- if (ds->ops->phylink_get_interfaces) -+- ds->ops->phylink_get_interfaces(ds, dp->index, -+- dp->pl_config.supported_interfaces); -+- -+- dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), mode, -+- &dsa_port_phylink_mac_ops); -+- if (IS_ERR(dp->pl)) { -+- netdev_err(slave_dev, -+- "error creating PHYLINK: %ld\n", PTR_ERR(dp->pl)); -+- return PTR_ERR(dp->pl); -+- } -++ ret = dsa_port_phylink_create(dp); -++ if (ret) -++ return ret; -+ -+ if (ds->ops->get_phy_flags) -+ phy_flags = ds->ops->get_phy_flags(ds, dp->index); -+-- -+2.35.1 -+ -diff --git a/target/linux/generic/backport-5.15/781-v5.17-3-net-dsa-replace-phylink_get_interfaces-with-phylink_.patch b/target/linux/generic/backport-5.15/781-v5.17-3-net-dsa-replace-phylink_get_interfaces-with-phylink_.patch -new file mode 100644 -index 0000000000..d2f1bd88bb ---- /dev/null -+++ b/target/linux/generic/backport-5.15/781-v5.17-3-net-dsa-replace-phylink_get_interfaces-with-phylink_.patch -@@ -0,0 +1,58 @@ -+From 31509e304cd5cbdeaecf12cb2de78b6ffe2ac022 Mon Sep 17 00:00:00 2001 -+From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> -+Date: Tue, 30 Nov 2021 13:10:01 +0000 -+Subject: [PATCH 3/6] net: dsa: replace phylink_get_interfaces() with -+ phylink_get_caps() -+MIME-Version: 1.0 -+Content-Type: text/plain; charset=UTF-8 -+Content-Transfer-Encoding: 8bit -+ -+Phylink needs slightly more information than phylink_get_interfaces() -+allows us to get from the DSA drivers - we need the MAC capabilities. -+Replace the phylink_get_interfaces() method with phylink_get_caps() to -+allow DSA drivers to fill in the phylink_config MAC capabilities field -+as well. -+ -+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> -+Reviewed-by: Marek BehĂşn <kabel@kernel.org> -+Reviewed-by: Andrew Lunn <andrew@lunn.ch> -+Signed-off-by: Jakub Kicinski <kuba@kernel.org> -+--- -+ include/net/dsa.h | 4 ++-- -+ net/dsa/port.c | 5 ++--- -+ 2 files changed, 4 insertions(+), 5 deletions(-) -+ -+diff --git a/include/net/dsa.h b/include/net/dsa.h -+index 77d0d9a8e2ab..1b130566ae3a 100644 -+--- a/include/net/dsa.h -++++ b/include/net/dsa.h -+@@ -636,8 +636,8 @@ struct dsa_switch_ops { -+ /* -+ * PHYLINK integration -+ */ -+- void (*phylink_get_interfaces)(struct dsa_switch *ds, int port, -+- unsigned long *supported_interfaces); -++ void (*phylink_get_caps)(struct dsa_switch *ds, int port, -++ struct phylink_config *config); -+ void (*phylink_validate)(struct dsa_switch *ds, int port, -+ unsigned long *supported, -+ struct phylink_link_state *state); -+diff --git a/net/dsa/port.c b/net/dsa/port.c -+index 4d227c503837..eed1b5397dc7 100644 -+--- a/net/dsa/port.c -++++ b/net/dsa/port.c -+@@ -1095,9 +1095,8 @@ int dsa_port_phylink_create(struct dsa_port *dp) -+ if (err) -+ mode = PHY_INTERFACE_MODE_NA; -+ -+- if (ds->ops->phylink_get_interfaces) -+- ds->ops->phylink_get_interfaces(ds, dp->index, -+- dp->pl_config.supported_interfaces); -++ if (ds->ops->phylink_get_caps) -++ ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config); -+ -+ dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), -+ mode, &dsa_port_phylink_mac_ops); -+-- -+2.35.1 -+ diff --git a/target/linux/generic/backport-5.15/781-v5.17-4-net-dsa-support-use-of-phylink_generic_validate.patch b/target/linux/generic/backport-5.15/781-v5.17-4-net-dsa-support-use-of-phylink_generic_validate.patch new file mode 100644 index 0000000000..6720e5569e @@ -396,17 +85,17 @@ index 0000000000..6720e5569e +@@ -985,8 +985,11 @@ static void dsa_port_phylink_validate(struct phylink_config *config, + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); + struct dsa_switch *ds = dp->ds; -+ ++ +- if (!ds->ops->phylink_validate) ++ if (!ds->ops->phylink_validate) { ++ if (config->mac_capabilities) ++ phylink_generic_validate(config, supported, state); + return; ++ } -+ ++ + ds->ops->phylink_validate(ds, dp->index, supported, state); + } -+-- ++-- +2.35.1 + diff --git a/target/linux/generic/backport-5.15/781-v5.17-5-net-dsa-hellcreek-convert-to-phylink_generic_validat.patch b/target/linux/generic/backport-5.15/781-v5.17-5-net-dsa-hellcreek-convert-to-phylink_generic_validat.patch @@ -444,7 +133,7 @@ index 0000000000..9c72c3e245 +@@ -1457,14 +1457,19 @@ static void hellcreek_teardown(struct dsa_switch *ds) + dsa_devlink_resources_unregister(ds); + } -+ ++ +-static void hellcreek_phylink_validate(struct dsa_switch *ds, int port, +- unsigned long *supported, +- struct phylink_link_state *state) @@ -453,7 +142,7 @@ index 0000000000..9c72c3e245 + { +- __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; + struct hellcreek *hellcreek = ds->priv; -+ ++ +- dev_dbg(hellcreek->dev, "Phylink validate for port %d\n", port); ++ __set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces); ++ __set_bit(PHY_INTERFACE_MODE_RGMII, config->supported_interfaces); @@ -463,7 +152,7 @@ index 0000000000..9c72c3e245 ++ * need it for compatibility with existing DT. ++ */ ++ __set_bit(PHY_INTERFACE_MODE_GMII, config->supported_interfaces); -+ ++ + /* The MAC settings are a hardware configuration option and cannot be + * changed at run time or by strapping. Therefore the attached PHYs +@@ -1472,12 +1477,9 @@ static void hellcreek_phylink_validate(struct dsa_switch *ds, int port, @@ -479,7 +168,7 @@ index 0000000000..9c72c3e245 +- linkmode_and(state->advertising, state->advertising, mask); ++ config->mac_capabilities = MAC_1000FD; + } -+ ++ + static int +@@ -1828,7 +1830,7 @@ static const struct dsa_switch_ops hellcreek_ds_ops = { + .get_strings = hellcreek_get_strings, @@ -490,7 +179,7 @@ index 0000000000..9c72c3e245 + .port_bridge_flags = hellcreek_bridge_flags, + .port_bridge_join = hellcreek_port_bridge_join, + .port_bridge_leave = hellcreek_port_bridge_leave, -+-- ++-- +2.35.1 + diff --git a/target/linux/generic/backport-5.15/781-v5.17-6-net-dsa-lantiq-convert-to-phylink_generic_validate.patch b/target/linux/generic/backport-5.15/781-v5.17-6-net-dsa-lantiq-convert-to-phylink_generic_validate.patch @@ -526,7 +215,7 @@ index 0000000000..9473bdff3b +@@ -1426,114 +1426,70 @@ static int gswip_port_fdb_dump(struct dsa_switch *ds, int port, + return 0; + } -+ ++ +-static void gswip_phylink_set_capab(unsigned long *supported, +- struct phylink_link_state *state) +-{ @@ -602,7 +291,7 @@ index 0000000000..9473bdff3b +- dev_err(ds->dev, "Unsupported port: %i\n", port); +- return; + } -+ ++ +- gswip_phylink_set_capab(supported, state); +- +- return; @@ -614,7 +303,7 @@ index 0000000000..9473bdff3b ++ config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | ++ MAC_10 | MAC_100 | MAC_1000; + } -+ ++ +-static void gswip_xrx300_phylink_validate(struct dsa_switch *ds, int port, +- unsigned long *supported, +- struct phylink_link_state *state) @@ -660,7 +349,7 @@ index 0000000000..9473bdff3b +- dev_err(ds->dev, "Unsupported port: %i\n", port); +- return; + } -+ ++ +- gswip_phylink_set_capab(supported, state); +- +- return; @@ -672,7 +361,7 @@ index 0000000000..9473bdff3b ++ config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | ++ MAC_10 | MAC_100 | MAC_1000; + } -+ ++ + static void gswip_port_set_link(struct gswip_priv *priv, int port, bool link) +@@ -1812,7 +1768,7 @@ static const struct dsa_switch_ops gswip_xrx200_switch_ops = { + .port_fdb_add = gswip_port_fdb_add, @@ -692,9 +381,9 @@ index 0000000000..9473bdff3b + .phylink_mac_config = gswip_phylink_mac_config, + .phylink_mac_link_down = gswip_phylink_mac_link_down, + .phylink_mac_link_up = gswip_phylink_mac_link_up, -+-- ++-- +2.35.1 + --- +-- 2.35.1 diff --git a/patches/openwrt/wip/0012-TurrisSFP-9-mvebu-add-support-for-Turris-SFP-module.patch b/patches/openwrt/wip/0012-TurrisSFP-9-mvebu-add-support-for-Turris-SFP-module.patch index 5f2c08569..7c9221d24 100644 --- a/patches/openwrt/wip/0012-TurrisSFP-9-mvebu-add-support-for-Turris-SFP-module.patch +++ b/patches/openwrt/wip/0012-TurrisSFP-9-mvebu-add-support-for-Turris-SFP-module.patch @@ -112,7 +112,7 @@ index 0000000000..c0c274d278 +@@ -300,6 +300,71 @@ static int phylink_parse_fixedlink(struct phylink *pl, + return 0; + } -+ ++ ++static void phylink_update_phy_modes(struct phylink *pl, ++ struct fwnode_handle *fwnode) ++{ @@ -184,13 +184,13 @@ index 0000000000..c0c274d278 +@@ -911,6 +976,8 @@ struct phylink *phylink_create(struct phylink_config *config, + __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); + timer_setup(&pl->link_poll, phylink_fixed_poll, 0); -+ ++ ++ phylink_update_phy_modes(pl, fwnode); ++ + bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS); + linkmode_copy(pl->link_config.advertising, pl->supported); + phylink_validate(pl, pl->supported, &pl->link_config); -+-- ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-02-net-phylink-pass-supported-PHY-interface-modes-to-ph.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-02-net-phylink-pass-supported-PHY-interface-modes-to-ph.patch @@ -226,7 +226,7 @@ index 0000000000..a528045987 +@@ -1195,6 +1195,10 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy) + pl->link_config.interface = pl->link_interface; + } -+ ++ ++ /* Set the PHY's host supported interfaces */ ++ phy_interface_copy(phy->host_interfaces, ++ pl->config->supported_interfaces); @@ -237,7 +237,7 @@ index 0000000000..a528045987 +@@ -1264,6 +1268,10 @@ int phylink_fwnode_phy_connect(struct phylink *pl, + if (!phy_dev) + return -ENODEV; -+ ++ ++ /* Set the PHY's host supported interfaces */ ++ phy_interface_copy(phy_dev->host_interfaces, ++ pl->config->supported_interfaces); @@ -248,7 +248,7 @@ index 0000000000..a528045987 +@@ -2448,6 +2456,8 @@ static bool phylink_phy_no_inband(struct phy_device *phy) + (phy->c45_ids.device_ids[1] & 0xfffffff0) == 0xae025150; + } -+ ++ ++static DECLARE_PHY_INTERFACE_MASK(phylink_sfp_interfaces); ++ + static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) @@ -257,7 +257,7 @@ index 0000000000..a528045987 +@@ -2469,6 +2479,10 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) + else + mode = MLO_AN_INBAND; -+ ++ ++ /* Set the PHY's host supported interfaces */ ++ phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces, ++ pl->config->supported_interfaces); @@ -268,7 +268,7 @@ index 0000000000..a528045987 +@@ -2852,4 +2866,18 @@ void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs, + } + EXPORT_SYMBOL_GPL(phylink_mii_c45_pcs_get_state); -+ ++ ++static int __init phylink_init(void) ++{ ++ __set_bit(PHY_INTERFACE_MODE_USXGMII, phylink_sfp_interfaces); @@ -291,7 +291,7 @@ index 0000000000..a528045987 +@@ -169,6 +169,12 @@ static inline bool phy_interface_empty(const unsigned long *intf) + return bitmap_empty(intf, PHY_INTERFACE_MODE_MAX); + } -+ ++ ++static inline void phy_interface_copy(unsigned long *dst, ++ const unsigned long *src) ++{ @@ -312,14 +312,14 @@ index 0000000000..a528045987 +@@ -658,6 +665,9 @@ struct phy_device { + /* used with phy_speed_down */ + __ETHTOOL_DECLARE_LINK_MODE_MASK(adv_old); -+ ++ ++ /* host supported PHY interface types */ ++ DECLARE_PHY_INTERFACE_MASK(host_interfaces); ++ + /* Energy efficient ethernet modes which should be prohibited */ + u32 eee_broken_modes; -+ -+-- ++ ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-03-net-phy-marvell10g-add-downshift-tunable-support.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-03-net-phy-marvell10g-add-downshift-tunable-support.patch @@ -358,7 +358,7 @@ index 0000000000..4ccb537861 +@@ -33,6 +34,8 @@ + #define MV_PHY_ALASKA_NBT_QUIRK_MASK 0xfffffffe + #define MV_PHY_ALASKA_NBT_QUIRK_REV (MARVELL_PHY_ID_88X3310 | 0xa) -+ ++ ++#define MV_VERSION(a,b,c,d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) ++ + enum { @@ -367,7 +367,7 @@ index 0000000000..4ccb537861 +@@ -62,6 +65,15 @@ enum { + MV_PCS_CSCR1_MDIX_MDIX = 0x0020, + MV_PCS_CSCR1_MDIX_AUTO = 0x0060, -+ ++ ++ MV_PCS_DSC1 = 0x8003, ++ MV_PCS_DSC1_ENABLE = BIT(9), ++ MV_PCS_DSC1_10GBT = 0x01c0, @@ -382,7 +382,7 @@ index 0000000000..4ccb537861 + MV_PCS_CSSR1_SPD1_SPD2 = 0xc000, +@@ -125,6 +137,7 @@ enum { + }; -+ ++ + struct mv3310_chip { ++ bool (*has_downshift)(struct phy_device *phydev); + void (*init_supported_interfaces)(unsigned long *mask); @@ -390,16 +390,16 @@ index 0000000000..4ccb537861 + int (*init_interface)(struct phy_device *phydev, int mactype); +@@ -138,6 +151,7 @@ struct mv3310_priv { + DECLARE_BITMAP(supported_interfaces, PHY_INTERFACE_MODE_MAX); -+ ++ + u32 firmware_ver; ++ bool has_downshift; + bool rate_match; + phy_interface_t const_interface; -+ ++ +@@ -330,6 +344,71 @@ static int mv3310_reset(struct phy_device *phydev, u32 unit) + 5000, 100000, true); + } -+ ++ ++static int mv3310_get_downshift(struct phy_device *phydev, u8 *ds) ++{ ++ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); @@ -471,7 +471,7 @@ index 0000000000..4ccb537861 +@@ -448,6 +527,9 @@ static int mv3310_probe(struct phy_device *phydev) + priv->firmware_ver >> 24, (priv->firmware_ver >> 16) & 255, + (priv->firmware_ver >> 8) & 255, priv->firmware_ver & 255); -+ ++ ++ if (chip->has_downshift) ++ priv->has_downshift = chip->has_downshift(phydev); ++ @@ -480,7 +480,7 @@ index 0000000000..4ccb537861 + if (ret) +@@ -616,7 +698,16 @@ static int mv3310_config_init(struct phy_device *phydev) + } -+ ++ + /* Enable EDPD mode - saving 600mW */ +- return mv3310_set_edpd(phydev, ETHTOOL_PHY_EDPD_DFLT_TX_MSECS); ++ err = mv3310_set_edpd(phydev, ETHTOOL_PHY_EDPD_DFLT_TX_MSECS); @@ -494,7 +494,7 @@ index 0000000000..4ccb537861 ++ ++ return 0; + } -+ ++ + static int mv3310_get_features(struct phy_device *phydev) +@@ -886,6 +977,8 @@ static int mv3310_get_tunable(struct phy_device *phydev, + struct ethtool_tunable *tuna, void *data) @@ -517,7 +517,7 @@ index 0000000000..4ccb537861 +@@ -904,6 +999,14 @@ static int mv3310_set_tunable(struct phy_device *phydev, + } + } -+ ++ ++static bool mv3310_has_downshift(struct phy_device *phydev) ++{ ++ struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); @@ -531,7 +531,7 @@ index 0000000000..4ccb537861 + __set_bit(PHY_INTERFACE_MODE_SGMII, mask); +@@ -943,6 +1046,7 @@ static void mv2111_init_supported_interfaces(unsigned long *mask) + } -+ ++ + static const struct mv3310_chip mv3310_type = { ++ .has_downshift = mv3310_has_downshift, + .init_supported_interfaces = mv3310_init_supported_interfaces, @@ -539,13 +539,13 @@ index 0000000000..4ccb537861 + .init_interface = mv3310_init_interface, +@@ -953,6 +1057,7 @@ static const struct mv3310_chip mv3310_type = { + }; -+ ++ + static const struct mv3310_chip mv3340_type = { ++ .has_downshift = mv3310_has_downshift, + .init_supported_interfaces = mv3340_init_supported_interfaces, + .get_mactype = mv3310_get_mactype, + .init_interface = mv3340_init_interface, -+-- ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-04-net-phy-marvell10g-Use-generic-macro-for-supported-i.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-04-net-phy-marvell10g-Use-generic-macro-for-supported-i.patch @@ -579,14 +579,14 @@ index 0000000000..76f3479f3a ++++ b/drivers/net/phy/marvell10g.c +@@ -148,7 +148,7 @@ struct mv3310_chip { + }; -+ ++ + struct mv3310_priv { +- DECLARE_BITMAP(supported_interfaces, PHY_INTERFACE_MODE_MAX); ++ DECLARE_PHY_INTERFACE_MASK(supported_interfaces); -+ ++ + u32 firmware_ver; + bool has_downshift; -+-- ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-05-net-phy-marvell10g-Use-tabs-instead-of-spaces-for-in.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-05-net-phy-marvell10g-Use-tabs-instead-of-spaces-for-in.patch @@ -643,7 +643,7 @@ index 0000000000..2d931ba43e + /* Temperature control/read registers (88X3310 only) */ + MV_V2_TEMP_CTRL = 0xf08a, + MV_V2_TEMP_CTRL_MASK = 0xc000, -+-- ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-06-net-phy-marvell10g-select-host-interface-configurati.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-06-net-phy-marvell10g-select-host-interface-configurati.patch @@ -702,7 +702,7 @@ index 0000000000..b40e361036 +@@ -96,6 +96,11 @@ enum { + MV_PCS_PORT_INFO_NPORTS_MASK = 0x0380, + MV_PCS_PORT_INFO_NPORTS_SHIFT = 7, -+ ++ ++ /* SerDes reinitialization 88E21X0 */ ++ MV_AN_21X0_SERDES_CTRL2 = 0x800f, ++ MV_AN_21X0_SERDES_CTRL2_AUTO_INIT_DIS = BIT(13), @@ -718,12 +718,12 @@ index 0000000000..b40e361036 ++ int (*set_mactype)(struct phy_device *phydev, int mactype); ++ int (*select_mactype)(unsigned long *interfaces); + int (*init_interface)(struct phy_device *phydev, int mactype); -+ ++ + #ifdef CONFIG_HWMON +@@ -593,6 +600,49 @@ static int mv2110_get_mactype(struct phy_device *phydev) + return mactype & MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK; + } -+ ++ ++static int mv2110_set_mactype(struct phy_device *phydev, int mactype) ++{ ++ int err, val; @@ -773,7 +773,7 @@ index 0000000000..b40e361036 +@@ -604,6 +654,46 @@ static int mv3310_get_mactype(struct phy_device *phydev) + return mactype & MV_V2_33X0_PORT_CTRL_MACTYPE_MASK; + } -+ ++ ++static int mv3310_set_mactype(struct phy_device *phydev, int mactype) ++{ ++ int ret; @@ -823,7 +823,7 @@ index 0000000000..b40e361036 + const struct mv3310_chip *chip = to_mv3310_chip(phydev); ++ DECLARE_PHY_INTERFACE_MASK(interfaces); + int err, mactype; -+ ++ +- /* Check that the PHY interface type is compatible */ +- if (!test_bit(phydev->interface, priv->supported_interfaces)) ++ /* In case host didn't provide supported interfaces */ @@ -834,12 +834,12 @@ index 0000000000..b40e361036 ++ priv->supported_interfaces); ++ if (phy_interface_empty(interfaces)) + return -ENODEV; -+ ++ + phydev->mdix_ctrl = ETH_TP_MDI_AUTO; +@@ -687,9 +783,15 @@ static int mv3310_config_init(struct phy_device *phydev) + if (err) + return err; -+ ++ +- mactype = chip->get_mactype(phydev); +- if (mactype < 0) +- return mactype; @@ -852,7 +852,7 @@ index 0000000000..b40e361036 ++ if (err) ++ return err; ++ } -+ ++ + err = chip->init_interface(phydev, mactype); + if (err) { +@@ -1049,6 +1151,8 @@ static const struct mv3310_chip mv3310_type = { @@ -862,7 +862,7 @@ index 0000000000..b40e361036 ++ .set_mactype = mv3310_set_mactype, ++ .select_mactype = mv3310_select_mactype, + .init_interface = mv3310_init_interface, -+ ++ + #ifdef CONFIG_HWMON +@@ -1060,6 +1164,8 @@ static const struct mv3310_chip mv3340_type = { + .has_downshift = mv3310_has_downshift, @@ -871,7 +871,7 @@ index 0000000000..b40e361036 ++ .set_mactype = mv3310_set_mactype, ++ .select_mactype = mv3310_select_mactype, + .init_interface = mv3340_init_interface, -+ ++ + #ifdef CONFIG_HWMON +@@ -1070,6 +1176,8 @@ static const struct mv3310_chip mv3340_type = { + static const struct mv3310_chip mv2110_type = { @@ -880,7 +880,7 @@ index 0000000000..b40e361036 ++ .set_mactype = mv2110_set_mactype, ++ .select_mactype = mv2110_select_mactype, + .init_interface = mv2110_init_interface, -+ ++ + #ifdef CONFIG_HWMON +@@ -1080,6 +1188,8 @@ static const struct mv3310_chip mv2110_type = { + static const struct mv3310_chip mv2111_type = { @@ -889,9 +889,9 @@ index 0000000000..b40e361036 ++ .set_mactype = mv2110_set_mactype, ++ .select_mactype = mv2110_select_mactype, + .init_interface = mv2110_init_interface, -+ ++ + #ifdef CONFIG_HWMON -+-- ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-07-net-phylink-allow-attaching-phy-for-SFP-modules-on-8.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-07-net-phylink-allow-attaching-phy-for-SFP-modules-on-8.patch @@ -933,19 +933,19 @@ index 0000000000..bd9f2b6ae0 +- phy_interface_mode_is_8023z(interface)))) ++ phy_interface_mode_is_8023z(interface) && !pl->sfp_bus))) + return -EINVAL; -+ ++ + if (pl->phydev) +@@ -2347,9 +2347,6 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode, + phylink_an_mode_str(mode), phy_modes(config.interface), + __ETHTOOL_LINK_MODE_MASK_NBITS, support); -+ ++ +- if (phy_interface_mode_is_8023z(iface) && pl->phydev) +- return -EINVAL; +- + changed = !linkmode_equal(pl->supported, support) || + !linkmode_equal(pl->link_config.advertising, + config.advertising); -+-- ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-08-net-sfp-create-destroy-I2C-mdiobus-before-PHY-probe-.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-08-net-sfp-create-destroy-I2C-mdiobus-before-PHY-probe-.patch @@ -993,7 +993,7 @@ index 0000000000..8ce0a3fcd0 + const struct sff_data *type; + size_t i2c_block_size; +@@ -532,9 +533,6 @@ static int sfp_i2c_write(struct sfp *sfp, bool a2, u8 dev_addr, void *buf, -+ ++ + static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c) + { +- struct mii_bus *i2c_mii; @@ -1001,11 +1001,11 @@ index 0000000000..8ce0a3fcd0 +- + if (!i2c_check_functionality(i2c, I2C_FUNC_I2C)) + return -EINVAL; -+ ++ +@@ -542,7 +540,15 @@ static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c) + sfp->read = sfp_i2c_read; + sfp->write = sfp_i2c_write; -+ ++ +- i2c_mii = mdio_i2c_alloc(sfp->dev, i2c); ++ return 0; ++} @@ -1018,11 +1018,11 @@ index 0000000000..8ce0a3fcd0 ++ i2c_mii = mdio_i2c_alloc(sfp->dev, sfp->i2c); + if (IS_ERR(i2c_mii)) + return PTR_ERR(i2c_mii); -+ ++ +@@ -560,6 +566,12 @@ static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c) + return 0; + } -+ ++ ++static void sfp_i2c_mdiobus_destroy(struct sfp *sfp) ++{ ++ mdiobus_unregister(sfp->i2c_mii); @@ -1035,7 +1035,7 @@ index 0000000000..8ce0a3fcd0 +@@ -1724,6 +1736,14 @@ static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn) + } + } -+ ++ ++static int sfp_sm_add_mdio_bus(struct sfp *sfp) ++{ ++ if (sfp->mdio_protocol != MDIO_I2C_NONE) @@ -1050,7 +1050,7 @@ index 0000000000..8ce0a3fcd0 +@@ -1739,19 +1759,19 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp) + { + int err = 0; -+ ++ +- switch (sfp->id.base.extended_cc) { +- case SFF8024_ECC_10GBASE_T_SFI: +- case SFF8024_ECC_10GBASE_T_SR: @@ -1060,7 +1060,7 @@ index 0000000000..8ce0a3fcd0 ++ switch (sfp->mdio_protocol) { ++ case MDIO_I2C_NONE: + break; -+ ++ +- default: +- if (sfp->id.base.e1000_base_t) +- err = sfp_sm_probe_phy(sfp, false); @@ -1075,11 +1075,11 @@ index 0000000000..8ce0a3fcd0 ++ + return err; + } -+ ++ +@@ -2073,6 +2093,16 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) + if (sfp->quirk && sfp->quirk->fixup) + sfp->quirk->fixup(sfp); -+ ++ ++ if (sfp->id.base.extended_cc == SFF8024_ECC_10GBASE_T_SFI || ++ sfp->id.base.extended_cc == SFF8024_ECC_10GBASE_T_SR || ++ sfp->id.base.extended_cc == SFF8024_ECC_5GBASE_T || @@ -1092,7 +1092,7 @@ index 0000000000..8ce0a3fcd0 ++ + return 0; + } -+ ++ +@@ -2244,6 +2274,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event) + sfp_module_stop(sfp->sfp_bus); + if (sfp->mod_phy) @@ -1122,7 +1122,7 @@ index 0000000000..8ce0a3fcd0 +@@ -11,6 +11,12 @@ struct device; + struct i2c_adapter; + struct mii_bus; -+ ++ ++enum mdio_i2c_proto { ++ MDIO_I2C_NONE, ++ MDIO_I2C_MARVELL_C22, @@ -1130,9 +1130,9 @@ index 0000000000..8ce0a3fcd0 ++}; ++ + struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c); -+ ++ + #endif -+-- ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-09-net-phy-mdio-i2c-support-I2C-MDIO-protocol-for-RollB.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-09-net-phy-mdio-i2c-support-I2C-MDIO-protocol-for-RollB.patch @@ -1189,13 +1189,13 @@ index 0000000000..2806501dd0 + #include <linux/mdio/mdio-i2c.h> + #include <linux/phy.h> ++#include <linux/sfp.h> -+ ++ + /* + * I2C bus addresses 0x50 and 0x51 are normally an EEPROM, which is +@@ -28,7 +30,7 @@ static unsigned int i2c_mii_phy_addr(int phy_id) + return phy_id + 0x40; + } -+ ++ +-static int i2c_mii_read(struct mii_bus *bus, int phy_id, int reg) ++static int i2c_mii_read_default(struct mii_bus *bus, int phy_id, int reg) + { @@ -1204,7 +1204,7 @@ index 0000000000..2806501dd0 +@@ -62,7 +64,8 @@ static int i2c_mii_read(struct mii_bus *bus, int phy_id, int reg) + return data[0] << 8 | data[1]; + } -+ ++ +-static int i2c_mii_write(struct mii_bus *bus, int phy_id, int reg, u16 val) ++static int i2c_mii_write_default(struct mii_bus *bus, int phy_id, int reg, ++ u16 val) @@ -1214,7 +1214,7 @@ index 0000000000..2806501dd0 +@@ -91,9 +94,288 @@ static int i2c_mii_write(struct mii_bus *bus, int phy_id, int reg, u16 val) + return ret < 0 ? ret : 0; + } -+ ++ +-struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c) ++/* RollBall SFPs do not access internal PHY via I2C address 0x56, but ++ * instead via address 0x51, when SFP page is set to 0x03 and password to @@ -1498,17 +1498,17 @@ index 0000000000..2806501dd0 + { + struct mii_bus *mii; ++ int ret; -+ ++ + if (!i2c_check_functionality(i2c, I2C_FUNC_I2C)) + return ERR_PTR(-EINVAL); +@@ -104,10 +386,28 @@ struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c) -+ ++ + snprintf(mii->id, MII_BUS_ID_SIZE, "i2c:%s", dev_name(parent)); + mii->parent = parent; +- mii->read = i2c_mii_read; +- mii->write = i2c_mii_write; + mii->priv = i2c; -+ ++ ++ switch (protocol) { ++ case MDIO_I2C_ROLLBALL: ++ ret = i2c_mii_init_rollball(i2c); @@ -1539,12 +1539,12 @@ index 0000000000..2806501dd0 +@@ -548,7 +548,7 @@ static int sfp_i2c_mdiobus_create(struct sfp *sfp) + struct mii_bus *i2c_mii; + int ret; -+ ++ +- i2c_mii = mdio_i2c_alloc(sfp->dev, sfp->i2c); ++ i2c_mii = mdio_i2c_alloc(sfp->dev, sfp->i2c, sfp->mdio_protocol); + if (IS_ERR(i2c_mii)) + return PTR_ERR(i2c_mii); -+ ++ +@@ -1770,6 +1770,10 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp) + case MDIO_I2C_C45: + err = sfp_sm_probe_phy(sfp, true); @@ -1554,7 +1554,7 @@ index 0000000000..2806501dd0 ++ err = -EOPNOTSUPP; ++ break; + } -+ ++ + return err; +diff --git a/include/linux/mdio/mdio-i2c.h b/include/linux/mdio/mdio-i2c.h +index 3bde1a555a49..65b550a6fc32 100644 @@ -1566,13 +1566,13 @@ index 0000000000..2806501dd0 + MDIO_I2C_C45, ++ MDIO_I2C_ROLLBALL, + }; -+ ++ +-struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c); ++struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c, ++ enum mdio_i2c_proto protocol); -+ ++ + #endif -+-- ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-10-net-sfp-add-support-for-multigig-RollBall-transceive.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-10-net-sfp-add-support-for-multigig-RollBall-transceive.patch @@ -1611,7 +1611,7 @@ index 0000000000..1d775870a1 +@@ -130,6 +130,12 @@ bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id) + } + } -+ ++ ++ if (((!memcmp(id->base.vendor_name, "OEM ", 16) || ++ !memcmp(id->base.vendor_name, "Turris ", 16)) && ++ (!memcmp(id->base.vendor_pn, "SFP-10G-T ", 16) || @@ -1632,9 +1632,9 @@ index 0000000000..1d775870a1 ++#define T_WAIT_ROLLBALL msecs_to_jiffies(25000) + #define T_START_UP msecs_to_jiffies(300) + #define T_START_UP_BAD_GPON msecs_to_jiffies(60000) -+ ++ +@@ -205,8 +206,11 @@ static const enum gpiod_flags gpio_flags[] = { -+ ++ + /* SFP modules appear to always have their PHY configured for bus address + * 0x56 (which with mdio-i2c, translates to a PHY address of 22). ++ * RollBall SFPs access phy via SFP Enhanced Digital Diagnostic Interface @@ -1643,7 +1643,7 @@ index 0000000000..1d775870a1 +-#define SFP_PHY_ADDR 22 ++#define SFP_PHY_ADDR 22 ++#define SFP_PHY_ADDR_ROLLBALL 17 -+ ++ + struct sff_data { + unsigned int gpios; +@@ -252,6 +256,7 @@ struct sfp { @@ -1652,18 +1652,18 @@ index 0000000000..1d775870a1 + unsigned int module_t_start_up; ++ unsigned int module_t_wait; + bool tx_fault_ignore; -+ ++ + const struct sfp_quirk *quirk; +@@ -1636,12 +1641,12 @@ static void sfp_sm_phy_detach(struct sfp *sfp) + sfp->mod_phy = NULL; + } -+ ++ +-static int sfp_sm_probe_phy(struct sfp *sfp, bool is_c45) ++static int sfp_sm_probe_phy(struct sfp *sfp, int addr, bool is_c45) + { + struct phy_device *phy; + int err; -+ ++ +- phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45); ++ phy = get_phy_device(sfp->i2c_mii, addr, is_c45); + if (phy == ERR_PTR(-ENODEV)) @@ -1671,27 +1671,27 @@ index 0000000000..1d775870a1 + if (IS_ERR(phy)) { +@@ -1764,15 +1769,15 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp) + break; -+ ++ + case MDIO_I2C_MARVELL_C22: +- err = sfp_sm_probe_phy(sfp, false); ++ err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR, false); + break; -+ ++ + case MDIO_I2C_C45: +- err = sfp_sm_probe_phy(sfp, true); ++ err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR, true); + break; -+ ++ + case MDIO_I2C_ROLLBALL: +- err = -EOPNOTSUPP; ++ err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR_ROLLBALL, true); + break; + } -+ ++ +@@ -2097,7 +2102,20 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) + if (sfp->quirk && sfp->quirk->fixup) + sfp->quirk->fixup(sfp); -+ ++ +- if (sfp->id.base.extended_cc == SFF8024_ECC_10GBASE_T_SFI || ++ sfp->module_t_wait = T_WAIT; ++ @@ -1711,7 +1711,7 @@ index 0000000000..1d775870a1 + sfp->id.base.extended_cc == SFF8024_ECC_5GBASE_T || + sfp->id.base.extended_cc == SFF8024_ECC_2_5GBASE_T) +@@ -2303,9 +2321,10 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event) -+ ++ + /* We need to check the TX_FAULT state, which is not defined + * while TX_DISABLE is asserted. The earliest we want to do +- * anything (such as probe for a PHY) is 50ms. @@ -1721,7 +1721,7 @@ index 0000000000..1d775870a1 +- sfp_sm_next(sfp, SFP_S_WAIT, T_WAIT); ++ sfp_sm_next(sfp, SFP_S_WAIT, sfp->module_t_wait); + break; -+ ++ + case SFP_S_WAIT: +@@ -2319,8 +2338,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event) + * deasserting. @@ -1733,8 +1733,8 @@ index 0000000000..1d775870a1 ++ timeout -= sfp->module_t_wait; + else + timeout = 1; -+ -+-- ++ ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-11-net-sfp-augment-SFP-parsing-with-phy_interface_t-bit.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-11-net-sfp-augment-SFP-parsing-with-phy_interface_t-bit.patch @@ -1780,7 +1780,7 @@ index 0000000000..bda0114281 +--- a/drivers/net/phy/marvell-88x2222.c ++++ b/drivers/net/phy/marvell-88x2222.c +@@ -478,6 +478,7 @@ static int mv2222_config_init(struct phy_device *phydev) -+ ++ + static int mv2222_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) + { ++ DECLARE_PHY_INTERFACE_MASK(interfaces); @@ -1790,18 +1790,18 @@ index 0000000000..bda0114281 +@@ -489,7 +490,7 @@ static int mv2222_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) + priv = (struct mv2222_data *)phydev->priv; + dev = &phydev->mdio.dev; -+ ++ +- sfp_parse_support(phydev->sfp_bus, id, sfp_supported); ++ sfp_parse_support(phydev->sfp_bus, id, sfp_supported, interfaces); + sfp_interface = sfp_select_interface(phydev->sfp_bus, sfp_supported); -+ ++ + dev_info(dev, "%s SFP module inserted\n", phy_modes(sfp_interface)); +diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c +index 4d726ee03ce2..288befc9f44b 100644 +--- a/drivers/net/phy/marvell.c ++++ b/drivers/net/phy/marvell.c +@@ -2806,6 +2806,7 @@ static int marvell_probe(struct phy_device *phydev) -+ ++ + static int m88e1510_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) + { ++ DECLARE_PHY_INTERFACE_MASK(interfaces); @@ -1809,13 +1809,13 @@ index 0000000000..bda0114281 + phy_interface_t interface; + struct device *dev; +@@ -2817,7 +2818,7 @@ static int m88e1510_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) -+ ++ + dev = &phydev->mdio.dev; -+ ++ +- sfp_parse_support(phydev->sfp_bus, id, supported); ++ sfp_parse_support(phydev->sfp_bus, id, supported, interfaces); + interface = sfp_select_interface(phydev->sfp_bus, supported); -+ ++ + dev_info(dev, "%s SFP module inserted\n", phy_modes(interface)); +diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c +index b16e67b352bf..c07d51907418 100644 @@ -1827,18 +1827,18 @@ index 0000000000..bda0114281 + __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; ++ DECLARE_PHY_INTERFACE_MASK(interfaces); + phy_interface_t iface; -+ ++ +- sfp_parse_support(phydev->sfp_bus, id, support); ++ sfp_parse_support(phydev->sfp_bus, id, support, interfaces); + iface = sfp_select_interface(phydev->sfp_bus, support); -+ ++ + if (iface != PHY_INTERFACE_MODE_10GBASER) { +diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c +index f1fad9e18d03..7d0b7a2e69d8 100644 +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -77,6 +77,7 @@ struct phylink { -+ ++ + struct sfp_bus *sfp_bus; + bool sfp_may_have_phy; ++ DECLARE_PHY_INTERFACE_MASK(sfp_interfaces); @@ -1847,13 +1847,13 @@ index 0000000000..bda0114281 + }; +@@ -2385,7 +2386,8 @@ static int phylink_sfp_module_insert(void *upstream, + ASSERT_RTNL(); -+ ++ + linkmode_zero(support); +- sfp_parse_support(pl->sfp_bus, id, support); ++ phy_interface_zero(pl->sfp_interfaces); ++ sfp_parse_support(pl->sfp_bus, id, support, pl->sfp_interfaces); + pl->sfp_port = sfp_parse_port(pl->sfp_bus, id, support); -+ ++ + /* If this module may have a PHY connecting later, defer until later */ +diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c +index 22dba5895ef6..98af41843cce 100644 @@ -1877,7 +1877,7 @@ index 0000000000..bda0114281 + __ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = { 0, }; +@@ -177,27 +179,41 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, + } -+ ++ + /* Set ethtool support from the compliance fields. */ +- if (id->base.e10g_base_sr) ++ if (id->base.e10g_base_sr) { @@ -1912,7 +1912,7 @@ index 0000000000..bda0114281 ++ __set_bit(PHY_INTERFACE_MODE_1000BASEX, interfaces); ++ __set_bit(PHY_INTERFACE_MODE_SGMII, interfaces); + } -+ ++ + /* 1000Base-PX or 1000Base-BX10 */ + if ((id->base.e_base_px || id->base.e_base_bx10) && +- br_min <= 1300 && br_max >= 1200) @@ -1920,7 +1920,7 @@ index 0000000000..bda0114281 + phylink_set(modes, 1000baseX_Full); ++ __set_bit(PHY_INTERFACE_MODE_1000BASEX, interfaces); ++ } -+ ++ + /* 100Base-FX, 100Base-LX, 100Base-PX, 100Base-BX10 */ + if (id->base.e100_base_fx || id->base.e100_base_lx) +@@ -210,21 +226,30 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, @@ -1957,7 +1957,7 @@ index 0000000000..bda0114281 ++ __set_bit(PHY_INTERFACE_MODE_10GBASER, interfaces); + } + } -+ ++ +@@ -249,12 +274,15 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, + case SFF8024_ECC_10GBASE_T_SFI: + case SFF8024_ECC_10GBASE_T_SR: @@ -1989,7 +1989,7 @@ index 0000000000..bda0114281 ++ __set_bit(PHY_INTERFACE_MODE_1000BASEX, interfaces); ++ } + } -+ ++ + /* If we haven't discovered any modes that this module supports, try +@@ -283,14 +315,18 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, + * 2500BASE-X, so we allow some slack here. @@ -2006,20 +2006,20 @@ index 0000000000..bda0114281 ++ __set_bit(PHY_INTERFACE_MODE_2500BASEX, interfaces); ++ } + } -+ ++ + if (bus->sfp_quirk && bus->sfp_quirk->modes) +- bus->sfp_quirk->modes(id, modes); ++ bus->sfp_quirk->modes(id, modes, interfaces); -+ ++ + linkmode_or(support, support, modes); -+ ++ +diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c +index 49e69f1d9b1b..02c55fdae8be 100644 +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -333,13 +333,15 @@ static void sfp_fixup_halny_gsfp(struct sfp *sfp) + } -+ ++ + static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id, +- unsigned long *modes) ++ unsigned long *modes, unsigned long *interfaces) @@ -2027,7 +2027,7 @@ index 0000000000..bda0114281 + linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, modes); ++ __set_bit(PHY_INTERFACE_MODE_2500BASEX, interfaces); + } -+ ++ + static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id, +- unsigned long *modes) ++ unsigned long *modes, @@ -2041,7 +2041,7 @@ index 0000000000..bda0114281 + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, modes); ++ __set_bit(PHY_INTERFACE_MODE_1000BASEX, interfaces); + } -+ ++ + static const struct sfp_quirk sfp_quirks[] = { +diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h +index 7ad06deae76c..6cf1643214d3 100644 @@ -2056,7 +2056,7 @@ index 0000000000..bda0114281 ++ unsigned long *interfaces); + void (*fixup)(struct sfp *sfp); + }; -+ ++ +diff --git a/include/linux/sfp.h b/include/linux/sfp.h +index 302094b855fb..d1f343853b6c 100644 +--- a/include/linux/sfp.h @@ -2069,9 +2069,9 @@ index 0000000000..bda0114281 ++ unsigned long *support, unsigned long *interfaces); + phy_interface_t sfp_select_interface(struct sfp_bus *bus, + unsigned long *link_modes); -+ ++ +@@ -568,7 +568,8 @@ static inline bool sfp_may_have_phy(struct sfp_bus *bus, -+ ++ + static inline void sfp_parse_support(struct sfp_bus *bus, + const struct sfp_eeprom_id *id, +- unsigned long *support) @@ -2079,8 +2079,8 @@ index 0000000000..bda0114281 ++ unsigned long *interfaces) + { + } -+ -+-- ++ ++-- +2.35.1 + diff --git a/target/linux/mvebu/patches-5.15/706-TurrisSFP-12-net-phylink-use-phy_interface_t-bitmaps-for-optical-.patch b/target/linux/mvebu/patches-5.15/706-TurrisSFP-12-net-phylink-use-phy_interface_t-bitmaps-for-optical-.patch @@ -2112,7 +2112,7 @@ index 0000000000..c1adcacf27 +@@ -2296,6 +2296,42 @@ static void phylink_sfp_detach(void *upstream, struct sfp_bus *bus) + pl->netdev->sfp_bus = NULL; + } -+ ++ ++static const phy_interface_t phylink_sfp_interface_preference[] = { ++ PHY_INTERFACE_MODE_USXGMII, ++ PHY_INTERFACE_MODE_10GBASER, @@ -2155,7 +2155,7 @@ index 0000000000..c1adcacf27 +@@ -2377,25 +2413,102 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode, + return ret; + } -+ ++ ++static int phylink_sfp_config_nophy(struct phylink *pl) ++{ ++ __ETHTOOL_DECLARE_LINK_MODE_MASK(support); @@ -2239,9 +2239,9 @@ index 0000000000..c1adcacf27 + { + struct phylink *pl = upstream; +- unsigned long *support = pl->sfp_support; -+ ++ + ASSERT_RTNL(); -+ ++ +- linkmode_zero(support); ++ linkmode_zero(pl->sfp_support); + phy_interface_zero(pl->sfp_interfaces); @@ -2249,29 +2249,29 @@ index 0000000000..c1adcacf27 +- pl->sfp_port = sfp_parse_port(pl->sfp_bus, id, support); ++ sfp_parse_support(pl->sfp_bus, id, pl->sfp_support, pl->sfp_interfaces); ++ pl->sfp_port = sfp_parse_port(pl->sfp_bus, id, pl->sfp_support); -+ ++ + /* If this module may have a PHY connecting later, defer until later */ + pl->sfp_may_have_phy = sfp_may_have_phy(pl->sfp_bus, id); + if (pl->sfp_may_have_phy) + return 0; -+ ++ +- return phylink_sfp_config(pl, MLO_AN_INBAND, support, support); ++ return phylink_sfp_config_nophy(pl); + } -+ ++ + static int phylink_sfp_module_start(void *upstream) +@@ -2414,8 +2527,7 @@ static int phylink_sfp_module_start(void *upstream) + if (!pl->sfp_may_have_phy) + return 0; -+ ++ +- return phylink_sfp_config(pl, MLO_AN_INBAND, +- pl->sfp_support, pl->sfp_support); ++ return phylink_sfp_config_nophy(pl); + } -+ ++ + static void phylink_sfp_module_stop(void *upstream) +@@ -2867,13 +2979,11 @@ EXPORT_SYMBOL_GPL(phylink_mii_c45_pcs_get_state); -+ ++ + static int __init phylink_init(void) + { +- __set_bit(PHY_INTERFACE_MODE_USXGMII, phylink_sfp_interfaces); @@ -2286,12 +2286,12 @@ index 0000000000..c1adcacf27 ++ for (i = 0; i < ARRAY_SIZE(phylink_sfp_interface_preference); ++i) ++ __set_bit(phylink_sfp_interface_preference[i], ++ phylink_sfp_interfaces); -+ ++ + return 0; + } -+-- ++-- +2.35.1 + --- +-- 2.35.1 -- GitLab