realtek: dsa: Drop secondary LAG configuration handler
authorSven Eckelmann <[email protected]>
Sun, 9 Nov 2025 08:26:27 +0000 (09:26 +0100)
committerHauke Mehrtens <[email protected]>
Tue, 11 Nov 2025 00:06:49 +0000 (01:06 +0100)
The DSA code is responsible to inform the driver about link aggregation
changes. Having a second one which behaves slightly different makes the
whole process fragile and creates hard to debug problems.

It also complicates the code because the secondary event handler can also
not rely on shared DSA state to handle things like LAG ID.

Signed-off-by: Sven Eckelmann <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/20707
Signed-off-by: Hauke Mehrtens <[email protected]>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h

index 0a77db6b5d4e5f8210ee2a4ee7f71e295067ecd8..dc588d40d40c7c2246b69f0db260eed988d6394b 100644 (file)
@@ -689,59 +689,6 @@ static int rtl83xx_l2_nexthop_rm(struct rtl838x_switch_priv *priv, struct rtl83x
        return 0;
 }
 
-static int rtl83xx_handle_changeupper(struct rtl838x_switch_priv *priv,
-                                     struct net_device *ndev,
-                                     struct netdev_notifier_changeupper_info *info)
-{
-       struct net_device *upper = info->upper_dev;
-       struct netdev_lag_upper_info *lag_upper_info = NULL;
-       int i, j, err;
-
-       if (!netif_is_lag_master(upper))
-               return 0;
-
-       mutex_lock(&priv->reg_mutex);
-
-       for (i = 0; i < priv->ds->num_lag_ids; i++) {
-               if ((!priv->lag_devs[i]) || (priv->lag_devs[i] == upper))
-                       break;
-       }
-       for (j = 0; j < priv->cpu_port; j++) {
-               if (priv->ports[j].dp->user == ndev)
-                       break;
-       }
-       if (j >= priv->cpu_port) {
-               err = -EINVAL;
-               goto out;
-       }
-
-       if (info->linking) {
-               lag_upper_info = info->upper_info;
-               if (!priv->lag_devs[i])
-                       priv->lag_devs[i] = upper;
-               err = rtl83xx_lag_add(priv->ds, i, priv->ports[j].dp->index, lag_upper_info);
-               if (err) {
-                       err = -EINVAL;
-                       goto out;
-               }
-       } else {
-               if (!priv->lag_devs[i])
-                       err = -EINVAL;
-               err = rtl83xx_lag_del(priv->ds, i, priv->ports[j].dp->index);
-               if (err) {
-                       err = -EINVAL;
-                       goto out;
-               }
-               if (!priv->lags_port_members[i])
-                       priv->lag_devs[i] = NULL;
-       }
-
-out:
-       mutex_unlock(&priv->reg_mutex);
-
-       return 0;
-}
-
 int rtl83xx_port_is_under(const struct net_device * dev, struct rtl838x_switch_priv *priv)
 {
        /* Is the lower network device a DSA user network device of our RTL930X-switch?
@@ -764,31 +711,6 @@ int rtl83xx_port_is_under(const struct net_device * dev, struct rtl838x_switch_p
        return -EINVAL;
 }
 
-static int rtl83xx_netdevice_event(struct notifier_block *this,
-                                  unsigned long event, void *ptr)
-{
-       struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
-       struct rtl838x_switch_priv *priv;
-       int err;
-
-       pr_debug("In: %s, event: %lu\n", __func__, event);
-
-       if ((event != NETDEV_CHANGEUPPER) && (event != NETDEV_CHANGELOWERSTATE))
-               return NOTIFY_DONE;
-
-       priv = container_of(this, struct rtl838x_switch_priv, nb);
-       switch (event) {
-       case NETDEV_CHANGEUPPER:
-               err = rtl83xx_handle_changeupper(priv, ndev, ptr);
-               break;
-       }
-
-       if (err)
-               return err;
-
-       return NOTIFY_DONE;
-}
-
 static const struct rhashtable_params route_ht_params = {
        .key_len     = sizeof(u32),
        .key_offset  = offsetof(struct rtl83xx_route, gw_ip),
@@ -1701,14 +1623,6 @@ static int __init rtl83xx_sw_probe(struct platform_device *pdev)
        for (int i = 0; i < 4; i++)
                priv->mirror_group_ports[i] = -1;
 
-       /* Register netdevice event callback to catch changes in link aggregation groups */
-       priv->nb.notifier_call = rtl83xx_netdevice_event;
-       if (register_netdevice_notifier(&priv->nb)) {
-               priv->nb.notifier_call = NULL;
-               dev_err(dev, "Failed to register LAG netdev notifier\n");
-               goto err_register_nb;
-       }
-
        /* Initialize hash table for L3 routing */
        rhltable_init(&priv->routes, &route_ht_params);
 
@@ -1756,8 +1670,6 @@ static int __init rtl83xx_sw_probe(struct platform_device *pdev)
 err_register_fib_nb:
        unregister_netevent_notifier(&priv->ne_nb);
 err_register_ne_nb:
-       unregister_netdevice_notifier(&priv->nb);
-err_register_nb:
        dsa_switch_shutdown(priv->ds);
 err_register_switch:
        destroy_workqueue(priv->wq);
index f0005b6be027af6b40afbb88c532a358404234d3..292a9893cb066267f3a42946f541d3e6eb453799 100644 (file)
@@ -1170,7 +1170,6 @@ struct rtl838x_switch_priv {
        u32 is_lagmember[57];
        u64 lagmembers;
        struct workqueue_struct *wq;
-       struct notifier_block nb;  /* TODO: change to different name */
        struct notifier_block ne_nb;
        struct notifier_block fib_nb;
        bool eee_enabled;