From 7a0d8efdaa38d814881cf233e3b2baf9dcbd2832 Mon Sep 17 00:00:00 2001 From: Lincoln Tran Date: Tue, 16 Jun 2020 13:38:43 -0700 Subject: [PATCH] qcacmn: Update regulatory to use bitmap for band Setband changes require support for 6G band. Using a bitmap better supports the addition of new bands. Changes to support this include: 1. Update band_capability in regulatory pdev priv obj to be a bitmap. 2. Add API to convert between the bitmap and enum band_info. 3. Update channel list modifying function to include case for 6G band. 4. Update the get and set APIs to use uint32_t instead of band_info. Change-Id: Iff38fdd7cc540a0e471647de349d7fa57b3a8467 CRs-fixed: 2726285 --- .../regulatory/core/src/reg_build_chan_list.c | 27 ++++++++++++---- umac/regulatory/core/src/reg_priv_objs.c | 5 +-- umac/regulatory/core/src/reg_priv_objs.h | 8 +++-- .../regulatory/core/src/reg_services_common.c | 27 ++++++++++++++++ .../regulatory/core/src/reg_services_common.h | 14 +++++++++ umac/regulatory/core/src/reg_utils.c | 31 +++++-------------- umac/regulatory/core/src/reg_utils.h | 9 +++--- .../inc/reg_services_public_struct.h | 2 +- .../dispatcher/inc/wlan_reg_services_api.h | 13 ++++++++ .../dispatcher/inc/wlan_reg_ucfg_api.h | 9 +++--- .../dispatcher/src/wlan_reg_services_api.c | 7 +++++ .../dispatcher/src/wlan_reg_ucfg_api.c | 8 ++--- 12 files changed, 114 insertions(+), 46 deletions(-) diff --git a/umac/regulatory/core/src/reg_build_chan_list.c b/umac/regulatory/core/src/reg_build_chan_list.c index d1a3862bca2f..bdeaa71f074f 100644 --- a/umac/regulatory/core/src/reg_build_chan_list.c +++ b/umac/regulatory/core/src/reg_build_chan_list.c @@ -254,17 +254,21 @@ static void reg_modify_chan_list_for_indoor_channels( } /** - * reg_modify_chan_list_for_band() - Based on the input band value, either - * disable 2GHz or 5GHz channels. + * reg_modify_chan_list_for_band() - Based on the input band bitmap, either + * disable 2GHz, 5GHz, or 6GHz channels. * @chan_list: Pointer to regulatory channel list. - * @band_val: Input band value. + * @band_bitmap: Input bitmap of reg_wifi_band values. */ static void reg_modify_chan_list_for_band(struct regulatory_channel *chan_list, - enum band_info band_val) + uint32_t band_bitmap) { enum channel_enum chan_enum; - if (band_val == BAND_2G) { + if (!band_bitmap) + return; + + if (!(band_bitmap & BIT(REG_BAND_5G))) { + reg_debug("disabling 5G"); for (chan_enum = MIN_5GHZ_CHANNEL; chan_enum <= MAX_5GHZ_CHANNEL; chan_enum++) { chan_list[chan_enum].chan_flags |= @@ -273,7 +277,8 @@ static void reg_modify_chan_list_for_band(struct regulatory_channel *chan_list, } } - if (band_val == BAND_5G) { + if (!(band_bitmap & BIT(REG_BAND_2G))) { + reg_debug("disabling 2G"); for (chan_enum = MIN_24GHZ_CHANNEL; chan_enum <= MAX_24GHZ_CHANNEL; chan_enum++) { chan_list[chan_enum].chan_flags |= @@ -281,6 +286,16 @@ static void reg_modify_chan_list_for_band(struct regulatory_channel *chan_list, chan_list[chan_enum].state = CHANNEL_STATE_DISABLE; } } + + if (!(band_bitmap & BIT(REG_BAND_6G))) { + reg_debug("disabling 6G"); + for (chan_enum = MIN_6GHZ_CHANNEL; + chan_enum <= MAX_6GHZ_CHANNEL; chan_enum++) { + chan_list[chan_enum].chan_flags |= + REGULATORY_CHAN_DISABLED; + chan_list[chan_enum].state = CHANNEL_STATE_DISABLE; + } + } } /** diff --git a/umac/regulatory/core/src/reg_priv_objs.c b/umac/regulatory/core/src/reg_priv_objs.c index 4bc1db82baf7..2b8d2b3611e6 100644 --- a/umac/regulatory/core/src/reg_priv_objs.c +++ b/umac/regulatory/core/src/reg_priv_objs.c @@ -82,7 +82,8 @@ 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->band_capability = BAND_ALL; + soc_reg_obj->band_capability = (BIT(REG_BAND_2G) | BIT(REG_BAND_5G) | + BIT(REG_BAND_6G)); soc_reg_obj->enable_11d_supp = false; soc_reg_obj->indoor_chan_enabled = true; soc_reg_obj->force_ssc_disable_indoor_channel = false; @@ -212,7 +213,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 = false; - pdev_priv_obj->band_capability = psoc_priv_obj->band_capability; + pdev_priv_obj->band_capability = psoc_priv_obj->band_capability; pdev_priv_obj->indoor_chan_enabled = psoc_priv_obj->indoor_chan_enabled; pdev_priv_obj->en_chan_144 = true; diff --git a/umac/regulatory/core/src/reg_priv_objs.h b/umac/regulatory/core/src/reg_priv_objs.h index 1b0c87e16f4e..9997db91a785 100644 --- a/umac/regulatory/core/src/reg_priv_objs.h +++ b/umac/regulatory/core/src/reg_priv_objs.h @@ -91,6 +91,8 @@ struct chan_change_cbk_entry { * country update is pending for pdev (phy_id). * @world_country_pending: In this array, element[phy_id] is true if any world * country update is pending for pdev (phy_id). + * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the + * bit position value * @ignore_fw_reg_offload_ind: Ignore FW reg offload indication * @six_ghz_supported: whether 6ghz is supported */ @@ -111,7 +113,7 @@ struct wlan_regulatory_psoc_priv_obj { bool new_11d_ctry_pending[PSOC_MAX_PHY_REG_CAP]; bool world_country_pending[PSOC_MAX_PHY_REG_CAP]; bool dfs_enabled; - enum band_info band_capability; + uint32_t band_capability; bool indoor_chan_enabled; bool ignore_fw_reg_offload_ind; bool enable_11d_supp_original; @@ -147,6 +149,8 @@ struct wlan_regulatory_psoc_priv_obj { /** * struct wlan_regulatory_pdev_priv_obj - wlan regulatory pdev private object * @pdev_opened: whether pdev has been opened by application + * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the + * bit position value */ struct wlan_regulatory_pdev_priv_obj { struct regulatory_channel cur_chan_list[NUM_CHANNELS]; @@ -174,7 +178,7 @@ struct wlan_regulatory_pdev_priv_obj { qdf_freq_t range_5g_high; bool dfs_enabled; bool set_fcc_channel; - enum band_info band_capability; + uint32_t band_capability; bool indoor_chan_enabled; bool en_chan_144; uint32_t wireless_modes; diff --git a/umac/regulatory/core/src/reg_services_common.c b/umac/regulatory/core/src/reg_services_common.c index 937a36a1e79c..c4857aa1869b 100644 --- a/umac/regulatory/core/src/reg_services_common.c +++ b/umac/regulatory/core/src/reg_services_common.c @@ -3903,3 +3903,30 @@ enum reg_phymode reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, } } #endif /* CHECK_REG_PHYMODE */ + +#ifdef CONFIG_REG_CLIENT +enum band_info reg_band_bitmap_to_band_info(uint32_t band_bitmap) +{ + if ((band_bitmap & BIT(REG_BAND_2G)) && + (band_bitmap & BIT(REG_BAND_5G)) && + (band_bitmap & BIT(REG_BAND_6G))) + return BAND_ALL; + else if ((band_bitmap & BIT(REG_BAND_5G)) && + (band_bitmap & BIT(REG_BAND_6G))) + return BAND_5G; + else if ((band_bitmap & BIT(REG_BAND_2G)) && + (band_bitmap & BIT(REG_BAND_6G))) + return BAND_2G; + else if ((band_bitmap & BIT(REG_BAND_2G)) && + (band_bitmap & BIT(REG_BAND_5G))) + return BAND_ALL; + else if (band_bitmap & BIT(REG_BAND_2G)) + return BAND_2G; + else if (band_bitmap & BIT(REG_BAND_5G)) + return BAND_5G; + else if (band_bitmap & BIT(REG_BAND_6G)) + return BAND_2G; + else + return BAND_UNKNOWN; +} +#endif diff --git a/umac/regulatory/core/src/reg_services_common.h b/umac/regulatory/core/src/reg_services_common.h index 43bffe9aa085..7f96ae1a214b 100644 --- a/umac/regulatory/core/src/reg_services_common.h +++ b/umac/regulatory/core/src/reg_services_common.h @@ -1146,4 +1146,18 @@ reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, } #endif /* CHECK_REG_PHYMODE */ +#ifdef CONFIG_REG_CLIENT +/** + * reg_band_bitmap_to_band_info() - Convert the band_bitmap to a band_info enum. + * Since band_info enum only has combinations for 2G and 5G, 6G is not + * considered in this function. + * @band_bitmap: bitmap on top of reg_wifi_band of bands enabled + * + * Return: BAND_ALL if both 2G and 5G band is enabled + * BAND_2G if 2G is enabled but 5G isn't + * BAND_5G if 5G is enabled but 2G isn't + */ +enum band_info reg_band_bitmap_to_band_info(uint32_t band_bitmap); +#endif + #endif diff --git a/umac/regulatory/core/src/reg_utils.c b/umac/regulatory/core/src/reg_utils.c index 5db2727900d7..42122f13ff8f 100644 --- a/umac/regulatory/core/src/reg_utils.c +++ b/umac/regulatory/core/src/reg_utils.c @@ -456,8 +456,7 @@ bool reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev *pdev) } #endif -QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, - enum band_info band) +QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, uint32_t band_bitmap) { struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj; struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; @@ -471,8 +470,8 @@ QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_INVAL; } - if (pdev_priv_obj->band_capability == band) { - reg_info("same band %d", band); + if (pdev_priv_obj->band_capability == band_bitmap) { + reg_info("same band %d", band_bitmap); return QDF_STATUS_SUCCESS; } @@ -488,8 +487,8 @@ QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_INVAL; } - reg_info("set band_info: %d", band); - pdev_priv_obj->band_capability = band; + reg_info("set band bitmap: %d", band_bitmap); + pdev_priv_obj->band_capability = band_bitmap; reg_compute_pdev_current_chan_list(pdev_priv_obj); @@ -499,11 +498,9 @@ QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, } QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev, - enum band_info *band) + uint32_t *band_bitmap) { - struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj; struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; - struct wlan_objmgr_psoc *psoc; pdev_priv_obj = reg_get_pdev_obj(pdev); @@ -512,20 +509,8 @@ QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_E_INVAL; } - psoc = wlan_pdev_get_psoc(pdev); - if (!psoc) { - reg_err("psoc is NULL"); - return QDF_STATUS_E_INVAL; - } - - psoc_priv_obj = reg_get_psoc_obj(psoc); - if (!IS_VALID_PSOC_REG_OBJ(psoc_priv_obj)) { - reg_err("psoc reg component is NULL"); - return QDF_STATUS_E_INVAL; - } - - reg_debug("get band_info: %d", pdev_priv_obj->band_capability); - *band = pdev_priv_obj->band_capability; + reg_debug("get band bitmap: %d", pdev_priv_obj->band_capability); + *band_bitmap = pdev_priv_obj->band_capability; return QDF_STATUS_SUCCESS; } diff --git a/umac/regulatory/core/src/reg_utils.h b/umac/regulatory/core/src/reg_utils.h index dd5442e9f58d..6acb39448b1d 100644 --- a/umac/regulatory/core/src/reg_utils.h +++ b/umac/regulatory/core/src/reg_utils.h @@ -188,20 +188,20 @@ QDF_STATUS reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, /** * reg_set_band() - Sets the band information for the PDEV * @pdev: The physical dev to set the band for - * @band: The set band parameters to configure for the physical device + * @band_bitmap: The set band parameters to configure for the physical device * * Return: QDF_STATUS */ -QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, enum band_info band); +QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, uint32_t band_bitmap); /** * reg_get_band() - Get the band information for the PDEV * @pdev: The physical dev to get the band for - * @band: The band parameters of the physical device + * @band_bitmap: The band parameters of the physical device * * Return: QDF_STATUS */ -QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev, enum band_info *band); +QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev, uint32_t *band_bitmap); /** * reg_set_fcc_constraint() - Apply fcc constraints on channels 12/13 @@ -627,4 +627,5 @@ static inline void set_disable_channel_state( { } #endif + #endif diff --git a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h index 7a42996fbd81..f5bcf0fc9118 100644 --- a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h +++ b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h @@ -965,7 +965,7 @@ struct reg_config_vars { uint32_t enable_11d_support; uint32_t scan_11d_interval; uint32_t userspace_ctry_priority; - enum band_info band_capability; + uint32_t band_capability; uint32_t dfs_enabled; uint32_t indoor_chan_enabled; uint32_t force_ssc_disable_indoor_channel; diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index ad7feeddbd8a..a0856025aae2 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -1442,4 +1442,17 @@ wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, } #endif /* CHECK_REG_PHYMODE */ +#ifdef CONFIG_REG_CLIENT +/** + * wlan_reg_band_bitmap_to_band_info() - Convert the band_bitmap to a + * band_info enum + * @band_bitmap: bitmap on top of reg_wifi_band of bands enabled + * + * Return: BAND_ALL if both 2G and 5G band is enabled + * BAND_2G if 2G is enabled but 5G isn't + * BAND_5G if 5G is enabled but 2G isn't + */ +enum band_info wlan_reg_band_bitmap_to_band_info(uint32_t band_bitmap); +#endif + #endif diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h index aadfa5a5b96b..640d53644267 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h @@ -33,22 +33,23 @@ typedef QDF_STATUS (*reg_event_cb)(void *status_struct); /** * ucfg_reg_set_band() - Sets the band information for the PDEV * @pdev: The physical pdev to set the band for - * @band: The set band parameter to configure for the physical device + * @band_bitmap: The band bitmap parameter (over reg_wifi_band) to configure + * for the physical device * * Return: QDF_STATUS */ QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev, - enum band_info band); + uint32_t band_bitmap); /** * ucfg_reg_get_band() - Gets the band information for the PDEV * @pdev: The physical pdev to get the band for - * @band: The band parameter of the physical device + * @band_bitmap: The band parameter of the physical device * * Return: QDF_STATUS */ QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev, - enum band_info *band); + uint32_t *band_bitmap); /** * ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 9c919e1cf5e7..fd343a3ec649 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -1205,3 +1205,10 @@ enum reg_phymode wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev, return reg_get_max_phymode(pdev, phy_in, freq); } #endif /* CHECK_REG_PHYMODE */ + +#ifdef CONFIG_REG_CLIENT +enum band_info wlan_reg_band_bitmap_to_band_info(uint32_t band_bitmap) +{ + return reg_band_bitmap_to_band_info(band_bitmap); +} +#endif diff --git a/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c b/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c index 1ce1eab29240..0ca077df8a94 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c @@ -119,15 +119,15 @@ QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev, #ifdef CONFIG_REG_CLIENT QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev, - enum band_info band) + uint32_t band_bitmap) { - return reg_set_band(pdev, band); + return reg_set_band(pdev, band_bitmap); } QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev, - enum band_info *band) + uint32_t *band_bitmap) { - return reg_get_band(pdev, band); + return reg_get_band(pdev, band_bitmap); } /**