From 3162e0daadb4eae67080db5334fcebb0d14bb14a Mon Sep 17 00:00:00 2001 From: Amar Singhal Date: Fri, 23 Jun 2017 12:17:00 +0530 Subject: [PATCH] qcacmn: Modify reg-domain to pdev level In worst case, different pdevs can be in different countries and hence different reg-domains. Also there could be differences due to front-haul and back-haul. Change-Id: Ib9e998b5f7de4e42a1736d07e9e5602d8506e7b6 CRs-Fixed: 2048784 --- umac/dfs/dispatcher/src/wlan_dfs_lmac_api.c | 5 +- umac/dfs/dispatcher/src/wlan_dfs_utils_api.c | 2 +- umac/regulatory/core/src/reg_priv.h | 20 +- umac/regulatory/core/src/reg_services.c | 345 +++++++++--------- umac/regulatory/core/src/reg_services.h | 16 +- .../inc/reg_services_public_struct.h | 28 +- .../dispatcher/inc/wlan_reg_services_api.h | 6 +- .../dispatcher/inc/wlan_reg_ucfg_api.h | 12 +- .../dispatcher/src/wlan_reg_services_api.c | 8 +- .../dispatcher/src/wlan_reg_ucfg_api.c | 18 +- wmi/src/wmi_unified_tlv.c | 3 +- 11 files changed, 252 insertions(+), 211 deletions(-) diff --git a/umac/dfs/dispatcher/src/wlan_dfs_lmac_api.c b/umac/dfs/dispatcher/src/wlan_dfs_lmac_api.c index b0bc42ccbf55..d7a2719b169f 100644 --- a/umac/dfs/dispatcher/src/wlan_dfs_lmac_api.c +++ b/umac/dfs/dispatcher/src/wlan_dfs_lmac_api.c @@ -87,12 +87,9 @@ void lmac_dfs_disable(struct wlan_objmgr_pdev *pdev, int no_cac) int lmac_get_dfsdomain(struct wlan_objmgr_pdev *pdev) { - struct wlan_objmgr_psoc *psoc; enum dfs_reg dfsdomain; - psoc = wlan_pdev_get_psoc(pdev); - - wlan_reg_get_dfs_region(psoc, &dfsdomain); + wlan_reg_get_dfs_region(pdev, &dfsdomain); return dfsdomain; } diff --git a/umac/dfs/dispatcher/src/wlan_dfs_utils_api.c b/umac/dfs/dispatcher/src/wlan_dfs_utils_api.c index 320949c1386d..b11758d81f73 100644 --- a/umac/dfs/dispatcher/src/wlan_dfs_utils_api.c +++ b/umac/dfs/dispatcher/src/wlan_dfs_utils_api.c @@ -501,7 +501,7 @@ QDF_STATUS dfs_get_random_channel( goto random_chan_error; } - wlan_reg_get_dfs_region(psoc, &dfs_reg); + wlan_reg_get_dfs_region(pdev, &dfs_reg); chan_list = qdf_mem_malloc(num_chan * sizeof(*chan_list)); if (!chan_list) { DFS_PRINTK("%s: mem alloc failed\n", __func__); diff --git a/umac/regulatory/core/src/reg_priv.h b/umac/regulatory/core/src/reg_priv.h index eb3f31f20a8e..00e0ac1510aa 100644 --- a/umac/regulatory/core/src/reg_priv.h +++ b/umac/regulatory/core/src/reg_priv.h @@ -46,23 +46,16 @@ reg_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args) struct wlan_regulatory_psoc_priv_obj { - struct regulatory_channel mas_chan_list[NUM_CHANNELS]; + struct mas_chan_params mas_chan_params[PSOC_MAX_PHY_REG_CAP]; bool offload_enabled; uint8_t num_phy; - uint16_t reg_dmn_pair; - uint16_t ctry_code; - bool nol_chan[NUM_CHANNELS]; - char default_country[REG_ALPHA2_LEN + 1]; - char current_country[REG_ALPHA2_LEN + 1]; + char cur_country[REG_ALPHA2_LEN + 1]; + char def_country[REG_ALPHA2_LEN + 1]; enum country_src cc_src; struct wlan_objmgr_psoc *psoc_ptr; - uint32_t phybitmap; - enum dfs_reg dfs_region; bool new_user_ctry_pending; bool new_11d_ctry_pending; - char country_11d[REG_ALPHA2_LEN + 1]; bool dfs_enabled; - bool set_fcc_channel; enum band_info band_capability; bool indoor_chan_enabled; bool enable_11d_supp_original; @@ -81,6 +74,13 @@ struct wlan_regulatory_psoc_priv_obj { struct wlan_regulatory_pdev_priv_obj { struct regulatory_channel cur_chan_list[NUM_CHANNELS]; + struct regulatory_channel mas_chan_list[NUM_CHANNELS]; + char default_country[REG_ALPHA2_LEN + 1]; + char current_country[REG_ALPHA2_LEN + 1]; + uint16_t reg_dmn_pair; + uint16_t ctry_code; + enum dfs_reg dfs_region; + uint32_t phybitmap; struct wlan_objmgr_pdev *pdev_ptr; uint32_t range_2g_low; uint32_t range_2g_high; diff --git a/umac/regulatory/core/src/reg_services.c b/umac/regulatory/core/src/reg_services.c index 036e36eadf53..a6792b63a637 100644 --- a/umac/regulatory/core/src/reg_services.c +++ b/umac/regulatory/core/src/reg_services.c @@ -803,8 +803,8 @@ QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc, } qdf_mem_copy(country_code, - psoc_reg->default_country, - sizeof(psoc_reg->default_country)); + psoc_reg->def_country, + REG_ALPHA2_LEN + 1); return QDF_STATUS_SUCCESS; } @@ -830,9 +830,10 @@ QDF_STATUS reg_set_default_country(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_E_INVAL; } - reg_info("setting default_country:n%s", country); - qdf_mem_copy(psoc_reg->default_country, - country, sizeof(psoc_reg->default_country)); + reg_info("setting default_country: %s", country); + + qdf_mem_copy(psoc_reg->def_country, + country, REG_ALPHA2_LEN + 1); return QDF_STATUS_SUCCESS; } @@ -853,13 +854,12 @@ QDF_STATUS reg_set_country(struct wlan_objmgr_pdev *pdev, psoc = wlan_pdev_get_psoc(pdev); psoc_reg = reg_get_psoc_obj(psoc); - if (!IS_VALID_PSOC_REG_OBJ(psoc_reg)) { reg_err("psoc reg component is NULL"); return QDF_STATUS_E_INVAL; } - if (!qdf_mem_cmp(psoc_reg->current_country, + if (!qdf_mem_cmp(psoc_reg->cur_country, country, REG_ALPHA2_LEN)) { reg_err("country is not different"); return QDF_STATUS_E_INVAL; @@ -895,10 +895,10 @@ QDF_STATUS reg_reset_country(struct wlan_objmgr_psoc *psoc) return QDF_STATUS_E_INVAL; } - reg_info("re-setting current_country to default"); - qdf_mem_copy(psoc_reg->current_country, - psoc_reg->default_country, - sizeof(psoc_reg->current_country)); + reg_info("re-setting user country to default"); + qdf_mem_copy(psoc_reg->cur_country, + psoc_reg->def_country, + REG_ALPHA2_LEN + 1); return QDF_STATUS_SUCCESS; } @@ -909,18 +909,18 @@ QDF_STATUS reg_reset_country(struct wlan_objmgr_psoc *psoc) * * Return: None */ -void reg_get_dfs_region(struct wlan_objmgr_psoc *psoc, +void reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg *dfs_reg) { - struct wlan_regulatory_psoc_priv_obj *soc_reg; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; - soc_reg = reg_get_psoc_obj(psoc); - if (!IS_VALID_PSOC_REG_OBJ(soc_reg)) { - reg_err("psoc reg component is NULL"); + pdev_priv_obj = reg_get_pdev_obj(pdev); + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("reg component pdev priv is NULL"); return; } - *dfs_reg = soc_reg->dfs_region; + *dfs_reg = pdev_priv_obj->dfs_region; } /** @@ -929,17 +929,18 @@ void reg_get_dfs_region(struct wlan_objmgr_psoc *psoc, * * Return: None */ -void reg_set_dfs_region(struct wlan_objmgr_psoc *psoc, +void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg dfs_reg) { - struct wlan_regulatory_psoc_priv_obj *soc_reg; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; - soc_reg = reg_get_psoc_obj(psoc); - if (!IS_VALID_PSOC_REG_OBJ(soc_reg)) { + pdev_priv_obj = reg_get_pdev_obj(pdev); + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { reg_err("psoc reg component is NULL"); return; } - soc_reg->dfs_region = dfs_reg; + + pdev_priv_obj->dfs_region = dfs_reg; } QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, @@ -1342,9 +1343,9 @@ static void modify_chan_list_for_indoor_channels(struct regulatory_channel if (REGULATORY_CHAN_INDOOR_ONLY & chan_list[chan_enum].chan_flags) { chan_list[chan_enum].state = - CHANNEL_STATE_PASSIVE; + CHANNEL_STATE_DISABLE; chan_list[chan_enum].chan_flags |= - REGULATORY_CHAN_NO_IR; + REGULATORY_CHAN_DISABLED; } } } @@ -1468,20 +1469,37 @@ modify_chan_list_for_freq_range(struct regulatory_channel *chan_list, } } -static void init_pdev_chan_list(struct wlan_regulatory_psoc_priv_obj - *psoc_priv_obj, - struct wlan_regulatory_pdev_priv_obj - *pdev_priv_obj) +static void init_pdev_mas_chan_list(struct wlan_regulatory_pdev_priv_obj + *pdev_priv_obj, + struct mas_chan_params + *mas_chan_params) { - qdf_mem_copy(pdev_priv_obj->cur_chan_list, - psoc_priv_obj->mas_chan_list, + qdf_mem_copy(pdev_priv_obj->mas_chan_list, + mas_chan_params->mas_chan_list, NUM_CHANNELS * sizeof(struct regulatory_channel)); + + pdev_priv_obj->dfs_region = mas_chan_params->dfs_region; + + pdev_priv_obj->phybitmap = mas_chan_params->phybitmap; + + pdev_priv_obj->reg_dmn_pair = mas_chan_params->reg_dmn_pair; + pdev_priv_obj->ctry_code = mas_chan_params->ctry_code; + + qdf_mem_copy(pdev_priv_obj->default_country, + mas_chan_params->default_country, REG_ALPHA2_LEN + 1); + + qdf_mem_copy(pdev_priv_obj->current_country, + mas_chan_params->current_country, REG_ALPHA2_LEN + 1); } static void compute_pdev_current_chan_list(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj) { + qdf_mem_copy(pdev_priv_obj->cur_chan_list, + pdev_priv_obj->mas_chan_list, + NUM_CHANNELS * sizeof(struct regulatory_channel)); + modify_chan_list_for_freq_range(pdev_priv_obj->cur_chan_list, pdev_priv_obj->range_2g_low, pdev_priv_obj->range_2g_high, @@ -1782,6 +1800,7 @@ static void reg_propagate_mas_chan_list_to_pdev(struct wlan_objmgr_psoc *psoc, struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj; struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; enum direction *dir = arg; + uint32_t pdev_id; struct wlan_lmac_if_reg_tx_ops *reg_tx_ops; psoc_priv_obj = (struct wlan_regulatory_psoc_priv_obj *) @@ -1800,8 +1819,9 @@ static void reg_propagate_mas_chan_list_to_pdev(struct wlan_objmgr_psoc *psoc, return; } - init_pdev_chan_list(psoc_priv_obj, - pdev_priv_obj); + pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); + init_pdev_mas_chan_list(pdev_priv_obj, + &psoc_priv_obj->mas_chan_params[pdev_id]); compute_pdev_current_chan_list(pdev_priv_obj); @@ -1855,18 +1875,13 @@ QDF_STATUS reg_process_master_chan_list(struct cur_regulatory_info struct wlan_lmac_if_reg_tx_ops *tx_ops; struct wlan_objmgr_psoc *psoc; enum channel_enum chan_enum; - QDF_STATUS status; wlan_objmgr_ref_dbgid dbg_id; enum direction dir; + uint8_t phy_id; + struct wlan_objmgr_pdev *pdev; reg_debug("process reg master chan list"); - if (regulat_info->status_code == REG_CURRENT_ALPHA2_NOT_FOUND) { - reg_err("current country not present in regdb"); - soc_reg->new_user_ctry_pending = false; - return QDF_STATUS_SUCCESS; - } - psoc = regulat_info->psoc; soc_reg = reg_get_psoc_obj(psoc); @@ -1875,7 +1890,20 @@ QDF_STATUS reg_process_master_chan_list(struct cur_regulatory_info return QDF_STATUS_E_FAILURE; } - mas_chan_list = soc_reg->mas_chan_list; + tx_ops = reg_get_psoc_tx_ops(psoc); + if (tx_ops->is_regdb_offloaded) + soc_reg->offload_enabled = + tx_ops->is_regdb_offloaded(psoc); + else + soc_reg->offload_enabled = false; + if (tx_ops->is_11d_offloaded) + soc_reg->is_11d_offloaded = + tx_ops->is_11d_offloaded(psoc); + else + soc_reg->is_11d_offloaded = false; + + phy_id = regulat_info->phy_id; + mas_chan_list = soc_reg->mas_chan_params[phy_id].mas_chan_list; for (chan_enum = 0; chan_enum < NUM_CHANNELS; chan_enum++) { @@ -1890,27 +1918,20 @@ QDF_STATUS reg_process_master_chan_list(struct cur_regulatory_info mas_chan_list[chan_enum].nol_chan = false; } - tx_ops = reg_get_psoc_tx_ops(psoc); - if (tx_ops->is_regdb_offloaded) - soc_reg->offload_enabled = - tx_ops->is_regdb_offloaded(psoc); - else - soc_reg->offload_enabled = false; - - if (tx_ops->is_11d_offloaded) - soc_reg->is_11d_offloaded = - tx_ops->is_11d_offloaded(psoc); - else - soc_reg->is_11d_offloaded = false; - - soc_reg->phybitmap = regulat_info->phybitmap; - soc_reg->dfs_region = regulat_info->dfs_region; soc_reg->num_phy = regulat_info->num_phy; - soc_reg->ctry_code = regulat_info->ctry_code; - soc_reg->reg_dmn_pair = regulat_info->reg_dmn_pair; - qdf_mem_copy(soc_reg->default_country, regulat_info->alpha2, + soc_reg->mas_chan_params[phy_id].phybitmap = + regulat_info->phybitmap; + soc_reg->mas_chan_params[phy_id].dfs_region = + regulat_info->dfs_region; + soc_reg->mas_chan_params[phy_id].ctry_code = + regulat_info->ctry_code; + soc_reg->mas_chan_params[phy_id].reg_dmn_pair = + regulat_info->reg_dmn_pair; + qdf_mem_copy(soc_reg->mas_chan_params[phy_id].current_country, + regulat_info->alpha2, REG_ALPHA2_LEN + 1); - qdf_mem_copy(soc_reg->current_country, regulat_info->alpha2, + qdf_mem_copy(soc_reg->cur_country, + regulat_info->alpha2, REG_ALPHA2_LEN + 1); min_bw_2g = regulat_info->min_bw_2g; @@ -1944,17 +1965,22 @@ QDF_STATUS reg_process_master_chan_list(struct cur_regulatory_info soc_reg->cc_src = SOURCE_DRIVER; if (soc_reg->new_user_ctry_pending == true) { - soc_reg->new_user_ctry_pending = false; soc_reg->cc_src = SOURCE_USERSPACE; soc_reg->user_ctry_set = true; reg_debug("new country code is set"); reg_run_11d_state_machine(psoc); } else if (soc_reg->new_11d_ctry_pending == true) { - soc_reg->new_11d_ctry_pending = false; soc_reg->cc_src = SOURCE_11D; soc_reg->user_ctry_set = false; + } else { + qdf_mem_copy(soc_reg->mas_chan_params[phy_id].default_country, + regulat_info->alpha2, + REG_ALPHA2_LEN + 1); + qdf_mem_copy(soc_reg->def_country, + regulat_info->alpha2, + REG_ALPHA2_LEN + 1); } if (soc_reg->offload_enabled) { @@ -1965,17 +1991,13 @@ QDF_STATUS reg_process_master_chan_list(struct cur_regulatory_info dir = SOUTHBOUND; } - status = wlan_objmgr_psoc_try_get_ref(psoc, dbg_id); - if (QDF_IS_STATUS_ERROR(status)) { - reg_err("error taking psoc ref cnt"); - return status; + pdev = wlan_objmgr_get_pdev_by_id(psoc, phy_id, dbg_id); + if (pdev != NULL) { + reg_propagate_mas_chan_list_to_pdev(psoc, pdev, &dir); + wlan_objmgr_pdev_release_ref(pdev, dbg_id); } - status = wlan_objmgr_iterate_obj_list(psoc, WLAN_PDEV_OP, - reg_propagate_mas_chan_list_to_pdev, - &dir, 1, dbg_id); - wlan_objmgr_psoc_release_ref(psoc, dbg_id); - return status; + return QDF_STATUS_SUCCESS; } /** @@ -1996,6 +2018,7 @@ QDF_STATUS wlan_regulatory_psoc_obj_created_notification( enum channel_enum chan_enum; QDF_STATUS status; uint8_t i; + uint8_t pdev_cnt; soc_reg_obj = qdf_mem_malloc(sizeof(*soc_reg_obj)); if (NULL == soc_reg_obj) { @@ -2006,7 +2029,6 @@ QDF_STATUS wlan_regulatory_psoc_obj_created_notification( soc_reg_obj->offload_enabled = false; soc_reg_obj->psoc_ptr = psoc; soc_reg_obj->dfs_enabled = true; - soc_reg_obj->set_fcc_channel = false; soc_reg_obj->band_capability = BAND_ALL; soc_reg_obj->enable_11d_supp = false; soc_reg_obj->indoor_chan_enabled = true; @@ -2018,19 +2040,22 @@ QDF_STATUS wlan_regulatory_psoc_obj_created_notification( qdf_spinlock_create(&soc_reg_obj->cbk_list_lock); - mas_chan_list = soc_reg_obj->mas_chan_list; + for (pdev_cnt = 0; pdev_cnt < PSOC_MAX_PHY_REG_CAP; pdev_cnt++) { + mas_chan_list = + soc_reg_obj->mas_chan_params[pdev_cnt].mas_chan_list; - for (chan_enum = 0; chan_enum < NUM_CHANNELS; - chan_enum++) { - mas_chan_list[chan_enum].chan_num = - channel_map[chan_enum].chan_num; - mas_chan_list[chan_enum].center_freq = - channel_map[chan_enum].center_freq; - mas_chan_list[chan_enum].chan_flags |= - REGULATORY_CHAN_DISABLED; - mas_chan_list[chan_enum].state = - CHANNEL_STATE_DISABLE; - mas_chan_list[chan_enum].nol_chan = false; + for (chan_enum = 0; chan_enum < NUM_CHANNELS; + chan_enum++) { + mas_chan_list[chan_enum].chan_num = + channel_map[chan_enum].chan_num; + mas_chan_list[chan_enum].center_freq = + channel_map[chan_enum].center_freq; + mas_chan_list[chan_enum].chan_flags |= + REGULATORY_CHAN_DISABLED; + mas_chan_list[chan_enum].state = + CHANNEL_STATE_DISABLE; + mas_chan_list[chan_enum].nol_chan = false; + } } status = wlan_objmgr_psoc_component_obj_attach(psoc, @@ -2118,9 +2143,6 @@ QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, reg_info("setting band_info: %d", band); pdev_priv_obj->band_capability = band; - init_pdev_chan_list(psoc_priv_obj, - pdev_priv_obj); - compute_pdev_current_chan_list(pdev_priv_obj); status = send_scheduler_msg_sb(psoc, pdev); @@ -2162,9 +2184,6 @@ QDF_STATUS reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_INVAL; } - init_pdev_chan_list(psoc_priv_obj, - pdev_priv_obj); - compute_pdev_current_chan_list(pdev_priv_obj); status = send_scheduler_msg_sb(psoc, pdev); @@ -2207,9 +2226,6 @@ QDF_STATUS reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, pdev_priv_obj->dfs_enabled = enable; - init_pdev_chan_list(psoc_priv_obj, - pdev_priv_obj); - compute_pdev_current_chan_list(pdev_priv_obj); status = send_scheduler_msg_sb(psoc, pdev); @@ -2261,7 +2277,7 @@ QDF_STATUS wlan_regulatory_pdev_obj_created_notification( pdev_priv_obj->pdev_ptr = pdev; pdev_priv_obj->dfs_enabled = psoc_priv_obj->dfs_enabled; - pdev_priv_obj->set_fcc_channel = psoc_priv_obj->set_fcc_channel; + pdev_priv_obj->set_fcc_channel = false; pdev_priv_obj->band_capability = psoc_priv_obj->band_capability; pdev_priv_obj->indoor_chan_enabled = psoc_priv_obj->indoor_chan_enabled; @@ -2297,8 +2313,8 @@ QDF_STATUS wlan_regulatory_pdev_obj_created_notification( pdev_priv_obj->range_5g_high = range_5g_high; pdev_priv_obj->wireless_modes = reg_cap_ptr->wireless_modes; - init_pdev_chan_list(psoc_priv_obj, - pdev_priv_obj); + init_pdev_mas_chan_list(pdev_priv_obj, + &psoc_priv_obj->mas_chan_params[pdev_id]); compute_pdev_current_chan_list(pdev_priv_obj); @@ -2517,28 +2533,23 @@ void reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, { enum channel_enum chan_enum; struct regulatory_channel *mas_chan_list; - struct wlan_objmgr_psoc *psoc; - struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; uint16_t i; - enum direction dir; - QDF_STATUS status; if (!num_chan || !chan_list) { reg_err("chan_list or num_ch is NULL"); return; } - psoc = wlan_pdev_get_psoc(pdev); + pdev_priv_obj = wlan_objmgr_pdev_get_comp_private_obj(pdev, + WLAN_UMAC_COMP_REGULATORY); - psoc_priv_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc, - WLAN_UMAC_COMP_REGULATORY); - - if (NULL == psoc_priv_obj) { + if (NULL == pdev_priv_obj) { reg_err("reg psoc private obj is NULL"); return; } - mas_chan_list = psoc_priv_obj->mas_chan_list; + mas_chan_list = pdev_priv_obj->mas_chan_list; for (i = 0; i < num_chan; i++) { chan_enum = reg_get_chan_enum(chan_list[i]); if (chan_enum == INVALID_CHANNEL) { @@ -2549,17 +2560,7 @@ void reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, mas_chan_list[chan_enum].nol_chan = nol_chan; } - dir = SOUTHBOUND; - - status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_REGULATORY_SB_ID); - if (QDF_IS_STATUS_ERROR(status)) { - reg_err("error taking psoc ref cnt"); - return; - } - status = wlan_objmgr_iterate_obj_list(psoc, WLAN_PDEV_OP, - reg_propagate_mas_chan_list_to_pdev, - &dir, 1, WLAN_REGULATORY_SB_ID); - wlan_objmgr_psoc_release_ref(psoc, WLAN_REGULATORY_SB_ID); + compute_pdev_current_chan_list(pdev_priv_obj); } static void reg_change_pdev_for_config(struct wlan_objmgr_psoc *psoc, @@ -2591,9 +2592,6 @@ static void reg_change_pdev_for_config(struct wlan_objmgr_psoc *psoc, psoc_priv_obj->indoor_chan_enabled; pdev_priv_obj->band_capability = psoc_priv_obj->band_capability; - init_pdev_chan_list(psoc_priv_obj, - pdev_priv_obj); - compute_pdev_current_chan_list(pdev_priv_obj); send_scheduler_msg_sb(psoc, pdev); @@ -2662,15 +2660,16 @@ bool reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc) } void reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, - struct regulatory_channel *reg_channels, - uint8_t *alpha2, - enum dfs_reg dfs_region) + struct regulatory_channel *reg_channels, + uint8_t *alpha2, + enum dfs_reg dfs_region) { struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj; QDF_STATUS status; uint32_t count; enum direction dir; + uint32_t pdev_cnt; psoc_priv_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_UMAC_COMP_REGULATORY); @@ -2680,10 +2679,10 @@ void reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, return; } - psoc_priv_obj->dfs_region = dfs_region; - qdf_mem_copy(psoc_priv_obj->current_country, alpha2, + qdf_mem_copy(psoc_priv_obj->cur_country, alpha2, REG_ALPHA2_LEN); + for (count = 0; count < NUM_CHANNELS; count++) { reg_channels[count].chan_num = channel_map[count].chan_num; @@ -2692,12 +2691,17 @@ void reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, reg_channels[count].nol_chan = false; } - qdf_mem_copy(psoc_priv_obj->mas_chan_list, - reg_channels, - NUM_CHANNELS * sizeof(struct regulatory_channel)); + for (pdev_cnt = 0; pdev_cnt < PSOC_MAX_PHY_REG_CAP; pdev_cnt++) { + qdf_mem_copy(psoc_priv_obj->mas_chan_params[pdev_cnt]. + mas_chan_list, + reg_channels, + NUM_CHANNELS * sizeof(struct regulatory_channel)); + + psoc_priv_obj->mas_chan_params[pdev_cnt].dfs_region = + dfs_region; + } dir = SOUTHBOUND; - status = wlan_objmgr_psoc_try_get_ref(psoc, WLAN_REGULATORY_SB_ID); if (QDF_IS_STATUS_ERROR(status)) { reg_err("error taking psoc ref cnt"); @@ -2772,41 +2776,38 @@ enum country_src reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc, struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj; psoc_priv_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc, - WLAN_UMAC_COMP_REGULATORY); + WLAN_UMAC_COMP_REGULATORY); if (NULL == psoc_priv_obj) { reg_err("reg psoc private obj is NULL"); - return SOURCE_UNKNOWN; } - qdf_mem_copy(alpha2, psoc_priv_obj->current_country, + qdf_mem_copy(alpha2, psoc_priv_obj->cur_country, REG_ALPHA2_LEN + 1); return psoc_priv_obj->cc_src; } -QDF_STATUS reg_program_default_cc(struct wlan_objmgr_psoc *psoc, +QDF_STATUS reg_program_default_cc(struct wlan_objmgr_pdev *pdev, uint16_t regdmn) { - struct wlan_regulatory_psoc_priv_obj *soc_reg; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; struct cur_regulatory_info *reg_info; uint16_t cc = -1; uint16_t country_index = -1, regdmn_pair = -1; + struct wlan_objmgr_psoc *psoc; QDF_STATUS err; - soc_reg = (struct wlan_regulatory_psoc_priv_obj *) - wlan_objmgr_psoc_get_comp_private_obj(psoc, - WLAN_UMAC_COMP_REGULATORY); + pdev_priv_obj = (struct wlan_regulatory_pdev_priv_obj *) + wlan_objmgr_pdev_get_comp_private_obj(pdev, + WLAN_UMAC_COMP_REGULATORY); - if (NULL == soc_reg) { + if (NULL == pdev_priv_obj) { reg_err("reg soc is NULL"); return QDF_STATUS_E_FAILURE; } - if (soc_reg->offload_enabled) - return QDF_STATUS_E_FAILURE; - reg_info = (struct cur_regulatory_info *)qdf_mem_malloc (sizeof(struct cur_regulatory_info)); if (reg_info == NULL) { @@ -2814,7 +2815,14 @@ QDF_STATUS reg_program_default_cc(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_E_NOMEM; } + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + reg_err("psoc is NULL"); + return QDF_STATUS_E_INVAL; + } + reg_info->psoc = psoc; + reg_info->phy_id = wlan_objmgr_pdev_get_pdev_id(pdev); if (regdmn == 0) { reg_get_default_country(®dmn); @@ -2837,7 +2845,7 @@ QDF_STATUS reg_program_default_cc(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_E_FAILURE; } - soc_reg->ctry_code = cc; + pdev_priv_obj->ctry_code = cc; } else { reg_get_rdpair_from_regdmn_id(regdmn, @@ -2852,7 +2860,7 @@ QDF_STATUS reg_program_default_cc(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_E_FAILURE; } - soc_reg->reg_dmn_pair = regdmn; + pdev_priv_obj->reg_dmn_pair = regdmn; } reg_info->offload_enabled = false; @@ -2865,20 +2873,21 @@ 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) +QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev, + struct cc_regdmn_s *rd) { struct cur_regulatory_info *reg_info; - struct wlan_regulatory_psoc_priv_obj *soc_reg; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; uint16_t country_index = -1, regdmn_pair = -1; + struct wlan_objmgr_psoc *psoc; QDF_STATUS err; - soc_reg = (struct wlan_regulatory_psoc_priv_obj *) - wlan_objmgr_psoc_get_comp_private_obj(psoc, - WLAN_UMAC_COMP_REGULATORY); + pdev_priv_obj = (struct wlan_regulatory_pdev_priv_obj *) + wlan_objmgr_pdev_get_comp_private_obj(pdev, + WLAN_UMAC_COMP_REGULATORY); - if (NULL == soc_reg) { - reg_err("soc_reg is NULL"); + if (NULL == pdev_priv_obj) { + reg_err(" pdev priv obj is NULL"); return QDF_STATUS_E_FAILURE; } @@ -2889,7 +2898,14 @@ QDF_STATUS reg_program_chan_list(struct wlan_objmgr_psoc *psoc, return QDF_STATUS_E_NOMEM; } + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + reg_err("psoc is NULL"); + return QDF_STATUS_E_INVAL; + } + reg_info->psoc = psoc; + reg_info->phy_id = wlan_objmgr_pdev_get_pdev_id(pdev); if (rd->flags == CC_IS_SET) { reg_get_rdpair_from_country_code(rd->cc.country_code, @@ -2938,39 +2954,40 @@ bool reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc) return psoc_priv_obj->enable_11d_supp; } -QDF_STATUS reg_get_current_cc(struct wlan_objmgr_psoc *psoc, - struct cc_regdmn_s *rd) +QDF_STATUS reg_get_current_cc(struct wlan_objmgr_pdev *pdev, + struct cc_regdmn_s *rd) { - struct wlan_regulatory_psoc_priv_obj *soc_reg; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; - soc_reg = (struct wlan_regulatory_psoc_priv_obj *) - wlan_objmgr_psoc_get_comp_private_obj(psoc, - WLAN_UMAC_COMP_REGULATORY); + pdev_priv_obj = (struct wlan_regulatory_pdev_priv_obj *) + wlan_objmgr_pdev_get_comp_private_obj(pdev, + WLAN_UMAC_COMP_REGULATORY); - if (NULL == soc_reg) { - reg_err("reg soc is NULL"); + if (NULL == pdev_priv_obj) { + reg_err("reg pdev priv is NULL"); return QDF_STATUS_E_FAILURE; } if (rd->flags == CC_IS_SET) { - rd->cc.country_code = soc_reg->ctry_code; + rd->cc.country_code = pdev_priv_obj->ctry_code; } else if (rd->flags == ALPHA_IS_SET) { - qdf_mem_copy(rd->cc.alpha, soc_reg->current_country, - sizeof(rd->cc.alpha)); + qdf_mem_copy(rd->cc.alpha, pdev_priv_obj->current_country, + sizeof(rd->cc.alpha)); } else if (rd->flags == REGDMN_IS_SET) { - rd->cc.regdmn_id = soc_reg->reg_dmn_pair; + rd->cc.regdmn_id = pdev_priv_obj->reg_dmn_pair; } return QDF_STATUS_SUCCESS; } QDF_STATUS reg_save_new_11d_country(struct wlan_objmgr_psoc *psoc, - uint8_t *country) + uint8_t *country) { struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj; psoc_priv_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc, - WLAN_UMAC_COMP_REGULATORY); + WLAN_UMAC_COMP_REGULATORY); + if (!psoc_priv_obj) { reg_err("reg psoc private obj is NULL"); diff --git a/umac/regulatory/core/src/reg_services.h b/umac/regulatory/core/src/reg_services.h index 47c74912b255..4c2eb1dcd866 100644 --- a/umac/regulatory/core/src/reg_services.h +++ b/umac/regulatory/core/src/reg_services.h @@ -187,7 +187,7 @@ QDF_STATUS reg_reset_country(struct wlan_objmgr_psoc *psoc); QDF_STATUS reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, bool enable); -void reg_get_dfs_region(struct wlan_objmgr_psoc *psoc, +void reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg *dfs_reg); uint32_t reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, @@ -199,7 +199,7 @@ uint32_t reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, uint16_t reg_get_bw_value(enum phy_ch_width bw); -void reg_set_dfs_region(struct wlan_objmgr_psoc *psoc, +void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg dfs_reg); QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, @@ -249,8 +249,8 @@ 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); +QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev, + 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); @@ -290,11 +290,11 @@ void reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, uint8_t *alpha2, enum dfs_reg dfs_region); -QDF_STATUS reg_program_default_cc(struct wlan_objmgr_psoc *psoc, - uint16_t regdmn); +QDF_STATUS reg_program_default_cc(struct wlan_objmgr_pdev *pdev, + uint16_t regdmn); -QDF_STATUS reg_get_current_cc(struct wlan_objmgr_psoc *psoc, - struct cc_regdmn_s *rd); +QDF_STATUS reg_get_current_cc(struct wlan_objmgr_pdev *pdev, + struct cc_regdmn_s *rd); QDF_STATUS reg_get_curr_band(struct wlan_objmgr_pdev *pdev, enum band_info *band); diff --git a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h index 3f961a55c146..d1a0f086b110 100644 --- a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h +++ b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h @@ -457,8 +457,13 @@ struct cur_reg_rule { /** * struct cur_regulatory_info * @psoc: psoc ptr - * @cc_setting_code: cc setting regdb value + * @status_code: status value + * @num_phy: number of phy + * @phy_id: phy id + * @reg_dmn_pair: reg domain pair + * @ctry_code: country code * @alpha2: country alpha2 + * @offload_enabled: offload enabled * @dfs_reg: dfs region * @phybitmap: phy bit map * @min_bw_2g: minimum 2G bw @@ -474,6 +479,7 @@ struct cur_regulatory_info { struct wlan_objmgr_psoc *psoc; enum cc_setting_code status_code; uint8_t num_phy; + uint8_t phy_id; uint16_t reg_dmn_pair; uint16_t ctry_code; uint8_t alpha2[REG_ALPHA2_LEN + 1]; @@ -548,4 +554,24 @@ enum direction { SOUTHBOUND, }; +/** + * struct mas_chan_params + * @dfs_region: dfs region + * @phybitmap: phybitmap + * @mas_chan_list: master chan list + * @default_country: default country + * @current_country: current country + * @reg_dmn_pair: reg domain pair + * @ctry_code: country code + */ +struct mas_chan_params { + enum dfs_reg dfs_region; + uint32_t phybitmap; + struct regulatory_channel mas_chan_list[NUM_CHANNELS]; + char default_country[REG_ALPHA2_LEN + 1]; + char current_country[REG_ALPHA2_LEN + 1]; + uint16_t reg_dmn_pair; + uint16_t ctry_code; +}; + #endif diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index 793ec02f99e1..c7ce864f300c 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -129,7 +129,7 @@ void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, * * Return: None */ -void wlan_reg_get_dfs_region(struct wlan_objmgr_psoc *psoc, +void wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg *dfs_reg); /** @@ -174,12 +174,12 @@ enum channel_state wlan_reg_get_bonded_channel_state( /** * wlan_reg_set_dfs_region() - set the dfs region - * @psoc: psoc ptr + * @pdev: pdev ptr * @dfs_reg: dfs region * * Return: void */ -void wlan_reg_set_dfs_region(struct wlan_objmgr_psoc *psoc, +void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg dfs_reg); /** diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h index 77a688a82c07..065be747f851 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h @@ -116,14 +116,14 @@ QDF_STATUS ucfg_reg_unregister_event_handler(uint8_t vdev_id, reg_event_cb cb, void *arg); 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_default_cc(struct wlan_objmgr_pdev *pdev, + uint16_t regdmn); -QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_psoc *psoc, - struct cc_regdmn_s *rd); +QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev, + struct cc_regdmn_s *rd); -QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_psoc *psoc, - struct cc_regdmn_s *rd); +QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev, + struct cc_regdmn_s *rd); /** * ucfg_reg_set_config_vars () - Set the config vars in reg component diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 3a8d7d3bccc4..01f442513a18 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -133,13 +133,13 @@ void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, * * Return: None */ -void wlan_reg_get_dfs_region(struct wlan_objmgr_psoc *psoc, +void wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg *dfs_reg) { /* * Get the current dfs region */ - reg_get_dfs_region(psoc, dfs_reg); + reg_get_dfs_region(pdev, dfs_reg); } uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, @@ -202,10 +202,10 @@ enum channel_state wlan_reg_get_bonded_channel_state( * * Return: None */ -void wlan_reg_set_dfs_region(struct wlan_objmgr_psoc *psoc, +void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg dfs_reg) { - reg_set_dfs_region(psoc, dfs_reg); + reg_set_dfs_region(pdev, dfs_reg); } QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, diff --git a/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c b/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c index 0d9f0327241b..0757a4161e5f 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c @@ -70,22 +70,22 @@ void ucfg_reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc, reg_program_mas_chan_list(psoc, reg_channels, alpha2, dfs_region); } -QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_psoc *psoc, - uint16_t regdmn) +QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev, + uint16_t regdmn) { - return reg_program_default_cc(psoc, regdmn); + return reg_program_default_cc(pdev, regdmn); } -QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_psoc *psoc, - struct cc_regdmn_s *rd) +QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev, + struct cc_regdmn_s *rd) { - return reg_program_chan_list(psoc, rd); + return reg_program_chan_list(pdev, rd); } -QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_psoc *psoc, - struct cc_regdmn_s *rd) +QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev, + struct cc_regdmn_s *rd) { - return reg_get_current_cc(psoc, rd); + return reg_get_current_cc(pdev, rd); } /** diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 6f2a6841c4f2..d5a4d1ae7a6a 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -17800,11 +17800,12 @@ static QDF_STATUS extract_reg_chan_list_update_event_tlv( reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules; reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules; qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2), - REG_ALPHA2_LEN); + REG_ALPHA2_LEN); reg_info->dfs_region = chan_list_event_hdr->dfs_region; reg_info->phybitmap = chan_list_event_hdr->phybitmap; reg_info->offload_enabled = true; reg_info->num_phy = chan_list_event_hdr->num_phy; + reg_info->phy_id = chan_list_event_hdr->phy_id; reg_info->ctry_code = chan_list_event_hdr->country_id; reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code; if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)