Re: [[RFC PATCH v4 net-next] 0/2] net: dsa: hsr: Enable HSR HW offloading for KSZ9477

From: Vladimir Oltean
Date: Mon Sep 11 2023 - 18:01:03 EST


On Mon, Sep 11, 2023 at 04:58:48PM +0200, Lukasz Majewski wrote:
> Dear Community,
>
> Are there any comments regarding this new revision of the HSR support
> for KSZ9477 switch?
>
> Best regards,
>
> Lukasz Majewski

Yeah, the integration with the DSA master's MAC address is not quite
what I was expecting to see.

See, both the DSA master's MAC address, as well as the HSR device's MAC
address, can be changed at runtime with:

ip link set eth0 address AA:BB:CC:DD:EE:FF # DSA master
ip link set lan1 address AA:BB:CC:DD:EE:FF # indirectly changes the HSR's address too

which is problematic because the hardware does not get updated in that
case, but the address change is not refused either.

Actually, the reason why I haven't yet said anything is because it made
me realize that there is a pre-existing bug in net/dsa/slave.c where we
have this pattern:

if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
dev_uc_add(master, dev->dev_addr);

but there is no replay of the dev_uc_add() call when the master->dev_addr
changes. This really results in RX packet loss, as I have tested. I don't
know what is the best way to solve it.

Anyway, programming the MAC address of the DSA master or of the HSR
device to hardware seems to require tracking the NETDEV_CHANGEADDR and
NETDEV_PRE_CHANGEADDR events, even if only to reject those changes.