From: Vladimir Oltean 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) --- 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 83795fd66aab2..38876e1779564 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 69a4fb683b3a1..14ee9686ca0ab 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 39f042e56f365..599db0a6ba2e3 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 d17ce88d49471..ad7615849c7a4 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 fe3b2dad3d684..94eb79fa34392 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 aa428353818d8..621139a2c3025 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, -- 2.53.0