qcacld-3.0: Modify DFS region for KR and CN

KR and CN have different DFS regions than what kernel provides.
Assign the correct DFS regions for KR and CN. Also use "enum
dfs_region" as the parameter type in functions that have
dfs region as parameter.

CRs-Fixed: 1047214
Change-Id: I2ddd67d3c29a448dd2a1d3a63113750783fb6731
diff --git a/core/cds/inc/cds_reg_service.h b/core/cds/inc/cds_reg_service.h
index 7a87e94..4fc7a52 100644
--- a/core/cds/inc/cds_reg_service.h
+++ b/core/cds/inc/cds_reg_service.h
@@ -343,6 +343,26 @@
 	uint8_t center_freq_seg1;
 };
 
+/**
+ * enum dfs_region - DFS region
+ * @DFS_UNINIT_REGION: un-initialized region
+ * @DFS_FCC_REGION: FCC region
+ * @DFS_ETSI_REGION: ETSI region
+ * @DFS_MKK_REGION: MKK region
+ * @DFS_CN_REGION: China region
+ * @DFS_KR_REGION: Korea region
+ * @DFS_UNDEF_REGION: Undefined region
+ */
+enum dfs_region {
+	DFS_UNINIT_REGION = 0,
+	DFS_FCC_REGION = 1,
+	DFS_ETSI_REGION = 2,
+	DFS_MKK_REGION = 3,
+	DFS_CN_REGION = 4,
+	DFS_KR_REGION = 5,
+	DFS_UNDEF_REGION
+};
+
 extern const struct chan_map chan_mapping[NUM_CHANNELS];
 extern struct regulatory_channel reg_channels[NUM_CHANNELS];
 
@@ -357,8 +377,8 @@
 					   uint8_t *num_base_channels);
 
 enum channel_state cds_get_channel_state(uint32_t chan_num);
-QDF_STATUS cds_get_dfs_region(uint8_t *dfs_region);
-QDF_STATUS cds_put_dfs_region(uint8_t dfs_region);
+QDF_STATUS cds_get_dfs_region(enum dfs_region *dfs_reg);
+QDF_STATUS cds_put_dfs_region(enum dfs_region dfs_reg);
 
 bool cds_is_dsrc_channel(uint16_t center_freq);
 enum channel_state cds_get_5g_bonded_channel_state(uint16_t chan_num,
diff --git a/core/cds/inc/cds_regdomain.h b/core/cds/inc/cds_regdomain.h
index d1c134d..ac202b7 100644
--- a/core/cds/inc/cds_regdomain.h
+++ b/core/cds/inc/cds_regdomain.h
@@ -473,20 +473,6 @@
 };
 
 /**
- * enum dfs_region - DFS region
- * @DFS_UNINIT_REGION: un-initialized region
- * @DFS_FCC_REGION: FCC region
- * @DFS_ETSI_REGION: ETSI region
- * @DFS_MKK_REGION: MKK region
- */
-enum dfs_region {
-	DFS_UNINIT_REGION = 0,
-	DFS_FCC_REGION = 1,
-	DFS_ETSI_REGION = 2,
-	DFS_MKK_REGION = 3
-};
-
-/**
  * enum offset_t: channel offset
  * @BW20: 20 mhz channel
  * @BW40_LOW_PRIMARY: lower channel in 40 mhz
diff --git a/core/cds/src/cds_reg_service.c b/core/cds/src/cds_reg_service.c
index b15f99f..32cfc71 100644
--- a/core/cds/src/cds_reg_service.c
+++ b/core/cds/src/cds_reg_service.c
@@ -40,6 +40,7 @@
 #include "cds_reg_service.h"
 #include "cds_regdomain.h"
 
+
 const struct chan_map chan_mapping[NUM_CHANNELS] = {
 	[CHAN_ENUM_1] = {2412, 1},
 	[CHAN_ENUM_2] = {2417, 2},
@@ -152,7 +153,7 @@
 
 struct regulatory_channel reg_channels[NUM_CHANNELS];
 static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
-static uint8_t dfs_region;
+static enum dfs_region dfs_region;
 
 /**
  * cds_get_channel_list_with_power() - retrieve channel list with power
@@ -580,7 +581,7 @@
  *
  * Return: QDF_STATUS
  */
