]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dsa: microchip: bypass dev_ops for change_mtu() operation
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 12 May 2026 13:06:25 +0000 (15:06 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 May 2026 01:16:14 +0000 (18:16 -0700)
MTU changing is done through a common function that redirects the
treatment to a specific ksz_dev_ops callback. This layer of indirection
isn't needed since we now have a dsa_switch_ops struct for each switch
family.

Remove this indirection layer in MTU changing for KSZ switches, by
directly connecting the ksz_dev_ops :: change_mtu() implementations to
dsa_switch_ops.
Remove the no longer used change_mtu() callback from ksz_dev_ops

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-3-c00f6ce037fa@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/microchip/ksz8.c
drivers/net/dsa/microchip/ksz9477.c
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h
drivers/net/dsa/microchip/lan937x_main.c

index 10ab89ff93b657454da11e9381aed080fe4929c6..dd603e7f1a6399b14cf276f6a9b5232068285301 100644 (file)
@@ -188,8 +188,9 @@ static int ksz8795_change_mtu(struct ksz_device *dev, int frame_size)
        return ksz_rmw8(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, ctrl2);
 }
 
-static int ksz8_change_mtu(struct ksz_device *dev, int port, int mtu)
+static int ksz8_change_mtu(struct dsa_switch *ds, int port, int mtu)
 {
+       struct ksz_device *dev = ds->priv;
        u16 frame_size;
 
        if (!dsa_is_cpu_port(dev->ds, port))
@@ -2226,7 +2227,6 @@ const struct ksz_dev_ops ksz8463_dev_ops = {
        .reset = ksz8_reset_switch,
        .init = ksz8_switch_init,
        .exit = ksz8_switch_exit,
-       .change_mtu = ksz8_change_mtu,
 };
 
 const struct ksz_dev_ops ksz87xx_dev_ops = {
@@ -2257,7 +2257,6 @@ const struct ksz_dev_ops ksz87xx_dev_ops = {
        .reset = ksz8_reset_switch,
        .init = ksz8_switch_init,
        .exit = ksz8_switch_exit,
-       .change_mtu = ksz8_change_mtu,
        .pme_write8 = ksz8_pme_write8,
        .pme_pread8 = ksz8_pme_pread8,
        .pme_pwrite8 = ksz8_pme_pwrite8,
@@ -2291,7 +2290,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops = {
        .reset = ksz8_reset_switch,
        .init = ksz8_switch_init,
        .exit = ksz8_switch_exit,
-       .change_mtu = ksz8_change_mtu,
        .pme_write8 = ksz8_pme_write8,
        .pme_pread8 = ksz8_pme_pread8,
        .pme_pwrite8 = ksz8_pme_pwrite8,
@@ -2332,7 +2330,7 @@ const struct dsa_switch_ops ksz8463_switch_ops = {
        .port_mirror_del        = ksz_port_mirror_del,
        .get_stats64            = ksz_get_stats64,
        .get_pause_stats        = ksz_get_pause_stats,
-       .port_change_mtu        = ksz_change_mtu,
+       .port_change_mtu        = ksz8_change_mtu,
        .port_max_mtu           = ksz_max_mtu,
        .get_wol                = ksz_get_wol,
        .set_wol                = ksz_set_wol,
@@ -2392,7 +2390,7 @@ const struct dsa_switch_ops ksz87xx_switch_ops = {
        .port_mirror_del        = ksz_port_mirror_del,
        .get_stats64            = ksz_get_stats64,
        .get_pause_stats        = ksz_get_pause_stats,
-       .port_change_mtu        = ksz_change_mtu,
+       .port_change_mtu        = ksz8_change_mtu,
        .port_max_mtu           = ksz_max_mtu,
        .get_wol                = ksz_get_wol,
        .set_wol                = ksz_set_wol,
@@ -2452,7 +2450,7 @@ const struct dsa_switch_ops ksz88xx_switch_ops = {
        .port_mirror_del        = ksz_port_mirror_del,
        .get_stats64            = ksz_get_stats64,
        .get_pause_stats        = ksz_get_pause_stats,
-       .port_change_mtu        = ksz_change_mtu,
+       .port_change_mtu        = ksz8_change_mtu,
        .port_max_mtu           = ksz_max_mtu,
        .get_wol                = ksz_get_wol,
        .set_wol                = ksz_set_wol,
index 11e6fd1f46ce0b111ec376657db4076af21c627e..f21a05a86b4837be9393406f2def0f08a1daf20c 100644 (file)
@@ -45,8 +45,9 @@ static void ksz9477_port_cfg32(struct ksz_device *dev, int port, int offset,
                           bits, set ? bits : 0);
 }
 
-static int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu)
+static int ksz9477_change_mtu(struct dsa_switch *ds, int port, int mtu)
 {
+       struct ksz_device *dev = ds->priv;
        u16 frame_size;
 
        if (!dsa_is_cpu_port(dev->ds, port))
@@ -1790,7 +1791,6 @@ const struct ksz_dev_ops ksz9477_dev_ops = {
        .fdb_del = ksz9477_fdb_del,
        .mdb_add = ksz9477_mdb_add,
        .mdb_del = ksz9477_mdb_del,
-       .change_mtu = ksz9477_change_mtu,
        .pme_write8 = ksz_write8,
        .pme_pread8 = ksz_pread8,
        .pme_pwrite8 = ksz_pwrite8,
@@ -1839,7 +1839,7 @@ const struct dsa_switch_ops ksz9477_switch_ops = {
        .port_mirror_del        = ksz_port_mirror_del,
        .get_stats64            = ksz_get_stats64,
        .get_pause_stats        = ksz_get_pause_stats,
-       .port_change_mtu        = ksz_change_mtu,
+       .port_change_mtu        = ksz9477_change_mtu,
        .port_max_mtu           = ksz_max_mtu,
        .get_wol                = ksz_get_wol,
        .set_wol                = ksz_set_wol,
index cfca29007e36b0455d39ea3fb8a2d2cb30ca2df8..eb13d548ebff91b17f7a21b82e11b55437457db3 100644 (file)
@@ -3342,16 +3342,6 @@ void ksz_port_mirror_del(struct dsa_switch *ds, int port,
                dev->dev_ops->mirror_del(dev, port, mirror);
 }
 
-int ksz_change_mtu(struct dsa_switch *ds, int port, int mtu)
-{
-       struct ksz_device *dev = ds->priv;
-
-       if (!dev->dev_ops->change_mtu)
-               return -EOPNOTSUPP;
-
-       return dev->dev_ops->change_mtu(dev, port, mtu);
-}
-
 int ksz_max_mtu(struct dsa_switch *ds, int port)
 {
        struct ksz_device *dev = ds->priv;
index 80b3f2483e36d3a476b1425f983dab398b99ac9f..0aa83c75c40a119583b571b0a9ed381c78265a43 100644 (file)
@@ -434,7 +434,6 @@ struct ksz_dev_ops {
                       struct dsa_db db);
        void (*get_caps)(struct ksz_device *dev, int port,
                         struct phylink_config *config);
-       int (*change_mtu)(struct ksz_device *dev, int port, int mtu);
        int (*pme_write8)(struct ksz_device *dev, u32 reg, u8 value);
        int (*pme_pread8)(struct ksz_device *dev, int port, int offset,
                          u8 *data);
@@ -545,7 +544,6 @@ int ksz_port_mirror_add(struct dsa_switch *ds, int port,
                        bool ingress, struct netlink_ext_ack *extack);
 void ksz_port_mirror_del(struct dsa_switch *ds, int port,
                         struct dsa_mall_mirror_tc_entry *mirror);
-int ksz_change_mtu(struct dsa_switch *ds, int port, int mtu);
 int ksz_max_mtu(struct dsa_switch *ds, int port);
 
 bool ksz_support_eee(struct dsa_switch *ds, int port);
index 19e444cb0a74ad08964e53ce6f971bee45c5a890..feaaaafeace61888006ec69b525ed363a9adb18c 100644 (file)
@@ -430,9 +430,9 @@ static void lan937x_config_cpu_port(struct dsa_switch *ds)
        }
 }
 
-static int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu)
+static int lan937x_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 {
-       struct dsa_switch *ds = dev->ds;
+       struct ksz_device *dev = ds->priv;
        int ret;
 
        new_mtu += VLAN_ETH_HLEN + ETH_FCS_LEN;
@@ -725,7 +725,6 @@ const struct ksz_dev_ops lan937x_dev_ops = {
        .fdb_del = ksz9477_fdb_del,
        .mdb_add = ksz9477_mdb_add,
        .mdb_del = ksz9477_mdb_del,
-       .change_mtu = lan937x_change_mtu,
        .config_cpu_port = lan937x_config_cpu_port,
        .tc_cbs_set_cinc = lan937x_tc_cbs_set_cinc,
        .enable_stp_addr = ksz9477_enable_stp_addr,
@@ -770,7 +769,7 @@ const struct dsa_switch_ops lan937x_switch_ops = {
        .port_mirror_del        = ksz_port_mirror_del,
        .get_stats64            = ksz_get_stats64,
        .get_pause_stats        = ksz_get_pause_stats,
-       .port_change_mtu        = ksz_change_mtu,
+       .port_change_mtu        = lan937x_change_mtu,
        .port_max_mtu           = ksz_max_mtu,
        .get_wol                = ksz_get_wol,
        .set_wol                = ksz_set_wol,