prima: WLAN Driver Release 3.2.0.2

Integrate the following CLs from Perforce:

636735: Insure PMK candidate notify event only sent up to supplicant for RSN
Insure that PMK candidate notify even only sent up to supplicant for
RSN associations (CR 362782)

636761,
636770,
636789: Feature for supporting roaming to an AP with better RSSI
This feature takes care of the station to roam to a new AP only if the
roamable/new AP has a better RSSI than current AP.  A new ini item has
been added named RoamRssiDiff using which we can configure how better
in terms of Rssi, the new AP that we want to roam should be. On
providing a value of Zero, the feature is disabled and the check for
an AP with better RSSI does not happen while roaming. (CR 366355)

636834: Set rssi filter period to FT value
if CCX is disable and LFR is enabled, rssi filter period was set to 20
(default value) because of which RSSI monitoring was not effective,
changes added to set rssi filter period to FT rssi value (5) even for
LFR enabled case also. (CR 372303)

636843: isFastRoamingEnabled passed during reassoc (CR 372303)

636970: Implemented getwlandbg for SoftAP
SoftAP does not have an ioctl to print the log levels and log
info. Implemented getwlandbg for SoftAP.  (CR 374467)

636989 & 636992: Remove hard tabs and DOS line endings

637100: Fix of WDA Stop timeout kernel panic issue.
WDA stop timeout should never happen. Increasing WDA stop timeout
after considering 1 pending request and cleaning up WDI pending queues
once driver unload is trigerred.  (CR 367261)

637246: Fixed WLAN_BAPReset() to avoid sending Disassoc on STA interface.
Due to some reason(Seen just after driver load and whenever
hdd_netdev_notifier_call get called with netdevice state
NETDEV_GOING_DOWN where we call WLANBAP_DeregisterFromHCI())
WLAN_BAPReset was getting called through BSL_Write -> bslWriteFinish.
Even If the BT-AMP session is not opened(in this case
btampHandle->sessionId will be zero(default value) and if
WLAN_BAPReset is called, BAP was issueing sme_RoamDisconnect with
sessionId 0 which is station interface which results in Disassoc of
STA with AP.  Fixed the issue by checking BT-AMP session is opened or
not. (btampContext->isBapSessionOpen). If its opened then only call
sme_RoamDisconnect.

637340: SAP does not beacon on Country code to which STA is associated
(CR 368474)

637497: completed tx statistic reporting functionality
(CR 370923)

637687: Support for MC/BC & hostARPOffload with ini to work instead of ioctl
Fixes MC frames are still passed to host driver although
McastBcastFilter=1, hostArpOffload=0 (CR 363707)

637850: Fix for SAP Auto Channel Selection feature
For SAP auto channel selection, WLAN host driver do scan to find less
noise channel. While performaing scan do not check for Active session
in CSR module and change CSR roam state to eCSR_ROAMING_STATE_SCANNING
state for scan command irrespective of session is active or not.  (CR
375829)

638022: Fix for CCX-STA to connect to CCKM-RSN AP
because of the incorrect if-else-if authentication type overwritten to
255 (CR 376930)

638142-638147: Fix compilation warnings caused by GCC -Wenum-compare
Recent versions of the GCC compiler include an "enum-compare" warning
which will emit a warning when an enum of one type is compared with an
enum of a different type.  The compiler has found occurrences of this
issue in the WLAN code.  Fix those issues such that enum comparisons
are restricted to enums of the same enumerated type.

638253: Implemented getAutoChannel ioctl for SoftAP
SoftAP does not have an ioctl to get auto channel. Implemented
getAutoChannel for SoftAP and fixed getchannel ioctl for softap (CR
369147)

638267: Fix GCC 4.6 compile failure in WDI due to inlining failure
WDI_GET_PAL_CTX() was defined to be an inline function, but the
function body was not available to the compilation units that refer to
it.  Other versions of the compiler have silently ignored this, but
GCC-4.6 is emitting an error "sorry, unimplemented: inlining failed in
call to 'WDI_GET_PAL_CTX': function body not available".  So we remove
the unnecessary "inline" directive from the definition of
WDI_GET_PAL_CTX().

638291: Fix WLAN suspended flag
If WLAN driver suspend fails becuase of a TX, RX or MC thread suspend
timeout, the suspended flag is not reset. So set the suspended flag
only after all three threads are suspended successfully.  (CR 375230)

638703: Disabling AMP flag
Disabling AMP flag from config file, so that we don't register with
HCI any more as BT AMP is not PORed (CR 375826)
diff --git a/CORE/SME/src/csr/csrNeighborRoam.c b/CORE/SME/src/csr/csrNeighborRoam.c
index bc79a22..c1d710e 100644
--- a/CORE/SME/src/csr/csrNeighborRoam.c
+++ b/CORE/SME/src/csr/csrNeighborRoam.c
@@ -865,6 +865,37 @@
     return eHAL_STATUS_SUCCESS;
 }
 
+tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
+{
+        tCsrScanResultInfo *pScanResult;
+        tpCsrNeighborRoamControlInfo    pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
+        tANI_U32 CurrAPRssi = -125; /* We are setting this as default value to make sure we return this value,
+                                       when we do not see this AP in the scan result for some reason.However,it is 
+                                       less likely that we are associated to an AP and do not see it in the scan list*/
+
+        while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
+        {
+
+                if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
+                                                pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
+                {
+                        /* We got a match with the currently associated AP.
+                         * Capture the RSSI value and complete the while loop.
+                         * The while loop is completed in order to make the current entry go back to NULL,
+                         * and in the next while loop, it properly starts searching from the head of the list.
+                         * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
+
+                         CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
+
+                } else {
+                        continue;
+                }
+        }
+
+        return CurrAPRssi;
+
+}
+
 /* ---------------------------------------------------------------------------
 
     \fn csrNeighborRoamProcessScanResults
@@ -884,6 +915,16 @@
     tCsrScanResultInfo *pScanResult;
     tpCsrNeighborRoamControlInfo    pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
     tpCsrNeighborRoamBSSInfo    pBssInfo;
+    tANI_U32 CurrAPRssi;
+    tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
+
+    /***************************************************************
+     * Find out the Current AP RSSI and keep it handy to check if
+     * it is better than the RSSI of the AP which we are
+     * going to roam.If so, we are going to continue with the
+     * current AP.
+     ***************************************************************/
+    CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
 
     /* Expecting the scan result already to be in the sorted order based on the RSSI */
     /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
@@ -905,20 +946,37 @@
        if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId, 
                        pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
         {
-            //currently associated AP. Do not have this in the roamable AP list
+            /* currently associated AP. Do not have this in the roamable AP list */
             continue;
         }
 
-#if 0
-    if (abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold) < abs(pScanResult->BssDescriptor.rssi))
-    {
-            VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
-                 "%s: [INFOLOG]Current reassoc threshold %d new ap rssi worse=%d\n", __func__,
-                     (int)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
-                     (int)pScanResult->BssDescriptor.rssi * (-1) );
-        continue;
-    }        
-#endif //0
+       /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
+        * is disabled and we continue to roam without any check*/
+       if(RoamRssiDiff > 0)
+       {
+               if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
+               {
+                       /*Do not roam to an AP with worse RSSI than the current*/
+                       VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
+                                 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d\n", __func__,
+                                 CurrAPRssi,
+                                 (int)pScanResult->BssDescriptor.rssi * (-1) );
+                       continue;
+               } else {
+                       /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
+                        * margin that is provided by user from the ini file (RoamRssiDiff)*/
+                       if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
+                       {
+                          continue;
+                       }
+                       else {
+                                 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
+                                            "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d\n", __func__,
+                                            CurrAPRssi,
+                                            (int)pScanResult->BssDescriptor.rssi * (-1) );
+                       }
+               }
+       }
 
 #ifdef WLAN_FEATURE_VOWIFI_11R
         if (pNeighborRoamInfo->is11rAssoc)
@@ -1123,6 +1181,7 @@
     tCsrScanResultFilter    scanFilter;
     tScanResultHandle       scanResult;
     tANI_U32                tempVal = 0;
+    eHalStatus              hstatus;
 
     pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
     
@@ -1161,23 +1220,23 @@
            should use the BSSID filter made out of neighbor reports */
         if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
         {
-            status = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
-            NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("11R or CCX Association: Prepare scan filter status  with neighbor AP = %d"), status);
+            hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
+            NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("11R or CCX Association: Prepare scan filter status  with neighbor AP = %d"), hstatus);
             tempVal = 1;
         }
         else
 #endif
         {
-            status = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
-            NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("11R/CCX/Other Association: Prepare scan to find neighbor AP filter status  = %d"), status);
+            hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
+            NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("11R/CCX/Other Association: Prepare scan to find neighbor AP filter status  = %d"), hstatus);
         }
-        if (eHAL_STATUS_SUCCESS != status)
+        if (eHAL_STATUS_SUCCESS != hstatus)
         {
             smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
             return eHAL_STATUS_FAILURE;
         }
-        status = csrScanGetResult(pMac, &scanFilter, &scanResult);
-        NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), status);
+        hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
+        NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
         /* Process the scan results and update roamable AP list */
         csrNeighborRoamProcessScanResults(pMac, &scanResult);
 
@@ -1273,9 +1332,9 @@
                 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), status);
                 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
                 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
-                return VOS_STATUS_E_FAILURE;
+                return eHAL_STATUS_FAILURE;
             }
-            
+
             NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
             /* Register a reassoc Indication callback */
             vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
@@ -1295,17 +1354,17 @@
     {
 
         /* Restart the timer for the next scan sequence as scanning is not over */
-        status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer, 
+        hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer, 
                     pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT, 
                     eANI_BOOLEAN_FALSE);
     
-        if (eHAL_STATUS_SUCCESS != status)
+        if (eHAL_STATUS_SUCCESS != hstatus)
         {
             /* Timer start failed.. Should we ASSERT here??? */
             smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
             vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
             pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
-            return VOS_STATUS_E_FAILURE;
+            return eHAL_STATUS_FAILURE;
         }
     }
     return eHAL_STATUS_SUCCESS;
@@ -2300,6 +2359,8 @@
 {
     tpCsrNeighborRoamControlInfo    pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
     eHalStatus  status = eHAL_STATUS_SUCCESS;
+    VOS_STATUS  vstatus;
+
 #if  defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
     int  init_ft_flag = FALSE;
 #endif
@@ -2382,20 +2443,19 @@
 
                 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
                 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
-                status = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
+                vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
                                             WLANTL_HO_THRESHOLD_DOWN, 
                                             csrNeighborRoamNeighborLookupDOWNCallback, 
                                             VOS_MODULE_ID_SME, pMac);
             
-                if(!VOS_IS_STATUS_SUCCESS( status))
+                if(!VOS_IS_STATUS_SUCCESS(vstatus))
                 {
                    //err msg
-                   smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d\n"), status);
+                   smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d\n"), vstatus);
+                   status = eHAL_STATUS_FAILURE;
                 }
             }
 #endif
-
-            
             break;
         default:
             smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);