diff --git a/umac/regulatory/core/src/reg_build_chan_list.c b/umac/regulatory/core/src/reg_build_chan_list.c index cbf1c3ecea2a..3e46e9394725 100644 --- a/umac/regulatory/core/src/reg_build_chan_list.c +++ b/umac/regulatory/core/src/reg_build_chan_list.c @@ -656,6 +656,40 @@ void reg_propagate_mas_chan_list_to_pdev(struct wlan_objmgr_psoc *psoc, } } +/** + * reg_populate_6g_band_channels() - For all the valid 6GHz regdb channels + * in the master channel list, find the regulatory rules and call + * reg_fill_channel_info() to populate master channel list with txpower, + * antennagain, BW info, etc. + * @reg_rule_5g: Pointer to regulatory rule. + * @num_5g_reg_rules: Number of regulatory rules. + * @min_bw_5g: Minimum regulatory bandwidth. + * @mas_chan_list: Pointer to the master channel list. + */ +#ifdef CONFIG_BAND_6GHZ +static void +reg_populate_6g_band_channels(struct cur_reg_rule *reg_rule_5g, + uint32_t num_5g_reg_rules, + uint16_t min_bw_5g, + struct regulatory_channel *mas_chan_list) +{ + reg_populate_band_channels(MIN_6GHZ_CHANNEL, + MAX_6GHZ_CHANNEL, + reg_rule_5g, + num_5g_reg_rules, + min_bw_5g, + mas_chan_list); +} +#else +static void +reg_populate_6g_band_channels(struct cur_reg_rule *reg_rule_5g, + uint32_t num_5g_reg_rules, + uint16_t min_bw_5g, + struct regulatory_channel *mas_chan_list) +{ +} +#endif /* CONFIG_BAND_6GHZ */ + QDF_STATUS reg_process_master_chan_list( struct cur_regulatory_info *regulat_info) { @@ -805,16 +839,19 @@ QDF_STATUS reg_process_master_chan_list( reg_rule_2g, num_2g_reg_rules, min_bw_2g, mas_chan_list); - if (num_5g_reg_rules != 0) + if (num_5g_reg_rules != 0) { reg_populate_band_channels(MIN_5GHZ_CHANNEL, MAX_5GHZ_CHANNEL, reg_rule_5g, num_5g_reg_rules, min_bw_5g, mas_chan_list); - - if (num_5g_reg_rules != 0) reg_populate_band_channels(MIN_49GHZ_CHANNEL, MAX_49GHZ_CHANNEL, - reg_rule_5g, num_5g_reg_rules, - min_bw_5g, mas_chan_list); + reg_rule_5g, num_5g_reg_rules, + min_bw_5g, mas_chan_list); + reg_populate_6g_band_channels(reg_rule_5g, + num_5g_reg_rules, + min_bw_5g, + mas_chan_list); + } if (soc_reg->new_user_ctry_pending[phy_id]) { soc_reg->new_user_ctry_pending[phy_id] = false; diff --git a/umac/regulatory/core/src/reg_services_common.c b/umac/regulatory/core/src/reg_services_common.c index d16b96ef67a1..da03f8e538a1 100644 --- a/umac/regulatory/core/src/reg_services_common.c +++ b/umac/regulatory/core/src/reg_services_common.c @@ -36,7 +36,7 @@ #include const struct chan_map *channel_map; - +#ifdef CONFIG_CHAN_NUM_API static const struct bonded_channel bonded_chan_40mhz_list[] = { {36, 40}, {44, 48}, @@ -66,6 +66,98 @@ static const struct bonded_channel bonded_chan_160mhz_list[] = { {36, 64}, {100, 128} }; +#endif /* CONFIG_CHAN_NUM_API */ + +#ifdef CONFIG_CHAN_FREQ_API +/* bonded_chan_40mhz_list_freq - List of 40MHz bonnded channel frequencies */ +static const struct bonded_channel_freq bonded_chan_40mhz_list_freq[] = { + {5180, 5200}, + {5220, 5240}, + {5260, 5280}, + {5300, 5320}, + {5500, 5520}, + {5540, 5560}, + {5580, 5600}, + {5620, 5640}, + {5660, 5680}, + {5700, 5720}, + {5745, 5765}, + {5785, 5805}, + {5825, 5845}, +#ifdef CONFIG_BAND_6GHZ + {5945, 5965}, + {5985, 6005}, + {6025, 6045}, + {6065, 6085}, + {6105, 6125}, + {6145, 6165}, + {6185, 6205}, + {6225, 6245}, + {6265, 6285}, + {6305, 6325}, + {6345, 6365}, + {6385, 6405}, + {6425, 6445}, + {6465, 6485}, + {6505, 6525}, + {6545, 6565}, + {6585, 6605}, + {6625, 6645}, + {6665, 6685}, + {6705, 6725}, + {6745, 6765}, + {6785, 6805}, + {6825, 6845}, + {6865, 6885}, + {6905, 6925}, + {6945, 6965}, + {6985, 7005}, + {7025, 7045}, + {7065, 7085} +#endif /*CONFIG_BAND_6GHZ*/ +}; + +/* bonded_chan_80mhz_list_freq - List of 80MHz bonnded channel frequencies */ +static const struct bonded_channel_freq bonded_chan_80mhz_list_freq[] = { + {5180, 5240}, + {5260, 5320}, + {5500, 5560}, + {5580, 5640}, + {5660, 5720}, + {5745, 5805}, +#ifdef CONFIG_BAND_6GHZ + {5945, 6005}, + {6025, 6085}, + {6105, 6165}, + {6185, 6245}, + {6265, 6325}, + {6345, 6405}, + {6425, 6485}, + {6505, 6565}, + {6585, 6645}, + {6665, 6725}, + {6745, 6805}, + {6825, 6885}, + {6905, 6965}, + {6985, 7045} +#endif /*CONFIG_BAND_6GHZ*/ +}; + +/* bonded_chan_160mhz_list_freq - List of 160MHz bonnded channel frequencies */ +static const struct bonded_channel_freq bonded_chan_160mhz_list_freq[] = { + {5180, 5320}, + {5500, 5640}, +#ifdef CONFIG_BAND_6GHZ + {5945, 6085}, + {6105, 6245}, + {6265, 6405}, + {6425, 6565}, + {6585, 6725}, + {6745, 6885}, + {6905, 7045} +#endif /*CONFIG_BAND_6GHZ*/ +}; +#endif /*CONFIG_CHAN_FREQ_API*/ static const enum phy_ch_width get_next_lower_bw[] = { [CH_WIDTH_80P80MHZ] = CH_WIDTH_160MHZ, @@ -949,6 +1041,7 @@ struct wlan_lmac_if_reg_tx_ops *reg_get_psoc_tx_ops( return &((psoc->soc_cb.tx_ops.reg_ops)); } +#ifdef CONFIG_CHAN_NUM_API QDF_STATUS reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev, struct channel_power *ch_list, uint8_t *num_chan) @@ -1228,6 +1321,7 @@ enum channel_state reg_get_2g_bonded_channel_state( return CHANNEL_STATE_ENABLE; } +#endif /* CONFIG_CHAN_NUM_API */ /** * reg_combine_channel_states() - Get minimum of channel state1 and state2 @@ -1247,6 +1341,7 @@ static enum channel_state reg_combine_channel_states( return min(chan_state1, chan_state2); } +#ifdef CONFIG_CHAN_NUM_API /** * reg_set_5g_channel_params () - Sets channel parameteres for given bandwidth * @ch: channel number. @@ -1408,6 +1503,7 @@ void reg_set_channel_params(struct wlan_objmgr_pdev *pdev, else if (REG_IS_24GHZ_CH(ch)) reg_set_2g_channel_params(pdev, ch, ch_params, sec_ch_2g); } +#endif /* CONFIG_CHAN_NUM_API */ QDF_STATUS reg_get_curr_band(struct wlan_objmgr_pdev *pdev, enum band_info *band) @@ -1477,6 +1573,7 @@ void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, reg_init_channel_map(dfs_reg); } +#ifdef CONFIG_CHAN_NUM_API uint32_t reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, uint32_t chan_num) { @@ -1536,6 +1633,7 @@ bool reg_is_dfs_ch(struct wlan_objmgr_pdev *pdev, return ch_state == CHANNEL_STATE_DFS; } +#endif /* CONFIG_CHAN_NUM_API */ uint32_t reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, uint32_t freq) @@ -1562,6 +1660,7 @@ uint32_t reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, return 0; } +#ifdef CONFIG_CHAN_NUM_API uint32_t reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, uint32_t chan_num) { @@ -1646,6 +1745,7 @@ void reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, reg_compute_pdev_current_chan_list(pdev_priv_obj); } +#endif /* CONFIG_CHAN_NUM_API */ QDF_STATUS reg_program_default_cc(struct wlan_objmgr_pdev *pdev, uint16_t regdmn) @@ -2075,6 +2175,7 @@ bool reg_chan_in_range(struct regulatory_channel *chan_list, return false; } +#ifdef CONFIG_CHAN_NUM_API void reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev, uint8_t *chan_list, uint8_t num_chan, bool nol_history_chan) @@ -2122,6 +2223,7 @@ bool reg_is_5ghz_ch(uint32_t chan) { return REG_IS_5GHZ_CH(chan); } +#endif /* CONFIG_CHAN_NUM_API */ bool reg_is_24ghz_ch_freq(uint32_t freq) { @@ -2138,6 +2240,35 @@ bool reg_is_6ghz_chan_freq(uint16_t freq) { return REG_IS_6GHZ_FREQ(freq); } + +uint16_t reg_min_6ghz_chan_freq(void) +{ + return REG_MIN_6GHZ_CHAN_FREQ; +} + +uint16_t reg_max_6ghz_chan_freq(void) +{ + return REG_MAX_6GHZ_CHAN_FREQ; +} + +bool reg_is_6ghz_psc_chan_freq(uint16_t freq) +{ + uint8_t count; + + if (!REG_IS_6GHZ_FREQ(freq)) { + reg_err(" Channel frequency is not a 6GHz frequency"); + return false; + } + for (count = 1; count <= NUM_PSC_FREQ; count++) { + if (count == + (((freq - SIXG_STARTING_FREQ) + (FREQ_LEFT_SHIFT)) / + (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G))) + return true; + } + reg_err(" Channel frequency is not a 6GHz PSC frequency"); + + return false; +} #endif bool reg_is_49ghz_freq(uint32_t freq) @@ -2155,6 +2286,7 @@ uint32_t reg_ch_to_freq(uint32_t ch_enum) return REG_CH_TO_FREQ(ch_enum); } +#ifdef CONFIG_CHAN_NUM_API bool reg_is_same_band_channels(uint32_t chan_num1, uint32_t chan_num2) { return (chan_num1 && chan_num2 && @@ -2185,6 +2317,29 @@ uint32_t reg_max_5ghz_ch_num(void) { return REG_MAX_5GHZ_CH_NUM; } +#endif /* CONFIG_CHAN_NUM_API */ + +#ifdef CONFIG_CHAN_FREQ_API +uint16_t reg_min_24ghz_chan_freq(void) +{ + return REG_MIN_24GHZ_CH_FREQ; +} + +uint16_t reg_max_24ghz_chan_freq(void) +{ + return REG_MAX_24GHZ_CH_FREQ; +} + +uint16_t reg_min_5ghz_chan_freq(void) +{ + return REG_MIN_5GHZ_CH_FREQ; +} + +uint16_t reg_max_5ghz_chan_freq(void) +{ + return REG_MAX_5GHZ_CH_FREQ; +} +#endif /* CONFIG_CHAN_FREQ_API */ QDF_STATUS reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev, bool enable) @@ -2335,3 +2490,663 @@ QDF_STATUS reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev) return status; } + +#ifdef CONFIG_CHAN_FREQ_API +QDF_STATUS reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev + *pdev, + struct channel_power + *ch_list, + uint8_t *num_chan) +{ + int i, count; + struct regulatory_channel *reg_channels; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + + if (!num_chan || !ch_list) { + reg_err("chan_list or num_ch is NULL"); + return QDF_STATUS_E_FAILURE; + } + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("reg pdev priv obj is NULL"); + return QDF_STATUS_E_FAILURE; + } + + /* set the current channel list */ + reg_channels = pdev_priv_obj->cur_chan_list; + + for (i = 0, count = 0; i < NUM_CHANNELS; i++) { + if (reg_channels[i].state && + !(reg_channels[i].chan_flags & REGULATORY_CHAN_DISABLED)) { + ch_list[count].center_freq = + reg_channels[i].center_freq; + ch_list[count++].tx_power = + reg_channels[i].tx_power; + } + } + + *num_chan = count; + + return QDF_STATUS_SUCCESS; +} + +enum channel_enum reg_get_chan_enum_for_freq(uint16_t freq) +{ + uint32_t count; + + for (count = 0; count < NUM_CHANNELS; count++) + if (channel_map[count].center_freq == freq) + return count; + + reg_err("invalid channel center frequency %d", freq); + + return INVALID_CHANNEL; +} + +enum channel_state reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + enum channel_enum ch_idx; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + + ch_idx = reg_get_chan_enum_for_freq(freq); + + if (ch_idx == INVALID_CHANNEL) + return CHANNEL_STATE_INVALID; + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("pdev reg obj is NULL"); + return CHANNEL_STATE_INVALID; + } + + return pdev_priv_obj->cur_chan_list[ch_idx].state; +} + +/** + * reg_get_5g_bonded_chan_array_for_freq()- Return the channel state for a + * 5G or 6G channel frequency based on the bonded channel. + * @pdev: Pointer to pdev. + * @freq: Channel center frequency. + * @bonded_chan_ar: Array of bonded channel frequencies. + * @array_size: Array size. + * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. + * + * Return: Channel State + */ +static enum channel_state +reg_get_5g_bonded_chan_array_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + const struct bonded_channel_freq + bonded_chan_ar[], + uint16_t array_size, + const struct bonded_channel_freq + **bonded_chan_ptr_ptr) +{ + int i; + uint16_t chan_cfreq; + const struct bonded_channel_freq *bonded_chan_ptr = NULL; + enum channel_state chan_state = CHANNEL_STATE_INVALID; + enum channel_state temp_chan_state; + + for (i = 0; i < array_size; i++) { + if ((freq >= bonded_chan_ar[i].start_freq) && + (freq <= bonded_chan_ar[i].end_freq)) { + bonded_chan_ptr = &bonded_chan_ar[i]; + break; + } + } + + if (!bonded_chan_ptr) + return chan_state; + + *bonded_chan_ptr_ptr = bonded_chan_ptr; + chan_cfreq = bonded_chan_ptr->start_freq; + while (chan_cfreq <= bonded_chan_ptr->end_freq) { + temp_chan_state = reg_get_channel_state_for_freq(pdev, + chan_cfreq); + if (temp_chan_state < chan_state) + chan_state = temp_chan_state; + chan_cfreq = chan_cfreq + 20; + } + + return chan_state; +} + +/** + * reg_get_5g_bonded_channel_for_freq()- Return the channel state for a + * 5G or 6G channel frequency based on the channel width and bonded channel + * @pdev: Pointer to pdev. + * @freq: Channel center frequency. + * @ch_width: Channel Width. + * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. + * + * Return: Channel State + */ +static enum channel_state +reg_get_5g_bonded_channel_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width ch_width, + const struct bonded_channel_freq + **bonded_chan_ptr_ptr) + +{ + if (ch_width == CH_WIDTH_80P80MHZ) + return reg_get_5g_bonded_chan_array_for_freq(pdev, freq, + bonded_chan_80mhz_list_freq, + QDF_ARRAY_SIZE(bonded_chan_80mhz_list_freq), + bonded_chan_ptr_ptr); + else if (ch_width == CH_WIDTH_160MHZ) + return reg_get_5g_bonded_chan_array_for_freq(pdev, freq, + bonded_chan_160mhz_list_freq, + QDF_ARRAY_SIZE(bonded_chan_160mhz_list_freq), + bonded_chan_ptr_ptr); + else if (ch_width == CH_WIDTH_80MHZ) + return reg_get_5g_bonded_chan_array_for_freq(pdev, freq, + bonded_chan_80mhz_list_freq, + QDF_ARRAY_SIZE(bonded_chan_80mhz_list_freq), + bonded_chan_ptr_ptr); + else if (ch_width == CH_WIDTH_40MHZ) + return reg_get_5g_bonded_chan_array_for_freq(pdev, freq, + bonded_chan_40mhz_list_freq, + QDF_ARRAY_SIZE(bonded_chan_40mhz_list_freq), + bonded_chan_ptr_ptr); + else + return reg_get_channel_state_for_freq(pdev, freq); +} + +enum channel_state +reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width bw) +{ + enum channel_enum ch_indx; + enum channel_state chan_state; + struct regulatory_channel *reg_channels; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + bool bw_enabled = false; + const struct bonded_channel_freq *bonded_chan_ptr = NULL; + + if (bw > CH_WIDTH_80P80MHZ) { + reg_err("bw passed is not good"); + return CHANNEL_STATE_INVALID; + } + + chan_state = reg_get_5g_bonded_channel_for_freq(pdev, freq, bw, + &bonded_chan_ptr); + + if ((chan_state == CHANNEL_STATE_INVALID) || + (chan_state == CHANNEL_STATE_DISABLE)) + return chan_state; + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("pdev reg obj is NULL"); + return CHANNEL_STATE_INVALID; + } + reg_channels = pdev_priv_obj->cur_chan_list; + + ch_indx = reg_get_chan_enum_for_freq(freq); + if (ch_indx == INVALID_CHANNEL) + return CHANNEL_STATE_INVALID; + if (bw == CH_WIDTH_5MHZ) + bw_enabled = true; + else if (bw == CH_WIDTH_10MHZ) + bw_enabled = (reg_channels[ch_indx].min_bw <= 10) && + (reg_channels[ch_indx].max_bw >= 10); + else if (bw == CH_WIDTH_20MHZ) + bw_enabled = (reg_channels[ch_indx].min_bw <= 20) && + (reg_channels[ch_indx].max_bw >= 20); + else if (bw == CH_WIDTH_40MHZ) + bw_enabled = (reg_channels[ch_indx].min_bw <= 40) && + (reg_channels[ch_indx].max_bw >= 40); + else if (bw == CH_WIDTH_80MHZ) + bw_enabled = (reg_channels[ch_indx].min_bw <= 80) && + (reg_channels[ch_indx].max_bw >= 80); + else if (bw == CH_WIDTH_160MHZ) + bw_enabled = (reg_channels[ch_indx].min_bw <= 160) && + (reg_channels[ch_indx].max_bw >= 160); + else if (bw == CH_WIDTH_80P80MHZ) + bw_enabled = (reg_channels[ch_indx].min_bw <= 80) && + (reg_channels[ch_indx].max_bw >= 80); + + if (bw_enabled) + return chan_state; + else + return CHANNEL_STATE_DISABLE; +} + +enum channel_state +reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t oper_ch_freq, + uint16_t sec_ch_freq, + enum phy_ch_width bw) +{ + enum channel_enum chan_idx; + enum channel_state chan_state; + struct regulatory_channel *reg_channels; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + bool bw_enabled = false; + enum channel_state chan_state2 = CHANNEL_STATE_INVALID; + + if (bw > CH_WIDTH_40MHZ) + return CHANNEL_STATE_INVALID; + + if (bw == CH_WIDTH_40MHZ) { + if ((sec_ch_freq + 20 != oper_ch_freq) && + (oper_ch_freq + 20 != sec_ch_freq)) + return CHANNEL_STATE_INVALID; + chan_state2 = reg_get_channel_state_for_freq(pdev, sec_ch_freq); + if (chan_state2 == CHANNEL_STATE_INVALID) + return chan_state2; + } + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("reg pdev priv obj is NULL"); + return CHANNEL_STATE_INVALID; + } + + reg_channels = pdev_priv_obj->cur_chan_list; + + chan_state = reg_get_channel_state_for_freq(pdev, oper_ch_freq); + if (chan_state2 < chan_state) + chan_state = chan_state2; + + if ((chan_state == CHANNEL_STATE_INVALID) || + (chan_state == CHANNEL_STATE_DISABLE)) + return chan_state; + + chan_idx = reg_get_chan_enum_for_freq(oper_ch_freq); + if (chan_idx == INVALID_CHANNEL) + return CHANNEL_STATE_INVALID; + if (bw == CH_WIDTH_5MHZ) + bw_enabled = true; + else if (bw == CH_WIDTH_10MHZ) + bw_enabled = (reg_channels[chan_idx].min_bw <= 10) && + (reg_channels[chan_idx].max_bw >= 10); + else if (bw == CH_WIDTH_20MHZ) + bw_enabled = (reg_channels[chan_idx].min_bw <= 20) && + (reg_channels[chan_idx].max_bw >= 20); + else if (bw == CH_WIDTH_40MHZ) + bw_enabled = (reg_channels[chan_idx].min_bw <= 40) && + (reg_channels[chan_idx].max_bw >= 40); + + if (bw_enabled) + return chan_state; + else + return CHANNEL_STATE_DISABLE; + + return CHANNEL_STATE_ENABLE; +} + +/** + * reg_set_5g_channel_params_for_freq()- Set channel parameters like center + * frequency for a bonded channel state. Also return the maximum bandwidth + * supported by the channel. + * @pdev: Pointer to pdev. + * @freq: Channel center frequency. + * ch_params: Pointer to ch_params. + * + * Return: void + */ +static void reg_set_5g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + struct ch_params *ch_params) +{ + /* + * Set channel parameters like center frequency for a bonded channel + * state. Also return the maximum bandwidth supported by the channel. + */ + + enum phy_ch_width next_lower_bw; + enum channel_state chan_state = CHANNEL_STATE_ENABLE; + enum channel_state chan_state2 = CHANNEL_STATE_ENABLE; + const struct bonded_channel_freq *bonded_chan_ptr = NULL; + const struct bonded_channel_freq *bonded_chan_ptr2 = NULL; + + if (!ch_params) { + reg_err("ch_params is NULL"); + return; + } + + if (ch_params->ch_width >= CH_WIDTH_MAX) { + if (ch_params->mhz_freq_seg1 != 0) + ch_params->ch_width = CH_WIDTH_80P80MHZ; + else + ch_params->ch_width = CH_WIDTH_160MHZ; + } + next_lower_bw = ch_params->ch_width; + + while (ch_params->ch_width != CH_WIDTH_INVALID) { + ch_params->ch_width = next_lower_bw; + next_lower_bw = get_next_lower_bw[ch_params->ch_width]; + bonded_chan_ptr = NULL; + bonded_chan_ptr2 = NULL; + chan_state = reg_get_5g_bonded_channel_for_freq( + pdev, freq, ch_params->ch_width, + &bonded_chan_ptr); + + chan_state = reg_get_5g_bonded_channel_state_for_freq( + pdev, freq, ch_params->ch_width); + + if (ch_params->ch_width == CH_WIDTH_80P80MHZ) { + chan_state2 = reg_get_5g_bonded_channel_state_for_freq( + pdev, ch_params->mhz_freq_seg1 - 10, + CH_WIDTH_80MHZ); + + chan_state = reg_combine_channel_states( + chan_state, chan_state2); + } + + if ((chan_state != CHANNEL_STATE_ENABLE) && + (chan_state != CHANNEL_STATE_DFS)) + continue; + if (ch_params->ch_width <= CH_WIDTH_20MHZ) { + ch_params->sec_ch_offset = NO_SEC_CH; + ch_params->mhz_freq_seg0 = freq; + if (reg_is_6ghz_chan_freq(ch_params->mhz_freq_seg0)) + ch_params->center_freq_seg0 = + (ch_params->mhz_freq_seg0 - + SIXG_STARTING_FREQ) / FREQ_TO_CHAN_SCALE; + else + ch_params->center_freq_seg0 = + (ch_params->mhz_freq_seg0 - + FIVEG_STARTING_FREQ) / FREQ_TO_CHAN_SCALE; + break; + } else if (ch_params->ch_width >= CH_WIDTH_40MHZ) { + reg_get_5g_bonded_chan_array_for_freq( + pdev, freq, bonded_chan_40mhz_list_freq, + QDF_ARRAY_SIZE(bonded_chan_40mhz_list_freq), + &bonded_chan_ptr2); + if (!bonded_chan_ptr || !bonded_chan_ptr2) + continue; + if (freq == bonded_chan_ptr2->start_freq) + ch_params->sec_ch_offset = LOW_PRIMARY_CH; + else + ch_params->sec_ch_offset = HIGH_PRIMARY_CH; + + ch_params->mhz_freq_seg0 = + (bonded_chan_ptr->start_freq + + bonded_chan_ptr->end_freq) / 2; + if (reg_is_6ghz_chan_freq(ch_params->mhz_freq_seg0)) + ch_params->center_freq_seg0 = + (ch_params->mhz_freq_seg0 - + SIXG_STARTING_FREQ) / FREQ_TO_CHAN_SCALE; + else + ch_params->center_freq_seg0 = + (ch_params->mhz_freq_seg0 - + FIVEG_STARTING_FREQ) / FREQ_TO_CHAN_SCALE; + break; + } + } + + if (ch_params->ch_width == CH_WIDTH_160MHZ) { + ch_params->mhz_freq_seg1 = ch_params->mhz_freq_seg0; + if (reg_is_6ghz_chan_freq(ch_params->mhz_freq_seg1)) + ch_params->center_freq_seg1 = + (ch_params->mhz_freq_seg1 - SIXG_STARTING_FREQ) / + FREQ_TO_CHAN_SCALE; + else + ch_params->center_freq_seg1 = + (ch_params->mhz_freq_seg1 - FIVEG_STARTING_FREQ) / + FREQ_TO_CHAN_SCALE; + chan_state = reg_get_5g_bonded_channel_for_freq( + pdev, freq, CH_WIDTH_80MHZ, &bonded_chan_ptr); + if (bonded_chan_ptr) { + ch_params->mhz_freq_seg0 = + (bonded_chan_ptr->start_freq + + bonded_chan_ptr->end_freq) / 2; + if (reg_is_6ghz_chan_freq(ch_params->mhz_freq_seg0)) + ch_params->center_freq_seg0 = + (ch_params->mhz_freq_seg0 - + SIXG_STARTING_FREQ) / FREQ_TO_CHAN_SCALE; + else + ch_params->center_freq_seg0 = + (ch_params->mhz_freq_seg0 - + FIVEG_STARTING_FREQ) / FREQ_TO_CHAN_SCALE; + } + } + + /* Overwrite mhz_freq_seg1 to 0 for non 160 and 80+80 width */ + if (!(ch_params->ch_width == CH_WIDTH_160MHZ || + ch_params->ch_width == CH_WIDTH_80P80MHZ)) { + ch_params->mhz_freq_seg1 = 0; + ch_params->center_freq_seg1 = 0; + } +} + +/** + * reg_set_2g_channel_params_for_freq() - set the 2.4G bonded channel parameters + * @oper_freq: operating channel + * @ch_params: channel parameters + * @sec_ch_2g_freq: 2.4G secondary channel + * + * Return: void + */ +static void reg_set_2g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t oper_freq, + struct ch_params *ch_params, + uint16_t sec_ch_2g_freq) +{ + enum channel_state chan_state = CHANNEL_STATE_ENABLE; + + 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; + } + + while (ch_params->ch_width != CH_WIDTH_INVALID) { + chan_state = + reg_get_2g_bonded_channel_state_for_freq(pdev, oper_freq, + sec_ch_2g_freq, + ch_params->ch_width); + if (chan_state == CHANNEL_STATE_ENABLE) { + if (ch_params->ch_width == CH_WIDTH_40MHZ) { + if (oper_freq < sec_ch_2g_freq) + ch_params->sec_ch_offset = + LOW_PRIMARY_CH; + else + ch_params->sec_ch_offset = + HIGH_PRIMARY_CH; + ch_params->mhz_freq_seg0 = + (oper_freq + sec_ch_2g_freq) / 2; + if (ch_params->mhz_freq_seg0 == + TWOG_CHAN_14_IN_MHZ) + ch_params->center_freq_seg0 = 14; + else + ch_params->center_freq_seg0 = + (ch_params->mhz_freq_seg0 - + TWOG_STARTING_FREQ) / + FREQ_TO_CHAN_SCALE; + } else { + ch_params->sec_ch_offset = NO_SEC_CH; + ch_params->mhz_freq_seg0 = oper_freq; + if (ch_params->mhz_freq_seg0 == + TWOG_CHAN_14_IN_MHZ) + ch_params->center_freq_seg0 = 14; + else + ch_params->center_freq_seg0 = + (ch_params->mhz_freq_seg0 - + TWOG_STARTING_FREQ) / + FREQ_TO_CHAN_SCALE; + } + break; + } + + ch_params->ch_width = get_next_lower_bw[ch_params->ch_width]; + } + /* Overwrite mhz_freq_seg1 and center_freq_seg1 to 0 for 2.4 Ghz */ + ch_params->mhz_freq_seg1 = 0; + ch_params->center_freq_seg1 = 0; +} + +void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t sec_ch_2g_freq, + struct ch_params *ch_params) +{ + if (reg_is_5ghz_ch_freq(freq) || reg_is_6ghz_chan_freq(freq)) + reg_set_5g_channel_params_for_freq(pdev, freq, ch_params); + else if (reg_is_24ghz_ch_freq(freq)) + reg_set_2g_channel_params_for_freq(pdev, freq, ch_params, + sec_ch_2g_freq); +} + +uint8_t reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + enum channel_enum chan_enum; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + struct regulatory_channel *reg_channels; + + chan_enum = reg_get_chan_enum_for_freq(freq); + + if (chan_enum == INVALID_CHANNEL) { + reg_err("channel is invalid"); + return QDF_STATUS_E_FAILURE; + } + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("reg pdev priv obj is NULL"); + return QDF_STATUS_E_FAILURE; + } + + reg_channels = pdev_priv_obj->cur_chan_list; + + return reg_channels[chan_enum].tx_power; +} + +bool reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq) +{ + enum channel_state ch_state; + + ch_state = reg_get_channel_state_for_freq(pdev, freq); + + return ch_state == CHANNEL_STATE_DFS; +} + +void reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t *chan_list, + uint8_t num_chan, + bool nol_chan) +{ + enum channel_enum chan_enum; + struct regulatory_channel *mas_chan_list; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + uint16_t i; + + if (!num_chan || !chan_list) { + reg_err("chan_list or num_ch is NULL"); + return; + } + + pdev_priv_obj = reg_get_pdev_obj(pdev); + if (!pdev_priv_obj) { + reg_err("reg psoc private obj is NULL"); + return; + } + + 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) { + reg_err("Invalid ch in nol list, chan %d", + chan_list[i]); + continue; + } + mas_chan_list[chan_enum].nol_chan = nol_chan; + } + + reg_compute_pdev_current_chan_list(pdev_priv_obj); +} + +void reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t *chan_list, + uint8_t num_chan, + bool nol_history_chan) +{ + enum channel_enum chan_enum; + struct regulatory_channel *mas_chan_list; + struct regulatory_channel *cur_chan_list; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + uint16_t i; + + if (!num_chan || !chan_list) { + reg_err("chan_list or num_ch is NULL"); + return; + } + + pdev_priv_obj = wlan_objmgr_pdev_get_comp_private_obj( + pdev, WLAN_UMAC_COMP_REGULATORY); + + if (!pdev_priv_obj) { + reg_err("reg psoc private obj is NULL"); + return; + } + + mas_chan_list = pdev_priv_obj->mas_chan_list; + cur_chan_list = pdev_priv_obj->cur_chan_list; + + for (i = 0; i < num_chan; i++) { + chan_enum = reg_get_chan_enum_for_freq(chan_list[i]); + if (chan_enum == INVALID_CHANNEL) { + reg_err("Invalid ch in nol list, chan %d", + chan_list[i]); + continue; + } + mas_chan_list[chan_enum].nol_history = nol_history_chan; + cur_chan_list[chan_enum].nol_history = nol_history_chan; + } +} + +static inline bool REG_IS_FREQUENCY_VALID_5G_SBS(uint16_t curfreq, + uint16_t newfreq) +{ + return ((curfreq) > (newfreq) ? + REG_CH_TO_FREQ(reg_get_chan_enum_for_freq(curfreq)) + - REG_CH_TO_FREQ(reg_get_chan_enum_for_freq(newfreq)) + > REG_SBS_SEPARATION_THRESHOLD : + REG_CH_TO_FREQ(reg_get_chan_enum_for_freq(newfreq)) + - REG_CH_TO_FREQ(reg_get_chan_enum_for_freq(curfreq)) + > REG_SBS_SEPARATION_THRESHOLD); +} + +bool reg_is_frequency_valid_5g_sbs(uint16_t curfreq, uint16_t newfreq) +{ + return REG_IS_FREQUENCY_VALID_5G_SBS(curfreq, newfreq); +} + +#ifdef CONFIG_BAND_6GHZ +bool reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2) +{ + return (freq1 && freq2 && ((REG_IS_6GHZ_FREQ(freq1) && + REG_IS_6GHZ_FREQ(freq2)) || + (REG_IS_5GHZ_FREQ(freq1) && + REG_IS_5GHZ_FREQ(freq2)) || + (REG_IS_24GHZ_CH_FREQ(freq1) && + REG_IS_24GHZ_CH_FREQ(freq2)))); +} +#else +bool reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2) +{ + return (freq1 && freq2 && ((REG_IS_5GHZ_FREQ(freq1) && + REG_IS_5GHZ_FREQ(freq2)) || + (REG_IS_24GHZ_CH_FREQ(freq1) && + REG_IS_24GHZ_CH_FREQ(freq2)))); +} +#endif /* CONFIG_BAND_6GHZ */ +#endif /* CONFIG_CHAN_FREQ_API */ diff --git a/umac/regulatory/core/src/reg_services_common.h b/umac/regulatory/core/src/reg_services_common.h index 96bf036c29cb..dc143db77efa 100644 --- a/umac/regulatory/core/src/reg_services_common.h +++ b/umac/regulatory/core/src/reg_services_common.h @@ -28,7 +28,9 @@ #define IS_VALID_PSOC_REG_OBJ(psoc_priv_obj) (psoc_priv_obj) #define IS_VALID_PDEV_REG_OBJ(pdev_priv_obj) (pdev_priv_obj) +#define FREQ_TO_CHAN_SCALE 5 +#ifdef CONFIG_CHAN_NUM_API #define REG_MIN_24GHZ_CH_NUM channel_map[MIN_24GHZ_CHANNEL].chan_num #define REG_MAX_24GHZ_CH_NUM channel_map[MAX_24GHZ_CHANNEL].chan_num #define REG_MIN_5GHZ_CH_NUM channel_map[MIN_5GHZ_CHANNEL].chan_num @@ -37,6 +39,7 @@ #define REG_IS_24GHZ_CH(chan_num) \ (((chan_num) >= REG_MIN_24GHZ_CH_NUM) && \ ((chan_num) <= REG_MAX_24GHZ_CH_NUM)) +#endif /* CONFIG_CHAN_NUM_API */ #define REG_MIN_24GHZ_CH_FREQ channel_map[MIN_24GHZ_CHANNEL].center_freq #define REG_MAX_24GHZ_CH_FREQ channel_map[MAX_24GHZ_CHANNEL].center_freq @@ -45,6 +48,18 @@ (((freq) >= REG_MIN_24GHZ_CH_FREQ) && \ ((freq) <= REG_MAX_24GHZ_CH_FREQ)) +#ifdef CONFIG_CHAN_FREQ_API +#define FIVEG_STARTING_FREQ 5000 +#define TWOG_STARTING_FREQ 2407 +#define TWOG_CHAN_14_IN_MHZ 2484 +#define TWOG_CHAN_1_IN_MHZ 2412 +#define TWOG_CHAN_5_IN_MHZ 2432 +#define TWOG_CHAN_6_IN_MHZ 2437 +#define TWOG_CHAN_13_IN_MHZ 2472 +#define REG_MIN_5GHZ_CH_FREQ channel_map[MIN_5GHZ_CHANNEL].center_freq +#define REG_MAX_5GHZ_CH_FREQ channel_map[MAX_5GHZ_CHANNEL].center_freq +#endif /* CONFIG_CHAN_FREQ_API */ + #define REG_MIN_49GHZ_CH_FREQ channel_map[MIN_49GHZ_CHANNEL].center_freq #define REG_MAX_49GHZ_CH_FREQ channel_map[MAX_49GHZ_CHANNEL].center_freq @@ -52,17 +67,32 @@ (((freq) >= REG_MIN_49GHZ_CH_FREQ) && \ ((freq) <= REG_MAX_49GHZ_CH_FREQ)) +#ifdef CONFIG_CHAN_NUM_API #define REG_IS_5GHZ_CH(chan_num) \ (((chan_num) >= REG_MIN_5GHZ_CH_NUM) && \ ((chan_num) <= REG_MAX_5GHZ_CH_NUM)) +#endif /* CONFIG_CHAN_NUM_API */ #define REG_IS_5GHZ_FREQ(freq) \ (((freq) >= channel_map[MIN_5GHZ_CHANNEL].center_freq) && \ ((freq) <= channel_map[MAX_5GHZ_CHANNEL].center_freq)) #ifdef CONFIG_BAND_6GHZ -#define REG_MIN_6GHZ_CH_FREQ channel_map[MIN_6GHZ_CHANNEL].center_freq -#define REG_MAX_6GHZ_CH_FREQ channel_map[MAX_6GHZ_CHANNEL].center_freq +#define FREQ_LEFT_SHIFT 55 +#define SIXG_STARTING_FREQ 5940 +#define NUM_80MHZ_BAND_IN_6G 16 +#define NUM_PSC_FREQ 15 +#define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G) +#define REG_MIN_6GHZ_CHAN_FREQ channel_map[MIN_6GHZ_CHANNEL].center_freq +#define REG_MAX_6GHZ_CHAN_FREQ channel_map[MAX_6GHZ_CHANNEL].center_freq +#else +#define FREQ_LEFT_SHIFT 0 +#define SIXG_STARTING_FREQ 0 +#define NUM_80MHZ_BAND_IN_6G 0 +#define NUM_PSC_FREQ 0 +#define PSC_BAND_MHZ (FREQ_TO_CHAN_SCALE * NUM_80MHZ_BAND_IN_6G) +#define REG_MIN_6GHZ_CHAN_FREQ 0 +#define REG_MAX_6GHZ_CHAN_FREQ 0 #endif /*CONFIG_BAND_6GHZ*/ #define REG_CH_NUM(ch_enum) channel_map[ch_enum].chan_num @@ -73,6 +103,7 @@ extern const struct chan_map *channel_map; +#ifdef CONFIG_CHAN_NUM_API /** * reg_get_chan_enum() - Get channel enum for given channel number * @chan_num: Channel number @@ -141,6 +172,7 @@ enum channel_state reg_get_2g_bonded_channel_state( void reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, uint8_t sec_ch_2g, struct ch_params *ch_params); +#endif /* CONFIG_CHAN_NUM_API */ /** * reg_read_default_country() - Get the default regulatory country @@ -162,6 +194,7 @@ QDF_STATUS reg_read_default_country(struct wlan_objmgr_psoc *psoc, void reg_get_current_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg *dfs_reg); +#ifdef CONFIG_CHAN_NUM_API /** * reg_get_channel_reg_power() - Get the txpower for the given channel * @pdev: Pointer to pdev @@ -181,6 +214,7 @@ uint32_t reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, */ uint32_t reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, uint32_t chan_num); +#endif /* CONFIG_CHAN_NUM_API */ /** * reg_get_bw_value() - give bandwidth value @@ -200,6 +234,7 @@ uint16_t reg_get_bw_value(enum phy_ch_width bw); void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg dfs_reg); +#ifdef CONFIG_CHAN_NUM_API /** * reg_chan_to_band() - Get band from channel number * @chan_num: channel number @@ -207,6 +242,7 @@ void reg_set_dfs_region(struct wlan_objmgr_pdev *pdev, * Return: band info */ enum band_info reg_chan_to_band(uint32_t chan_num); +#endif /* CONFIG_CHAN_NUM_API */ /** * reg_program_chan_list() - Set user country code and populate the channel list @@ -218,6 +254,7 @@ enum band_info reg_chan_to_band(uint32_t chan_num); QDF_STATUS reg_program_chan_list(struct wlan_objmgr_pdev *pdev, struct cc_regdmn_s *rd); +#ifdef CONFIG_CHAN_NUM_API /** * reg_update_nol_ch () - Updates NOL channels in current channel list * @pdev: pointer to pdev object @@ -238,6 +275,7 @@ void reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, uint8_t *chan_list, * Return: true or false */ bool reg_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); +#endif /* CONFIG_CHAN_NUM_API */ /** * reg_freq_to_chan() - Get channel number from frequency. @@ -248,6 +286,7 @@ bool reg_is_dfs_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); */ uint32_t reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, uint32_t freq); +#ifdef CONFIG_CHAN_NUM_API /** * reg_chan_to_freq() - Get frequency from channel number * @pdev: Pointer to pdev @@ -265,6 +304,7 @@ uint32_t reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, uint32_t chan_num); * Return: true if the channel is 4.9GHz else false. */ bool reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, uint8_t chan_num); +#endif /* CONFIG_CHAN_NUM_API */ /** * reg_program_default_cc() - Program default country code @@ -382,6 +422,7 @@ void reg_init_channel_map(enum dfs_reg dfs_region); struct wlan_lmac_if_reg_tx_ops *reg_get_psoc_tx_ops( struct wlan_objmgr_psoc *psoc); +#ifdef CONFIG_CHAN_NUM_API /** * reg_update_nol_history_ch() - Set nol-history flag for the channels in the * list. @@ -412,6 +453,7 @@ bool reg_is_24ghz_ch(uint32_t chan); * Return: true if channel number is 5GHz, else false */ bool reg_is_5ghz_ch(uint32_t chan); +#endif /* CONFIG_CHAN_NUM_API */ /** * reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz @@ -446,14 +488,58 @@ bool reg_is_6ghz_chan_freq(uint16_t freq); */ static inline bool REG_IS_6GHZ_FREQ(uint16_t freq) { - return ((freq >= REG_MIN_6GHZ_CH_FREQ) && - (freq <= REG_MAX_6GHZ_CH_FREQ)); + return ((freq >= REG_MIN_6GHZ_CHAN_FREQ) && + (freq <= REG_MAX_6GHZ_CHAN_FREQ)); } + +/** + * reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency is + * preferred scanning channel frequency. + * @freq: Channel frequency + * + * Return: true if given 6GHz channel frequency is preferred scanning channel + * frequency, else false + */ +bool reg_is_6ghz_psc_chan_freq(uint16_t freq); + +/** + * reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency + * + * Return: Minimum 6GHz channel center frequency + */ +uint16_t reg_min_6ghz_chan_freq(void); + +/** + * reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency + * + * Return: Maximum 6GHz channel center frequency + */ +uint16_t reg_max_6ghz_chan_freq(void); #else static inline bool reg_is_6ghz_chan_freq(uint16_t freq) { return false; } + +static inline bool REG_IS_6GHZ_FREQ(uint16_t freq) +{ + return false; +} + +static inline bool reg_is_6ghz_psc_chan_freq(uint16_t freq) +{ + return false; +} + +static inline uint16_t reg_min_6ghz_chan_freq(void) +{ + return 0; +} + +static inline uint16_t reg_max_6ghz_chan_freq(void) +{ + return 0; +} #endif /* CONFIG_BAND_6GHZ */ /** @@ -480,6 +566,7 @@ uint32_t reg_ch_num(uint32_t ch_enum); */ uint32_t reg_ch_to_freq(uint32_t ch_enum); +#ifdef CONFIG_CHAN_NUM_API /** * reg_is_same_band_channels() - Check if given channel numbers have same band * @chan_num1: Channel number1 @@ -525,6 +612,37 @@ uint32_t reg_min_5ghz_ch_num(void); * Return: Maximum 5GHz channel number */ uint32_t reg_max_5ghz_ch_num(void); +#endif /* CONFIG_CHAN_NUM_API */ + +#ifdef CONFIG_CHAN_FREQ_API +/** + * reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency + * + * Return: Minimum 2.4GHz channel frequency + */ +uint16_t reg_min_24ghz_chan_freq(void); + +/** + * reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency + * + * Return: Maximum 2.4GHz channel frequency + */ +uint16_t reg_max_24ghz_chan_freq(void); + +/** + * reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency + * + * Return: Minimum 5GHz channel frequency + */ +uint16_t reg_min_5ghz_chan_freq(void); + +/** + * reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency + * + * Return: Maximum 5GHz channel frequency + */ +uint16_t reg_max_5ghz_chan_freq(void); +#endif /* CONFIG_CHAN_FREQ_API */ /** * reg_enable_dfs_channels() - Enable the use of DFS channels @@ -551,4 +669,160 @@ bool reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev); * Return: QDF_STATUS */ QDF_STATUS reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev); + +#ifdef CONFIG_CHAN_FREQ_API +/** + * reg_get_chan_enum_for_freq() - Get channel enum for given channel frequency + * @freq: Channel Frequency + * + * Return: Channel enum + */ +enum channel_enum reg_get_chan_enum_for_freq(uint16_t freq); + +/** + * reg_get_channel_list_with_power_for_freq() - Provides the channel list with + * power + * @pdev: Pointer to pdev + * @ch_list: Pointer to the channel list. + * @num_chan: Pointer to save number of channels + * + * Return: QDF_STATUS + */ +QDF_STATUS +reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, + struct channel_power *ch_list, + uint8_t *num_chan); + +/** + * reg_get_channel_state_for_freq() - Get channel state from regulatory + * @pdev: Pointer to pdev + * @freq: channel center frequency. + * + * Return: channel state + */ +enum channel_state reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq); + +/** + * reg_get_5g_bonded_channel_state_for_freq() - Get channel state for + * 5G bonded channel using the channel frequency + * @pdev: Pointer to pdev + * @freq: channel center frequency. + * @bw: channel band width + * + * Return: channel state + */ +enum channel_state +reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width bw); + +/** + * reg_get_2g_bonded_channel_state_for_freq() - Get channel state for 2G + * bonded channel + * @freq: channel center frequency. + * @pdev: Pointer to pdev + * @oper_ch_freq: Primary channel center frequency + * @sec_ch_freq: Secondary channel center frequency + * @bw: channel band width + * + * Return: channel state + */ +enum channel_state +reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t oper_ch_freq, + uint16_t sec_ch_freq, + enum phy_ch_width bw); + +/** + * reg_set_channel_params_for_freq () - Sets channel parameteres for given + * bandwidth + * @pdev: Pointer to pdev + * @freq: Channel center frequency. + * @sec_ch_2g_freq: Secondary 2G channel frequency + * @ch_params: pointer to the channel parameters. + * + * Return: None + */ +void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t sec_ch_2g_freq, + struct ch_params *ch_params); + +/** + * reg_get_channel_reg_power_for_freq() - Get the txpower for the given channel + * @pdev: Pointer to pdev + * @freq: Channel frequency + * + * Return: txpower + */ +uint8_t reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq); + +/** + * reg_update_nol_ch_for_freq () - Updates NOL channels in current channel list + * @pdev: pointer to pdev object + * @ch_list: pointer to NOL channel list + * @num_ch: No.of channels in list + * @update_nol: set/reset the NOL status + * + * Return: None + */ +void reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t *chan_list, + uint8_t num_chan, + bool nol_chan); +/** + * reg_is_dfs_for_freq () - Checks the channel state for DFS + * @pdev: pdev ptr + * @freq: Channel center frequency + * + * Return: true or false + */ +bool reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq); + +/** + * reg_chan_freq_is_49ghz() - Check if the input channel center frequency is + * 4.9GHz + * @pdev: Pdev pointer + * @chan_num: Input channel center frequency + * + * Return: true if the frequency is 4.9GHz else false. + */ +bool reg_chan_freq_is_49ghz(uint16_t freq); + +/** + * reg_update_nol_history_ch_for_freq() - Set nol-history flag for the channels + * in the list. + * @pdev: Pdev ptr. + * @chan_list: Input channel freqeuncy list. + * @num_ch: Number of channels. + * @nol_history_ch: NOL-History flag. + * + * Return: void + */ +void reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t *chan_list, + uint8_t num_chan, + bool nol_history_chan); + +/** + * reg_is_same_5g_band_freqs() - Check if given channel center + * frequencies have same band + * @freq1: Channel Center Frequency 1 + * @freq2: Channel Center Frequency 2 + * + * Return: true if both the frequencies has the same band. + */ +bool reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2); + +/** + * reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS. + * @curfreq: current channel frequency + * @newfreq: new channel center frequency + * + * Return: true if the given center frequency is a valid 5G SBS + */ +bool reg_is_frequency_valid_5g_sbs(uint16_t curfreq, uint16_t newfreq); +#endif /* CONFIG_CHAN_FREQ_API */ #endif diff --git a/umac/regulatory/core/src/reg_utils.c b/umac/regulatory/core/src/reg_utils.c index bc5df2914c6e..c9a85fefcfa7 100644 --- a/umac/regulatory/core/src/reg_utils.c +++ b/umac/regulatory/core/src/reg_utils.c @@ -42,6 +42,7 @@ #define IS_VALID_PSOC_REG_OBJ(psoc_priv_obj) (psoc_priv_obj) #define IS_VALID_PDEV_REG_OBJ(pdev_priv_obj) (pdev_priv_obj) +#ifdef CONFIG_CHAN_NUM_API bool reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint32_t ch) { enum channel_enum ch_idx; @@ -65,6 +66,34 @@ bool reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint32_t ch) return false; } +#endif /* CONFIG_CHAN_NUM_API */ + +#ifdef CONFIG_CHAN_FREQ_API +bool reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + enum channel_enum ch_idx; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + + ch_idx = reg_get_chan_enum_for_freq(freq); + + if (ch_idx == INVALID_CHANNEL) + return false; + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("pdev reg obj is NULL"); + return false; + } + + if (pdev_priv_obj->cur_chan_list[ch_idx].chan_flags & + REGULATORY_CHAN_RADAR) + return true; + + return false; +} +#endif /* CONFIG_CHAN_FREQ_API */ bool reg_is_world_ctry_code(uint16_t ctry_code) { @@ -274,6 +303,7 @@ QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, return QDF_STATUS_SUCCESS; } +#ifdef CONFIG_CHAN_NUM_API bool reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) { @@ -284,8 +314,36 @@ bool reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, return (ch_state == CHANNEL_STATE_DFS) || (ch_state == CHANNEL_STATE_DISABLE); } +#endif /* CONFIG_CHAN_NUM_API */ + +#ifdef CONFIG_CHAN_FREQ_API +bool reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + enum channel_state chan_state; + + chan_state = reg_get_channel_state_for_freq(pdev, freq); + + return (chan_state == CHANNEL_STATE_DFS) || + (chan_state == CHANNEL_STATE_DISABLE); +} +#endif /* CONFIG_CHAN_FREQ_API */ #ifdef WLAN_FEATURE_DSRC +#ifdef CONFIG_CHAN_FREQ_API +bool reg_is_dsrc_freq(uint16_t freq) +{ + if (!REG_IS_5GHZ_FREQ(chan)) + return false; + + if (!(freq >= REG_DSRC_START_FREQ && freq <= REG_DSRC_END_FREQ)) + return false; + + return true; +} +#endif /*CONFIG_CHAN_FREQ_API*/ + +#ifdef CONFIG_CHAN_NUM_API bool reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint32_t chan) { struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; @@ -308,6 +366,7 @@ bool reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint32_t chan) return true; } +#endif /* CONFIG_CHAN_NUM_API */ #else @@ -325,6 +384,22 @@ bool reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev) return reg_etsi13_regdmn(cur_reg_dmn.dmn_id_5g); } +#ifdef CONFIG_CHAN_FREQ_API +bool reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + if (!REG_IS_5GHZ_FREQ(freq)) + return false; + + if (!(freq >= REG_ETSI13_SRD_START_FREQ && + freq <= REG_ETSI13_SRD_END_FREQ)) + return false; + + return reg_is_etsi13_regdmn(pdev); +} +#endif /* CONFIG_CHAN_FREQ_API */ + +#ifdef CONFIG_CHAN_NUM_API bool reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev, uint32_t chan) { struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; @@ -348,6 +423,7 @@ bool reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev, uint32_t chan) return reg_is_etsi13_regdmn(pdev); } +#endif /* CONFIG_CHAN_NUM_API */ bool reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev *pdev) { @@ -477,6 +553,64 @@ QDF_STATUS reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) return status; } +#ifdef CONFIG_CHAN_FREQ_API +QDF_STATUS reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, + uint32_t *channel_list, + uint32_t num_channels) +{ + struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + struct wlan_objmgr_psoc *psoc; + uint16_t i, j; + + pdev_priv_obj = reg_get_pdev_obj(pdev); + + if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) { + reg_err("pdev reg component is NULL"); + 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; + } + if (pdev_priv_obj->num_cache_channels > 0) { + pdev_priv_obj->num_cache_channels = 0; + qdf_mem_zero(&pdev_priv_obj->cache_disable_chan_list, + sizeof(pdev_priv_obj->cache_disable_chan_list)); + } + + for (i = 0; i < num_channels; i++) { + for (j = 0; j < NUM_CHANNELS; j++) { + if (channel_list[i] == pdev_priv_obj-> + cur_chan_list[j].center_freq) { + pdev_priv_obj-> + cache_disable_chan_list[i].center_freq = + channel_list[i]; + pdev_priv_obj-> + cache_disable_chan_list[i].state = + pdev_priv_obj->cur_chan_list[j].state; + pdev_priv_obj-> + cache_disable_chan_list[i].chan_flags = + pdev_priv_obj-> + cur_chan_list[j].chan_flags; + } + } + } + pdev_priv_obj->num_cache_channels = num_channels; + + return QDF_STATUS_SUCCESS; +} +#endif /* CONFIG_CHAN_FREQ_API */ + +#ifdef CONFIG_CHAN_NUM_API QDF_STATUS reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, uint32_t *channel_list, uint32_t num_channels) @@ -531,7 +665,7 @@ QDF_STATUS reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_SUCCESS; } - +#endif /* CONFIG_CHAN_NUM_API */ void set_disable_channel_state( struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj) { @@ -680,6 +814,18 @@ QDF_STATUS reg_set_config_vars(struct wlan_objmgr_psoc *psoc, return status; } +#ifdef CONFIG_CHAN_FREQ_API +bool reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq) +{ + enum channel_state ch_state; + + ch_state = reg_get_channel_state_for_freq(pdev, freq); + + return ch_state == CHANNEL_STATE_DISABLE; +} +#endif /* CONFIG_CHAN_FREQ_API */ + +#ifdef CONFIG_CHAN_NUM_API bool reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) { enum channel_state ch_state; @@ -688,6 +834,7 @@ bool reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) return ch_state == CHANNEL_STATE_DISABLE; } +#endif /* CONFIG_CHAN_NUM_API */ bool reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc) { diff --git a/umac/regulatory/core/src/reg_utils.h b/umac/regulatory/core/src/reg_utils.h index 1ab8b9471036..9115ce97cf03 100644 --- a/umac/regulatory/core/src/reg_utils.h +++ b/umac/regulatory/core/src/reg_utils.h @@ -33,6 +33,7 @@ #define REG_ETSI13_SRD_START_FREQ 5745 #define REG_ETSI13_SRD_END_FREQ 5865 +#ifdef CONFIG_CHAN_NUM_API #define REG_IS_CHANNEL_VALID_5G_SBS(curchan, newchan) \ ((curchan) > (newchan) ? \ REG_CH_TO_FREQ(reg_get_chan_enum(curchan)) \ @@ -41,6 +42,7 @@ REG_CH_TO_FREQ(reg_get_chan_enum(newchan)) \ - REG_CH_TO_FREQ(reg_get_chan_enum(curchan)) \ > REG_SBS_SEPARATION_THRESHOLD) +#endif /* CONFIG_LEGACY_REG_API */ /** * reg_is_world_ctry_code() - Check if the given country code is WORLD regdomain @@ -50,7 +52,7 @@ */ bool reg_is_world_ctry_code(uint16_t ctry_code); -#ifdef CONFIG_REG_CLIENT +#if defined(CONFIG_REG_CLIENT) && defined(CONFIG_CHAN_NUM_API) /** * reg_chan_has_dfs_attribute() - check channel has dfs attribue or not * @ch: channel number. @@ -61,6 +63,156 @@ bool reg_is_world_ctry_code(uint16_t ctry_code); */ bool reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint32_t ch); +/** + * reg_is_passive_or_disable_ch() - Check if the given channel is passive or + * disabled. + * @pdev: Pointer to physical dev + * @chan: Channel number + * + * Return: true if channel is passive or disabled, else false. + */ +bool reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); + +/** + * reg_is_disable_ch() - Check if the given channel in disable state + * @pdev: Pointer to pdev + * @chan: channel number + * + * Return: True if channel state is disabled, else false + */ +bool reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); +#else +static inline bool +reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint32_t ch) +{ + return false; +} + +static inline bool +reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) +{ + return false; +} + +static inline bool +reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan) +{ + return false; +} +#endif /* defined(CONFIG_REG_CLIENT) && defined(CONFIG_CHAN_NUM_API) */ + +#if defined(CONFIG_REG_CLIENT) && defined(CONFIG_CHAN_FREQ_API) +/** + * reg_chan_has_dfs_attribute_for_freq() - check channel frequency has dfs + * attribue or not + * @freq: channel frequency. + * + * This API gets initial dfs attribute flag of the channel frequency from + * regdomain + * + * Return: true if channel frequency is dfs, otherwise false + */ +bool reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq); +/** + * reg_is_passive_or_disable_for_freq() - Check if the given channel is + * passive or disabled. + * @pdev: Pointer to physical dev + * @chan: Channel frequency + * + * Return: true if channel frequency is passive or disabled, else false. + */ +bool reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq); +/** + * reg_is_disable_for_freq() - Check if the given channel frequency in + * disable state + * @pdev: Pointer to pdev + * @freq: Channel frequency + * + * Return: True if channel state is disabled, else false + */ +bool reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq); +#else +static inline bool +reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + return false; +} + +static inline bool +reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + return false; +} + +static inline bool +reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq) +{ + return false; +} +#endif /* defined(CONFIG_REG_CLIENT) && defined(CONFIG_CHAN_FREQ_API) */ + +#ifdef DISABLE_CHANNEL_LIST +/** + * reg_restore_cached_channels() - Cache the current state of the channels + * @pdev: The physical dev to cache the channels for + */ +QDF_STATUS reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev); +#else +static inline +QDF_STATUS reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) +{ + return QDF_STATUS_SUCCESS; +} +#endif /* DISABLE_CHANNEL_LIST */ + +#if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_FREQ_API) +/** + * reg_cache_channel_freq_state() - Cache the current state of the channels + * based on the channel center frequency + * @pdev: The physical dev to cache the channels for + * @channel_list: List of the channels for which states needs to be cached + * @num_channels: Number of channels in the list + * + */ +QDF_STATUS reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, + uint32_t *channel_list, + uint32_t num_channels); +#else +static inline +QDF_STATUS reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, + uint32_t *channel_list, + uint32_t num_channels) +{ + return QDF_STATUS_SUCCESS; +} +#endif /* defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_FREQ_API) */ + +#if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_NUM_API) +/** + * reg_cache_channel_state() - Cache the current state of the channels + * @pdev: The physical dev to cache the channels for + * @channel_list: List of the channels for which states needs to be cached + * @num_channels: Number of channels in the list + * + */ +QDF_STATUS reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, + uint32_t *channel_list, + uint32_t num_channels); +#else +static inline +QDF_STATUS reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, + uint32_t *channel_list, + uint32_t num_channels) +{ + return QDF_STATUS_SUCCESS; +} +#endif /* defined (DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_NUM_API) */ + +#ifdef CONFIG_REG_CLIENT /** * reg_set_band() - Sets the band information for the PDEV * @pdev: The physical dev to set the band for @@ -79,39 +231,6 @@ QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, enum band_info band); */ QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev, enum band_info *band); -#ifdef DISABLE_CHANNEL_LIST -/** - * reg_restore_cached_channels() - Cache the current state of the channels - * @pdev: The physical dev to cache the channels for - */ -QDF_STATUS reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev); - -/** - * reg_cache_channel_state() - Cache the current state of the channels - * @pdev: The physical dev to cache the channels for - * @channel_list: List of the channels for which states needs to be cached - * @num_channels: Number of channels in the list - * - */ -QDF_STATUS reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, - uint32_t *channel_list, - uint32_t num_channels); -#else -static inline -QDF_STATUS reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev) -{ - return QDF_STATUS_SUCCESS; -} - -static inline -QDF_STATUS reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, - uint32_t *channel_list, - uint32_t num_channels) -{ - return QDF_STATUS_SUCCESS; -} -#endif - /** * reg_set_fcc_constraint() - Apply fcc constraints on channels 12/13 * @pdev: The physical dev to set the band for @@ -199,25 +318,6 @@ QDF_STATUS reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, const uint8_t *country_alpha2, enum country_src source); -/** - * reg_is_passive_or_disable_ch() - Check if the given channel is passive or - * disabled. - * @pdev: Pointer to physical dev - * @chan: Channel number - * - * Return: true if channel is passive or disabled, else false. - */ -bool reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); - -/** - * reg_is_disable_ch() - Check if the given channel in disable state - * @pdev: Pointer to pdev - * @chan: channel number - * - * Return: True if channel state is disabled, else false - */ -bool reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); - /** * reg_set_config_vars () - set configration variables * @psoc: psoc ptr @@ -308,13 +408,6 @@ bool reg_ignore_default_country(struct wlan_regulatory_psoc_priv_obj *soc_reg, struct cur_regulatory_info *regulat_info); #else - -static inline bool reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, - uint32_t ch) -{ - return false; -} - static inline QDF_STATUS reg_read_current_country(struct wlan_objmgr_psoc *psoc, uint8_t *country_code) { @@ -349,18 +442,6 @@ static inline QDF_STATUS reg_get_domain_from_country_code( return QDF_STATUS_SUCCESS; } -static inline bool reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, - uint32_t chan) -{ - return false; -} - -static inline bool reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, - uint32_t chan) -{ - return false; -} - static inline QDF_STATUS reg_set_config_vars(struct wlan_objmgr_psoc *psoc, struct reg_config_vars config_vars) { @@ -427,6 +508,18 @@ bool reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq) #endif #if defined(WLAN_FEATURE_DSRC) && defined(CONFIG_REG_CLIENT) +/** + * reg_is_dsrc_freq () - Checks the channel frequency is DSRC or not + * @freq: Channel center frequency + * @pdev: pdev ptr + * + * Return: true or false + */ +#ifdef CONFIG_CHAN_FREQ_API +bool reg_is_dsrc_freq(uint16_t freq); +#endif /* CONFIG_CHAN_FREQ_API*/ + +#ifdef CONFIG_CHAN_NUM_API /** * reg_is_dsrc_chan () - Checks the channel for DSRC or not * @chan: channel @@ -435,6 +528,7 @@ bool reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq) * Return: true or false */ bool reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint32_t chan); +#endif /* CONFIG_CHAN_NUM_API */ static inline bool reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev, uint32_t chan) @@ -447,6 +541,20 @@ static inline bool reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev) return false; } +/** + * reg_is_etsi13_srd_chan_for_freq() - Checks the channel for ETSI13 srd ch + * frequency or not + * @freq: Channel center frequency + * @pdev: pdev ptr + * + * Return: true or false + */ +static inline bool +reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq) +{ + return false; +} + static inline bool reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev *pdev) { @@ -459,6 +567,16 @@ static inline bool reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, return false; } +static inline bool reg_is_dsrc_freq(uint16_t freq) +{ + return false; +} + +#ifdef CONFIG_CHAN_FREQ_API +bool reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev + *pdev, uint16_t freq); +#endif /*CONFIG_CHAN_FREQ_API */ + /** * reg_is_etsi13_regdmn () - Checks if the current reg domain is ETSI13 or not * @pdev: pdev ptr @@ -467,6 +585,7 @@ static inline bool reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, */ bool reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev); +#ifdef CONFIG_CHAN_NUM_API /** * reg_is_etsi13_srd_chan () - Checks the channel for ETSI13 srd ch or not * @chan: channel @@ -475,6 +594,7 @@ bool reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev); * Return: true or false */ bool reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev, uint32_t chan); +#endif /* CONFIG_CHAN_NUM_API */ /** * reg_is_etsi13_srd_chan_allowed_master_mode() - Checks if regdmn is ETSI13 @@ -492,6 +612,18 @@ static inline bool reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, return false; } +static inline bool reg_is_dsrc_freq(uint16_t freq) +{ + return false; +} + +static inline +bool reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + return false; +} + static inline bool reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev) { return false; diff --git a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h index bb5cc44464e9..1ac4e4317442 100644 --- a/umac/regulatory/dispatcher/inc/reg_services_public_struct.h +++ b/umac/regulatory/dispatcher/inc/reg_services_public_struct.h @@ -492,22 +492,28 @@ enum ctl_value { * struct ch_params * @ch_width: channel width * @sec_ch_offset: secondary channel offset - * @center_freq_seg0: center freq for segment 0 - * @center_freq_seg1: center freq for segment 1 + * @center_freq_seg0: channel number for segment 0 + * @center_freq_seg1: channel number segment 1 + * @mhz_freq_seg0: Center frequency for segment 0 + * @mhz_freq_seg1: Center frequency for segment 1 */ struct ch_params { enum phy_ch_width ch_width; uint8_t sec_ch_offset; uint8_t center_freq_seg0; uint8_t center_freq_seg1; + uint16_t mhz_freq_seg0; + uint16_t mhz_freq_seg1; }; /** * struct channel_power + * @center_freq: Channel Center Frequency * @chan_num: channel number * @tx_power: TX power */ struct channel_power { + uint32_t center_freq; uint32_t chan_num; uint32_t tx_power; }; @@ -674,6 +680,16 @@ struct bonded_channel { uint16_t end_ch; }; +/** + * struct bonded_channel_freq + * @start_freq: start channel frequency + * @end_freq: end channel frequency + */ +struct bonded_channel_freq { + uint16_t start_freq; + uint16_t end_freq; +}; + struct set_country { uint8_t country[REG_ALPHA2_LEN + 1]; uint8_t pdev_id; @@ -734,7 +750,7 @@ struct cur_reg_rule { * @min_bw_5g: minimum 5G bw * @max_bw_5g: maximum 5G bw * @num_2g_reg_rules: number 2G reg rules - * @num_5g_reg_rules: number 5G reg rules + * @num_5g_reg_rules: number 5G and 6G reg rules * @reg_rules_2g_ptr: ptr to 2G reg rules * @reg_rules_5g_ptr: ptr to 5G reg rules */ diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index abdfc36e505b..b16a764c77f7 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -26,6 +26,7 @@ #ifndef __WLAN_REG_SERVICES_API_H #define __WLAN_REG_SERVICES_API_H +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_min_24ghz_ch_num() - Get minimum 2.4GHz channel number * @@ -57,7 +58,43 @@ uint32_t wlan_reg_min_5ghz_ch_num(void); */ #define WLAN_REG_MAX_5GHZ_CH_NUM wlan_reg_max_5ghz_ch_num() uint32_t wlan_reg_max_5ghz_ch_num(void); +#endif /* CONFIG_CHAN_NUM_API */ +#ifdef CONFIG_CHAN_FREQ_API +/** + * wlan_reg_min_24ghz_chan_freq() - Get minimum 2.4GHz channel frequency + * + * Return: Minimum 2.4GHz channel frequency + */ +#define WLAN_REG_MIN_24GHZ_CHAN_FREQ wlan_reg_min_24ghz_chan_freq() +uint16_t wlan_reg_min_24ghz_chan_freq(void); + +/** + * wlan_reg_max_24ghz_chan_freq() - Get maximum 2.4GHz channel frequency + * + * Return: Maximum 2.4GHz channel frequency + */ +#define WLAN_REG_MAX_24GHZ_CHAN_FREQ wlan_reg_max_24ghz_chan_freq() +uint16_t wlan_reg_max_24ghz_chan_freq(void); + +/** + * wlan_reg_min_5ghz_chan_freq() - Get minimum 5GHz channel frequency + * + * Return: Minimum 5GHz channel frequency + */ +#define WLAN_REG_MIN_5GHZ_CHAN_FREQ wlan_reg_min_5ghz_chan_freq() +uint16_t wlan_reg_min_5ghz_chan_freq(void); + +/** + * wlan_reg_max_5ghz_chan_freq() - Get maximum 5GHz channel frequency + * + * Return: Maximum 5GHz channel frequency + */ +#define WLAN_REG_MAX_5GHZ_CHAN_FREQ wlan_reg_max_5ghz_chan_freq() +uint16_t wlan_reg_max_5ghz_chan_freq(void); +#endif /* CONFIG_CHAN_FREQ_API */ + +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_is_24ghz_ch() - Check if the given channel number is 2.4GHz * @chan: Channel number @@ -75,6 +112,7 @@ bool wlan_reg_is_24ghz_ch(uint32_t chan); */ #define WLAN_REG_IS_5GHZ_CH(chan) wlan_reg_is_5ghz_ch(chan) bool wlan_reg_is_5ghz_ch(uint32_t chan); +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_is_24ghz_ch_freq() - Check if the given channel frequency is 2.4GHz @@ -94,8 +132,6 @@ bool wlan_reg_is_24ghz_ch_freq(uint32_t freq); #define WLAN_REG_IS_5GHZ_CH_FREQ(freq) wlan_reg_is_5ghz_ch_freq(freq) bool wlan_reg_is_5ghz_ch_freq(uint32_t freq); -#define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) wlan_reg_is_6ghz_chan_freq(freq) - #ifdef CONFIG_BAND_6GHZ /** * wlan_reg_is_6ghz_chan_freq() - Check if the given channel frequency is 6GHz @@ -103,14 +139,62 @@ bool wlan_reg_is_5ghz_ch_freq(uint32_t freq); * * Return: true if channel frequency is 6GHz, else false */ - +#define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) wlan_reg_is_6ghz_chan_freq(freq) bool wlan_reg_is_6ghz_chan_freq(uint16_t freq); + +/** + * wlan_reg_is_6ghz_psc_chan_freq() - Check if the given 6GHz channel frequency + * is preferred scanning channel frequency. + * @freq: Channel frequency + * + * Return: true if given 6GHz channel frequency is preferred scanning channel + * frequency, else false + */ +#define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) \ + wlan_reg_is_6ghz_psc_chan_freq(freq) +bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq); + +/** + * wlan_reg_min_6ghz_chan_freq() - Get minimum 6GHz channel center frequency + * + * Return: Minimum 6GHz channel center frequency + */ +#define WLAN_REG_MIN_6GHZ_CHAN_FREQ wlan_reg_min_6ghz_chan_freq() +uint16_t wlan_reg_min_6ghz_chan_freq(void); + +/** + * wlan_reg_max_6ghz_chan_freq() - Get maximum 6GHz channel center frequency + * + * Return: Maximum 6GHz channel center frequency + */ +#define WLAN_REG_MAX_6GHZ_CHAN_FREQ wlan_reg_max_6ghz_chan_freq() +uint16_t wlan_reg_max_6ghz_chan_freq(void); #else + +#define WLAN_REG_IS_6GHZ_CHAN_FREQ(freq) (false) static inline bool wlan_reg_is_6ghz_chan_freq(uint16_t freq) { return false; } -#endif + +#define WLAN_REG_IS_6GHZ_PSC_CHAN_FREQ(freq) (false) +static inline bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq) +{ + return false; +} + +#define WLAN_REG_MIN_6GHZ_CHAN_FREQ (false) +static inline uint16_t wlan_reg_min_6ghz_chan_freq(void) +{ + return 0; +} + +#define WLAN_REG_MAX_6GHZ_CHAN_FREQ (false) +static inline uint16_t wlan_reg_max_6ghz_chan_freq(void) +{ + return 0; +} +#endif /* CONFIG_BAND_6GHZ */ /** * wlan_reg_is_49ghz_freq() - Check if the given channel frequency is 4.9GHz @@ -139,6 +223,7 @@ uint32_t wlan_reg_ch_num(uint32_t ch_enum); #define WLAN_REG_CH_TO_FREQ(ch_enum) wlan_reg_ch_to_freq(ch_enum) uint32_t wlan_reg_ch_to_freq(uint32_t ch_enum); +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_is_same_band_channels() - Check if given channel numbers have same * band @@ -161,10 +246,10 @@ bool wlan_reg_is_same_band_channels(uint32_t chan_num1, uint32_t chan_num2); #define WLAN_REG_IS_CHANNEL_VALID_5G_SBS(curchan, newchan) \ wlan_reg_is_channel_valid_5g_sbs(curchan, newchan) bool wlan_reg_is_channel_valid_5g_sbs(uint32_t curchan, uint32_t newchan); +#endif /* CONFIG_CHAN_NUM_API */ -#define WLAN_REG_INVALID_CHANNEL_ID -#define WLAN_REG_GET_24_END_CHAN_NUM 14 +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_chan_to_band() - Get band from channel number * @chan_num: channel number @@ -183,7 +268,7 @@ enum band_info wlan_reg_chan_to_band(uint32_t chan_num); QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev, struct channel_power *ch_list, uint8_t *num_chan); - +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_read_default_country() - Read the default country for the regdomain * @country: pointer to the country code. @@ -213,6 +298,7 @@ bool wlan_reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq); QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, uint8_t *country); +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_chan_has_dfs_attribute() - check channel has dfs attribute flag * @ch: channel number. @@ -233,6 +319,20 @@ wlan_reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint32_t ch); */ bool wlan_reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num); +#endif /* CONFIG_CHAN_NUM_API */ + +#ifdef CONFIG_CHAN_FREQ_API +/** + * wlan_reg_is_etsi13_srd_chan_for_freq () - Checks if the ch is ETSI13 srd ch + * or not + * @pdev: pdev ptr + * @freq: channel center frequency + * + * Return: true or false + */ +bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq); +#endif /*CONFIG_CHAN_FREQ_API*/ /** * wlan_reg_is_etsi13_regdmn() - Checks if current reg domain is ETSI13 or not @@ -262,6 +362,7 @@ bool wlan_reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev */ bool wlan_reg_is_world(uint8_t *country); +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_get_chan_enum() - Get channel enum for given channel number * @chan_num: Channel number @@ -316,7 +417,7 @@ enum channel_state wlan_reg_get_2g_bonded_channel_state( void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, uint8_t sec_ch_2g, struct ch_params *ch_params); - +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_get_dfs_region () - Get the current dfs region * @dfs_reg: pointer to dfs region @@ -326,9 +427,10 @@ void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, enum dfs_reg *dfs_reg); +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_get_channel_reg_power() - Provide the channel regulatory power - * @chan_num: chennal number + * @chan_num: channel number * * Return: int */ @@ -337,12 +439,13 @@ uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, /** * wlan_reg_get_channel_freq() - provide the channel center freq - * @chan_num: chennal number + * @chan_num: channel number * * Return: int */ uint32_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, uint32_t chan_num); +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_get_current_chan_list() - provide the pdev current channel list @@ -353,6 +456,8 @@ uint32_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, */ QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, struct regulatory_channel *chan_list); + +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_get_bonded_channel_state() - get bonded channel state * @pdev: pdev ptr @@ -365,6 +470,7 @@ QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, enum channel_state wlan_reg_get_bonded_channel_state( struct wlan_objmgr_pdev *pdev, uint8_t ch, enum phy_ch_width bw, uint8_t sec_ch); +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_set_dfs_region() - set the dfs region @@ -496,6 +602,7 @@ QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev); */ QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev); +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_update_nol_ch () - set nol channel * @pdev: pdev ptr @@ -547,6 +654,7 @@ bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev, * Return: true or false */ bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, uint32_t chan); +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_freq_to_chan () - convert channel freq to channel number @@ -575,6 +683,7 @@ uint32_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, */ bool wlan_reg_is_us(uint8_t *country); +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_chan_is_49ghz() - Check if the input channel number is 4.9GHz * @pdev: Pdev pointer @@ -582,9 +691,9 @@ bool wlan_reg_is_us(uint8_t *country); * * Return: true if the channel is 4.9GHz else false. */ - bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, uint8_t chan_num); +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_set_country() - Set the current regulatory country @@ -693,6 +802,7 @@ wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc); QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, struct cur_regdmn_info *cur_regdmn); +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_update_nol_history_ch() - Set nol-history flag for the channels in * the list. @@ -708,7 +818,7 @@ void wlan_reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev, uint8_t *ch_list, uint8_t num_ch, bool nol_history_ch); - +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_is_regdmn_en302502_applicable() - Find if ETSI EN302_502 radar * pattern is applicable in the current regulatory domain. @@ -728,4 +838,191 @@ bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev); * Return : QDF_STATUS */ QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev); + +#ifdef CONFIG_CHAN_FREQ_API +/** + * wlan_reg_is_same_band_freqs() - Check if two channel frequencies + * have same band + * @freq1: Frequency 1 + * @freq2: Frequency 2 + * + * Return: true if both the channel frequency has the same band. + */ +#define WLAN_REG_IS_SAME_BAND_FREQS(freq1, freq2) \ + wlan_reg_is_same_band_freqs(freq1, freq2) +bool wlan_reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2); + +/** + * wlan_reg_get_chan_enum_for_freq() - Get channel enum for given channel center + * frequency + * @freq: Channel center frequency + * + * Return: Channel enum + */ +enum channel_enum wlan_reg_get_chan_enum_for_freq(uint16_t freq); + +/** + * wlan_reg_update_nol_history_ch_for_freq() - Set nol-history flag for the + * channels in the list. + * + * @pdev: Pdev ptr + * @ch_list: Input channel list. + * @num_ch: Number of channels. + * @nol_history_ch: Nol history value. + * + * Return: void + */ +void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t *ch_list, + uint8_t num_ch, + bool nol_history_ch); +/** + * wlan_reg_is_frequency_valid_5g_sbs() Check if the given frequency is 5G SBS. + * @curfreq: current channel center frequency + * @newfreq:new channel center frequency + * + * Return: true if the given frequency is a valid 5G SBS + */ +#define WLAN_REG_IS_FREQUENCY_VALID_5G_SBS(curfreq, newfreq) \ + wlan_reg_is_frequency_valid_5g_sbs(curfreq, newfreq) +bool wlan_reg_is_frequency_valid_5g_sbs(uint16_t curfreq, uint16_t newfreq); + +/** + * wlan_reg_chan_has_dfs_attribute_for_freq() - check channel has dfs + * attribute flag + * @freq: channel center frequency. + * + * This API get chan initial dfs attribute from regdomain + * + * Return: true if chan is dfs, otherwise false + */ +bool +wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq); + +/** + * wlan_reg_get_channel_list_with_power_for_freq() - Provide the channel list + * with power + * @ch_list: pointer to the channel list. + * + * Return: QDF_STATUS + */ +QDF_STATUS +wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, + struct channel_power *ch_list, + uint8_t *num_chan); + +/** + * wlan_reg_get_5g_bonded_channel_state_for_freq() - Get 5G bonded channel state + * @pdev: The physical dev to program country code or regdomain + * @freq: channel frequency. + * @bw: channel band width + * + * Return: channel state + */ +enum channel_state +wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width bw); +/** + * wlan_reg_get_2g_bonded_channel_state_for_freq() - Get 2G bonded channel state + * @pdev: The physical dev to program country code or regdomain + * @freq: channel center frequency. + * @sec_ch_freq: Secondary channel center frequency. + * @bw: channel band width + * + * Return: channel state + */ +enum channel_state +wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t sec_ch_freq, + enum phy_ch_width bw); + +/** + * wlan_reg_get_channel_state_for_freq() - Get channel state from regulatory + * @pdev: Pointer to pdev + * @freq: channel center frequency. + * + * Return: channel state + */ +enum channel_state +wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq); + +/** + * wlan_reg_set_channel_params_for_freq () - Sets channel parameteres for + * given bandwidth + * @pdev: The physical dev to program country code or regdomain + * @freq: channel center frequency. + * @sec_ch_2g_freq: Secondary channel center frequency. + * @ch_params: pointer to the channel parameters. + * + * Return: None + */ +void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t sec_ch_2g_freq, + struct ch_params *ch_params); + +/** + * wlan_reg_get_channel_cfreq_reg_power_for_freq() - Provide the channel + * regulatory power + * @freq: channel center frequency + * + * Return: int + */ +uint32_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, + uint32_t freq); + +/** + * wlan_reg_update_nol_ch_for_freq () - set nol channel + * @pdev: pdev ptr + * @ch_list: channel list to be returned + * @num_ch: number of channels + * @nol_ch: nol flag + * + * Return: void + */ +void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t *ch_list, + uint8_t num_ch, + bool nol_ch); + +/** + * wlan_reg_is_dfs_freq () - Checks the channel state for DFS + * @freq: Channel center frequency + * + * Return: true or false + */ +bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq); + +/** + * wlan_reg_is_dsrc_freq () - Checks if the channel is dsrc channel or not + * @freq: Channel center frequency + * + * Return: true or false + */ +bool wlan_reg_is_dsrc_freq(uint16_t freq); + +/** + * wlan_reg_is_passive_or_disable_for_freq () - Checks chan state for passive + * and disabled + * @pdev: pdev ptr + * @freq: Channel center frequency + * + * Return: true or false + */ +bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq); + +/** + * wlan_reg_is_disable_for_freq () - Checks chan state for disabled + * @pdev: pdev ptr + * @freq: Channel center frequency + * + * Return: true or false + */ +bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq); +#endif /*CONFIG_CHAN_FREQ_API */ #endif diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h index bb493e91806b..4ed60544a935 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h @@ -66,7 +66,7 @@ QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev, * * Return: QDF_STATUS */ -#ifdef DISABLE_CHANNEL_LIST +#if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_NUM_API) void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, uint32_t *channel_list, uint32_t num_channels); @@ -77,7 +77,29 @@ void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, uint32_t num_channels) { } -#endif +#endif /* CONFIG_CHAN_NUM_API */ + +/** + * ucfg_reg_cache_channel_freq_state() - Cache the current state of the + * channels based on the channel center frequency. + * @pdev: Pointer to pdev. + * @channel_list: List of the channels for which states need to be cached. + * @num_channels: Number of channels in the list. + * + * Return: QDF_STATUS + */ +#if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_FREQ_API) +void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, + uint32_t *channel_list, + uint32_t num_channels); +#else +static inline +void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, + uint32_t *channel_list, + uint32_t num_channels) +{ +} +#endif /* CONFIG_CHAN_FREQ_API */ /** * ucfg_reg_restore_cached_channels() - Cache the current state of the channles diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 7e99716766fb..e4802efb9b35 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -41,6 +41,7 @@ #include <../../core/src/reg_offload_11d_scan.h> #include +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_get_channel_list_with_power() - Provide the channel list with power * @ch_list: pointer to the channel list. @@ -56,6 +57,7 @@ QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev, */ return reg_get_channel_list_with_power(pdev, ch_list, num_chan); } +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_read_default_country() - Read the default country for the regdomain @@ -81,6 +83,7 @@ QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc, return reg_read_current_country(psoc, country); } +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_get_channel_state() - Get channel state from regulatory * @ch: channel number. @@ -153,6 +156,7 @@ void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch, */ reg_set_channel_params(pdev, ch, sec_ch_2g, ch_params); } +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_get_dfs_region () - Get the current dfs region @@ -171,6 +175,7 @@ QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_SUCCESS; } +#ifdef CONFIG_CHAN_NUM_API uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev, uint32_t chan_num) { @@ -188,6 +193,7 @@ uint32_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev, { return reg_get_channel_freq(pdev, chan_num); } +#endif /* CONFIG_CHAN_NUM_API */ QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev, struct regulatory_channel *chan_list) @@ -206,6 +212,7 @@ uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw) return reg_get_bw_value(bw); } +#ifdef CONFIG_CHAN_NUM_API /** * wlan_reg_get_bonded_channel_state() - Get 2G bonded channel state * @ch: channel number. @@ -224,6 +231,7 @@ enum channel_state wlan_reg_get_bonded_channel_state( return reg_get_5g_bonded_channel_state(pdev, ch, bw); } +#endif /* CONFIG_CHAN_NUM_API */ /** * wlan_reg_set_dfs_region () - Get the current dfs region @@ -444,6 +452,7 @@ QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev) return QDF_STATUS_SUCCESS; } +#ifdef CONFIG_CHAN_NUM_API void wlan_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, uint8_t *ch_list, uint8_t num_ch, bool nol_ch) { @@ -474,6 +483,7 @@ bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev, { return reg_is_disable_ch(pdev, chan); } +#endif /* CONFIG_CHAN_NUM_API */ uint32_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev, uint32_t freq) @@ -487,11 +497,13 @@ uint32_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev, return reg_chan_to_freq(pdev, chan_num); } +#ifdef CONFIG_CHAN_NUM_API bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev, uint8_t chan_num) { return reg_chan_is_49ghz(pdev, chan_num); } +#endif /* CONFIG_CHAN_NUM_API */ QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev, uint8_t *country) @@ -540,6 +552,7 @@ bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc) return reg_11d_enabled_on_host(psoc); } +#ifdef CONFIG_CHAN_NUM_API bool wlan_reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num) { return reg_is_dsrc_chan(pdev, chan_num); @@ -550,6 +563,7 @@ bool wlan_reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev, { return reg_is_etsi13_srd_chan(pdev, chan_num); } +#endif /* CONFIG_CHAN_NUM_API */ bool wlan_reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev) { @@ -626,6 +640,7 @@ QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev, return reg_get_curr_regdomain(pdev, cur_regdmn); } +#ifdef CONFIG_CHAN_NUM_API uint32_t wlan_reg_min_24ghz_ch_num(void) { return reg_min_24ghz_ch_num(); @@ -645,7 +660,31 @@ uint32_t wlan_reg_max_5ghz_ch_num(void) { return reg_max_5ghz_ch_num(); } +#endif /* CONFIG_CHAN_NUM_API */ +#ifdef CONFIG_CHAN_FREQ_API +uint16_t wlan_reg_min_24ghz_chan_freq(void) +{ + return reg_min_24ghz_chan_freq(); +} + +uint16_t wlan_reg_max_24ghz_chan_freq(void) +{ + return reg_max_24ghz_chan_freq(); +} + +uint16_t wlan_reg_min_5ghz_chan_freq(void) +{ + return reg_min_5ghz_chan_freq(); +} + +uint16_t wlan_reg_max_5ghz_chan_freq(void) +{ + return reg_max_5ghz_chan_freq(); +} +#endif /* CONFIG_CHAN_FREQ_API */ + +#ifdef CONFIG_CHAN_NUM_API bool wlan_reg_is_24ghz_ch(uint32_t chan) { return reg_is_24ghz_ch(chan); @@ -655,6 +694,7 @@ bool wlan_reg_is_5ghz_ch(uint32_t chan) { return reg_is_5ghz_ch(chan); } +#endif /* CONFIG_CHAN_NUM_API */ bool wlan_reg_is_24ghz_ch_freq(uint32_t freq) { @@ -671,7 +711,23 @@ bool wlan_reg_is_6ghz_chan_freq(uint16_t freq) { return reg_is_6ghz_chan_freq(freq); } -#endif + +uint16_t wlan_reg_min_6ghz_chan_freq(void) +{ + return reg_min_6ghz_chan_freq(); +} + +uint16_t wlan_reg_max_6ghz_chan_freq(void) +{ + return reg_max_6ghz_chan_freq(); +} + +bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq) +{ + return reg_is_6ghz_psc_chan_freq(freq); +} +#endif /* CONFIG_BAND_6GHZ */ + bool wlan_reg_is_49ghz_freq(uint32_t freq) { return reg_is_49ghz_freq(freq); @@ -687,6 +743,7 @@ uint32_t wlan_reg_ch_to_freq(uint32_t ch_enum) return reg_ch_to_freq(ch_enum); } +#ifdef CONFIG_CHAN_NUM_API bool wlan_reg_is_same_band_channels(uint32_t chan_num1, uint32_t chan_num2) { return reg_is_same_band_channels(chan_num1, chan_num2); @@ -712,6 +769,7 @@ enum channel_enum wlan_reg_get_chan_enum(uint32_t chan_num) { return reg_get_chan_enum(chan_num); } +#endif /* CONFIG_CHAN_NUM_API */ bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev) { @@ -728,3 +786,124 @@ QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev) { return reg_modify_pdev_chan_range(pdev); } + +#ifdef CONFIG_CHAN_FREQ_API +bool wlan_reg_is_same_band_freqs(uint16_t freq1, uint16_t freq2) +{ + return reg_is_same_band_freqs(freq1, freq2); +} + +bool wlan_reg_is_frequency_valid_5g_sbs(uint16_t curfreq, uint16_t newfreq) +{ + return reg_is_frequency_valid_5g_sbs(curfreq, newfreq); +} + +enum channel_enum wlan_reg_get_chan_enum_for_freq(uint16_t freq) +{ + return reg_get_chan_enum_for_freq(freq); +} + +bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + return reg_is_etsi13_srd_chan_for_freq(pdev, freq); +} + +bool wlan_reg_is_dsrc_freq(uint16_t freq) +{ + return reg_is_dsrc_freq(freq); +} + +void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t *ch_list, + uint8_t num_ch, + bool nol_ch) +{ + reg_update_nol_ch_for_freq(pdev, ch_list, num_ch, nol_ch); +} + +void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t *ch_list, + uint8_t num_ch, + bool nol_history_ch) +{ + reg_update_nol_history_ch_for_freq(pdev, + ch_list, + num_ch, + nol_history_ch); +} + +bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq) +{ + return reg_is_dfs_for_freq(pdev, freq); +} + +bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + return reg_is_passive_or_disable_for_freq(pdev, freq); +} + +bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, uint16_t freq) +{ + return reg_is_disable_for_freq(pdev, freq); +} + +QDF_STATUS +wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, + struct channel_power *ch_list, + uint8_t *num_chan) +{ + return reg_get_channel_list_with_power_for_freq(pdev, + ch_list, + num_chan); +} + +bool +wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + return reg_chan_has_dfs_attribute_for_freq(pdev, freq); +} + +enum channel_state +wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width bw) +{ + return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, bw); +} + +enum channel_state +wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t sec_ch_freq, + enum phy_ch_width bw) +{ + return reg_get_2g_bonded_channel_state_for_freq(pdev, + freq, + sec_ch_freq, + bw); +} + +void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + uint16_t sec_ch_2g_freq, + struct ch_params *ch_params) +{ + reg_set_channel_params_for_freq(pdev, freq, sec_ch_2g_freq, ch_params); +} + +enum channel_state +wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq) +{ + return reg_get_channel_state_for_freq(pdev, freq); +} + +uint32_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev, + uint32_t freq) +{ + return reg_get_channel_reg_power_for_freq(pdev, freq); +} +#endif /* CONFIG CHAN FREQ API */ diff --git a/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c b/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c index e4fde34a265f..68e809d502f7 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_ucfg_api.c @@ -287,6 +287,24 @@ QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc, qdf_export_symbol(ucfg_reg_set_hal_reg_cap); #ifdef DISABLE_CHANNEL_LIST +#ifdef CONFIG_CHAN_FREQ_API +/** + * ucfg_reg_cache_channel_freq_state() - Cache the current state of the channels + * based of the channel center frequency. + * @pdev: The physical dev to cache the channels for + * @channel_list: List of the channels for which states needs to be cached + * @num_channels: Number of channels in the list + * + */ +void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev, + uint32_t *channel_list, + uint32_t num_channels) +{ + reg_cache_channel_freq_state(pdev, channel_list, num_channels); +} +#endif /* CONFIG_CHAN_FREQ_API */ + +#ifdef CONFIG_CHAN_NUM_API /** * ucfg_reg_cache_channel_state() - Cache the current state of the channles * @pdev: The physical dev to cache the channels for @@ -299,6 +317,7 @@ void ucfg_reg_cache_channel_state(struct wlan_objmgr_pdev *pdev, { reg_cache_channel_state(pdev, channel_list, num_channels); } +#endif /* CONFIG_CHAN_NUM_API */ /** * ucfg_reg_restore_cached_channels() - Cache the current state of the channles