wlan: Change WDI_FillTxBd to use peer staIdx (StaIdx of Bss Mac address)

If staIdx for destination mac address is not found. Drop the frame if
Bss entry is not found.
Frames from one session seen on other session's channel.
Frames seen on sniffer for few seconds even after disassoc/deauth.

Change-Id: Ia137b1ba5330ee723e990afc4393b41b5c55bc0a
CR-Fixed: 399609
diff --git a/CORE/WDA/src/wlan_qct_wda_ds.c b/CORE/WDA/src/wlan_qct_wda_ds.c
index 1198f1d..034ed2d 100644
--- a/CORE/WDA/src/wlan_qct_wda_ds.c
+++ b/CORE/WDA/src/wlan_qct_wda_ds.c
@@ -1357,7 +1357,7 @@
     {
       VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
                    "WDA : Pushing a packet to WDI failed.");
-      VOS_ASSERT( 0 );
+      VOS_ASSERT( wdiStatus != WDI_STATUS_E_NOT_ALLOWED );
       //We need to free the packet here
       vos_pkt_get_user_data_ptr(pTxPacket, VOS_PKT_USER_DATA_ID_TL, (void **)&pfnTxComp);
       if(pfnTxComp)
@@ -1412,11 +1412,7 @@
     {
       VOS_TRACE( VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
                    "WDA : Pushing a packet to WDI failed.");
-      /* TODO Wd should return this packet to VOSS. Otherwise
-         UMAC is going in low resource condition.
-         Who needs to do it? DXE, WDI?
-         */
-      VOS_ASSERT( 0 );
+      VOS_ASSERT( wdiStatus != WDI_STATUS_E_NOT_ALLOWED );
       //We need to free the packet here
       vos_pkt_get_user_data_ptr(pTxPacket, VOS_PKT_USER_DATA_ID_TL, (void **)&pfnTxComp);
       if(pfnTxComp)
diff --git a/CORE/WDI/CP/src/wlan_qct_wdi.c b/CORE/WDI/CP/src/wlan_qct_wdi.c
index 006f58f..bbfd376 100644
--- a/CORE/WDI/CP/src/wlan_qct_wdi.c
+++ b/CORE/WDI/CP/src/wlan_qct_wdi.c
@@ -14672,6 +14672,8 @@
     pSTATable[wdiDelSTARsp.ucSTAIdx].bcastDpuSignature = WDI_DPU_SELF_STA_DEFAULT_SIG;
     pSTATable[wdiDelSTARsp.ucSTAIdx].bcastMgmtDpuSignature = WDI_DPU_SELF_STA_DEFAULT_SIG;
     pSTATable[wdiDelSTARsp.ucSTAIdx].dpuSig = WDI_DPU_SELF_STA_DEFAULT_SIG;
+
+    pSTATable[wdiDelSTARsp.ucSTAIdx].bssIdx = WDI_BSS_INVALID_IDX;
   }
   else
   {
diff --git a/CORE/WDI/CP/src/wlan_qct_wdi_dp.c b/CORE/WDI/CP/src/wlan_qct_wdi_dp.c
index 596e1f7..387f26e 100644
--- a/CORE/WDI/CP/src/wlan_qct_wdi_dp.c
+++ b/CORE/WDI/CP/src/wlan_qct_wdi_dp.c
@@ -691,22 +691,58 @@
            if( ucUnicastDst ) 
            {
              wdiStatus = WDI_STATableFindStaidByAddr( pWDICtx, 
-                                        *(wpt_macAddr*)pDestMacAddr, &ucStaId );
-               // Only case this look would fail would be in STA mode, in AP & IBSS mode
-               // this look should pass. In STA mode the unicast data frame could be
-               // transmitted to a DestAddr for which there might not be an entry in
-               // HAL STA table and the lookup would fail. In such cases use the Addr2
-               // (self MAC address) to get the selfStaIdx.
+                 *(wpt_macAddr*)pDestMacAddr, &ucStaId ); 
+             // Only case this look would fail would be in STA mode, in AP & IBSS mode 
+             // this look should pass. In STA mode the unicast data frame could be 
+             // transmitted to a DestAddr for which there might not be an entry in 
+             // HAL STA table and the lookup would fail. In such cases use the Addr2 
+             // (self MAC address) to get the selfStaIdx.
+             // From SelfStaIdx, get BSSIdx and use BSS MacAddr to get the staIdx 
+             // corresponding to peerSta(AP)
 
 
               if (WDI_STATUS_SUCCESS != wdiStatus) 
               {
-                // Get the station index for ADDR2, which should be the self MAC addr
-                wdiStatus = WDI_STATableFindStaidByAddr( pWDICtx,
-                                       *(wpt_macAddr*)pAddr2, &ucStaId );
-                if (WDI_STATUS_SUCCESS != wdiStatus)
+                if( !ucDisableFrmXtl )
                 {
-                  return WDI_STATUS_E_FAILURE;
+                  // FrameTranslation in HW is enanled. This means, pDestMacaddress may
+                  // be unknown.
+                  // Get the station index for ADDR2, which should be the self MAC addr
+                  wdiStatus = WDI_STATableFindStaidByAddr( pWDICtx, 
+                      *(wpt_macAddr*)pAddr2, &ucStaId ); 
+                  if (WDI_STATUS_SUCCESS == wdiStatus)
+                  {
+                    //Found self Sta index.
+                    WDI_StaStruct* pSTATable = (WDI_StaStruct*) pWDICtx->staTable;
+                    wpt_uint8                 bssSesIdx  = 0;
+                    WDI_BSSSessionType*       pBSSSes             = NULL;
+
+                    //Initialize WDI status to error.
+                    wdiStatus = WDI_STATUS_E_NOT_ALLOWED;
+
+                    //Check if its BSSIdx is valid.
+                    if (pSTATable[ucStaId].bssIdx != WDI_BSS_INVALID_IDX) 
+                    {
+                      //Use BSSIdx to get the association sequence and use macBssId
+                      //to get the peerMac Address(MacBSSID).
+                      bssSesIdx = WDI_FindAssocSessionByBSSIdx( pWDICtx,
+                          pSTATable[ucStaId].bssIdx,
+                          &pBSSSes);
+
+                      if ( NULL != pBSSSes )
+                      {
+                        //Get staId from the peerMac. 
+                        wdiStatus = WDI_STATableFindStaidByAddr( pWDICtx, 
+                            pBSSSes->macBSSID, &ucStaId ); 
+                      }
+                    }
+                  }
+                }
+                //wdiStatus will be success if it found valid peerStaIdx
+                //Otherwise return failure.
+                if(WDI_STATUS_SUCCESS != wdiStatus )
+                {
+                  return WDI_STATUS_E_NOT_ALLOWED;
                 }
               }
             }