[PATCH v2 5/6] realtek: remove store_mcgroups/load_mcgroups
Jan Hoffmann
jan at 3e8.eu
Sat May 6 16:05:34 PDT 2023
The current implementation only works when store and load are called for
the same port without any other calls in between. This is because the
store function only saves a single port number instead of a portmask for
each group. It also doesn't take into account that the allocation of
multicast group entries might change between store/load calls.
As a result, the multicast port mask table gets corrupted. This also
includes the reserved entry for unknown multicast, which gets corrupted
even when no other mdb entries have been added.
Remove the code for storing/loading multicast groups entirely, as the
original commit message doesn't offer a convincing reason why this would
be necessary in the first place.
Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable")
Signed-off-by: Jan Hoffmann <jan at 3e8.eu>
---
.../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 30 -------------------
.../drivers/net/dsa/rtl83xx/rtl838x.h | 1 -
.../files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 26 ----------------
.../drivers/net/dsa/rtl83xx/rtl838x.h | 1 -
4 files changed, 58 deletions(-)
diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
index 9aaa255d2639..7661ecd8f21a 100644
--- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
@@ -1025,31 +1025,6 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr
return portmask;
}
-static void store_mcgroups(struct rtl838x_switch_priv *priv, int port)
-{
- int mc_group;
-
- for (mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) {
- u64 portmask = priv->r->read_mcast_pmask(mc_group);
- if (portmask & BIT_ULL(port)) {
- priv->mc_group_saves[mc_group] = port;
- rtl83xx_mc_group_del_port(priv, mc_group, port);
- }
- }
-}
-
-static void load_mcgroups(struct rtl838x_switch_priv *priv, int port)
-{
- int mc_group;
-
- for (mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) {
- if (priv->mc_group_saves[mc_group] == port) {
- rtl83xx_mc_group_add_port(priv, mc_group, port);
- priv->mc_group_saves[mc_group] = -1;
- }
- }
-}
-
static int rtl83xx_port_enable(struct dsa_switch *ds, int port,
struct phy_device *phydev)
{
@@ -1068,8 +1043,6 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port,
/* add port to switch mask of CPU_PORT */
priv->r->traffic_enable(priv->cpu_port, port);
- load_mcgroups(priv, port);
-
if (priv->is_lagmember[port]) {
pr_debug("%s: %d is lag slave. ignore\n", __func__, port);
return 0;
@@ -1105,7 +1078,6 @@ static void rtl83xx_port_disable(struct dsa_switch *ds, int port)
// BUG: This does not work on RTL931X
/* remove port from switch mask of CPU_PORT */
priv->r->traffic_disable(priv->cpu_port, port);
- store_mcgroups(priv, port);
/* remove all other ports in the same bridge from switch mask of port */
v = priv->r->traffic_get(port);
@@ -1205,7 +1177,6 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port,
port_bitmap |= BIT_ULL(i);
}
}
- load_mcgroups(priv, port);
/* Add all other ports to this port matrix. */
if (priv->ports[port].enable) {
@@ -1246,7 +1217,6 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port,
port_bitmap &= ~BIT_ULL(i);
}
}
- store_mcgroups(priv, port);
/* Add all other ports to this port matrix. */
if (priv->ports[port].enable) {
diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h
index 19049e4c957a..fc3d3f7b9777 100644
--- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h
+++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h
@@ -1072,7 +1072,6 @@ struct rtl838x_switch_priv {
struct notifier_block fib_nb;
bool eee_enabled;
unsigned long int mc_group_bm[MAX_MC_GROUPS >> 5];
- int mc_group_saves[MAX_MC_GROUPS];
int n_pie_blocks;
struct rhashtable tc_ht;
unsigned long int pie_use_bm[MAX_PIE_ENTRIES >> 5];
diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
index f99736af24ee..ad2ad6e8f72a 100644
--- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
@@ -1012,27 +1012,6 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr
return portmask;
}
-static void store_mcgroups(struct rtl838x_switch_priv *priv, int port)
-{
- for (int mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) {
- u64 portmask = priv->r->read_mcast_pmask(mc_group);
- if (portmask & BIT_ULL(port)) {
- priv->mc_group_saves[mc_group] = port;
- rtl83xx_mc_group_del_port(priv, mc_group, port);
- }
- }
-}
-
-static void load_mcgroups(struct rtl838x_switch_priv *priv, int port)
-{
- for (int mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) {
- if (priv->mc_group_saves[mc_group] == port) {
- rtl83xx_mc_group_add_port(priv, mc_group, port);
- priv->mc_group_saves[mc_group] = -1;
- }
- }
-}
-
static int rtl83xx_port_enable(struct dsa_switch *ds, int port,
struct phy_device *phydev)
{
@@ -1051,8 +1030,6 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port,
/* add port to switch mask of CPU_PORT */
priv->r->traffic_enable(priv->cpu_port, port);
- load_mcgroups(priv, port);
-
if (priv->is_lagmember[port]) {
pr_debug("%s: %d is lag slave. ignore\n", __func__, port);
return 0;
@@ -1088,7 +1065,6 @@ static void rtl83xx_port_disable(struct dsa_switch *ds, int port)
/* BUG: This does not work on RTL931X */
/* remove port from switch mask of CPU_PORT */
priv->r->traffic_disable(priv->cpu_port, port);
- store_mcgroups(priv, port);
/* remove all other ports in the same bridge from switch mask of port */
v = priv->r->traffic_get(port);
@@ -1190,7 +1166,6 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port,
port_bitmap |= BIT_ULL(i);
}
}
- load_mcgroups(priv, port);
/* Add all other ports to this port matrix. */
if (priv->ports[port].enable) {
@@ -1230,7 +1205,6 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port,
port_bitmap &= ~BIT_ULL(i);
}
}
- store_mcgroups(priv, port);
/* Add all other ports to this port matrix. */
if (priv->ports[port].enable) {
diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h
index a4bfc285a60c..7053697bd882 100644
--- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h
+++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h
@@ -1068,7 +1068,6 @@ struct rtl838x_switch_priv {
struct notifier_block fib_nb;
bool eee_enabled;
unsigned long int mc_group_bm[MAX_MC_GROUPS >> 5];
- int mc_group_saves[MAX_MC_GROUPS];
int n_pie_blocks;
struct rhashtable tc_ht;
unsigned long int pie_use_bm[MAX_PIE_ENTRIES >> 5];
--
2.40.0
More information about the openwrt-devel
mailing list