wlan: Cache frames only for STA whose assoc/reassoc req is send.

This fix will introduce a variable enableCaching for each
STA ID which will be used to enable/disable cache for that
particular STA. Caching will be enabled when assoc/reassoc
req is being sent while it is disabled after flushing of
frames for that STA.
This fix is done to avaoid low resource condition when
packets are cached at TL.
Also removing variable ucRxBlocked as it is no more
required.

Change-Id: Ic8604f70b835cb5dedcd64662bd6a28f0af6bbfa
CRs-Fixed: 685340
diff --git a/CORE/MAC/src/pe/lim/limSendManagementFrames.c b/CORE/MAC/src/pe/lim/limSendManagementFrames.c
index 23d1a8d..b63cbe2 100644
--- a/CORE/MAC/src/pe/lim/limSendManagementFrames.c
+++ b/CORE/MAC/src/pe/lim/limSendManagementFrames.c
@@ -2555,6 +2555,10 @@
     MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
            psessionEntry->peSessionId,
            pMacHdr->fc.subType));
+
+    // enable caching
+    WLANTL_EnableCaching(psessionEntry->staId);
+
     halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
             HAL_TXRX_FRM_802_11_MGMT,
             ANI_TXDIR_TODS,
@@ -3365,6 +3369,10 @@
     MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
            psessionEntry->peSessionId,
            pMacHdr->fc.subType));
+
+    // enable caching
+    WLANTL_EnableCaching(psessionEntry->staId);
+
     halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
                             HAL_TXRX_FRM_802_11_MGMT,
                             ANI_TXDIR_TODS,
diff --git a/CORE/TL/inc/wlan_qct_tl.h b/CORE/TL/inc/wlan_qct_tl.h
index 1e30336..30472b2 100644
--- a/CORE/TL/inc/wlan_qct_tl.h
+++ b/CORE/TL/inc/wlan_qct_tl.h
@@ -2546,6 +2546,31 @@
  }
 #endif 
 
+/*===========================================================================
+
+  FUNCTION    WLANTL_EnableCaching
+
+  DESCRIPTION
+
+    This function is used to enable caching only when assoc/reassoc req is send.
+    that is cache packets only for such STA ID.
+
+
+  DEPENDENCIES
+
+    TL must have been initialized before this gets called.
+
+
+  PARAMETERS
+
+   staId:   station id.
+
+  RETURN VALUE
+
+   none
+
+============================================================================*/
+void WLANTL_EnableCaching(v_U8_t staId);
 
  /*===========================================================================
 
diff --git a/CORE/TL/src/wlan_qct_tl.c b/CORE/TL/src/wlan_qct_tl.c
index 3ce775d..4638b44 100644
--- a/CORE/TL/src/wlan_qct_tl.c
+++ b/CORE/TL/src/wlan_qct_tl.c
@@ -986,6 +986,44 @@
 
 /*===========================================================================
 
+  FUNCTION    WLANTL_EnableCaching
+
+  DESCRIPTION
+
+    This function is used to enable caching only when assoc/reassoc req is send.
+    that is cache packets only for such STA ID.
+
+
+  DEPENDENCIES
+
+    TL must have been initialized before this gets called.
+
+
+  PARAMETERS
+
+   staId:   station id
+
+  RETURN VALUE
+
+   none
+
+============================================================================*/
+void WLANTL_EnableCaching(v_U8_t staId)
+{
+  v_PVOID_t pvosGCtx= vos_get_global_context(VOS_MODULE_ID_TL,NULL);
+  WLANTL_CbType* pTLCb = VOS_GET_TL_CB(pvosGCtx);
+  if ( NULL == pTLCb )
+  {
+    TLLOGE(VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
+           "WLAN TL:Invalid TL pointer from pvosGCtx on "
+           "WLANTL_EnableCaching"));
+    return;
+  }
+  pTLCb->atlSTAClients[staId]->enableCaching = 1;
+}
+
+/*===========================================================================
+
   FUNCTION    WLANTL_AssocFailed
 
   DESCRIPTION
@@ -1373,7 +1411,6 @@
     Start with the state suggested by client caller
     -----------------------------------------------------------------------*/
   pClientSTA->tlState = pwSTADescType->ucInitState;
-  pClientSTA->ucRxBlocked = 1;
   /*-----------------------------------------------------------------------
     After all the init is complete we can mark the existance flag 
     ----------------------------------------------------------------------*/
@@ -4959,7 +4996,7 @@
     /*-----------------------------------------------------------------------
     After all the init is complete we can mark the existance flag 
     ----------------------------------------------------------------------*/
-  pClientSTA->ucRxBlocked = 0;
+  pClientSTA->enableCaching = 0;
 
   //WLAN_TL_UNLOCK_STA_CACHE(pTLCb->atlSTAClients[ucSTAId]); 
   return VOS_STATUS_SUCCESS; 
@@ -5791,15 +5828,11 @@
       }
 #endif
 
-      if ((( 0 == pClientSTA->ucExists ) ||
-           (0 != pClientSTA->ucRxBlocked) ||
-           ( WLANTL_STA_DISCONNECTED == pClientSTA->tlState)) &&
+      if (( pClientSTA->enableCaching == 1 ) &&
             /*Dont buffer Broadcast/Multicast frames. If AP transmits bursts of Broadcast/Multicast data frames, 
              * libra buffers all Broadcast/Multicast packets after authentication with AP, 
              * So it will lead to low resource condition in Rx Data Path.*/
-          (WDA_IS_RX_BCAST(pvBDHeader) == 0) &&
-           /* Dont cache frames for SOFTAP */
-          (WLAN_STA_SOFTAP != pClientSTA->wSTADesc.wSTAType))
+          ( WDA_IS_RX_BCAST(pvBDHeader) == 0 ))
       {
         if( WDA_IsSelfSTA(pvosGCtx,ucSTAId))
         {
@@ -6661,7 +6694,7 @@
               "ucEAPOLPktPending: %d\tucNoMoreData: %d",
               pClientSTA->ucEapolPktPending, pClientSTA->ucNoMoreData));
         TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
-               "ucRxBlocked: %d\t fcStaTxDisabled: %d", pClientSTA->ucRxBlocked,
+               "enableCaching: %d\t fcStaTxDisabled: %d", pClientSTA->enableCaching,
                pClientSTA->fcStaTxDisabled));
         TLLOGE(VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
                "ucCurrentAC: %d\tucServicedAC: %d", pClientSTA->ucCurrentAC,
diff --git a/CORE/TL/src/wlan_qct_tli.h b/CORE/TL/src/wlan_qct_tli.h
index 29a7710..f47e7a5 100644
--- a/CORE/TL/src/wlan_qct_tli.h
+++ b/CORE/TL/src/wlan_qct_tli.h
@@ -497,13 +497,6 @@
      ID allowed */
   v_U8_t                        ucExists;
 
-  /*The flag controls the Rx path for the station - as long as there are
-    packets at sta level that need to be fwd-ed the Rx path will be blocked,
-    it will become unblocked only when the cached frames were fwd-ed;
-    while the rx path is blocked all rx-ed frames for that STA will be cached
-    */
-  v_U8_t                        ucRxBlocked;
-
   /* Function pointer to the receive packet handler from HDD */
   WLANTL_STARxCBType            pfnSTARx;
 
@@ -612,6 +605,8 @@
   WLANTL_CacheInfoType       tlCacheInfo;
   /* LWM related fields */
 
+  v_BOOL_t  enableCaching;
+
   //current station is slow. LWM mode is enabled.
   v_BOOL_t ucLwmModeEnabled;
   //LWM events is reported when LWM mode is on. Able to send more traffic