qlcnic: Allow SR-IOV VF probe in hypervisor.
authorRajesh Borundia <rajesh.borundia@qlogic.com>
Fri, 9 May 2014 06:51:29 +0000 (02:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 May 2014 17:08:57 +0000 (13:08 -0400)
o Add support for SR-IOV VF probe in hypervisor to enable
  assignment of VFs within hypervisor.
o SR-IOV VF can be uplinked to bridge/macvtap device with this change.
o Refactor SR-IOV enable/disable code. We cannot take rtnl lock
  while enabling/disabling SR-IOV as VF probe will take an rtnl
  lock.
o Disable spoofchk by default.

Signed-off-by: Rajesh Borundia <rajesh.borundia@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c

index 7023d358baa9c0bb0f4d423174bf21acfe3ac3ea..28ebe1ba5a0b103d5c9ed1d8af1300e791089ad2 100644 (file)
@@ -2398,9 +2398,6 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        int err, pci_using_dac = -1;
        char board_name[QLCNIC_MAX_BOARD_NAME_LEN + 19]; /* MAC + ": " + name */
 
-       if (pdev->is_virtfn)
-               return -ENODEV;
-
        err = pci_enable_device(pdev);
        if (err)
                return err;
@@ -2680,9 +2677,9 @@ static void qlcnic_remove(struct pci_dev *pdev)
                return;
 
        netdev = adapter->netdev;
-       qlcnic_sriov_pf_disable(adapter);
 
        qlcnic_cancel_idc_work(adapter);
+       qlcnic_sriov_pf_disable(adapter);
        ahw = adapter->ahw;
 
        unregister_netdev(netdev);
index 0638c1810d54547df9eafb961439085dff4364a2..4eccc2b74f679a51e10ca12dfc590dbca78b4041 100644 (file)
@@ -198,7 +198,7 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs)
                        }
                        sriov->vf_info[i].vp = vp;
                        vp->max_tx_bw = MAX_BW;
-                       vp->spoofchk = true;
+                       vp->spoofchk = false;
                        random_ether_addr(vp->mac);
                        dev_info(&adapter->pdev->dev,
                                 "MAC Address %pM is configured for VF %d\n",
index c7926ce85fecf76fa226694dc5265dbdc9a812c0..df409086e4d3ad339d148ea224afec2224e4ad72 100644 (file)
@@ -472,12 +472,12 @@ static int qlcnic_pci_sriov_disable(struct qlcnic_adapter *adapter)
                return -EPERM;
        }
 
+       qlcnic_sriov_pf_disable(adapter);
+
        rtnl_lock();
        if (netif_running(netdev))
                __qlcnic_down(adapter, netdev);
 
-       qlcnic_sriov_pf_disable(adapter);
-
        qlcnic_sriov_free_vlans(adapter);
 
        qlcnic_sriov_pf_cleanup(adapter);
@@ -596,7 +596,6 @@ static int __qlcnic_pci_sriov_enable(struct qlcnic_adapter *adapter,
 
        qlcnic_sriov_alloc_vlans(adapter);
 
-       err = qlcnic_sriov_pf_enable(adapter, num_vfs);
        return err;
 
 del_flr_queue:
@@ -627,25 +626,36 @@ static int qlcnic_pci_sriov_enable(struct qlcnic_adapter *adapter, int num_vfs)
                __qlcnic_down(adapter, netdev);
 
        err = __qlcnic_pci_sriov_enable(adapter, num_vfs);
-       if (err) {
-               netdev_info(netdev, "Failed to enable SR-IOV on port %d\n",
-                           adapter->portnum);
+       if (err)
+               goto error;
 
-               err = -EIO;
-               if (qlcnic_83xx_configure_opmode(adapter))
-                       goto error;
-       } else {
+       if (netif_running(netdev))
+               __qlcnic_up(adapter, netdev);
+
+       rtnl_unlock();
+       err = qlcnic_sriov_pf_enable(adapter, num_vfs);
+       if (!err) {
                netdev_info(netdev,
                            "SR-IOV is enabled successfully on port %d\n",
                            adapter->portnum);
                /* Return number of vfs enabled */
-               err = num_vfs;
+               return num_vfs;
        }
+
+       rtnl_lock();
        if (netif_running(netdev))
-               __qlcnic_up(adapter, netdev);
+               __qlcnic_down(adapter, netdev);
 
 error:
+       if (!qlcnic_83xx_configure_opmode(adapter)) {
+               if (netif_running(netdev))
+                       __qlcnic_up(adapter, netdev);
+       }
+
        rtnl_unlock();
+       netdev_info(netdev, "Failed to enable SR-IOV on port %d\n",
+                   adapter->portnum);
+
        return err;
 }