From dcec4534a1c748e479707e6150716bac289a0348 Mon Sep 17 00:00:00 2001 From: Vignesh U Date: Wed, 29 Dec 2021 11:28:01 +0530 Subject: [PATCH] qcacmn: Based on input 6g power mode find if freq is enabled or not Add the new sets of APIs that checks if given freq is enabled on given power mode's channel list. Also, remove reg_is_chan_disabled() and replace the callers with reg_is_chan_disabled_and_not_nol(). Change-Id: I65ee6b8dde629b0e31b050b478300a8ba5ae5b4a --- .../regulatory/core/src/reg_build_chan_list.c | 15 +-- .../regulatory/core/src/reg_services_common.c | 114 ++++++++++++++++++ .../regulatory/core/src/reg_services_common.h | 36 ++++++ .../dispatcher/inc/wlan_reg_services_api.h | 35 ++++++ .../dispatcher/src/wlan_reg_services_api.c | 14 +++ 5 files changed, 200 insertions(+), 14 deletions(-) diff --git a/umac/regulatory/core/src/reg_build_chan_list.c b/umac/regulatory/core/src/reg_build_chan_list.c index d9bf5abfbe..e7fbc8ff1e 100644 --- a/umac/regulatory/core/src/reg_build_chan_list.c +++ b/umac/regulatory/core/src/reg_build_chan_list.c @@ -2170,19 +2170,6 @@ reg_fill_best_pwr_mode(struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj, } #endif -/** - * reg_is_chan_disabled() - Check if the input regulatory channel entry - * is disabled - * @chan: Pointer to chan - * - * Return: bool - */ -static bool reg_is_chan_disabled(struct regulatory_channel *chan) -{ - return ((chan->state == CHANNEL_STATE_DISABLE) || - (chan->chan_flags & REGULATORY_CHAN_DISABLED)); -} - #ifdef CONFIG_AFC_SUPPORT /** * reg_assign_afc_chan_entry_to_mas_chan() - Assign the AFC channel list entry @@ -2265,7 +2252,7 @@ static void reg_update_sup_ch_entry_for_mode( return; } - if (reg_is_chan_disabled(&temp_reg_chan)) + if (reg_is_chan_disabled_and_not_nol(&temp_reg_chan)) return; super_chan_list = pdev_priv_obj->super_chan_list; diff --git a/umac/regulatory/core/src/reg_services_common.c b/umac/regulatory/core/src/reg_services_common.c index 553bc4b096..75bceb72a7 100644 --- a/umac/regulatory/core/src/reg_services_common.c +++ b/umac/regulatory/core/src/reg_services_common.c @@ -6759,3 +6759,117 @@ bool reg_is_state_allowed(enum channel_state chan_state) return !((chan_state == CHANNEL_STATE_INVALID) || (chan_state == CHANNEL_STATE_DISABLE)); } + +static bool +reg_is_freq_idx_enabled_on_cur_chan_list(struct wlan_regulatory_pdev_priv_obj + *pdev_priv_obj, + enum channel_enum freq_idx) +{ + struct regulatory_channel *cur_chan_list; + + if (freq_idx >= NUM_CHANNELS) + return false; + + cur_chan_list = pdev_priv_obj->cur_chan_list; + + return !reg_is_chan_disabled_and_not_nol(&cur_chan_list[freq_idx]); +} + +static inline bool +reg_is_supr_entry_mode_disabled(const struct super_chan_info *super_chan_ent, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + return ((super_chan_ent->chan_flags_arr[in_6g_pwr_mode] & + REGULATORY_CHAN_DISABLED) && + super_chan_ent->state_arr[in_6g_pwr_mode] == + CHANNEL_STATE_DISABLE); +} + +static bool +reg_is_freq_idx_enabled_on_given_pwr_mode(struct wlan_regulatory_pdev_priv_obj + *pdev_priv_obj, + enum channel_enum freq_idx, + enum supported_6g_pwr_types + in_6g_pwr_mode) +{ + const struct super_chan_info *super_chan_ent; + QDF_STATUS status; + + if (freq_idx >= NUM_CHANNELS) + return false; + + if (freq_idx < MIN_6GHZ_CHANNEL) + return reg_is_freq_idx_enabled_on_cur_chan_list(pdev_priv_obj, + freq_idx); + + status = reg_get_superchan_entry(pdev_priv_obj->pdev_ptr, freq_idx, + &super_chan_ent); + if (QDF_IS_STATUS_ERROR(status)) { + reg_debug("Failed to get super channel entry for freq_idx %d", + freq_idx); + return false; + } + + /* If the input 6G power mode is best power mode, get the best power + * mode type from the super channel entry. + */ + if (in_6g_pwr_mode == REG_BEST_PWR_MODE) + in_6g_pwr_mode = super_chan_ent->best_power_mode; + + return !reg_is_supr_entry_mode_disabled(super_chan_ent, in_6g_pwr_mode); +} + +bool +reg_is_freq_enabled(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + enum channel_enum freq_idx; + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("reg pdev private obj is NULL"); + return false; + } + + freq_idx = reg_get_chan_enum_for_freq(freq); + + if (freq_idx == INVALID_CHANNEL) + return false; + + return reg_is_freq_idx_enabled(pdev, freq_idx, in_6g_pwr_mode); +} + +bool reg_is_freq_idx_enabled(struct wlan_objmgr_pdev *pdev, + enum channel_enum freq_idx, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("reg pdev private obj is NULL"); + return false; + } + + if (freq_idx < MIN_6GHZ_CHANNEL) + return reg_is_freq_idx_enabled_on_cur_chan_list(pdev_priv_obj, + freq_idx); + + switch (in_6g_pwr_mode) { + case REG_CURRENT_PWR_MODE: + return reg_is_freq_idx_enabled_on_cur_chan_list(pdev_priv_obj, + freq_idx); + + case REG_BEST_PWR_MODE: + default: + return reg_is_freq_idx_enabled_on_given_pwr_mode(pdev_priv_obj, + freq_idx, + in_6g_pwr_mode + ); + } +} + diff --git a/umac/regulatory/core/src/reg_services_common.h b/umac/regulatory/core/src/reg_services_common.h index 6366da85c0..fc35f3129d 100644 --- a/umac/regulatory/core/src/reg_services_common.h +++ b/umac/regulatory/core/src/reg_services_common.h @@ -1925,4 +1925,40 @@ QDF_STATUS reg_is_chwidth_supported(struct wlan_objmgr_pdev *pdev, * channel. */ bool reg_is_state_allowed(enum channel_state chan_state); + +/** + * reg_is_freq_enabled() - Checks if the given frequency is enabled on the given + * power mode or not. If the frequency is not a 6G frequency then the input + * power mode is ignored and only current channel list is searched. + * + * @pdev: pdev pointer. + * @freq: input frequency. + * @in_6g_pwr_mode: Power mode on which the freq is enabled or not is to be + * checked. + * + * Return: True if the frequency is present in the given power mode channel + * list. + */ +bool reg_is_freq_enabled(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_mode); + +/** + * reg_is_freq_idx_enabled() - Checks if the given frequency index is enabled on + * the given power mode or not. If the frequency index is not a 6G frequency + * then the input power mode is ignored and only current channel list is + * searched. + * + * @pdev: pdev pointer. + * @freq_idx: input frequency index. + * @in_6g_pwr_mode: Power mode on which the frequency index is enabled or not + * is to be checked. + * + * Return: True if the frequency index is present in the given power mode + * channel list. + */ +bool reg_is_freq_idx_enabled(struct wlan_objmgr_pdev *pdev, + enum channel_enum freq_idx, + enum supported_6g_pwr_types in_6g_pwr_mode); + #endif diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index 79a7af27cb..acc0f0d266 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -604,6 +604,41 @@ bool wlan_reg_is_chan_disabled_and_not_nol(struct regulatory_channel *chan); QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, struct regulatory_channel *chan_list); +/** + * wlan_reg_is_freq_enabled() - Checks if the given frequency is enabled on the + * given power mode or not. If the frequency is not a 6G frequency then the + * input power mode is ignored and only current channel list is searched. + * + * @pdev: pdev pointer. + * @freq: input frequency. + * @in_6g_pwr_mode: Power mode on which the freq is enabled or not is to be + * checked. + * + * Return: True if the frequency is present in the given power mode channel + * list. + */ +bool wlan_reg_is_freq_enabled(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_mode); + +/** + * wlan_reg_is_freq_idx_enabled() - Checks if the given frequency index is + * enabled on the given power mode or not. If the frequency index is not a 6G + * frequency then the input power mode is ignored and only current channel list + * is searched. + * + * @pdev: pdev pointer. + * @freq_idx: input frequency index. + * @in_6g_pwr_mode: Power mode on which the frequency index is enabled or not + * is to be checked. + * + * Return: True if the frequency index is present in the given power mode + * channel list. + */ +bool wlan_reg_is_freq_idx_enabled(struct wlan_objmgr_pdev *pdev, + enum channel_enum freq_idx, + enum supported_6g_pwr_types in_6g_pwr_mode); + #ifdef CONFIG_REG_CLIENT /** * wlan_reg_get_secondary_current_chan_list() - provide the pdev secondary diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 3b57a19adc..0387eb893a 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -133,6 +133,20 @@ QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, qdf_export_symbol(wlan_reg_get_current_chan_list); +bool wlan_reg_is_freq_enabled(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + return reg_is_freq_enabled(pdev, freq, in_6g_pwr_mode); +} + +bool wlan_reg_is_freq_idx_enabled(struct wlan_objmgr_pdev *pdev, + enum channel_enum freq_idx, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + return reg_is_freq_idx_enabled(pdev, freq_idx, in_6g_pwr_mode); +} + #ifdef CONFIG_REG_CLIENT QDF_STATUS wlan_reg_get_secondary_current_chan_list( struct wlan_objmgr_pdev *pdev,