Skip to contentSkip to conversation

i40e: Look up MAC address in Open Firmware or IDPROM

PATCH Superseded Sowmini Varadhan 2 participants 4 messages Oct 29, 2015 – Oct 30, 2015

Subsystems (3)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i40e: Look up MAC address in Open Firmware or IDPROM

This is the i40e equivalent of commit c762dff24c06 ("ixgbe: Look up MAC address in Open Firmware or IDPROM").

As with that fix, attempt to look up the MAC address in Open Firmware on systems that uspport it, and use IDPROM on SPARC if no OF address is found.

---
 drivers/net/ethernet/intel/i40e/i40e_common.c |   36 +++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +36 -0
index 2d74c6e..53f804a 100644
@@ -24,11 +24,23 @@
  *
  ******************************************************************************/
 
+#include <linux/etherdevice.h>
+#ifdef CONFIG_OF
+#include <linux/of_net.h>
+#endif
+#include <linux/pci.h>
+#include "i40e.h"
+
 #include "i40e_type.h"
 #include "i40e_adminq.h"
 #include "i40e_prototype.h"
 #include "i40e_virtchnl.h"
 
+#ifdef CONFIG_SPARC
+#include <asm/idprom.h>
+#include <asm/prom.h>
+#endif
+
 /**
  * i40e_set_mac_type - Sets MAC type
  * @hw: pointer to the HW structure
@@ -1008,6 +1020,27 @@ i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw,
 	return status;
 }
 
+static int i40e_get_platform_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
+{
+#ifdef CONFIG_OF
+	struct i40e_pf *pf = hw->back;
+	struct device_node *dp = pci_device_to_OF_node(pf->pdev);
+	const unsigned char *addr;
+
+	addr = of_get_mac_address(dp);
+	if (addr) {
+		ether_addr_copy(mac_addr, addr);
+		return 0;
+	}
+#endif /* CONFIG_OF */
+
+#ifdef CONFIG_SPARC
+	ether_addr_copy(mac_addr, idprom->id_ethaddr);
+	return 0;
+#endif /* CONFIG_SPARC */
+	return 1;
+}
+
 /**
  * i40e_get_mac_addr - get MAC address
  * @hw: pointer to the HW structure
@@ -1021,6 +1054,9 @@ i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
 	i40e_status status;
 	u16 flags = 0;
 
+	if (!i40e_get_platform_mac_addr(hw, mac_addr))
+		return I40E_SUCCESS;
+
 	status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);
 
 	if (flags & I40E_AQC_LAN_ADDR_VALID)
Signature · 1 line
1.7.1
#1 lore raw
Quoted 8 lines · Sowmini Varadhan

This is the i40e equivalent of commit c762dff24c06 ("ixgbe: Look up MAC address in Open Firmware or IDPROM").

As with that fix, attempt to look up the MAC address in Open Firmware on systems that uspport it, and use IDPROM on SPARC if no OF address is found.

[]

drivers/net/ethernet/intel/i40e/i40e_common.c

Quoted 3 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +2 -0
+#include <linux/etherdevice.h>
 
+#ifdef CONFIG_OF

This seems redundant.

Quoted 4 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +4 -0
+#include <linux/of_net.h>
+#endif
+#include <linux/pci.h>
+#include "i40e.h"

drivers/net/ethernet/intel/i40e/i40e_common.c line 42

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +5 -0
+
 #include "i40e_type.h"
 #include "i40e_adminq.h"
 #include "i40e_prototype.h"
 #include "i40e_virtchnl.h"
 
+#ifdef CONFIG_SPARC
+#include <asm/idprom.h>
+#include <asm/prom.h>
+#endif

Why not to put before local headers?

drivers/net/ethernet/intel/i40e/i40e_common.c i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw, · line 1025

Quoted 3 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +3 -0
+static int i40e_get_platform_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
+{
+#ifdef CONFIG_OF

Does the following has no stubs?

drivers/net/ethernet/intel/i40e/i40e_common.c i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw, · line 1030

Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +5 -0
+       struct i40e_pf *pf = hw->back;
+       struct device_node *dp = pci_device_to_OF_node(pf->pdev);
+       const unsigned char *addr;
+
+       addr = of_get_mac_address(dp);

^^^

Quoted 22 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +15 -0
+       if (addr) {
+               ether_addr_copy(mac_addr, addr);
+               return 0;
+       }
+#endif /* CONFIG_OF */
+
+#ifdef CONFIG_SPARC
+       ether_addr_copy(mac_addr, idprom->id_ethaddr);
+       return 0;
+#endif /* CONFIG_SPARC */
+       return 1;
+}
+
 /**
  * i40e_get_mac_addr - get MAC address
  * @hw: pointer to the HW structure
@@ -1021,6 +1054,9 @@ i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
        i40e_status status;
        u16 flags = 0;
 
+       if (!i40e_get_platform_mac_addr(hw, mac_addr))
+               return I40E_SUCCESS;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 10 lines · Andy Shevchenko

Does the following has no stubs?

drivers/net/ethernet/intel/i40e/i40e_common.c i40e_status i40e_aq_mac_address_write(struct i40e_hw *hw, · line 1030

Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +5 -0
+       struct i40e_pf *pf = hw->back;
+       struct device_node *dp = pci_device_to_OF_node(pf->pdev);
+       const unsigned char *addr;
+
+       addr = of_get_mac_address(dp);

^^^

I was not able to find any.
I'm fixing up the rest and respinning V2 as a separate thread.

Thanks
--Sowmini

#3 lore raw
Quoted 10 lines · Sowmini Varadhan
Quoted 9 lines · Andy Shevchenko

Does the following has no stubs?

Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +5 -0
+       struct i40e_pf *pf = hw->back;
+       struct device_node *dp = pci_device_to_OF_node(pf->pdev);
+       const unsigned char *addr;
+
+       addr = of_get_mac_address(dp);
Quoted 4 lines
Quoted 1 line

^^^

I was not able to find any.
I'm fixing up the rest and respinning V2 as a separate thread.

of_net.h contains the stub of of_get_mac_addr() which means you don't need to put ugly ifdefs in the function.

Have no idea about CONFIG_SPARC though.

Signature · 2 lines
With Best Regards,
Andy Shevchenko