Skip to content

Commit c762dff

Browse files
martinkpetersenJeff Kirsher
authored andcommitted
ixgbe: Look up MAC address in Open Firmware or IDPROM
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 <[email protected]> Tested-by: Phil Schmitt <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent ad435ec commit c762dff

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <linux/slab.h>
4343
#include <net/checksum.h>
4444
#include <net/ip6_checksum.h>
45+
#include <linux/etherdevice.h>
4546
#include <linux/ethtool.h>
4647
#include <linux/if.h>
4748
#include <linux/if_vlan.h>
@@ -50,6 +51,15 @@
5051
#include <linux/prefetch.h>
5152
#include <scsi/fc/fc_fcoe.h>
5253

54+
#ifdef CONFIG_OF
55+
#include <linux/of_net.h>
56+
#endif
57+
58+
#ifdef CONFIG_SPARC
59+
#include <asm/idprom.h>
60+
#include <asm/prom.h>
61+
#endif
62+
5363
#include "ixgbe.h"
5464
#include "ixgbe_common.h"
5565
#include "ixgbe_dcb_82599.h"
@@ -8020,6 +8030,29 @@ int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
80208030
return is_wol_supported;
80218031
}
80228032

8033+
/**
8034+
* ixgbe_get_platform_mac_addr - Look up MAC address in Open Firmware / IDPROM
8035+
* @adapter: Pointer to adapter struct
8036+
*/
8037+
static void ixgbe_get_platform_mac_addr(struct ixgbe_adapter *adapter)
8038+
{
8039+
#ifdef CONFIG_OF
8040+
struct device_node *dp = pci_device_to_OF_node(adapter->pdev);
8041+
struct ixgbe_hw *hw = &adapter->hw;
8042+
const unsigned char *addr;
8043+
8044+
addr = of_get_mac_address(dp);
8045+
if (addr) {
8046+
ether_addr_copy(hw->mac.perm_addr, addr);
8047+
return;
8048+
}
8049+
#endif /* CONFIG_OF */
8050+
8051+
#ifdef CONFIG_SPARC
8052+
ether_addr_copy(hw->mac.perm_addr, idprom->id_ethaddr);
8053+
#endif /* CONFIG_SPARC */
8054+
}
8055+
80238056
/**
80248057
* ixgbe_probe - Device Initialization Routine
80258058
* @pdev: PCI device information struct
@@ -8289,6 +8322,8 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
82898322
goto err_sw_init;
82908323
}
82918324

8325+
ixgbe_get_platform_mac_addr(adapter);
8326+
82928327
memcpy(netdev->dev_addr, hw->mac.perm_addr, netdev->addr_len);
82938328

82948329
if (!is_valid_ether_addr(netdev->dev_addr)) {

0 commit comments

Comments
 (0)