]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
i40e: amortize wait time when disabling lots of VFs
[karo-tx-linux.git] / drivers / net / ethernet / intel / i40e / i40e_virtchnl_pf.c
index 78460c52b7c445112cd777385f0e81058f26e918..2a47a6474366bf616242635e740e713fb9a3b776 100644 (file)
@@ -50,8 +50,8 @@ static void i40e_vc_vf_broadcast(struct i40e_pf *pf,
        for (i = 0; i < pf->num_alloc_vfs; i++, vf++) {
                int abs_vf_id = vf->vf_id + (int)hw->func_caps.vf_base_id;
                /* Not all vfs are enabled so skip the ones that are not */
-               if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states) &&
-                   !test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states))
+               if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) &&
+                   !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
                        continue;
 
                /* Ignore return value on purpose - a given VF may fail, but
@@ -137,8 +137,8 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf)
                return;
 
        /* verify if the VF is in either init or active before proceeding */
-       if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states) &&
-           !test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states))
+       if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) &&
+           !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
                return;
 
        abs_vf_id = vf->vf_id + (int)vf->pf->hw.func_caps.vf_base_id;
@@ -702,10 +702,8 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
                        dev_info(&pf->pdev->dev,
                                 "Could not allocate VF broadcast filter\n");
                spin_unlock_bh(&vsi->mac_filter_hash_lock);
-               i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(0, vf->vf_id),
-                                 (u32)hena);
-               i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(1, vf->vf_id),
-                                 (u32)(hena >> 32));
+               wr32(&pf->hw, I40E_VFQF_HENA1(0, vf->vf_id), (u32)hena);
+               wr32(&pf->hw, I40E_VFQF_HENA1(1, vf->vf_id), (u32)(hena >> 32));
        }
 
        /* program mac filter */
@@ -811,6 +809,11 @@ static void i40e_free_vf_res(struct i40e_vf *vf)
        u32 reg_idx, reg;
        int i, msix_vf;
 
+       /* Start by disabling VF's configuration API to prevent the OS from
+        * accessing the VF's VSI after it's freed / invalidated.
+        */
+       clear_bit(I40E_VF_STATE_INIT, &vf->vf_states);
+
        /* free vsi & disconnect it from the parent uplink */
        if (vf->lan_vsi_idx) {
                i40e_vsi_release(pf->vsi[vf->lan_vsi_idx]);
@@ -850,7 +853,6 @@ static void i40e_free_vf_res(struct i40e_vf *vf)
        /* reset some of the state variables keeping track of the resources */
        vf->num_queue_pairs = 0;
        vf->vf_states = 0;
-       clear_bit(I40E_VF_STAT_INIT, &vf->vf_states);
 }
 
 /**
@@ -882,7 +884,7 @@ static int i40e_alloc_vf_res(struct i40e_vf *vf)
        vf->num_queue_pairs = total_queue_pairs;
 
        /* VF is now completely initialized */
-       set_bit(I40E_VF_STAT_INIT, &vf->vf_states);
+       set_bit(I40E_VF_STATE_INIT, &vf->vf_states);
 
 error_alloc:
        if (ret)
@@ -921,25 +923,30 @@ static int i40e_quiesce_vf_pci(struct i40e_vf *vf)
 }
 
 /**
- * i40e_reset_vf
+ * i40e_trigger_vf_reset
  * @vf: pointer to the VF structure
  * @flr: VFLR was issued or not
  *
- * reset the VF
+ * Trigger hardware to start a reset for a particular VF. Expects the caller
+ * to wait the proper amount of time to allow hardware to reset the VF before
+ * it cleans up and restores VF functionality.
  **/
