[openwrt/openwrt] realtek: set up L2 table entries properly

LEDE Commits lede-commits at lists.infradead.org
Wed Oct 26 01:19:55 PDT 2022


svanheule pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/2088e440b1325ca87e4aa30162e7baa03850a37b

commit 2088e440b1325ca87e4aa30162e7baa03850a37b
Author: Jan Hoffmann <jan at 3e8.eu>
AuthorDate: Wed Oct 26 00:20:04 2022 +0200

    realtek: set up L2 table entries properly
    
    Initialize the data structure using memset to avoid the possibility of
    writing garbage values to the hardware.
    
    Always set a valid entry type, which should fix writing unicast entries
    on RTL930x.
    
    For unicast entries, set the is_static flag to prevent the switch from
    aging them out.
    
    Also set the rvid field for unicast entries. This is not strictly
    necessary, as the switch fills it in automatically from a non-zero vid.
    However, this makes the code consistent with multicast entry setup.
    
    While at it, reorder the statements and fix some style issues (double
    space, comma instead of semicolon at end of statement). Also remove the
    unneeded priv parameter and debug print for the multicast entry setup
    function.
    
    Fixes: cde31976e37 ("realtek: Add support for Layer 2 Multicast")
    Signed-off-by: Jan Hoffmann <jan at 3e8.eu>
---
 .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c       | 29 ++++++++++++++--------
 1 file changed, 19 insertions(+), 10 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 10e6103f0d..a9ca85c7f5 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
@@ -1537,23 +1537,32 @@ static int rtl83xx_vlan_del(struct dsa_switch *ds, int port,
 
 static void rtl83xx_setup_l2_uc_entry(struct rtl838x_l2_entry *e, int port, int vid, u64 mac)
 {
-	e->is_ip_mc = e->is_ipv6_mc  = false;
+	memset(e, 0, sizeof(*e));
+
+	e->type = L2_UNICAST;
 	e->valid = true;
+
 	e->age = 3;
-	e->port = port,
-	e->vid = vid;
+	e->is_static = true;
+
+	e->port = port;
+
+	e->rvid = e->vid = vid;
+	e->is_ip_mc = e->is_ipv6_mc = false;
 	u64_to_ether_addr(mac, e->mac);
 }
 
-static void rtl83xx_setup_l2_mc_entry(struct rtl838x_switch_priv *priv,
-				      struct rtl838x_l2_entry *e, int vid, u64 mac, int mc_group)
+static void rtl83xx_setup_l2_mc_entry(struct rtl838x_l2_entry *e, int vid, u64 mac, int mc_group)
 {
-	e->is_ip_mc = e->is_ipv6_mc  = false;
+	memset(e, 0, sizeof(*e));
+
+	e->type = L2_MULTICAST;
 	e->valid = true;
+
 	e->mc_portmask_index = mc_group;
-	e->type = L2_MULTICAST;
+
 	e->rvid = e->vid = vid;
-	pr_debug("%s: vid: %d, rvid: %d\n", __func__, e->vid, e->rvid);
+	e->is_ip_mc = e->is_ipv6_mc = false;
 	u64_to_ether_addr(mac, e->mac);
 }
 
@@ -1768,7 +1777,7 @@ static void rtl83xx_port_mdb_add(struct dsa_switch *ds, int port,
 				err = -ENOTSUPP;
 				goto out;
 			}
-			rtl83xx_setup_l2_mc_entry(priv, &e, vid, mac, mc_group);
+			rtl83xx_setup_l2_mc_entry(&e, vid, mac, mc_group);
 			priv->r->write_l2_entry_using_hash(idx >> 2, idx & 0x3, &e);
 		}
 		goto out;
@@ -1789,7 +1798,7 @@ static void rtl83xx_port_mdb_add(struct dsa_switch *ds, int port,
 				err = -ENOTSUPP;
 				goto out;
 			}
-			rtl83xx_setup_l2_mc_entry(priv, &e, vid, mac, mc_group);
+			rtl83xx_setup_l2_mc_entry(&e, vid, mac, mc_group);
 			priv->r->write_cam(idx, &e);
 		}
 		goto out;




More information about the lede-commits mailing list