From: Markus Stockhausen Date: Sun, 28 Jun 2026 07:56:02 +0000 (+0200) Subject: realtek: l3: relocate get_egress_mac() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e0377bf3827bfaaf081f9cf7dec9d76076b4b42e;p=thirdparty%2Fopenwrt.git realtek: l3: relocate get_egress_mac() Move get_egress_mac() from DSA to layer 3 code. Link: https://github.com/openwrt/openwrt/pull/23979 Signed-off-by: Markus Stockhausen --- diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c index 2dbadb60675..19bc1489617 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c @@ -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, diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h index 276c19a80bc..6445c1cad48 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.h @@ -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); diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h index dea01a6f727..c1abc0d3474 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl-otto.h @@ -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); diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl930x.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl930x.c index a07100cf9f4..c51de884542 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl930x.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl930x.c @@ -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,