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 <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>
This commit is contained in:
Vladimir Oltean 2026-05-12 15:06:28 +02:00 committed by Jakub Kicinski
parent ede165ba0b
commit 5973ddcc17
6 changed files with 20 additions and 57 deletions

View 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,

View File

@ -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,

View 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);

View 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;

View 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);

View 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,