Skip to contentSkip to conversation

i40e: Look up MAC address in Open Firmware or IDPROM

PATCH Superseded Sowmini Varadhan 3 participants 3 messages Dec 5, 2015 – Dec 7, 2015

Subsystems (3)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v8 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 support it, and use IDPROM on SPARC if no OF address is found.

In the case of the i40e there is an assumption that the default mac address has already been set up as the primary mac filter on probe, so if this filter is obtained from the Open Firmware or IDPROM, an explicit write is needed via i40e_aq_mac_address_write() and i40e_aq_add_macvlan() invocation.

The I40E_FLAG_PF_MAC flag in the platform-private i40e_pf structure tracks whether a platform-specific mac address was found, in which case calls to i40e_aq_mac_address_write() and i40e_aq_add_macvlan() will be triggered.

---
v2, v3: Andy Shevchenko comments
v4: Shannon Nelson review: explicitly set up mac filters before register_netdev
v5: Shannon Nelson code style comments
v6: Shannon Nelson code style comments
v7: Ensure that i40e_macaddr_init() is called only for VSI_MAIN, and only
if the mac address is not the default. Some additional code-refactoring based on comments from Shannon Nelson
v8: use pf->flags instead of bit value to track if we found a platform-specific
macaddr. Other code-style comments from Shannon Nelson

 drivers/net/ethernet/intel/i40e/i40e.h      |    1 +
 drivers/net/ethernet/intel/i40e/i40e_main.c |   89 +++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
index 0b9537b..b85eaee 100644
@@ -337,6 +337,7 @@ struct i40e_pf {
 #define I40E_FLAG_LINK_POLLING_ENABLED		BIT_ULL(39)
 #define I40E_FLAG_VEB_MODE_ENABLED		BIT_ULL(40)
 #define I40E_FLAG_NO_PCI_LINK_CHECK		BIT_ULL(42)
+#define I40E_FLAG_PF_MAC			BIT_ULL(50)
 
 	/* tracks features that get auto disabled by errors */
 	u64 auto_disable_flags;
drivers/net/ethernet/intel/i40e/i40e_main.c +89 -0

119 lines not on this page · raw message

Signature · 1 line
1.7.1
maintainer
#1 lore raw

From: Sowmini Varadhan <[email protected]>
Date: Sat, 5 Dec 2015 15:33:00 -0500

Quoted 7 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +7 -0
+static void i40e_get_platform_mac_addr(struct pci_dev *pdev, struct i40e_pf *pf)
+{
+	struct device_node *dp = pci_device_to_OF_node(pdev);
+	const unsigned char *addr;
+	u8 *mac_addr = pf->hw.mac.addr;
+
+	pf->flags &= ~I40E_FLAG_PF_MAC;

drivers/net/ethernet/intel/i40e/i40e_main.c static void i40e_print_features(struct i40e_pf *pf) · line 10427

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +10 -0
+	addr = of_get_mac_address(dp);
+	if (addr) {
+		ether_addr_copy(mac_addr, addr);
+		pf->flags |= I40E_FLAG_PF_MAC;
+	}
+#ifdef CONFIG_SPARC
+	ether_addr_copy(mac_addr, idprom->id_ethaddr);
+	pf->flags |= I40E_FLAG_PF_MAC;
+#endif /* CONFIG_SPARC */
+}

This logic doesn't look right.

If we find an address via of_get_mac_address() we should not use the IDPROM address. But here you are, since the IDPROM code runs unconditionally.

#2 lore raw

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

In reply to Sowmini Varadhan
Quoted 41 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Sowmini Varadhan
Sent: Saturday, December 05, 2015 12:33 PM
To: sowmini.varadhan at oracle.com; intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux-kernel at vger.kernel.org
Cc: andy.shevchenko at gmail.com; matthew.vick at intel.com
Subject: [Intel-wired-lan] [PATCH v8] 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 support it, and use IDPROM on SPARC if no OF address is found.

In the case of the i40e there is an assumption that the default mac address has already been set up as the primary mac filter on probe, so if this filter is obtained from the Open Firmware or IDPROM, an explicit write is needed via i40e_aq_mac_address_write() and
i40e_aq_add_macvlan() invocation.

The I40E_FLAG_PF_MAC flag in the platform-private i40e_pf structure tracks whether a platform-specific mac address was found, in which case calls to i40e_aq_mac_address_write() and i40e_aq_add_macvlan() will be triggered.

---
v2, v3: Andy Shevchenko comments
v4: Shannon Nelson review: explicitly set up mac filters before register_netdev
v5: Shannon Nelson code style comments
v6: Shannon Nelson code style comments
v7: Ensure that i40e_macaddr_init() is called only for VSI_MAIN, and only
if the mac address is not the default. Some additional code-refactoring based on comments from Shannon Nelson
v8: use pf->flags instead of bit value to track if we found a platform-specific
macaddr. Other code-style comments from Shannon Nelson

Quoted 4 lines
 drivers/net/ethernet/intel/i40e/i40e.h      |    1 +
 drivers/net/ethernet/intel/i40e/i40e_main.c |   89
+++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 0 deletions(-)

Patch code changes correctly applied, driver displays correct MAC address, no more -11 error on driver init.