netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] ixgbe: Look up MAC address in Open Firmware or IDPROM
@ 2014-11-15  2:16 Martin K. Petersen
  2014-11-15  6:21 ` Jeff Kirsher
  2014-11-17 23:35 ` Rustad, Mark D
  0 siblings, 2 replies; 3+ messages in thread
From: Martin K. Petersen @ 2014-11-15  2:16 UTC (permalink / raw)
  To: netdev; +Cc: linux.nics, Jeff Kirsher


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>

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d2df4e3d1032..11b6997150d9 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"
@@ -7960,6 +7970,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
@@ -8223,6 +8256,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)) {

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

* Re: [PATCH v3] ixgbe: Look up MAC address in Open Firmware or IDPROM
  2014-11-15  2:16 [PATCH v3] ixgbe: Look up MAC address in Open Firmware or IDPROM Martin K. Petersen
@ 2014-11-15  6:21 ` Jeff Kirsher
  2014-11-17 23:35 ` Rustad, Mark D
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Kirsher @ 2014-11-15  6:21 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: netdev, linux.nics

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

On Fri, 2014-11-14 at 21:16 -0500, Martin K. Petersen wrote:
> 
> 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>

Thanks Martin, I will add your patch to my queue.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v3] ixgbe: Look up MAC address in Open Firmware or IDPROM
  2014-11-15  2:16 [PATCH v3] ixgbe: Look up MAC address in Open Firmware or IDPROM Martin K. Petersen
  2014-11-15  6:21 ` Jeff Kirsher
@ 2014-11-17 23:35 ` Rustad, Mark D
  1 sibling, 0 replies; 3+ messages in thread
From: Rustad, Mark D @ 2014-11-17 23:35 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: netdev@vger.kernel.org, Linux NICS, Kirsher, Jeffrey T

[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]

On Nov 14, 2014, at 6:16 PM, Martin K. Petersen <mkp@mkp.net> wrote:

> @@ -7960,6 +7970,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)

How about tagging adapter with __maybe_unused in this case to avoid warnings when neither CONFIG_OF or CONFIG_SPARC are defined?

> +{
> +#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

-- 
Mark Rustad, Networking Division, Intel Corporation


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

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

end of thread, other threads:[~2014-11-17 23:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-15  2:16 [PATCH v3] ixgbe: Look up MAC address in Open Firmware or IDPROM Martin K. Petersen
2014-11-15  6:21 ` Jeff Kirsher
2014-11-17 23:35 ` Rustad, Mark D

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