]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
igb: change how we handle alternate mac addresses
authorAlexander Duyck <alexander.h.duyck@intel.com>
Mon, 5 Oct 2009 06:34:25 +0000 (06:34 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 2 Aug 2010 17:20:44 +0000 (10:20 -0700)
commit 22896639af98ebc721a94ed71fc3acf2fb4a24dc upstream.

This patch allows us to treat the alternate mac address as though it is the
physical address on the adapter.  This is accomplished by letting the
alt_mac_address function to only fail on an NVM error.  If no errors occur
and the alternate mac address is not present then RAR0 is read as the
default mac address.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Brandon Philips <bphilips@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/net/igb/e1000_82575.c
drivers/net/igb/e1000_hw.h
drivers/net/igb/e1000_mac.c

index c6d97ebdfb809a39a9dfb9fc59babe6b020aa55a..33352ffa9669cb33bc25b16542bb4589f4d526a4 100644 (file)
@@ -1168,9 +1168,18 @@ static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
 {
        s32 ret_val = 0;
 
-       if (igb_check_alt_mac_addr(hw))
-               ret_val = igb_read_mac_addr(hw);
+       /*
+        * If there's an alternate MAC address place it in RAR0
+        * so that it will override the Si installed default perm
+        * address.
+        */
+       ret_val = igb_check_alt_mac_addr(hw);
+       if (ret_val)
+               goto out;
+
+       ret_val = igb_read_mac_addr(hw);
 
+out:
        return ret_val;
 }
 
index 1a23aeb2d404ec8e8db85be004bf116b0a20d212..72081df3a39714b7e99a37b8e91ef32e808347c4 100644 (file)
@@ -53,6 +53,8 @@ struct e1000_hw;
 
 #define E1000_FUNC_1     1
 
+#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1   3
+
 enum e1000_mac_type {
        e1000_undefined = 0,
        e1000_82575,
index 7d76bb085e105923080bb8304209f0874c5eeff6..d4fa82c45fb943a05848a9690a5cd2c7a286e203 100644 (file)
@@ -185,13 +185,12 @@ s32 igb_check_alt_mac_addr(struct e1000_hw *hw)
        }
 
        if (nvm_alt_mac_addr_offset == 0xFFFF) {
-               ret_val = -(E1000_NOT_IMPLEMENTED);
+               /* There is no Alternate MAC Address */
                goto out;
        }
 
        if (hw->bus.func == E1000_FUNC_1)
-               nvm_alt_mac_addr_offset += ETH_ALEN/sizeof(u16);
-
+               nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN1;
        for (i = 0; i < ETH_ALEN; i += 2) {
                offset = nvm_alt_mac_addr_offset + (i >> 1);
                ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
@@ -206,14 +205,16 @@ s32 igb_check_alt_mac_addr(struct e1000_hw *hw)
 
        /* if multicast bit is set, the alternate address will not be used */
        if (alt_mac_addr[0] & 0x01) {
-               ret_val = -(E1000_NOT_IMPLEMENTED);
+               hw_dbg("Ignoring Alternate Mac Address with MC bit set\n");
                goto out;
        }
 
-       for (i = 0; i < ETH_ALEN; i++)
-               hw->mac.addr[i] = hw->mac.perm_addr[i] = alt_mac_addr[i];
-
-       hw->mac.ops.rar_set(hw, hw->mac.perm_addr, 0);
+       /*
+        * We have a valid alternate MAC address, and we want to treat it the
+        * same as the normal permanent MAC address stored by the HW into the
+        * RAR. Do this by mapping this address into RAR0.
+        */
+       hw->mac.ops.rar_set(hw, alt_mac_addr, 0);
 
 out:
        return ret_val;