Skip to content

Commit d39514e

Browse files
KanjiMonsterkuba-moo
authored andcommitted
net: dsa: b53: fix BCM5325/65 ARL entry VIDs
BCM5325/65's ARL entry registers do not contain the VID, only the search result register does. ARL entries have a separate VID entry register for the index into the VLAN table. So make ARL entry accessors use the VID entry registers instead, and move the VLAN ID field definition to the search register definition. Fixes: c456553 ("net: dsa: b53: add support for FDB operations on 5325/5365") Signed-off-by: Jonas Gorski <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3b08863 commit d39514e

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,19 +1853,24 @@ static int b53_arl_rw_op(struct b53_device *dev, unsigned int op)
18531853
static void b53_arl_read_entry_25(struct b53_device *dev,
18541854
struct b53_arl_entry *ent, u8 idx)
18551855
{
1856+
u8 vid_entry;
18561857
u64 mac_vid;
18571858

1859+
b53_read8(dev, B53_ARLIO_PAGE, B53_ARLTBL_VID_ENTRY_25(idx),
1860+
&vid_entry);
18581861
b53_read64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx),
18591862
&mac_vid);
1860-
b53_arl_to_entry_25(ent, mac_vid);
1863+
b53_arl_to_entry_25(ent, mac_vid, vid_entry);
18611864
}
18621865

18631866
static void b53_arl_write_entry_25(struct b53_device *dev,
18641867
const struct b53_arl_entry *ent, u8 idx)
18651868
{
1869+
u8 vid_entry;
18661870
u64 mac_vid;
18671871

1868-
b53_arl_from_entry_25(&mac_vid, ent);
1872+
b53_arl_from_entry_25(&mac_vid, &vid_entry, ent);
1873+
b53_write8(dev, B53_ARLIO_PAGE, B53_ARLTBL_VID_ENTRY_25(idx), vid_entry);
18691874
b53_write64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx),
18701875
mac_vid);
18711876
}

drivers/net/dsa/b53/b53_priv.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static inline void b53_arl_to_entry(struct b53_arl_entry *ent,
341341
}
342342

343343
static inline void b53_arl_to_entry_25(struct b53_arl_entry *ent,
344-
u64 mac_vid)
344+
u64 mac_vid, u8 vid_entry)
345345
{
346346
memset(ent, 0, sizeof(*ent));
347347
ent->is_valid = !!(mac_vid & ARLTBL_VALID_25);
@@ -352,7 +352,7 @@ static inline void b53_arl_to_entry_25(struct b53_arl_entry *ent,
352352
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;
355-
ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25;
355+
ent->vid = vid_entry;
356356
}
357357

358358
static inline void b53_arl_to_entry_89(struct b53_arl_entry *ent,
@@ -381,7 +381,7 @@ static inline void b53_arl_from_entry(u64 *mac_vid, u32 *fwd_entry,
381381
*fwd_entry |= ARLTBL_AGE;
382382
}
383383

384-
static inline void b53_arl_from_entry_25(u64 *mac_vid,
384+
static inline void b53_arl_from_entry_25(u64 *mac_vid, u8 *vid_entry,
385385
const struct b53_arl_entry *ent)
386386
{
387387
*mac_vid = ether_addr_to_u64(ent->mac);
@@ -390,14 +390,13 @@ static inline void b53_arl_from_entry_25(u64 *mac_vid,
390390
else
391391
*mac_vid |= ((u64)ent->port << ARLTBL_DATA_PORT_ID_S_25) &
392392
ARLTBL_DATA_PORT_ID_MASK_25;
393-
*mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) <<
394-
ARLTBL_VID_S_65;
395393
if (ent->is_valid)
396394
*mac_vid |= ARLTBL_VALID_25;
397395
if (ent->is_static)
398396
*mac_vid |= ARLTBL_STATIC_25;
399397
if (ent->is_age)
400398
*mac_vid |= ARLTBL_AGE_25;
399+
*vid_entry = ent->vid;
401400
}
402401

403402
static inline void b53_arl_from_entry_89(u64 *mac_vid, u32 *fwd_entry,
@@ -422,7 +421,8 @@ static inline void b53_arl_search_to_entry_25(struct b53_arl_entry *ent,
422421
ent->is_age = !!(mac_vid & ARLTBL_AGE_25);
423422
ent->is_static = !!(mac_vid & ARLTBL_STATIC_25);
424423
u64_to_ether_addr(mac_vid, ent->mac);
425-
ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25;
424+
ent->vid = (mac_vid & ARL_SRCH_RSLT_VID_MASK_25) >>
425+
ARL_SRCH_RSLT_VID_S_25;
426426
ent->port = (mac_vid & ARL_SRCH_RSLT_PORT_ID_MASK_25) >>
427427
ARL_SRCH_RSLT_PORT_ID_S_25;
428428
if (is_multicast_ether_addr(ent->mac) && (ext & ARL_SRCH_RSLT_EXT_MC_MII))

drivers/net/dsa/b53/b53_regs.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,9 @@
329329
#define B53_ARLTBL_MAC_VID_ENTRY(n) ((0x10 * (n)) + 0x10)
330330
#define ARLTBL_MAC_MASK 0xffffffffffffULL
331331
#define ARLTBL_VID_S 48
332-
#define ARLTBL_VID_MASK_25 0xff
333332
#define ARLTBL_VID_MASK 0xfff
334333
#define ARLTBL_DATA_PORT_ID_S_25 48
335334
#define ARLTBL_DATA_PORT_ID_MASK_25 GENMASK_ULL(53, 48)
336-
#define ARLTBL_VID_S_65 53
337335
#define ARLTBL_AGE_25 BIT_ULL(61)
338336
#define ARLTBL_STATIC_25 BIT_ULL(62)
339337
#define ARLTBL_VALID_25 BIT_ULL(63)
@@ -353,6 +351,9 @@
353351
#define ARLTBL_STATIC_89 BIT(14)
354352
#define ARLTBL_VALID_89 BIT(15)
355353

354+
/* BCM5325/BCM565 ARL Table VID Entry N Registers (8 bit) */
355+
#define B53_ARLTBL_VID_ENTRY_25(n) ((0x2 * (n)) + 0x30)
356+
356357
/* Maximum number of bin entries in the ARL for all switches */
357358
#define B53_ARLTBL_MAX_BIN_ENTRIES 4
358359

@@ -380,6 +381,8 @@
380381
#define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24
381382
#define ARL_SRCH_RSLT_PORT_ID_S_25 48
382383
#define ARL_SRCH_RSLT_PORT_ID_MASK_25 GENMASK_ULL(52, 48)
384+
#define ARL_SRCH_RSLT_VID_S_25 53
385+
#define ARL_SRCH_RSLT_VID_MASK_25 GENMASK_ULL(60, 53)
383386

384387
/* BCM5325/5365 Search result extend register (8 bit) */
385388
#define B53_ARL_SRCH_RSLT_EXT_25 0x2c

0 commit comments

Comments
 (0)