]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: dsa: 6.18: adjust mac ops and callbacks
authorJonas Jelonek <jelonek.jonas@gmail.com>
Sun, 30 Nov 2025 12:34:33 +0000 (12:34 +0000)
committerRobert Marko <robimarko@gmail.com>
Sun, 29 Mar 2026 16:08:21 +0000 (18:08 +0200)
Between 6.12 and 6.18, several DSA switch ops have changed.
phylink_mac_* ops were moved out of dsa_switch_ops into dsa_switch using
phylink_mac_ops. Add new definitions for that and adjust the callbacks
accordingly to work with the different signatures.

get_mac_eee() has been dropped and support_eee() was added.

remove_new() has been dropped completely, allowing us to use remove()
again.

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21181
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/dsa.c
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl83xx.h

index b946558513049884e2364061c2361154fc42d5f6..0c5e9f3f384a1dc77d2b4a481aac907203a25004 100644 (file)
@@ -1632,6 +1632,7 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
        switch (soc_info.family) {
        case RTL8380_FAMILY_ID:
                priv->ds->ops = &rtldsa_83xx_switch_ops;
+               priv->ds->phylink_mac_ops = &rtldsa_83xx_phylink_mac_ops;
                priv->cpu_port = RTL838X_CPU_PORT;
                priv->port_mask = 0x1f;
                priv->port_width = 1;
@@ -1642,6 +1643,7 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
                break;
        case RTL8390_FAMILY_ID:
                priv->ds->ops = &rtldsa_83xx_switch_ops;
+               priv->ds->phylink_mac_ops = &rtldsa_83xx_phylink_mac_ops;
                priv->cpu_port = RTL839X_CPU_PORT;
                priv->port_mask = 0x3f;
                priv->port_width = 2;
@@ -1652,6 +1654,7 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
                break;
        case RTL9300_FAMILY_ID:
                priv->ds->ops = &rtldsa_93xx_switch_ops;
+               priv->ds->phylink_mac_ops = &rtldsa_93xx_phylink_mac_ops;
                priv->cpu_port = RTL930X_CPU_PORT;
                priv->port_mask = 0x1f;
                priv->port_width = 1;
@@ -1663,6 +1666,7 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
                break;
        case RTL9310_FAMILY_ID:
                priv->ds->ops = &rtldsa_93xx_switch_ops;
+               priv->ds->phylink_mac_ops = &rtldsa_93xx_phylink_mac_ops;
                priv->cpu_port = RTL931X_CPU_PORT;
                priv->port_mask = 0x3f;
                priv->port_width = 2;
index ca3252c1ed91eddfce62e1dec9104ba76fa2f0bb..86a8fc52be9f6ff5a4e331f99a0fa62984340718 100644 (file)
@@ -285,13 +285,13 @@ static int rtldsa_93xx_setup(struct dsa_switch *ds)
        return 0;
 }
 
