[PATCH net-next 4/7] net: dsa: b53: fix CPU port unicast ARL entries for BCM5325/65

Jonas Gorski posted 7 patches 6 days, 16 hours ago
There is a newer version of this series
[PATCH net-next 4/7] net: dsa: b53: fix CPU port unicast ARL entries for BCM5325/65
Posted by Jonas Gorski 6 days, 16 hours ago
On BCM5325 and BCM5365, unicast ARL entries use 8 as the value for the
CPU port, so we need to translate it to/from 5 as used for the CPU port
at most other places.

Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 drivers/net/dsa/b53/b53_priv.h | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index 3b22e817fb28..bd821d60ac90 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -344,12 +344,14 @@ static inline void b53_arl_to_entry_25(struct b53_arl_entry *ent,
 				       u64 mac_vid)
 {
 	memset(ent, 0, sizeof(*ent));
-	ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) &
-		     ARLTBL_DATA_PORT_ID_MASK_25;
 	ent->is_valid = !!(mac_vid & ARLTBL_VALID_25);
 	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->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) &
+		     ARLTBL_DATA_PORT_ID_MASK_25;
+	if (!is_multicast_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;
 }
 
@@ -383,8 +385,11 @@ static inline void b53_arl_from_entry_25(u64 *mac_vid,
 					 const struct b53_arl_entry *ent)
 {
 	*mac_vid = ether_addr_to_u64(ent->mac);
-	*mac_vid |= (u64)(ent->port & ARLTBL_DATA_PORT_ID_MASK_25) <<
-			  ARLTBL_DATA_PORT_ID_S_25;
+	if (!is_multicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT_25)
+		*mac_vid |= (u64)B53_CPU_PORT << ARLTBL_DATA_PORT_ID_S_25;
+	else
+		*mac_vid |= (u64)(ent->port & ARLTBL_DATA_PORT_ID_MASK_25) <<
+				  ARLTBL_DATA_PORT_ID_S_25;
 	*mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) <<
 			  ARLTBL_VID_S_65;
 	if (ent->is_valid)
-- 
2.43.0
Re: [PATCH net-next 4/7] net: dsa: b53: fix CPU port unicast ARL entries for BCM5325/65
Posted by Vladimir Oltean 6 days, 3 hours ago
On Tue, Nov 25, 2025 at 08:51:47AM +0100, Jonas Gorski wrote:
> On BCM5325 and BCM5365, unicast ARL entries use 8 as the value for the
> CPU port, so we need to translate it to/from 5 as used for the CPU port
> at most other places.
> +	ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) &
> +		     ARLTBL_DATA_PORT_ID_MASK_25;
> +	if (!is_multicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT)
> +		ent->port = B53_CPU_PORT_25;

Why not use is_unicast_ether_addr() to have a more clear correlation
between the commit message and the code?
Re: [PATCH net-next 4/7] net: dsa: b53: fix CPU port unicast ARL entries for BCM5325/65
Posted by Jonas Gorski 5 days, 14 hours ago
On Tue, Nov 25, 2025 at 9:42 PM Vladimir Oltean <olteanv@gmail.com> wrote:
>
> On Tue, Nov 25, 2025 at 08:51:47AM +0100, Jonas Gorski wrote:
> > On BCM5325 and BCM5365, unicast ARL entries use 8 as the value for the
> > CPU port, so we need to translate it to/from 5 as used for the CPU port
> > at most other places.
> > +     ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) &
> > +                  ARLTBL_DATA_PORT_ID_MASK_25;
> > +     if (!is_multicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT)
> > +             ent->port = B53_CPU_PORT_25;
>
> Why not use is_unicast_ether_addr() to have a more clear correlation
> between the commit message and the code?

There is a very simple explanation for that: I didn't know it existed.
Will change it for v2.

Thanks for the review,
Jonas