diff --git a/components/tdls/core/src/wlan_tdls_main.h b/components/tdls/core/src/wlan_tdls_main.h index a00c845151..7a086fed8c 100644 --- a/components/tdls/core/src/wlan_tdls_main.h +++ b/components/tdls/core/src/wlan_tdls_main.h @@ -314,7 +314,7 @@ struct tdls_peer_mlme_info { * @buf_sta_capable: is buffer sta * @off_channel_capable: is offchannel supported flag * @supported_channels_len: supported channels length - * @supported_channels: supported channels + * @supported_chan_freq: supported channel frequency * @supported_oper_classes_len: supported operation classes length * @supported_oper_classes: supported operation classes * @is_forced_peer: is forced peer @@ -346,7 +346,7 @@ struct tdls_peer { uint8_t buf_sta_capable; uint8_t off_channel_capable; uint8_t supported_channels_len; - uint8_t supported_channels[WLAN_MAC_MAX_SUPP_CHANNELS]; + qdf_freq_t supported_chan_freq[WLAN_MAC_MAX_SUPP_CHANNELS]; uint8_t supported_oper_classes_len; uint8_t supported_oper_classes[WLAN_MAX_SUPP_OPER_CLASSES]; bool is_forced_peer; diff --git a/components/tdls/core/src/wlan_tdls_peer.c b/components/tdls/core/src/wlan_tdls_peer.c index e2e1ab4ee6..f5db00f99d 100644 --- a/components/tdls/core/src/wlan_tdls_peer.c +++ b/components/tdls/core/src/wlan_tdls_peer.c @@ -550,7 +550,6 @@ void tdls_extract_peer_state_param(struct tdls_peer_update_state *peer_param, struct tdls_soc_priv_obj *soc_obj; enum channel_state ch_state; struct wlan_objmgr_pdev *pdev; - uint8_t chan_id; uint32_t cur_band; qdf_freq_t ch_freq; uint32_t tx_power = 0; @@ -615,14 +614,13 @@ void tdls_extract_peer_state_param(struct tdls_peer_update_state *peer_param, num = 0; for (i = 0; i < peer->supported_channels_len; i++) { - chan_id = peer->supported_channels[i]; - ch_freq = wlan_reg_legacy_chan_to_freq(pdev, chan_id); + ch_freq = peer->supported_chan_freq[i]; ch_state = wlan_reg_get_channel_state_for_freq(pdev, ch_freq); if (CHANNEL_STATE_INVALID != ch_state && CHANNEL_STATE_DFS != ch_state && !wlan_reg_is_dsrc_freq(ch_freq)) { - peer_param->peer_cap.peer_chan[num].chan_id = chan_id; + peer_param->peer_cap.peer_chan[num].ch_freq = ch_freq; if (!wlan_reg_is_6ghz_chan_freq(ch_freq)) { tx_power = wlan_reg_get_channel_reg_power_for_freq(pdev, @@ -858,9 +856,9 @@ void tdls_set_peer_caps(struct tdls_vdev_priv_obj *vdev_obj, curr_peer->buf_sta_capable = is_buffer_sta; curr_peer->off_channel_capable = is_off_channel_supported; - qdf_mem_copy(curr_peer->supported_channels, - req_info->supported_channels, - req_info->supported_channels_len); + qdf_mem_copy(curr_peer->supported_chan_freq, + req_info->supported_chan_freq, + sizeof(qdf_freq_t) * req_info->supported_channels_len); curr_peer->supported_channels_len = req_info->supported_channels_len; diff --git a/components/tdls/dispatcher/inc/wlan_tdls_public_structs.h b/components/tdls/dispatcher/inc/wlan_tdls_public_structs.h index a96fc3a35a..2b911e589a 100644 --- a/components/tdls/dispatcher/inc/wlan_tdls_public_structs.h +++ b/components/tdls/dispatcher/inc/wlan_tdls_public_structs.h @@ -822,7 +822,7 @@ struct tdls_update_peer_params { uint8_t uapsd_queues; uint8_t max_sp; uint8_t supported_channels_len; - uint8_t supported_channels[WLAN_MAC_MAX_SUPP_CHANNELS]; + qdf_freq_t supported_chan_freq[WLAN_MAC_MAX_SUPP_CHANNELS]; uint8_t supported_oper_classes_len; uint8_t supported_oper_classes[WLAN_MAX_SUPP_OPER_CLASSES]; bool is_qos_wmm_sta; @@ -908,14 +908,14 @@ struct tdls_info { /** * struct tdls_ch_params - channel parameters - * @chan_id: ID of the channel + * @ch_freq: Channel frequency * @pwr: power level * @dfs_set: is dfs supported or not * @half_rate: is the channel operating at 10MHz * @quarter_rate: is the channel operating at 5MHz */ struct tdls_ch_params { - uint8_t chan_id; + qdf_freq_t ch_freq; uint8_t pwr; bool dfs_set; bool half_rate; diff --git a/core/mac/src/pe/lim/lim_process_tdls.c b/core/mac/src/pe/lim/lim_process_tdls.c index e5687b9544..e6d77d283d 100644 --- a/core/mac/src/pe/lim/lim_process_tdls.c +++ b/core/mac/src/pe/lim/lim_process_tdls.c @@ -189,6 +189,18 @@ void lim_init_tdls_data(struct mac_context *mac, struct pe_session *pe_session) return; } +static bool +is_duplicate_chan(uint8_t *arr, uint8_t index, uint8_t ch_id) +{ + int i; + + for (i = 0; i < index; i++) { + if (arr[i] == ch_id) + return true; + } + return false; +} + static void populate_dot11f_tdls_offchannel_params( struct mac_context *mac, struct pe_session *pe_session, @@ -210,11 +222,6 @@ static void populate_dot11f_tdls_offchannel_params( numChans = mac->mlme_cfg->reg.valid_channel_list_num; - for (i = 0; i < mac->mlme_cfg->reg.valid_channel_list_num; i++) { - validChan[i] = wlan_reg_freq_to_chan(mac->pdev, - mac->mlme_cfg->reg.valid_channel_freq_list[i]); - } - if (wlan_reg_is_24ghz_ch_freq(pe_session->curr_op_freq)) band = BAND_2G; else @@ -226,8 +233,15 @@ static void populate_dot11f_tdls_offchannel_params( mac->user_configured_nss); /* validating the channel list for DFS and 2G channels */ - for (i = 0U; i < numChans; i++) { - ch_freq = wlan_reg_legacy_chan_to_freq(mac->pdev, validChan[i]); + for (i = 0; i < numChans; i++) { + ch_freq = mac->mlme_cfg->reg.valid_channel_freq_list[i]; + + validChan[i] = wlan_reg_freq_to_chan(mac->pdev, + mac->mlme_cfg->reg.valid_channel_freq_list[i]); + + if (is_duplicate_chan(validChan, i, validChan[i])) + continue; + if ((band == BAND_5G) && (NSS_2x2_MODE == nss_5g) && (NSS_1x1_MODE == nss_2g) && @@ -243,8 +257,15 @@ static void populate_dot11f_tdls_offchannel_params( } } + if (wlan_reg_is_6ghz_chan_freq(ch_freq) && + !wlan_reg_is_6ghz_psc_chan_freq(ch_freq)) { + pe_debug("skipping non-psc channel %d", ch_freq); + continue; + } + if (valid_count >= ARRAY_SIZE(suppChannels->bands)) break; + suppChannels->bands[valid_count][0] = validChan[i]; suppChannels->bands[valid_count][1] = 1; valid_count++; @@ -277,11 +298,6 @@ static void populate_dot11f_tdls_offchannel_params( wlan_reg_freq_to_chan(mac->pdev, pe_session->curr_op_freq), chanOffset); - pe_debug("countryCodeCurrent: %s, curr_op_freq: %d, htSecondaryChannelOffset: %d, chanOffset: %d op class: %d", - mac->scan.countryCodeCurrent, - pe_session->curr_op_freq, - pe_session->htSecondaryChannelOffset, - chanOffset, op_class); suppOperClasses->present = 1; suppOperClasses->classes[0] = op_class; @@ -290,6 +306,12 @@ static void populate_dot11f_tdls_offchannel_params( for (i = 0; i < numClasses; i++) suppOperClasses->classes[i + 1] = classes[i]; + pe_debug("countryCodeCurrent: %s, curr_op_freq: %d, htSecondaryChannelOffset: %d, chanOffset: %d op class: %d num_supportd_chan %d num_supportd_opclass %d", + mac->scan.countryCodeCurrent, + pe_session->curr_op_freq, + pe_session->htSecondaryChannelOffset, + chanOffset, op_class, valid_count, numClasses); + /* add one for present operating class, added in the beginning */ suppOperClasses->num_classes = numClasses + 1; diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c index f6d3a45782..8fafd79f73 100644 --- a/core/wma/src/wma_features.c +++ b/core/wma/src/wma_features.c @@ -3726,7 +3726,6 @@ int wma_update_tdls_peer_state(WMA_HANDLE handle, int ret = 0; uint32_t *ch_mhz = NULL; size_t ch_mhz_len; - uint8_t chan_id; bool restore_last_peer = false; QDF_STATUS qdf_status; struct wmi_unified *wmi_handle; @@ -3777,10 +3776,8 @@ int wma_update_tdls_peer_state(WMA_HANDLE handle, goto end_tdls_peer_state; } - for (i = 0; i < peer_cap->peer_chanlen; ++i) { - chan_id = peer_cap->peer_chan[i].chan_id; - ch_mhz[i] = cds_chan_to_freq(chan_id); - } + for (i = 0; i < peer_cap->peer_chanlen; ++i) + ch_mhz[i] = peer_cap->peer_chan[i].ch_freq; } cdp_peer_set_tdls_offchan_enabled(soc, peer_state->vdev_id, diff --git a/os_if/tdls/src/wlan_cfg80211_tdls.c b/os_if/tdls/src/wlan_cfg80211_tdls.c index 02059b4dc5..ea9236c71a 100644 --- a/os_if/tdls/src/wlan_cfg80211_tdls.c +++ b/os_if/tdls/src/wlan_cfg80211_tdls.c @@ -164,76 +164,79 @@ error: } static bool -is_duplicate_channel(uint8_t *arr, int index, uint8_t match) +is_duplicate_freq(qdf_freq_t *arr, uint8_t index, qdf_freq_t freq) { int i; for (i = 0; i < index; i++) { - if (arr[i] == match) + if (arr[i] == freq) return true; } return false; } +static uint8_t +tdls_fill_chan_freq_from_supported_ch_list(const uint8_t *src_chans, + uint8_t src_chan_num, + const uint8_t *src_opclass, + uint8_t src_num_opclass, + qdf_freq_t *freq_lst) +{ + uint8_t i = 0, j = 0, num_unique_freq = 0; + qdf_freq_t freq; + + for (i = 0; i < src_num_opclass; i++) { + for (j = 0; j < src_chan_num; j++) { + freq = wlan_reg_chan_opclass_to_freq(src_chans[j], + src_opclass[i], false); + + if (is_duplicate_freq(freq_lst, num_unique_freq, freq)) + continue; + + if (wlan_reg_is_6ghz_chan_freq(freq) && + !wlan_reg_is_6ghz_psc_chan_freq(freq)) { + osif_debug("skipping non-psc channel %d", freq); + continue; + } + + freq_lst[num_unique_freq] = freq; + osif_debug("freq %d index %d ", freq, num_unique_freq); + num_unique_freq++; + + if (num_unique_freq > NUM_CHANNELS) { + osif_debug("num_unique_freq more than max num"); + break; + } + } + } + + return num_unique_freq; +} + static void tdls_calc_channels_from_staparams(struct tdls_update_peer_params *req_info, struct station_parameters *params) { - int i = 0, j = 0, k = 0, no_of_channels = 0; - int num_unique_channels; - int next; - uint8_t *dest_chans; - const uint8_t *src_chans; + uint8_t i = 0; + uint8_t num_unique_freq = 0; + const uint8_t *src_chans, *src_opclass; + qdf_freq_t *dest_freq; - dest_chans = req_info->supported_channels; src_chans = params->supported_channels; + src_opclass = params->supported_oper_classes; + dest_freq = req_info->supported_chan_freq; - /* Convert (first channel , number of channels) tuple to - * the total list of channels. This goes with the assumption - * that if the first channel is < 14, then the next channels - * are an incremental of 1 else an incremental of 4 till the number - * of channels. - */ - for (i = 0; i < params->supported_channels_len && - j < WLAN_MAC_MAX_SUPP_CHANNELS; i += 2) { - int wifi_chan_index; + num_unique_freq = tdls_fill_chan_freq_from_supported_ch_list(src_chans, + params->supported_channels_len, + src_opclass, + params->supported_oper_classes_len, + dest_freq); - if (!is_duplicate_channel(dest_chans, j, src_chans[i])) - dest_chans[j] = src_chans[i]; - else - continue; - - wifi_chan_index = ((dest_chans[j] <= WLAN_CHANNEL_14) ? 1 : 4); - no_of_channels = src_chans[i + 1]; - - osif_debug("i:%d,j:%d,k:%d,[%d]:%d,index:%d,chans_num: %d", - i, j, k, j, - dest_chans[j], - wifi_chan_index, - no_of_channels); - - for (k = 1; k <= no_of_channels && - j < WLAN_MAC_MAX_SUPP_CHANNELS - 1; k++) { - next = dest_chans[j] + wifi_chan_index; - - if (!is_duplicate_channel(dest_chans, j + 1, next)) - dest_chans[j + 1] = next; - else - continue; - - osif_debug("i: %d, j: %d, k: %d, [%d]: %d", - i, j, k, j + 1, dest_chans[j + 1]); - j += 1; - } - } - num_unique_channels = j + 1; osif_debug("Unique Channel List: supported_channels "); - for (i = 0; i < num_unique_channels; i++) - osif_debug("[%d]: %d,", i, dest_chans[i]); + for (i = 0; i < num_unique_freq; i++) + osif_debug(" %d,", dest_freq[i]); - if (num_unique_channels > NUM_CHANNELS) - num_unique_channels = NUM_CHANNELS; - req_info->supported_channels_len = num_unique_channels; + req_info->supported_channels_len = num_unique_freq; osif_debug("After removing duplcates supported_channels_len: %d", req_info->supported_channels_len); } @@ -318,9 +321,6 @@ wlan_cfg80211_tdls_extract_params(struct tdls_update_peer_params *req_info, req_info->uapsd_queues = params->uapsd_queues; req_info->max_sp = params->max_sp; - if (params->supported_channels_len) - tdls_calc_channels_from_staparams(req_info, params); - if (params->supported_oper_classes_len > WLAN_MAX_SUPP_OPER_CLASSES) { osif_debug("received oper classes:%d, resetting it to max supported: %d", params->supported_oper_classes_len, @@ -334,6 +334,9 @@ wlan_cfg80211_tdls_extract_params(struct tdls_update_peer_params *req_info, req_info->supported_oper_classes_len = params->supported_oper_classes_len; + if (params->supported_channels_len) + tdls_calc_channels_from_staparams(req_info, params); + if (params->ext_capab_len) qdf_mem_copy(req_info->extn_capability, params->ext_capab, sizeof(req_info->extn_capability));