Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <vladimir.oltean@nxp.com>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Vladimir Oltean and committed by
Paolo Abeni
6715042c fefe5dc4

+17
+10
include/net/dsa.h
··· 969 969 struct phy_device *phy); 970 970 void (*port_disable)(struct dsa_switch *ds, int port); 971 971 972 + 973 + /* 974 + * Notification for MAC address changes on user ports. Drivers can 975 + * currently only veto operations. They should not use the method to 976 + * program the hardware, since the operation is not rolled back in case 977 + * of other errors. 978 + */ 979 + int (*port_set_mac_address)(struct dsa_switch *ds, int port, 980 + const unsigned char *addr); 981 + 972 982 /* 973 983 * Compatibility between device trees defining multiple CPU ports and 974 984 * drivers which are not OK to use by default the numerically smallest
+7
net/dsa/slave.c
··· 457 457 if (!is_valid_ether_addr(addr->sa_data)) 458 458 return -EADDRNOTAVAIL; 459 459 460 + if (ds->ops->port_set_mac_address) { 461 + err = ds->ops->port_set_mac_address(ds, dp->index, 462 + addr->sa_data); 463 + if (err) 464 + return err; 465 + } 466 + 460 467 /* If the port is down, the address isn't synced yet to hardware or 461 468 * to the DSA master, so there is nothing to change. 462 469 */