]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dsa: microchip: bypass dev_ops for mirror operations
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 12 May 2026 13:06:28 +0000 (15:06 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 May 2026 01:16:15 +0000 (18:16 -0700)
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 <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-6-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/ksz9477.h
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h
drivers/net/dsa/microchip/lan937x_main.c

index 83795fd66aab232d8845d7ab52110f0c05fd33df..38876e17795640492379edd9e6efaddf31c7e3b4 100644 (file)
@@ -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,
index 69a4fb683b3a16b8b547bc05cb50de83a09b453e..14ee9686ca0ab6adec22b38cc52a0f9eca09072e 100644 (file)
@@ -1080,10 +1080,11 @@ exit:
        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,
index 39f042e56f36532d02d0568313daf5389ecb5ff7..599db0a6ba2e37f2a8fad3b56301edad3e7eee2d 100644 (file)
@@ -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);
index d17ce88d49471e47c6c9c4159d10228c35c3fd78..ad7615849c7a4453017d90096324b07ed1cc5aa8 100644 (file)
@@ -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;
index fe3b2dad3d684a62cb9ceea349dc094f651e9489..94eb79fa34392990284ad8575005ba96661d6a2a 100644 (file)
@@ -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);
index aa428353818d82bc84cdcdf2e3e617a8cc4fdde9..621139a2c302595aa487950aae3158444f30b58e 100644 (file)
@@ -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,