]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: rtl931x: set hash_msb based on VLAN ID when adding a new L2 entry 20183/head
authorIssam Hamdi <ih@simonwunderlich.de>
Wed, 3 Sep 2025 12:19:38 +0000 (14:19 +0200)
committerRobert Marko <robimarko@gmail.com>
Mon, 29 Sep 2025 18:55:22 +0000 (20:55 +0200)
During testing, we discovered that when adding a new offload FDB rule
on certain VLANs and then delete it, does not work as expected.

Steps to Reproduce:

* Create VLAN 4094 on the port lan1:

      bridge vlan add vid 4094 dev lan1 pvid

* Add a new FDB entry on port lan1 for VLAN 4094:

      bridge fdb add 00:01:02:22:33:44 dev lan1 vlan 4094 master permanent

* Delete the new FDB entry on port lan1 for VLAN4094

      bridge fdb del 00:01:02:22:33:44 dev lan1 vlan 4094 master permanent

Root Cause:

The failure occurs because the hash_msb flag is not set correctly
based on the VLAN ID when adding a new L2 entry.

Signed-off-by: Issam Hamdi <ih@simonwunderlich.de>
Signed-off-by: Sven Eckelmann <se@simonwunderlich.de>
Link: https://github.com/openwrt/openwrt/pull/20183
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c

index 1126d082ebab28317cac4bcc6375c9e6f7fefb6f..469246f0f8fbcf17526bece1636de5c075625724 100644 (file)
@@ -737,6 +737,7 @@ struct rtl838x_l2_entry {
        bool is_local_forward:1;
        bool is_remote_forward:1;
        bool is_l2_tunnel:1;
+       bool hash_msb:1;
        int l2_tunnel_id;
        int l2_tunnel_list_id;
 };
index 27dd999840eb5677b1d049685d309297c9f2ab86..28602151c0c5bf34460d450429eaf512a6485754 100644 (file)
@@ -558,6 +558,7 @@ static void rtl931x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e)
 
        r[0] |= e->is_open_flow ? BIT(30) : 0;
        r[0] |= e->is_pe_forward ? BIT(29) : 0;
+       r[0] |= e->hash_msb ? BIT(28): 0;
        r[2] = e->next_hop ? BIT(30) : 0;
        r[0] |= (e->rvid & 0xfff) << 16;
 
@@ -675,11 +676,22 @@ static void rtl931x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_
        u32 r[4];
        struct table_reg *q = rtl_table_get(RTL9310_TBL_0, 0);
        u32 idx = (0 << 14) | (hash << 2) | pos; /* Access SRAM, with hash and at pos in bucket */
+       int hash_algo_id;
 
        pr_debug("%s: hash %d, pos %d\n", __func__, hash, pos);
        pr_debug("%s: index %d -> mac %02x:%02x:%02x:%02x:%02x:%02x\n", __func__, idx,
                e->mac[0], e->mac[1], e->mac[2], e->mac[3],e->mac[4],e->mac[5]);
 
+       if (idx < 0x4000)
+               hash_algo_id = sw_r32(RTL931X_L2_CTRL) & BIT(0);
+       else
+               hash_algo_id = (sw_r32(RTL931X_L2_CTRL) & BIT(1)) >> 1;
+
+       if (hash_algo_id == 0)
+               e->hash_msb = (e->rvid >> 2) & 0x1;
+       else
+               e->hash_msb = (e->rvid >> 11) & 0x1;
+
        rtl931x_fill_l2_row(r, e);
        pr_debug("%s: %d: %08x %08x %08x\n", __func__, idx, r[0], r[1], r[2]);