From 4a127a897643ecbbde657b8b02714684d6902470 Mon Sep 17 00:00:00 2001 From: Ananya Barat Date: Mon, 4 May 2020 18:18:51 +0530 Subject: [PATCH] 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 --- .../regulatory/core/src/reg_services_common.c | 47 +++++++++++++++++++ .../regulatory/core/src/reg_services_common.h | 24 ++++++++++ .../dispatcher/inc/wlan_reg_services_api.h | 23 +++++++++ .../dispatcher/src/wlan_reg_services_api.c | 18 +++++++ 4 files changed, 112 insertions(+) diff --git a/umac/regulatory/core/src/reg_services_common.c b/umac/regulatory/core/src/reg_services_common.c index a87f86a2cba4..b0523058bd3a 100644 --- a/umac/regulatory/core/src/reg_services_common.c +++ b/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) { diff --git a/umac/regulatory/core/src/reg_services_common.h b/umac/regulatory/core/src/reg_services_common.h index 48f5b1d6d6dc..cac5cb7ea96a 100644 --- a/umac/regulatory/core/src/reg_services_common.h +++ b/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 diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index f3b48e6e0402..aecba4b1327e 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/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 diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 9b90573a161b..0d462245377a 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/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