From a0e11f61a9d1d4439104b78967f90917da2c0f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20L=C3=BCssing?= Date: Sat, 10 May 2025 15:38:49 +0200 Subject: [PATCH] realtek: setup special portmasks only once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The special all-ports multicast portmasks table entry would be written twice, redundantly as vlan_profile_setup() is called twice. Which is unnecessary. Writing this reserved multicast portmask entry is independent of a VLAN profile, therefore let's move this to a more suitable position. Signed-off-by: Linus Lüssing Link: https://github.com/openwrt/openwrt/pull/21872 Signed-off-by: Robert Marko --- .../realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c | 11 +++++++++++ .../files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c | 7 ------- .../files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c | 2 -- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c index 2726a3ca20..fd2710f039 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c @@ -445,6 +445,16 @@ static void rtldsa_vlan_set_pvid(struct rtl838x_switch_priv *priv, priv->ports[port].pvid = pvid; } +static void rtldsa_83xx_mc_pmasks_setup(struct rtl838x_switch_priv *priv) +{ + /* RTL8380 and RTL8390 use an index into the portmask table to set the + * unknown multicast portmask, setup a default at a safe location + * On RTL93XX, the portmask is directly set in the profile, + * see e.g. rtl9300_vlan_profile_setup + */ + priv->r->write_mcast_pmask(MC_PMASK_ALL_PORTS_IDX, ~0); +} + /* Initialize all VLANS */ static void rtldsa_vlan_setup(struct rtl838x_switch_priv *priv) { @@ -547,6 +557,7 @@ static int rtldsa_83xx_setup(struct dsa_switch *ds) rtldsa_83xx_init_stats(priv); rtldsa_init_counters(priv); + rtldsa_83xx_mc_pmasks_setup(priv); rtldsa_vlan_setup(priv); rtldsa_setup_bpdu_traps(priv); diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c index 8c20c04083..8c408e5608 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c @@ -521,13 +521,6 @@ static void rtl838x_vlan_profile_setup(int profile) RTL838X_VLAN_IP6_UNKN_MC_FLD(MC_PMASK_ALL_PORTS_IDX); sw_w32(p, RTL838X_VLAN_PROFILE(profile)); - - /* RTL8380 and RTL8390 use an index into the portmask table to set the - * unknown multicast portmask, setup a default at a safe location - * On RTL93XX, the portmask is directly set in the profile, - * see e.g. rtl9300_vlan_profile_setup - */ - rtl838x_write_mcast_pmask(MC_PMASK_ALL_PORTS_IDX, RTL838X_MC_PMASK_ALL_PORTS); } static void rtl838x_l2_learning_setup(void) diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c index a60a406f81..72185d3e89 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c @@ -554,8 +554,6 @@ static void rtl839x_vlan_profile_setup(int profile) sw_w32(p[0], RTL839X_VLAN_PROFILE(profile)); sw_w32(p[1], RTL839X_VLAN_PROFILE(profile) + 4); - - rtl839x_write_mcast_pmask(MC_PMASK_ALL_PORTS_IDX, RTL839X_MC_PMASK_ALL_PORTS); } static void rtl839x_traffic_set(int source, u64 dest_matrix)