]> Gentwo Git Trees - linux/.git/commitdiff
net: dsa: b53: fix BCM5325/65 ARL entry VIDs
authorJonas Gorski <jonas.gorski@gmail.com>
Fri, 28 Nov 2025 08:06:24 +0000 (09:06 +0100)
committerJakub Kicinski <kuba@kernel.org>
Mon, 1 Dec 2025 22:46:39 +0000 (14:46 -0800)
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: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20251128080625.27181-7-jonas.gorski@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/b53/b53_common.c
drivers/net/dsa/b53/b53_priv.h
drivers/net/dsa/b53/b53_regs.h

index 09a64812cd84c8ac1a789bf81c8ee56a4041306c..ac995f36ed95a9d1daf23d2977bbc204ae8510dc 100644 (file)
@@ -1853,19 +1853,24 @@ static int b53_arl_rw_op(struct b53_device *dev, unsigned int op)
 static void b53_arl_read_entry_25(struct b53_device *dev,
                                  struct b53_arl_entry *ent, u8 idx)
 {
+       u8 vid_entry;
        u64 mac_vid;
 
+       b53_read8(dev, B53_ARLIO_PAGE, B53_ARLTBL_VID_ENTRY_25(idx),
+                 &vid_entry);
        b53_read64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx),
                   &mac_vid);
-       b53_arl_to_entry_25(ent, mac_vid);
+       b53_arl_to_entry_25(ent, mac_vid, vid_entry);
 }
 
 static void b53_arl_write_entry_25(struct b53_device *dev,
                                   const struct b53_arl_entry *ent, u8 idx)
 {
+       u8 vid_entry;
        u64 mac_vid;
 
-       b53_arl_from_entry_25(&mac_vid, ent);
+       b53_arl_from_entry_25(&mac_vid, &vid_entry, ent);
+       b53_write8(dev, B53_ARLIO_PAGE, B53_ARLTBL_VID_ENTRY_25(idx), vid_entry);
        b53_write64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx),
                    mac_vid);
 }
index f4afbfcc345e61b3a3369ae1ff9f2f6766c9ced8..bd6849e5bb93900895c7e55b30f01e107ffac77b 100644 (file)
@@ -341,7 +341,7 @@ static inline void b53_arl_to_entry(struct b53_arl_entry *ent,
 }
 
 static inline void b53_arl_to_entry_25(struct b53_arl_entry *ent,
-                                      u64 mac_vid)
+                                      u64 mac_vid, u8 vid_entry)
 {
        memset(ent, 0, sizeof(*ent));
        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,
                     ARLTBL_DATA_PORT_ID_S_25;
        if (is_unicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT)
                ent->port = B53_CPU_PORT_25;
-       ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25;
+       ent->vid = vid_entry;
 }
 
 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,
                *fwd_entry |= ARLTBL_AGE;
 }
 
-static inline void b53_arl_from_entry_25(u64 *mac_vid,
+static inline void b53_arl_from_entry_25(u64 *mac_vid, u8 *vid_entry,
                                         const struct b53_arl_entry *ent)
 {
        *mac_vid = ether_addr_to_u64(ent->mac);
@@ -390,14 +390,13 @@ static inline void b53_arl_from_entry_25(u64 *mac_vid,
        else
                *mac_vid |= ((u64)ent->port << ARLTBL_DATA_PORT_ID_S_25) &
                            ARLTBL_DATA_PORT_ID_MASK_25;
-       *mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) <<
-                         ARLTBL_VID_S_65;
        if (ent->is_valid)
                *mac_vid |= ARLTBL_VALID_25;
        if (ent->is_static)
                *mac_vid |= ARLTBL_STATIC_25;
        if (ent->is_age)
                *mac_vid |= ARLTBL_AGE_25;
+       *vid_entry = ent->vid;
 }
 
 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,
        ent->is_age = !!(mac_vid & ARLTBL_AGE_25);
        ent->is_static = !!(mac_vid & ARLTBL_STATIC_25);
        u64_to_ether_addr(mac_vid, ent->mac);
-       ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25;
+       ent->vid = (mac_vid & ARL_SRCH_RSLT_VID_MASK_25) >>
+                  ARL_SRCH_RSLT_VID_S_25;
        ent->port = (mac_vid & ARL_SRCH_RSLT_PORT_ID_MASK_25) >>
                    ARL_SRCH_RSLT_PORT_ID_S_25;
        if (is_multicast_ether_addr(ent->mac) && (ext & ARL_SRCH_RSLT_EXT_MC_MII))
index 54b1016eb7eb1d90078282efa7e8366a0ffac1da..54a278db67c9fd458d255f2626e001492fe0eb9d 100644 (file)
 #define B53_ARLTBL_MAC_VID_ENTRY(n)    ((0x10 * (n)) + 0x10)
 #define   ARLTBL_MAC_MASK              0xffffffffffffULL
 #define   ARLTBL_VID_S                 48
-#define   ARLTBL_VID_MASK_25           0xff
 #define   ARLTBL_VID_MASK              0xfff
 #define   ARLTBL_DATA_PORT_ID_S_25     48
 #define   ARLTBL_DATA_PORT_ID_MASK_25  GENMASK_ULL(53, 48)
-#define   ARLTBL_VID_S_65              53
 #define   ARLTBL_AGE_25                        BIT_ULL(61)
 #define   ARLTBL_STATIC_25             BIT_ULL(62)
 #define   ARLTBL_VALID_25              BIT_ULL(63)
 #define   ARLTBL_STATIC_89             BIT(14)
 #define   ARLTBL_VALID_89              BIT(15)
 
+/* BCM5325/BCM565 ARL Table VID Entry N Registers (8 bit) */
+#define B53_ARLTBL_VID_ENTRY_25(n)     ((0x2 * (n)) + 0x30)
+
 /* Maximum number of bin entries in the ARL for all switches */
 #define B53_ARLTBL_MAX_BIN_ENTRIES     4
 
 #define B53_ARL_SRCH_RSTL_0_MACVID_25  0x24
 #define   ARL_SRCH_RSLT_PORT_ID_S_25   48
 #define   ARL_SRCH_RSLT_PORT_ID_MASK_25        GENMASK_ULL(52, 48)
+#define   ARL_SRCH_RSLT_VID_S_25       53
+#define   ARL_SRCH_RSLT_VID_MASK_25    GENMASK_ULL(60, 53)
 
 /* BCM5325/5365 Search result extend register (8 bit) */
 #define B53_ARL_SRCH_RSLT_EXT_25       0x2c