netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Martin K Petersen <mkp@mkp.net>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com,
	Martin K Petersen <martin.petersen@oracle.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 03/14] ixgbe: Look up MAC address in Open Firmware or IDPROM
Date: Fri,  5 Dec 2014 09:52:42 -0800	[thread overview]
Message-ID: <1417801973-28793-4-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1417801973-28793-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Martin K Petersen <mkp@mkp.net>

Attempt to look up the MAC address in Open Firmware on systems that
support it. On SPARC resort to using the IDPROM if no OF address is
found.

Signed-off-by: Martin K Petersen <martin.petersen@oracle.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 73cd0fe..18ddffb 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -42,6 +42,7 @@
 #include <linux/slab.h>
 #include <net/checksum.h>
 #include <net/ip6_checksum.h>
+#include <linux/etherdevice.h>
 #include <linux/ethtool.h>
 #include <linux/if.h>
 #include <linux/if_vlan.h>
@@ -50,6 +51,15 @@
 #include <linux/prefetch.h>
 #include <scsi/fc/fc_fcoe.h>
 
+#ifdef CONFIG_OF
+#include <linux/of_net.h>
+#endif
+
+#ifdef CONFIG_SPARC
+#include <asm/idprom.h>
+#include <asm/prom.h>
+#endif
+
 #include "ixgbe.h"
 #include "ixgbe_common.h"
 #include "ixgbe_dcb_82599.h"
@@ -8021,6 +8031,29 @@ int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
 }
 
 /**
+ * ixgbe_get_platform_mac_addr - Look up MAC address in Open Firmware / IDPROM
+ * @adapter: Pointer to adapter struct
+ */
+static void ixgbe_get_platform_mac_addr(struct ixgbe_adapter *adapter)
+{
+#ifdef CONFIG_OF
+	struct device_node *dp = pci_device_to_OF_node(adapter->pdev);
+	struct ixgbe_hw *hw = &adapter->hw;
+	const unsigned char *addr;
+
+	addr = of_get_mac_address(dp);
+	if (addr) {
+		ether_addr_copy(hw->mac.perm_addr, addr);
+		return;
+	}
+#endif /* CONFIG_OF */
+
+#ifdef CONFIG_SPARC
+	ether_addr_copy(hw->mac.perm_addr, idprom->id_ethaddr);
+#endif /* CONFIG_SPARC */
+}
+
+/**
  * ixgbe_probe - Device Initialization Routine
  * @pdev: PCI device information struct
  * @ent: entry in ixgbe_pci_tbl
@@ -8289,6 +8322,8 @@ skip_sriov:
 		goto err_sw_init;
 	}
 
+	ixgbe_get_platform_mac_addr(adapter);
+
 	memcpy(netdev->dev_addr, hw->mac.perm_addr, netdev->addr_len);
 
 	if (!is_valid_ether_addr(netdev->dev_addr)) {
-- 
1.9.3

  parent reply	other threads:[~2014-12-05 17:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-05 17:52 [net-next 00/14][pull request] Intel Wired LAN Driver Updates 2014-12-05 Jeff Kirsher
2014-12-05 17:52 ` [net-next 01/14] ixgbe: Clean-up page reuse code Jeff Kirsher
2014-12-05 17:52 ` [net-next 02/14] ixgbe: Remove tail write abstraction and add missing barrier Jeff Kirsher
2014-12-05 17:52 ` Jeff Kirsher [this message]
2014-12-05 17:52 ` [net-next 04/14] ixgbe: remove CIAA/D register reads from bad VF check Jeff Kirsher
2014-12-05 18:08   ` Alex Williamson
2014-12-06  4:49   ` David Miller
2014-12-06  4:58     ` Jeff Kirsher
2014-12-06 19:42       ` Alex Williamson
2014-12-05 17:52 ` [net-next 05/14] ixgbe: add support for X550 extended RSS support Jeff Kirsher
2014-12-05 17:52 ` [net-next 06/14] ixgbe: Add timeout parameter to ixgbe_host_interface_command Jeff Kirsher
2014-12-05 17:52 ` [net-next 07/14] ixgbe: Add x550 SW/FW semaphore support Jeff Kirsher
2014-12-05 17:52 ` [net-next 08/14] ixgbe: add methods for combined read and write operations Jeff Kirsher
2014-12-05 17:52 ` [net-next 09/14] ixgbe: cleanup checksum to allow error results Jeff Kirsher
2014-12-05 17:52 ` [net-next 10/14] ixgbe: Add X550 support function pointers Jeff Kirsher
2014-12-05 17:52 ` [net-next 11/14] ixgbe: bump version number Jeff Kirsher
2014-12-05 17:52 ` [net-next 12/14] ixgbe: fix crash on rmmod after probe fail Jeff Kirsher
2014-12-05 17:52 ` [net-next 13/14] ixgbevf: add support for X550 VFs Jeff Kirsher
2014-12-05 17:52 ` [net-next 14/14] ixgbevf: fix possible crashes in probe and remove Jeff Kirsher
2014-12-06  4:55 ` [net-next 00/14][pull request] Intel Wired LAN Driver Updates 2014-12-05 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=1417801973-28793-4-git-send-email-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=jogreene@redhat.com \
    --cc=martin.petersen@oracle.com \
    --cc=mkp@mkp.net \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.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).