diff --git a/umac/regulatory/core/src/reg_db_parser.c b/umac/regulatory/core/src/reg_db_parser.c index 572ed3b44b..4a1d5255f5 100644 --- a/umac/regulatory/core/src/reg_db_parser.c +++ b/umac/regulatory/core/src/reg_db_parser.c @@ -26,6 +26,7 @@ #include "reg_db_parser.h" #include #include "reg_priv.h" +#include "reg_services.h" QDF_STATUS reg_is_country_code_valid(uint8_t alpha[3]) { @@ -213,7 +214,8 @@ static inline QDF_STATUS reg_get_reginfo_form_country_code_and_regdmn_pair( reg_info->ctry_code = g_all_countries[country_index].country_code; - reg_info->reg_dmn_pair = 0; + reg_info->reg_dmn_pair = + g_reg_dmn_pairs[regdmn_pair].reg_dmn_pair_id; reg_info->dfs_region = regdomains_5g[dmn_id_5g].dfs_region; reg_info->phybitmap = g_all_countries[country_index].phymode_bitmap; diff --git a/umac/regulatory/core/src/reg_services.c b/umac/regulatory/core/src/reg_services.c index 7f13a1d475..d5670ab4c3 100644 --- a/umac/regulatory/core/src/reg_services.c +++ b/umac/regulatory/core/src/reg_services.c @@ -39,10 +39,6 @@ #define MAX_PWR_FCC_CHAN_13 2 #define SCAN_11D_PERIOD_MS 360000 -#define IS_VALID_PSOC_REG_OBJ(psoc_priv_obj) (NULL != psoc_priv_obj) -#define IS_VALID_PDEV_REG_OBJ(pdev_priv_obj) (NULL != pdev_priv_obj) - - const struct bonded_channel bonded_chan_40mhz_list[] = { {36, 40}, {44, 48}, @@ -230,13 +226,7 @@ static const struct reg_dmn_op_class_map_t japan_op_class[] = { {0, 0, 0, {0} }, }; -/** - * reg_get_psoc_obj() - Provides the reg component object pointer - * @psoc: pointer to psoc object. - * - * Return: reg component object pointer - */ -static struct wlan_regulatory_psoc_priv_obj *reg_get_psoc_obj( +struct wlan_regulatory_psoc_priv_obj *reg_get_psoc_obj( struct wlan_objmgr_psoc *psoc) { struct wlan_regulatory_psoc_priv_obj *soc_reg; @@ -3059,3 +3049,45 @@ QDF_STATUS reg_set_11d_offloaded(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_SUCCESS; } + +QDF_STATUS reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, + struct cur_regdmn_info *cur_regdmn) +{ + struct wlan_objmgr_psoc *psoc; + struct wlan_regulatory_psoc_priv_obj *soc_reg; + uint16_t index; + int num_reg_dmn; + uint8_t phy_id; + + psoc = wlan_pdev_get_psoc(pdev); + soc_reg = reg_get_psoc_obj(psoc); + if (!IS_VALID_PSOC_REG_OBJ(soc_reg)) { + reg_err("soc reg component is NULL"); + return QDF_STATUS_E_INVAL; + } + + phy_id = wlan_objmgr_pdev_get_pdev_id(pdev); + cur_regdmn->regdmn_pair_id = + soc_reg->mas_chan_params[phy_id].reg_dmn_pair; + + reg_get_num_reg_dmn_pairs(&num_reg_dmn); + for (index = 0; index < num_reg_dmn; index++) { + if (g_reg_dmn_pairs[index].reg_dmn_pair_id == + cur_regdmn->regdmn_pair_id) + break; + } + + if (index == num_reg_dmn) { + reg_err("invalid regdomain"); + return QDF_STATUS_E_FAILURE; + } + + cur_regdmn->dmn_id_2g = g_reg_dmn_pairs[index].dmn_id_2g; + cur_regdmn->dmn_id_5g = g_reg_dmn_pairs[index].dmn_id_5g; + cur_regdmn->ctl_2g = regdomains_2g[cur_regdmn->dmn_id_2g].ctl_val; + cur_regdmn->ctl_5g = regdomains_5g[cur_regdmn->dmn_id_5g].ctl_val; + cur_regdmn->dfs_region = + regdomains_5g[cur_regdmn->dmn_id_5g].dfs_region; + + return QDF_STATUS_SUCCESS; +} diff --git a/umac/regulatory/core/src/reg_services.h b/umac/regulatory/core/src/reg_services.h index ed170fd477..9b0ee34f6e 100644 --- a/umac/regulatory/core/src/reg_services.h +++ b/umac/regulatory/core/src/reg_services.h @@ -67,6 +67,9 @@ - REG_CH_TO_FREQ(reg_get_chan_enum(curchan)) \ > REG_SBS_SEPARATION_THRESHOLD) +#define IS_VALID_PSOC_REG_OBJ(psoc_priv_obj) (NULL != psoc_priv_obj) +#define IS_VALID_PDEV_REG_OBJ(pdev_priv_obj) (NULL != pdev_priv_obj) + /* EEPROM setting is a country code */ #define COUNTRY_ERD_FLAG 0x8000 @@ -334,6 +337,15 @@ QDF_STATUS reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev); */ QDF_STATUS reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev); +/** + * reg_get_psoc_obj() - Provides the reg component object pointer + * @psoc: pointer to psoc object. + * + * Return: reg component object pointer + */ +struct wlan_regulatory_psoc_priv_obj *reg_get_psoc_obj( + struct wlan_objmgr_psoc *psoc); + /** * reg_set_regdb_offloaded() - set/clear regulatory offloaded flag * @@ -351,4 +363,14 @@ QDF_STATUS reg_set_regdb_offloaded(struct wlan_objmgr_psoc *psoc, */ QDF_STATUS reg_set_11d_offloaded(struct wlan_objmgr_psoc *psoc, bool val); + +/** + * reg_get_curr_regdomain() - Get current regdomain in use + * @pdev: pdev pointer + * @cur_regdmn: Current regdomain info + * + * Return: QDF status + */ +QDF_STATUS reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, + struct cur_regdmn_info *cur_regdmn); #endif diff --git a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h index 071b6da60a..86cf0d9129 100644 --- a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h +++ b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h @@ -604,4 +604,21 @@ struct cc_regdmn_s { uint8_t flags; }; +/** + * struct cur_regdmn_info: Current regulatory info + * @regdmn_pair_id: Current regdomain pair ID + * @dmn_id_2g: 2GHz regdomain ID + * @dmn_id_5g: 5GHz regdomain ID + * @ctl_2g: 2GHz CTL value + * @ctl_5g: 5GHzCTL value + * @dfs_region: dfs region + */ +struct cur_regdmn_info { + uint16_t regdmn_pair_id; + uint16_t dmn_id_2g; + uint16_t dmn_id_5g; + uint8_t ctl_2g; + uint8_t ctl_5g; + uint8_t dfs_region; +}; #endif diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index ba6e843b71..2b562f8eca 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -416,4 +416,13 @@ QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev, struct wlan_lmac_if_reg_tx_ops * wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc); +/** + * wlan_reg_get_curr_regdomain() - Get current regdomain in use + * @pdev: pdev pointer + * @cur_regdmn: Current regdomain info + * + * Return: QDF status + */ +QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, + struct cur_regdmn_info *cur_regdmn); #endif diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 6a6351f8fd..3c894d7af4 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -28,6 +28,7 @@ #include #include "../../core/src/reg_services.h" #include "../../core/src/reg_priv.h" +#include "../../core/src/reg_db_parser.h" /** * wlan_reg_get_channel_list_with_power() - Provide the channel list with power @@ -488,3 +489,9 @@ wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc) { return reg_get_psoc_tx_ops(psoc); } + +QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, + struct cur_regdmn_info *cur_regdmn) +{ + return reg_get_curr_regdomain(pdev, cur_regdmn); +}