diff --git a/umac/regulatory/core/src/reg_services_common.c b/umac/regulatory/core/src/reg_services_common.c index c1111b6159..5ed4604d55 100644 --- a/umac/regulatory/core/src/reg_services_common.c +++ b/umac/regulatory/core/src/reg_services_common.c @@ -4141,6 +4141,48 @@ update_bw: } } +#ifdef CONFIG_REG_CLIENT +static qdf_freq_t reg_get_sec_ch_2g_freq(struct wlan_objmgr_pdev *pdev, + qdf_freq_t primary_freq) +{ + qdf_freq_t sec_ch_2g_freq = 0; + + if (primary_freq >= TWOG_CHAN_1_IN_MHZ && + primary_freq <= TWOG_CHAN_5_IN_MHZ) + sec_ch_2g_freq = primary_freq + HT40_SEC_OFFSET; + else if (primary_freq >= TWOG_CHAN_6_IN_MHZ && + primary_freq <= TWOG_CHAN_13_IN_MHZ) + sec_ch_2g_freq = primary_freq - HT40_SEC_OFFSET; + + return sec_ch_2g_freq; +} +#else +static qdf_freq_t reg_get_sec_ch_2g_freq(struct wlan_objmgr_pdev *pdev, + qdf_freq_t primary_freq) +{ + qdf_freq_t sec_ch_2g_freq; + + if (primary_freq < TWOG_CHAN_1_IN_MHZ || + primary_freq > TWOG_CHAN_13_IN_MHZ) + return 0; + + sec_ch_2g_freq = primary_freq + HT40_SEC_OFFSET; + + /* For 2G primary frequencies > 2452 (IEEE9), return HT40-. */ + if (primary_freq > TWOG_CHAN_9_IN_MHZ) + sec_ch_2g_freq = primary_freq - HT40_SEC_OFFSET; + + /* + * For 2G primary frequencies <= 2452 (IEEE9), return HT40+ if + * the secondary is available, else return HT40-. + */ + else if (!reg_is_freq_present_in_cur_chan_list(pdev, sec_ch_2g_freq)) + sec_ch_2g_freq = primary_freq - HT40_SEC_OFFSET; + + return sec_ch_2g_freq; +} +#endif + void reg_set_2g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t oper_freq, struct ch_params *ch_params, @@ -4165,14 +4207,8 @@ void reg_set_2g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, if (ch_params->ch_width >= CH_WIDTH_MAX) ch_params->ch_width = CH_WIDTH_40MHZ; - if ((reg_get_bw_value(ch_params->ch_width) > 20) && !sec_ch_2g_freq) { - if (oper_freq >= TWOG_CHAN_1_IN_MHZ && oper_freq <= - TWOG_CHAN_5_IN_MHZ) - sec_ch_2g_freq = oper_freq + 20; - else if (oper_freq >= TWOG_CHAN_6_IN_MHZ && oper_freq <= - TWOG_CHAN_13_IN_MHZ) - sec_ch_2g_freq = oper_freq - 20; - } + if ((reg_get_bw_value(ch_params->ch_width) > 20) && !sec_ch_2g_freq) + sec_ch_2g_freq = reg_get_sec_ch_2g_freq(pdev, oper_freq); max_bw = pdev_priv_obj->cur_chan_list[chan_enum].max_bw; diff --git a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h index 98cd412f9c..65038cea86 100644 --- a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h +++ b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h @@ -1591,8 +1591,11 @@ struct reg_sched_payload { #define TWOG_CHAN_1_IN_MHZ 2412 #define TWOG_CHAN_5_IN_MHZ 2432 #define TWOG_CHAN_6_IN_MHZ 2437 +#define TWOG_CHAN_9_IN_MHZ 2452 #define TWOG_CHAN_13_IN_MHZ 2472 +#define HT40_SEC_OFFSET 20 + /** * struct reg_ctl_params - reg ctl and regd info * @regd: regdomain pair