]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: l3: relocate RTL83xx setup
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 28 Jun 2026 09:51:27 +0000 (11:51 +0200)
committerMarkus Stockhausen <markus.stockhausen@gmx.de>
Mon, 29 Jun 2026 16:17:08 +0000 (18:17 +0200)
Make use of the new layer 3 setup callback for RTL83xx.

- RTL838x had no setup. Drtop it completely
- RTL839x move the setup over to the layer 3 code.

Link: https://github.com/openwrt/openwrt/pull/23979
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/rtl838x.c
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl839x.c

index dfa30fe42b4b83158cc44c835fc95fb5c69ebe05..f9e8cf61b0d94d4fd4726dfb4889ac9b648bd418 100644 (file)
@@ -101,6 +101,31 @@ static void otto_l3_839x_route_write(struct otto_l3_ctrl *ctrl, int idx, struct
        rtl_table_release(r);
 }
 
+static void otto_l3_839x_setup_port_macs(struct otto_l3_ctrl *ctrl)
+{
+       struct rtl838x_switch_priv *priv = ctrl->priv;
+       struct net_device *dev;
+       u64 mac;
+
+       /* Configure the switch's own MAC addresses used when routing packets */
+       dev_dbg(ctrl->dev, "got port %08x\n", (u32)priv->ports[priv->r->cpu_port].dp);
+       dev = priv->ports[priv->r->cpu_port].dp->user;
+       mac = ether_addr_to_u64(dev->dev_addr);
+
+       for (int i = 0; i < 15; i++) {
+               mac++;  /* BUG: VRRP for testing */
+               sw_w32(mac >> 32, RTL839X_ROUTING_SA_CTRL + i * 8);
+               sw_w32(mac, RTL839X_ROUTING_SA_CTRL + i * 8 + 4);
+       }
+}
+
+static int otto_l3_839x_setup(struct otto_l3_ctrl *ctrl)
+{
+       otto_l3_839x_setup_port_macs(ctrl);
+
+       return 0;
+}
+
 __maybe_unused
 static u32 otto_l3_930x_hash4(u32 ip, int algorithm, bool move_dip)
 {
@@ -1314,6 +1339,7 @@ const struct otto_l3_config otto_l3_838x_cfg = {
 const struct otto_l3_config otto_l3_839x_cfg = {
        .route_read = otto_l3_839x_route_read,
        .route_write = otto_l3_839x_route_write,
+       .setup = otto_l3_839x_setup,
 };
 
 const struct otto_l3_config otto_l3_930x_cfg = {
index 3dd1cc6f1319fc7d8de84138a10b77281bb449ba..d614dcb3a62211c52c1031ca5be8c5872639cdba 100644 (file)
@@ -1628,12 +1628,6 @@ static void rtl838x_packet_cntr_clear(int counter)
        rtl_table_release(r);
 }
 
-static int rtl838x_l3_setup(struct rtl838x_switch_priv *priv)
-{
-       /* Nothing to be done */
-       return 0;
-}
-
 static void rtl838x_vlan_port_keep_tag_set(int port, bool keep_outer, bool keep_inner)
 {
        sw_w32(FIELD_PREP(RTL838X_VLAN_PORT_TAG_STS_CTRL_OTAG_STS_MASK,
@@ -1847,7 +1841,6 @@ const struct rtldsa_config rtldsa_838x_cfg = {
        .l2_learning_setup = rtl838x_l2_learning_setup,
        .packet_cntr_read = rtl838x_packet_cntr_read,
        .packet_cntr_clear = rtl838x_packet_cntr_clear,
-       .l3_setup = rtl838x_l3_setup,
        .set_receive_management_action = rtl838x_set_receive_management_action,
        .qos_init = rtldsa_838x_qos_init,
        .lag_set_distribution_algorithm = rtldsa_838x_set_distribution_algorithm,
index 857201be290ad90cd4096bd5ebe0b5951e922448..27959172d8d1db6901073881039c03aefdd3621e 100644 (file)
@@ -1533,30 +1533,6 @@ static void rtl839x_packet_cntr_clear(int counter)
        rtl_table_release(r);
 }
 
-/* Configure the switch's own MAC addresses used when routing packets */
-static void rtl839x_setup_port_macs(struct rtl838x_switch_priv *priv)
-{
-       struct net_device *dev;
-       u64 mac;
-
-       pr_debug("%s: got port %08x\n", __func__, (u32)priv->ports[priv->r->cpu_port].dp);
-       dev = priv->ports[priv->r->cpu_port].dp->user;
-       mac = ether_addr_to_u64(dev->dev_addr);
-
-       for (int i = 0; i < 15; i++) {
-               mac++;  /* BUG: VRRP for testing */
-               sw_w32(mac >> 32, RTL839X_ROUTING_SA_CTRL + i * 8);
-               sw_w32(mac, RTL839X_ROUTING_SA_CTRL + i * 8 + 4);
-       }
-}
-
-static int rtl839x_l3_setup(struct rtl838x_switch_priv *priv)
-{
-       rtl839x_setup_port_macs(priv);
-
-       return 0;
-}
-
 static void rtl839x_vlan_port_keep_tag_set(int port, bool keep_outer, bool keep_inner)
 {
        sw_w32(FIELD_PREP(RTL839X_VLAN_PORT_TAG_STS_CTRL_OTAG_STS_MASK,
@@ -1756,7 +1732,6 @@ const struct rtldsa_config rtldsa_839x_cfg = {
        .l2_learning_setup = rtl839x_l2_learning_setup,
        .packet_cntr_read = rtl839x_packet_cntr_read,
        .packet_cntr_clear = rtl839x_packet_cntr_clear,
-       .l3_setup = rtl839x_l3_setup,
        .set_receive_management_action = rtl839x_set_receive_management_action,
        .qos_init = rtldsa_839x_qos_init,
        .lag_set_distribution_algorithm = rtldsa_839x_set_distribution_algorithm,