Commit cbb961ca authored by Madalin Bucur's avatar Madalin Bucur Committed by David S. Miller

dpaa_eth: Use random MAC address when none is given

If there is no valid MAC address in the device tree, use a random
MAC address.
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarMadalin Bucur <madalin.bucur@oss.nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f3353b99
...@@ -233,8 +233,20 @@ static int dpaa_netdev_init(struct net_device *net_dev, ...@@ -233,8 +233,20 @@ static int dpaa_netdev_init(struct net_device *net_dev,
net_dev->features |= net_dev->hw_features; net_dev->features |= net_dev->hw_features;
net_dev->vlan_features = net_dev->features; net_dev->vlan_features = net_dev->features;
memcpy(net_dev->perm_addr, mac_addr, net_dev->addr_len); if (is_valid_ether_addr(mac_addr)) {
memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len); memcpy(net_dev->perm_addr, mac_addr, net_dev->addr_len);
memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len);
} else {
eth_hw_addr_random(net_dev);
err = priv->mac_dev->change_addr(priv->mac_dev->fman_mac,
(enet_addr_t *)net_dev->dev_addr);
if (err) {
dev_err(dev, "Failed to set random MAC address\n");
return -EINVAL;
}
dev_info(dev, "Using random MAC address: %pM\n",
net_dev->dev_addr);
}
net_dev->ethtool_ops = &dpaa_ethtool_ops; net_dev->ethtool_ops = &dpaa_ethtool_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment