qcacld-3.0: Add support for new regulatory files

Regulatory component is getting updated to reduce the
code size based on different regulatory features. In this
process new regulatory files are getting added and some
of the files are getting removed.

To compile the newly added files update the required changes
in driver Kbuild file.

Some of the functins which are not supposed to be invoked from
outside the component directly, replace those function calls
with the appropriate wrapper functions.

Change-Id: I31a25268250b99f4f156c4f149966213746d999e
CRs-Fixed: 2373780
diff --git a/Kbuild b/Kbuild
index 24cc5fe..418ee55 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1045,6 +1045,8 @@
 
 TARGET_IF_OBJ := $(TARGET_IF_DIR)/core/src/target_if_main.o \
 		$(TARGET_IF_DIR)/regulatory/src/target_if_reg.o \
+		$(TARGET_IF_DIR)/regulatory/src/target_if_reg_lte.o \
+		$(TARGET_IF_DIR)/regulatory/src/target_if_reg_11d.o \
 		$(TARGET_IF_DIR)/init_deinit/src/init_cmd_api.o \
 		$(TARGET_IF_DIR)/init_deinit/src/init_deinit_lmac.o \
 		$(TARGET_IF_DIR)/init_deinit/src/init_event_handler.o \
@@ -1311,12 +1313,18 @@
 REG_DISPATCHER_OBJ_DIR := $(WLAN_COMMON_ROOT)/$(REG_DISPATCHER_SRC_DIR)
 REGULATORY_INC := -I$(WLAN_COMMON_INC)/$(REGULATORY_CORE_INC_DIR)
 REGULATORY_INC += -I$(WLAN_COMMON_INC)/$(REG_DISPATCHER_INC_DIR)
-REGULATORY_OBJS := $(REG_CORE_OBJ_DIR)/reg_db.o \
-                   $(REG_CORE_OBJ_DIR)/reg_services.o \
-                   $(REG_CORE_OBJ_DIR)/reg_db_parser.o \
-                   $(REG_DISPATCHER_OBJ_DIR)/wlan_reg_services_api.o \
-                   $(REG_DISPATCHER_OBJ_DIR)/wlan_reg_tgt_api.o \
-                   $(REG_DISPATCHER_OBJ_DIR)/wlan_reg_ucfg_api.o
+REGULATORY_OBJS := $(REG_CORE_OBJ_DIR)/reg_build_chan_list.o \
+		    $(REG_CORE_OBJ_DIR)/reg_callbacks.o \
+		    $(REG_CORE_OBJ_DIR)/reg_db.o \
+		    $(REG_CORE_OBJ_DIR)/reg_db_parser.o \
+		    $(REG_CORE_OBJ_DIR)/reg_getset.o \
+		    $(REG_CORE_OBJ_DIR)/reg_lte.o \
+		    $(REG_CORE_OBJ_DIR)/reg_opclass.o \
+		    $(REG_CORE_OBJ_DIR)/reg_priv_objs.o \
+		    $(REG_DISPATCHER_OBJ_DIR)/wlan_reg_services_api.o \
+		    $(REG_CORE_OBJ_DIR)/reg_services_common.o \
+		    $(REG_DISPATCHER_OBJ_DIR)/wlan_reg_tgt_api.o \
+		    $(REG_DISPATCHER_OBJ_DIR)/wlan_reg_ucfg_api.o
 ifeq ($(CONFIG_HOST_11D_SCAN), y)
 REGULATORY_OBJS += $(REG_CORE_OBJ_DIR)/reg_host_11d.o
 endif
@@ -2458,6 +2466,12 @@
 #Flag to enable set and get disable channel list feature
 cppflags-$(CONFIG_DISABLE_CHANNEL_LIST) += -DDISABLE_CHANNEL_LIST
 
+#Flag to enable/disable LTE COEX support
+cppflags-$(CONFIG_CONFIG_LTE_COEX) += -DCONFIG_LTE_COEX
+
+#Flag to enable/disable HOST_OPCLASS
+cppflags-$(CONFIG_HOST_OPCLASS) += -DHOST_OPCLASS
+
 #Flag to enable Dynamic Voltage WDCVS (Config Voltage Mode)
 cppflags-$(CONFIG_WLAN_DYNAMIC_CVM) += -DFEATURE_WLAN_DYNAMIC_CVM
 
diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c
index 3ccd40d..47b0d6d 100644
--- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c
+++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_action.c
@@ -1489,8 +1489,9 @@
 		    wlan_reg_is_passive_or_disable_ch(pm_ctx->pdev, channel) ||
 		    !(policy_mgr_sta_sap_scc_on_lte_coex_chan(psoc) ||
 		      policy_mgr_is_safe_channel(psoc, channel)) ||
