qcacld-3.0: Keep source of driver hint also

Maintain source of driver as well as 11d hint. Use the source of
hint to correctly disable 11d if required.

CRs-Fixed: 1093565
Change-Id: Id0ccc44389836b72466b501f5ce024f1be4b5926
diff --git a/core/cds/inc/cds_reg_service.h b/core/cds/inc/cds_reg_service.h
index 8156519..bbe9fa4 100644
--- a/core/cds/inc/cds_reg_service.h
+++ b/core/cds/inc/cds_reg_service.h
@@ -283,6 +283,7 @@
  * @SOURCE_11D: source 11D
  */
 enum country_src {
+	SOURCE_UNKNOWN,
 	SOURCE_QUERY,
 	SOURCE_CORE,
 	SOURCE_DRIVER,
diff --git a/core/hdd/src/wlan_hdd_regulatory.c b/core/hdd/src/wlan_hdd_regulatory.c
index 666bc77..64de8ca 100644
--- a/core/hdd/src/wlan_hdd_regulatory.c
+++ b/core/hdd/src/wlan_hdd_regulatory.c
@@ -672,9 +672,10 @@
 			hdd_ctx->reg.cc_src = SOURCE_CORE;
 			if (is_wiphy_custom_regulatory(wiphy))
 				reset = true;
-		} else if (NL80211_REGDOM_SET_BY_DRIVER == request->initiator)
+		} else if (NL80211_REGDOM_SET_BY_DRIVER == request->initiator) {
 			hdd_ctx->reg.cc_src = SOURCE_DRIVER;
-		else {
+			sme_set_cc_src(hdd_ctx->hHal, SOURCE_DRIVER);
+		} else {
 			hdd_ctx->reg.cc_src = SOURCE_USERSPACE;
 			hdd_restore_custom_reg_settings(wiphy,
 							request->alpha2,
diff --git a/core/mac/inc/ani_global.h b/core/mac/inc/ani_global.h
index 7634b01..d0fbfaf 100644
--- a/core/mac/inc/ani_global.h
+++ b/core/mac/inc/ani_global.h
@@ -966,8 +966,8 @@
 	enum auth_tx_ack_status auth_ack_status;
 	uint8_t user_configured_nss;
 	bool sta_prefer_80MHz_over_160MHz;
-	bool is_11d_hint;
 	struct wlan_objmgr_psoc *psoc;
+	enum  country_src reg_hint_src;
 } tAniSirGlobal;
 
 typedef enum {
diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h
index 6f7afab..d5dad96 100644
--- a/core/sme/inc/sme_api.h
+++ b/core/sme/inc/sme_api.h
@@ -1363,4 +1363,5 @@
 				(struct  power_stats_response *response,
 				void *context), void *power_stats_context);
 #endif
+void sme_set_cc_src(tHalHandle hal_handle, enum country_src);
 #endif /* #if !defined( __SME_API_H ) */
diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c
index 0b100ad..9a44572 100644
--- a/core/sme/src/common/sme_api.c
+++ b/core/sme/src/common/sme_api.c
@@ -7675,6 +7675,12 @@
 	return status;
 }
 
+void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
+{
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
+
+	mac_ctx->reg_hint_src = cc_src;
+}
 /* ---------------------------------------------------------------------------
 
     \fn sme_handle_change_country_code
@@ -7830,23 +7836,25 @@
 
 	sms_log(mac_ctx, LOG1, FL(" called"));
 
-	if (!mac_ctx->is_11d_hint) {
-		if (user_ctry_priority)
-			mac_ctx->roam.configParam.Is11dSupportEnabled = false;
-		else {
-			if (mac_ctx->roam.configParam.Is11dSupportEnabled &&
-			    mac_ctx->scan.countryCode11d[0] != 0) {
+	if (SOURCE_11D != mac_ctx->reg_hint_src) {
+		if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
+			if (user_ctry_priority)
+				mac_ctx->roam.configParam.Is11dSupportEnabled =
+					false;
+			else {
+				if (mac_ctx->roam.configParam.Is11dSupportEnabled &&
+				    mac_ctx->scan.countryCode11d[0] != 0) {
 
-				sms_log(mac_ctx, LOGW,
-					FL("restore 11d"));
+					sms_log(mac_ctx, LOGW,
+						FL("restore 11d"));
 
-				status = csr_get_regulatory_domain_for_country(
-					mac_ctx,
-					mac_ctx->scan.countryCode11d,
-					&reg_domain_id,
-					SOURCE_11D);
-
-				return QDF_STATUS_E_FAILURE;
+					status = csr_get_regulatory_domain_for_country(
+						mac_ctx,
+						mac_ctx->scan.countryCode11d,
+						&reg_domain_id,
+						SOURCE_11D);
+					return QDF_STATUS_E_FAILURE;
+				}
 			}
 		}
 	} else {
@@ -7858,7 +7866,6 @@
 			qdf_mem_copy(mac_ctx->scan.countryCode11d,
 				     msg->countryCode,
 				     WNI_CFG_COUNTRY_CODE_LEN);
-		mac_ctx->is_11d_hint = false;
 	}
 
 	qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
@@ -7883,6 +7890,8 @@
 	 */
 	mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
 
+	mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
+
 	sme_disconnect_connected_sessions(mac_ctx);
 
 	sms_log(mac_ctx, LOG1, FL(" returned"));
diff --git a/core/sme/src/csr/csr_api_scan.c b/core/sme/src/csr/csr_api_scan.c
index a7149c9..92fa1af 100644
--- a/core/sme/src/csr/csr_api_scan.c
+++ b/core/sme/src/csr/csr_api_scan.c
@@ -3713,7 +3713,7 @@
 		goto free_ie;
 	}
 
-	pMac->is_11d_hint = true;
+	pMac->reg_hint_src = SOURCE_11D;
 	status = csr_get_regulatory_domain_for_country(pMac,
 				pCountryCodeSelected, &domainId, SOURCE_11D);
 	if (status != QDF_STATUS_SUCCESS) {