netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Or Gerlitz <ogerlitz@mellanox.com>,
	Maor Gottlieb <maorg@mellanox.com>, Tal Alon <talal@mellanox.com>,
	Majd Dibbiny <majd@mellanox.com>,
	Matan Barak <matanb@mellanox.com>,
	saeedm@dev.mellanox.co.il, Saeed Mahameed <saeedm@mellanox.com>
Subject: [PATCH net-next V1 2/9] net/mlx5e: Assign random MAC address if needed
Date: Thu, 10 Dec 2015 17:12:38 +0200	[thread overview]
Message-ID: <1449760365-23622-3-git-send-email-saeedm@mellanox.com> (raw)
In-Reply-To: <1449760365-23622-1-git-send-email-saeedm@mellanox.com>

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>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |    5 +++++
 .../net/ethernet/mellanox/mlx5/core/mlx5_core.h    |    3 +++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index d67058a..a20be56 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -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)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index bee7da8..ea6a137 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -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 */
-- 
1.7.1

  parent reply	other threads:[~2015-12-10 15:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10 15:12 [PATCH net-next V1 0/9] mlx5 improved flow steering management Saeed Mahameed
2015-12-10 15:12 ` [PATCH net-next V1 1/9] net/mlx5: Fix query E-Switch capabilities Saeed Mahameed
2015-12-10 15:12 ` Saeed Mahameed [this message]
2015-12-10 15:12 ` [PATCH net-next V1 3/9] net/mlx5_core: Introduce flow steering firmware commands Saeed Mahameed
2015-12-10 15:12 ` [PATCH net-next V1 4/9] net/mlx5_core: Add flow steering base data structures Saeed Mahameed
2015-12-10 15:12 ` [PATCH net-next V1 5/9] net/mlx5_core: Add flow steering lookup algorithms Saeed Mahameed
2015-12-10 15:12 ` [PATCH net-next V1 6/9] net/mlx5_core: Introduce flow steering API Saeed Mahameed
2015-12-10 15:12 ` [PATCH net-next V1 7/9] net/mlx5_core: Flow steering tree initialization Saeed Mahameed
2015-12-10 15:12 ` [PATCH net-next V1 8/9] net/mlx5: Use flow steering infrastructure for mlx5_en Saeed Mahameed
2015-12-10 15:12 ` [PATCH net-next V1 9/9] net/mlx5e: Rename en_flow_table.c to en_fs.c Saeed Mahameed
2015-12-12  5:24 ` [PATCH net-next V1 0/9] mlx5 improved flow steering management David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449760365-23622-3-git-send-email-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=majd@mellanox.com \
    --cc=maorg@mellanox.com \
    --cc=matanb@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=saeedm@dev.mellanox.co.il \
    --cc=talal@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).