Browse Source

qcacmn: Set country code from ioctl

The IOCTL may pass country ISO or country code or regDomain pair
ID as input. In all 3 cases, get the regrules and build master
channel list.

Change-Id: I643734dff175709853cb013b9b58365cceffd5d4
CRs-Fixed: 2002892
Baila, Shashikala Prabhu 8 years ago
parent
commit
f9889e58d4

+ 18 - 16
umac/regulatory/core/src/reg_db_parser.c

@@ -184,15 +184,11 @@ static inline QDF_STATUS reg_get_reginfo_form_country_code_and_regdmn_pair(
 		uint16_t country_index,
 		uint16_t regdmn_pair)
 {
-	uint16_t i, j;
 	uint8_t rule_size_2g, rule_size_5g;
 	uint8_t dmn_id_5g, dmn_id_2g;
 
-	i = country_index;
-	j = regdmn_pair;
-
-	dmn_id_5g = g_reg_dmn_pairs[j].dmn_id_5g;
-	dmn_id_2g = g_reg_dmn_pairs[j].dmn_id_2g;
+	dmn_id_5g = g_reg_dmn_pairs[regdmn_pair].dmn_id_5g;
+	dmn_id_2g = g_reg_dmn_pairs[regdmn_pair].dmn_id_2g;
 
 	rule_size_2g = QDF_ARRAY_SIZE(regdomains_2g[dmn_id_2g].reg_rule_id);
 	rule_size_5g = QDF_ARRAY_SIZE(regdomains_5g[dmn_id_5g].reg_rule_id);
@@ -200,10 +196,16 @@ static inline QDF_STATUS reg_get_reginfo_form_country_code_and_regdmn_pair(
 	if (((rule_size_2g + rule_size_5g) >=
 				regdomains_2g[dmn_id_2g].num_reg_rules +
 				regdomains_5g[dmn_id_5g].num_reg_rules)) {
+
+		qdf_mem_copy(reg_info->alpha2,
+				g_all_countries[country_index].alpha2,
+				sizeof(g_all_countries[country_index].alpha2));
+
 		reg_info->dfs_region = regdomains_5g[dmn_id_5g].dfs_region;
-		reg_info->phybitmap = g_all_countries[i].phymode_bitmap;
-		reg_info->max_bw_2g = g_all_countries[i].max_bw_2g;
-		reg_info->max_bw_5g = g_all_countries[i].max_bw_5g;
+		reg_info->phybitmap =
+			g_all_countries[country_index].phymode_bitmap;
+		reg_info->max_bw_2g = g_all_countries[country_index].max_bw_2g;
+		reg_info->max_bw_5g = g_all_countries[country_index].max_bw_5g;
 
 		reg_info->min_bw_2g = regdomains_2g[dmn_id_2g].min_bw;
 		reg_info->min_bw_5g = regdomains_5g[dmn_id_5g].min_bw;
@@ -235,13 +237,11 @@ static inline QDF_STATUS reg_get_reginfo_form_regdmn_pair(
 		struct cur_regulatory_info *reg_info,
 		uint16_t regdmn_pair)
 {
-	uint16_t j;
 	uint8_t rule_size_2g, rule_size_5g;
 	uint8_t dmn_id_5g, dmn_id_2g;
 
-	j = regdmn_pair;
-	dmn_id_5g = g_reg_dmn_pairs[j].dmn_id_5g;
-	dmn_id_2g = g_reg_dmn_pairs[j].dmn_id_2g;
+	dmn_id_5g = g_reg_dmn_pairs[regdmn_pair].dmn_id_5g;
+	dmn_id_2g = g_reg_dmn_pairs[regdmn_pair].dmn_id_2g;
 
 	rule_size_2g = QDF_ARRAY_SIZE(regdomains_2g[dmn_id_2g].reg_rule_id);
 	rule_size_5g = QDF_ARRAY_SIZE(regdomains_5g[dmn_id_5g].reg_rule_id);
@@ -250,6 +250,8 @@ static inline QDF_STATUS reg_get_reginfo_form_regdmn_pair(
 		    regdomains_2g[dmn_id_2g].num_reg_rules +
 		    regdomains_5g[dmn_id_5g].num_reg_rules)) {
 
+		qdf_mem_zero(reg_info->alpha2, sizeof(reg_info->alpha2));
+
 		reg_info->dfs_region = regdomains_5g[dmn_id_5g].dfs_region;
 		reg_info->phybitmap = 0;
 		reg_info->max_bw_2g = 40;
@@ -292,9 +294,9 @@ QDF_STATUS reg_get_cur_reginfo(struct cur_regulatory_info *reg_info,
 				country_index,
 				regdmn_pair);
 	else if (regdmn_pair != (uint16_t)(-1))
-			reg_get_reginfo_form_regdmn_pair(
-					reg_info,
-					regdmn_pair);
+		reg_get_reginfo_form_regdmn_pair(
+				reg_info,
+				regdmn_pair);
 	else
 		return QDF_STATUS_E_FAILURE;
 

+ 63 - 0
umac/regulatory/core/src/reg_services.c

@@ -2085,3 +2085,66 @@ QDF_STATUS reg_program_default_cc(struct wlan_objmgr_psoc *psoc,
 
 	return QDF_STATUS_SUCCESS;
 }
+
+QDF_STATUS reg_program_chan_list(struct wlan_objmgr_psoc *psoc,
+		struct cc_regdmn_s *rd)
+{
+	struct cur_regulatory_info *reg_info;
+	struct wlan_regulatory_psoc_priv_obj *soc_reg;
+	uint16_t country_index = -1, regdmn_pair = -1;
+	QDF_STATUS err;
+
+	reg_info = (struct cur_regulatory_info *)qdf_mem_malloc
+		(sizeof(struct cur_regulatory_info));
+	if (reg_info == NULL) {
+		reg_err("reg info is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	soc_reg = (struct wlan_regulatory_psoc_priv_obj *)
+		wlan_objmgr_psoc_get_comp_private_obj(psoc,
+				WLAN_UMAC_COMP_REGULATORY);
+
+	if (NULL == soc_reg) {
+		reg_err("soc_reg is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	if (soc_reg->offload_enabled)
+		return QDF_STATUS_E_FAILURE;
+
+	reg_info->psoc = psoc;
+
+	if (rd->flags == CC_IS_SET) {
+		reg_get_rdpair_from_country_code(rd->cc.country_code,
+				&country_index,
+				&regdmn_pair);
+	} else if (rd->flags == ALPHA_IS_SET) {
+		reg_get_rdpair_from_country_iso(rd->cc.alpha,
+				&country_index,
+				&regdmn_pair);
+	} else if (rd->flags == REGDMN_IS_SET) {
+		reg_get_rdpair_from_regdmn_id(rd->cc.regdmn_id,
+				&regdmn_pair);
+	}
+
+	err = reg_get_cur_reginfo(reg_info, country_index, regdmn_pair);
+	if (err == QDF_STATUS_E_FAILURE) {
+		reg_err("%s : Unable to set country code\n", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	if (rd->flags == CC_IS_SET ||
+			rd->flags == ALPHA_IS_SET) {
+		soc_reg->ctry_code =
+			g_all_countries[country_index].country_code;
+	}
+
+	if (rd->flags == REGDMN_IS_SET)
+		soc_reg->reg_dmn_pair = rd->cc.regdmn_id;
+
+	reg_info->offload_enabled = false;
+	reg_process_master_chan_list(reg_info);
+
+	return QDF_STATUS_SUCCESS;
+}

+ 3 - 0
umac/regulatory/core/src/reg_services.h

@@ -187,6 +187,9 @@ QDF_STATUS reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev,
 				     struct regulatory_channel
 				     *chan_list);
 
+QDF_STATUS reg_program_chan_list(struct wlan_objmgr_psoc *psoc,
+		struct cc_regdmn_s *rd);
+
 void reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, uint8_t *ch_list,
 		       uint8_t num_ch, bool nol_ch);
 

+ 3 - 0
umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h

@@ -49,6 +49,9 @@ QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id);
 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_psoc *psoc,
 		uint16_t regdmn);
 
+QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_psoc *psoc,
+		struct cc_regdmn_s *rd);
+
 /**
  * ucfg_reg_set_config_vars () - Set the config vars in reg component
  * @psoc: psoc ptr

+ 6 - 0
umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c

@@ -119,3 +119,9 @@ QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_psoc *psoc,
 {
 	return reg_program_default_cc(psoc, regdmn);
 }
+
+QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_psoc *psoc,
+		struct cc_regdmn_s *rd)
+{
+	return reg_program_chan_list(psoc, rd);
+}