-		    (!reg_is_etsi13_srd_chan_allowed_master_mode(pm_ctx->pdev)
-		    && reg_is_etsi13_srd_chan(pm_ctx->pdev, channel))) {
+		    (!wlan_reg_is_etsi13_srd_chan_allowed_master_mode(
+								pm_ctx->pdev) &&
+		     wlan_reg_is_etsi13_srd_chan(pm_ctx->pdev, channel))) {
 			if (wlan_reg_is_dfs_ch(pm_ctx->pdev, channel) &&
 			    sta_sap_scc_on_dfs_chan) {
 				policy_mgr_debug("STA SAP SCC is allowed on DFS channel");
diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c
index 569a75b..acd9086 100644
--- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c
+++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -1844,8 +1844,8 @@
 	policy_mgr_debug("Set weight of DFS/passive channels to 0");
 
 	for (i = 0; i < orig_channel_count; i++) {
-		channel_state = reg_get_channel_state(pm_ctx->pdev,
-				pcl_channels[i]);
+		channel_state = wlan_reg_get_channel_state(pm_ctx->pdev,
+							   pcl_channels[i]);
 		if ((channel_state == CHANNEL_STATE_DISABLE) ||
 				(channel_state == CHANNEL_STATE_INVALID))
 			/* Set weight of inactive channels to 0 */
@@ -2789,14 +2789,14 @@
 	 */
 	switch (num_connections) {
 	case 1:
-		band1 = reg_chan_to_band(pm_conc_connection_list[0].chan);
+		band1 = wlan_reg_chan_to_band(pm_conc_connection_list[0].chan);
 		if (band1 == BAND_2G)
 			return PM_DBS;
 		else
 			return PM_NOP;
 	case 2:
-		band1 = reg_chan_to_band(pm_conc_connection_list[0].chan);
-		band2 = reg_chan_to_band(pm_conc_connection_list[1].chan);
+		band1 = wlan_reg_chan_to_band(pm_conc_connection_list[0].chan);
+		band2 = wlan_reg_chan_to_band(pm_conc_connection_list[1].chan);
 		if ((band1 == BAND_2G) ||
 			(band2 == BAND_2G)) {
 			if (!hw_mode.dbs_cap)
@@ -2821,9 +2821,9 @@
 		} else
 			return PM_NOP;
 	case 3:
-		band1 = reg_chan_to_band(pm_conc_connection_list[0].chan);
-		band2 = reg_chan_to_band(pm_conc_connection_list[1].chan);
-		band3 = reg_chan_to_band(pm_conc_connection_list[2].chan);
+		band1 = wlan_reg_chan_to_band(pm_conc_connection_list[0].chan);
+		band2 = wlan_reg_chan_to_band(pm_conc_connection_list[1].chan);
+		band3 = wlan_reg_chan_to_band(pm_conc_connection_list[2].chan);
 		if ((band1 == BAND_2G) ||
 			(band2 == BAND_2G) ||
 			(band3 == BAND_2G)) {
@@ -2912,8 +2912,8 @@
 		next_action = PM_NOP;
 		break;
 	case 2:
-		band1 = reg_chan_to_band(pm_conc_connection_list[0].chan);
-		band2 = reg_chan_to_band(pm_conc_connection_list[1].chan);
+		band1 = wlan_reg_chan_to_band(pm_conc_connection_list[0].chan);
+		band2 = wlan_reg_chan_to_band(pm_conc_connection_list[1].chan);
 		if ((band1 == band2) && (hw_mode.dbs_cap))
 			next_action = PM_SINGLE_MAC_UPGRADE;
 		else if ((band1 != band2) && (!hw_mode.dbs_cap))
@@ -2924,9 +2924,9 @@
 		break;
 
 	case 3:
-		band1 = reg_chan_to_band(pm_conc_connection_list[0].chan);
-		band2 = reg_chan_to_band(pm_conc_connection_list[1].chan);
-		band3 = reg_chan_to_band(pm_conc_connection_list[2].chan);
+		band1 = wlan_reg_chan_to_band(pm_conc_connection_list[0].chan);
+		band2 = wlan_reg_chan_to_band(pm_conc_connection_list[1].chan);
+		band3 = wlan_reg_chan_to_band(pm_conc_connection_list[2].chan);
 		if (((band1 == band2) && (band2 == band3)) &&
 				(hw_mode.dbs_cap)) {
 			next_action = PM_SINGLE_MAC_UPGRADE;
diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c
index 3895e70..ecc3891 100644
--- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c
+++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_get_set_utils.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -3351,11 +3351,11 @@
 				org_ch_list[i];
 		}
 	} else if (band_mask == 2) {
-		if ((reg_get_channel_state(pm_ctx->pdev, ch_5g) ==
+		if ((wlan_reg_get_channel_state(pm_ctx->pdev, ch_5g) ==
 			CHANNEL_STATE_DFS) &&
 		      policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan(psoc))
 			ch_list[ch_list_count++] = ch_5g;
-		else if (!(reg_get_channel_state(pm_ctx->pdev, ch_5g) ==
+		else if (!(wlan_reg_get_channel_state(pm_ctx->pdev, ch_5g) ==
 			CHANNEL_STATE_DFS))
 			ch_list[ch_list_count++] = ch_5g;
 		for (i = 0; i < *org_ch_list_count; i++) {
@@ -3530,7 +3530,7 @@
 	sap_count = policy_mgr_mode_specific_connection_count(psoc,
 							      PM_SAP_MODE,
 							      NULL);
-	state = reg_get_channel_state(pm_ctx->pdev, channel);
+	state = wlan_reg_get_channel_state(pm_ctx->pdev, channel);
 
 	policy_mgr_debug("sta_sap_scc_on_dfs_chan %u, sap_count %u, channel %u, state %u",
 			 sta_sap_scc_on_dfs_chan, sap_count, channel, state);
diff --git a/components/tdls/core/src/wlan_tdls_cmds_process.c b/components/tdls/core/src/wlan_tdls_cmds_process.c
index a27c040..6eb228d 100644
--- a/components/tdls/core/src/wlan_tdls_cmds_process.c
+++ b/components/tdls/core/src/wlan_tdls_cmds_process.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -21,6 +21,12 @@
  *
  * TDLS north bound commands implementation
  */
+#include <qdf_types.h>
+#include <qdf_status.h>
+#include <wlan_cmn.h>
+#include <reg_services_public_struct.h>
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_objmgr_pdev_obj.h>
 #include <wlan_reg_services_api.h>
 #include <wlan_serialization_api.h>
 #include "wlan_tdls_main.h"
diff --git a/configs/default_defconfig b/configs/default_defconfig
index 9af7c5f..a94b85e 100644
--- a/configs/default_defconfig
+++ b/configs/default_defconfig
@@ -579,6 +579,15 @@
 #Flag to enable set and get disable channel list feature
 CONFIG_DISABLE_CHANNEL_LIST :=y
 
+#Flag to enable LTE COEX feature
+CONFIG_CONFIG_LTE_COEX := y
+
+#Flag to enable/disable HOST 11d scan
+CONFIG_HOST_11D_SCAN :=y
+
+#Flag to enable HOST OPCLASS feature
+CONFIG_HOST_OPCLASS := y
+
 #Flag to enable Dynamic Voltage WDCVS (Config Voltage Mode)
 CONFIG_WLAN_DYNAMIC_CVM := y
 
diff --git a/core/cds/inc/cds_api.h b/core/cds/inc/cds_api.h
index 74bf5b0..15ea5da 100644
--- a/core/cds/inc/cds_api.h
+++ b/core/cds/inc/cds_api.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -36,6 +36,7 @@
 #include <qdf_lock.h>
 #include "qdf_platform.h"
 #include "qdf_cpuhp.h"
+#include <wlan_cmn.h>
 #include "reg_services_public_struct.h"
 #include <cds_reg_service.h>
 #include <cds_packet.h>
diff --git a/core/cds/inc/cds_regdomain.h b/core/cds/inc/cds_regdomain.h
index 50d91f6..1d46e63 100644
--- a/core/cds/inc/cds_regdomain.h
+++ b/core/cds/inc/cds_regdomain.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011, 2014-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -62,6 +62,7 @@
 #ifndef __CDS_REGDOMAIN_H
 #define __CDS_REGDOMAIN_H
 
+#include <wlan_cmn.h>
 #include <reg_services_public_struct.h>
 
 #define MIN_TX_PWR_CAP    8
diff --git a/core/cds/src/cds_reg_service.c b/core/cds/src/cds_reg_service.c
index c658fdc..5c93ada 100644
--- a/core/cds/src/cds_reg_service.c
+++ b/core/cds/src/cds_reg_service.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -24,6 +24,7 @@
 
 #include "qdf_types.h"
 #include "qdf_trace.h"
+#include <wlan_objmgr_pdev_obj.h>
 #include "wlan_reg_services_api.h"
 #include "cds_reg_service.h"
 #include "cds_ieee80211_common_i.h"
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index ef477fa..0125a71 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -1033,7 +1033,7 @@
  */
 int wlan_hdd_get_adjacent_chan(uint8_t chan, bool upper)
 {
-	enum channel_enum ch_idx = reg_get_chan_enum(chan);
+	enum channel_enum ch_idx = wlan_reg_get_chan_enum(chan);
 
 	if (ch_idx == INVALID_CHANNEL)
 		return -EINVAL;
@@ -1100,11 +1100,11 @@
 	}
 
 	if (WLAN_REG_IS_24GHZ_CH(op_chan)) {
-		min_chan = REG_MIN_24GHZ_CH_NUM;
-		max_chan = REG_MAX_24GHZ_CH_NUM;
-	} else if WLAN_REG_IS_5GHZ_CH(op_chan) {
-		min_chan = REG_MIN_5GHZ_CH_NUM;
-		max_chan = REG_MAX_5GHZ_CH_NUM;
+		min_chan = WLAN_REG_MIN_24GHZ_CH_NUM;
+		max_chan = WLAN_REG_MAX_24GHZ_CH_NUM;
+	} else if (WLAN_REG_IS_5GHZ_CH(op_chan)) {
+		min_chan = WLAN_REG_MIN_5GHZ_CH_NUM;
+		max_chan = WLAN_REG_MAX_5GHZ_CH_NUM;
 	} else {
 		hdd_err("invalid channel:%d", op_chan);
 		return -EINVAL;
@@ -8603,7 +8603,7 @@
 		     ch_idx <= channel_list->
 					avoid_freq_range[range_idx].end_freq;
 		     ch_idx++) {
-			 if (INVALID_CHANNEL == reg_get_chan_enum(ch_idx))
+			if (INVALID_CHANNEL == wlan_reg_get_chan_enum(ch_idx))
 				continue;
 			for (unsafe_channel_index = 0;
 			     unsafe_channel_index < unsafe_channel_count;
diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c
index 36c049d..67a86d3 100644
--- a/core/hdd/src/wlan_hdd_hostapd.c
+++ b/core/hdd/src/wlan_hdd_hostapd.c
@@ -86,6 +86,7 @@
 #include "wlan_crypto_global_api.h"
 #include "wlan_action_oui_ucfg_api.h"
 #include "nan_ucfg_api.h"
+#include <wlan_reg_services_api.h>
 
 #define ACS_SCAN_EXPIRY_TIMEOUT_S 4
 
@@ -4508,7 +4509,7 @@
 	}
 
 	for (i = 0; i < cache_chann->num_channels; i++) {
-		freq = reg_chan_to_freq(
+		freq = wlan_reg_chan_to_freq(
 				hdd_ctx->pdev,
 				cache_chann->channel_info[i].channel_num);
 		if (!freq)
@@ -4580,8 +4581,8 @@
 	}
 
 	for (i = 0; i < cache_chann->num_channels; i++) {
-		freq = reg_chan_to_freq(hdd_ctx->pdev,
-					cache_chann->
+		freq = wlan_reg_chan_to_freq(hdd_ctx->pdev,
+					     cache_chann->
 						channel_info[i].channel_num);
 		if (!freq)
 			continue;
@@ -4594,7 +4595,7 @@
 		 * the channels
 		 */
 		cache_chann->channel_info[i].reg_status =
-					reg_get_channel_state(
+					wlan_reg_get_channel_state(
 							hdd_ctx->pdev,
 							rf_channel);
 		cache_chann->channel_info[i].wiphy_status =
@@ -5916,13 +5917,13 @@
 	/* if sta_sap_scc_on_dfs_chan ini is set, DFS master capability is
 	 * assumed disabled in the driver.
 	 */
-	if ((reg_get_channel_state(hdd_ctx->pdev, channel) ==
+	if ((wlan_reg_get_channel_state(hdd_ctx->pdev, channel) ==
 	     CHANNEL_STATE_DFS) && sta_sap_scc_on_dfs_chan && !sta_cnt) {
 		hdd_err("SAP not allowed on DFS channel!!");
 		return -EINVAL;
 	}
-	if (!reg_is_etsi13_srd_chan_allowed_master_mode(hdd_ctx->pdev) &&
-	    reg_is_etsi13_srd_chan(hdd_ctx->pdev, channel)) {
+	if (!wlan_reg_is_etsi13_srd_chan_allowed_master_mode(hdd_ctx->pdev) &&
+	    wlan_reg_is_etsi13_srd_chan(hdd_ctx->pdev, channel)) {
 		hdd_err("SAP not allowed on SRD channel.");
 		return -EINVAL;
 	}
diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c
index d191852..946d4dd 100644
--- a/core/sap/src/sap_fsm.c
+++ b/core/sap/src/sap_fsm.c
@@ -2493,8 +2493,8 @@
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
 			  FL("ap_ctx->ch_params.ch_width %d, channel %d"),
 			     sap_ctx->ch_params.ch_width,
-			     reg_get_channel_state(mac_ctx->pdev,
-						   sap_ctx->channel));
+			     wlan_reg_get_channel_state(mac_ctx->pdev,
+							sap_ctx->channel));
 
 		/*
 		 * The upper layers have been informed that AP is up and