From: Gavin Shan
> Sent: 15 July 2016 11:44
> The device is assigned with random MAC address. It isn't reasonable.
> An valid MAC address might have been provided by (uboot) firmware by
> device-tree or in chip. It's reasonable to use it to maintain consistency.
>
> This uses the MAC address from device-tree or that in the chip if it's
> valid. Otherwise, a random MAC address is given as before.
...
> + m = ioread32(priv->base + FTGMAC100_OFFSET_MAC_MADR);
> + l = ioread32(priv->base + FTGMAC100_OFFSET_MAC_LADR);
> +
> + mac[0] = (m >> 8) & 0xff;
> + mac[1] = m & 0xff;
> + mac[2] = (l >> 24) & 0xff;
> + mac[3] = (l >> 16) & 0xff;
> + mac[4] = (l >> 8) & 0xff;
> + mac[5] = l & 0xff;
> +
> + if (!is_valid_ether_addr(mac)) {
> + mac[5] = (m >> 8) & 0xff;
> + mac[4] = m & 0xff;
> + mac[3] = (l >> 24) & 0xff;
> + mac[2] = (l >> 16) & 0xff;
> + mac[1] = (l >> 8) & 0xff;
> + mac[0] = l & 0xff;
> + }
...
That is horrid, not all byte reversed addresses will be invalid.
David