remove useless memzone includes
[dpdk.git] / drivers / net / i40e / i40e_ethdev_vf.c
index 0d29e53..a32c196 100644 (file)
 #include <rte_log.h>
 #include <rte_debug.h>
 #include <rte_pci.h>
+#include <rte_bus_pci.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
-#include <rte_memzone.h>
 #include <rte_eal.h>
 #include <rte_alarm.h>
 #include <rte_ether.h>
@@ -118,7 +118,7 @@ static int i40evf_dev_xstats_get_names(struct rte_eth_dev *dev,
 static void i40evf_dev_xstats_reset(struct rte_eth_dev *dev);
 static int i40evf_vlan_filter_set(struct rte_eth_dev *dev,
                                  uint16_t vlan_id, int on);
-static void i40evf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+static int i40evf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 static void i40evf_dev_close(struct rte_eth_dev *dev);
 static int  i40evf_dev_reset(struct rte_eth_dev *dev);
 static void i40evf_dev_promiscuous_enable(struct rte_eth_dev *dev);
@@ -1111,10 +1111,30 @@ i40evf_enable_irq0(struct i40e_hw *hw)
 }
 
 static int
-i40evf_reset_vf(struct i40e_hw *hw)
+i40evf_check_vf_reset_done(struct i40e_hw *hw)
 {
        int i, reset;
 
+       for (i = 0; i < MAX_RESET_WAIT_CNT; i++) {
+               reset = I40E_READ_REG(hw, I40E_VFGEN_RSTAT) &
+                       I40E_VFGEN_RSTAT_VFR_STATE_MASK;
+               reset = reset >> I40E_VFGEN_RSTAT_VFR_STATE_SHIFT;
+               if (reset == VIRTCHNL_VFR_VFACTIVE ||
+                   reset == VIRTCHNL_VFR_COMPLETED)
+                       break;
+               rte_delay_ms(50);
+       }
+
+       if (i >= MAX_RESET_WAIT_CNT)
+               return -1;
+
+       return 0;
+}
+static int
+i40evf_reset_vf(struct i40e_hw *hw)
+{
+       int ret;
+
        if (i40e_vf_reset(hw) != I40E_SUCCESS) {
                PMD_INIT_LOG(ERR, "Reset VF NIC failed");
                return -1;
@@ -1130,19 +1150,10 @@ i40evf_reset_vf(struct i40e_hw *hw)
          */
        rte_delay_ms(200);
 
-       for (i = 0; i < MAX_RESET_WAIT_CNT; i++) {
-               reset = rd32(hw, I40E_VFGEN_RSTAT) &
-                       I40E_VFGEN_RSTAT_VFR_STATE_MASK;
-               reset = reset >> I40E_VFGEN_RSTAT_VFR_STATE_SHIFT;
-               if (VIRTCHNL_VFR_COMPLETED == reset || VIRTCHNL_VFR_VFACTIVE == reset)
-                       break;
-               else
-                       rte_delay_ms(50);
-       }
-
-       if (i >= MAX_RESET_WAIT_CNT) {
-               PMD_INIT_LOG(ERR, "Reset VF NIC failed");
-               return -1;
+       ret = i40evf_check_vf_reset_done(hw);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "VF is still resetting");
+               return ret;
        }
 
        return 0;
@@ -1165,6 +1176,10 @@ i40evf_init_vf(struct rte_eth_dev *dev)
                goto err;
        }
 
+       err = i40evf_check_vf_reset_done(hw);
+       if (err)
+               goto err;
+
        i40e_init_adminq_parameter(hw);
        err = i40e_init_adminq(hw);
        if (err) {
@@ -1189,6 +1204,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)
                PMD_INIT_LOG(ERR, "init_adminq failed");
                goto err;
        }
+
        vf->aq_resp = rte_zmalloc("vf_aq_resp", I40E_AQ_BUF_SZ, 0);
        if (!vf->aq_resp) {
                PMD_INIT_LOG(ERR, "unable to allocate vf_aq_resp memory");
@@ -1445,7 +1461,6 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
        i40e_set_default_ptype_table(eth_dev);
        i40e_set_default_pctype_table(eth_dev);
        rte_eth_copy_pci_info(eth_dev, pci_dev);
-       eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
        hw->vendor_id = pci_dev->id.vendor_id;
        hw->device_id = pci_dev->id.device_id;
@@ -1572,12 +1587,10 @@ static int
 i40evf_init_vlan(struct rte_eth_dev *dev)
 {
        /* Apply vlan offload setting */
-       i40evf_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK);
-
-       return I40E_SUCCESS;
+       return i40evf_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK);
 }
 
-static void
+static int
 i40evf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 {
        struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
@@ -1590,6 +1603,8 @@ i40evf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
                else
                        i40evf_disable_vlan_strip(dev);
        }
+
+       return 0;
 }
 
 static int