From: Markus Stockhausen Date: Sun, 28 Jun 2026 09:51:27 +0000 (+0200) Subject: realtek: l3: relocate RTL83xx setup X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5fe67b988710441f9e1e02086c324f169bbdde08;p=thirdparty%2Fopenwrt.git realtek: l3: relocate RTL83xx setup 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 --- 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 dfa30fe42b4..f9e8cf61b0d 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 @@ -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 = { diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.c index 3dd1cc6f131..d614dcb3a62 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl838x.c @@ -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, diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl839x.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl839x.c index 857201be290..27959172d8d 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl839x.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/rtl839x.c @@ -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,