From 83ea7fd73b11dd8cbf4416507a5eac3890b49fb0 Mon Sep 17 00:00:00 2001 From: "Bastien Curutchet (Schneider Electric)" Date: Tue, 12 May 2026 15:06:23 +0200 Subject: [PATCH 1/7] net: dsa: microchip: remove unused phylink_mac_link_up() callback ksz_dev_ops::phylink_mac_link_up() isn't used anywhere. Remove it. Signed-off-by: Bastien Curutchet (Schneider Electric) Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-1-c00f6ce037fa@bootlin.com Signed-off-by: Jakub Kicinski --- drivers/net/dsa/microchip/ksz_common.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 3dde7e771727..0ab3b4f96595 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -444,11 +444,6 @@ struct ksz_dev_ops { u8 data); void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze); void (*port_init_cnt)(struct ksz_device *dev, int port); - void (*phylink_mac_link_up)(struct ksz_device *dev, int port, - unsigned int mode, - phy_interface_t interface, - struct phy_device *phydev, int speed, - int duplex, bool tx_pause, bool rx_pause); void (*setup_rgmii_delay)(struct ksz_device *dev, int port); int (*tc_cbs_set_cinc)(struct ksz_device *dev, int port, u32 val); void (*config_cpu_port)(struct dsa_switch *ds); From f27ae140c8da251b72d8eea53efd172ac1682faf Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Tue, 12 May 2026 15:06:24 +0200 Subject: [PATCH 2/7] net: dsa: microchip: bypass dev_ops for FDB ageing operations dsa_switch_ops :: set_ageing_time() goes through ksz_set_ageing_time(), further dispatched through ksz_dev_ops :: set_ageing_time(). Only ksz9477 and lan937x provide an implementation for this, so remove the (optional) method from ksz8463_switch_ops, ksz87xx_switch_ops, ksz88xx_switch_ops. Also, hook up ksz9477 and lan937x dsa_switch_ops directly to their respective implementations. Every switch family provides a dsa_switch_ops :: port_fast_age() implementation, which is dispatched through ksz_dev_ops :: flush_dyn_mac_table(). Remove the dev_ops indirection and connect the flush_dyn_mac_table() methods directly to their respective dsa_switch_ops. Signed-off-by: Vladimir Oltean Signed-off-by: Bastien Curutchet (Schneider Electric) Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-2-c00f6ce037fa@bootlin.com Signed-off-by: Jakub Kicinski --- drivers/net/dsa/microchip/ksz8.c | 15 +++++---------- drivers/net/dsa/microchip/ksz9477.c | 12 ++++++------ drivers/net/dsa/microchip/ksz9477.h | 2 +- drivers/net/dsa/microchip/ksz_common.c | 17 ----------------- drivers/net/dsa/microchip/ksz_common.h | 4 ---- drivers/net/dsa/microchip/lan937x_main.c | 9 ++++----- 6 files changed, 16 insertions(+), 43 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c index abee0dc5ec04..10ab89ff93b6 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -1278,8 +1278,9 @@ static void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member) ksz_pwrite8(dev, port, offset, data); } -static void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port) +static void ksz8_flush_dyn_mac_table(struct dsa_switch *ds, int port) { + struct ksz_device *dev = ds->priv; u8 learn[DSA_MAX_PORTS]; int first, index, cnt; const u16 *regs; @@ -2201,7 +2202,6 @@ const struct ksz_dev_ops ksz8463_dev_ops = { .setup = ksz8_setup, .get_port_addr = ksz8463_get_port_addr, .cfg_port_member = ksz8_cfg_port_member, - .flush_dyn_mac_table = ksz8_flush_dyn_mac_table, .port_setup = ksz8_port_setup, .r_phy = ksz8463_r_phy, .w_phy = ksz8463_w_phy, @@ -2233,7 +2233,6 @@ const struct ksz_dev_ops ksz87xx_dev_ops = { .setup = ksz8_setup, .get_port_addr = ksz8_get_port_addr, .cfg_port_member = ksz8_cfg_port_member, - .flush_dyn_mac_table = ksz8_flush_dyn_mac_table, .port_setup = ksz8_port_setup, .r_phy = ksz8_r_phy, .w_phy = ksz8_w_phy, @@ -2268,7 +2267,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops = { .setup = ksz8_setup, .get_port_addr = ksz8_get_port_addr, .cfg_port_member = ksz8_cfg_port_member, - .flush_dyn_mac_table = ksz8_flush_dyn_mac_table, .port_setup = ksz8_port_setup, .r_phy = ksz8_r_phy, .w_phy = ksz8_w_phy, @@ -2309,7 +2307,6 @@ const struct dsa_switch_ops ksz8463_switch_ops = { .phy_write = ksz_phy_write16, .phylink_get_caps = ksz_phylink_get_caps, .port_setup = ksz_port_setup, - .set_ageing_time = ksz_set_ageing_time, .get_strings = ksz_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, .get_sset_count = ksz_sset_count, @@ -2322,7 +2319,7 @@ const struct dsa_switch_ops ksz8463_switch_ops = { .port_teardown = ksz_port_teardown, .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, - .port_fast_age = ksz_port_fast_age, + .port_fast_age = ksz8_flush_dyn_mac_table, .port_vlan_filtering = ksz_port_vlan_filtering, .port_vlan_add = ksz_port_vlan_add, .port_vlan_del = ksz_port_vlan_del, @@ -2370,7 +2367,6 @@ const struct dsa_switch_ops ksz87xx_switch_ops = { .phy_write = ksz_phy_write16, .phylink_get_caps = ksz_phylink_get_caps, .port_setup = ksz_port_setup, - .set_ageing_time = ksz_set_ageing_time, .get_strings = ksz_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, .get_sset_count = ksz_sset_count, @@ -2383,7 +2379,7 @@ const struct dsa_switch_ops ksz87xx_switch_ops = { .port_teardown = ksz_port_teardown, .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, - .port_fast_age = ksz_port_fast_age, + .port_fast_age = ksz8_flush_dyn_mac_table, .port_vlan_filtering = ksz_port_vlan_filtering, .port_vlan_add = ksz_port_vlan_add, .port_vlan_del = ksz_port_vlan_del, @@ -2431,7 +2427,6 @@ const struct dsa_switch_ops ksz88xx_switch_ops = { .phy_write = ksz_phy_write16, .phylink_get_caps = ksz_phylink_get_caps, .port_setup = ksz_port_setup, - .set_ageing_time = ksz_set_ageing_time, .get_strings = ksz_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, .get_sset_count = ksz_sset_count, @@ -2444,7 +2439,7 @@ const struct dsa_switch_ops ksz88xx_switch_ops = { .port_teardown = ksz_port_teardown, .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, - .port_fast_age = ksz_port_fast_age, + .port_fast_age = ksz8_flush_dyn_mac_table, .port_vlan_filtering = ksz_port_vlan_filtering, .port_vlan_add = ksz_port_vlan_add, .port_vlan_del = ksz_port_vlan_del, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index ac2c63fe0588..11e6fd1f46ce 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -604,8 +604,9 @@ void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member) ksz_pwrite32(dev, port, REG_PORT_VLAN_MEMBERSHIP__4, member); } -void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port) +void ksz9477_flush_dyn_mac_table(struct dsa_switch *ds, int port) { + struct ksz_device *dev = ds->priv; const u16 *regs = dev->info->regs; u8 data; @@ -1170,8 +1171,9 @@ static void ksz9477_get_caps(struct ksz_device *dev, int port, } } -static int ksz9477_set_ageing_time(struct ksz_device *dev, unsigned int msecs) +static int ksz9477_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) { + struct ksz_device *dev = ds->priv; u32 secs = msecs / 1000; u8 data, mult, value; u32 max_val; @@ -1769,9 +1771,7 @@ const struct ksz_dev_ops ksz9477_dev_ops = { .setup = ksz9477_setup, .get_port_addr = ksz9477_get_port_addr, .cfg_port_member = ksz9477_cfg_port_member, - .flush_dyn_mac_table = ksz9477_flush_dyn_mac_table, .port_setup = ksz9477_port_setup, - .set_ageing_time = ksz9477_set_ageing_time, .r_phy = ksz9477_r_phy, .w_phy = ksz9477_w_phy, .r_mib_cnt = ksz9477_r_mib_cnt, @@ -1813,7 +1813,7 @@ const struct dsa_switch_ops ksz9477_switch_ops = { .phy_write = ksz_phy_write16, .phylink_get_caps = ksz_phylink_get_caps, .port_setup = ksz_port_setup, - .set_ageing_time = ksz_set_ageing_time, + .set_ageing_time = ksz9477_set_ageing_time, .get_strings = ksz_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, .get_sset_count = ksz_sset_count, @@ -1826,7 +1826,7 @@ const struct dsa_switch_ops ksz9477_switch_ops = { .port_teardown = ksz_port_teardown, .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, - .port_fast_age = ksz_port_fast_age, + .port_fast_age = ksz9477_flush_dyn_mac_table, .port_vlan_filtering = ksz_port_vlan_filtering, .port_vlan_add = ksz_port_vlan_add, .port_vlan_del = ksz_port_vlan_del, diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h index bacadcbc478c..8012904a2130 100644 --- a/drivers/net/dsa/microchip/ksz9477.h +++ b/drivers/net/dsa/microchip/ksz9477.h @@ -13,7 +13,7 @@ u32 ksz9477_get_port_addr(int port, int offset); void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member); -void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port); +void ksz9477_flush_dyn_mac_table(struct dsa_switch *ds, int port); void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt); void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt); diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 426414a21845..cfca29007e36 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3085,23 +3085,6 @@ void ksz_port_bridge_leave(struct dsa_switch *ds, int port, */ } -void ksz_port_fast_age(struct dsa_switch *ds, int port) -{ - struct ksz_device *dev = ds->priv; - - dev->dev_ops->flush_dyn_mac_table(dev, port); -} - -int ksz_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->set_ageing_time) - return -EOPNOTSUPP; - - return dev->dev_ops->set_ageing_time(dev, msecs); -} - int ksz_port_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 0ab3b4f96595..80b3f2483e36 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -363,9 +363,7 @@ struct ksz_dev_ops { void (*teardown)(struct dsa_switch *ds); u32 (*get_port_addr)(int port, int offset); void (*cfg_port_member)(struct ksz_device *dev, int port, u8 member); - void (*flush_dyn_mac_table)(struct ksz_device *dev, int port); void (*port_setup)(struct ksz_device *dev, int port, bool cpu_port); - int (*set_ageing_time)(struct ksz_device *dev, unsigned int msecs); /** * @mdio_bus_preinit: Function pointer to pre-initialize the MDIO bus @@ -515,8 +513,6 @@ int ksz_port_vlan_add(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack); int ksz_port_vlan_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan); -void ksz_port_fast_age(struct dsa_switch *ds, int port); -int ksz_set_ageing_time(struct dsa_switch *ds, unsigned int msecs); int ksz_port_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c index e522990cce22..19e444cb0a74 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -461,8 +461,9 @@ static int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu) return 0; } -static int lan937x_set_ageing_time(struct ksz_device *dev, unsigned int msecs) +static int lan937x_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) { + struct ksz_device *dev = ds->priv; u8 data, mult, value8; bool in_msec = false; u32 max_val, value; @@ -702,9 +703,7 @@ const struct ksz_dev_ops lan937x_dev_ops = { .teardown = lan937x_teardown, .get_port_addr = ksz9477_get_port_addr, .cfg_port_member = ksz9477_cfg_port_member, - .flush_dyn_mac_table = ksz9477_flush_dyn_mac_table, .port_setup = lan937x_port_setup, - .set_ageing_time = lan937x_set_ageing_time, .mdio_bus_preinit = lan937x_mdio_bus_preinit, .create_phy_addr_map = lan937x_create_phy_addr_map, .r_phy = lan937x_r_phy, @@ -745,7 +744,7 @@ const struct dsa_switch_ops lan937x_switch_ops = { .phy_write = ksz_phy_write16, .phylink_get_caps = ksz_phylink_get_caps, .port_setup = ksz_port_setup, - .set_ageing_time = ksz_set_ageing_time, + .set_ageing_time = lan937x_set_ageing_time, .get_strings = ksz_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, .get_sset_count = ksz_sset_count, @@ -758,7 +757,7 @@ const struct dsa_switch_ops lan937x_switch_ops = { .port_teardown = ksz_port_teardown, .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, - .port_fast_age = ksz_port_fast_age, + .port_fast_age = ksz9477_flush_dyn_mac_table, .port_vlan_filtering = ksz_port_vlan_filtering, .port_vlan_add = ksz_port_vlan_add, .port_vlan_del = ksz_port_vlan_del, From 9f16bc5c737d0eefda9c4e231decc960c8c51080 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Tue, 12 May 2026 15:06:25 +0200 Subject: [PATCH 3/7] net: dsa: microchip: bypass dev_ops for change_mtu() operation 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 Signed-off-by: Bastien Curutchet (Schneider Electric) Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-3-c00f6ce037fa@bootlin.com Signed-off-by: Jakub Kicinski --- drivers/net/dsa/microchip/ksz8.c | 12 +++++------- drivers/net/dsa/microchip/ksz9477.c | 6 +++--- drivers/net/dsa/microchip/ksz_common.c | 10 ---------- drivers/net/dsa/microchip/ksz_common.h | 2 -- drivers/net/dsa/microchip/lan937x_main.c | 7 +++---- 5 files changed, 11 insertions(+), 26 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c index 10ab89ff93b6..dd603e7f1a63 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -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, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 11e6fd1f46ce..f21a05a86b48 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -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, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index cfca29007e36..eb13d548ebff 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -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; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 80b3f2483e36..0aa83c75c40a 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -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); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c index 19e444cb0a74..feaaaafeace6 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -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, From e439c7871efb424ad65ccea221973d9ef78208cc Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Tue, 12 May 2026 15:06:26 +0200 Subject: [PATCH 4/7] net: dsa: microchip: bypass dev_ops for VLAN operations VLAN operations are handled through a common function that redirects the treatment to ksz_dev_ops callbacks. This level of indirection isn't needed since we now have a dsa_switch_ops for each kind of switch. Remove this useless layer of indirection by connecting directly the VLAN operations to the relevant dsa_switch_ops. Adapt their prototypes to match dsa_switch_ops expectations. Remove the now unused VLAN callbacks from ksz_dev_ops. Signed-off-by: Vladimir Oltean Signed-off-by: Bastien Curutchet (Schneider Electric) Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-4-c00f6ce037fa@bootlin.com Signed-off-by: Jakub Kicinski --- drivers/net/dsa/microchip/ksz8.c | 39 +++++++++++------------- drivers/net/dsa/microchip/ksz9477.c | 21 +++++++------ drivers/net/dsa/microchip/ksz9477.h | 6 ++-- drivers/net/dsa/microchip/ksz_common.c | 34 --------------------- drivers/net/dsa/microchip/ksz_common.h | 14 --------- drivers/net/dsa/microchip/lan937x_main.c | 9 ++---- 6 files changed, 34 insertions(+), 89 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c index dd603e7f1a63..94c8034a192a 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -1446,9 +1446,11 @@ static int ksz8_fdb_del(struct ksz_device *dev, int port, return ksz8_del_sta_mac(dev, port, addr, vid); } -static int ksz8_port_vlan_filtering(struct ksz_device *dev, int port, bool flag, +static int ksz8_port_vlan_filtering(struct dsa_switch *ds, int port, bool flag, struct netlink_ext_ack *extack) { + struct ksz_device *dev = ds->priv; + if (ksz_is_ksz88x3(dev) || ksz_is_ksz8463(dev)) return -ENOTSUPP; @@ -1476,11 +1478,12 @@ static void ksz8_port_enable_pvid(struct ksz_device *dev, int port, bool state) } } -static int ksz8_port_vlan_add(struct ksz_device *dev, int port, +static int ksz8_port_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack) { bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; + struct ksz_device *dev = ds->priv; struct ksz_port *p = &dev->ports[port]; u16 data, new_pvid = 0; u8 fid, member, valid; @@ -1548,11 +1551,12 @@ static int ksz8_port_vlan_add(struct ksz_device *dev, int port, return 0; } -static int ksz8_port_vlan_del(struct ksz_device *dev, int port, +static int ksz8_port_vlan_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { - u16 data, pvid; + struct ksz_device *dev = ds->priv; u8 fid, member, valid; + u16 data, pvid; if (ksz_is_ksz88x3(dev) || ksz_is_ksz8463(dev)) return -ENOTSUPP; @@ -2216,9 +2220,6 @@ const struct ksz_dev_ops ksz8463_dev_ops = { .fdb_del = ksz8_fdb_del, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, - .vlan_filtering = ksz8_port_vlan_filtering, - .vlan_add = ksz8_port_vlan_add, - .vlan_del = ksz8_port_vlan_del, .mirror_add = ksz8_port_mirror_add, .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, @@ -2246,9 +2247,6 @@ const struct ksz_dev_ops ksz87xx_dev_ops = { .fdb_del = ksz8_fdb_del, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, - .vlan_filtering = ksz8_port_vlan_filtering, - .vlan_add = ksz8_port_vlan_add, - .vlan_del = ksz8_port_vlan_del, .mirror_add = ksz8_port_mirror_add, .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, @@ -2279,9 +2277,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops = { .fdb_del = ksz8_fdb_del, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, - .vlan_filtering = ksz8_port_vlan_filtering, - .vlan_add = ksz8_port_vlan_add, - .vlan_del = ksz8_port_vlan_del, .mirror_add = ksz8_port_mirror_add, .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, @@ -2318,9 +2313,9 @@ const struct dsa_switch_ops ksz8463_switch_ops = { .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, .port_fast_age = ksz8_flush_dyn_mac_table, - .port_vlan_filtering = ksz_port_vlan_filtering, - .port_vlan_add = ksz_port_vlan_add, - .port_vlan_del = ksz_port_vlan_del, + .port_vlan_filtering = ksz8_port_vlan_filtering, + .port_vlan_add = ksz8_port_vlan_add, + .port_vlan_del = ksz8_port_vlan_del, .port_fdb_dump = ksz_port_fdb_dump, .port_fdb_add = ksz_port_fdb_add, .port_fdb_del = ksz_port_fdb_del, @@ -2378,9 +2373,9 @@ const struct dsa_switch_ops ksz87xx_switch_ops = { .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, .port_fast_age = ksz8_flush_dyn_mac_table, - .port_vlan_filtering = ksz_port_vlan_filtering, - .port_vlan_add = ksz_port_vlan_add, - .port_vlan_del = ksz_port_vlan_del, + .port_vlan_filtering = ksz8_port_vlan_filtering, + .port_vlan_add = ksz8_port_vlan_add, + .port_vlan_del = ksz8_port_vlan_del, .port_fdb_dump = ksz_port_fdb_dump, .port_fdb_add = ksz_port_fdb_add, .port_fdb_del = ksz_port_fdb_del, @@ -2438,9 +2433,9 @@ const struct dsa_switch_ops ksz88xx_switch_ops = { .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, .port_fast_age = ksz8_flush_dyn_mac_table, - .port_vlan_filtering = ksz_port_vlan_filtering, - .port_vlan_add = ksz_port_vlan_add, - .port_vlan_del = ksz_port_vlan_del, + .port_vlan_filtering = ksz8_port_vlan_filtering, + .port_vlan_add = ksz8_port_vlan_add, + .port_vlan_del = ksz8_port_vlan_del, .port_fdb_dump = ksz_port_fdb_dump, .port_fdb_add = ksz_port_fdb_add, .port_fdb_del = ksz_port_fdb_del, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index f21a05a86b48..959229185df9 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -629,9 +629,11 @@ void ksz9477_flush_dyn_mac_table(struct dsa_switch *ds, int port) } } -int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port, +int ksz9477_port_vlan_filtering(struct dsa_switch *ds, int port, bool flag, struct netlink_ext_ack *extack) { + struct ksz_device *dev = ds->priv; + if (flag) { ksz_port_cfg(dev, port, REG_PORT_LUE_CTRL, PORT_VLAN_LOOKUP_VID_0, true); @@ -645,12 +647,13 @@ int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port, return 0; } -int ksz9477_port_vlan_add(struct ksz_device *dev, int port, +int ksz9477_port_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack) { - u32 vlan_table[3]; bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; + struct ksz_device *dev = ds->priv; + u32 vlan_table[3]; int err; err = ksz9477_get_vlan_table(dev, vlan->vid, vlan_table); @@ -681,10 +684,11 @@ int ksz9477_port_vlan_add(struct ksz_device *dev, int port, return 0; } -int ksz9477_port_vlan_del(struct ksz_device *dev, int port, +int ksz9477_port_vlan_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; + struct ksz_device *dev = ds->priv; u32 vlan_table[3]; u16 pvid; @@ -1780,9 +1784,6 @@ const struct ksz_dev_ops ksz9477_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, - .vlan_filtering = ksz9477_port_vlan_filtering, - .vlan_add = ksz9477_port_vlan_add, - .vlan_del = ksz9477_port_vlan_del, .mirror_add = ksz9477_port_mirror_add, .mirror_del = ksz9477_port_mirror_del, .get_caps = ksz9477_get_caps, @@ -1827,9 +1828,9 @@ const struct dsa_switch_ops ksz9477_switch_ops = { .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, .port_fast_age = ksz9477_flush_dyn_mac_table, - .port_vlan_filtering = ksz_port_vlan_filtering, - .port_vlan_add = ksz_port_vlan_add, - .port_vlan_del = ksz_port_vlan_del, + .port_vlan_filtering = ksz9477_port_vlan_filtering, + .port_vlan_add = ksz9477_port_vlan_add, + .port_vlan_del = ksz9477_port_vlan_del, .port_fdb_dump = ksz_port_fdb_dump, .port_fdb_add = ksz_port_fdb_add, .port_fdb_del = ksz_port_fdb_del, diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h index 8012904a2130..75a7b2bfc797 100644 --- a/drivers/net/dsa/microchip/ksz9477.h +++ b/drivers/net/dsa/microchip/ksz9477.h @@ -19,12 +19,12 @@ void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt); void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze); void ksz9477_port_init_cnt(struct ksz_device *dev, int port); -int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port, +int ksz9477_port_vlan_filtering(struct dsa_switch *ds, int port, bool flag, struct netlink_ext_ack *extack); -int ksz9477_port_vlan_add(struct ksz_device *dev, int port, +int ksz9477_port_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack); -int ksz9477_port_vlan_del(struct ksz_device *dev, int port, +int ksz9477_port_vlan_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan); int ksz9477_port_mirror_add(struct ksz_device *dev, int port, struct dsa_mall_mirror_tc_entry *mirror, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index eb13d548ebff..07d1d58113f0 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3287,40 +3287,6 @@ int ksz_port_bridge_flags(struct dsa_switch *ds, int port, return 0; } -int ksz_port_vlan_filtering(struct dsa_switch *ds, int port, - bool flag, struct netlink_ext_ack *extack) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->vlan_filtering) - return -EOPNOTSUPP; - - return dev->dev_ops->vlan_filtering(dev, port, flag, extack); -} - -int ksz_port_vlan_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_vlan *vlan, - struct netlink_ext_ack *extack) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->vlan_add) - return -EOPNOTSUPP; - - return dev->dev_ops->vlan_add(dev, port, vlan, extack); -} - -int ksz_port_vlan_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_vlan *vlan) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->vlan_del) - return -EOPNOTSUPP; - - return dev->dev_ops->vlan_del(dev, port, vlan); -} - int ksz_port_mirror_add(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror, bool ingress, struct netlink_ext_ack *extack) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 0aa83c75c40a..d07b3f5918f8 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -408,13 +408,6 @@ struct ksz_dev_ops { void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt); void (*r_mib_stat64)(struct ksz_device *dev, int port); - int (*vlan_filtering)(struct ksz_device *dev, int port, - bool flag, struct netlink_ext_ack *extack); - int (*vlan_add)(struct ksz_device *dev, int port, - const struct switchdev_obj_port_vlan *vlan, - struct netlink_ext_ack *extack); - int (*vlan_del)(struct ksz_device *dev, int port, - const struct switchdev_obj_port_vlan *vlan); int (*mirror_add)(struct ksz_device *dev, int port, struct dsa_mall_mirror_tc_entry *mirror, bool ingress, struct netlink_ext_ack *extack); @@ -505,13 +498,6 @@ int ksz_port_pre_bridge_flags(struct dsa_switch *ds, int port, int ksz_port_bridge_flags(struct dsa_switch *ds, int port, struct switchdev_brport_flags flags, struct netlink_ext_ack *extack); -int ksz_port_vlan_filtering(struct dsa_switch *ds, int port, - bool flag, struct netlink_ext_ack *extack); -int ksz_port_vlan_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_vlan *vlan, - struct netlink_ext_ack *extack); -int ksz_port_vlan_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_vlan *vlan); int ksz_port_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c index feaaaafeace6..be6a457ee8e4 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -713,9 +713,6 @@ const struct ksz_dev_ops lan937x_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, - .vlan_filtering = ksz9477_port_vlan_filtering, - .vlan_add = ksz9477_port_vlan_add, - .vlan_del = ksz9477_port_vlan_del, .mirror_add = ksz9477_port_mirror_add, .mirror_del = ksz9477_port_mirror_del, .get_caps = lan937x_phylink_get_caps, @@ -757,9 +754,9 @@ const struct dsa_switch_ops lan937x_switch_ops = { .port_pre_bridge_flags = ksz_port_pre_bridge_flags, .port_bridge_flags = ksz_port_bridge_flags, .port_fast_age = ksz9477_flush_dyn_mac_table, - .port_vlan_filtering = ksz_port_vlan_filtering, - .port_vlan_add = ksz_port_vlan_add, - .port_vlan_del = ksz_port_vlan_del, + .port_vlan_filtering = ksz9477_port_vlan_filtering, + .port_vlan_add = ksz9477_port_vlan_add, + .port_vlan_del = ksz9477_port_vlan_del, .port_fdb_dump = ksz_port_fdb_dump, .port_fdb_add = ksz_port_fdb_add, .port_fdb_del = ksz_port_fdb_del, From ede165ba0bd0b91f388f43ff0df89afd34dd24c1 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Tue, 12 May 2026 15:06:27 +0200 Subject: [PATCH 5/7] net: dsa: microchip: bypass dev_ops for FDB and MDB operations FDB and MDB operations are handled through a common function that redirects the treatment to ksz_dev_ops callbacks. This layer of indirection isn't needed since we now have a dsa_switch_ops for each kind of switch. Remove one indirection layer for KSZ switches, by connecting the ksz_dev_ops :: fdb_dump(), fdb_add(), fdb_del(), mdb_add() and mdb_del() operations directly to dsa_switch_ops. Remove the FDB and MDB operations from ksz_dev_ops. Signed-off-by: Vladimir Oltean Signed-off-by: Bastien Curutchet (Schneider Electric) Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-5-c00f6ce037fa@bootlin.com Signed-off-by: Jakub Kicinski --- drivers/net/dsa/microchip/ksz8.c | 64 +++++++++--------------- drivers/net/dsa/microchip/ksz9477.c | 42 ++++++++-------- drivers/net/dsa/microchip/ksz9477.h | 10 ++-- drivers/net/dsa/microchip/ksz_common.c | 59 ---------------------- drivers/net/dsa/microchip/ksz_common.h | 26 ---------- drivers/net/dsa/microchip/lan937x_main.c | 15 ++---- 6 files changed, 56 insertions(+), 160 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c index 94c8034a192a..83795fd66aab 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -1315,9 +1315,10 @@ static void ksz8_flush_dyn_mac_table(struct dsa_switch *ds, int port) } } -static int ksz8_fdb_dump(struct ksz_device *dev, int port, +static int ksz8_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data) { + struct ksz_device *dev = ds->priv; u8 mac[ETH_ALEN]; u8 src_port, fid; u16 entries = 0; @@ -1420,30 +1421,30 @@ static int ksz8_del_sta_mac(struct ksz_device *dev, int port, return ksz8_w_sta_mac_table(dev, index, &alu); } -static int ksz8_mdb_add(struct ksz_device *dev, int port, +static int ksz8_mdb_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db) { - return ksz8_add_sta_mac(dev, port, mdb->addr, mdb->vid); + return ksz8_add_sta_mac(ds->priv, port, mdb->addr, mdb->vid); } -static int ksz8_mdb_del(struct ksz_device *dev, int port, +static int ksz8_mdb_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db) { - return ksz8_del_sta_mac(dev, port, mdb->addr, mdb->vid); + return ksz8_del_sta_mac(ds->priv, port, mdb->addr, mdb->vid); } -static int ksz8_fdb_add(struct ksz_device *dev, int port, +static int ksz8_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db) { - return ksz8_add_sta_mac(dev, port, addr, vid); + return ksz8_add_sta_mac(ds->priv, port, addr, vid); } -static int ksz8_fdb_del(struct ksz_device *dev, int port, +static int ksz8_fdb_del(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db) { - return ksz8_del_sta_mac(dev, port, addr, vid); + return ksz8_del_sta_mac(ds->priv, port, addr, vid); } static int ksz8_port_vlan_filtering(struct dsa_switch *ds, int port, bool flag, @@ -2215,11 +2216,6 @@ const struct ksz_dev_ops ksz8463_dev_ops = { .r_mib_stat64 = ksz88xx_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .fdb_dump = ksz8_fdb_dump, - .fdb_add = ksz8_fdb_add, - .fdb_del = ksz8_fdb_del, - .mdb_add = ksz8_mdb_add, - .mdb_del = ksz8_mdb_del, .mirror_add = ksz8_port_mirror_add, .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, @@ -2242,11 +2238,6 @@ const struct ksz_dev_ops ksz87xx_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .fdb_dump = ksz8_fdb_dump, - .fdb_add = ksz8_fdb_add, - .fdb_del = ksz8_fdb_del, - .mdb_add = ksz8_mdb_add, - .mdb_del = ksz8_mdb_del, .mirror_add = ksz8_port_mirror_add, .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, @@ -2272,11 +2263,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops = { .r_mib_stat64 = ksz88xx_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .fdb_dump = ksz8_fdb_dump, - .fdb_add = ksz8_fdb_add, - .fdb_del = ksz8_fdb_del, - .mdb_add = ksz8_mdb_add, - .mdb_del = ksz8_mdb_del, .mirror_add = ksz8_port_mirror_add, .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, @@ -2316,11 +2302,11 @@ const struct dsa_switch_ops ksz8463_switch_ops = { .port_vlan_filtering = ksz8_port_vlan_filtering, .port_vlan_add = ksz8_port_vlan_add, .port_vlan_del = ksz8_port_vlan_del, - .port_fdb_dump = ksz_port_fdb_dump, - .port_fdb_add = ksz_port_fdb_add, - .port_fdb_del = ksz_port_fdb_del, - .port_mdb_add = ksz_port_mdb_add, - .port_mdb_del = ksz_port_mdb_del, + .port_fdb_dump = ksz8_fdb_dump, + .port_fdb_add = ksz8_fdb_add, + .port_fdb_del = ksz8_fdb_del, + .port_mdb_add = ksz8_mdb_add, + .port_mdb_del = ksz8_mdb_del, .port_mirror_add = ksz_port_mirror_add, .port_mirror_del = ksz_port_mirror_del, .get_stats64 = ksz_get_stats64, @@ -2376,11 +2362,11 @@ const struct dsa_switch_ops ksz87xx_switch_ops = { .port_vlan_filtering = ksz8_port_vlan_filtering, .port_vlan_add = ksz8_port_vlan_add, .port_vlan_del = ksz8_port_vlan_del, - .port_fdb_dump = ksz_port_fdb_dump, - .port_fdb_add = ksz_port_fdb_add, - .port_fdb_del = ksz_port_fdb_del, - .port_mdb_add = ksz_port_mdb_add, - .port_mdb_del = ksz_port_mdb_del, + .port_fdb_dump = ksz8_fdb_dump, + .port_fdb_add = ksz8_fdb_add, + .port_fdb_del = ksz8_fdb_del, + .port_mdb_add = ksz8_mdb_add, + .port_mdb_del = ksz8_mdb_del, .port_mirror_add = ksz_port_mirror_add, .port_mirror_del = ksz_port_mirror_del, .get_stats64 = ksz_get_stats64, @@ -2436,11 +2422,11 @@ const struct dsa_switch_ops ksz88xx_switch_ops = { .port_vlan_filtering = ksz8_port_vlan_filtering, .port_vlan_add = ksz8_port_vlan_add, .port_vlan_del = ksz8_port_vlan_del, - .port_fdb_dump = ksz_port_fdb_dump, - .port_fdb_add = ksz_port_fdb_add, - .port_fdb_del = ksz_port_fdb_del, - .port_mdb_add = ksz_port_mdb_add, - .port_mdb_del = ksz_port_mdb_del, + .port_fdb_dump = ksz8_fdb_dump, + .port_fdb_add = ksz8_fdb_add, + .port_fdb_del = ksz8_fdb_del, + .port_mdb_add = ksz8_mdb_add, + .port_mdb_del = ksz8_mdb_del, .port_mirror_add = ksz_port_mirror_add, .port_mirror_del = ksz_port_mirror_del, .get_stats64 = ksz_get_stats64, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 959229185df9..69a4fb683b3a 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -718,9 +718,10 @@ int ksz9477_port_vlan_del(struct dsa_switch *ds, int port, return 0; } -int ksz9477_fdb_add(struct ksz_device *dev, int port, +int ksz9477_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db) { + struct ksz_device *dev = ds->priv; u32 alu_table[4]; u32 data; int ret = 0; @@ -774,9 +775,10 @@ int ksz9477_fdb_add(struct ksz_device *dev, int port, return ret; } -int ksz9477_fdb_del(struct ksz_device *dev, int port, +int ksz9477_fdb_del(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db) { + struct ksz_device *dev = ds->priv; u32 alu_table[4]; u32 data; int ret = 0; @@ -863,13 +865,14 @@ static void ksz9477_convert_alu(struct alu_struct *alu, u32 *alu_table) alu->mac[5] = alu_table[3] & 0xFF; } -int ksz9477_fdb_dump(struct ksz_device *dev, int port, +int ksz9477_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data) { - int ret = 0; - u32 ksz_data; - u32 alu_table[4]; + struct ksz_device *dev = ds->priv; struct alu_struct alu; + u32 alu_table[4]; + u32 ksz_data; + int ret = 0; int timeout; mutex_lock(&dev->alu_mutex); @@ -917,9 +920,10 @@ int ksz9477_fdb_dump(struct ksz_device *dev, int port, return ret; } -int ksz9477_mdb_add(struct ksz_device *dev, int port, +int ksz9477_mdb_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db) { + struct ksz_device *dev = ds->priv; u32 static_table[4]; const u8 *shifts; const u32 *masks; @@ -996,16 +1000,17 @@ int ksz9477_mdb_add(struct ksz_device *dev, int port, return err; } -int ksz9477_mdb_del(struct ksz_device *dev, int port, +int ksz9477_mdb_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db) { + struct ksz_device *dev = ds->priv; u32 static_table[4]; + u32 mac_hi, mac_lo; const u8 *shifts; const u32 *masks; - u32 data; - int index; int ret = 0; - u32 mac_hi, mac_lo; + int index; + u32 data; shifts = dev->info->shifts; masks = dev->info->masks; @@ -1787,11 +1792,6 @@ const struct ksz_dev_ops ksz9477_dev_ops = { .mirror_add = ksz9477_port_mirror_add, .mirror_del = ksz9477_port_mirror_del, .get_caps = ksz9477_get_caps, - .fdb_dump = ksz9477_fdb_dump, - .fdb_add = ksz9477_fdb_add, - .fdb_del = ksz9477_fdb_del, - .mdb_add = ksz9477_mdb_add, - .mdb_del = ksz9477_mdb_del, .pme_write8 = ksz_write8, .pme_pread8 = ksz_pread8, .pme_pwrite8 = ksz_pwrite8, @@ -1831,11 +1831,11 @@ const struct dsa_switch_ops ksz9477_switch_ops = { .port_vlan_filtering = ksz9477_port_vlan_filtering, .port_vlan_add = ksz9477_port_vlan_add, .port_vlan_del = ksz9477_port_vlan_del, - .port_fdb_dump = ksz_port_fdb_dump, - .port_fdb_add = ksz_port_fdb_add, - .port_fdb_del = ksz_port_fdb_del, - .port_mdb_add = ksz_port_mdb_add, - .port_mdb_del = ksz_port_mdb_del, + .port_fdb_dump = ksz9477_fdb_dump, + .port_fdb_add = ksz9477_fdb_add, + .port_fdb_del = ksz9477_fdb_del, + .port_mdb_add = ksz9477_mdb_add, + .port_mdb_del = ksz9477_mdb_del, .port_mirror_add = ksz_port_mirror_add, .port_mirror_del = ksz_port_mirror_del, .get_stats64 = ksz_get_stats64, diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h index 75a7b2bfc797..39f042e56f36 100644 --- a/drivers/net/dsa/microchip/ksz9477.h +++ b/drivers/net/dsa/microchip/ksz9477.h @@ -33,15 +33,15 @@ void ksz9477_port_mirror_del(struct ksz_device *dev, int port, struct dsa_mall_mirror_tc_entry *mirror); int ksz9477_errata_monitor(struct ksz_device *dev, int port, u64 tx_late_col); -int ksz9477_fdb_dump(struct ksz_device *dev, int port, +int ksz9477_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data); -int ksz9477_fdb_add(struct ksz_device *dev, int port, +int ksz9477_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db); -int ksz9477_fdb_del(struct ksz_device *dev, int port, +int ksz9477_fdb_del(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db); -int ksz9477_mdb_add(struct ksz_device *dev, int port, +int ksz9477_mdb_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db); -int ksz9477_mdb_del(struct ksz_device *dev, int port, +int ksz9477_mdb_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db); int ksz9477_enable_stp_addr(struct ksz_device *dev); void ksz9477_port_queue_split(struct ksz_device *dev, int port); diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 07d1d58113f0..d17ce88d4947 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3085,65 +3085,6 @@ void ksz_port_bridge_leave(struct dsa_switch *ds, int port, */ } -int ksz_port_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid, - struct dsa_db db) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->fdb_add) - return -EOPNOTSUPP; - - return dev->dev_ops->fdb_add(dev, port, addr, vid, db); -} - -int ksz_port_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, - u16 vid, struct dsa_db db) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->fdb_del) - return -EOPNOTSUPP; - - return dev->dev_ops->fdb_del(dev, port, addr, vid, db); -} - -int ksz_port_fdb_dump(struct dsa_switch *ds, int port, - dsa_fdb_dump_cb_t *cb, void *data) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->fdb_dump) - return -EOPNOTSUPP; - - return dev->dev_ops->fdb_dump(dev, port, cb, data); -} - -int ksz_port_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb, - struct dsa_db db) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->mdb_add) - return -EOPNOTSUPP; - - return dev->dev_ops->mdb_add(dev, port, mdb, db); -} - -int ksz_port_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb, - struct dsa_db db) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->mdb_del) - return -EOPNOTSUPP; - - return dev->dev_ops->mdb_del(dev, port, mdb, db); -} - static int ksz9477_set_default_prio_queue_mapping(struct ksz_device *dev, int port) { diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index d07b3f5918f8..fe3b2dad3d68 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -413,18 +413,6 @@ struct ksz_dev_ops { bool ingress, struct netlink_ext_ack *extack); void (*mirror_del)(struct ksz_device *dev, int port, struct dsa_mall_mirror_tc_entry *mirror); - int (*fdb_add)(struct ksz_device *dev, int port, - const unsigned char *addr, u16 vid, struct dsa_db db); - int (*fdb_del)(struct ksz_device *dev, int port, - const unsigned char *addr, u16 vid, struct dsa_db db); - int (*fdb_dump)(struct ksz_device *dev, int port, - dsa_fdb_dump_cb_t *cb, void *data); - int (*mdb_add)(struct ksz_device *dev, int port, - const struct switchdev_obj_port_mdb *mdb, - struct dsa_db db); - int (*mdb_del)(struct ksz_device *dev, int port, - const struct switchdev_obj_port_mdb *mdb, - struct dsa_db db); void (*get_caps)(struct ksz_device *dev, int port, struct phylink_config *config); int (*pme_write8)(struct ksz_device *dev, u32 reg, u8 value); @@ -498,20 +486,6 @@ int ksz_port_pre_bridge_flags(struct dsa_switch *ds, int port, int ksz_port_bridge_flags(struct dsa_switch *ds, int port, struct switchdev_brport_flags flags, struct netlink_ext_ack *extack); -int ksz_port_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid, - struct dsa_db db); -int ksz_port_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, - u16 vid, struct dsa_db db); -int ksz_port_fdb_dump(struct dsa_switch *ds, int port, - dsa_fdb_dump_cb_t *cb, void *data); -int ksz_port_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb, - struct dsa_db db); -int ksz_port_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb, - struct dsa_db db); void ksz_phylink_get_caps(struct dsa_switch *ds, int port, struct phylink_config *config); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c index be6a457ee8e4..aa428353818d 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -717,11 +717,6 @@ const struct ksz_dev_ops lan937x_dev_ops = { .mirror_del = ksz9477_port_mirror_del, .get_caps = lan937x_phylink_get_caps, .setup_rgmii_delay = lan937x_setup_rgmii_delay, - .fdb_dump = ksz9477_fdb_dump, - .fdb_add = ksz9477_fdb_add, - .fdb_del = ksz9477_fdb_del, - .mdb_add = ksz9477_mdb_add, - .mdb_del = ksz9477_mdb_del, .config_cpu_port = lan937x_config_cpu_port, .tc_cbs_set_cinc = lan937x_tc_cbs_set_cinc, .enable_stp_addr = ksz9477_enable_stp_addr, @@ -757,11 +752,11 @@ const struct dsa_switch_ops lan937x_switch_ops = { .port_vlan_filtering = ksz9477_port_vlan_filtering, .port_vlan_add = ksz9477_port_vlan_add, .port_vlan_del = ksz9477_port_vlan_del, - .port_fdb_dump = ksz_port_fdb_dump, - .port_fdb_add = ksz_port_fdb_add, - .port_fdb_del = ksz_port_fdb_del, - .port_mdb_add = ksz_port_mdb_add, - .port_mdb_del = ksz_port_mdb_del, + .port_fdb_dump = ksz9477_fdb_dump, + .port_fdb_add = ksz9477_fdb_add, + .port_fdb_del = ksz9477_fdb_del, + .port_mdb_add = ksz9477_mdb_add, + .port_mdb_del = ksz9477_mdb_del, .port_mirror_add = ksz_port_mirror_add, .port_mirror_del = ksz_port_mirror_del, .get_stats64 = ksz_get_stats64, From 5973ddcc1765cfb325747eb4bab7c504e1f282bd Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Tue, 12 May 2026 15:06:28 +0200 Subject: [PATCH 6/7] net: dsa: microchip: bypass dev_ops for mirror operations Mirror operations are handled through a common function that redirects the treatment to ksz_dev_ops callbacks. This layer of indirection isn't needed since we now have a dsa_switch_ops for each switch family. Remove this indirection layer for KSZ switches, by connecting the ksz_dev_ops :: mirror_add() and mirror_del() operations directly to dsa_switch_ops. Remove the now unused mirror callbacks from ksz_dev_ops. Signed-off-by: Vladimir Oltean Signed-off-by: Bastien Curutchet (Schneider Electric) Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-6-c00f6ce037fa@bootlin.com Signed-off-by: Jakub Kicinski --- drivers/net/dsa/microchip/ksz8.c | 24 ++++++++++-------------- drivers/net/dsa/microchip/ksz9477.c | 12 ++++++------ drivers/net/dsa/microchip/ksz9477.h | 4 ++-- drivers/net/dsa/microchip/ksz_common.c | 21 --------------------- drivers/net/dsa/microchip/ksz_common.h | 10 ---------- drivers/net/dsa/microchip/lan937x_main.c | 6 ++---- 6 files changed, 20 insertions(+), 57 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c index 83795fd66aab..38876e177956 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -1585,10 +1585,11 @@ static int ksz8_port_vlan_del(struct dsa_switch *ds, int port, return 0; } -static int ksz8_port_mirror_add(struct ksz_device *dev, int port, +static int ksz8_port_mirror_add(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror, bool ingress, struct netlink_ext_ack *extack) { + struct ksz_device *dev = ds->priv; int offset = P_MIRROR_CTRL; if (ksz_is_ksz8463(dev)) @@ -1611,9 +1612,10 @@ static int ksz8_port_mirror_add(struct ksz_device *dev, int port, return 0; } -static void ksz8_port_mirror_del(struct ksz_device *dev, int port, +static void ksz8_port_mirror_del(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror) { + struct ksz_device *dev = ds->priv; int offset = P_MIRROR_CTRL; u8 data; @@ -2216,8 +2218,6 @@ const struct ksz_dev_ops ksz8463_dev_ops = { .r_mib_stat64 = ksz88xx_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .mirror_add = ksz8_port_mirror_add, - .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, .config_cpu_port = ksz8_config_cpu_port, .enable_stp_addr = ksz8_enable_stp_addr, @@ -2238,8 +2238,6 @@ const struct ksz_dev_ops ksz87xx_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .mirror_add = ksz8_port_mirror_add, - .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, .config_cpu_port = ksz8_config_cpu_port, .enable_stp_addr = ksz8_enable_stp_addr, @@ -2263,8 +2261,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops = { .r_mib_stat64 = ksz88xx_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .mirror_add = ksz8_port_mirror_add, - .mirror_del = ksz8_port_mirror_del, .get_caps = ksz8_get_caps, .config_cpu_port = ksz8_config_cpu_port, .enable_stp_addr = ksz8_enable_stp_addr, @@ -2307,8 +2303,8 @@ const struct dsa_switch_ops ksz8463_switch_ops = { .port_fdb_del = ksz8_fdb_del, .port_mdb_add = ksz8_mdb_add, .port_mdb_del = ksz8_mdb_del, - .port_mirror_add = ksz_port_mirror_add, - .port_mirror_del = ksz_port_mirror_del, + .port_mirror_add = ksz8_port_mirror_add, + .port_mirror_del = ksz8_port_mirror_del, .get_stats64 = ksz_get_stats64, .get_pause_stats = ksz_get_pause_stats, .port_change_mtu = ksz8_change_mtu, @@ -2367,8 +2363,8 @@ const struct dsa_switch_ops ksz87xx_switch_ops = { .port_fdb_del = ksz8_fdb_del, .port_mdb_add = ksz8_mdb_add, .port_mdb_del = ksz8_mdb_del, - .port_mirror_add = ksz_port_mirror_add, - .port_mirror_del = ksz_port_mirror_del, + .port_mirror_add = ksz8_port_mirror_add, + .port_mirror_del = ksz8_port_mirror_del, .get_stats64 = ksz_get_stats64, .get_pause_stats = ksz_get_pause_stats, .port_change_mtu = ksz8_change_mtu, @@ -2427,8 +2423,8 @@ const struct dsa_switch_ops ksz88xx_switch_ops = { .port_fdb_del = ksz8_fdb_del, .port_mdb_add = ksz8_mdb_add, .port_mdb_del = ksz8_mdb_del, - .port_mirror_add = ksz_port_mirror_add, - .port_mirror_del = ksz_port_mirror_del, + .port_mirror_add = ksz8_port_mirror_add, + .port_mirror_del = ksz8_port_mirror_del, .get_stats64 = ksz_get_stats64, .get_pause_stats = ksz_get_pause_stats, .port_change_mtu = ksz8_change_mtu, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 69a4fb683b3a..14ee9686ca0a 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1080,10 +1080,11 @@ int ksz9477_mdb_del(struct dsa_switch *ds, int port, return ret; } -int ksz9477_port_mirror_add(struct ksz_device *dev, int port, +int ksz9477_port_mirror_add(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror, bool ingress, struct netlink_ext_ack *extack) { + struct ksz_device *dev = ds->priv; u8 data; int p; @@ -1119,9 +1120,10 @@ int ksz9477_port_mirror_add(struct ksz_device *dev, int port, return 0; } -void ksz9477_port_mirror_del(struct ksz_device *dev, int port, +void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror) { + struct ksz_device *dev = ds->priv; bool in_use = false; u8 data; int p; @@ -1789,8 +1791,6 @@ const struct ksz_dev_ops ksz9477_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, - .mirror_add = ksz9477_port_mirror_add, - .mirror_del = ksz9477_port_mirror_del, .get_caps = ksz9477_get_caps, .pme_write8 = ksz_write8, .pme_pread8 = ksz_pread8, @@ -1836,8 +1836,8 @@ const struct dsa_switch_ops ksz9477_switch_ops = { .port_fdb_del = ksz9477_fdb_del, .port_mdb_add = ksz9477_mdb_add, .port_mdb_del = ksz9477_mdb_del, - .port_mirror_add = ksz_port_mirror_add, - .port_mirror_del = ksz_port_mirror_del, + .port_mirror_add = ksz9477_port_mirror_add, + .port_mirror_del = ksz9477_port_mirror_del, .get_stats64 = ksz_get_stats64, .get_pause_stats = ksz_get_pause_stats, .port_change_mtu = ksz9477_change_mtu, diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h index 39f042e56f36..599db0a6ba2e 100644 --- a/drivers/net/dsa/microchip/ksz9477.h +++ b/drivers/net/dsa/microchip/ksz9477.h @@ -26,10 +26,10 @@ int ksz9477_port_vlan_add(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack); int ksz9477_port_vlan_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan); -int ksz9477_port_mirror_add(struct ksz_device *dev, int port, +int ksz9477_port_mirror_add(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror, bool ingress, struct netlink_ext_ack *extack); -void ksz9477_port_mirror_del(struct ksz_device *dev, int port, +void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror); int ksz9477_errata_monitor(struct ksz_device *dev, int port, u64 tx_late_col); diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index d17ce88d4947..ad7615849c7a 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3228,27 +3228,6 @@ int ksz_port_bridge_flags(struct dsa_switch *ds, int port, return 0; } -int ksz_port_mirror_add(struct dsa_switch *ds, int port, - struct dsa_mall_mirror_tc_entry *mirror, - bool ingress, struct netlink_ext_ack *extack) -{ - struct ksz_device *dev = ds->priv; - - if (!dev->dev_ops->mirror_add) - return -EOPNOTSUPP; - - return dev->dev_ops->mirror_add(dev, port, mirror, ingress, extack); -} - -void ksz_port_mirror_del(struct dsa_switch *ds, int port, - struct dsa_mall_mirror_tc_entry *mirror) -{ - struct ksz_device *dev = ds->priv; - - if (dev->dev_ops->mirror_del) - dev->dev_ops->mirror_del(dev, port, mirror); -} - int ksz_max_mtu(struct dsa_switch *ds, int port) { struct ksz_device *dev = ds->priv; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index fe3b2dad3d68..94eb79fa3439 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -408,11 +408,6 @@ struct ksz_dev_ops { void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt); void (*r_mib_stat64)(struct ksz_device *dev, int port); - int (*mirror_add)(struct ksz_device *dev, int port, - struct dsa_mall_mirror_tc_entry *mirror, - bool ingress, struct netlink_ext_ack *extack); - void (*mirror_del)(struct ksz_device *dev, int port, - struct dsa_mall_mirror_tc_entry *mirror); void (*get_caps)(struct ksz_device *dev, int port, struct phylink_config *config); int (*pme_write8)(struct ksz_device *dev, u32 reg, u8 value); @@ -499,11 +494,6 @@ void ksz_phylink_mac_link_down(struct phylink_config *config, unsigned int mode, phy_interface_t interface); -int ksz_port_mirror_add(struct dsa_switch *ds, int port, - struct dsa_mall_mirror_tc_entry *mirror, - 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_max_mtu(struct dsa_switch *ds, int port); bool ksz_support_eee(struct dsa_switch *ds, int port); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c index aa428353818d..621139a2c302 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -713,8 +713,6 @@ const struct ksz_dev_ops lan937x_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, - .mirror_add = ksz9477_port_mirror_add, - .mirror_del = ksz9477_port_mirror_del, .get_caps = lan937x_phylink_get_caps, .setup_rgmii_delay = lan937x_setup_rgmii_delay, .config_cpu_port = lan937x_config_cpu_port, @@ -757,8 +755,8 @@ const struct dsa_switch_ops lan937x_switch_ops = { .port_fdb_del = ksz9477_fdb_del, .port_mdb_add = ksz9477_mdb_add, .port_mdb_del = ksz9477_mdb_del, - .port_mirror_add = ksz_port_mirror_add, - .port_mirror_del = ksz_port_mirror_del, + .port_mirror_add = ksz9477_port_mirror_add, + .port_mirror_del = ksz9477_port_mirror_del, .get_stats64 = ksz_get_stats64, .get_pause_stats = ksz_get_pause_stats, .port_change_mtu = lan937x_change_mtu, From 82e5193a4e506793629aea461904cffda251b5b1 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Tue, 12 May 2026 15:06:29 +0200 Subject: [PATCH 7/7] net: dsa: microchip: bypass dev_ops for phylink_get_caps() ksz_phylink_get_caps() is a bit different from other generic methods. It has a dev_ops->get_caps() call in the middle of the function, and it does other stuff before (set some supported_interfaces) and after (set lpi_interfaces from supported_interfaces). Whereas the dev_ops->get_caps() methods set mac_capabilities and (optionally) logically OR the supported_interfaces with that of the PCS. The idea is that this can be expressed simpler, and avoid a indirect function call to dev_ops->get_caps(). If we tail-call the common ksz_phylink_get_caps() from individual phylink_get_caps() methods, we do reorder the settings, but in an inconsequential way (the transfer from supported_interfaces to lpi_interfaces still sees a complete list of the supported_interfaces). Remove the no longer used get_caps() callbacl the ksz_dev_ops. Signed-off-by: Vladimir Oltean Signed-off-by: Bastien Curutchet (Schneider Electric) Link: https://patch.msgid.link/20260512-clean-ksz-2nd-series-v1-7-c00f6ce037fa@bootlin.com Signed-off-by: Jakub Kicinski --- drivers/net/dsa/microchip/ksz8.c | 17 +++++++++-------- drivers/net/dsa/microchip/ksz9477.c | 11 +++++++---- drivers/net/dsa/microchip/ksz_common.c | 3 --- drivers/net/dsa/microchip/ksz_common.h | 2 -- drivers/net/dsa/microchip/lan937x_main.c | 9 ++++++--- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c index 38876e177956..825133e9ce6e 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -1995,9 +1995,11 @@ static int ksz8_setup(struct dsa_switch *ds) return ret; } -static void ksz8_get_caps(struct ksz_device *dev, int port, - struct phylink_config *config) +static void ksz8_phylink_get_caps(struct dsa_switch *ds, int port, + struct phylink_config *config) { + struct ksz_device *dev = ds->priv; + config->mac_capabilities = MAC_10 | MAC_100; /* Silicon Errata Sheet (DS80000830A): @@ -2011,6 +2013,8 @@ static void ksz8_get_caps(struct ksz_device *dev, int port, /* Asym pause is not supported on KSZ8863 and KSZ8873 */ if (!ksz_is_ksz88x3(dev)) config->mac_capabilities |= MAC_ASYM_PAUSE; + + ksz_phylink_get_caps(ds, port, config); } static u32 ksz8_get_port_addr(int port, int offset) @@ -2218,7 +2222,6 @@ const struct ksz_dev_ops ksz8463_dev_ops = { .r_mib_stat64 = ksz88xx_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .get_caps = ksz8_get_caps, .config_cpu_port = ksz8_config_cpu_port, .enable_stp_addr = ksz8_enable_stp_addr, .reset = ksz8_reset_switch, @@ -2238,7 +2241,6 @@ const struct ksz_dev_ops ksz87xx_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .get_caps = ksz8_get_caps, .config_cpu_port = ksz8_config_cpu_port, .enable_stp_addr = ksz8_enable_stp_addr, .reset = ksz8_reset_switch, @@ -2261,7 +2263,6 @@ const struct ksz_dev_ops ksz88xx_dev_ops = { .r_mib_stat64 = ksz88xx_r_mib_stats64, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, - .get_caps = ksz8_get_caps, .config_cpu_port = ksz8_config_cpu_port, .enable_stp_addr = ksz8_enable_stp_addr, .reset = ksz8_reset_switch, @@ -2280,7 +2281,7 @@ const struct dsa_switch_ops ksz8463_switch_ops = { .teardown = ksz_teardown, .phy_read = ksz_phy_read16, .phy_write = ksz_phy_write16, - .phylink_get_caps = ksz_phylink_get_caps, + .phylink_get_caps = ksz8_phylink_get_caps, .port_setup = ksz_port_setup, .get_strings = ksz_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, @@ -2340,7 +2341,7 @@ const struct dsa_switch_ops ksz87xx_switch_ops = { .teardown = ksz_teardown, .phy_read = ksz_phy_read16, .phy_write = ksz_phy_write16, - .phylink_get_caps = ksz_phylink_get_caps, + .phylink_get_caps = ksz8_phylink_get_caps, .port_setup = ksz_port_setup, .get_strings = ksz_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, @@ -2400,7 +2401,7 @@ const struct dsa_switch_ops ksz88xx_switch_ops = { .teardown = ksz_teardown, .phy_read = ksz_phy_read16, .phy_write = ksz_phy_write16, - .phylink_get_caps = ksz_phylink_get_caps, + .phylink_get_caps = ksz8_phylink_get_caps, .port_setup = ksz_port_setup, .get_strings = ksz_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 14ee9686ca0a..65fd07ef73ad 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1165,9 +1165,11 @@ static phy_interface_t ksz9477_get_interface(struct ksz_device *dev, int port) return interface; } -static void ksz9477_get_caps(struct ksz_device *dev, int port, - struct phylink_config *config) +static void ksz9477_phylink_get_caps(struct dsa_switch *ds, int port, + struct phylink_config *config) { + struct ksz_device *dev = ds->priv; + config->mac_capabilities = MAC_10 | MAC_100 | MAC_ASYM_PAUSE | MAC_SYM_PAUSE; @@ -1181,6 +1183,8 @@ static void ksz9477_get_caps(struct ksz_device *dev, int port, config->supported_interfaces, p->pcs->supported_interfaces); } + + ksz_phylink_get_caps(ds, port, config); } static int ksz9477_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) @@ -1791,7 +1795,6 @@ const struct ksz_dev_ops ksz9477_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, - .get_caps = ksz9477_get_caps, .pme_write8 = ksz_write8, .pme_pread8 = ksz_pread8, .pme_pwrite8 = ksz_pwrite8, @@ -1812,7 +1815,7 @@ const struct dsa_switch_ops ksz9477_switch_ops = { .teardown = ksz_teardown, .phy_read = ksz_phy_read16, .phy_write = ksz_phy_write16, - .phylink_get_caps = ksz_phylink_get_caps, + .phylink_get_caps = ksz9477_phylink_get_caps, .port_setup = ksz_port_setup, .set_ageing_time = ksz9477_set_ageing_time, .get_strings = ksz_get_strings, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index ad7615849c7a..4a7bcd1a9392 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1995,9 +1995,6 @@ void ksz_phylink_get_caps(struct dsa_switch *ds, int port, config->supported_interfaces); } - if (dev->dev_ops->get_caps) - dev->dev_ops->get_caps(dev, port, config); - if (ds->ops->support_eee && ds->ops->support_eee(ds, port)) { memcpy(config->lpi_interfaces, config->supported_interfaces, sizeof(config->lpi_interfaces)); diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 94eb79fa3439..f6dad256a550 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -408,8 +408,6 @@ struct ksz_dev_ops { void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt); void (*r_mib_stat64)(struct ksz_device *dev, int port); - void (*get_caps)(struct ksz_device *dev, int port, - struct phylink_config *config); int (*pme_write8)(struct ksz_device *dev, u32 reg, u8 value); int (*pme_pread8)(struct ksz_device *dev, int port, int offset, u8 *data); diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c index 621139a2c302..f84548168b37 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -575,9 +575,11 @@ static void lan937x_set_rgmii_rx_delay(struct ksz_device *dev, int port) lan937x_set_tune_adj(dev, port, REG_PORT_XMII_CTRL_4, val); } -static void lan937x_phylink_get_caps(struct ksz_device *dev, int port, +static void lan937x_phylink_get_caps(struct dsa_switch *ds, int port, struct phylink_config *config) { + struct ksz_device *dev = ds->priv; + config->mac_capabilities = MAC_100FD; if (dev->info->supports_rgmii[port]) { @@ -588,6 +590,8 @@ static void lan937x_phylink_get_caps(struct ksz_device *dev, int port, config->mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_100HD | MAC_10; } + + ksz_phylink_get_caps(ds, port, config); } static void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port) @@ -713,7 +717,6 @@ const struct ksz_dev_ops lan937x_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, - .get_caps = lan937x_phylink_get_caps, .setup_rgmii_delay = lan937x_setup_rgmii_delay, .config_cpu_port = lan937x_config_cpu_port, .tc_cbs_set_cinc = lan937x_tc_cbs_set_cinc, @@ -731,7 +734,7 @@ const struct dsa_switch_ops lan937x_switch_ops = { .teardown = ksz_teardown, .phy_read = ksz_phy_read16, .phy_write = ksz_phy_write16, - .phylink_get_caps = ksz_phylink_get_caps, + .phylink_get_caps = lan937x_phylink_get_caps, .port_setup = ksz_port_setup, .set_ageing_time = lan937x_set_ageing_time, .get_strings = ksz_get_strings,