ixgbevf: Adjust to handle unassigned MAC address from PF
authorGreg Rose <gregory.v.rose@intel.com>
Wed, 13 Feb 2013 03:02:05 +0000 (03:02 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 28 Mar 2013 08:13:46 +0000 (01:13 -0700)
If the administrator has not assigned a MAC address to the VF via the
PF then handle it gracefully by generating a temporary MAC address.
This ensures that we always know when we have a random address and
udev won't get upset about it.

Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Stefan Assmann <sassmann@kpanic.de>
Tested-by: Sibai Li <sibai.li@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
drivers/net/ethernet/intel/ixgbevf/vf.c

index 5563250883a5637846364f4b7ba00f864b944ff8..eeae9349f78bbad7bf7881110f09e90116e8c983 100644 (file)
@@ -2052,6 +2052,7 @@ static int ixgbevf_sw_init(struct ixgbevf_adapter *adapter)
 {
        struct ixgbe_hw *hw = &adapter->hw;
        struct pci_dev *pdev = adapter->pdev;
+       struct net_device *netdev = adapter->netdev;
        int err;
 
        /* PCI config space info */
@@ -2071,18 +2072,26 @@ static int ixgbevf_sw_init(struct ixgbevf_adapter *adapter)
        err = hw->mac.ops.reset_hw(hw);
        if (err) {
                dev_info(&pdev->dev,
-                        "PF still in reset state, assigning new address\n");
-               eth_hw_addr_random(adapter->netdev);
-               memcpy(adapter->hw.mac.addr, adapter->netdev->dev_addr,
-                       adapter->netdev->addr_len);
+                        "PF still in reset state.  Is the PF interface up?\n");
        } else {
                err = hw->mac.ops.init_hw(hw);
                if (err) {
                        pr_err("init_shared_code failed: %d\n", err);
                        goto out;
                }
-               memcpy(adapter->netdev->dev_addr, adapter->hw.mac.addr,
-                      adapter->netdev->addr_len);
+               err = hw->mac.ops.get_mac_addr(hw, hw->mac.addr);
+               if (err)
+                       dev_info(&pdev->dev, "Error reading MAC address\n");
+               else if (is_zero_ether_addr(adapter->hw.mac.addr))
+                       dev_info(&pdev->dev,
+                                "MAC address not assigned by administrator.\n");
+               memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
+       }
+
+       if (!is_valid_ether_addr(netdev->dev_addr)) {
+               dev_info(&pdev->dev, "Assigning random MAC address\n");
+               eth_hw_addr_random(netdev);
+               memcpy(hw->mac.addr, netdev->dev_addr, netdev->addr_len);
        }
 
        /* lock to protect mailbox accesses */
index 0c94557b53df9b656dafd2e1a96f56c3803c8288..387b52635bc051259a5e5b99d9740c69bcca687a 100644 (file)
@@ -109,7 +109,12 @@ static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw)
        if (ret_val)
                return ret_val;
 
-       if (msgbuf[0] != (IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK))
+       /* New versions of the PF may NACK the reset return message
+        * to indicate that no MAC address has yet been assigned for
+        * the VF.
+        */
+       if (msgbuf[0] != (IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK) &&
+           msgbuf[0] != (IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_NACK))
                return IXGBE_ERR_INVALID_MAC_ADDR;
 
        memcpy(hw->mac.perm_addr, addr, ETH_ALEN);