-QDF_STATUS cds_get_dfs_region(uint8_t *dfs_reg)
+QDF_STATUS cds_get_dfs_region(enum dfs_region *dfs_reg)
 {
 	*dfs_reg = dfs_region;
 
@@ -670,7 +671,7 @@
  *
  * Return: QDF_STATUS
  */
-QDF_STATUS cds_put_dfs_region(uint8_t dfs_reg)
+QDF_STATUS cds_put_dfs_region(enum dfs_region dfs_reg)
 {
 	dfs_region = dfs_reg;
 
diff --git a/core/hdd/src/wlan_hdd_regulatory.c b/core/hdd/src/wlan_hdd_regulatory.c
index 6f7457e..4a33cf8 100644
--- a/core/hdd/src/wlan_hdd_regulatory.c
+++ b/core/hdd/src/wlan_hdd_regulatory.c
@@ -33,10 +33,10 @@
 
 #include "qdf_types.h"
 #include "cds_reg_service.h"
+#include "cds_regdomain.h"
 #include "qdf_trace.h"
 #include "sme_api.h"
 #include "wlan_hdd_main.h"
-#include "cds_regdomain.h"
 #include "wlan_hdd_regulatory.h"
 
 #define WORLD_SKU_MASK      0x00F0
@@ -427,6 +427,43 @@
 	wlan_hdd_cfg80211_update_band(wiphy, band_capability);
 }
 
+/**
+ * hdd_set_dfs_region() - set the dfs_region
+ * @dfs_region: the dfs_region to set
+ *
+ * Return: void
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
+static void hdd_set_dfs_region(hdd_context_t *hdd_ctx,
+			       enum dfs_region dfs_reg)
+{
+	cds_put_dfs_region(dfs_reg);
+}
+#else
+static void hdd_set_dfs_region(hdd_context_t *hdd_ctx,
+				     enum dfs_region dfs_reg)
+{
+
+	/* remap the ctl code to dfs region code */
+	switch (hdd_ctx->reg.ctl_5g) {
+	case FCC:
+		cds_put_dfs_region(DFS_FCC_REGION);
+		break;
+	case ETSI:
+		cds_put_dfs_region(DFS_ETSI_REGION);
+		break;
+	case MKK:
+		cds_put_dfs_region(DFS_MKK_REGION);
+		break;
+	default:
+		/* set default dfs_region to FCC */
+		cds_put_dfs_region(DFS_FCC_REGION);
+		break;
+	}
+
+}
+#endif
+
 
 /**
  * hdd_regulatory_init() - regulatory_init
@@ -439,6 +476,7 @@
 {
 	int ret_val;
 	struct regulatory *reg_info;
+	enum dfs_region dfs_reg;
 
 	reg_info = &hdd_ctx->reg;
 
@@ -460,6 +498,10 @@
 
 	cds_fill_and_send_ctl_to_fw(reg_info);
 
+	hdd_set_dfs_region(hdd_ctx, DFS_FCC_REGION);
+	cds_get_dfs_region(&dfs_reg);
+	cds_set_wma_dfs_region(dfs_reg);
+
 	return 0;
 }
 
@@ -488,43 +530,6 @@
 
 
 /**
- * hdd_set_dfs_region() - set the dfs_region
- * @dfs_region: the dfs_region to set
- *
- * Return: void
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
-static void hdd_set_dfs_region(hdd_context_t *hdd_ctx,
-			       uint8_t dfs_reg)
-{
-	cds_put_dfs_region(dfs_reg);
-}
-#else
-static void hdd_set_dfs_region(hdd_context_t *hdd_ctx,
-				     uint8_t dfs_reg)
-{
-
-	/* remap the ctl code to dfs region code */
-	switch (hdd_ctx->reg.ctl_5g) {
-	case FCC:
-		cds_put_dfs_region(DFS_FCC_REGION);
-		break;
-	case ETSI:
-		cds_put_dfs_region(DFS_ETSI_REGION);
-		break;
-	case MKK:
-		cds_put_dfs_region(DFS_MKK_REGION);
-		break;
-	default:
-		/* set default dfs_region to FCC */
-		cds_put_dfs_region(DFS_FCC_REGION);
-		break;
-	}
-
-}
-#endif
-
-/**
  * hdd_restore_custom_reg_settings() - restore custom reg settings
  * @wiphy: wiphy structure
  * @country_alpha2: alpha2 of the country
@@ -601,7 +606,7 @@
 	hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
 	bool vht80_allowed;
 	bool reset = false;
-	uint8_t dfs_reg;
+	enum dfs_region dfs_reg;
 
 	hdd_info("country: %c%c, initiator %d, dfs_region: %d",
 		  request->alpha2[0],
@@ -620,6 +625,14 @@
 		return;
 	}
 
+	if (('K' == request->alpha2[0]) &&
+	    ('R' == request->alpha2[1]))
+		request->dfs_region = DFS_KR_REGION;
+
+	if (('C' == request->alpha2[0]) &&
+	    ('N' == request->alpha2[1]))
+		request->dfs_region = DFS_CN_REGION;
+
 	/* first check if this callback is in response to the driver callback */
 
 	switch (request->initiator) {
diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c
index 0737620..7135232 100644
--- a/core/sap/src/sap_fsm.c
+++ b/core/sap/src/sap_fsm.c
@@ -1246,13 +1246,14 @@
  */
 static uint8_t sap_apply_rules(ptSapContext sap_ctx)
 {
-	uint8_t num_valid_ch, dfs_region, i = 0, ch_id;
+	uint8_t num_valid_ch, i = 0, ch_id;
 	tAll5GChannelList *sap_all_ch = &sap_ctx->SapAllChnlList;
 	bool is_ch_nol = false;
 	bool is_out_of_range = false;
 	tpAniSirGlobal mac_ctx;
 	tHalHandle hal = CDS_GET_HAL_CB(sap_ctx->p_cds_gctx);
 	uint8_t preferred_location;
+	enum dfs_region dfs_region;
 
 	if (NULL == hal) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
@@ -4853,7 +4854,7 @@
 	uint32_t cacTimeOut;
 	tHalHandle hHal = NULL;
 	tpAniSirGlobal pMac = NULL;
-	uint8_t dfs_region;
+	enum dfs_region dfs_region;
 
 	if (sapContext == NULL) {
 		return 0;
diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c
index 7a77d19..edb3aa2 100644
--- a/core/sap/src/sap_module.c
+++ b/core/sap/src/sap_module.c
@@ -2871,7 +2871,7 @@
 {
 	tpAniSirGlobal pMac = NULL;
 	QDF_STATUS status;
-	uint8_t dfs_region;
+	enum dfs_region dfs_region;
 
 	if (NULL != hHal) {
 		pMac = PMAC_STRUCT(hHal);
@@ -2955,7 +2955,7 @@
 {
 	tpAniSirGlobal pMac = NULL;
 	QDF_STATUS status;
-	uint8_t dfs_region;
+	enum dfs_region dfs_region;
 
 	if (NULL != hHal) {
 		pMac = PMAC_STRUCT(hHal);
diff --git a/core/wma/inc/wma.h b/core/wma/inc/wma.h
index 1665af6..d915c88 100644
--- a/core/wma/inc/wma.h
+++ b/core/wma/inc/wma.h
@@ -2112,7 +2112,7 @@
 				   uint32_t len);
 int wma_mgmt_tx_bundle_completion_handler(void *handle,
 	uint8_t *cmpl_event_params, uint32_t len);
-void wma_set_dfs_region(tp_wma_handle wma, uint8_t dfs_region);
+void wma_set_dfs_region(tp_wma_handle wma, enum dfs_region dfs_region);
 uint32_t wma_get_vht_ch_width(void);
 QDF_STATUS
 wma_config_debug_module_cmd(wmi_unified_t wmi_handle, A_UINT32 param,
diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c
index f2c8a87..5ed1ff9 100644
--- a/core/wma/src/wma_features.c
+++ b/core/wma/src/wma_features.c
@@ -7199,10 +7199,11 @@
  *
  * Return: none
  */
-void wma_set_dfs_region(tp_wma_handle wma, uint8_t dfs_region)
+void wma_set_dfs_region(tp_wma_handle wma, enum dfs_region dfs_region)
 {
-	/* dfs information is passed */
-	if (dfs_region > DFS_MKK_REGION || dfs_region == DFS_UNINIT_REGION)
+	if (dfs_region >= DFS_UNDEF_REGION ||
+	    dfs_region == DFS_UNINIT_REGION)
+
 		/* assign DFS_FCC_REGION as default region*/
 		wma->dfs_ic->current_dfs_regdomain = DFS_FCC_REGION;
 	else