]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: dsa: realtek: provide own phylink MAC operations
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Sun, 28 Apr 2024 10:33:11 +0000 (11:33 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 30 Apr 2024 11:50:01 +0000 (13:50 +0200)
Convert realtek to provide its own phylink MAC operations, thus
avoiding the shim layer in DSA's port.c. We need to provide a stub for
the mandatory mac_config() method for rtl8366rb.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/E1s11qJ-00AHi0-Kk@rmk-PC.armlinux.org.uk
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/dsa/realtek/realtek.h
drivers/net/dsa/realtek/rtl8365mb.c
drivers/net/dsa/realtek/rtl8366rb.c
drivers/net/dsa/realtek/rtl83xx.c

index e0b1aa01337b3424f6b57d588211ab31f005f8d1..a1b2e0b529d54831dd5954946cd141d5b2679977 100644 (file)
@@ -17,6 +17,7 @@
 #define REALTEK_HW_STOP_DELAY          25      /* msecs */
 #define REALTEK_HW_START_DELAY         100     /* msecs */
 
+struct phylink_mac_ops;
 struct realtek_ops;
 struct dentry;
 struct inode;
@@ -117,6 +118,7 @@ struct realtek_ops {
 struct realtek_variant {
        const struct dsa_switch_ops *ds_ops;
        const struct realtek_ops *ops;
+       const struct phylink_mac_ops *phylink_mac_ops;
        unsigned int clk_delay;
        u8 cmd_read;
        u8 cmd_write;
index 12665a8a34126efb356e0f1a71e8866780e84166..b9674f68b756a5e3bff6a37344dab7c46ab00924 100644 (file)
@@ -1048,11 +1048,13 @@ static void rtl8365mb_phylink_get_caps(struct dsa_switch *ds, int port,
                phy_interface_set_rgmii(config->supported_interfaces);
 }
 
-static void rtl8365mb_phylink_mac_config(struct dsa_switch *ds, int port,
+static void rtl8365mb_phylink_mac_config(struct phylink_config *config,
                                         unsigned int mode,
                                         const struct phylink_link_state *state)
 {
-       struct realtek_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct realtek_priv *priv = dp->ds->priv;
+       u8 port = dp->index;
        int ret;
 
        if (mode != MLO_AN_PHY && mode != MLO_AN_FIXED) {
@@ -1076,13 +1078,15 @@ static void rtl8365mb_phylink_mac_config(struct dsa_switch *ds, int port,
         */
 }
 
-static void rtl8365mb_phylink_mac_link_down(struct dsa_switch *ds, int port,
+static void rtl8365mb_phylink_mac_link_down(struct phylink_config *config,
                                            unsigned int mode,
                                            phy_interface_t interface)
 {
-       struct realtek_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct realtek_priv *priv = dp->ds->priv;
        struct rtl8365mb_port *p;
        struct rtl8365mb *mb;
+       u8 port = dp->index;
        int ret;
 
        mb = priv->chip_data;
@@ -1101,16 +1105,18 @@ static void rtl8365mb_phylink_mac_link_down(struct dsa_switch *ds, int port,
        }
 }
 
-static void rtl8365mb_phylink_mac_link_up(struct dsa_switch *ds, int port,
+static void rtl8365mb_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,
+                                         int speed, int duplex, bool tx_pause,
                                          bool rx_pause)
 {
-       struct realtek_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct realtek_priv *priv = dp->ds->priv;
        struct rtl8365mb_port *p;
        struct rtl8365mb *mb;
+       u8 port = dp->index;
        int ret;
 
        mb = priv->chip_data;
@@ -2106,15 +2112,18 @@ static int rtl8365mb_detect(struct realtek_priv *priv)
        return 0;
 }
 
+static const struct phylink_mac_ops rtl8365mb_phylink_mac_ops = {
+       .mac_config = rtl8365mb_phylink_mac_config,
+       .mac_link_down = rtl8365mb_phylink_mac_link_down,
+       .mac_link_up = rtl8365mb_phylink_mac_link_up,
+};
+
 static const struct dsa_switch_ops rtl8365mb_switch_ops = {
        .get_tag_protocol = rtl8365mb_get_tag_protocol,
        .change_tag_protocol = rtl8365mb_change_tag_protocol,
        .setup = rtl8365mb_setup,
        .teardown = rtl8365mb_teardown,
        .phylink_get_caps = rtl8365mb_phylink_get_caps,
-       .phylink_mac_config = rtl8365mb_phylink_mac_config,
-       .phylink_mac_link_down = rtl8365mb_phylink_mac_link_down,
-       .phylink_mac_link_up = rtl8365mb_phylink_mac_link_up,
        .port_stp_state_set = rtl8365mb_port_stp_state_set,
        .get_strings = rtl8365mb_get_strings,
        .get_ethtool_stats = rtl8365mb_get_ethtool_stats,
@@ -2136,6 +2145,7 @@ static const struct realtek_ops rtl8365mb_ops = {
 const struct realtek_variant rtl8365mb_variant = {
        .ds_ops = &rtl8365mb_switch_ops,
        .ops = &rtl8365mb_ops,
+       .phylink_mac_ops = &rtl8365mb_phylink_mac_ops,
        .clk_delay = 10,
        .cmd_read = 0xb9,
        .cmd_write = 0xb8,
index 9244c63e8289c5fa0bb15096d6b890927a5cb8b5..9e821b42e5f37c8c15ed2266409f35b97b0a4233 100644 (file)
@@ -1305,11 +1305,19 @@ static void rtl8366rb_phylink_get_caps(struct dsa_switch *ds, int port,
 }
 
 static void
-rtl8366rb_mac_link_up(struct dsa_switch *ds, int port, unsigned int mode,
-                     phy_interface_t interface, struct phy_device *phydev,
+rtl8366rb_mac_config(struct phylink_config *config, unsigned int mode,
+                    const struct phylink_link_state *state)
+{
+}
+
+static void
+rtl8366rb_mac_link_up(struct phylink_config *config, struct phy_device *phydev,
+                     unsigned int mode, phy_interface_t interface,
                      int speed, int duplex, bool tx_pause, bool rx_pause)
 {
-       struct realtek_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct realtek_priv *priv = dp->ds->priv;
+       int port = dp->index;
        unsigned int val;
        int ret;
 
@@ -1375,10 +1383,12 @@ rtl8366rb_mac_link_up(struct dsa_switch *ds, int port, unsigned int mode,
 }
 
 static void
-rtl8366rb_mac_link_down(struct dsa_switch *ds, int port, unsigned int mode,
+rtl8366rb_mac_link_down(struct phylink_config *config, unsigned int mode,
                        phy_interface_t interface)
 {
-       struct realtek_priv *priv = ds->priv;
+       struct dsa_port *dp = dsa_phylink_to_port(config);
+       struct realtek_priv *priv = dp->ds->priv;
+       int port = dp->index;
        int ret;
 
        if (port != priv->cpu_port)
@@ -2028,12 +2038,16 @@ static int rtl8366rb_detect(struct realtek_priv *priv)
        return 0;
 }
 
+static const struct phylink_mac_ops rtl8366rb_phylink_mac_ops = {
+       .mac_config = rtl8366rb_mac_config,
+       .mac_link_down = rtl8366rb_mac_link_down,
+       .mac_link_up = rtl8366rb_mac_link_up,
+};
+
 static const struct dsa_switch_ops rtl8366rb_switch_ops = {
        .get_tag_protocol = rtl8366_get_tag_protocol,
        .setup = rtl8366rb_setup,
        .phylink_get_caps = rtl8366rb_phylink_get_caps,
-       .phylink_mac_link_up = rtl8366rb_mac_link_up,
-       .phylink_mac_link_down = rtl8366rb_mac_link_down,
        .get_strings = rtl8366_get_strings,
        .get_ethtool_stats = rtl8366_get_ethtool_stats,
        .get_sset_count = rtl8366_get_sset_count,
@@ -2071,6 +2085,7 @@ static const struct realtek_ops rtl8366rb_ops = {
 const struct realtek_variant rtl8366rb_variant = {
        .ds_ops = &rtl8366rb_switch_ops,
        .ops = &rtl8366rb_ops,
+       .phylink_mac_ops = &rtl8366rb_phylink_mac_ops,
        .clk_delay = 10,
        .cmd_read = 0xa9,
        .cmd_write = 0xa8,
index a9c1702431efba3df3e524714f0569f394b801d4..35709a1756ae06838256fe1a6d3096646bb25a9e 100644 (file)
@@ -236,6 +236,7 @@ int rtl83xx_register_switch(struct realtek_priv *priv)
        ds->priv = priv;
        ds->dev = priv->dev;
        ds->ops = priv->variant->ds_ops;
+       ds->phylink_mac_ops = priv->variant->phylink_mac_ops;
        ds->num_ports = priv->num_ports;
 
        ret = dsa_register_switch(ds);