From: Sven Eckelmann Date: Sun, 9 Nov 2025 08:26:27 +0000 (+0100) Subject: realtek: dsa: Drop secondary LAG configuration handler X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=ca014cfd729ff64f652d273c65f47d598019a3d0;p=openwrt%2Fstaging%2Fxback.git realtek: dsa: Drop secondary LAG configuration handler 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 Link: https://github.com/openwrt/openwrt/pull/20707 Signed-off-by: Hauke Mehrtens --- diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c index 0a77db6b5d..dc588d40d4 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c @@ -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); diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h index f0005b6be0..292a9893cb 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h @@ -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;