]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: l3: move routes to l3 structure
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Fri, 26 Jun 2026 16:28:29 +0000 (18:28 +0200)
committerMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 28 Jun 2026 06:46:36 +0000 (08:46 +0200)
Make routes an attribute of the new layer 3 control structure.

Link: https://github.com/openwrt/openwrt/pull/23963
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h

index db3caadb8bd93ab52c953757385a4b8b16a4c20b..68daeffd4e28904260a0c83f853697e65ef5367a 100644 (file)
@@ -157,11 +157,12 @@ static int otto_l3_alloc_egress_intf(struct rtl838x_switch_priv *priv, u64 mac,
 /* Updates an L3 next hop entry in the ROUTING table */
 static int otto_l3_nexthop_update(struct rtl838x_switch_priv *priv, __be32 ip_addr, u64 mac)
 {
-       struct otto_l3_route *r;
+       struct otto_l3_ctrl *ctrl = priv->l3_ctrl;
        struct rhlist_head *tmp, *list;
+       struct otto_l3_route *r;
 
        rcu_read_lock();
-       list = rhltable_lookup(&priv->routes, &ip_addr, otto_l3_route_ht_params);
+       list = rhltable_lookup(&ctrl->routes, &ip_addr, otto_l3_route_ht_params);
        if (!list) {
                rcu_read_unlock();
                return -ENOENT;
@@ -264,9 +265,10 @@ static int otto_l3_port_ipv4_resolve(struct rtl838x_switch_priv *priv,
 
 static void otto_l3_route_remove(struct rtl838x_switch_priv *priv, struct otto_l3_route *r)
 {
+       struct otto_l3_ctrl *ctrl = priv->l3_ctrl;
        int id;
 
-       if (rhltable_remove(&priv->routes, &r->linkage, otto_l3_route_ht_params))
+       if (rhltable_remove(&ctrl->routes, &r->linkage, otto_l3_route_ht_params))
                dev_warn(priv->dev, "Could not remove route\n");
 
        if (r->is_host_route) {
@@ -291,6 +293,7 @@ static void otto_l3_route_remove(struct rtl838x_switch_priv *priv, struct otto_l
 
 static struct otto_l3_route *otto_l3_host_route_alloc(struct rtl838x_switch_priv *priv, u32 ip)
 {
+       struct otto_l3_ctrl *ctrl = priv->l3_ctrl;
        struct otto_l3_route *r;
        int idx = 0, err;
 
@@ -314,7 +317,7 @@ static struct otto_l3_route *otto_l3_host_route_alloc(struct rtl838x_switch_priv
        r->pr.id = -1; /* We still need to allocate a rule in HW */
        r->is_host_route = true;
 
-       err = rhltable_insert(&priv->routes, &r->linkage, otto_l3_route_ht_params);
+       err = rhltable_insert(&ctrl->routes, &r->linkage, otto_l3_route_ht_params);
        if (err) {
                pr_err("Could not insert new rule\n");
                mutex_unlock(&priv->reg_mutex);
@@ -335,6 +338,7 @@ out_free:
 
 static struct otto_l3_route *otto_l3_route_alloc(struct rtl838x_switch_priv *priv, u32 ip)
 {
+       struct otto_l3_ctrl *ctrl = priv->l3_ctrl;
        struct otto_l3_route *r;
        int idx = 0, err;
 
@@ -354,7 +358,7 @@ static struct otto_l3_route *otto_l3_route_alloc(struct rtl838x_switch_priv *pri
        r->pr.id = -1; /* We still need to allocate a rule in HW */
        r->is_host_route = false;
 
-       err = rhltable_insert(&priv->routes, &r->linkage, otto_l3_route_ht_params);
+       err = rhltable_insert(&ctrl->routes, &r->linkage, otto_l3_route_ht_params);
        if (err) {
                pr_err("Could not insert new rule\n");
                mutex_unlock(&priv->reg_mutex);
@@ -476,6 +480,7 @@ static int otto_l3_fib_del_v4(struct rtl838x_switch_priv *priv,
                           struct fib_entry_notifier_info *info)
 {
        struct fib_nh *nh = fib_info_nh(info->fi, 0);
+       struct otto_l3_ctrl *ctrl = priv->l3_ctrl;
        struct rhlist_head *tmp, *list;
        struct otto_l3_route *route;
 
@@ -483,7 +488,7 @@ static int otto_l3_fib_del_v4(struct rtl838x_switch_priv *priv,
                return 0;
 
        rcu_read_lock();
-       list = rhltable_lookup(&priv->routes, &nh->fib_nh_gw4, otto_l3_route_ht_params);
+       list = rhltable_lookup(&ctrl->routes, &nh->fib_nh_gw4, otto_l3_route_ht_params);
        if (!list) {
                rcu_read_unlock();
                dev_err(priv->dev, "no such gateway: %pI4\n", &nh->fib_nh_gw4);
@@ -715,7 +720,7 @@ int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv)
        ctrl->priv = priv;
 
        /* Initialize hash table for L3 routing */
-       rhltable_init(&priv->routes, &otto_l3_route_ht_params);
+       rhltable_init(&ctrl->routes, &otto_l3_route_ht_params);
 
        /*
         * Register netevent notifier callback to catch notifications about neighboring changes
index d61087dffff4d50d1aa72af899a8f8a0f0fc790c..fb6d47cdb6d12948158a3e045a23cf09b817ff03 100644 (file)
@@ -9,6 +9,7 @@ struct otto_l3_ctrl {
        struct rtl838x_switch_priv *priv;
        struct notifier_block fib_nb;
        struct notifier_block ne_nb;
+       struct rhltable routes;
 };
 
 struct otto_l3_route_attr {
index 832f047562d7df636cbd93585f5fcc20b25a2ac0..8b5b5bff62d8657d5ec15683ee0a88414d7f74f3 100644 (file)
@@ -1510,7 +1510,6 @@ struct rtl838x_switch_priv {
        unsigned long pie_use_bm[MAX_PIE_ENTRIES >> 5];
        unsigned long octet_cntr_use_bm[MAX_COUNTERS >> 5];
        unsigned long packet_cntr_use_bm[MAX_COUNTERS >> 4];
-       struct rhltable routes;
        unsigned long route_use_bm[MAX_ROUTES >> 5];
        unsigned long host_route_use_bm[MAX_HOST_ROUTES >> 5];
        struct rtl838x_l3_intf *interfaces[MAX_INTERFACES];