wlan: Prevent purging of sme pending commands

As a part of wlan exit, HDD sent below commands
to sme.
1) Full Power Request
2) Disconnect Req (DelBSS /Del Sta)
3) Close Session ( DelSelfSta ).
But when MC thread get block, all these commands added into
SME pending queue. When csr perform Close session, CSR purge
all the pending commands. Hence DelSelfSTA goes without DelBss
/Del Sta which is not expected sequence by firmware.

In this fix purging of command will be perform bit ahead,
so all essential command go to firmware before sending
DelSelfSta.

Change-Id: Icfbe20bf62ac98cde361dffbd7e466e6ac8ed101
CRs-Fixed: 850747
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index 6afb563..2049dd7 100755
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -6363,7 +6363,7 @@
    {
       INIT_COMPLETION(pAdapter->session_close_comp_var);
       if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal,
-                                    pAdapter->sessionId,
+                                    pAdapter->sessionId, VOS_TRUE,
                                     hdd_smeCloseSessionCallback, pAdapter))
       {
          unsigned long rc;
@@ -7282,7 +7282,7 @@
          {
             INIT_COMPLETION(pAdapter->session_close_comp_var);
             if (eHAL_STATUS_SUCCESS ==
-                  sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId,
+                  sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, VOS_FALSE,
                      hdd_smeCloseSessionCallback, pAdapter))
             {
                unsigned long ret;
@@ -8131,6 +8131,27 @@
         vos_mem_free(scanReq.ChannelInfo.ChannelList);
 }
 
+void hdd_purge_cmd_list_all_adapters( hdd_context_t *pHddCtx )
+{
+   hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
+   VOS_STATUS status;
+   hdd_adapter_t      *pAdapter;
+
+   ENTER();
+
+   status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
+
+   while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
+   {
+      pAdapter = pAdapterNode->pAdapter;
+
+      status = sme_PurgeCmdList(pHddCtx->hHal, pAdapter->sessionId);
+      status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
+      pAdapterNode = pNext;
+   }
+
+   EXIT();
+}
 /**---------------------------------------------------------------------------
 
   \brief hdd_full_power_callback() - HDD full power callback function
@@ -8371,6 +8392,10 @@
          vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
          pAdapterNode = pNext;
       }
+
+       //Purge all sme cmd's for all interface
+       hdd_purge_cmd_list_all_adapters(pHddCtx);
+
       // Cancel any outstanding scan requests.  We are about to close all
       // of our adapters, but an adapter structure is what SME passes back
       // to our callback function. Hence if there are any outstanding scan