net/mlx4_en: Handle unassigned VF MAC address correctly
When a VF sense they didn't get MAC address, use random one. This will address the case of administrator not assigning MAC to the VF through the PF OS APIs and keep udev happy. Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5efe5355f2
commit
ef96f7d46a
|
@ -2119,6 +2119,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
|
|||
struct mlx4_en_priv *priv;
|
||||
int i;
|
||||
int err;
|
||||
u64 mac_u64;
|
||||
|
||||
dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv),
|
||||
MAX_TX_RINGS, MAX_RX_RINGS);
|
||||
|
@ -2192,10 +2193,17 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
|
|||
dev->addr_len = ETH_ALEN;
|
||||
mlx4_en_u64_to_mac(dev->dev_addr, mdev->dev->caps.def_mac[priv->port]);
|
||||
if (!is_valid_ether_addr(dev->dev_addr)) {
|
||||
en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n",
|
||||
priv->port, dev->dev_addr);
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
if (mlx4_is_slave(priv->mdev->dev)) {
|
||||
eth_hw_addr_random(dev);
|
||||
en_warn(priv, "Assigned random MAC address %pM\n", dev->dev_addr);
|
||||
mac_u64 = mlx4_en_mac_to_u64(dev->dev_addr);
|
||||
mdev->dev->caps.def_mac[priv->port] = mac_u64;
|
||||
} else {
|
||||
en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n",
|
||||
priv->port, dev->dev_addr);
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(priv->prev_mac, dev->dev_addr, sizeof(priv->prev_mac));
|
||||
|
|
Loading…
Reference in New Issue