Skip to content

Commit 626cc67

Browse files
committed
realtek: l3: move notifier blocks to private structure
Relocate the notification handlers into the new L3 ecosystem. Link: openwrt/openwrt#23937 Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
1 parent 8c2ef13 commit 626cc67

3 files changed

Lines changed: 23 additions & 23 deletions

File tree

target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,16 @@ static void otto_l3_fib_event_work_do(struct work_struct *work)
567567
/* Called with rcu_read_lock() */
568568
static int otto_l3_fib_notifier(struct notifier_block *this, unsigned long event, void *ptr)
569569
{
570-
struct fib_notifier_info *info = ptr;
571-
struct rtl838x_switch_priv *priv;
570+
struct otto_l3_ctrl *ctrl = container_of(this, struct otto_l3_ctrl, fib_nb);
571+
struct rtl838x_switch_priv *priv = ctrl->priv;
572572
struct otto_l3_fib_event_work *fib_work;
573+
struct fib_notifier_info *info = ptr;
573574

574575
if ((info->family != AF_INET && info->family != AF_INET6 &&
575576
info->family != RTNL_FAMILY_IPMR &&
576577
info->family != RTNL_FAMILY_IP6MR))
577578
return NOTIFY_DONE;
578579

579-
priv = container_of(this, struct rtl838x_switch_priv, fib_nb);
580-
581580
/* ignore FIB events for HW with missing L3 offloading implementation */
582581
if (!priv->r->l3_setup)
583582
return NOTIFY_DONE;
@@ -647,13 +646,12 @@ static void otto_l3_net_event_work_do(struct work_struct *work)
647646

648647
static int otto_l3_netevent_notifier(struct notifier_block *this, unsigned long event, void *ptr)
649648
{
650-
struct rtl838x_switch_priv *priv;
651-
struct net_device *dev;
649+
struct otto_l3_ctrl *ctrl = container_of(this, struct otto_l3_ctrl, ne_nb);
650+
struct rtl838x_switch_priv *priv = ctrl->priv;
651+
struct otto_l3_net_event_work *net_work;
652652
struct neighbour *n = ptr;
653+
struct net_device *dev;
653654
int err, port;
654-
struct otto_l3_net_event_work *net_work;
655-
656-
priv = container_of(this, struct rtl838x_switch_priv, ne_nb);
657655

658656
switch (event) {
659657
case NETEVENT_NEIGH_UPDATE:
@@ -693,13 +691,15 @@ static int otto_l3_netevent_notifier(struct notifier_block *this, unsigned long
693691

694692
void otto_l3_remove(struct rtl838x_switch_priv *priv)
695693
{
696-
if (priv->ne_nb.notifier_call) {
697-
unregister_netevent_notifier(&priv->ne_nb);
698-
priv->ne_nb.notifier_call = NULL;
694+
struct otto_l3_ctrl *ctrl = priv->l3_ctrl;
695+
696+
if (ctrl->ne_nb.notifier_call) {
697+
unregister_netevent_notifier(&ctrl->ne_nb);
698+
ctrl->ne_nb.notifier_call = NULL;
699699
}
700-
if (priv->fib_nb.notifier_call) {
701-
unregister_fib_notifier(&init_net, &priv->fib_nb);
702-
priv->fib_nb.notifier_call = NULL;
700+
if (ctrl->fib_nb.notifier_call) {
701+
unregister_fib_notifier(&init_net, &ctrl->fib_nb);
702+
ctrl->fib_nb.notifier_call = NULL;
703703
}
704704
}
705705

@@ -721,10 +721,10 @@ int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv)
721721
* Register netevent notifier callback to catch notifications about neighboring changes
722722
* to update nexthop entries for L3 routing.
723723
*/
724-
priv->ne_nb.notifier_call = otto_l3_netevent_notifier;
725-
err = register_netevent_notifier(&priv->ne_nb);
724+
ctrl->ne_nb.notifier_call = otto_l3_netevent_notifier;
725+
err = register_netevent_notifier(&ctrl->ne_nb);
726726
if (err) {
727-
priv->ne_nb.notifier_call = NULL;
727+
ctrl->ne_nb.notifier_call = NULL;
728728
return dev_err_probe(dev, err, "Failed to register netevent notifier\n");
729729
}
730730

@@ -733,10 +733,10 @@ int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv)
733733
* FIBs pointing to our own netdevs are programmed into the device, so no need to pass a
734734
* callback.
735735
*/
736-
priv->fib_nb.notifier_call = otto_l3_fib_notifier;
737-
err = register_fib_notifier(&init_net, &priv->fib_nb, NULL, NULL);
736+
ctrl->fib_nb.notifier_call = otto_l3_fib_notifier;
737+
err = register_fib_notifier(&init_net, &ctrl->fib_nb, NULL, NULL);
738738
if (err) {
739-
priv->fib_nb.notifier_call = NULL;
739+
ctrl->fib_nb.notifier_call = NULL;
740740
otto_l3_remove(priv);
741741
return dev_err_probe(dev, err, "Failed to register fib event notifier\n");
742742
}

target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
struct otto_l3_ctrl {
99
struct rtl838x_switch_priv *priv;
10+
struct notifier_block fib_nb;
11+
struct notifier_block ne_nb;
1012
};
1113

1214
struct otto_l3_route_attr {

target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,8 +1504,6 @@ struct rtl838x_switch_priv {
15041504
/** @lagmembers: Port (bit) is part of any LAG */
15051505
u64 lagmembers;
15061506
struct workqueue_struct *wq;
1507-
struct notifier_block ne_nb;
1508-
struct notifier_block fib_nb;
15091507
bool eee_enabled;
15101508
unsigned long mc_group_bm[MAX_MC_GROUPS >> 5];
15111509
struct rhashtable tc_ht;

0 commit comments

Comments
 (0)