wlan: Delete any associated STAs on AP/P2P GO teardown.

Delete any associated STAs entry and send deauth to each
associated STA on removing or tearing down AP/P2P GO.

Change-Id: I217c66b52ce186836fddba3e7cda4c1c0f7e9c9d
CRs-Fixed: 710966
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index f807119..807690c 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -9692,6 +9692,52 @@
 
 /**---------------------------------------------------------------------------
 
+  \brief hdd_del_all_sta() - function
+
+  This function removes all the stations associated on stopping AP/P2P GO.
+
+  \param  - pAdapter - Pointer to the HDD
+
+  \return - None
+
+  --------------------------------------------------------------------------*/
+
+int hdd_del_all_sta(hdd_adapter_t *pAdapter)
+{
+    v_U16_t i;
+    VOS_STATUS vos_status;
+
+    ENTER();
+
+    hddLog(VOS_TRACE_LEVEL_INFO,
+           "%s: Delete all STAs associated.",__func__);
+    if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
+     || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
+       )
+    {
+        for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
+        {
+            if ((pAdapter->aStaInfo[i].isUsed) &&
+                (!pAdapter->aStaInfo[i].isDeauthInProgress))
+            {
+                u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
+                hddLog(VOS_TRACE_LEVEL_ERROR,
+                       "%s: Delete STA with staid = %d and MAC::"
+                        MAC_ADDRESS_STR,
+                        __func__, i, MAC_ADDR_ARRAY(macAddr));
+                vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
+                if (VOS_IS_STATUS_SUCCESS(vos_status))
+                    pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
+            }
+        }
+    }
+
+    EXIT();
+    return 0;
+}
+
+/**---------------------------------------------------------------------------
+
   \brief hdd_softap_sta_disassoc() - function
 
   This to take counter measure to handle deauth req from HDD