RE: [PATCH net-next v2 6/6] net: dsa: microchip: ksz9477: make switch MAC address configurable

From: Tristram.Ha
Date: Fri Jul 21 2023 - 18:10:05 EST


> The switch MAC address is used for sending pause frames and for Wake on Magic
> Packet. So, make use of local-mac-address property in the switch node
> root and configure it in the HW.
>

> @@ -1211,6 +1211,14 @@ int ksz9477_setup(struct dsa_switch *ds)
> if (dev->wakeup_source)
> ksz_write8(dev, REG_SW_PME_CTRL, PME_ENABLE);
>
> + if (is_valid_ether_addr(dev->mac_addr)) {
> + int i;
> +
> + for (i = 0; i < ETH_ALEN; i++)
> + ksz_write8(dev, REG_SW_MAC_ADDR_0 + i,
> + dev->mac_addr[i]);
> + }
> +

> +
> + mac = of_get_property(dev->dev->of_node, "local-mac-address",
> + NULL);
> + if (mac)
> + memcpy(dev->mac_addr, mac, ETH_ALEN);

So the Magic Packet uses the same MAC address for all KSZ9477 switches
if local-mac-address is not defined. Is that practical in real operating
environment?
The DSA driver used to have an API to set the MAC address to the switch,
but it was removed because nobody used it.