]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/mlx5e: Assign random MAC address if needed
authorSaeed Mahameed <saeedm@mellanox.com>
Thu, 10 Dec 2015 15:12:38 +0000 (17:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 12 Dec 2015 05:15:23 +0000 (00:15 -0500)
Under SRIOV there might be a case where VFs are loaded
without pre-assigned MAC address. In this case, the VF
will randomize its own MAC.  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: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

index d67058afe87ec96be19db7f43d6b3bb22006e7a6..a20be56df55397147e0df38e3de2f09cf78ad1df 100644 (file)
@@ -2103,6 +2103,11 @@ static void mlx5e_set_netdev_dev_addr(struct net_device *netdev)
        struct mlx5e_priv *priv = netdev_priv(netdev);
 
        mlx5_query_nic_vport_mac_address(priv->mdev, 0, netdev->dev_addr);
+       if (is_zero_ether_addr(netdev->dev_addr) &&
+           !MLX5_CAP_GEN(priv->mdev, vport_group_manager)) {
+               eth_hw_addr_random(netdev);
+               mlx5_core_info(priv->mdev, "Assigned random MAC address %pM\n", netdev->dev_addr);
+       }
 }
 
 static void mlx5e_build_netdev(struct net_device *netdev)
index bee7da822dfe208eb9a9dd8095d76bf48de6962f..ea6a137fd76c8710a663362324818e5e6e69fe4c 100644 (file)
@@ -65,6 +65,9 @@ do {                                                                  \
                (__dev)->priv.name, __func__, __LINE__, current->pid,   \
                ##__VA_ARGS__)
 
+#define mlx5_core_info(__dev, format, ...)                             \
+       dev_info(&(__dev)->pdev->dev, format, ##__VA_ARGS__)
+
 enum {
        MLX5_CMD_DATA, /* print command payload only */
        MLX5_CMD_TIME, /* print command execution time */