]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: l3: relocate get_egress_mac()
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 28 Jun 2026 07:56:02 +0000 (09:56 +0200)
committerMarkus Stockhausen <markus.stockhausen@gmx.de>
Mon, 29 Jun 2026 16:17:07 +0000 (18:17 +0200)
Move get_egress_mac() from DSA to 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/l3.h
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h
target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl930x.c

index 2dbadb60675c43a4c66827da9b99bf6c26a3e0cd..19bc1489617d1fc83058a040bc7a21facb624d8a 100644 (file)
@@ -95,6 +95,26 @@ static void otto_l3_839x_route_write(struct otto_l3_ctrl *ctrl, int idx, struct
        rtl_table_release(r);
 }
 
+/*
+ * Get the Destination-MAC of an L3 egress interface or the Source MAC for routed packets
+ * from the SoC's L3_EGR_INTF_MAC table. Indexes 0-2047 are DMACs, 2048+ are SMACs
+ */
+__maybe_unused
+static u64 otto_l3_930x_get_egress_mac(struct otto_l3_ctrl *ctrl, u32 idx)
+{
+       struct table_reg *r = rtl_table_get(RTL9300_TBL_2, 2);
+       u64 mac;
+
+       rtl_table_read(r, idx);
+       /* The table has a size of 2 registers */
+       mac = sw_r32(rtl_table_data(r, 0));
+       mac <<= 32;
+       mac |= sw_r32(rtl_table_data(r, 1));
+       rtl_table_release(r);
+
+       return mac;
+}
+
 /* Write a host route entry from the table using its index. Only unicast routes supported */
 __maybe_unused
 static void otto_l3_930x_host_route_write(struct otto_l3_ctrl *ctrl, int idx, struct otto_l3_route *rt)
@@ -563,7 +583,7 @@ static int otto_l3_alloc_egress_intf(struct otto_l3_ctrl *ctrl, u64 mac, int vla
 
        mutex_lock(&priv->reg_mutex);
        for (int i = 0; i < MAX_SMACS; i++) {
-               m = priv->r->get_l3_egress_mac(L3_EGRESS_DMACS + i);
+               m = ctrl->cfg->get_egress_mac(ctrl, L3_EGRESS_DMACS + i);
                if (free_mac < 0 && !m) {
                        free_mac = i;
                        continue;
@@ -1149,6 +1169,7 @@ const struct otto_l3_config otto_l3_839x_cfg = {
 
 const struct otto_l3_config otto_l3_930x_cfg = {
 #ifdef CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD
+       .get_egress_mac = otto_l3_930x_get_egress_mac,
        .host_route_write = otto_l3_930x_host_route_write,
        .get_router_mac = otto_l3_930x_get_router_mac,
        .set_router_mac = otto_l3_930x_set_router_mac,
index 276c19a80bc1136072d5fab82e134cc74d9151bc..6445c1cad4857a5ffc79c9a6944a8609182a26f0 100644 (file)
@@ -28,6 +28,7 @@ struct otto_l3_router_mac {
 
 
 struct otto_l3_config {
+       u64 (*get_egress_mac)(struct otto_l3_ctrl *ctrl, u32 idx);
        void (*host_route_write)(struct otto_l3_ctrl *ctrl, int idx, struct otto_l3_route *rt);
        void (*get_router_mac)(struct otto_l3_ctrl *ctrl, u32 idx, struct otto_l3_router_mac *m);
        void (*set_router_mac)(struct otto_l3_ctrl *ctrl, u32 idx, struct otto_l3_router_mac *m);
index dea01a6f727ca03fa767e69b1d81a8dbc0fface3..c1abc0d3474ec95c2d3ea86000dd2087bbec8003 100644 (file)
@@ -1418,7 +1418,6 @@ struct rtldsa_config {
        u32 (*packet_cntr_read)(int counter);
        void (*packet_cntr_clear)(int counter);
        int (*l3_setup)(struct rtl838x_switch_priv *priv);
-       u64 (*get_l3_egress_mac)(u32 idx);
        void (*set_l3_egress_mac)(u32 idx, u64 mac);
        int (*find_l3_slot)(struct otto_l3_route *rt, bool must_exist);
        void (*set_l3_egress_intf)(int idx, struct rtl838x_l3_intf *intf);
index a07100cf9f45e06bfd8d32957ac0293f453f60e8..c51de884542b05243f93a42505b8ca822a5cc0f8 100644 (file)
@@ -1999,26 +1999,6 @@ static void rtl930x_set_l3_egress_intf(int idx, struct rtl838x_l3_intf *intf)
        rtl_table_release(r);
 }
 
-/* Get the Destination-MAC of an L3 egress interface or the Source MAC for routed packets
- * from the SoC's L3_EGR_INTF_MAC table
- * Indexes 0-2047 are DMACs, 2048+ are SMACs
- */
-static u64 rtl930x_get_l3_egress_mac(u32 idx)
-{
-       u64 mac;
-       /* Read L3_EGR_INTF_MAC table (2) via register RTL9300_TBL_2 */
-       struct table_reg *r = rtl_table_get(RTL9300_TBL_2, 2);
-
-       rtl_table_read(r, idx);
-       /* The table has a size of 2 registers */
-       mac = sw_r32(rtl_table_data(r, 0));
-       mac <<= 32;
-       mac |= sw_r32(rtl_table_data(r, 1));
-       rtl_table_release(r);
-
-       return mac;
-}
-
 /* Set the Destination-MAC of a route or the Source MAC of an L3 egress interface
  * in the SoC's L3_EGR_INTF_MAC table
  * Indexes 0-2047 are DMACs, 2048+ are SMACs
@@ -2520,7 +2500,6 @@ const struct rtldsa_config rtldsa_930x_cfg = {
        .packet_cntr_clear = rtl930x_packet_cntr_clear,
 #ifdef CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD
        .l3_setup = rtl930x_l3_setup,
-       .get_l3_egress_mac = rtl930x_get_l3_egress_mac,
        .set_l3_egress_mac = rtl930x_set_l3_egress_mac,
        .find_l3_slot = rtl930x_find_l3_slot,
        .set_l3_egress_intf = rtl930x_set_l3_egress_intf,