-void i40e_reset_vf(struct i40e_vf *vf, bool flr)
+static void i40e_trigger_vf_reset(struct i40e_vf *vf, bool flr)
 {
        struct i40e_pf *pf = vf->pf;
        struct i40e_hw *hw = &pf->hw;
        u32 reg, reg_idx, bit_idx;
-       bool rsd = false;
-       int i;
-
-       if (test_and_set_bit(__I40E_VF_DISABLE, &pf->state))
-               return;
 
        /* warn the VF */
-       clear_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states);
+       clear_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states);
+
+       /* Disable VF's configuration API during reset. The flag is re-enabled
+        * in i40e_alloc_vf_res(), when it's safe again to access VF's VSI.
+        * It's normally disabled in i40e_free_vf_res(), but it's safer
+        * to do it earlier to give some time to finish to any VF config
+        * functions that may still be running at this point.
+        */
+       clear_bit(I40E_VF_STATE_INIT, &vf->vf_states);
 
        /* In the case of a VFLR, the HW has already reset the VF and we
         * just need to clean up, so don't hit the VFRTRIG register.
@@ -960,6 +967,79 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
        if (i40e_quiesce_vf_pci(vf))
                dev_err(&pf->pdev->dev, "VF %d PCI transactions stuck\n",
                        vf->vf_id);
+}
+
+/**
+ * i40e_cleanup_reset_vf
+ * @vf: pointer to the VF structure
+ *
+ * Cleanup a VF after the hardware reset is finished. Expects the caller to
+ * have verified whether the reset is finished properly, and ensure the
+ * minimum amount of wait time has passed.
+ **/
+static void i40e_cleanup_reset_vf(struct i40e_vf *vf)
+{
+       struct i40e_pf *pf = vf->pf;
+       struct i40e_hw *hw = &pf->hw;
+       u32 reg;
+
+       /* free VF resources to begin resetting the VSI state */
+       i40e_free_vf_res(vf);
+
+       /* Enable hardware by clearing the reset bit in the VPGEN_VFRTRIG reg.
+        * By doing this we allow HW to access VF memory at any point. If we
+        * did it any sooner, HW could access memory while it was being freed
+        * in i40e_free_vf_res(), causing an IOMMU fault.
+        *
+        * On the other hand, this needs to be done ASAP, because the VF driver
+        * is waiting for this to happen and may report a timeout. It's
+        * harmless, but it gets logged into Guest OS kernel log, so best avoid
+        * it.
+        */
+       reg = rd32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id));
+       reg &= ~I40E_VPGEN_VFRTRIG_VFSWR_MASK;
+       wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg);
+
+       /* reallocate VF resources to finish resetting the VSI state */
+       if (!i40e_alloc_vf_res(vf)) {
+               int abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id;
+               i40e_enable_vf_mappings(vf);
+               set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states);
+               clear_bit(I40E_VF_STATE_DISABLED, &vf->vf_states);
+               /* Do not notify the client during VF init */
+               if (test_and_clear_bit(I40E_VF_STATE_PRE_ENABLE,
+                                      &vf->vf_states))
+                       i40e_notify_client_of_vf_reset(pf, abs_vf_id);
+               vf->num_vlan = 0;
+       }
+
+       /* Tell the VF driver the reset is done. This needs to be done only
+        * after VF has been fully initialized, because the VF driver may
+        * request resources immediately after setting this flag.
+        */
+       wr32(hw, I40E_VFGEN_RSTAT1(vf->vf_id), I40E_VFR_VFACTIVE);
+}
+
+/**
+ * i40e_reset_vf
+ * @vf: pointer to the VF structure
+ * @flr: VFLR was issued or not
+ *
+ * reset the VF
+ **/
+void i40e_reset_vf(struct i40e_vf *vf, bool flr)
+{
+       struct i40e_pf *pf = vf->pf;
+       struct i40e_hw *hw = &pf->hw;
+       bool rsd = false;
+       u32 reg;
+       int i;
+
+       /* If VFs have been disabled, there is no need to reset */
+       if (test_and_set_bit(__I40E_VF_DISABLE, &pf->state))
+               return;
+
+       i40e_trigger_vf_reset(vf, flr);
 
        /* poll VPGEN_VFRSTAT reg to make sure
         * that reset is complete
@@ -984,32 +1064,113 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
        if (!rsd)
                dev_err(&pf->pdev->dev, "VF reset check timeout on VF %d\n",
                        vf->vf_id);
-       wr32(hw, I40E_VFGEN_RSTAT1(vf->vf_id), I40E_VFR_COMPLETED);
-       /* clear the reset bit in the VPGEN_VFRTRIG reg */
-       reg = rd32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id));
-       reg &= ~I40E_VPGEN_VFRTRIG_VFSWR_MASK;
-       wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg);
+       usleep_range(10000, 20000);
 
-       /* On initial reset, we won't have any queues */
-       if (vf->lan_vsi_idx == 0)
-               goto complete_reset;
+       /* On initial reset, we don't have any queues to disable */
+       if (vf->lan_vsi_idx != 0)
+               i40e_vsi_stop_rings(pf->vsi[vf->lan_vsi_idx]);
 
