1
0
Fork 0
forked from mirror/openwrt

realtek: rtl931x: set hash_msb based on VLAN ID when adding a new L2 entry

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>
This commit is contained in:
Issam Hamdi 2025-09-03 14:19:38 +02:00 committed by Robert Marko
parent 8c82e2dc93
commit 36d8d19993
2 changed files with 13 additions and 0 deletions

View 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;
};

View 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]);