aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorOr Gerlitz <ogerlitz@mellanox.com>2013-06-04 01:13:28 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-04 15:58:24 -0400
commitef96f7d46ad86625237da8a35e812bdf7896e640 (patch)
tree5ffd54f31569c2b74dcb471df51cf3c9188798a1 /drivers/net/ethernet
parent5efe5355f22fb9b7bb64d19809c0a75805e0ccb8 (diff)
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>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 810aab01c3c9..89c47ea84b50 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2119,6 +2119,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
2119 struct mlx4_en_priv *priv; 2119 struct mlx4_en_priv *priv;
2120 int i; 2120 int i;
2121 int err; 2121 int err;
2122 u64 mac_u64;
2122 2123
2123 dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv), 2124 dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv),
2124 MAX_TX_RINGS, MAX_RX_RINGS); 2125 MAX_TX_RINGS, MAX_RX_RINGS);
@@ -2192,10 +2193,17 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
2192 dev->addr_len = ETH_ALEN; 2193 dev->addr_len = ETH_ALEN;
2193 mlx4_en_u64_to_mac(dev->dev_addr, mdev->dev->caps.def_mac[priv->port]); 2194 mlx4_en_u64_to_mac(dev->dev_addr, mdev->dev->caps.def_mac[priv->port]);
2194 if (!is_valid_ether_addr(dev->dev_addr)) { 2195 if (!is_valid_ether_addr(dev->dev_addr)) {
2195 en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n", 2196 if (mlx4_is_slave(priv->mdev->dev)) {
2196 priv->port, dev->dev_addr); 2197 eth_hw_addr_random(dev);
2197 err = -EINVAL; 2198 en_warn(priv, "Assigned random MAC address %pM\n", dev->dev_addr);
2198 goto out; 2199 mac_u64 = mlx4_en_mac_to_u64(dev->dev_addr);
2200 mdev->dev->caps.def_mac[priv->port] = mac_u64;
2201 } else {
2202 en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n",
2203 priv->port, dev->dev_addr);
2204 err = -EINVAL;
2205 goto out;
2206 }
2199 } 2207 }
2200 2208
2201 memcpy(priv->prev_mac, dev->dev_addr, sizeof(priv->prev_mac)); 2209 memcpy(priv->prev_mac, dev->dev_addr, sizeof(priv->prev_mac));