-       i40e_vsi_stop_rings(pf->vsi[vf->lan_vsi_idx]);
-complete_reset:
-       /* reallocate VF resources to reset the VSI state */
-       i40e_free_vf_res(vf);
-       if (!i40e_alloc_vf_res(vf)) {
-               int abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id;
-               i40e_enable_vf_mappings(vf);
-               set_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states);
-               clear_bit(I40E_VF_STAT_DISABLED, &vf->vf_states);
-               /* Do not notify the client during VF init */
-               if (vf->pf->num_alloc_vfs)
-                       i40e_notify_client_of_vf_reset(pf, abs_vf_id);
-               vf->num_vlan = 0;
+       i40e_cleanup_reset_vf(vf);
+
+       i40e_flush(hw);
+       clear_bit(__I40E_VF_DISABLE, &pf->state);
+}
+
+/**
+ * i40e_reset_all_vfs
+ * @pf: pointer to the PF structure
+ * @flr: VFLR was issued or not
+ *
+ * Reset all allocated VFs in one go. First, tell the hardware to reset each
+ * VF, then do all the waiting in one chunk, and finally finish restoring each
+ * VF after the wait. This is useful during PF routines which need to reset
+ * all VFs, as otherwise it must perform these resets in a serialized fashion.
+ **/
+void i40e_reset_all_vfs(struct i40e_pf *pf, bool flr)
+{
+       struct i40e_hw *hw = &pf->hw;
+       struct i40e_vf *vf;
+       int i, v;
+       u32 reg;
+
+       /* If we don't have any VFs, then there is nothing to reset */
+       if (!pf->num_alloc_vfs)
+               return;
+
+       /* If VFs have been disabled, there is no need to reset */
+       if (test_and_set_bit(__I40E_VF_DISABLE, &pf->state))
+               return;
+
+       /* Begin reset on all VFs at once */
+       for (v = 0; v < pf->num_alloc_vfs; v++)
+               i40e_trigger_vf_reset(&pf->vf[v], flr);
+
+       /* HW requires some time to make sure it can flush the FIFO for a VF
+        * when it resets it. Poll the VPGEN_VFRSTAT register for each VF in
+        * sequence to make sure that it has completed. We'll keep track of
+        * the VFs using a simple iterator that increments once that VF has
+        * finished resetting.
+        */
+       for (i = 0, v = 0; i < 10 && v < pf->num_alloc_vfs; i++) {
+               usleep_range(10000, 20000);
+
+               /* Check each VF in sequence, beginning with the VF to fail
+                * the previous check.
+                */
+               while (v < pf->num_alloc_vfs) {
+                       vf = &pf->vf[v];
+                       reg = rd32(hw, I40E_VPGEN_VFRSTAT(vf->vf_id));
+                       if (!(reg & I40E_VPGEN_VFRSTAT_VFRD_MASK))
+                               break;
+
+                       /* If the current VF has finished resetting, move on
+                        * to the next VF in sequence.
+                        */
+                       v++;
+               }
+       }
+
+       if (flr)
+               usleep_range(10000, 20000);
+
+       /* Display a warning if at least one VF didn't manage to reset in
+        * time, but continue on with the operation.
+        */
+       if (v < pf->num_alloc_vfs)
+               dev_err(&pf->pdev->dev, "VF reset check timeout on VF %d\n",
+                       pf->vf[v].vf_id);
+       usleep_range(10000, 20000);
+
+       /* Begin disabling all the rings associated with VFs, but do not wait
+        * between each VF.
+        */
+       for (v = 0; v < pf->num_alloc_vfs; v++) {
+               /* On initial reset, we don't have any queues to disable */
+               if (pf->vf[v].lan_vsi_idx == 0)
+                       continue;
+
+               i40e_vsi_stop_rings_no_wait(pf->vsi[pf->vf[v].lan_vsi_idx]);
+       }
+
+       /* Now that we've notified HW to disable all of the VF rings, wait
+        * until they finish.
+        */
+       for (v = 0; v < pf->num_alloc_vfs; v++) {
+               /* On initial reset, we don't have any queues to disable */
+               if (pf->vf[v].lan_vsi_idx == 0)
+                       continue;
+
+               i40e_vsi_wait_queues_disabled(pf->vsi[pf->vf[v].lan_vsi_idx]);
        }
-       /* tell the VF the reset is done */
-       wr32(hw, I40E_VFGEN_RSTAT1(vf->vf_id), I40E_VFR_VFACTIVE);
+
+       /* Hw may need up to 50ms to finish disabling the RX queues. We
+        * minimize the wait by delaying only once for all VFs.
+        */
+       mdelay(50);
+
+       /* Finish the reset on each VF */
+       for (v = 0; v < pf->num_alloc_vfs; v++)
+               i40e_cleanup_reset_vf(&pf->vf[v]);
 
        i40e_flush(hw);
        clear_bit(__I40E_VF_DISABLE, &pf->state);
@@ -1033,9 +1194,21 @@ void i40e_free_vfs(struct i40e_pf *pf)
                usleep_range(1000, 2000);
 
        i40e_notify_client_of_vf_enable(pf, 0);
-       for (i = 0; i < pf->num_alloc_vfs; i++)
-               if (test_bit(I40E_VF_STAT_INIT, &pf->vf[i].vf_states))
-                       i40e_vsi_stop_rings(pf->vsi[pf->vf[i].lan_vsi_idx]);
+
+       /* Amortize wait time by stopping all VFs at the same time */
+       for (i = 0; i < pf->num_alloc_vfs; i++) {
+               if (test_bit(I40E_VF_STATE_INIT, &pf->vf[i].vf_states))
+                       continue;
+
+               i40e_vsi_stop_rings_no_wait(pf->vsi[pf->vf[i].lan_vsi_idx]);
+       }
+
+       for (i = 0; i < pf->num_alloc_vfs; i++) {
+               if (test_bit(I40E_VF_STATE_INIT, &pf->vf[i].vf_states))
+                       continue;
+
+               i40e_vsi_wait_queues_disabled(pf->vsi[pf->vf[i].lan_vsi_idx]);
+       }
 
        /* Disable IOV before freeing resources. This lets any VF drivers
         * running in the host get themselves cleaned up before we yank
@@ -1052,7 +1225,7 @@ void i40e_free_vfs(struct i40e_pf *pf)
        tmp = pf->num_alloc_vfs;
        pf->num_alloc_vfs = 0;
        for (i = 0; i < tmp; i++) {
-               if (test_bit(I40E_VF_STAT_INIT, &pf->vf[i].vf_states))
+               if (test_bit(I40E_VF_STATE_INIT, &pf->vf[i].vf_states))
                        i40e_free_vf_res(&pf->vf[i]);
                /* disable qp mappings */
                i40e_disable_vf_mappings(&pf->vf[i]);
@@ -1120,12 +1293,15 @@ int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs)
                /* assign default capabilities */
                set_bit(I40E_VIRTCHNL_VF_CAP_L2, &vfs[i].vf_caps);
                vfs[i].spoofchk = true;
