qcacld-3.0: Reset auth_failure_timeout in pe_delete_session

auth_failure_timeout is updated as part of
lim_check_and_announce_join_success for p2p client with NOA.
And the default value is stored in pe_session->defaultAuthFailureTimeout
After receiving the auth resp or in case of auth failure the
auth_failure_timeout is reset to default value. But there is any other
failure and pe session is deleted then the auth_failure_timeout is
not reset. And p2p cli connection will use the wrong auth timeout.
And can result in connection delay's if GO doesn't send the auth response.

Reset the auth_failure_timeout to defalut as part of pe_delete_session.
And decrease the max value to 5000ms.

Change-Id: I374bf45279f086127ef062b83a06049c895c4675
CRs-Fixed: 2343832
diff --git a/components/mlme/dispatcher/inc/cfg_mlme_timeout.h b/components/mlme/dispatcher/inc/cfg_mlme_timeout.h
index 9379a0c..7caed90 100644
--- a/components/mlme/dispatcher/inc/cfg_mlme_timeout.h
+++ b/components/mlme/dispatcher/inc/cfg_mlme_timeout.h
@@ -59,8 +59,8 @@
  */
 #define CFG_AUTH_FAILURE_TIMEOUT CFG_INI_UINT( \
 		"auth_failure_timeout", \
-		0, \
-		65535, \
+		500, \
+		5000, \
 		1000, \
 		CFG_VALUE_OR_DEFAULT, \
 		"auth failure timeout")
diff --git a/core/mac/src/pe/lim/lim_process_mlm_req_messages.c b/core/mac/src/pe/lim/lim_process_mlm_req_messages.c
index 613ef3a..0f64acb 100644
--- a/core/mac/src/pe/lim/lim_process_mlm_req_messages.c
+++ b/core/mac/src/pe/lim/lim_process_mlm_req_messages.c
@@ -1223,6 +1223,7 @@
 	/* Activate Auth failure timer */
 	MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
 			 session->peSessionId, eLIM_AUTH_FAIL_TIMER));
+	 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_FAIL_TIMER);
 	if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAuthFailureTimer)
 	    != TX_SUCCESS) {
 		pe_err("could not start Auth failure timer");
diff --git a/core/mac/src/pe/lim/lim_session.c b/core/mac/src/pe/lim/lim_session.c
index f508d70..c25e7bc 100644
--- a/core/mac/src/pe/lim/lim_session.c
+++ b/core/mac/src/pe/lim/lim_session.c
@@ -37,6 +37,7 @@
 
 #include "sch_api.h"
 #include "lim_send_messages.h"
+#include "cfg_ucfg_api.h"
 
 #ifdef WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY
 static struct sDphHashNode *g_dph_node_array;
@@ -881,6 +882,18 @@
 
 	lim_reset_bcn_probe_filter(mac_ctx, session);
 
+	/* Restore default failure timeout */
+	if (session->defaultAuthFailureTimeout) {
+		pe_debug("Restore default failure timeout");
+		if (cfg_in_range(CFG_AUTH_FAILURE_TIMEOUT,
+				 session->defaultAuthFailureTimeout))
+			mac_ctx->mlme_cfg->timeouts.auth_failure_timeout =
+				session->defaultAuthFailureTimeout;
+		else
+			mac_ctx->mlme_cfg->timeouts.auth_failure_timeout =
+				cfg_default(CFG_AUTH_FAILURE_TIMEOUT);
+	}
+
 	for (n = 0; n < (mac_ctx->lim.maxStation + 1); n++) {
 		timer_ptr = &mac_ctx->lim.limTimers.gpLimCnfWaitTimer[n];
 		if (session->peSessionId == timer_ptr->sessionId)