]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dsa: microchip: bypass dev_ops for VLAN operations
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 12 May 2026 13:06:26 +0000 (15:06 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 May 2026 01:16:15 +0000 (18:16 -0700)
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 <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-4-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 dd603e7f1a6399b14cf276f6a9b5232068285301..94c8034a192a95880ccb7f1addde7e9bddc32d17 100644 (file)
@@ -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,
index f21a05a86b4837be9393406f2def0f08a1daf20c..959229185df973f404eb4d7e6a5f08d9033a6d7b 100644 (file)
@@ -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,
index 8012904a21308af847bfceb0d7e2c8f086e70f6e..75a7b2bfc7976b36d3467d2af65b9a5ff920c78b 100644 (file)
@@ -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,
index eb13d548ebff91b17f7a21b82e11b55437457db3..07d1d58113f05a276105e605319437027d0d923d 100644 (file)
@@ -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)
index 0aa83c75c40a119583b571b0a9ed381c78265a43..d07b3f5918f8e8caed521130e2314bee6a0b6c23 100644 (file)
@@ -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);
index feaaaafeace61888006ec69b525ed363a9adb18c..be6a457ee8e4b7bf94a38cb8b7cc7d4700d2db0e 100644 (file)
@@ -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,