SAP: Limit the number of Disassoc/Deauth frames processing

Currently, if STA keeps on sending the deauth/disassoc then
DUT(which is SAP) processes the deauth/disassoc frame and keep
posting the Deauth indication to CSR queue.Since the deauth
keeps on coming from STA, PE message queue will always have this
DEAUTH frames to process and CSR is not able to get chance
to process the DEAUTH indication.
This eventually results into crash.

Changes are done to drop the deauth/Disassoc Frame if it is
already in the processing state.

Change-Id: Iadc62801bad716c83c82868218f0b4cf180198ed
CRs-Fixed: 824092
diff --git a/CORE/MAC/src/dph/dphHashTable.c b/CORE/MAC/src/dph/dphHashTable.c
index b72b6e8..80fb505 100644
--- a/CORE/MAC/src/dph/dphHashTable.c
+++ b/CORE/MAC/src/dph/dphHashTable.c
@@ -285,6 +285,7 @@
     pStaDs->apsdMaxSpLen = 0;
     pStaDs->acMode[0] = pStaDs->acMode[1] = pStaDs->acMode[2] = pStaDs->acMode[3] =  0;
 #endif /* WMM_APSD */
+    pStaDs->isDisassocDeauthInProgress = 0;
     pStaDs->valid = 1;
     return pStaDs;
 }
@@ -429,6 +430,7 @@
       else
          prev->next = ptr->next;
       ptr->added = 0;
+      ptr->isDisassocDeauthInProgress = 0;
       ptr->next = 0;
     }
   else
diff --git a/CORE/MAC/src/include/dphGlobal.h b/CORE/MAC/src/include/dphGlobal.h
index 2c9c959..a06cd8d 100644
--- a/CORE/MAC/src/include/dphGlobal.h
+++ b/CORE/MAC/src/include/dphGlobal.h
@@ -634,7 +634,7 @@
      * end of the structure.
 
      */
-
+    tANI_U8 isDisassocDeauthInProgress;
     struct sDphHashNode  *next;
 
 
diff --git a/CORE/MAC/src/pe/lim/limProcessDeauthFrame.c b/CORE/MAC/src/pe/lim/limProcessDeauthFrame.c
index 03b04dd..7edde94 100644
--- a/CORE/MAC/src/pe/lim/limProcessDeauthFrame.c
+++ b/CORE/MAC/src/pe/lim/limProcessDeauthFrame.c
@@ -455,7 +455,8 @@
     }
 
     if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
-        (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
+        (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE) ||
+        (pStaDs->isDisassocDeauthInProgress))
     {
         /**
          * Already in the process of deleting context for the peer
@@ -463,10 +464,12 @@
          */
         PELOGE(limLog(pMac, LOGE,
            FL("received Deauth frame from peer that is in state %d, addr "
-           MAC_ADDRESS_STR),
-           pStaDs->mlmStaContext.mlmState,MAC_ADDR_ARRAY(pHdr->sa));)
+           MAC_ADDRESS_STR", isDisassocDeauthInProgress : %d\n"),
+           pStaDs->mlmStaContext.mlmState,MAC_ADDR_ARRAY(pHdr->sa),
+           pStaDs->isDisassocDeauthInProgress);)
         return;
     } 
+    pStaDs->isDisassocDeauthInProgress++;
     pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes)reasonCode;
     pStaDs->mlmStaContext.cleanupTrigger = eLIM_PEER_ENTITY_DEAUTH;
 
diff --git a/CORE/MAC/src/pe/lim/limProcessDisassocFrame.c b/CORE/MAC/src/pe/lim/limProcessDisassocFrame.c
index 861b9e4..e6a934c 100644
--- a/CORE/MAC/src/pe/lim/limProcessDisassocFrame.c
+++ b/CORE/MAC/src/pe/lim/limProcessDisassocFrame.c
@@ -269,15 +269,18 @@
     }
 
     if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
-        (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
+        (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE) ||
+        (pStaDs->isDisassocDeauthInProgress))
     {
         /**
          * Already in the process of deleting context for the peer
          * and received Disassociation frame. Log and Ignore.
          */
         PELOGE(limLog(pMac, LOGE,
-               FL("received Disassoc frame in state %d from "MAC_ADDRESS_STR),
-               pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa));)
+               FL("received Disassoc frame in state %d from "MAC_ADDRESS_STR
+               ",isDisassocDeauthInProgress : %d\n"),
+               pStaDs->mlmStaContext.mlmState, MAC_ADDR_ARRAY(pHdr->sa),
+               pStaDs->isDisassocDeauthInProgress);)
 
         return;
     } 
@@ -298,6 +301,8 @@
 
     } // if (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE)
 
+    pStaDs->isDisassocDeauthInProgress++;
+
     pStaDs->mlmStaContext.cleanupTrigger = eLIM_PEER_ENTITY_DISASSOC;
     pStaDs->mlmStaContext.disassocReason = (tSirMacReasonCodes) reasonCode;