-               /* VF resources get allocated during reset */
-               i40e_reset_vf(&vfs[i], false);
+
+               set_bit(I40E_VF_STATE_PRE_ENABLE, &vfs[i].vf_states);
 
        }
        pf->num_alloc_vfs = num_alloc_vfs;
 
+       /* VF resources get allocated during reset */
+       i40e_reset_all_vfs(pf, false);
+
        i40e_notify_client_of_vf_enable(pf, num_alloc_vfs);
 
 err_alloc:
@@ -1258,7 +1434,7 @@ static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
                                "Number of invalid messages exceeded for VF %d\n",
                                vf->vf_id);
                        dev_err(&pf->pdev->dev, "Use PF Control I/F to enable the VF\n");
-                       set_bit(I40E_VF_STAT_DISABLED, &vf->vf_states);
+                       set_bit(I40E_VF_STATE_DISABLED, &vf->vf_states);
                }
        } else {
                vf->num_valid_msgs++;
@@ -1333,7 +1509,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
        int len = 0;
        int ret;
 
-       if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto err;
        }
@@ -1359,10 +1535,10 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
        if (!vsi->info.pvid)
                vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_VLAN;
 
-       if (i40e_vf_client_capable(pf, vf->vf_id, I40E_CLIENT_IWARP) &&
+       if (i40e_vf_client_capable(pf, vf->vf_id) &&
            (vf->driver_caps & I40E_VIRTCHNL_VF_OFFLOAD_IWARP)) {
                vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_IWARP;
-               set_bit(I40E_VF_STAT_IWARPENA, &vf->vf_states);
+               set_bit(I40E_VF_STATE_IWARPENA, &vf->vf_states);
        }
 
        if (vf->driver_caps & I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF) {
@@ -1383,6 +1559,13 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
                                I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2;
        }
 
+       if (vf->driver_caps & I40E_VIRTCHNL_VF_OFFLOAD_ENCAP)
+               vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_ENCAP;
+
+       if ((pf->flags & I40E_FLAG_OUTER_UDP_CSUM_CAPABLE) &&
+           (vf->driver_caps & I40E_VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM))
+               vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM;
+
        if (vf->driver_caps & I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING) {
                if (pf->flags & I40E_FLAG_MFP_ENABLED) {
                        dev_err(&pf->pdev->dev,
@@ -1416,7 +1599,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
                ether_addr_copy(vfres->vsi_res[0].default_mac_addr,
                                vf->default_lan_addr.addr);
        }
-       set_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states);
+       set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states);
 
 err:
        /* send the response back to the VF */
@@ -1439,7 +1622,7 @@ err:
  **/
 static void i40e_vc_reset_vf_msg(struct i40e_vf *vf)
 {
-       if (test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states))
+       if (test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
                i40e_reset_vf(vf, false);
 }
 
@@ -1487,7 +1670,7 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf,
        int bkt;
 
        vsi = i40e_find_vsi_from_id(pf, info->vsi_id);
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
            !i40e_vc_isvalid_vsi_id(vf, info->vsi_id) ||
            !vsi) {
                aq_ret = I40E_ERR_PARAM;
@@ -1548,9 +1731,9 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf,
                         "VF %d successfully set multicast promiscuous mode\n",
                         vf->vf_id);
                if (allmulti)
