wlan: flush cached frames on deleting the station context

TL caches the frames for all STAs which are not yet registered.
It has been seen that the firmware allows frames for a STA to
reach the Host even when 802.11 authentication is not completed
in some cases. If the authentication times out, all the frames
which are cached remain in the TL cache consuming lot of resources.
Whenever authentication fails the host driver will delete the STA
context from the firmware, and after getting a successful response
from the firmware we will try to flush all cached frames and free
up the resources.

Change-Id: I1b4678c33cc99a6138a77d0574d01c4c7e51b4b3
CRs-Fixed: 673062
diff --git a/CORE/TL/inc/wlan_qct_tl.h b/CORE/TL/inc/wlan_qct_tl.h
index 570cf77..1e30336 100644
--- a/CORE/TL/inc/wlan_qct_tl.h
+++ b/CORE/TL/inc/wlan_qct_tl.h
@@ -913,6 +913,53 @@
   v_PVOID_t  pvosGCtx 
 );
 
+/*===========================================================================
+
+  FUNCTION    WLANTL_StartForwarding
+
+  DESCRIPTION
+
+    This function is used to ask serialization through TX thread of the
+    cached frame forwarding (if statation has been registered in the mean while)
+    or flushing (if station has not been registered by the time)
+
+    In case of forwarding, upper layer is only required to call WLANTL_RegisterSTAClient()
+    and doesn't need to call this function explicitly. TL will handle this inside
+    WLANTL_RegisterSTAClient().
+
+    In case of flushing, upper layer is required to call this function explicitly
+
+  DEPENDENCIES
+
+    TL must have been initialized before this gets called.
+
+
+  PARAMETERS
+
+   ucSTAId:   station id
+
+  RETURN VALUE
+
+    The result code associated with performing the operation
+    Please check return values of vos_tx_mq_serialize.
+
+  SIDE EFFECTS
+    If TL was asked to perform WLANTL_CacheSTAFrame() in WLANTL_RxFrames(),
+    either WLANTL_RegisterSTAClient() or this function must be called
+    within reasonable time. Otherwise, TL will keep cached vos buffer until
+    one of this function is called, and may end up with system buffer exhasution.
+
+    It's an upper layer's responsibility to call this function in case of
+    flushing
+
+============================================================================*/
+VOS_STATUS
+WLANTL_StartForwarding
+(
+  v_U8_t ucSTAId,
+  v_U8_t ucUcastSig,
+  v_U8_t ucBcastSig
+);
 
 /*----------------------------------------------------------------------------
     INTERACTION WITH HDD
diff --git a/CORE/WDA/src/wlan_qct_wda.c b/CORE/WDA/src/wlan_qct_wda.c
index 5189550..133a654 100644
--- a/CORE/WDA/src/wlan_qct_wda.c
+++ b/CORE/WDA/src/wlan_qct_wda.c
@@ -3770,6 +3770,9 @@
                  "%s: Clear STA index form table Fail", __func__);
      VOS_ASSERT(0) ;
    }
+
+   WLANTL_StartForwarding(staIdx,0,0);
+
    vos_mem_free(pWdaParams->wdaWdiApiMsgParam);
    vos_mem_free(pWdaParams) ;
    /* reset the the system role*/
@@ -3875,6 +3878,7 @@
          VOS_ASSERT(0) ;
       }
       delStaReqParam->staIdx = wdiDelStaRsp->ucSTAIdx ;
+      WLANTL_StartForwarding(delStaReqParam->staIdx,0,0);
    }
    vos_mem_free(pWdaParams->wdaWdiApiMsgParam);
    vos_mem_free(pWdaParams) ;