netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] enic: Store permanent MAC address during probe()
@ 2017-03-20 22:41 PJ Waskiewicz
  2017-03-21  0:33 ` Govindarajulu Varadarajan
  2017-03-22 18:26 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: PJ Waskiewicz @ 2017-03-20 22:41 UTC (permalink / raw)
  To: netdev, Christian Benvenuti, Sujith Sankar,
	Govindarajulu Varadarajan, Neel Patel
  Cc: PJ Waskiewicz

From: PJ Waskiewicz <pjwaskiewicz@gmail.com>

The permanent MAC address is useful to store for things like ethtool,
and when bonding with modes such as active/passive or LACP.  This
follows the model of other Ethernet drivers, such as ixgbe.

This was verified on a C220 chassis with the Cisco VNIC Ethernet device.

Signed-off-by: PJ Waskiewicz <pjwaskiewicz@gmail.com>
---
 drivers/net/ethernet/cisco/enic/enic_main.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 4b87bee..8bb2114 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -964,6 +964,16 @@ void enic_reset_addr_lists(struct enic *enic)
 	enic->flags = 0;
 }
 
+static int enic_set_perm_mac_addr(struct net_device *netdev, char *addr)
+{
+	if (!is_valid_ether_addr(addr) && !is_zero_ether_addr(addr))
+		return -EADDRNOTAVAIL;
+
+	memcpy(netdev->perm_addr, addr, netdev->addr_len);
+
+	return 0;
+}
+
 static int enic_set_mac_addr(struct net_device *netdev, char *addr)
 {
 	struct enic *enic = netdev_priv(netdev);
@@ -2872,6 +2882,14 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto err_out_dev_deinit;
 	}
 
+	/* Store off permanent MAC address
+	 */
+	err = enic_set_perm_mac_addr(netdev, enic->mac_addr);
+	if (err) {
+		dev_err(dev, "Invalid MAC address, aborting\n");
+		goto err_out_dev_deinit;
+	}
+
 	enic->tx_coalesce_usecs = enic->config.intr_timer_usec;
 	/* rx coalesce time already got initialized. This gets used
 	 * if adaptive coal is turned off
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-03-22 18:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-20 22:41 [PATCH] enic: Store permanent MAC address during probe() PJ Waskiewicz
2017-03-21  0:33 ` Govindarajulu Varadarajan
2017-03-21  0:37   ` PJ Waskiewicz
2017-03-21  1:49     ` Govindarajulu Varadarajan
2017-03-21  6:20       ` PJ Waskiewicz
2017-03-22 18:26 ` David Miller

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).