-                       set_bit(I40E_VF_STAT_MC_PROMISC, &vf->vf_states);
+                       set_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states);
                else
-                       clear_bit(I40E_VF_STAT_MC_PROMISC, &vf->vf_states);
+                       clear_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states);
        }
 
        if (info->flags & I40E_FLAG_VF_UNICAST_PROMISC)
@@ -1599,9 +1782,9 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf,
                         "VF %d successfully set unicast promiscuous mode\n",
                         vf->vf_id);
                if (alluni)
-                       set_bit(I40E_VF_STAT_UC_PROMISC, &vf->vf_states);
+                       set_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states);
                else
-                       clear_bit(I40E_VF_STAT_UC_PROMISC, &vf->vf_states);
+                       clear_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states);
        }
 
 error_param:
@@ -1630,7 +1813,7 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
        i40e_status aq_ret = 0;
        int i;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
        }
@@ -1687,7 +1870,7 @@ static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
        unsigned long tempmap;
        int i;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
        }
@@ -1747,7 +1930,7 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
        u16 vsi_id = vqs->vsi_id;
        i40e_status aq_ret = 0;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
        }
@@ -1786,7 +1969,7 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
        struct i40e_pf *pf = vf->pf;
        i40e_status aq_ret = 0;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
        }
@@ -1828,7 +2011,7 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
 
        memset(&stats, 0, sizeof(struct i40e_eth_stats));
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
        }
@@ -1853,7 +2036,7 @@ error_param:
 }
 
 /* If the VF is not trusted restrict the number of MAC/VLAN it can program */
