aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
diff options
context:
space:
mode:
authorAlexander Duyck <aduyck@mirantis.com>2015-11-02 20:10:07 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2015-12-12 04:37:34 -0500
commitc2bc9ce91c31cc214667b9e1a150cd3000856c1c (patch)
tree9e5e59f1278b799a70782248ce9872a9f4676c8f /drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
parentb6488b662b5011a3640033a266886603892dfed1 (diff)
ixgbe: Reorder search to work from the top down instead of bottom up
This patch is meant to reduce the complexity of the search function used for finding a VLVF entry associated with a given VLAN ID. The previous code was searching from bottom to top. I reordered it to search from top to bottom. In addition I pulled an AND statement out of the loop and instead replaced it with an OR statement outside the loop. This should help to reduce the overall size and complexity of the function. There was also some formatting I cleaned up in regards to whitespace and such. Signed-off-by: Alexander Duyck <aduyck@mirantis.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ixgbe/ixgbe_common.c')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index 5fd860a8d6f7..73dcc0aec6dc 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -3002,7 +3002,7 @@ s32 ixgbe_init_uta_tables_generic(struct ixgbe_hw *hw)
3002static s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan, bool vlvf_bypass) 3002static s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan, bool vlvf_bypass)
3003{ 3003{
3004 s32 regindex, first_empty_slot; 3004 s32 regindex, first_empty_slot;
3005 u32 bits = 0; 3005 u32 bits;
3006 3006
3007 /* short cut the special case */ 3007 /* short cut the special case */
3008 if (vlan == 0) 3008 if (vlan == 0)
@@ -3014,33 +3014,29 @@ static s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan, bool vlvf_bypass)
3014 */ 3014 */
3015 first_empty_slot = vlvf_bypass ? IXGBE_ERR_NO_SPACE : 0; 3015 first_empty_slot = vlvf_bypass ? IXGBE_ERR_NO_SPACE : 0;
3016 3016
3017 /* 3017 /* add VLAN enable bit for comparison */
3018 * Search for the vlan id in the VLVF entries. Save off the first empty 3018 vlan |= IXGBE_VLVF_VIEN;
3019 * slot found along the way 3019
3020 */ 3020 /* Search for the vlan id in the VLVF entries. Save off the first empty
3021 for (regindex = 1; regindex < IXGBE_VLVF_ENTRIES; regindex++) { 3021 * slot found along the way.
3022 *
3023 * pre-decrement loop covering (IXGBE_VLVF_ENTRIES - 1) .. 1
3024 */
3025 for (regindex = IXGBE_VLVF_ENTRIES; --regindex;) {
3022 bits = IXGBE_READ_REG(hw, IXGBE_VLVF(regindex)); 3026 bits = IXGBE_READ_REG(hw, IXGBE_VLVF(regindex));
3023 if (!bits && !(first_empty_slot)) 3027 if (bits == vlan)
3028 return regindex;
3029 if (!first_empty_slot && !bits)
3024 first_empty_slot = regindex; 3030 first_empty_slot = regindex;
3025 else if ((bits & 0x0FFF) == vlan)
3026 break;
3027 } 3031 }
3028 3032
3029 /* 3033 /* If we are here then we didn't find the VLAN. Return first empty
3030 * If regindex is less than IXGBE_VLVF_ENTRIES, then we found the vlan 3034 * slot we found during our search, else error.
3031 * in the VLVF. Else use the first empty VLVF register for this 3035 */
3032 * vlan id. 3036 if (!first_empty_slot)
3033 */ 3037 hw_dbg(hw, "No space in VLVF.\n");
3034 if (regindex >= IXGBE_VLVF_ENTRIES) {
3035 if (first_empty_slot)
3036 regindex = first_empty_slot;
3037 else {
3038 hw_dbg(hw, "No space in VLVF.\n");
3039 regindex = IXGBE_ERR_NO_SPACE;
3040 }
3041 }
3042 3038
3043 return regindex; 3039 return first_empty_slot ? : IXGBE_ERR_NO_SPACE;
3044} 3040}
3045 3041
3046/** 3042/**