wlan: RSSI based TDLS tear down.

If the RSSI value goes beyond the threshold value configured
in the ini then tear down the TDLS link.
CRs-Fixed: 458592

Change-Id: I134b2e5f0a81d7c08f3d69981fd9a970e8272a55
diff --git a/CORE/TL/src/wlan_qct_tl.c b/CORE/TL/src/wlan_qct_tl.c
index accdeea..aa6aba8 100644
--- a/CORE/TL/src/wlan_qct_tl.c
+++ b/CORE/TL/src/wlan_qct_tl.c
@@ -1337,6 +1337,19 @@
      data to calculate RSSI. So to avoid reporting zero, we are initializing
      RSSI with RSSI saved in BssDescription during scanning. */
   pClientSTA->rssiAvg = rssi;
+#ifdef FEATURE_WLAN_TDLS
+  if(WLAN_STA_TDLS == pClientSTA->wSTADesc.wSTAType)
+  {
+    /* If client is TDLS, use TDLS specific alpha */
+    pClientSTA->rssiAlpha = WLANTL_HO_TDLS_ALPHA;
+  }
+  else
+  {
+    pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
+  }
+#else
+    pClientSTA->rssiAlpha = WLANTL_HO_DEFAULT_ALPHA;
+#endif /* FEATURE_WLAN_TDLS */
 
   /*Tx not suspended and station fully registered*/
   vos_atomic_set_U8(
@@ -7742,6 +7755,7 @@
     else
     {
       wRxMetaInfo.ucUP = ucTid;
+      wRxMetaInfo.rssiAvg = pClientSTA->rssiAvg;
       pClientSTA->pfnSTARx( pvosGCtx, vosDataBuff, ucSTAId,
                                             &wRxMetaInfo );
     }
diff --git a/CORE/TL/src/wlan_qct_tl_hosupport.c b/CORE/TL/src/wlan_qct_tl_hosupport.c
index 64b584e..d6be98a 100644
--- a/CORE/TL/src/wlan_qct_tl_hosupport.c
+++ b/CORE/TL/src/wlan_qct_tl_hosupport.c
@@ -90,7 +90,6 @@
 //#define WLANTL_HO_UTEST
 
 #define WLANTL_HO_DEFAULT_RSSI      0xFF
-#define WLANTL_HO_DEFAULT_ALPHA     5
 #define WLANTL_HO_INVALID_RSSI      -100
 /* RSSI sampling period, usec based
  * To reduce performance overhead
@@ -876,28 +875,21 @@
    TLHS_UtestHandleNewRSSI(&currentRSSI, pAdapter);
 #endif /* WLANTL_HO_UTEST */
 
-/* Commenting this part of the code as this may not be necessarity true in all cases */
-#if 0
-   if(WLANTL_HO_INVALID_RSSI == currentRSSI)
-   {
-      return status;
-   }
-#endif
-
-   if(0 == currentHO->historyRSSI)
+   if(0 == tlCtxt->atlSTAClients[STAid]->rssiAvg)
    {
       *currentAvgRSSI = currentRSSI;
    }
    else
    {
-      *currentAvgRSSI = ((currentHO->historyRSSI * currentHO->alpha) +
-                         (currentRSSI * (10 - currentHO->alpha))) / 10;
+      *currentAvgRSSI = ((tlCtxt->atlSTAClients[STAid]->rssiAvg  *
+                          tlCtxt->atlSTAClients[STAid]->rssiAlpha) +
+                         (currentRSSI * (10 - tlCtxt->atlSTAClients[STAid]->rssiAlpha))) / 10;
    }
+
 #ifdef RSSI_HACK
    *currentAvgRSSI = (v_S7_t)dumpCmdRSSI;
 #endif
 
-
    tlCtxt->atlSTAClients[STAid]->rssiAvg = *currentAvgRSSI;
 
    TLLOG1(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO,"Current new RSSI is %d, averaged RSSI is %d", currentRSSI, *currentAvgRSSI));
diff --git a/CORE/TL/src/wlan_qct_tli.h b/CORE/TL/src/wlan_qct_tli.h
index 167fc2e..a8fa010 100644
--- a/CORE/TL/src/wlan_qct_tli.h
+++ b/CORE/TL/src/wlan_qct_tli.h
@@ -508,6 +508,9 @@
   /* Value of the averaged RSSI for this station in BMPS */
   v_S7_t                        rssiAvgBmps;
 
+  /* Value of the Alpha to calculate RSSI average */
+  v_S7_t                        rssiAlpha;
+
   /* Value of the averaged RSSI for this station */
   v_U32_t                       uLinkQualityAvg;