瀏覽代碼

qcacmn: Get max 5G bandwidth from country code or regdomain pair

If the country code is present, from the country code get the country
index in g_all_countries. Then get the maximum 5G bandwidth supported
by the country. Otherwise, from the regdomain pair value, get the max
5G bandwidth that is supported by that regdomain.

One of the applications of the maximum 5Ghz bandwidth is the following:
Build the 80P80 channels only if 160 MHz bandwidth is supported by the
country

Change-Id: I9e09fdc3a9a276c75f3fc709ee041a47ec812516
CRs-Fixed: 2673083
Ananya Barat 5 年之前
父節點
當前提交
4a127a8976

+ 47 - 0
umac/regulatory/core/src/reg_services_common.c

@@ -1547,6 +1547,53 @@ QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc,
 	return QDF_STATUS_SUCCESS;
 }
 
+QDF_STATUS reg_get_max_5g_bw_from_country_code(uint16_t cc,
+					       uint16_t *max_bw_5g)
+{
+	uint16_t i;
+	int num_countries;
+
+	*max_bw_5g = 0;
+	reg_get_num_countries(&num_countries);
+
+	for (i = 0; i < num_countries; i++) {
+		if (g_all_countries[i].country_code == cc)
+			break;
+	}
+
+	if (i == num_countries)
+		return QDF_STATUS_E_FAILURE;
+
+	*max_bw_5g = g_all_countries[i].max_bw_5g;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS reg_get_max_5g_bw_from_regdomain(uint16_t regdmn,
+					    uint16_t *max_bw_5g)
+{
+	uint16_t i;
+	int num_reg_dmn;
+
+	*max_bw_5g = 0;
+	reg_get_num_reg_dmn_pairs(&num_reg_dmn);
+
+	for (i = 0; i < num_reg_dmn; i++) {
+		if (g_reg_dmn_pairs[i].reg_dmn_pair_id == regdmn)
+			break;
+	}
+
+	if (i == num_reg_dmn)
+		return QDF_STATUS_E_FAILURE;
+
+	if (!regdomains_5g[g_reg_dmn_pairs[i].dmn_id_5g].num_reg_rules)
+		*max_bw_5g = 0;
+	else
+		*max_bw_5g = BW_160_MHZ;
+
+	return QDF_STATUS_SUCCESS;
+}
+
 void reg_get_current_dfs_region(struct wlan_objmgr_pdev *pdev,
 				enum dfs_reg *dfs_reg)
 {

+ 24 - 0
umac/regulatory/core/src/reg_services_common.h

@@ -219,6 +219,30 @@ void reg_set_channel_params(struct wlan_objmgr_pdev *pdev,
 QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc,
 				    uint8_t *country_code);
 
+/**
+ * reg_get_ctry_idx_max_bw_from_country_code() - Get the max 5G bandwidth
+ * from country code
+ * @cc : Country Code
+ * @max_bw_5g : Max 5G bandwidth supported by the country
+ *
+ * Return : QDF_STATUS
+ */
+
+QDF_STATUS reg_get_max_5g_bw_from_country_code(uint16_t cc,
+					       uint16_t *max_bw_5g);
+
+/**
+ * reg_get_max_5g_bw_from_regdomain() - Get the max 5G bandwidth
+ * supported by the regdomain
+ * @orig_regdmn : Regdomain pair value
+ * @max_bw_5g : Max 5G bandwidth supported by the country
+ *
+ * Return : QDF_STATUS
+ */
+
+QDF_STATUS reg_get_max_5g_bw_from_regdomain(uint16_t regdmn,
+					    uint16_t *max_bw_5g);
+
 /**
  * reg_get_current_dfs_region () - Get the current dfs region
  * @pdev: Pointer to pdev

+ 23 - 0
umac/regulatory/dispatcher/inc/wlan_reg_services_api.h

@@ -336,6 +336,29 @@ QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev,
 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc,
 				   uint8_t *country);
 
+/**
+ * wlan_reg_get_ctry_idx_max_bw_from_country_code() - Get the max 5G
+ * bandwidth from country code
+ * @cc : Country Code
+ * @max_bw_5g : Max 5G bandwidth supported by the country
+ *
+ * Return : QDF_STATUS
+ */
+
+QDF_STATUS wlan_reg_get_max_5g_bw_from_country_code(uint16_t cc,
+						    uint16_t *max_bw_5g);
+
+/**
+ * wlan_reg_get_max_5g_bw_from_regdomain() - Get the max 5G bandwidth
+ * supported by the regdomain
+ * @orig_regdmn : Regdomain Pair value
+ * @max_bw_5g : Max 5G bandwidth supported by the country
+ *
+ * Return : QDF_STATUS
+ */
+QDF_STATUS wlan_reg_get_max_5g_bw_from_regdomain(uint16_t regdmn,
+						 uint16_t *max_bw_5g);
+
 /**
  * wlan_reg_get_fcc_constraint() - Check FCC constraint on given frequency
  * @pdev: physical dev to get

+ 18 - 0
umac/regulatory/dispatcher/src/wlan_reg_services_api.c

@@ -84,6 +84,24 @@ QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc,
 	return reg_read_current_country(psoc, country);
 }
 
+QDF_STATUS wlan_reg_get_max_5g_bw_from_country_code(uint16_t cc,
+						    uint16_t *max_bw_5g)
+{
+	/*
+	 * Get the max 5G bandwidth from country code
+	 */
+	return reg_get_max_5g_bw_from_country_code(cc, max_bw_5g);
+}
+
+QDF_STATUS wlan_reg_get_max_5g_bw_from_regdomain(uint16_t regdmn,
+						 uint16_t *max_bw_5g)
+{
+	/*
+	 * Get the max 5G bandwidth from regdomain pair value
+	 */
+	return reg_get_max_5g_bw_from_regdomain(regdmn, max_bw_5g);
+}
+
 #ifdef CONFIG_CHAN_NUM_API
 /**
  * wlan_reg_get_channel_state() - Get channel state from regulatory