Merge branch 'for-linus-dma-masks' of git://git.linaro.org/people/rmk/linux-arm
[cascardo/linux.git] / drivers / net / ethernet / intel / igb / igb_main.c
index 7579383..2ac14bd 100644 (file)
@@ -182,6 +182,7 @@ static void igb_check_vf_rate_limit(struct igb_adapter *);
 
 #ifdef CONFIG_PCI_IOV
 static int igb_vf_configure(struct igb_adapter *adapter, int vf);
+static int igb_pci_enable_sriov(struct pci_dev *dev, int num_vfs);
 #endif
 
 #ifdef CONFIG_PM
@@ -2423,7 +2424,7 @@ err_dma:
 }
 
 #ifdef CONFIG_PCI_IOV
-static int  igb_disable_sriov(struct pci_dev *pdev)
+static int igb_disable_sriov(struct pci_dev *pdev)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct igb_adapter *adapter = netdev_priv(netdev);
@@ -2464,27 +2465,19 @@ static int igb_enable_sriov(struct pci_dev *pdev, int num_vfs)
        int err = 0;
        int i;
 
-       if (!adapter->msix_entries) {
+       if (!adapter->msix_entries || num_vfs > 7) {
                err = -EPERM;
                goto out;
        }
-
        if (!num_vfs)
                goto out;
-       else if (old_vfs && old_vfs == num_vfs)
-               goto out;
-       else if (old_vfs && old_vfs != num_vfs)
-               err = igb_disable_sriov(pdev);
-
-       if (err)
-               goto out;
-
-       if (num_vfs > 7) {
-               err = -EPERM;
-               goto out;
-       }
 
-       adapter->vfs_allocated_count = num_vfs;
+       if (old_vfs) {
+               dev_info(&pdev->dev, "%d pre-allocated VFs found - override max_vfs setting of %d\n",
+                        old_vfs, max_vfs);
+               adapter->vfs_allocated_count = old_vfs;
+       } else
+               adapter->vfs_allocated_count = num_vfs;
 
        adapter->vf_data = kcalloc(adapter->vfs_allocated_count,
                                sizeof(struct vf_data_storage), GFP_KERNEL);
@@ -2498,10 +2491,12 @@ static int igb_enable_sriov(struct pci_dev *pdev, int num_vfs)
                goto out;
        }
 
-       err = pci_enable_sriov(pdev, adapter->vfs_allocated_count);
-       if (err)
-               goto err_out;
-
+       /* only call pci_enable_sriov() if no VFs are allocated already */
+       if (!old_vfs) {
+               err = pci_enable_sriov(pdev, adapter->vfs_allocated_count);
+               if (err)
+                       goto err_out;
+       }
        dev_info(&pdev->dev, "%d VFs allocated\n",
                 adapter->vfs_allocated_count);
        for (i = 0; i < adapter->vfs_allocated_count; i++)
@@ -2617,7 +2612,7 @@ static void igb_probe_vfs(struct igb_adapter *adapter)
                return;
 
        pci_sriov_set_totalvfs(pdev, 7);
-       igb_enable_sriov(pdev, max_vfs);
+       igb_pci_enable_sriov(pdev, max_vfs);
 
 #endif /* CONFIG_PCI_IOV */
 }
@@ -5702,7 +5697,7 @@ static void igb_vf_reset_msg(struct igb_adapter *adapter, u32 vf)
 
        /* reply to reset with ack and vf mac address */
        msgbuf[0] = E1000_VF_RESET | E1000_VT_MSGTYPE_ACK;
-       memcpy(addr, vf_mac, 6);
+       memcpy(addr, vf_mac, ETH_ALEN);
        igb_write_mbx(hw, msgbuf, 3, vf);
 }
 
@@ -7832,4 +7827,26 @@ s32 igb_write_i2c_byte(struct e1000_hw *hw, u8 byte_offset,
                return E1000_SUCCESS;
 
 }
+
+int igb_reinit_queues(struct igb_adapter *adapter)
+{
+       struct net_device *netdev = adapter->netdev;
+       struct pci_dev *pdev = adapter->pdev;
+       int err = 0;
+
+       if (netif_running(netdev))
+               igb_close(netdev);
+
+       igb_clear_interrupt_scheme(adapter);
+
+       if (igb_init_interrupt_scheme(adapter, true)) {
+               dev_err(&pdev->dev, "Unable to allocate memory for queues\n");
+               return -ENOMEM;
+       }
+
+       if (netif_running(netdev))
+               err = igb_open(netdev);
+
+       return err;
+}
 /* igb_main.c */