diff --git a/target_if/mlme/psoc/src/target_if_psoc_wake_lock.c b/target_if/mlme/psoc/src/target_if_psoc_wake_lock.c index 265b4217d2..734e800f6d 100644 --- a/target_if/mlme/psoc/src/target_if_psoc_wake_lock.c +++ b/target_if/mlme/psoc/src/target_if_psoc_wake_lock.c @@ -219,9 +219,9 @@ void target_if_vdev_start_link_handler(struct wlan_objmgr_vdev *vdev, is_dfs = wlan_reg_is_dfs_for_freq(pdev, ch_freq); ch_state = - wlan_reg_get_5g_bonded_channel_state_for_freq(pdev, ch_freq, - ch_width, - REG_CURRENT_PWR_MODE); + wlan_reg_get_5g_bonded_channel_state_for_pwrmode( + pdev, ch_freq, ch_width, + REG_CURRENT_PWR_MODE); rx_ops = target_if_vdev_mgr_get_rx_ops(psoc); if (!rx_ops || !rx_ops->psoc_get_wakelock_info) { mlme_err("psoc_id:%d No Rx Ops", @@ -238,7 +238,8 @@ void target_if_vdev_start_link_handler(struct wlan_objmgr_vdev *vdev, prev_ch_is_dfs = wlan_reg_is_dfs_for_freq(pdev, prev_ch_freq); prev_ch_state = - wlan_reg_get_5g_bonded_channel_state_for_freq(pdev, + wlan_reg_get_5g_bonded_channel_state_for_pwrmode( + pdev, prev_ch_freq, prev_ch_width, REG_CURRENT_PWR_MODE); /* @@ -299,7 +300,7 @@ void target_if_vdev_stop_link_handler(struct wlan_objmgr_vdev *vdev) psoc_wakelock = rx_ops->psoc_get_wakelock_info(psoc); if (wlan_vdev_mlme_get_opmode(vdev) == QDF_SAP_MODE) if (is_dfs || - (wlan_reg_get_5g_bonded_channel_state_for_freq( + (wlan_reg_get_5g_bonded_channel_state_for_pwrmode( pdev, ch_freq, ch_width, diff --git a/target_if/spectral/target_if_spectral.c b/target_if/spectral/target_if_spectral.c index 715892d37e..c059c1f242 100644 --- a/target_if/spectral/target_if_spectral.c +++ b/target_if/spectral/target_if_spectral.c @@ -3955,7 +3955,7 @@ target_if_calculate_center_freq(struct target_if_spectral *spectral, const struct bonded_channel_freq *bonded_chan_ptr = NULL; enum channel_state state; - state = wlan_reg_get_5g_bonded_channel_and_state_for_freq + state = wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode (spectral->pdev_obj, chan_freq, agile_ch_width, &bonded_chan_ptr, REG_CURRENT_PWR_MODE); if (state == CHANNEL_STATE_DISABLE || @@ -4035,7 +4035,8 @@ target_if_validate_center_freq(struct target_if_spectral *spectral, uint32_t calulated_center_freq; enum channel_state st; - st = wlan_reg_get_5g_bonded_channel_and_state_for_freq + st = + wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode (pdev, center_freq + FREQ_OFFSET_10MHZ, agile_ch_width, &bonded_chan_ptr, @@ -4145,7 +4146,7 @@ target_if_is_agile_span_overlap_with_operating_span } else { enum channel_state state; - state = wlan_reg_get_5g_bonded_channel_and_state_for_freq + state = wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode (pdev, chan_freq, op_ch_width, &bonded_chan_ptr, REG_CURRENT_PWR_MODE); if (state == CHANNEL_STATE_DISABLE || @@ -4297,9 +4298,12 @@ target_if_spectral_is_valid_80p80_freq(struct wlan_objmgr_pdev *pdev, ch_params.center_freq_seg1 = wlan_reg_freq_to_chan(pdev, cfreq2); ch_params.mhz_freq_seg1 = cfreq2; ch_params.ch_width = CH_WIDTH_80P80MHZ; - wlan_reg_set_channel_params_for_freq(pdev, cfreq1 - FREQ_OFFSET_10MHZ, - 0, &ch_params, - REG_CURRENT_PWR_MODE); + wlan_reg_set_channel_params_for_pwrmode( + pdev, + cfreq1 - FREQ_OFFSET_10MHZ, + 0, + &ch_params, + REG_CURRENT_PWR_MODE); if (ch_params.ch_width != CH_WIDTH_80P80MHZ) return false; @@ -4308,7 +4312,7 @@ target_if_spectral_is_valid_80p80_freq(struct wlan_objmgr_pdev *pdev, ch_params.mhz_freq_seg1 != cfreq2) return false; - chan_state1 = wlan_reg_get_5g_bonded_channel_state_for_freq( + chan_state1 = wlan_reg_get_5g_bonded_channel_state_for_pwrmode( pdev, ch_params.mhz_freq_seg0 - FREQ_OFFSET_10MHZ, CH_WIDTH_80MHZ, @@ -4317,7 +4321,7 @@ target_if_spectral_is_valid_80p80_freq(struct wlan_objmgr_pdev *pdev, (chan_state1 == CHANNEL_STATE_INVALID)) return false; - chan_state2 = wlan_reg_get_5g_bonded_channel_state_for_freq( + chan_state2 = wlan_reg_get_5g_bonded_channel_state_for_pwrmode( pdev, ch_params.mhz_freq_seg1 - FREQ_OFFSET_10MHZ, CH_WIDTH_80MHZ, diff --git a/target_if/spectral/target_if_spectral_phyerr.c b/target_if/spectral/target_if_spectral_phyerr.c index 257a66b5e3..36e48d0190 100644 --- a/target_if/spectral/target_if_spectral_phyerr.c +++ b/target_if/spectral/target_if_spectral_phyerr.c @@ -893,7 +893,8 @@ target_if_spectral_unify_cfreq_format(struct target_if_spectral *spectral, enum channel_state state; /* Get the 80MHz channel containing the pri20 freq */ - state = wlan_reg_get_5g_bonded_channel_and_state_for_freq + state = + wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode (spectral->pdev_obj, pri20_freq, CH_WIDTH_80MHZ, &bonded_chan_ptr, REG_CURRENT_PWR_MODE); diff --git a/umac/dcs/core/src/wlan_dcs.c b/umac/dcs/core/src/wlan_dcs.c index 63698e02bf..ccef8858db 100644 --- a/umac/dcs/core/src/wlan_dcs.c +++ b/umac/dcs/core/src/wlan_dcs.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -783,7 +784,10 @@ static uint32_t wlan_dcs_get_pcl_for_sap(struct wlan_objmgr_vdev *vdev, for (i = 0, j = 0; i < pcl->pcl_len && i < freq_list_sz; i++) { freq = (qdf_freq_t)pcl->pcl_list[i]; - state = wlan_reg_get_channel_state_for_freq(pdev, freq); + state = wlan_reg_get_channel_state_for_pwrmode( + pdev, + freq, + REG_CURRENT_PWR_MODE); if (state != CHANNEL_STATE_ENABLE) continue; @@ -821,7 +825,10 @@ static uint32_t wlan_dcs_get_pcl_for_sap(struct wlan_objmgr_vdev *vdev, for (i = 0, j = 0; i < NUM_CHANNELS && i < freq_list_sz; i++) { freq = cur_chan_list[i].center_freq; - state = wlan_reg_get_channel_state_for_freq(pdev, freq); + state = wlan_reg_get_channel_state_for_pwrmode( + pdev, + freq, + REG_CURRENT_PWR_MODE); if (state != CHANNEL_STATE_ENABLE) continue; @@ -1029,8 +1036,9 @@ wlan_dcs_get_available_chan_for_bw(struct wlan_objmgr_pdev *pdev, continue; } - state = wlan_reg_get_5g_bonded_channel_and_state_for_freq( - pdev, freq, bw, &bonded_chan_ptr); + state = wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode( + pdev, freq, bw, &bonded_chan_ptr, + REG_CURRENT_PWR_MODE); if (state != CHANNEL_STATE_ENABLE) continue; diff --git a/umac/dfs/core/src/misc/dfs_random_chan_sel.c b/umac/dfs/core/src/misc/dfs_random_chan_sel.c index 1ebedf0c3c..5c33b18f1a 100644 --- a/umac/dfs/core/src/misc/dfs_random_chan_sel.c +++ b/umac/dfs/core/src/misc/dfs_random_chan_sel.c @@ -1566,7 +1566,7 @@ uint16_t dfs_prepare_random_channel_for_freq(struct wlan_dfs *dfs, if ((*chan_wd == DFS_CH_WIDTH_80P80MHZ) && (flags & DFS_RANDOM_CH_FLAG_RESTRICTED_80P80_ENABLED) && target_freq) { - wlan_reg_set_channel_params_for_freq( + wlan_reg_set_channel_params_for_pwrmode( dfs->dfs_pdev_obj, target_freq, 0, chan_params, diff --git a/umac/dfs/dispatcher/src/wlan_dfs_utils_api.c b/umac/dfs/dispatcher/src/wlan_dfs_utils_api.c index 0c05977683..c8522ffc7b 100644 --- a/umac/dfs/dispatcher/src/wlan_dfs_utils_api.c +++ b/umac/dfs/dispatcher/src/wlan_dfs_utils_api.c @@ -915,7 +915,8 @@ QDF_STATUS utils_dfs_get_vdev_random_channel_for_freq( "input width=%d", chan_params->ch_width); if (*target_chan_freq) { - wlan_reg_set_channel_params_for_freq(pdev, *target_chan_freq, 0, + wlan_reg_set_channel_params_for_pwrmode( + pdev, *target_chan_freq, 0, chan_params, REG_CURRENT_PWR_MODE); utils_dfs_get_max_phy_mode(pdev, hw_mode); @@ -981,9 +982,9 @@ QDF_STATUS utils_dfs_bw_reduced_channel_for_freq( } dfs_curchan = dfs->dfs_curchan; ch_state = - wlan_reg_get_channel_state_for_freq(pdev, - dfs_curchan->dfs_ch_freq, - REG_CURRENT_PWR_MODE); + wlan_reg_get_channel_state_for_pwrmode(pdev, + dfs_curchan->dfs_ch_freq, + REG_CURRENT_PWR_MODE); if (ch_state == CHANNEL_STATE_DFS || ch_state == CHANNEL_STATE_ENABLE) { @@ -1000,10 +1001,10 @@ QDF_STATUS utils_dfs_bw_reduced_channel_for_freq( dfs_curchan->dfs_ch_mhz_freq_seg1; chan_params->mhz_freq_seg1 = dfs_curchan->dfs_ch_mhz_freq_seg2; - wlan_reg_set_channel_params_for_freq(pdev, - dfs_curchan->dfs_ch_freq, - 0, chan_params, - REG_CURRENT_PWR_MODE); + wlan_reg_set_channel_params_for_pwrmode(pdev, dfs_curchan-> + dfs_ch_freq, + 0, chan_params, + REG_CURRENT_PWR_MODE); *target_chan_freq = dfs_curchan->dfs_ch_freq; utils_dfs_get_max_phy_mode(pdev, hw_mode); diff --git a/umac/mlme/connection_mgr/core/src/wlan_cm_connect_scan.c b/umac/mlme/connection_mgr/core/src/wlan_cm_connect_scan.c index 8e2fe7e169..7906146c76 100644 --- a/umac/mlme/connection_mgr/core/src/wlan_cm_connect_scan.c +++ b/umac/mlme/connection_mgr/core/src/wlan_cm_connect_scan.c @@ -85,7 +85,7 @@ static QDF_STATUS cm_fill_scan_req(struct cnx_mgr *cm_ctx, ch_freq = cm_req->req.chan_freq; if (ch_freq) { - state = wlan_reg_get_channel_state_for_freq( + state = wlan_reg_get_channel_state_for_pwrmode( pdev, ch_freq, REG_CURRENT_PWR_MODE); diff --git a/umac/regulatory/core/src/reg_build_chan_list.c b/umac/regulatory/core/src/reg_build_chan_list.c index 78c7215adf..e0b80ec6b3 100644 --- a/umac/regulatory/core/src/reg_build_chan_list.c +++ b/umac/regulatory/core/src/reg_build_chan_list.c @@ -2366,9 +2366,10 @@ void reg_compute_pdev_current_chan_list(struct wlan_regulatory_pdev_priv_obj pdev_priv_obj-> cur_chan_list); - reg_modify_chan_list_for_max_chwidth(pdev_priv_obj->pdev_ptr, - pdev_priv_obj->cur_chan_list, - REG_CURRENT_PWR_MODE); + reg_modify_chan_list_for_max_chwidth_for_pwrmode( + pdev_priv_obj->pdev_ptr, + pdev_priv_obj->cur_chan_list, + REG_CURRENT_PWR_MODE); reg_modify_chan_list_for_6g_edge_channels(pdev_priv_obj->pdev_ptr, pdev_priv_obj-> diff --git a/umac/regulatory/core/src/reg_opclass.c b/umac/regulatory/core/src/reg_opclass.c index 00d57fbc67..8bcada0494 100644 --- a/umac/regulatory/core/src/reg_opclass.c +++ b/umac/regulatory/core/src/reg_opclass.c @@ -1224,8 +1224,10 @@ void reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev, } chan_params.ch_width = CH_WIDTH_MAX; - reg_set_channel_params_for_freq(pdev, freq, 0, &chan_params, - REG_CURRENT_PWR_MODE); + reg_set_channel_params_for_pwrmode(pdev, freq, + 0, + &chan_params, + REG_CURRENT_PWR_MODE); reg_freq_width_to_chan_op_class(pdev, freq, reg_get_bw_value(chan_params.ch_width), diff --git a/umac/regulatory/core/src/reg_services_common.c b/umac/regulatory/core/src/reg_services_common.c index f5fd0c139a..a6f6bb005f 100644 --- a/umac/regulatory/core/src/reg_services_common.c +++ b/umac/regulatory/core/src/reg_services_common.c @@ -3660,10 +3660,32 @@ wlan_reg_get_usable_channel(struct wlan_objmgr_pdev *pdev, } #endif +enum channel_state reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + qdf_freq_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; +} + +#ifdef CONFIG_REG_6G_PWRMODE enum channel_state -reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, - qdf_freq_t freq, - enum supported_6g_pwr_types in_6g_pwr_type) +reg_get_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_type) { enum channel_enum ch_idx; struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; @@ -3698,6 +3720,7 @@ reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_mem_free(reg_chan_list); return state; } +#endif static uint32_t reg_get_channel_flags_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq) @@ -3776,8 +3799,6 @@ static uint32_t reg_get_channel_flags_from_secondary_list_for_freq( * @pdev: Pointer to pdev. * @freq: Channel center frequency. * @bonded_chan_ptr: Pointer to bonded_channel_freq. - * @in_6g_pwr_type: Input 6g power mode which decides the which power mode based - * channel list will be chosen. * * Return: Channel State */ @@ -3785,9 +3806,7 @@ 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_ptr, - enum supported_6g_pwr_types - in_6g_pwr_type) + bonded_chan_ptr) { uint16_t chan_cfreq; enum channel_state chan_state = CHANNEL_STATE_INVALID; @@ -3800,7 +3819,48 @@ reg_get_5g_bonded_chan_array_for_freq(struct wlan_objmgr_pdev *pdev, chan_cfreq = bonded_chan_ptr->start_freq; while (chan_cfreq <= bonded_chan_ptr->end_freq) { - temp_chan_state = reg_get_channel_state_for_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; +} + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_get_5g_bonded_chan_array_for_pwrmode()- 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_ptr: Pointer to bonded_channel_freq. + * @in_6g_pwr_type: Input 6g power mode which decides the which power mode based + * channel list will be chosen. + * + * Return: Channel State + */ +static enum channel_state +reg_get_5g_bonded_chan_array_for_pwrmode(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + const struct bonded_channel_freq * + bonded_chan_ptr, + enum supported_6g_pwr_types + in_6g_pwr_type) +{ + uint16_t chan_cfreq; + enum channel_state chan_state = CHANNEL_STATE_INVALID; + enum channel_state temp_chan_state; + + if (!bonded_chan_ptr) { + reg_debug("bonded chan ptr is NULL"); + return chan_state; + } + + chan_cfreq = bonded_chan_ptr->start_freq; + while (chan_cfreq <= bonded_chan_ptr->end_freq) { + temp_chan_state = reg_get_channel_state_for_pwrmode( pdev, chan_cfreq, in_6g_pwr_type); @@ -3811,6 +3871,7 @@ reg_get_5g_bonded_chan_array_for_freq(struct wlan_objmgr_pdev *pdev, return chan_state; } +#endif #ifdef WLAN_FEATURE_11BE void reg_set_create_punc_bitmap(struct ch_params *ch_params, @@ -3849,8 +3910,8 @@ bool reg_is_punc_bitmap_valid(enum phy_ch_width bw, uint16_t puncture_bitmap) } /** - * reg_update_5g_bonded_channel_state_punc() - update channel state with - * static puncturing feature + * reg_update_5g_bonded_channel_state_punc_for_freq() - update channel state + * with static puncturing feature * @pdev: pointer to pdev * @bonded_chan_ptr: Pointer to bonded_channel_freq. * @ch_params: pointer to ch_params @@ -3858,7 +3919,54 @@ bool reg_is_punc_bitmap_valid(enum phy_ch_width bw, uint16_t puncture_bitmap) * * Return: void */ -static void reg_update_5g_bonded_channel_state_punc( +static void reg_update_5g_bonded_channel_state_punc_for_freq( + struct wlan_objmgr_pdev *pdev, + const struct bonded_channel_freq *bonded_chan_ptr, + struct ch_params *ch_params, + enum channel_state *chan_state) +{ + qdf_freq_t chan_cfreq; + enum channel_state temp_chan_state; + uint16_t puncture_bitmap = 0; + int i = 0; + enum channel_state update_state = CHANNEL_STATE_ENABLE; + + if (!pdev || !bonded_chan_ptr || !ch_params || !chan_state || + !ch_params->is_create_punc_bitmap) + return; + + 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 (!reg_is_state_allowed(temp_chan_state)) + puncture_bitmap |= BIT(i); + /* Remember of any of the sub20 channel is a DFS channel */ + if (temp_chan_state == CHANNEL_STATE_DFS) + update_state = CHANNEL_STATE_DFS; + chan_cfreq = chan_cfreq + BW_20_MHZ; + i++; + } + /* Validate puncture bitmap. Update channel state. */ + if (reg_is_punc_bitmap_valid(ch_params->ch_width, puncture_bitmap)) { + *chan_state = update_state; + ch_params->reg_punc_bitmap = puncture_bitmap; + } +} + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_update_5g_bonded_channel_state_punc_for_pwrmode() - update channel state + * with static puncturing feature + * @pdev: pointer to pdev + * @bonded_chan_ptr: Pointer to bonded_channel_freq. + * @ch_params: pointer to ch_params + * @chan_state: chan_state to be updated + * + * Return: void + */ +static void reg_update_5g_bonded_channel_state_punc_for_pwrmode( struct wlan_objmgr_pdev *pdev, const struct bonded_channel_freq *bonded_chan_ptr, struct ch_params *ch_params, @@ -3878,9 +3986,8 @@ static void reg_update_5g_bonded_channel_state_punc( 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, - in_6g_pwr_mode); + reg_get_channel_state_for_pwrmode(pdev, chan_cfreq, + in_6g_pwr_mode); if (!reg_is_state_allowed(temp_chan_state)) puncture_bitmap |= BIT(i); /* Remember of any of the sub20 channel is a DFS channel */ @@ -3895,8 +4002,17 @@ static void reg_update_5g_bonded_channel_state_punc( ch_params->reg_punc_bitmap = puncture_bitmap; } } +#endif #else -static void reg_update_5g_bonded_channel_state_punc( +static void reg_update_5g_bonded_channel_state_punc_for_freq( + struct wlan_objmgr_pdev *pdev, + const struct bonded_channel_freq *bonded_chan_ptr, + struct ch_params *ch_params, + enum channel_state *chan_state) +{ +} + +static void reg_update_5g_bonded_channel_state_punc_for_pwrmode( struct wlan_objmgr_pdev *pdev, const struct bonded_channel_freq *bonded_chan_ptr, struct ch_params *ch_params, @@ -3909,9 +4025,82 @@ static void reg_update_5g_bonded_channel_state_punc( enum channel_state reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, - struct ch_params *ch_params, - enum supported_6g_pwr_types - in_6g_pwr_mode) + struct ch_params *ch_params) +{ + 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 (!ch_params) { + reg_err_rl("Invalid ch_params"); + return CHANNEL_STATE_INVALID; + } + bw = ch_params->ch_width; + if (bw > CH_WIDTH_80P80MHZ) { + reg_err_rl("bw (%d) passed is not good", bw); + return CHANNEL_STATE_INVALID; + } + + chan_state = reg_get_5g_bonded_channel_for_freq(pdev, freq, bw, + &bonded_chan_ptr); + + reg_update_5g_bonded_channel_state_punc_for_freq(pdev, + bonded_chan_ptr, + ch_params, + &chan_state); + + 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; + return CHANNEL_STATE_DISABLE; +} + +#ifdef CONFIG_REG_6G_PWRMODE +enum channel_state +reg_get_5g_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + struct ch_params *ch_params, + enum supported_6g_pwr_types + in_6g_pwr_mode) { enum phy_ch_width bw; enum channel_enum ch_indx; @@ -3932,11 +4121,12 @@ reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, return CHANNEL_STATE_INVALID; } - chan_state = reg_get_5g_bonded_channel_for_freq(pdev, freq, bw, - &bonded_chan_ptr, - in_6g_pwr_mode); + chan_state = reg_get_5g_bonded_channel_for_pwrmode(pdev, freq, bw, + &bonded_chan_ptr, + in_6g_pwr_mode); - reg_update_5g_bonded_channel_state_punc(pdev, bonded_chan_ptr, + reg_update_5g_bonded_channel_state_punc_for_pwrmode( + pdev, bonded_chan_ptr, ch_params, &chan_state, in_6g_pwr_mode); @@ -3991,6 +4181,7 @@ reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, return chan_state; return CHANNEL_STATE_DISABLE; } +#endif enum channel_state reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, @@ -4013,8 +4204,9 @@ reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, (oper_ch_freq + 20 != sec_ch_freq)) return CHANNEL_STATE_INVALID; chan_state2 = - reg_get_channel_state_for_freq(pdev, sec_ch_freq, - REG_CURRENT_PWR_MODE); + reg_get_channel_state_for_pwrmode(pdev, + sec_ch_freq, + REG_CURRENT_PWR_MODE); if (chan_state2 == CHANNEL_STATE_INVALID) return chan_state2; } @@ -4027,8 +4219,9 @@ reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, reg_channels = pdev_priv_obj->cur_chan_list; - chan_state = reg_get_channel_state_for_freq(pdev, oper_ch_freq, - REG_CURRENT_PWR_MODE); + chan_state = reg_get_channel_state_for_pwrmode(pdev, + oper_ch_freq, + REG_CURRENT_PWR_MODE); if (chan_state2 < chan_state) chan_state = chan_state2; @@ -4141,10 +4334,8 @@ reg_get_320_bonded_chan_array(struct wlan_objmgr_pdev *pdev, #define BW_160MHZ 160 #define REG_IS_TOT_CHAN_BW_BELOW_160(_x, _y) \ (reg_is_state_allowed((_x)) && (_y) < BW_160MHZ) -#define REG_IS_PRIMARY_CHAN_NOT_ALLOWED(_x, _y, _z) \ - (!reg_is_state_allowed(reg_get_channel_state_for_freq((_x), \ - (_y), \ - (_z)))) +#define REG_IS_PRIMARY_CHAN_NOT_ALLOWED(_x, _y) \ + (!reg_is_state_allowed(reg_get_channel_state_for_freq((_x), (_y)))) static inline qdf_freq_t reg_get_endchan_cen_from_bandstart(qdf_freq_t band_start, @@ -4161,8 +4352,7 @@ reg_get_320_bonded_channel_state(struct wlan_objmgr_pdev *pdev, const struct bonded_channel_freq *bonded_chan_ptr, enum phy_ch_width bw, - uint16_t *out_punc_bitmap, - enum supported_6g_pwr_types in_6g_pwr_type) + uint16_t *out_punc_bitmap) { enum channel_state chan_state = CHANNEL_STATE_INVALID; enum channel_state temp_chan_state; @@ -4184,7 +4374,74 @@ reg_get_320_bonded_channel_state(struct wlan_objmgr_pdev *pdev, while (startchan_cfreq <= endchan_cfreq) { temp_chan_state = reg_get_channel_state_for_freq(pdev, - startchan_cfreq, + startchan_cfreq); + if (reg_is_state_allowed(temp_chan_state)) { + max_cont_bw += SUB_CHAN_BW; + *out_punc_bitmap &= ~BIT(i); + } + + if (temp_chan_state < chan_state) + chan_state = temp_chan_state; + + startchan_cfreq = startchan_cfreq + SUB_CHAN_BW; + i++; + } + + /* After iterating through all the subchannels, if the final channel + * state is invalid/disable, it means all our subchannels are not + * valid and we could not find a 320 MHZ channel. + * If we have found a channel where the max width is: + * 1. Less than 160: there is no puncturing needed. Hence return + * the chan state as invalid. Or if the primary freq given is not + * supported by regulatory, the channel cannot be enabled as a + * punctured channel. So return channel state as invalid. + * 2. If greater than 160: Mark the invalid channels as punctured. + * and return channel state as ENABLE. + */ + if (REG_IS_TOT_CHAN_BW_BELOW_160(chan_state, max_cont_bw) || + REG_IS_PRIMARY_CHAN_NOT_ALLOWED(pdev, freq)) + return CHANNEL_STATE_INVALID; + else + return CHANNEL_STATE_ENABLE; +} + +#ifdef CONFIG_REG_6G_PWRMODE +#define REG_IS_PRIMARY_CHAN_NOT_ALLOWED_FOR_PWRMODE(_x, _y, _z) \ + (!reg_is_state_allowed(reg_get_channel_state_for_pwrmode((_x), \ + (_y), \ + (_z)))) + +static enum channel_state +reg_get_320_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + const struct bonded_channel_freq + *bonded_chan_ptr, + enum phy_ch_width bw, + uint16_t *out_punc_bitmap, + enum supported_6g_pwr_types + in_6g_pwr_type) +{ + enum channel_state chan_state = CHANNEL_STATE_INVALID; + enum channel_state temp_chan_state; + uint16_t startchan_cfreq, endchan_cfreq; + uint16_t max_cont_bw, i; + + *out_punc_bitmap = ALL_SCHANS_PUNC; + + if (!bonded_chan_ptr) + return chan_state; + + startchan_cfreq = bonded_chan_ptr->start_freq; + endchan_cfreq = + reg_get_endchan_cen_from_bandstart(startchan_cfreq, + BW_320_MHZ); + max_cont_bw = 0; + i = 0; + + while (startchan_cfreq <= endchan_cfreq) { + temp_chan_state = + reg_get_channel_state_for_pwrmode(pdev, + startchan_cfreq, in_6g_pwr_type); if (reg_is_state_allowed(temp_chan_state)) { max_cont_bw += SUB_CHAN_BW; @@ -4210,11 +4467,14 @@ reg_get_320_bonded_channel_state(struct wlan_objmgr_pdev *pdev, * and return channel state as ENABLE. */ if (REG_IS_TOT_CHAN_BW_BELOW_160(chan_state, max_cont_bw) || - REG_IS_PRIMARY_CHAN_NOT_ALLOWED(pdev, freq, in_6g_pwr_type)) + REG_IS_PRIMARY_CHAN_NOT_ALLOWED_FOR_PWRMODE(pdev, + freq, + in_6g_pwr_type)) return CHANNEL_STATE_INVALID; else return CHANNEL_STATE_ENABLE; } +#endif static inline bool reg_is_pri_within_240mhz_chan(qdf_freq_t freq) { @@ -4283,13 +4543,141 @@ reg_fill_chan320mhz_seg0_center(struct wlan_objmgr_pdev *pdev, * @band_center_320: Center of 320MHZ channel. * @chan_list: Pointer to reg_channel_list to be filled. * @update_bw: Flag to hold if bw is updated. + * + * Return - None. + */ +static void +reg_fill_channel_list_for_320(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum phy_ch_width *in_ch_width, + qdf_freq_t band_center_320, + struct reg_channel_list *chan_list, + bool *update_bw) +{ + uint8_t num_bonded_pairs, i, num_ch_params; + enum channel_state chan_state; + uint16_t array_size = QDF_ARRAY_SIZE(bonded_chan_320mhz_list_freq); + uint16_t out_punc_bitmap; + uint16_t max_reg_bw; + enum channel_enum chan_enum; + const struct bonded_channel_freq *bonded_ch_ptr[2] = {NULL, NULL}; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + + *update_bw = false; + + chan_enum = reg_get_chan_enum_for_freq(freq); + if (chan_enum == INVALID_CHANNEL) { + reg_err("chan freq is not valid"); + return; + } + + 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; + } + + /* Maximum bandwidth of the channel supported by regulatory for + * the given freq. + */ + max_reg_bw = pdev_priv_obj->cur_chan_list[chan_enum].max_bw; + + /* Regulatory does not support BW greater than 160. + * Try finding a channel in a lower mode. + */ + if (max_reg_bw <= BW_160MHZ) { + *in_ch_width = get_next_lower_bandwidth(*in_ch_width); + *update_bw = true; + return; + } + + num_bonded_pairs = + reg_get_320_bonded_chan_array(pdev, freq, band_center_320, + bonded_chan_320mhz_list_freq, + array_size, + bonded_ch_ptr); + + if (!num_bonded_pairs) { + if (band_center_320) { + reg_debug("No bonded pair for the given band_center\n"); + chan_list->num_ch_params = 0; + } else { + /* Could not find a 320 MHZ bonded channel pair, + * find a channel of lower BW. + */ + *in_ch_width = get_next_lower_bandwidth(*in_ch_width); + *update_bw = true; + } + return; + } + + for (i = 0, num_ch_params = 0 ; i < num_bonded_pairs; i++) { + /* Chan_state to hold the channel state of bonding + * pair of channels. + */ + chan_state = + reg_get_320_bonded_channel_state(pdev, freq, + bonded_ch_ptr[i], + *in_ch_width, + &out_punc_bitmap); + if (chan_state == CHANNEL_STATE_ENABLE) { + struct ch_params *t_chan_param = + &chan_list->chan_param[num_ch_params]; + + t_chan_param->mhz_freq_seg1 = + (bonded_ch_ptr[i]->start_freq + + bonded_ch_ptr[i]->end_freq) / 2; + t_chan_param->center_freq_seg1 = + reg_freq_to_chan(pdev, + t_chan_param->mhz_freq_seg1); + t_chan_param->ch_width = *in_ch_width; + t_chan_param->reg_punc_bitmap = out_punc_bitmap; + + reg_fill_chan320mhz_seg0_center(pdev, + t_chan_param, + freq); + num_ch_params++; + chan_list->num_ch_params = num_ch_params; + } + } + + /* The bonded pairs could not create any channels, + * lower the bandwidth to find a channel. + */ + if (!chan_list->num_ch_params) { + *in_ch_width = get_next_lower_bandwidth(*in_ch_width); + *update_bw = true; + } +} + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_fill_channel_list_for_320_for_pwrmode() - Fill 320MHZ channel list. If we + * are unable to find a channel whose width is greater than 160MHZ and less + * than 320 with the help of puncturing, using the given freq, set "update_bw" + * variable to be true, lower the channel width and return to the caller. + * The caller fetches a channel of reduced mode based on "update_bw" flag. + * + * If 320 band center is 0, return all the 320 channels + * that match the primary frequency else return only channel + * that matches 320 band center. + * + * @pdev: Pointer to struct wlan_objmgr_pdev. + * @freq: Input frequency in MHZ. + * @ch_width: Input channel width, if a channel of the given width is not + * found, reduce the channel width to the next lower mode and pass it to the + * caller. + * @band_center_320: Center of 320MHZ channel. + * @chan_list: Pointer to reg_channel_list to be filled. + * @update_bw: Flag to hold if bw is updated. * @in_6g_pwr_type: Input 6g power mode which decides the which power mode based * channel list will be chosen. * * Return - None. */ static void -reg_fill_channel_list_for_320(struct wlan_objmgr_pdev *pdev, +reg_fill_channel_list_for_320_for_pwrmode( + struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, enum phy_ch_width *in_ch_width, qdf_freq_t band_center_320, @@ -4371,7 +4759,8 @@ reg_fill_channel_list_for_320(struct wlan_objmgr_pdev *pdev, * pair of channels. */ chan_state = - reg_get_320_bonded_channel_state(pdev, freq, + reg_get_320_bonded_channel_state_for_pwrmode( + pdev, freq, bonded_ch_ptr[i], *in_ch_width, &out_punc_bitmap, @@ -4406,6 +4795,7 @@ reg_fill_channel_list_for_320(struct wlan_objmgr_pdev *pdev, *update_bw = true; } } +#endif /** * No subchannels are punctured @@ -4440,14 +4830,41 @@ static void reg_set_chan_params_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, qdf_freq_t sec_ch_2g_freq, - struct reg_channel_list *chan_list, - enum supported_6g_pwr_types in_6g_pwr_mode) + struct reg_channel_list *chan_list) +{ + wlan_reg_get_channel_params(pdev, freq, sec_ch_2g_freq, + &chan_list->chan_param[0], + REG_CURRENT_PWR_MODE); +} +#endif + +#ifdef CONFIG_REG_6G_PWRMODE +#ifdef CONFIG_REG_CLIENT +static void +reg_set_chan_params_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + struct reg_channel_list *chan_list, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + reg_set_channel_params_for_pwrmode(pdev, freq, sec_ch_2g_freq, + &chan_list->chan_param[0], + in_6g_pwr_mode); +} +#else +static void +reg_set_chan_params_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + struct reg_channel_list *chan_list, + enum supported_6g_pwr_types in_6g_pwr_mode) { wlan_reg_get_channel_params(pdev, freq, sec_ch_2g_freq, &chan_list->chan_param[0], in_6g_pwr_mode); } #endif +#endif /** * reg_fill_pre320mhz_channel() - Fill channel params for channel width @@ -4457,11 +4874,35 @@ reg_set_chan_params_for_freq(struct wlan_objmgr_pdev *pdev, * @ch_width: Channel width * @freq: Center frequency of the primary channel in MHz * @sec_ch_2g_freq: Secondary 2G channel frequency in MHZ + */ +static void +reg_fill_pre320mhz_channel(struct wlan_objmgr_pdev *pdev, + struct reg_channel_list *chan_list, + enum phy_ch_width ch_width, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq) +{ + chan_list->num_ch_params = 1; + chan_list->chan_param[0].ch_width = ch_width; + chan_list->chan_param[0].reg_punc_bitmap = NO_SCHANS_PUNC; + reg_set_chan_params_for_freq(pdev, freq, sec_ch_2g_freq, chan_list); +} + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_fill_pre320mhz_channel_for_pwrmode() - Fill channel params for channel + * width less than 320. + * @pdev: Pointer to struct wlan_objmgr_pdev + * @chan_list: Pointer to struct reg_channel_list + * @ch_width: Channel width + * @freq: Center frequency of the primary channel in MHz + * @sec_ch_2g_freq: Secondary 2G channel frequency in MHZ * @in_6g_pwr_type: Input 6g power mode which decides the which power mode based * channel list will be chosen. */ static void -reg_fill_pre320mhz_channel(struct wlan_objmgr_pdev *pdev, +reg_fill_pre320mhz_channel_for_pwrmode( + struct wlan_objmgr_pdev *pdev, struct reg_channel_list *chan_list, enum phy_ch_width ch_width, qdf_freq_t freq, @@ -4471,9 +4912,10 @@ reg_fill_pre320mhz_channel(struct wlan_objmgr_pdev *pdev, chan_list->num_ch_params = 1; chan_list->chan_param[0].ch_width = ch_width; chan_list->chan_param[0].reg_punc_bitmap = NO_SCHANS_PUNC; - reg_set_chan_params_for_freq(pdev, freq, sec_ch_2g_freq, chan_list, - in_6g_pwr_mode); + reg_set_chan_params_for_pwrmode(pdev, freq, sec_ch_2g_freq, chan_list, + in_6g_pwr_mode); } +#endif void reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, @@ -4481,8 +4923,7 @@ reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, qdf_freq_t sec_ch_2g_freq, enum phy_ch_width in_ch_width, qdf_freq_t band_center_320, - struct reg_channel_list *chan_list, - enum supported_6g_pwr_types in_6g_pwr_mode) + struct reg_channel_list *chan_list) { bool update_bw; @@ -4498,7 +4939,7 @@ reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, update_bw = 0; reg_fill_channel_list_for_320(pdev, freq, &in_ch_width, band_center_320, chan_list, - &update_bw, in_6g_pwr_mode); + &update_bw); if (!update_bw) return; } @@ -4509,9 +4950,50 @@ reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, * next available mode and fills ch_params. */ reg_fill_pre320mhz_channel(pdev, chan_list, in_ch_width, freq, + sec_ch_2g_freq); +} + +#ifdef CONFIG_REG_6G_PWRMODE +void +reg_fill_channel_list_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + enum phy_ch_width in_ch_width, + qdf_freq_t band_center_320, + struct reg_channel_list *chan_list, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + bool update_bw; + + if (!chan_list) { + reg_err("channel params is NULL"); + return; + } + + if (in_ch_width >= CH_WIDTH_MAX) + in_ch_width = CH_WIDTH_320MHZ; + + if (in_ch_width == CH_WIDTH_320MHZ) { + update_bw = 0; + reg_fill_channel_list_for_320_for_pwrmode( + pdev, freq, &in_ch_width, + band_center_320, chan_list, + &update_bw, in_6g_pwr_mode); + if (!update_bw) + return; + } + + /* A 320 channel is not available (or) user has not requested + * for a 320MHZ channel, look for channels in lower modes, + * reg_set_5g_channel_params_for_freq() finds for the + * next available mode and fills ch_params. + */ + reg_fill_pre320mhz_channel_for_pwrmode( + pdev, chan_list, in_ch_width, freq, sec_ch_2g_freq, in_6g_pwr_mode); } #endif +#endif #if defined(WLAN_FEATURE_11BE) && defined(CONFIG_REG_CLIENT) enum channel_state @@ -4566,13 +5048,10 @@ 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, - enum supported_6g_pwr_types in_6g_pwr_mode) - + **bonded_chan_ptr_ptr) { if (ch_width == CH_WIDTH_20MHZ) - return reg_get_channel_state_for_freq(pdev, freq, - in_6g_pwr_mode); + return reg_get_channel_state_for_freq(pdev, freq); /* Fetch the bonded_chan_ptr for width greater than 20MHZ. */ *bonded_chan_ptr_ptr = reg_get_bonded_chan_entry(freq, ch_width); @@ -4583,6 +5062,33 @@ reg_get_5g_bonded_channel_for_freq(struct wlan_objmgr_pdev *pdev, } return reg_get_5g_bonded_chan_array_for_freq(pdev, freq, + *bonded_chan_ptr_ptr); +} +#endif + +#ifdef CONFIG_REG_6G_PWRMODE +enum channel_state +reg_get_5g_bonded_channel_for_pwrmode(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width ch_width, + const struct bonded_channel_freq + **bonded_chan_ptr_ptr, + enum supported_6g_pwr_types + in_6g_pwr_mode) +{ + if (ch_width == CH_WIDTH_20MHZ) + return reg_get_channel_state_for_pwrmode(pdev, freq, + in_6g_pwr_mode); + + /* Fetch the bonded_chan_ptr for width greater than 20MHZ. */ + *bonded_chan_ptr_ptr = reg_get_bonded_chan_entry(freq, ch_width); + + if (!(*bonded_chan_ptr_ptr)) { + reg_debug_rl("bonded_chan_ptr_ptr is NULL"); + return CHANNEL_STATE_INVALID; + } + + return reg_get_5g_bonded_chan_array_for_pwrmode(pdev, freq, *bonded_chan_ptr_ptr, in_6g_pwr_mode); } @@ -4595,12 +5101,173 @@ reg_get_5g_bonded_channel_for_freq(struct wlan_objmgr_pdev *pdev, * @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 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; + struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj; + enum channel_enum chan_enum, sec_5g_chan_enum; + uint16_t max_bw, bw_80, sec_5g_freq_max_bw = 0; + + if (!ch_params) { + reg_err("ch_params is NULL"); + return; + } + + chan_enum = reg_get_chan_enum_for_freq(freq); + if (chan_enum == INVALID_CHANNEL) { + reg_err("chan freq is not valid"); + return; + } + + 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; + } + + 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; + } + + max_bw = pdev_priv_obj->cur_chan_list[chan_enum].max_bw; + bw_80 = reg_get_bw_value(CH_WIDTH_80MHZ); + + if (ch_params->ch_width == CH_WIDTH_80P80MHZ) { + sec_5g_chan_enum = + reg_get_chan_enum_for_freq(ch_params->mhz_freq_seg1 - + NEAREST_20MHZ_CHAN_FREQ_OFFSET); + if (sec_5g_chan_enum == INVALID_CHANNEL) { + reg_err("secondary channel freq is not valid"); + return; + } + + sec_5g_freq_max_bw = + pdev_priv_obj->cur_chan_list[sec_5g_chan_enum].max_bw; + } + + while (ch_params->ch_width != CH_WIDTH_INVALID) { + if (ch_params->ch_width == CH_WIDTH_80P80MHZ) { + if ((max_bw < bw_80) || (sec_5g_freq_max_bw < bw_80)) + goto update_bw; + } else if (max_bw < reg_get_bw_value(ch_params->ch_width)) { + goto update_bw; + } + + 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); + + if (ch_params->ch_width == CH_WIDTH_80P80MHZ) { + struct ch_params temp_ch_params = {0}; + + temp_ch_params.ch_width = CH_WIDTH_80MHZ; + /* Puncturing patter is not needed for 80+80 */ + reg_set_create_punc_bitmap(&temp_ch_params, false); + chan_state2 = reg_get_5g_bonded_channel_state_for_freq( + pdev, ch_params->mhz_freq_seg1 - + NEAREST_20MHZ_CHAN_FREQ_OFFSET, + &temp_ch_params); + + chan_state = reg_combine_channel_states( + chan_state, chan_state2); + } + + if ((chan_state != CHANNEL_STATE_ENABLE) && + (chan_state != CHANNEL_STATE_DFS)) + goto update_bw; + if (ch_params->ch_width <= CH_WIDTH_20MHZ) { + ch_params->sec_ch_offset = NO_SEC_CH; + ch_params->mhz_freq_seg0 = freq; + ch_params->center_freq_seg0 = + reg_freq_to_chan(pdev, + ch_params->mhz_freq_seg0); + break; + } else if (ch_params->ch_width >= CH_WIDTH_40MHZ) { + bonded_chan_ptr2 = + reg_get_bonded_chan_entry(freq, CH_WIDTH_40MHZ); + + if (!bonded_chan_ptr || !bonded_chan_ptr2) + goto update_bw; + 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; + ch_params->center_freq_seg0 = + reg_freq_to_chan(pdev, + ch_params->mhz_freq_seg0); + break; + } +update_bw: + ch_params->ch_width = + get_next_lower_bandwidth(ch_params->ch_width); + } + + if (ch_params->ch_width == CH_WIDTH_160MHZ) { + ch_params->mhz_freq_seg1 = ch_params->mhz_freq_seg0; + ch_params->center_freq_seg1 = + reg_freq_to_chan(pdev, + ch_params->mhz_freq_seg1); + + 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; + ch_params->center_freq_seg0 = + reg_freq_to_chan(pdev, + ch_params->mhz_freq_seg0); + } + } + + /* 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; + } +} + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_set_5g_channel_params_for_pwrmode()- 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. * @in_6g_pwr_type: Input 6g power mode which decides the which power mode based * channel list will be chosen. * * Return: void */ -static void reg_set_5g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, +static void reg_set_5g_channel_params_for_pwrmode( + struct wlan_objmgr_pdev *pdev, uint16_t freq, struct ch_params *ch_params, enum supported_6g_pwr_types @@ -4683,11 +5350,11 @@ static void reg_set_5g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, bonded_chan_ptr = NULL; bonded_chan_ptr2 = NULL; - chan_state = reg_get_5g_bonded_channel_for_freq( + chan_state = reg_get_5g_bonded_channel_for_pwrmode( pdev, freq, ch_params->ch_width, &bonded_chan_ptr, in_6g_pwr_type); - chan_state = reg_get_5g_bonded_channel_state_for_freq( + chan_state = reg_get_5g_bonded_channel_state_for_pwrmode( pdev, freq, ch_params, in_6g_pwr_type); if (ch_params->ch_width == CH_WIDTH_80P80MHZ) { @@ -4696,7 +5363,8 @@ static void reg_set_5g_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, temp_ch_params.ch_width = CH_WIDTH_80MHZ; /* Puncturing patter is not needed for 80+80 */ reg_set_create_punc_bitmap(&temp_ch_params, false); - chan_state2 = reg_get_5g_bonded_channel_state_for_freq( + chan_state2 = + reg_get_5g_bonded_channel_state_for_pwrmode( pdev, ch_params->mhz_freq_seg1 - NEAREST_20MHZ_CHAN_FREQ_OFFSET, &temp_ch_params, in_6g_pwr_type); @@ -4745,7 +5413,7 @@ update_bw: reg_freq_to_chan(pdev, ch_params->mhz_freq_seg1); - chan_state = reg_get_5g_bonded_channel_for_freq( + chan_state = reg_get_5g_bonded_channel_for_pwrmode( pdev, freq, CH_WIDTH_80MHZ, &bonded_chan_ptr, in_6g_pwr_type); if (bonded_chan_ptr) { @@ -4765,6 +5433,7 @@ update_bw: ch_params->center_freq_seg1 = 0; } } +#endif #ifdef CONFIG_REG_CLIENT static qdf_freq_t reg_get_sec_ch_2g_freq(struct wlan_objmgr_pdev *pdev, @@ -4932,12 +5601,27 @@ void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, qdf_freq_t sec_ch_2g_freq, - struct ch_params *ch_params, - enum supported_6g_pwr_types in_6g_pwr_mode) + 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, - in_6g_pwr_mode); + 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); +} +#endif + +#ifdef CONFIG_REG_6G_PWRMODE +void +reg_set_channel_params_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + struct ch_params *ch_params, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + if (reg_is_5ghz_ch_freq(freq) || reg_is_6ghz_chan_freq(freq)) + reg_set_5g_channel_params_for_pwrmode(pdev, freq, ch_params, + in_6g_pwr_mode); else if (reg_is_24ghz_ch_freq(freq)) reg_set_2g_channel_params_for_freq(pdev, freq, ch_params, sec_ch_2g_freq); @@ -5145,16 +5829,29 @@ enum reg_wifi_band reg_freq_to_band(qdf_freq_t freq) return REG_BAND_UNKNOWN; } -bool reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, - enum supported_6g_pwr_types in_6g_pwr_mode) +bool reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq) { enum channel_state ch_state; - ch_state = reg_get_channel_state_for_freq(pdev, freq, in_6g_pwr_mode); + ch_state = reg_get_channel_state_for_freq(pdev, freq); return ch_state == CHANNEL_STATE_DISABLE; } +#ifdef CONFIG_REG_6G_PWRMODE +bool reg_is_disable_for_pwrmode(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + enum channel_state ch_state; + + ch_state = reg_get_channel_state_for_pwrmode(pdev, + freq, + in_6g_pwr_mode); + + return ch_state == CHANNEL_STATE_DISABLE; +} +#endif + #ifdef CONFIG_REG_CLIENT bool reg_is_disable_in_secondary_list_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq) diff --git a/umac/regulatory/core/src/reg_services_common.h b/umac/regulatory/core/src/reg_services_common.h index 32ede8aa4d..b3bacf3952 100644 --- a/umac/regulatory/core/src/reg_services_common.h +++ b/umac/regulatory/core/src/reg_services_common.h @@ -879,14 +879,27 @@ reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev, * reg_get_channel_state_for_freq() - Get channel state from regulatory * @pdev: Pointer to pdev * @freq: channel center frequency. - * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: channel state */ enum channel_state reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, - qdf_freq_t freq, - enum supported_6g_pwr_types in_6g_pwr_type); + qdf_freq_t freq); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_get_channel_state_for_freq() - Get channel state from regulatory + * @pdev: Pointer to pdev + * @freq: channel center frequency. + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: channel state + */ +enum channel_state +reg_get_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_type); +#endif #ifdef CONFIG_REG_CLIENT /** @@ -915,9 +928,16 @@ enum channel_state reg_get_channel_state_from_secondary_list_for_freq( enum channel_state reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, - struct ch_params *ch_params, - enum supported_6g_pwr_types - in_6g_pwr_mode); + struct ch_params *ch_params); + +#ifdef CONFIG_REG_6G_PWRMODE +enum channel_state +reg_get_5g_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + struct ch_params *ch_params, + enum supported_6g_pwr_types + in_6g_pwr_mode); +#endif /** * reg_get_2g_bonded_channel_state_for_freq() - Get channel state for 2G @@ -943,17 +963,35 @@ reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, * @freq: Channel center frequency. * @sec_ch_2g_freq: Secondary 2G channel frequency * @ch_params: pointer to the channel parameters. - * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: None */ void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, qdf_freq_t sec_ch_2g_freq, - struct ch_params *ch_params, - enum supported_6g_pwr_types - in_6g_pwr_mode); + struct ch_params *ch_params); +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_set_channel_params_for_pwrmode () - 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. + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: None + */ +void reg_set_channel_params_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + struct ch_params *ch_params, + enum supported_6g_pwr_types + in_6g_pwr_mode); +#endif + +#ifdef WLAN_FEATURE_11BE /** * reg_fill_channel_list() - Fills an array of ch_params (list of * channels) for the given channel width and primary freq. @@ -972,15 +1010,42 @@ void reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, * * Return: None */ -#ifdef WLAN_FEATURE_11BE void reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, qdf_freq_t sec_ch_2g_freq, enum phy_ch_width ch_width, qdf_freq_t band_center_320, - struct reg_channel_list *chan_list, - enum supported_6g_pwr_types in_6g_pwr_mode); + struct reg_channel_list *chan_list); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_fill_channel_list_for_pwrmode() - Fills an array of ch_params (list of + * channels) for the given channel width and primary freq. + * If 320 band_center is given, ch_params corresponding to the + * given band_center is filled. + * + * @pdev: Pointer to pdev + * @freq: Center frequency of the primary channel in MHz + * @sec_ch_2g_freq: Secondary 2G channel frequency in MHZ + * @ch_width: Input channel width. + * @band_center: Center frequency of the 320MHZ channel. + * @chan_list: Pointer to struct reg_channel_list to be filled (Output). + * The caller is supposed to provide enough storage for the elements + * in the list. + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: None + */ +void +reg_fill_channel_list_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + enum phy_ch_width ch_width, + qdf_freq_t band_center_320, + struct reg_channel_list *chan_list, + enum supported_6g_pwr_types in_6g_pwr_mode); +#endif /** * reg_is_punc_bitmap_valid() - is puncture bitmap valid or not @@ -1124,8 +1189,29 @@ 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, - enum supported_6g_pwr_types in_6g_pwr_mode); + **bonded_chan_ptr_ptr); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_get_5g_bonded_channel_for_pwrmode()- 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. + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: Channel State + */ +enum channel_state +reg_get_5g_bonded_channel_for_pwrmode(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width ch_width, + const struct bonded_channel_freq + **bonded_chan_ptr_ptr, + enum supported_6g_pwr_types + in_6g_pwr_mode); +#endif /** * reg_is_disable_for_freq() - Check if the given channel frequency in @@ -1136,8 +1222,21 @@ reg_get_5g_bonded_channel_for_freq(struct wlan_objmgr_pdev *pdev, * * Return: True if channel state is disabled, else false */ -bool reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, - enum supported_6g_pwr_types in_6g_pwr_mode); +bool reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * reg_is_disable_for_pwrmode() - Check if the given channel frequency in + * disable state + * @pdev: Pointer to pdev + * @freq: Channel frequency + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: True if channel state is disabled, else false + */ +bool reg_is_disable_for_pwrmode(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_mode); +#endif #ifdef CONFIG_REG_CLIENT /** @@ -1699,7 +1798,8 @@ reg_find_txpower_from_6g_list(qdf_freq_t freq, void reg_update_max_phymode_chwidth_for_pdev(struct wlan_objmgr_pdev *pdev); /** - * reg_modify_chan_list_for_max_chwidth() - Update the maximum bandwidth for + * reg_modify_chan_list_for_max_chwidth_for_pwrmode() - Update the maximum + * bandwidth for * each channel in the current channel list. * @pdev: Pointer to PDEV object. * @cur_chan_list: Pointer to the pdev current channel list. @@ -1717,10 +1817,11 @@ void reg_update_max_phymode_chwidth_for_pdev(struct wlan_objmgr_pdev *pdev); * capabilities and the availability of adjacent channels. */ void -reg_modify_chan_list_for_max_chwidth(struct wlan_objmgr_pdev *pdev, - struct regulatory_channel *cur_chan_list, - enum supported_6g_pwr_types - in_6g_pwr_mode); +reg_modify_chan_list_for_max_chwidth_for_pwrmode(struct wlan_objmgr_pdev *pdev, + struct regulatory_channel + *cur_chan_list, + enum supported_6g_pwr_types + in_6g_pwr_mode); #else static inline void @@ -1729,12 +1830,13 @@ reg_update_max_phymode_chwidth_for_pdev(struct wlan_objmgr_pdev *pdev) } static inline void -reg_modify_chan_list_for_max_chwidth(struct wlan_objmgr_pdev *pdev, - struct regulatory_channel *cur_chan_list, - enum supported_6g_pwr_types in_6g_pwr_mode) +reg_modify_chan_list_for_max_chwidth_for_pwrmode(struct wlan_objmgr_pdev *pdev, + struct regulatory_channel + *cur_chan_list, + enum supported_6g_pwr_types + in_6g_pwr_mode) { } - #endif /* CONFIG_HOST_FIND_CHAN */ /** diff --git a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h index f62d78aa2c..cb6ec951b2 100644 --- a/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h +++ b/umac/regulatory/dispatcher/inc/wlan_reg_services_api.h @@ -790,7 +790,6 @@ wlan_reg_get_6g_afc_chan_list(struct wlan_objmgr_pdev *pdev, * @freq: channel frequency * @bw: channel band width * @sec_freq: secondary frequency - * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: channel state */ @@ -798,9 +797,27 @@ enum channel_state wlan_reg_get_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, enum phy_ch_width bw, - qdf_freq_t sec_freq, - enum supported_6g_pwr_types - in_6g_pwr_mode); + qdf_freq_t sec_freq); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * wlan_reg_get_bonded_channel_state_for_pwrmode() - Get bonded channel freq + * state + * @freq: channel frequency + * @bw: channel band width + * @sec_freq: secondary frequency + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: channel state + */ +enum channel_state +wlan_reg_get_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum phy_ch_width bw, + qdf_freq_t sec_freq, + enum supported_6g_pwr_types + in_6g_pwr_mode); +#endif /** * wlan_reg_set_dfs_region() - set the dfs region @@ -1298,22 +1315,38 @@ 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, + qdf_freq_t freq, + enum phy_ch_width bw); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * wlan_reg_get_5g_bonded_channel_state_for_pwrmode() - Get 5G bonded channel + * state. + * @pdev: The physical dev to program country code or regdomain + * @freq: channel frequency. + * @bw: channel band width * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: channel state */ enum channel_state -wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, - qdf_freq_t freq, - enum phy_ch_width bw, - enum supported_6g_pwr_types - in_6g_pwr_type); +wlan_reg_get_5g_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum phy_ch_width bw, + enum supported_6g_pwr_types + in_6g_pwr_type); +#endif + /** * wlan_reg_get_2g_bonded_channel_state_for_freq() - Get 2G bonded channel state * @pdev: The physical dev to program country code or regdomain @@ -1333,14 +1366,28 @@ wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, * wlan_reg_get_channel_state_for_freq() - Get channel state from regulatory * @pdev: Pointer to pdev * @freq: channel center frequency. - * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: channel state */ enum channel_state wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * wlan_reg_get_channel_state_for_pwrmode() - Get channel state from regulatory + * @pdev: Pointer to pdev + * @freq: channel center frequency. + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: channel state + */ +enum channel_state +wlan_reg_get_channel_state_for_pwrmode( + struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, enum supported_6g_pwr_types in_6g_pwr_type); +#endif #ifdef CONFIG_REG_CLIENT /** @@ -1356,6 +1403,7 @@ enum channel_state wlan_reg_get_channel_state_from_secondary_list_for_freq( qdf_freq_t freq); #endif +#ifdef WLAN_FEATURE_11BE /** * wlan_reg_fill_channel_list() - Fills the reg_channel_list (list of channels) * @pdev: Pointer to struct wlan_objmgr_pdev. @@ -1364,18 +1412,15 @@ enum channel_state wlan_reg_get_channel_state_from_secondary_list_for_freq( * @ch_width: Channel width of type 'enum phy_ch_width'. * @band_center_320: Center frequency of 320MHZ channel. * @chan_list: Pointer to struct reg_channel_list to be filled (Output param). - * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: None */ -#ifdef WLAN_FEATURE_11BE void wlan_reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, qdf_freq_t sec_ch_2g_freq, enum phy_ch_width ch_width, qdf_freq_t band_center_320, - struct reg_channel_list *chan_list, - enum supported_6g_pwr_types in_6g_pwr_type); + struct reg_channel_list *chan_list); /** * wlan_reg_is_punc_bitmap_valid() - is puncture bitmap valid or not @@ -1396,6 +1441,29 @@ bool wlan_reg_is_punc_bitmap_valid(enum phy_ch_width bw, */ void wlan_reg_set_create_punc_bitmap(struct ch_params *ch_params, bool is_create_punc_bitmap); +#ifdef CONFIG_REG_6G_PWRMODE +/** + * wlan_reg_fill_channel_list_for_pwrmode() - Fills the reg_channel_list + * (list of channels) + * @pdev: Pointer to struct wlan_objmgr_pdev. + * @freq: Center frequency of the primary channel in MHz + * @sec_ch_2g_freq: Secondary channel center frequency. + * @ch_width: Channel width of type 'enum phy_ch_width'. + * @band_center_320: Center frequency of 320MHZ channel. + * @chan_list: Pointer to struct reg_channel_list to be filled (Output param). + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: None + */ +void wlan_reg_fill_channel_list_for_pwrmode( + struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + enum phy_ch_width ch_width, + qdf_freq_t band_center_320, + struct reg_channel_list *chan_list, + enum supported_6g_pwr_types in_6g_pwr_type); +#endif #else static inline void wlan_reg_set_create_punc_bitmap(struct ch_params *ch_params, bool is_create_punc_bitmap) @@ -1410,16 +1478,33 @@ static inline void wlan_reg_set_create_punc_bitmap(struct ch_params *ch_params, * @freq: channel center frequency. * @sec_ch_2g_freq: Secondary channel center frequency. * @ch_params: pointer to the channel parameters. - * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: None */ void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, qdf_freq_t sec_ch_2g_freq, - struct ch_params *ch_params, - enum supported_6g_pwr_types - in_6g_pwr_mode); + struct ch_params *ch_params); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * wlan_reg_set_channel_params_for_pwrmode() - 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. + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: None + */ +void wlan_reg_set_channel_params_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + struct ch_params *ch_params, + enum supported_6g_pwr_types + in_6g_pwr_mode); +#endif /** * wlan_reg_get_channel_cfreq_reg_power_for_freq() - Provide the channel @@ -1476,13 +1561,25 @@ bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, * wlan_reg_is_disable_for_freq() - Checks chan state for disabled * @pdev: pdev ptr * @freq: Channel center frequency - * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: true or false */ bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq); +#ifdef CONFIG_REG_6G_PWRMODE +/** + * wlan_reg_is_disable_for_pwrmode() - Checks chan state for disabled + * @pdev: pdev ptr + * @freq: Channel center frequency + * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. + * + * Return: true or false + */ +bool wlan_reg_is_disable_for_pwrmode( + struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, enum supported_6g_pwr_types in_6g_pwr_mode); +#endif #ifdef CONFIG_REG_CLIENT /** @@ -1615,7 +1712,6 @@ bool wlan_reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev, const uint8_t country[3], uint8_t op_class, qdf_freq_t chan_freq); - /** * wlan_reg_get_5g_bonded_channel_and_state_for_freq()- Return the channel * state for a 5G or 6G channel frequency based on the channel width and @@ -1624,12 +1720,33 @@ bool wlan_reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev, * @freq: Channel center frequency. * @bw Channel Width. * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. + * + * Return: Channel State + */ +enum channel_state +wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width bw, + const + struct bonded_channel_freq + **bonded_chan_ptr_ptr); + +#ifdef CONFIG_REG_6G_PWRMODE +/** + * wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode()- 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. + * @bw Channel Width. + * @bonded_chan_ptr_ptr: Pointer to bonded_channel_freq. * @in_6g_pwr_type: 6g power type which decides 6G channel list lookup. * * Return: Channel State */ enum channel_state -wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, +wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode( + struct wlan_objmgr_pdev *pdev, uint16_t freq, enum phy_ch_width bw, const @@ -1637,6 +1754,7 @@ wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, **bonded_chan_ptr_ptr, enum supported_6g_pwr_types in_6g_pwr_mode); +#endif #endif /*CONFIG_CHAN_FREQ_API */ /** diff --git a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c index 74402f6b4c..56119ac3e4 100644 --- a/umac/regulatory/dispatcher/src/wlan_reg_services_api.c +++ b/umac/regulatory/dispatcher/src/wlan_reg_services_api.c @@ -1056,12 +1056,20 @@ bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev, } bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev, - qdf_freq_t freq, - enum supported_6g_pwr_types in_6g_pwr_mode) + qdf_freq_t freq) { - return reg_is_disable_for_freq(pdev, freq, in_6g_pwr_mode); + return reg_is_disable_for_freq(pdev, freq); } +#ifdef CONFIG_REG_6G_PWRMODE +bool wlan_reg_is_disable_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum supported_6g_pwr_types in_6g_pwr_mode) +{ + return reg_is_disable_for_pwrmode(pdev, freq, in_6g_pwr_mode); +} +#endif + #ifdef CONFIG_REG_CLIENT bool wlan_reg_is_disable_in_secondary_list_for_freq( struct wlan_objmgr_pdev *pdev, @@ -1104,9 +1112,7 @@ wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev, enum channel_state wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, - enum phy_ch_width bw, - enum supported_6g_pwr_types - in_6g_pwr_type) + enum phy_ch_width bw) { struct ch_params params = {0}; @@ -1119,8 +1125,7 @@ wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, params.ch_width = bw; - return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, ¶ms, - in_6g_pwr_type); + return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, ¶ms); } qdf_export_symbol(wlan_reg_get_5g_bonded_channel_state_for_freq); @@ -1130,21 +1135,36 @@ qdf_export_symbol(wlan_reg_get_5g_bonded_channel_state_for_freq); enum channel_state wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, - enum phy_ch_width bw, - enum supported_6g_pwr_types - in_6g_pwr_type) + enum phy_ch_width bw) { struct ch_params params = {0}; params.ch_width = bw; - return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, ¶ms, - in_6g_pwr_type); + return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, ¶ms); } qdf_export_symbol(wlan_reg_get_5g_bonded_channel_state_for_freq); #endif +#ifdef CONFIG_REG_6G_PWRMODE +enum channel_state +wlan_reg_get_5g_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum phy_ch_width bw, + enum supported_6g_pwr_types + in_6g_pwr_type) +{ + struct ch_params params = {0}; + + params.ch_width = bw; + return reg_get_5g_bonded_channel_state_for_pwrmode(pdev, freq, ¶ms, + in_6g_pwr_type); +} + +qdf_export_symbol(wlan_reg_get_5g_bonded_channel_state_for_pwrmode); +#endif + enum channel_state wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, @@ -1160,29 +1180,58 @@ wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, qdf_freq_t sec_ch_2g_freq, - struct ch_params *ch_params, - enum supported_6g_pwr_types - in_6g_pwr_mode) + struct ch_params *ch_params) { - reg_set_channel_params_for_freq(pdev, freq, sec_ch_2g_freq, ch_params, - in_6g_pwr_mode); + reg_set_channel_params_for_freq(pdev, freq, sec_ch_2g_freq, ch_params); } qdf_export_symbol(wlan_reg_set_channel_params_for_freq); +#ifdef CONFIG_REG_6G_PWRMODE +void wlan_reg_set_channel_params_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + struct ch_params *ch_params, + enum supported_6g_pwr_types + in_6g_pwr_mode) +{ + reg_set_channel_params_for_pwrmode(pdev, freq, sec_ch_2g_freq, + ch_params, + in_6g_pwr_mode); +} + +qdf_export_symbol(wlan_reg_set_channel_params_for_pwrmode); +#endif + #ifdef WLAN_FEATURE_11BE void wlan_reg_fill_channel_list(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, qdf_freq_t sec_ch_2g_freq, enum phy_ch_width ch_width, qdf_freq_t band_center_320, - struct reg_channel_list *chan_list, - enum supported_6g_pwr_types in_6g_pwr_type) + struct reg_channel_list *chan_list) { reg_fill_channel_list(pdev, freq, sec_ch_2g_freq, ch_width, - band_center_320, chan_list, in_6g_pwr_type); + band_center_320, chan_list); } +#ifdef CONFIG_REG_6G_PWRMODE +void +wlan_reg_fill_channel_list_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + qdf_freq_t sec_ch_2g_freq, + enum phy_ch_width ch_width, + qdf_freq_t band_center_320, + struct reg_channel_list *chan_list, + enum supported_6g_pwr_types + in_6g_pwr_type) +{ + reg_fill_channel_list_for_pwrmode(pdev, freq, sec_ch_2g_freq, ch_width, + band_center_320, chan_list, + in_6g_pwr_type); +} +#endif /* CONFIG_REG_6G_PWRMODE */ + bool wlan_reg_is_punc_bitmap_valid(enum phy_ch_width bw, uint16_t puncture_bitmap) { @@ -1194,16 +1243,26 @@ void wlan_reg_set_create_punc_bitmap(struct ch_params *ch_params, { reg_set_create_punc_bitmap(ch_params, is_create_punc_bitmap); } -#endif +#endif /* WLAN_FEATURE_11BE */ enum channel_state wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, - qdf_freq_t freq, - enum supported_6g_pwr_types in_6g_pwr_type) + qdf_freq_t freq) { - return reg_get_channel_state_for_freq(pdev, freq, in_6g_pwr_type); + return reg_get_channel_state_for_freq(pdev, freq); } +#ifdef CONFIG_REG_6G_PWRMODE +enum channel_state +wlan_reg_get_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum supported_6g_pwr_types + in_6g_pwr_type) +{ + return reg_get_channel_state_for_pwrmode(pdev, freq, in_6g_pwr_type); +} +#endif + #ifdef CONFIG_REG_CLIENT enum channel_state wlan_reg_get_channel_state_from_secondary_list_for_freq( struct wlan_objmgr_pdev *pdev, @@ -1292,6 +1351,23 @@ bool wlan_reg_is_freq_in_country_opclass(struct wlan_objmgr_pdev *pdev, enum channel_state wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, + uint16_t freq, + enum phy_ch_width bw, + const + struct bonded_channel_freq + **bonded_chan_ptr_ptr) +{ + /* + * Get channel frequencies and state from regulatory + */ + return reg_get_5g_bonded_channel_for_freq(pdev, freq, bw, + bonded_chan_ptr_ptr); +} + +#ifdef CONFIG_REG_6G_PWRMODE +enum channel_state +wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode( + struct wlan_objmgr_pdev *pdev, uint16_t freq, enum phy_ch_width bw, const @@ -1303,19 +1379,20 @@ wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev, /* * Get channel frequencies and state from regulatory */ - return reg_get_5g_bonded_channel_for_freq(pdev, freq, bw, - bonded_chan_ptr_ptr, - in_6g_pwr_mode); + return reg_get_5g_bonded_channel_for_pwrmode(pdev, freq, bw, + bonded_chan_ptr_ptr, + in_6g_pwr_mode); } +qdf_export_symbol(wlan_reg_get_5g_bonded_channel_and_state_for_pwrmode); +#endif + #if defined(WLAN_FEATURE_11BE) && defined(CONFIG_REG_CLIENT) enum channel_state wlan_reg_get_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, enum phy_ch_width bw, - qdf_freq_t sec_freq, - enum supported_6g_pwr_types - in_6g_pwr_mode) + qdf_freq_t sec_freq) { if (WLAN_REG_IS_24GHZ_CH_FREQ(freq)) return reg_get_2g_bonded_channel_state_for_freq(pdev, freq, @@ -1324,16 +1401,14 @@ wlan_reg_get_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, const struct bonded_channel_freq *bonded_chan_ptr_ptr = NULL; return reg_get_5g_bonded_channel_for_freq(pdev, freq, bw, - &bonded_chan_ptr_ptr, - in_6g_pwr_mode); + &bonded_chan_ptr_ptr); } else { struct ch_params params = {0}; params.ch_width = bw; return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, - ¶ms, - in_6g_pwr_mode); + ¶ms); } } @@ -1344,9 +1419,7 @@ enum channel_state wlan_reg_get_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, enum phy_ch_width bw, - qdf_freq_t sec_freq, - enum supported_6g_pwr_types - in_6g_pwr_mode) + qdf_freq_t sec_freq) { if (WLAN_REG_IS_24GHZ_CH_FREQ(freq)) { return reg_get_2g_bonded_channel_state_for_freq(pdev, freq, @@ -1357,12 +1430,37 @@ wlan_reg_get_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev, params.ch_width = bw; return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, + ¶ms); + } +} + +qdf_export_symbol(wlan_reg_get_5g_bonded_channel_and_state_for_freq); + +#ifdef CONFIG_REG_6G_PWRMODE +enum channel_state +wlan_reg_get_bonded_channel_state_for_pwrmode(struct wlan_objmgr_pdev *pdev, + qdf_freq_t freq, + enum phy_ch_width bw, + qdf_freq_t sec_freq, + enum supported_6g_pwr_types + in_6g_pwr_mode) +{ + if (WLAN_REG_IS_24GHZ_CH_FREQ(freq)) { + return reg_get_2g_bonded_channel_state_for_freq(pdev, freq, + sec_freq, bw); + } else { + struct ch_params params = {0}; + + params.ch_width = bw; + + return reg_get_5g_bonded_channel_state_for_pwrmode(pdev, freq, ¶ms, in_6g_pwr_mode); } } -qdf_export_symbol(wlan_reg_get_5g_bonded_channel_and_state_for_freq); +qdf_export_symbol(wlan_reg_get_bonded_channel_state_for_pwrmode); +#endif #endif #endif /* CONFIG CHAN FREQ API */ diff --git a/umac/scan/core/src/wlan_scan_cache_db.c b/umac/scan/core/src/wlan_scan_cache_db.c index 7f933040f3..cf02a7c2d2 100644 --- a/umac/scan/core/src/wlan_scan_cache_db.c +++ b/umac/scan/core/src/wlan_scan_cache_db.c @@ -1047,7 +1047,8 @@ QDF_STATUS __scm_handle_bcn_probe(struct scan_bcn_probe_event *bcn) } /* Do not add invalid channel entry as kernel will reject it */ if (scan_obj->drop_bcn_on_invalid_freq && - wlan_reg_is_disable_for_freq(pdev, + wlan_reg_is_disable_for_pwrmode( + pdev, scan_entry->channel.chan_freq, REG_CURRENT_PWR_MODE)) { scm_nofl_debug("Drop frame for invalid freq %d: "QDF_MAC_ADDR_FMT" Seq Num: %d RSSI %d", diff --git a/umac/scan/dispatcher/src/wlan_scan_utils_api.c b/umac/scan/dispatcher/src/wlan_scan_utils_api.c index 75a368b1c7..102d447b47 100644 --- a/umac/scan/dispatcher/src/wlan_scan_utils_api.c +++ b/umac/scan/dispatcher/src/wlan_scan_utils_api.c @@ -329,8 +329,8 @@ util_scan_get_chan_from_he_6g_params(struct wlan_objmgr_pdev *pdev, he_6g_params->primary_channel, band_mask); if (scan_obj->drop_bcn_on_invalid_freq && - wlan_reg_is_disable_for_freq(pdev, *chan_freq, - REG_CURRENT_PWR_MODE)) { + wlan_reg_is_disable_for_pwrmode(pdev, *chan_freq, + REG_CURRENT_PWR_MODE)) { scm_debug_rl(QDF_MAC_ADDR_FMT": Drop as invalid channel %d freq %d in HE 6Ghz params", QDF_MAC_ADDR_REF(scan_params->bssid.bytes), he_6g_params->primary_channel, *chan_freq); @@ -1286,7 +1286,7 @@ util_scan_populate_bcn_ie_list(struct wlan_objmgr_pdev *pdev, band_mask); /* Drop if invalid freq */ if (scan_obj->drop_bcn_on_invalid_freq && - wlan_reg_is_disable_for_freq( + wlan_reg_is_disable_for_pwrmode( pdev, *chan_freq, REG_CURRENT_PWR_MODE)) { scm_debug_rl(QDF_MAC_ADDR_FMT": Drop as invalid channel %d freq %d in HT_INFO IE", diff --git a/umac/wifi_pos/src/wifi_pos_main.c b/umac/wifi_pos/src/wifi_pos_main.c index 159fc5a2e5..60db721167 100644 --- a/umac/wifi_pos/src/wifi_pos_main.c +++ b/umac/wifi_pos/src/wifi_pos_main.c @@ -460,9 +460,9 @@ static void wifi_update_channel_bw_info(struct wlan_objmgr_psoc *psoc, return; } - wlan_reg_set_channel_params_for_freq(pdev, freq, - sec_ch_2g, &ch_params, - REG_CURRENT_PWR_MODE); + wlan_reg_set_channel_params_for_pwrmode(pdev, freq, sec_ch_2g, + &ch_params, + REG_CURRENT_PWR_MODE); chan->band_center_freq1 = ch_params.mhz_freq_seg0; if (wifi_pos_psoc->wifi_pos_get_fw_phy_mode_for_freq) {