-#define I40E_VC_MAX_MAC_ADDR_PER_VF 8
+#define I40E_VC_MAX_MAC_ADDR_PER_VF 12
 #define I40E_VC_MAX_VLAN_PER_VF 8
 
 /**
@@ -1915,7 +2098,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
        i40e_status ret = 0;
        int i;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
            !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
                ret = I40E_ERR_PARAM;
                goto error_param;
@@ -1984,7 +2167,7 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
        i40e_status ret = 0;
        int i;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
            !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
                ret = I40E_ERR_PARAM;
                goto error_param;
@@ -2050,7 +2233,7 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
                        "VF is not trusted, switch the VF to trusted to add more VLAN addresses\n");
                goto error_param;
        }
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
            !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
@@ -2077,12 +2260,12 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
                if (!ret)
                        vf->num_vlan++;
 
-               if (test_bit(I40E_VF_STAT_UC_PROMISC, &vf->vf_states))
+               if (test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states))
                        i40e_aq_set_vsi_uc_promisc_on_vlan(&pf->hw, vsi->seid,
                                                           true,
                                                           vfl->vlan_id[i],
                                                           NULL);
-               if (test_bit(I40E_VF_STAT_MC_PROMISC, &vf->vf_states))
+               if (test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states))
                        i40e_aq_set_vsi_mc_promisc_on_vlan(&pf->hw, vsi->seid,
                                                           true,
                                                           vfl->vlan_id[i],
@@ -2117,7 +2300,7 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
        i40e_status aq_ret = 0;
        int i;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
            !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
@@ -2140,12 +2323,12 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
                i40e_vsi_kill_vlan(vsi, vfl->vlan_id[i]);
                vf->num_vlan--;
 
-               if (test_bit(I40E_VF_STAT_UC_PROMISC, &vf->vf_states))
+               if (test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states))
                        i40e_aq_set_vsi_uc_promisc_on_vlan(&pf->hw, vsi->seid,
                                                           false,
                                                           vfl->vlan_id[i],
                                                           NULL);
-               if (test_bit(I40E_VF_STAT_MC_PROMISC, &vf->vf_states))
+               if (test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states))
                        i40e_aq_set_vsi_mc_promisc_on_vlan(&pf->hw, vsi->seid,
                                                           false,
                                                           vfl->vlan_id[i],
@@ -2171,8 +2354,8 @@ static int i40e_vc_iwarp_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
        int abs_vf_id = vf->vf_id + pf->hw.func_caps.vf_base_id;
        i40e_status aq_ret = 0;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
-           !test_bit(I40E_VF_STAT_IWARPENA, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
+           !test_bit(I40E_VF_STATE_IWARPENA, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
        }
@@ -2202,8 +2385,8 @@ static int i40e_vc_iwarp_qvmap_msg(struct i40e_vf *vf, u8 *msg, u16 msglen,
                                (struct i40e_virtchnl_iwarp_qvlist_info *)msg;
        i40e_status aq_ret = 0;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
-           !test_bit(I40E_VF_STAT_IWARPENA, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
+           !test_bit(I40E_VF_STATE_IWARPENA, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto error_param;
        }
@@ -2240,7 +2423,7 @@ static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg, u16 msglen)
        u16 vsi_id = vrk->vsi_id;
        i40e_status aq_ret = 0;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
            !i40e_vc_isvalid_vsi_id(vf, vsi_id) ||
            (vrk->key_len != I40E_HKEY_ARRAY_SIZE)) {
                aq_ret = I40E_ERR_PARAM;
@@ -2272,7 +2455,7 @@ static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg, u16 msglen)
        u16 vsi_id = vrl->vsi_id;
        i40e_status aq_ret = 0;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states) ||
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
            !i40e_vc_isvalid_vsi_id(vf, vsi_id) ||
            (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE)) {
                aq_ret = I40E_ERR_PARAM;
@@ -2302,7 +2485,7 @@ static int i40e_vc_get_rss_hena(struct i40e_vf *vf, u8 *msg, u16 msglen)
        i40e_status aq_ret = 0;
        int len = 0;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto err;
        }
@@ -2339,7 +2522,7 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg, u16 msglen)
        struct i40e_hw *hw = &pf->hw;
        i40e_status aq_ret = 0;
 
-       if (!test_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto err;
        }
@@ -2369,7 +2552,7 @@ static int i40e_vc_validate_vf_msg(struct i40e_vf *vf, u32 v_opcode,
        int valid_len = 0;
 
        /* Check if VF is disabled. */
-       if (test_bit(I40E_VF_STAT_DISABLED, &vf->vf_states))
+       if (test_bit(I40E_VF_STATE_DISABLED, &vf->vf_states))
                return I40E_ERR_PARAM;
 
        /* Validate message length. */
@@ -2693,7 +2876,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
 
        vf = &(pf->vf[vf_id]);
        vsi = pf->vsi[vf->lan_vsi_idx];
-       if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
                dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
                        vf_id);
                ret = -EAGAIN;
@@ -2782,7 +2965,7 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
 
        vf = &(pf->vf[vf_id]);
        vsi = pf->vsi[vf->lan_vsi_idx];
-       if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
                dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
                        vf_id);
                ret = -EAGAIN;
@@ -2914,7 +3097,7 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
 
        vf = &(pf->vf[vf_id]);
        vsi = pf->vsi[vf->lan_vsi_idx];
-       if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
                dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
                        vf_id);
                ret = -EAGAIN;
@@ -2995,7 +3178,7 @@ int i40e_ndo_get_vf_config(struct net_device *netdev,
        vf = &(pf->vf[vf_id]);
        /* first vsi is always the LAN vsi */
        vsi = pf->vsi[vf->lan_vsi_idx];
-       if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
                dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
                        vf_id);
                ret = -EAGAIN;
@@ -3114,7 +3297,7 @@ int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable)
        }
 
        vf = &(pf->vf[vf_id]);
-       if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
+       if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
                dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
                        vf_id);
                ret = -EAGAIN;