Skip to content

Commit 3b08863

Browse files
KanjiMonsterkuba-moo
authored andcommitted
net: dsa: b53: fix BCM5325/65 ARL entry multicast port masks
We currently use the mask 0xf for writing and reading b53_entry::port, but this is only correct for unicast ARL entries. Multicast ARL entries use a bitmask, and 0xf is not enough space for ports > 3, which includes the CPU port. So extend the mask accordingly to also fit port 4 (bit 4) and MII (bit 5). According to the datasheet the multicast port mask is [60:48], making it 12 bit wide, but bits 60-55 are reserved anyway, and collide with the priority field at [60:59], so I am not sure if this is valid. Therefore leave it at the actual used range, [53:48]. The ARL search result register differs a bit, and there the mask is only [52:48], so only spanning the user ports. The MII port bit is contained in the Search Result Extension register. So create a separate search result parse function that properly handles this. Fixes: c456553 ("net: dsa: b53: add support for FDB operations on 5325/5365") Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Jonas Gorski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8513210 commit 3b08863

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,10 +2119,12 @@ static void b53_arl_search_read_25(struct b53_device *dev, u8 idx,
21192119
struct b53_arl_entry *ent)
21202120
{
21212121
u64 mac_vid;
2122+
u8 ext;
21222123

2124+
b53_read8(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSLT_EXT_25, &ext);
21232125
b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_25,
21242126
&mac_vid);
2125-
b53_arl_to_entry_25(ent, mac_vid);
2127+
b53_arl_search_to_entry_25(ent, mac_vid, ext);
21262128
}
21272129

21282130
static void b53_arl_search_read_89(struct b53_device *dev, u8 idx,

drivers/net/dsa/b53/b53_priv.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ static inline void b53_arl_to_entry_25(struct b53_arl_entry *ent,
348348
ent->is_age = !!(mac_vid & ARLTBL_AGE_25);
349349
ent->is_static = !!(mac_vid & ARLTBL_STATIC_25);
350350
u64_to_ether_addr(mac_vid, ent->mac);
351-
ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) &
352-
ARLTBL_DATA_PORT_ID_MASK_25;
351+
ent->port = (mac_vid & ARLTBL_DATA_PORT_ID_MASK_25) >>
352+
ARLTBL_DATA_PORT_ID_S_25;
353353
if (is_unicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT)
354354
ent->port = B53_CPU_PORT_25;
355355
ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25;
@@ -388,8 +388,8 @@ static inline void b53_arl_from_entry_25(u64 *mac_vid,
388388
if (is_unicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT_25)
389389
*mac_vid |= (u64)B53_CPU_PORT << ARLTBL_DATA_PORT_ID_S_25;
390390
else
391-
*mac_vid |= (u64)(ent->port & ARLTBL_DATA_PORT_ID_MASK_25) <<
392-
ARLTBL_DATA_PORT_ID_S_25;
391+
*mac_vid |= ((u64)ent->port << ARLTBL_DATA_PORT_ID_S_25) &
392+
ARLTBL_DATA_PORT_ID_MASK_25;
393393
*mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) <<
394394
ARLTBL_VID_S_65;
395395
if (ent->is_valid)
@@ -414,6 +414,23 @@ static inline void b53_arl_from_entry_89(u64 *mac_vid, u32 *fwd_entry,
414414
*fwd_entry |= ARLTBL_AGE_89;
415415
}
416416

417+
static inline void b53_arl_search_to_entry_25(struct b53_arl_entry *ent,
418+
u64 mac_vid, u8 ext)
419+
{
420+
memset(ent, 0, sizeof(*ent));
421+
ent->is_valid = !!(mac_vid & ARLTBL_VALID_25);
422+
ent->is_age = !!(mac_vid & ARLTBL_AGE_25);
423+
ent->is_static = !!(mac_vid & ARLTBL_STATIC_25);
424+
u64_to_ether_addr(mac_vid, ent->mac);
425+
ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25;
426+
ent->port = (mac_vid & ARL_SRCH_RSLT_PORT_ID_MASK_25) >>
427+
ARL_SRCH_RSLT_PORT_ID_S_25;
428+
if (is_multicast_ether_addr(ent->mac) && (ext & ARL_SRCH_RSLT_EXT_MC_MII))
429+
ent->port |= BIT(B53_CPU_PORT_25);
430+
else if (!is_multicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT)
431+
ent->port = B53_CPU_PORT_25;
432+
}
433+
417434
static inline void b53_arl_search_to_entry_63xx(struct b53_arl_entry *ent,
418435
u64 mac_vid, u16 fwd_entry)
419436
{

drivers/net/dsa/b53/b53_regs.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@
332332
#define ARLTBL_VID_MASK_25 0xff
333333
#define ARLTBL_VID_MASK 0xfff
334334
#define ARLTBL_DATA_PORT_ID_S_25 48
335-
#define ARLTBL_DATA_PORT_ID_MASK_25 0xf
335+
#define ARLTBL_DATA_PORT_ID_MASK_25 GENMASK_ULL(53, 48)
336336
#define ARLTBL_VID_S_65 53
337337
#define ARLTBL_AGE_25 BIT_ULL(61)
338338
#define ARLTBL_STATIC_25 BIT_ULL(62)
@@ -378,6 +378,12 @@
378378

379379
/* Single register search result on 5325/5365 */
380380
#define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24
381+
#define ARL_SRCH_RSLT_PORT_ID_S_25 48
382+
#define ARL_SRCH_RSLT_PORT_ID_MASK_25 GENMASK_ULL(52, 48)
383+
384+
/* BCM5325/5365 Search result extend register (8 bit) */
385+
#define B53_ARL_SRCH_RSLT_EXT_25 0x2c
386+
#define ARL_SRCH_RSLT_EXT_MC_MII BIT(2)
381387

382388
/* ARL Search Data Result (32 bit) */
383389
#define B53_ARL_SRCH_RSTL_0 0x68

0 commit comments

Comments
 (0)