wlan: Validate bss session before issuing command to FW

Currently when vendor command
QCA_NL80211_VENDOR_SUBCMD_OFFLOADED_PACKETS is issued
bss session validation is not done. Host is issueing
ADD_PERIODIC_TX_PTRN_IND command aftrer delbss request is
sent to FW which is unexpected behaviour for FW.

Add a check to validat the bss session before
ADD_PERIODIC_TX_PTRN_IND command is issued.

Change-Id: If35ebbc5111edbb71cc5b00955b5c80710204c89
CRs-fixed: 2443270
diff --git a/CORE/WDI/CP/src/wlan_qct_wdi.c b/CORE/WDI/CP/src/wlan_qct_wdi.c
index 52583af..ac424e7 100644
--- a/CORE/WDI/CP/src/wlan_qct_wdi.c
+++ b/CORE/WDI/CP/src/wlan_qct_wdi.c
@@ -12805,6 +12805,8 @@
   WDI_Status                     wdiStatus;
   tHalAddPeriodicTxPtrn          *halAddPeriodicTxPtrn;
   wpt_uint8                      selfStaIdx          = 0;
+  wpt_uint8                    ucCurrentBSSSesIdx;
+  WDI_BSSSessionType*          pBSSSes             = NULL;
 
   /*-------------------------------------------------------------------------
      Sanity check
@@ -12848,6 +12850,22 @@
     return WDI_STATUS_E_FAILURE;
   }
 
+  ucCurrentBSSSesIdx = WDI_FindAssocSession( pWDICtx,
+                                pAddPeriodicTxPtrnParams->
+                                       wdiAddPeriodicTxPtrnParams.macAddr,
+                                &pBSSSes);
+  if ( NULL == pBSSSes )
+  {
+    WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
+              "%s: Association sequence for this BSS does not exist. macBSSID "
+              MAC_ADDRESS_STR,
+              __func__,
+             MAC_ADDR_ARRAY(pAddPeriodicTxPtrnParams->
+                            wdiAddPeriodicTxPtrnParams.macAddr));
+    wpalMemoryFree(pSendBuffer);
+    return WDI_STATUS_E_NOT_ALLOWED;
+  }
+
   halAddPeriodicTxPtrn->selfStaIdx = selfStaIdx;
   halAddPeriodicTxPtrn->ucPtrnId =
     pAddPeriodicTxPtrnParams->wdiAddPeriodicTxPtrnParams.ucPtrnId;