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>
This commit is contained in:
Jonas Gorski
2025-11-07 09:07:44 +01:00
committed by Jakub Kicinski
parent 4a291fe722
commit bf6e9d2ae1
+26 -12
View File
@@ -1860,6 +1860,16 @@ static void b53_arl_read_entry_25(struct b53_device *dev,
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)
{
@@ -1872,6 +1882,19 @@ static void b53_arl_read_entry_95(struct b53_device *dev,
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)
{
@@ -1912,9 +1935,8 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
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 */
@@ -1947,7 +1969,6 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
/* 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",
@@ -1975,16 +1996,9 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
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);
}