Skip to contentSkip to conversation

enic: Store permanent MAC address during probe()

PATCH In review PJ Waskiewicz 3 participants 6 messages Mar 20, 2017 – Mar 22, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 enic: Store permanent MAC address during probe()

From: PJ Waskiewicz <[email protected]>

The permanent MAC address is useful to store for things like ethtool, and when bonding with modes such as active/passive or LACP. This follows the model of other Ethernet drivers, such as ixgbe.

This was verified on a C220 chassis with the Cisco VNIC Ethernet device.

---
 drivers/net/ethernet/cisco/enic/enic_main.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/ethernet/cisco/enic/enic_main.c +18 -0
index 4b87bee..8bb2114 100644
@@ -964,6 +964,16 @@ void enic_reset_addr_lists(struct enic *enic)
 	enic->flags = 0;
 }
 
+static int enic_set_perm_mac_addr(struct net_device *netdev, char *addr)
+{
+	if (!is_valid_ether_addr(addr) && !is_zero_ether_addr(addr))
+		return -EADDRNOTAVAIL;
+
+	memcpy(netdev->perm_addr, addr, netdev->addr_len);
+
+	return 0;
+}
+
 static int enic_set_mac_addr(struct net_device *netdev, char *addr)
 {
 	struct enic *enic = netdev_priv(netdev);
@@ -2872,6 +2882,14 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto err_out_dev_deinit;
 	}
 
+	/* Store off permanent MAC address
+	 */
+	err = enic_set_perm_mac_addr(netdev, enic->mac_addr);
+	if (err) {
+		dev_err(dev, "Invalid MAC address, aborting\n");
+		goto err_out_dev_deinit;
+	}
+
 	enic->tx_coalesce_usecs = enic->config.intr_timer_usec;
 	/* rx coalesce time already got initialized. This gets used
 	 * if adaptive coal is turned off
Signature · 1 line
2.10.2
#2 lore raw
In reply to Govindarajulu Varadarajan
Quoted 11 lines · Govindarajulu Varadarajan
Quoted 4 lines · PJ Waskiewicz

From: PJ Waskiewicz <[email protected]>

The permanent MAC address is useful to store for things like ethtool, and when bonding with modes such as active/passive or LACP.

Hi Peter,

Is this patch fixing an issue with bonding drive on enic?

We noticed that running ethtool -P <eth> on an enic, even on 4.9, returned nothing. This has fallout when using bonding, where LACP or Active/Passive overrides the LAA on one of the slaves, one can't figure out what the physical MAC address is of each slave. So not a problem with bonding directly, it's more secondary as a result of the driver not reporting the actual permanent address.

Quoted 7 lines
Quoted 3 lines

This follows the model of other Ethernet drivers, such as ixgbe.

While other drivers set netdev->perm_addr, doesn't this actually come free in
register_netdevice().

I thought it did as well, but in 4.9 when we tested it wasn't working. Hence the patch. :-)

Cheers,
-PJ

#1 lore raw
In reply to PJ Waskiewicz
Quoted 4 lines · PJ Waskiewicz

From: PJ Waskiewicz <[email protected]>

The permanent MAC address is useful to store for things like ethtool, and when bonding with modes such as active/passive or LACP.

Hi Peter,

Is this patch fixing an issue with bonding drive on enic?

Quoted 2 lines

This follows the model of other Ethernet drivers, such as ixgbe.

While other drivers set netdev->perm_addr, doesn't this actually come free in register_netdevice().

#3 lore raw
In reply to PJ Waskiewicz
Quoted 22 lines · PJ Waskiewicz
Quoted 8 lines · Govindarajulu Varadarajan
Quoted 4 lines · PJ Waskiewicz

From: PJ Waskiewicz <[email protected]>

The permanent MAC address is useful to store for things like ethtool, and when bonding with modes such as active/passive or LACP.

Is this patch fixing an issue with bonding drive on enic?

We noticed that running ethtool -P <eth> on an enic, even on 4.9, returned nothing. This has fallout when using bonding, where LACP or Active/Passive overrides the LAA on one of the slaves, one can't figure out what the physical MAC address is of each slave. So not a problem with bonding directly, it's more secondary as a result of the driver not reporting the actual permanent address.

Quoted 4 lines
Quoted 3 lines

This follows the model of other Ethernet drivers, such as ixgbe.

Quoted 7 lines
Quoted 3 lines

While other drivers set netdev->perm_addr, doesn't this actually come free in
register_netdevice().

I thought it did as well, but in 4.9 when we tested it wasn't working. Hence the patch. :-)

Can you try with net-next? In my setup I do not see the issue on net-next and on 4.9 kernel. The issue for all drivers was fixed in
948b337e62ca9 ("net: init perm_addr in register_netdevice()")

#4 lore raw
Quoted 33 lines · Govindarajulu Varadarajan
Quoted 31 lines · PJ Waskiewicz
Quoted 10 lines · Govindarajulu Varadarajan
Quoted 4 lines · PJ Waskiewicz

From: PJ Waskiewicz <[email protected]>

The permanent MAC address is useful to store for things like ethtool, and when bonding with modes such as active/passive or LACP.

Is this patch fixing an issue with bonding drive on enic?

We noticed that running ethtool -P <eth> on an enic, even on 4.9, returned nothing. This has fallout when using bonding, where LACP or Active/Passive overrides the LAA on one of the slaves, one can't figure out what the physical MAC address is of each slave. So not a problem with bonding directly, it's more secondary as a result of the driver not reporting the actual permanent address.

Quoted 8 lines
Quoted 3 lines

This follows the model of other Ethernet drivers, such as ixgbe.

While other drivers set netdev->perm_addr, doesn't this actually come free
in
register_netdevice().

Quoted 8 lines
Quoted 3 lines

I thought it did as well, but in 4.9 when we tested it wasn't working. Hence the patch. :-)

Can you try with net-next? In my setup I do not see the issue on net-next and on
4.9 kernel. The issue for all drivers was fixed in 948b337e62ca9 ("net: init perm_addr in register_netdevice()")

The fix looks like it went in after 4.9 was tagged and released. 4.9 was tagged 12/11/2016, and 948b337e62ca9 was committed 1/8/2017. That would explain why I didn't see it in 4.9.

That being said, looks like 4.10 does work as expected without my patch, so I'm fine carrying the patch internally to our 4.9 tree. I'm not sure it's worth sending either this patch or the netdev-level patch to -stable though, it's a small issue that is already fixed upstream.

Consider this patch rescinded.

Cheers,
-PJ

maintainer
#5 lore raw
In reply to PJ Waskiewicz

From: PJ Waskiewicz <[email protected]>
Date: Mon, 20 Mar 2017 15:41:20 -0700

Quoted 9 lines

From: PJ Waskiewicz <[email protected]>

The permanent MAC address is useful to store for things like ethtool, and when bonding with modes such as active/passive or LACP. This follows the model of other Ethernet drivers, such as ixgbe.

This was verified on a C220 chassis with the Cisco VNIC Ethernet device.

As per the discussion, upstream fixes this generically, so I'm dropping this.