-static struct phylink_pcs *rtldsa_phylink_mac_select_pcs(struct dsa_switch *ds,
-                                                        int port,
+static struct phylink_pcs *rtldsa_phylink_mac_select_pcs(struct phylink_config *config,
                                                         phy_interface_t interface)
 {
-       struct rtl838x_switch_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct rtl838x_switch_priv *priv = dp->ds->priv;
 
-       return priv->ports[port].pcs;
+       return priv->ports[dp->index].pcs;
 }
 
 static void rtldsa_83xx_phylink_get_caps(struct dsa_switch *ds, int port,
@@ -336,12 +336,13 @@ static void rtldsa_93xx_phylink_get_caps(struct dsa_switch *ds, int port,
        __set_bit(PHY_INTERFACE_MODE_10G_QXGMII, config->supported_interfaces);
 }
 
-static void rtldsa_83xx_phylink_mac_config(struct dsa_switch *ds, int port,
+static void rtldsa_83xx_phylink_mac_config(struct phylink_config *config,
                                           unsigned int mode,
                                           const struct phylink_link_state *state)
 {
-       struct dsa_port *dp = dsa_to_port(ds, port);
-       struct rtl838x_switch_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct rtl838x_switch_priv *priv = dp->ds->priv;
+       int port = dp->index;
        u32 mcr;
 
        pr_debug("%s port %d, mode %x\n", __func__, port, mode);
@@ -367,11 +368,13 @@ static void rtldsa_83xx_phylink_mac_config(struct dsa_switch *ds, int port,
        sw_w32(mcr, priv->r->mac_force_mode_ctrl(port));
 }
 
-static void rtldsa_93xx_phylink_mac_config(struct dsa_switch *ds, int port,
+static void rtldsa_93xx_phylink_mac_config(struct phylink_config *config,
                                           unsigned int mode,
                                           const struct phylink_link_state *state)
 {
-       struct rtl838x_switch_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct rtl838x_switch_priv *priv = dp->ds->priv;
+       int port = dp->index;
 
        /* Nothing to be done for the CPU-port */
        if (port == priv->cpu_port)
@@ -381,11 +384,13 @@ static void rtldsa_93xx_phylink_mac_config(struct dsa_switch *ds, int port,
        sw_w32(0, priv->r->mac_force_mode_ctrl(port));
 }
 
-static void rtldsa_83xx_phylink_mac_link_down(struct dsa_switch *ds, int port,
+static void rtldsa_83xx_phylink_mac_link_down(struct phylink_config *config,
                                              unsigned int mode,
                                              phy_interface_t interface)
 {
-       struct rtl838x_switch_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct rtl838x_switch_priv *priv = dp->ds->priv;
+       int port = dp->index;
        int mask = 0;
 
        /* Stop TX/RX to port */
@@ -396,11 +401,13 @@ static void rtldsa_83xx_phylink_mac_link_down(struct dsa_switch *ds, int port,
        sw_w32_mask(mask, 0, priv->r->mac_force_mode_ctrl(port));
 }
 
-static void rtldsa_93xx_phylink_mac_link_down(struct dsa_switch *ds, int port,
+static void rtldsa_93xx_phylink_mac_link_down(struct phylink_config *config,
                                              unsigned int mode,
                                              phy_interface_t interface)
 {
-       struct rtl838x_switch_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct rtl838x_switch_priv *priv = dp->ds->priv;
+       int port = dp->index;
        u32 v = 0;
 
        /* Stop TX/RX to port */
@@ -414,15 +421,16 @@ static void rtldsa_93xx_phylink_mac_link_down(struct dsa_switch *ds, int port,
        sw_w32_mask(v, 0, priv->r->mac_force_mode_ctrl(port));
 }
 
-static void rtldsa_83xx_phylink_mac_link_up(struct dsa_switch *ds, int port,
+static void rtldsa_83xx_phylink_mac_link_up(struct phylink_config *config,
+                                           struct phy_device *phydev,
                                            unsigned int mode,
                                            phy_interface_t interface,
-                                           struct phy_device *phydev,
                                            int speed, int duplex,
                                            bool tx_pause, bool rx_pause)
 {
-       struct dsa_port *dp = dsa_to_port(ds, port);
-       struct rtl838x_switch_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct rtl838x_switch_priv *priv = dp->ds->priv;
+       int port = dp->index;
        u32 mcr, spdsel;
 
        if (speed == SPEED_1000)
@@ -477,15 +485,16 @@ static void rtldsa_83xx_phylink_mac_link_up(struct dsa_switch *ds, int port,
        sw_w32_mask(0, 0x3, priv->r->mac_port_ctrl(port));
 }
 
-static void rtldsa_93xx_phylink_mac_link_up(struct dsa_switch *ds, int port,
+static void rtldsa_93xx_phylink_mac_link_up(struct phylink_config *config,
+                                           struct phy_device *phydev,
                                            unsigned int mode,
                                            phy_interface_t interface,
-                                           struct phy_device *phydev,
                                            int speed, int duplex,
                                            bool tx_pause, bool rx_pause)
 {
-       struct dsa_port *dp = dsa_to_port(ds, port);
-       struct rtl838x_switch_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct rtl838x_switch_priv *priv = dp->ds->priv;
+       int port = dp->index;
        u32 mcr, spdsel;
 
        if (speed == SPEED_10000)
@@ -1102,6 +1111,14 @@ static void rtldsa_port_disable(struct dsa_switch *ds, int port)
        priv->ports[port].enable = false;
 }
 
+static bool rtldsa_support_eee(struct dsa_switch *ds, int port)
+{
+       struct rtl838x_switch_priv *priv = ds->priv;
+
+       /* TODO: do this better */
+       return (priv->ports[port].phy != 0);
+}
+
 static int rtldsa_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
 {
        struct rtl838x_switch_priv *priv = ds->priv;
@@ -1121,20 +1138,6 @@ static int rtldsa_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_ke
        return 0;
 }
 
-static int rtldsa_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *eee)
-{
-       /*
-        * Until kernel 6.6 the Realtek device specific get_mac_eee() functions filled many
-        * fields of the eee structure manually. That came from the fact, that the phy
-        * driver could not report EEE capabilities on its own. Upstream will replace this
-        * function with a simple boolean support_eee() getter starting from 6.14. That only
-        * checks if a port can provide EEE or not. In the best case it can be replaced with
-        * dsa_supports_eee() in the future. For now align to other upstream DSA drivers.
-        */
-
-       return 0;
-}
-
 static int rtldsa_set_ageing_time(struct dsa_switch *ds, unsigned int msec)
 {
        struct rtl838x_switch_priv *priv = ds->priv;
@@ -2620,6 +2623,13 @@ unlock:
        return ret;
 }
 
+const struct phylink_mac_ops rtldsa_83xx_phylink_mac_ops = {
+       .mac_select_pcs         = rtldsa_phylink_mac_select_pcs,
+       .mac_config             = rtldsa_83xx_phylink_mac_config,
+       .mac_link_down          = rtldsa_83xx_phylink_mac_link_down,
+       .mac_link_up            = rtldsa_83xx_phylink_mac_link_up,
+};
+
 const struct dsa_switch_ops rtldsa_83xx_switch_ops = {
        .get_tag_protocol       = rtldsa_get_tag_protocol,
        .setup                  = rtldsa_83xx_setup,
@@ -2628,10 +2638,6 @@ const struct dsa_switch_ops rtldsa_83xx_switch_ops = {
        .phy_write              = rtldsa_phy_write,
 
        .phylink_get_caps       = rtldsa_83xx_phylink_get_caps,
-       .phylink_mac_config     = rtldsa_83xx_phylink_mac_config,
-       .phylink_mac_link_down  = rtldsa_83xx_phylink_mac_link_down,
-       .phylink_mac_link_up    = rtldsa_83xx_phylink_mac_link_up,
-       .phylink_mac_select_pcs = rtldsa_phylink_mac_select_pcs,
 
        .get_strings            = rtldsa_get_strings,
        .get_ethtool_stats      = rtldsa_get_ethtool_stats,
@@ -2646,7 +2652,7 @@ const struct dsa_switch_ops rtldsa_83xx_switch_ops = {
        .port_enable            = rtldsa_port_enable,
        .port_disable           = rtldsa_port_disable,
 
-       .get_mac_eee            = rtldsa_get_mac_eee,
+       .support_eee            = rtldsa_support_eee,
        .set_mac_eee            = rtldsa_set_mac_eee,
 
        .set_ageing_time        = rtldsa_set_ageing_time,
@@ -2680,6 +2686,13 @@ const struct dsa_switch_ops rtldsa_83xx_switch_ops = {
        .port_bridge_flags      = rtldsa_port_bridge_flags,
 };
 
+const struct phylink_mac_ops rtldsa_93xx_phylink_mac_ops = {
+       .mac_select_pcs         = rtldsa_phylink_mac_select_pcs,
+       .mac_config             = rtldsa_93xx_phylink_mac_config,
+       .mac_link_down          = rtldsa_93xx_phylink_mac_link_down,
+       .mac_link_up            = rtldsa_93xx_phylink_mac_link_up,
+};
+
 const struct dsa_switch_ops rtldsa_93xx_switch_ops = {
        .get_tag_protocol       = rtldsa_get_tag_protocol,
        .setup                  = rtldsa_93xx_setup,
@@ -2688,10 +2701,6 @@ const struct dsa_switch_ops rtldsa_93xx_switch_ops = {
        .phy_write              = rtldsa_phy_write,
 
        .phylink_get_caps       = rtldsa_93xx_phylink_get_caps,
-       .phylink_mac_config     = rtldsa_93xx_phylink_mac_config,
-       .phylink_mac_link_down  = rtldsa_93xx_phylink_mac_link_down,
-       .phylink_mac_link_up    = rtldsa_93xx_phylink_mac_link_up,
-       .phylink_mac_select_pcs = rtldsa_phylink_mac_select_pcs,
 
        .get_strings            = rtldsa_get_strings,
        .get_ethtool_stats      = rtldsa_get_ethtool_stats,
@@ -2706,7 +2715,7 @@ const struct dsa_switch_ops rtldsa_93xx_switch_ops = {
        .port_enable            = rtldsa_port_enable,
        .port_disable           = rtldsa_port_disable,
 
-       .get_mac_eee            = rtldsa_get_mac_eee,
+       .support_eee            = rtldsa_support_eee,
        .set_mac_eee            = rtldsa_set_mac_eee,
 
        .set_ageing_time        = rtldsa_set_ageing_time,
index cf24ecc1befa6c06036e2b37d5c864e077cef499..3a58eecaab49cf90e8d88fe313e8c333f6732341 100644 (file)
@@ -191,6 +191,9 @@ void rtl930x_pie_rule_dump_raw(u32 r[]);
 extern const struct dsa_switch_ops rtldsa_83xx_switch_ops;
 extern const struct dsa_switch_ops rtldsa_93xx_switch_ops;
 
+extern const struct phylink_mac_ops rtldsa_83xx_phylink_mac_ops;
+extern const struct phylink_mac_ops rtldsa_93xx_phylink_mac_ops;
+
 extern const struct rtldsa_config rtldsa_838x_cfg;
 extern const struct rtldsa_config rtldsa_839x_cfg;
 extern const struct rtldsa_config rtldsa_930x_cfg;