qcacld-3.0: Send mode change event after addkey

On STA connection, mode change event is sent to
userspace after association is complete. This causes
delay in processing of M1 frame at supplicant due to
latency associated with nl80211_get_wiphy_index
function as part of processing mode change vendor event.

Fix is to send mode change event for STA after key
is added.

Change-Id: Id403bfdd26ed3a47449ba3f2967f4b4322ad5da6
CRs-Fixed: 2257117
diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h
index 825a372..844b242 100644
--- a/core/hdd/inc/wlan_hdd_main.h
+++ b/core/hdd/inc/wlan_hdd_main.h
@@ -1412,6 +1412,7 @@
 
 	/* rcpi information */
 	struct rcpi_info rcpi;
+	bool send_mode_change;
 };
 
 #define WLAN_HDD_GET_STATION_CTX_PTR(adapter) (&(adapter)->session.station)
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c
index 3c16ab0..315c786 100644
--- a/core/hdd/src/wlan_hdd_assoc.c
+++ b/core/hdd/src/wlan_hdd_assoc.c
@@ -1849,6 +1849,7 @@
 	    (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
 		sme_ps_disable_auto_ps_timer(mac_handle,
 					     adapter->session_id);
+		adapter->send_mode_change = true;
 	}
 	wlan_hdd_clear_link_layer_stats(adapter);
 
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index 178e7c8..01956d2 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -16487,6 +16487,11 @@
 			return -EINVAL;
 		}
 
+		if (adapter->send_mode_change) {
+			wlan_hdd_send_mode_change_event();
+			adapter->send_mode_change = false;
+		}
+
 		/* in case of IBSS as there was no information
 		 * available about WEP keys during IBSS join, group
 		 * key initialized with NULL key, so re-initialize
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 7ef4615..a52bced 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -3673,6 +3673,7 @@
 		adapter->offloads_configured = false;
 		adapter->is_link_up_service_needed = false;
 		adapter->disconnection_in_progress = false;
+		adapter->send_mode_change = true;
 		/* Init the net_device structure */
 		strlcpy(dev->name, name, IFNAMSIZ);