immortalwrt-VIKINGYFY/target/linux/generic/backport-6.12/612-02-v6.19-net-dsa-b53-move-reading-ARL-entries-into-their-own-function.patch
Álvaro Fernández Rojas 08964109be generic: 6.12: backport b53 patches from netdev-next
These patches have been accepted in netdev-next for linux v6.19.

2b3013ac0302 net: dsa: b53: add support for bcm63xx ARL entry format
300f78e8b6b7 net: dsa: b53: add support for 5389/5397/5398 ARL entry format
a7e73339ad46 net: dsa: b53: move ARL entry functions into ops struct
e0c476f325a8 net: dsa: b53: split reading search entry into their own functions
1716be6db04a net: dsa: b53: provide accessors for accessing ARL_SRCH_CTL
bf6e9d2ae1db net: dsa: b53: move writing ARL entries into their own functions
4a291fe72267 net: dsa: b53: move reading ARL entries into their own function
a6e4fd38bf2f net: dsa: b53: b53_arl_read{,25}(): use the entry for comparision

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-11-21 21:42:55 +01:00

118 lines
3.6 KiB
Diff

From 4a291fe7226736a465ddb3fa93c21fcef7162ec7 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Fri, 7 Nov 2025 09:07:43 +0100
Subject: [PATCH] net: dsa: b53: move reading ARL entries into their own
function
Instead of duplicating the whole code iterating over all bins for
BCM5325, factor out reading and parsing the entry into its own
functions, and name it the modern one after the first chip with that ARL
format, (BCM53)95.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20251107080749.26936-3-jonas.gorski@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/dsa/b53/b53_common.c | 69 +++++++++++---------------------
1 file changed, 23 insertions(+), 46 deletions(-)
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1830,48 +1830,30 @@ static int b53_arl_rw_op(struct b53_devi
return b53_arl_op_wait(dev);
}
-static int b53_arl_read(struct b53_device *dev, const u8 *mac,
- u16 vid, struct b53_arl_entry *ent, u8 *idx)
+static void b53_arl_read_entry_25(struct b53_device *dev,
+ struct b53_arl_entry *ent, u8 idx)
{
- DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES);
- unsigned int i;
- int ret;
-
- ret = b53_arl_op_wait(dev);
- if (ret)
- return ret;
+ u64 mac_vid;
- bitmap_zero(free_bins, dev->num_arl_bins);
-
- /* Read the bins */
- for (i = 0; i < dev->num_arl_bins; i++) {
- u64 mac_vid;
- u32 fwd_entry;
-
- b53_read64(dev, B53_ARLIO_PAGE,
- B53_ARLTBL_MAC_VID_ENTRY(i), &mac_vid);
- b53_read32(dev, B53_ARLIO_PAGE,
- B53_ARLTBL_DATA_ENTRY(i), &fwd_entry);
- b53_arl_to_entry(ent, mac_vid, fwd_entry);
+ b53_read64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx),
+ &mac_vid);
+ b53_arl_to_entry_25(ent, mac_vid);
+}
- if (!ent->is_valid) {
- set_bit(i, free_bins);
- continue;
- }
- if (!ether_addr_equal(ent->mac, mac))
- continue;
- if (dev->vlan_enabled && ent->vid != vid)
- continue;
- *idx = i;
- return 0;
- }
+static void b53_arl_read_entry_95(struct b53_device *dev,
+ struct b53_arl_entry *ent, u8 idx)
+{
+ u32 fwd_entry;
+ u64 mac_vid;
- *idx = find_first_bit(free_bins, dev->num_arl_bins);
- return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT;
+ b53_read64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx),
+ &mac_vid);
+ b53_read32(dev, B53_ARLIO_PAGE, B53_ARLTBL_DATA_ENTRY(idx), &fwd_entry);
+ b53_arl_to_entry(ent, mac_vid, fwd_entry);
}
-static int b53_arl_read_25(struct b53_device *dev, const u8 *mac,
- u16 vid, struct b53_arl_entry *ent, u8 *idx)
+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);
unsigned int i;
@@ -1885,12 +1867,10 @@ static int b53_arl_read_25(struct b53_de
/* Read the bins */
for (i = 0; i < dev->num_arl_bins; i++) {
- u64 mac_vid;
-
- b53_read64(dev, B53_ARLIO_PAGE,
- B53_ARLTBL_MAC_VID_ENTRY(i), &mac_vid);
-
- b53_arl_to_entry_25(ent, mac_vid);
+ if (is5325(dev) || is5365(dev))
+ b53_arl_read_entry_25(dev, ent, i);
+ else
+ b53_arl_read_entry_95(dev, ent, i);
if (!ent->is_valid) {
set_bit(i, free_bins);
@@ -1930,10 +1910,7 @@ static int b53_arl_op(struct b53_device
if (ret)
return ret;
- if (is5325(dev) || is5365(dev))
- ret = b53_arl_read_25(dev, addr, vid, &ent, &idx);
- else
- ret = b53_arl_read(dev, addr, vid, &ent, &idx);
+ ret = b53_arl_read(dev, addr, vid, &ent, &idx);
/* If this is a read, just finish now */
if (op)