]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: l3: add device specific configuration
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sat, 27 Jun 2026 11:48:59 +0000 (13:48 +0200)
committerMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 28 Jun 2026 06:46:37 +0000 (08:46 +0200)
All the layer 3 device specific functions and attributes currently
live in the DSA driver. Add a configuration structure to the layer
3 code. For now provide and fill a dummy value. It will be replaced
with meaningful data with the next patches.

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

index 86b407d8207baf4cc585aa12402d7deb80991b4d..305d9e8beb8d81379ed8587aa88751dd6e0fe7f6 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/if_vlan.h>
 #include <linux/inetdevice.h>
 #include <linux/notifier.h>
+#include <linux/of.h>
 #include <linux/rhashtable.h>
 #include <net/arp.h>
 #include <net/fib_notifier.h>
@@ -697,6 +698,30 @@ static int otto_l3_netevent_notifier(struct notifier_block *this, unsigned long
        return NOTIFY_DONE;
 }
 
+const struct otto_l3_config otto_l3_838x_cfg = {
+       ._dummy = 8380,
+};
+
+const struct otto_l3_config otto_l3_839x_cfg = {
+       ._dummy = 8390,
+};
+
+const struct otto_l3_config otto_l3_930x_cfg = {
+       ._dummy = 9300,
+};
+
+const struct otto_l3_config otto_l3_931x_cfg = {
+       ._dummy = 9310,
+};
+
+static const struct of_device_id otto_l3_of_ids[] = {
+       { .compatible = "realtek,rtl8380-switch", .data = &otto_l3_838x_cfg, },
+       { .compatible = "realtek,rtl8392-switch", .data = &otto_l3_839x_cfg, },
+       { .compatible = "realtek,rtl9301-switch", .data = &otto_l3_930x_cfg, },
+       { .compatible = "realtek,rtl9311-switch", .data = &otto_l3_931x_cfg, },
+       { /* sentinel */ }
+};
+
 void otto_l3_remove(struct rtl838x_switch_priv *priv)
 {
        struct otto_l3_ctrl *ctrl = priv->l3_ctrl;
@@ -713,6 +738,7 @@ void otto_l3_remove(struct rtl838x_switch_priv *priv)
 
 int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv)
 {
+       const struct of_device_id *match;
        struct otto_l3_ctrl *ctrl;
        int err;
 
@@ -723,6 +749,11 @@ int otto_l3_probe(struct device *dev, struct rtl838x_switch_priv *priv)
        ctrl->priv = priv;
        ctrl->dev = priv->dev;
 
+       match = of_match_node(otto_l3_of_ids, dev->of_node);
+       if (!match)
+               return dev_err_probe(dev, -EINVAL, "No compatible configuration found\n");
+       ctrl->cfg = match->data;
+
        /* Initialize hash table for L3 routing */
        rhltable_init(&ctrl->routes, &otto_l3_route_ht_params);
 
index 8894075c0f84f56b8e233b526115a1d39d33a863..4ab71dea98ff2ae16f3b26f8e7ca4965c8b9f56c 100644 (file)
@@ -5,7 +5,12 @@
 
 #include "rtl-otto.h"
 
+struct otto_l3_config {
+       int _dummy;
+};
+
 struct otto_l3_ctrl {
+       const struct otto_l3_config *cfg;
        struct device *dev;
        struct rtl838x_switch_priv *priv;
        struct notifier_block fib_nb;