From 6715042cd112e1db971583e2eed89b90d6f9b139 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Fri, 22 Sep 2023 15:31:05 +0200 Subject: net: dsa: notify drivers of MAC address changes on user ports In some cases, drivers may need to veto the changing of a MAC address on a user port. Such is the case with KSZ9477 when it offloads a HSR device, because it programs the MAC address of multiple ports to a shared hardware register. Those ports need to have equal MAC addresses for the lifetime of the HSR offload. Signed-off-by: Vladimir Oltean Signed-off-by: Lukasz Majewski Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean Signed-off-by: Paolo Abeni --- net/dsa/slave.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'net/dsa') diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 2b3d89b77121..4c3e502d7e16 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -457,6 +457,13 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; + if (ds->ops->port_set_mac_address) { + err = ds->ops->port_set_mac_address(ds, dp->index, + addr->sa_data); + if (err) + return err; + } + /* If the port is down, the address isn't synced yet to hardware or * to the DSA master, so there is nothing to change. */ -- cgit v1.2.3-70-g09d2