]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dsa: b53: b53_arl_read{,25}(): use the entry for comparision
authorJonas Gorski <jonas.gorski@gmail.com>
Fri, 7 Nov 2025 08:07:42 +0000 (09:07 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 11 Nov 2025 01:11:06 +0000 (17:11 -0800)
Align the b53_arl_read{,25}() functions by consistently using the
parsed arl entry instead of parsing the raw registers again.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20251107080749.26936-2-jonas.gorski@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/b53/b53_common.c

index c911d7ea601fede9a7891e1cc666b6f50895326c..1b94cf7b06e89c714c7d8db8deb6629f7b103d4f 100644 (file)
@@ -1850,7 +1850,7 @@ static int b53_arl_rw_op(struct b53_device *dev, unsigned int op)
        return b53_arl_op_wait(dev);
 }
 
-static int b53_arl_read(struct b53_device *dev, u64 mac,
+static int b53_arl_read(struct b53_device *dev, const u8 *mac,
                        u16 vid, struct b53_arl_entry *ent, u8 *idx)
 {
        DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES);
@@ -1874,14 +1874,13 @@ static int b53_arl_read(struct b53_device *dev, u64 mac,
                           B53_ARLTBL_DATA_ENTRY(i), &fwd_entry);
                b53_arl_to_entry(ent, mac_vid, fwd_entry);
 
-               if (!(fwd_entry & ARLTBL_VALID)) {
+               if (!ent->is_valid) {
                        set_bit(i, free_bins);
                        continue;
                }
-               if ((mac_vid & ARLTBL_MAC_MASK) != mac)
+               if (!ether_addr_equal(ent->mac, mac))
                        continue;
-               if (dev->vlan_enabled &&
-                   ((mac_vid >> ARLTBL_VID_S) & ARLTBL_VID_MASK) != vid)
+               if (dev->vlan_enabled && ent->vid != vid)
                        continue;
                *idx = i;
                return 0;
@@ -1891,7 +1890,7 @@ static int b53_arl_read(struct b53_device *dev, u64 mac,
        return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT;
 }
 
-static int b53_arl_read_25(struct b53_device *dev, u64 mac,
+static int b53_arl_read_25(struct b53_device *dev, const u8 *mac,
                           u16 vid, struct b53_arl_entry *ent, u8 *idx)
 {
        DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES);
@@ -1913,14 +1912,13 @@ static int b53_arl_read_25(struct b53_device *dev, u64 mac,
 
                b53_arl_to_entry_25(ent, mac_vid);
 
-               if (!(mac_vid & ARLTBL_VALID_25)) {
+               if (!ent->is_valid) {
                        set_bit(i, free_bins);
                        continue;
                }
-               if ((mac_vid & ARLTBL_MAC_MASK) != mac)
+               if (!ether_addr_equal(ent->mac, mac))
                        continue;
-               if (dev->vlan_enabled &&
-                   ((mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25) != vid)
+               if (dev->vlan_enabled && ent->vid != vid)
                        continue;
                *idx = i;
                return 0;
@@ -1953,9 +1951,9 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
                return ret;
 
        if (is5325(dev) || is5365(dev))
-               ret = b53_arl_read_25(dev, mac, vid, &ent, &idx);
+               ret = b53_arl_read_25(dev, addr, vid, &ent, &idx);
        else
-               ret = b53_arl_read(dev, mac, vid, &ent, &idx);
+               ret = b53_arl_read(dev, addr, vid, &ent, &idx);
 
        /* If this is a read, just finish now */
        if (op)