immortalwrt-VIKINGYFY/target/linux/generic/backport-6.12/612-03-v6.19-net-dsa-b53-move-writing-ARL-entries-into-their-own-functions.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

94 lines
2.9 KiB
Diff

From bf6e9d2ae1dbafee53ec4ccd126595172e1e5278 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Fri, 7 Nov 2025 09:07:44 +0100
Subject: [PATCH] net: dsa: b53: move writing ARL entries into their own
functions
Move writing ARL entries into individual functions for each format.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20251107080749.26936-4-jonas.gorski@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/dsa/b53/b53_common.c | 38 ++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 12 deletions(-)
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1840,6 +1840,16 @@ static void b53_arl_read_entry_25(struct
b53_arl_to_entry_25(ent, mac_vid);
}
+static void b53_arl_write_entry_25(struct b53_device *dev,
+ const struct b53_arl_entry *ent, u8 idx)
+{
+ u64 mac_vid;
+
+ b53_arl_from_entry_25(&mac_vid, ent);
+ b53_write64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx),
+ mac_vid);
+}
+
static void b53_arl_read_entry_95(struct b53_device *dev,
struct b53_arl_entry *ent, u8 idx)
{
@@ -1852,6 +1862,19 @@ static void b53_arl_read_entry_95(struct
b53_arl_to_entry(ent, mac_vid, fwd_entry);
}
+static void b53_arl_write_entry_95(struct b53_device *dev,
+ const struct b53_arl_entry *ent, u8 idx)
+{
+ u32 fwd_entry;
+ u64 mac_vid;
+
+ b53_arl_from_entry(&mac_vid, &fwd_entry, ent);
+ b53_write64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx),
+ mac_vid);
+ b53_write32(dev, B53_ARLIO_PAGE, B53_ARLTBL_DATA_ENTRY(idx),
+ fwd_entry);
+}
+
static int b53_arl_read(struct b53_device *dev, const u8 *mac,
u16 vid, struct b53_arl_entry *ent, u8 *idx)
{
@@ -1892,9 +1915,8 @@ static int b53_arl_op(struct b53_device
const unsigned char *addr, u16 vid, bool is_valid)
{
struct b53_arl_entry ent;
- u32 fwd_entry;
- u64 mac, mac_vid = 0;
u8 idx = 0;
+ u64 mac;
int ret;
/* Convert the array into a 64-bit MAC */
@@ -1927,7 +1949,6 @@ static int b53_arl_op(struct b53_device
/* We could not find a matching MAC, so reset to a new entry */
dev_dbg(dev->dev, "{%pM,%.4d} not found, using idx: %d\n",
addr, vid, idx);
- fwd_entry = 0;
break;
default:
dev_dbg(dev->dev, "{%pM,%.4d} found, using idx: %d\n",
@@ -1955,16 +1976,9 @@ static int b53_arl_op(struct b53_device
ent.is_age = false;
memcpy(ent.mac, addr, ETH_ALEN);
if (is5325(dev) || is5365(dev))
- b53_arl_from_entry_25(&mac_vid, &ent);
+ b53_arl_write_entry_25(dev, &ent, idx);
else
- b53_arl_from_entry(&mac_vid, &fwd_entry, &ent);
-
- b53_write64(dev, B53_ARLIO_PAGE,
- B53_ARLTBL_MAC_VID_ENTRY(idx), mac_vid);
-
- if (!is5325(dev) && !is5365(dev))
- b53_write32(dev, B53_ARLIO_PAGE,
- B53_ARLTBL_DATA_ENTRY(idx), fwd_entry);
+ b53_arl_write_entry_95(dev, &ent, idx);
return b53_arl_rw_op(dev, 0);
}