diff mbox

enic: Store permanent MAC address during probe()

Message ID 20170320224120.24484-1-pjw@netapp.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

PJ Waskiewicz March 20, 2017, 10:41 p.m. UTC
From: PJ Waskiewicz <pjwaskiewicz@gmail.com>

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.

Signed-off-by: PJ Waskiewicz <pjwaskiewicz@gmail.com>
---
 drivers/net/ethernet/cisco/enic/enic_main.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Govindarajulu Varadarajan March 21, 2017, 12:33 a.m. UTC | #1
On Mon, 20 Mar 2017, PJ Waskiewicz wrote:

> From: PJ Waskiewicz <pjwaskiewicz@gmail.com>
>
> 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?

> 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().
PJ Waskiewicz March 21, 2017, 12:37 a.m. UTC | #2
On Mon, Mar 20, 2017 at 5:33 PM, Govindarajulu Varadarajan
<gvaradar@cisco.com> wrote:
> On Mon, 20 Mar 2017, PJ Waskiewicz wrote:
>
>> From: PJ Waskiewicz <pjwaskiewicz@gmail.com>
>>
>> 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.

>
>> 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
Govindarajulu Varadarajan March 21, 2017, 1:49 a.m. UTC | #3
On Mon, 20 Mar 2017, PJ Waskiewicz wrote:

> On Mon, Mar 20, 2017 at 5:33 PM, Govindarajulu Varadarajan
> <gvaradar@cisco.com> wrote:
>> On Mon, 20 Mar 2017, PJ Waskiewicz wrote:
>>
>>> From: PJ Waskiewicz <pjwaskiewicz@gmail.com>
>>>
>>> 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.
>
>>
>>> 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.  :-)
>

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()")
PJ Waskiewicz March 21, 2017, 6:20 a.m. UTC | #4
On Mon, Mar 20, 2017 at 6:49 PM, Govindarajulu Varadarajan
<gvaradar@cisco.com> wrote:
> On Mon, 20 Mar 2017, PJ Waskiewicz wrote:
>
>> On Mon, Mar 20, 2017 at 5:33 PM, Govindarajulu Varadarajan
>> <gvaradar@cisco.com> wrote:
>>>
>>> On Mon, 20 Mar 2017, PJ Waskiewicz wrote:
>>>
>>>> From: PJ Waskiewicz <pjwaskiewicz@gmail.com>
>>>>
>>>> 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.
>>
>>>
>>>> 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.  :-)
>>
>
> 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
David Miller March 22, 2017, 6:26 p.m. UTC | #5
From: PJ Waskiewicz <pjwaskiewicz@gmail.com>
Date: Mon, 20 Mar 2017 15:41:20 -0700

> From: PJ Waskiewicz <pjwaskiewicz@gmail.com>
> 
> 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.
> 
> Signed-off-by: PJ Waskiewicz <pjwaskiewicz@gmail.com>

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

Patch

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 4b87bee..8bb2114 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -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