[dpdk-dev] [PATCH 21/29] ixgbe/base: smplify add/remove VLANs

2016-06-13 Thread Ferruh Yigit
On 5/6/2016 7:07 AM, Beilei Xing wrote:
> This patch simplifies the adding and removing VLANs from
> VFTA/VLVF/VLVFB registers. The logic to determine registers has
> been simplified to (vid / 32) and (1 - vid / 32). Many conditional
> paths and checks are no longer needed with this patch.
> 
> Signed-off-by: Beilei Xing 
> ---
typo on patch subject: smplify

...


[dpdk-dev] [PATCH 21/29] ixgbe/base: smplify add/remove VLANs

2016-05-06 Thread Beilei Xing
This patch simplifies the adding and removing VLANs from
VFTA/VLVF/VLVFB registers. The logic to determine registers has
been simplified to (vid / 32) and (1 - vid / 32). Many conditional
paths and checks are no longer needed with this patch.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c|  18 ++--
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +-
 drivers/net/ixgbe/base/ixgbe_common.c | 188 ++
 drivers/net/ixgbe/base/ixgbe_common.h |   2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   2 +-
 5 files changed, 91 insertions(+), 121 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index e117b86..90deaf1 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1080,8 +1080,8 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  ixgbe_set_vfta - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFTA
- *  @vlan_on: boolean flag to turn on/off VLAN in VFTA
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
@@ -1095,18 +1095,20 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  ixgbe_set_vlvf - Set VLAN Pool Filter
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
- *  @vfta_changed: pointer to boolean flag which indicates whether VFTA
- * should be changed
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN in VLVF
+ *  @vfta_delta: pointer to the difference between the current value of VFTA
+ *   and the desired value
+ *  @vfta: the desired value of the VFTA
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-   bool *vfta_changed)
+  u32 *vfta_delta, u32 vfta)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vlvf, (hw, vlan, vind,
-  vlan_on, vfta_changed), IXGBE_NOT_IMPLEMENTED);
+  vlan_on, vfta_delta, vfta),
+  IXGBE_NOT_IMPLEMENTED);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index f5970a8..9431d14 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -126,7 +126,7 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
   u32 vind, bool vlan_on);
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
-  bool vlan_on, bool *vfta_changed);
+  bool vlan_on, u32 *vfta_delta, u32 vfta);
 s32 ixgbe_fc_enable(struct ixgbe_hw *hw);
 s32 ixgbe_setup_fc(struct ixgbe_hw *hw);
 s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build,
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a708cf..4551a2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -3853,24 +3853,20 @@ s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan)
  *  ixgbe_set_vfta_generic - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
 s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
   bool vlan_on)
 {
-   s32 regindex;
-   u32 bitindex;
-   u32 vfta;
-   u32 targetbit;
-   s32 ret_val = IXGBE_SUCCESS;
-   bool vfta_changed = false;
+   u32 regidx, vfta_delta, vfta;
+   s32 ret_val;

DEBUGFUNC("ixgbe_set_vfta_generic");

-   if (vlan > 4095)
+   if (vlan > 4095 || vind > 63)
return IXGBE_ERR_PARAM;

/*
@@ -3885,33 +3881,28 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 
vlan, u32 vind,
 *bits[11-5]: which register
 *bits[4-0]:  which bit in the register
 */
-   regindex = (vlan >> 5) & 0x7F;
-   bitindex = vlan & 0x1F;
-   targetbit = (1 << bitindex);
-   vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
-
-   if (vlan_on) {
-   if (!(vfta & targetbit)) {
-   vfta |= targetbit;
-   vfta_changed = true;
-   }
-   } else {