59016c13f4518353e9483c6abb3b657d47ccfbd5
[openwrt/openwrt.git] /
1 From 0a215e4d8da0c5e36ee29304879a111daff5b461 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Tue, 25 Nov 2025 08:51:48 +0100
4 Subject: [PATCH] net: dsa: b53: fix BCM5325/65 ARL entry multicast port masks
5
6 We currently use the mask 0xf for writing and reading b53_entry::port,
7 but this is only correct for unicast ARL entries. Multicast ARL entries
8 use a bitmask, and 0xf is not enough space for ports > 3, which includes
9 the CPU port.
10
11 So extend the mask accordingly to also fit port 4 (bit 4) and MII (bit
12 5). According to the datasheet the multicast port mask is [60:48],
13 making it 12 bit wide, but bits 60-55 are reserved anyway, and collide
14 with the priority field at [60:59], so I am not sure if this is valid.
15 Therefore leave it at the actual used range, [53:48].
16
17 The ARL search result register differs a bit, and there the mask is only
18 [52:48], so only spanning the user ports. The MII port bit is
19 contained in the Search Result Extension register. So create a separate
20 search result parse function that properly handles this.
21
22 Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365")
23 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
24 ---
25 drivers/net/dsa/b53/b53_common.c | 4 +++-
26 drivers/net/dsa/b53/b53_priv.h | 25 +++++++++++++++++++++----
27 drivers/net/dsa/b53/b53_regs.h | 8 +++++++-
28 3 files changed, 31 insertions(+), 6 deletions(-)
29
30 --- a/drivers/net/dsa/b53/b53_common.c
31 +++ b/drivers/net/dsa/b53/b53_common.c
32 @@ -2099,10 +2099,12 @@ static void b53_arl_search_read_25(struc
33 struct b53_arl_entry *ent)
34 {
35 u64 mac_vid;
36 + u8 ext;
37
38 + b53_read8(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSLT_EXT_25, &ext);
39 b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_25,
40 &mac_vid);
41 - b53_arl_to_entry_25(ent, mac_vid);
42 + b53_arl_search_to_entry_25(ent, mac_vid, ext);
43 }
44
45 static void b53_arl_search_read_89(struct b53_device *dev, u8 idx,
46 --- a/drivers/net/dsa/b53/b53_priv.h
47 +++ b/drivers/net/dsa/b53/b53_priv.h
48 @@ -348,8 +348,8 @@ static inline void b53_arl_to_entry_25(s
49 ent->is_age = !!(mac_vid & ARLTBL_AGE_25);
50 ent->is_static = !!(mac_vid & ARLTBL_STATIC_25);
51 u64_to_ether_addr(mac_vid, ent->mac);
52 - ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) &
53 - ARLTBL_DATA_PORT_ID_MASK_25;
54 + ent->port = (mac_vid & ARLTBL_DATA_PORT_ID_MASK_25) >>
55 + ARLTBL_DATA_PORT_ID_S_25;
56 if (!is_multicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT)
57 ent->port = B53_CPU_PORT_25;
58 ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25;
59 @@ -388,8 +388,8 @@ static inline void b53_arl_from_entry_25
60 if (!is_multicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT_25)
61 *mac_vid |= (u64)B53_CPU_PORT << ARLTBL_DATA_PORT_ID_S_25;
62 else
63 - *mac_vid |= (u64)(ent->port & ARLTBL_DATA_PORT_ID_MASK_25) <<
64 - ARLTBL_DATA_PORT_ID_S_25;
65 + *mac_vid |= ((u64)ent->port << ARLTBL_DATA_PORT_ID_S_25) &
66 + ARLTBL_DATA_PORT_ID_MASK_25;
67 *mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) <<
68 ARLTBL_VID_S_65;
69 if (ent->is_valid)
70 @@ -414,6 +414,23 @@ static inline void b53_arl_from_entry_89
71 *fwd_entry |= ARLTBL_AGE_89;
72 }
73
74 +static inline void b53_arl_search_to_entry_25(struct b53_arl_entry *ent,
75 + u64 mac_vid, u8 ext)
76 +{
77 + memset(ent, 0, sizeof(*ent));
78 + ent->is_valid = !!(mac_vid & ARLTBL_VALID_25);
79 + ent->is_age = !!(mac_vid & ARLTBL_AGE_25);
80 + ent->is_static = !!(mac_vid & ARLTBL_STATIC_25);
81 + u64_to_ether_addr(mac_vid, ent->mac);
82 + ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25;
83 + ent->port = (mac_vid & ARL_SRCH_RSLT_PORT_ID_MASK_25) >>
84 + ARL_SRCH_RSLT_PORT_ID_S_25;
85 + if (is_multicast_ether_addr(ent->mac) && (ext & ARL_SRCH_RSLT_EXT_MC_MII))
86 + ent->port |= BIT(B53_CPU_PORT_25);
87 + else if (!is_multicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT)
88 + ent->port = B53_CPU_PORT_25;
89 +}
90 +
91 static inline void b53_arl_search_to_entry_63xx(struct b53_arl_entry *ent,
92 u64 mac_vid, u16 fwd_entry)
93 {
94 --- a/drivers/net/dsa/b53/b53_regs.h
95 +++ b/drivers/net/dsa/b53/b53_regs.h
96 @@ -328,7 +328,7 @@
97 #define ARLTBL_VID_MASK_25 0xff
98 #define ARLTBL_VID_MASK 0xfff
99 #define ARLTBL_DATA_PORT_ID_S_25 48
100 -#define ARLTBL_DATA_PORT_ID_MASK_25 0xf
101 +#define ARLTBL_DATA_PORT_ID_MASK_25 GENMASK_ULL(53, 48)
102 #define ARLTBL_VID_S_65 53
103 #define ARLTBL_AGE_25 BIT_ULL(61)
104 #define ARLTBL_STATIC_25 BIT_ULL(62)
105 @@ -374,6 +374,12 @@
106
107 /* Single register search result on 5325/5365 */
108 #define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24
109 +#define ARL_SRCH_RSLT_PORT_ID_S_25 48
110 +#define ARL_SRCH_RSLT_PORT_ID_MASK_25 GENMASK_ULL(52, 48)
111 +
112 +/* BCM5325/5365 Search result extend register (8 bit) */
113 +#define B53_ARL_SRCH_RSLT_EXT_25 0x2c
114 +#define ARL_SRCH_RSLT_EXT_MC_MII BIT(2)
115
116 /* ARL Search Data Result (32 bit) */
117 #define B53_ARL_SRCH_RSTL_0 0x68