wlan: Improve convergence of LFR roam candidate scan algorithm.

When no roam candidates are found, the existing scan algorithm takes
long time to converge and there is no guarantee that all channels will
be scanned. This not only impacts power consumption, but also affects
roam convergence by not being able to find roam candidates quickly. The
algorithm is being modified as follows in an attempt to address both
power and convergence of the algorithm:
1. If no candidates were found for the very first time, re-register with
TL by lowering the lookup threshold by 3 dBm. Once look up DOWN
notification is received, we will scan on channels in the occupied list
followed by ALL valid channels not in the occupied list.
2. If still no candidates are found, start neighbor scan results refresh
timer (default is 20s). Upon expiry of the timer, once again scan on
channels in the occupied list followed by ALL valid channels not in the
occupied list.
3. If still no candidates are found, abort scanning and go back to
connected state. At this instant, only lookup UP event is registered
with TL.
This changelist includes the following:
a) Above mentioned scan algorithm.
b) Populate occupied list only with channels where candidates matching
the profile are found.
c) Initialize the occupied list only a connection is made to a profile
different from the previous profile.
d) Use lookup UP threshold 2dB higher than lookup DOWN threshold.
NOTE: This change is being made ONLY for LFR.

Change-Id: Idb3887704dedad753e6406d0d9b1176dbc36f223
CR-Fixed: 418914
diff --git a/CORE/SME/inc/csrNeighborRoam.h b/CORE/SME/inc/csrNeighborRoam.h
index 8659fe7..96117d5 100644
--- a/CORE/SME/inc/csrNeighborRoam.h
+++ b/CORE/SME/inc/csrNeighborRoam.h
@@ -127,15 +127,23 @@
  * NEIGHBOR_LOOKUP_THRESHOLD_INCREMENT_CONSTANT) */
 #define NEIGHBOR_LOOKUP_THRESHOLD_INCREMENT_CONSTANT    5
 #define LOOKUP_THRESHOLD_INCREMENT_MULTIPLIER_MAX       4
-/* 
- * For every scan that results in no candidates, double the scan periodicity 
- * (initialized to NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN) until we hit 
- * NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX (60s). Subsequently, scan every 
- * 60s if we continue to find no candidates. Once a candidate is found, 
- * the periodicity is reset back to NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN.
+/*
+ * Set lookup UP threshold 5 dB higher than the configured
+ * lookup DOWN threshold to minimize thrashing between
+ * DOWN and UP events.
  */
-#define NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN (1000)
-#define NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX (60000)
+#define NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD \
+    (pNeighborRoamInfo->cfgParams.neighborLookupThreshold-5)
+#ifdef FEATURE_WLAN_LFR
+typedef enum
+{
+    eFirstEmptyScan=1,
+    eSecondEmptyScan,
+    eThirdEmptyScan,
+    eFourthEmptyScan,
+    eFifthEmptyScan,
+} eNeighborRoamEmptyScanCount;
+#endif
 
 /* Complete control information for neighbor roam algorithm */
 typedef struct sCsrNeighborRoamControlInfo
@@ -164,7 +172,13 @@
     tANI_BOOLEAN                isVOAdmitted;
     tANI_U32                    MinQBssLoadRequired;
 #endif
-    tANI_U16                    currentScanResultsRefreshPeriod;
+#ifdef FEATURE_WLAN_LFR
+    tANI_U8                     uEmptyScanCount; /* Consecutive number of times scan
+                                                    yielded no results. */
+    tCsrRoamConnectedProfile    prevConnProfile; /* Previous connected profile. If the
+                                                    new profile does not match previous
+                                                    we re-initialize occupied channel list */
+#endif
 } tCsrNeighborRoamControlInfo, *tpCsrNeighborRoamControlInfo;