diff --git a/os_if/linux/scan/src/wlan_cfg80211_scan.c b/os_if/linux/scan/src/wlan_cfg80211_scan.c index 180ecba9a9..73a6f7ef10 100644 --- a/os_if/linux/scan/src/wlan_cfg80211_scan.c +++ b/os_if/linux/scan/src/wlan_cfg80211_scan.c @@ -1745,15 +1745,13 @@ int wlan_vendor_abort_scan(struct wlan_objmgr_pdev *pdev, static inline struct ieee80211_channel * wlan_get_ieee80211_channel(struct wiphy *wiphy, struct wlan_objmgr_pdev *pdev, - int chan_no) + int chan_freq) { - unsigned int freq; struct ieee80211_channel *chan; - freq = wlan_reg_chan_to_freq(pdev, chan_no); - chan = ieee80211_get_channel(wiphy, freq); + chan = ieee80211_get_channel(wiphy, chan_freq); if (!chan) - osif_err("chan is NULL, chan_no: %d freq: %d", chan_no, freq); + osif_err("chan is NULL, freq: %d", chan_freq); return chan; } @@ -1925,11 +1923,11 @@ void wlan_cfg80211_inform_bss_frame(struct wlan_objmgr_pdev *pdev, bss_data.rssi = scan_params->rssi_raw; bss_data.chan = wlan_get_ieee80211_channel(wiphy, pdev, - scan_params->channel.chan_idx); + scan_params->channel.chan_freq); if (!bss_data.chan) { - osif_err("Channel not found for bss %pM seq %d chan %d", + osif_err("Channel not found for bss %pM seq %d chan_freq %d", bss_data.mgmt->bssid, scan_params->seq_num, - scan_params->channel.chan_idx); + scan_params->channel.chan_freq); qdf_mem_free(bss_data.mgmt); return; } diff --git a/umac/scan/core/src/wlan_scan_bss_score.c b/umac/scan/core/src/wlan_scan_bss_score.c index 7fe93d0de6..e5c9645fa2 100644 --- a/umac/scan/core/src/wlan_scan_bss_score.c +++ b/umac/scan/core/src/wlan_scan_bss_score.c @@ -387,7 +387,7 @@ static int32_t scm_calculate_bandwidth_score( bw_weight_per_idx = score_config->bandwidth_weight_per_index; - if (WLAN_CHAN_IS_2GHZ(entry->channel.chan_idx)) { + if (WLAN_REG_IS_24GHZ_CH_FREQ(entry->channel.chan_freq)) { cbmode = score_config->cb_mode_24G; if (score_config->vht_24G_cap) is_vht = true; @@ -699,6 +699,7 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc, struct weight_config *weight_config; struct wlan_scan_obj *scan_obj; uint32_t sta_nss; + struct wlan_objmgr_pdev *pdev = NULL; scan_obj = wlan_psoc_get_scan_obj(psoc); if (!scan_obj) { @@ -726,7 +727,7 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc, weight_config->ht_caps_weightage; score += ht_score; - if (WLAN_CHAN_IS_2GHZ(entry->channel.chan_idx)) { + if (WLAN_REG_IS_24GHZ_CH_FREQ(entry->channel.chan_freq)) { if (score_config->vht_24G_cap) is_vht = true; } else if (score_config->vht_cap) { @@ -783,13 +784,14 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc, */ if ((entry->rssi_raw > rssi_pref_5g_rssi_thresh) && !same_bucket) { - if (WLAN_CHAN_IS_5GHZ(entry->channel.chan_idx)) + if (WLAN_REG_IS_5GHZ_CH_FREQ(entry->channel.chan_freq)) band_score = weight_config->chan_band_weightage * WLAN_GET_SCORE_PERCENTAGE( score_config->band_weight_per_index, SCM_BAND_5G_INDEX); - } else if (WLAN_CHAN_IS_2GHZ(entry->channel.chan_idx)) { + } else if (WLAN_REG_IS_24GHZ_CH_FREQ( + entry->channel.chan_freq)) { band_score = weight_config->chan_band_weightage * WLAN_GET_SCORE_PERCENTAGE( score_config->band_weight_per_index, @@ -802,10 +804,20 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc, score += oce_wan_score; } - sta_nss = scm_get_sta_nss(psoc, entry->channel.chan_idx, + pdev = wlan_objmgr_get_pdev_by_id(psoc, entry->pdev_id, WLAN_SCAN_ID); + if (!pdev) { + scm_err("pdev is NULL"); + return 0; + } + + sta_nss = scm_get_sta_nss(psoc, + wlan_reg_freq_to_chan( + pdev, + entry->channel.chan_freq), score_config->vdev_nss_24g, score_config->vdev_nss_5g); + wlan_objmgr_pdev_release_ref(pdev, WLAN_SCAN_ID); /* * If station support nss as 2*2 but AP support NSS as 1*1, * this AP will be given half weight compare to AP which are having @@ -821,8 +833,8 @@ int scm_calculate_bss_score(struct wlan_objmgr_psoc *psoc, score_config->beamformee_cap, score_config->cb_mode_24G, score_config->cb_mode_5G, sta_nss); - scm_debug("Candidate (BSSID: %pM Chan %d) Cap:: rssi=%d HT=%d VHT=%d HE %d su beamformer %d phymode=%d air time fraction %d qbss load %d cong_pct %d NSS %d", - entry->bssid.bytes, entry->channel.chan_idx, + scm_debug("Candidate (BSSID: %pM freq %d) Cap:: rssi=%d HT=%d VHT=%d HE %d su beamformer %d phymode=%d air time fraction %d qbss load %d cong_pct %d NSS %d", + entry->bssid.bytes, entry->channel.chan_freq, entry->rssi_raw, util_scan_entry_htcap(entry) ? 1 : 0, util_scan_entry_vhtcap(entry) ? 1 : 0, util_scan_entry_hecap(entry) ? 1 : 0, ap_su_beam_former, diff --git a/umac/scan/core/src/wlan_scan_cache_db.c b/umac/scan/core/src/wlan_scan_cache_db.c index e4a3d2268e..20bfee98c0 100644 --- a/umac/scan/core/src/wlan_scan_cache_db.c +++ b/umac/scan/core/src/wlan_scan_cache_db.c @@ -559,9 +559,9 @@ scm_copy_info_from_dup_entry(struct wlan_objmgr_pdev *pdev, if ((scan_params->frm_subtype == MGMT_SUBTYPE_BEACON) && !util_scan_entry_htinfo(scan_params) && !util_scan_entry_ds_param(scan_params) && - (scan_params->channel.chan_idx != scan_entry->channel.chan_idx) && + (scan_params->channel.chan_freq != scan_entry->channel.chan_freq) && (scan_params->rssi_raw < ADJACENT_CHANNEL_RSSI_THRESHOLD)) { - scan_params->channel.chan_idx = scan_entry->channel.chan_idx; + scan_params->channel.chan_freq = scan_entry->channel.chan_freq; scan_params->channel_mismatch = true; } @@ -784,7 +784,7 @@ QDF_STATUS __scm_handle_bcn_probe(struct scan_bcn_probe_event *bcn) } if (bcn->frm_type == MGMT_SUBTYPE_BEACON && - utils_is_dfs_ch(pdev, bcn->rx_data->channel)) { + wlan_reg_is_dfs_for_freq(pdev, bcn->rx_data->chan_freq)) { util_scan_add_hidden_ssid(pdev, bcn->buf); } @@ -824,13 +824,13 @@ QDF_STATUS __scm_handle_bcn_probe(struct scan_bcn_probe_event *bcn) continue; } - scm_nofl_debug("Received %s from BSSID: %pM tsf_delta = %u Seq Num: %d ssid:%.*s, rssi: %d channel %d pdev_id = %d", + scm_nofl_debug("Received %s from BSSID: %pM tsf_delta = %u Seq Num: %d ssid:%.*s, rssi: %d frequency %d pdev_id = %d", (bcn->frm_type == MGMT_SUBTYPE_PROBE_RESP) ? "Probe Rsp" : "Beacon", scan_entry->bssid.bytes, scan_entry->tsf_delta, scan_entry->seq_num, scan_entry->ssid.length, scan_entry->ssid.ssid, scan_entry->rssi_raw, - scan_entry->channel.chan_idx, + scan_entry->channel.chan_freq, wlan_objmgr_pdev_get_pdev_id(pdev)); if (scan_obj->cb.update_beacon) @@ -900,6 +900,7 @@ static void scm_list_insert_sorted(struct wlan_objmgr_psoc *psoc, qdf_list_node_t *cur_lst = NULL, *next_lst = NULL; struct scan_default_params *params; int pcl_chan_weight = 0; + struct wlan_objmgr_pdev *pdev = NULL; params = wlan_scan_psoc_get_def_params(psoc); if (!params) { @@ -907,17 +908,28 @@ static void scm_list_insert_sorted(struct wlan_objmgr_psoc *psoc, return; } + pdev = wlan_objmgr_get_pdev_by_id(psoc, scan_node->entry->pdev_id, + WLAN_SCAN_ID); + if (!pdev) { + scm_err("pdev is NULL"); + return; + } + if (filter->num_of_pcl_channels > 0 && (scan_node->entry->rssi_raw > SCM_PCL_RSSI_THRESHOLD)) { if (scm_get_pcl_weight_of_channel( - scan_node->entry->channel.chan_idx, + wlan_reg_freq_to_chan( + pdev, + scan_node->entry->channel.chan_freq), filter, &pcl_chan_weight, filter->pcl_weight_list)) { - scm_debug("pcl channel %d pcl_chan_weight %d", - scan_node->entry->channel.chan_idx, - pcl_chan_weight); + scm_debug("pcl freq %d pcl_chan_weight %d", + scan_node->entry->channel.chan_freq, + pcl_chan_weight); } } + wlan_objmgr_pdev_release_ref(pdev, WLAN_SCAN_ID); + if (params->is_bssid_hint_priority && !qdf_mem_cmp(filter->bssid_hint.bytes, scan_node->entry->bssid.bytes, @@ -953,7 +965,6 @@ static void scm_list_insert_sorted(struct wlan_objmgr_psoc *psoc, if (!cur_lst) qdf_list_insert_back(scan_list, &scan_node->node); - } /** @@ -1289,16 +1300,20 @@ QDF_STATUS scm_flush_results(struct wlan_objmgr_pdev *pdev, * * Return: QDF_STATUS */ -static void scm_filter_channels(struct scan_dbs *scan_db, - struct scan_cache_node *db_node, - uint8_t *chan_list, uint32_t num_chan) +static void scm_filter_channels(struct wlan_objmgr_pdev *pdev, + struct scan_dbs *scan_db, + struct scan_cache_node *db_node, + uint8_t *chan_list, uint32_t num_chan) { int i; bool match = false; for (i = 0; i < num_chan; i++) { if (chan_list[i] == - util_scan_entry_channel_num(db_node->entry)) { + wlan_reg_freq_to_chan( + pdev, + util_scan_entry_channel_frequency( + db_node->entry))) { match = true; break; } @@ -1343,8 +1358,8 @@ void scm_filter_valid_channel(struct wlan_objmgr_pdev *pdev, cur_node = scm_get_next_node(scan_db, &scan_db->scan_hash_tbl[i], NULL); while (cur_node) { - scm_filter_channels(scan_db, - cur_node, chan_list, num_chan); + scm_filter_channels(pdev, scan_db, + cur_node, chan_list, num_chan); next_node = scm_get_next_node(scan_db, &scan_db->scan_hash_tbl[i], cur_node); cur_node = next_node; @@ -1505,7 +1520,9 @@ QDF_STATUS scm_scan_update_mlme_by_bssinfo(struct wlan_objmgr_pdev *pdev, entry = cur_node->entry; if (qdf_is_macaddr_equal(&bss_info->bssid, &entry->bssid) && (util_is_ssid_match(&bss_info->ssid, &entry->ssid)) && - (bss_info->chan == entry->channel.chan_idx)) { + (bss_info->chan == wlan_reg_freq_to_chan( + pdev, + entry->channel.chan_freq))) { /* Acquire db lock to prevent simultaneous update */ qdf_spin_lock_bh(&scan_db->scan_db_lock); qdf_mem_copy(&entry->mlme_info, mlme, diff --git a/umac/scan/core/src/wlan_scan_filter.c b/umac/scan/core/src/wlan_scan_filter.c index 4581289d75..5ffc8fb8e8 100644 --- a/umac/scan/core/src/wlan_scan_filter.c +++ b/umac/scan/core/src/wlan_scan_filter.c @@ -1142,6 +1142,7 @@ bool scm_filter_match(struct wlan_objmgr_psoc *psoc, bool match = false; struct scan_default_params *def_param; struct wlan_country_ie *cc_ie; + struct wlan_objmgr_pdev *pdev = NULL; def_param = wlan_scan_psoc_get_def_params(psoc); if (!def_param) @@ -1192,15 +1193,24 @@ bool scm_filter_match(struct wlan_objmgr_psoc *psoc, if (!match && filter->num_of_bssid) return false; + pdev = wlan_objmgr_get_pdev_by_id(psoc, db_entry->pdev_id, + WLAN_SCAN_ID); + if (!pdev) { + scm_err("pdev is NULL"); + return false; + } + match = false; for (i = 0; i < filter->num_of_channels; i++) { if (!filter->channel_list[i] || ( (filter->channel_list[i] == - db_entry->channel.chan_idx))) { + wlan_reg_freq_to_chan(pdev, + db_entry->channel.chan_freq)))) { match = true; break; } } + wlan_objmgr_pdev_release_ref(pdev, WLAN_SCAN_ID); if (!match && filter->num_of_channels) return false; @@ -1254,6 +1264,5 @@ bool scm_filter_match(struct wlan_objmgr_psoc *psoc, db_entry->bssid.bytes); return false; } - return true; } diff --git a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h index 45095c5b15..171f7f51da 100644 --- a/umac/scan/dispatcher/inc/wlan_scan_public_structs.h +++ b/umac/scan/dispatcher/inc/wlan_scan_public_structs.h @@ -89,15 +89,15 @@ struct wlan_objmgr_psoc; /** * struct channel_info - BSS channel information - * @chan_idx: current operating channel index + * @chan_freq: channel frequency * @cfreq0: channel frequency index0 * @cfreq1: channel frequency index1 * @priv: channel private information */ struct channel_info { - uint8_t chan_idx; - uint8_t cfreq0; - uint8_t cfreq1; + uint32_t chan_freq; + uint32_t cfreq0; + uint32_t cfreq1; void *priv; }; @@ -317,6 +317,7 @@ struct scan_mbssid_info { * @alt_wcn_ie: alternate WCN IE * @ie_list: IE list pointers * @raw_frame: contain raw frame and the length of the raw frame + * @pdev_id: pdev id */ struct scan_cache_entry { uint8_t frm_subtype; @@ -357,6 +358,12 @@ struct scan_cache_entry { struct element_info alt_wcn_ie; struct ie_list ie_list; struct element_info raw_frame; + /* + * This is added temporarily for 6GHz channel to freq conversion + * to get pdev wherever it requores to convert frequency to + * channel as regulatory apis requires pdev as argument + */ + uint8_t pdev_id; }; #define MAX_FAVORED_BSSID 16 diff --git a/umac/scan/dispatcher/inc/wlan_scan_utils_api.h b/umac/scan/dispatcher/inc/wlan_scan_utils_api.h index f2ab5d3074..17b284dd27 100644 --- a/umac/scan/dispatcher/inc/wlan_scan_utils_api.h +++ b/umac/scan/dispatcher/inc/wlan_scan_utils_api.h @@ -30,6 +30,7 @@ #include #include #include +#include #define ASCII_SPACE_CHARACTER 32 @@ -741,17 +742,17 @@ util_scan_entry_channel(struct scan_cache_entry *scan_entry) } /** - * util_scan_entry_channel_num() - function to read channel number + * util_scan_entry_channel_frequency() - function to read channel number * @scan_entry: scan entry * * API, function to read channel number * * Return: channel number */ -static inline uint8_t -util_scan_entry_channel_num(struct scan_cache_entry *scan_entry) +static inline uint32_t +util_scan_entry_channel_frequency(struct scan_cache_entry *scan_entry) { - return scan_entry->channel.chan_idx; + return scan_entry->channel.chan_freq; } /** diff --git a/umac/scan/dispatcher/src/wlan_scan_utils_api.c b/umac/scan/dispatcher/src/wlan_scan_utils_api.c index fbeec7590e..e2550a9ce8 100644 --- a/umac/scan/dispatcher/src/wlan_scan_utils_api.c +++ b/umac/scan/dispatcher/src/wlan_scan_utils_api.c @@ -141,8 +141,8 @@ bool util_is_scan_entry_match( util_scan_is_null_ssid(&entry2->ssid)) return true; } else if (entry1->cap_info.wlan_caps.ibss && - (entry1->channel.chan_idx == - entry2->channel.chan_idx)) { + (entry1->channel.chan_freq == + entry2->channel.chan_freq)) { /* * Same channel cannot have same SSID for * different IBSS, so no need to check BSSID @@ -499,7 +499,8 @@ util_scan_parse_vendor_ie(struct scan_cache_entry *scan_params, } static QDF_STATUS -util_scan_populate_bcn_ie_list(struct scan_cache_entry *scan_params) +util_scan_populate_bcn_ie_list(struct scan_cache_entry *scan_params, + uint8_t *chan_idx) { struct ie_header *ie, *sub_ie; uint32_t ie_len, sub_ie_len; @@ -539,7 +540,7 @@ util_scan_populate_bcn_ie_list(struct scan_cache_entry *scan_params) if (ie->ie_len != WLAN_DS_PARAM_IE_MAX_LEN) return QDF_STATUS_E_INVAL; scan_params->ie_list.ds_param = (uint8_t *)ie; - scan_params->channel.chan_idx = + *chan_idx = ((struct ds_ie *)ie)->cur_chan; break; case WLAN_ELEMID_TIM: @@ -617,8 +618,8 @@ util_scan_populate_bcn_ie_list(struct scan_cache_entry *scan_params) goto err; scan_params->ie_list.htinfo = (uint8_t *)&(((struct wlan_ie_htinfo *) ie)->hi_ie); - scan_params->channel.chan_idx = - ((struct wlan_ie_htinfo_cmn *) + *chan_idx = + ((struct wlan_ie_htinfo_cmn *) (scan_params->ie_list.htinfo))->hi_ctrlchannel; break; case WLAN_ELEMID_WAPI: @@ -1045,7 +1046,7 @@ util_scan_gen_scan_entry(struct wlan_objmgr_pdev *pdev, struct scan_cache_entry *scan_entry; struct qbss_load_ie *qbss_load; struct scan_cache_node *scan_node; - uint8_t i; + uint8_t i, chan_idx = 0; scan_entry = qdf_mem_malloc_atomic(sizeof(*scan_entry)); if (!scan_entry) { @@ -1079,6 +1080,7 @@ util_scan_gen_scan_entry(struct wlan_objmgr_pdev *pdev, scan_entry->rssi_raw = rx_param->rssi; scan_entry->avg_rssi = WLAN_RSSI_IN(scan_entry->rssi_raw); scan_entry->tsf_delta = rx_param->tsf_delta; + scan_entry->pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); /* Copy per chain rssi to scan entry */ qdf_mem_copy(scan_entry->per_chain_rssi, rx_param->rssi_ctl, @@ -1119,7 +1121,7 @@ util_scan_gen_scan_entry(struct wlan_objmgr_pdev *pdev, scan_entry->raw_frame.len = frame_len; qdf_mem_copy(scan_entry->raw_frame.ptr, frame, frame_len); - status = util_scan_populate_bcn_ie_list(scan_entry); + status = util_scan_populate_bcn_ie_list(scan_entry, &chan_idx); if (QDF_IS_STATUS_ERROR(status)) { scm_debug("failed to parse beacon IE"); qdf_mem_free(scan_entry->raw_frame.ptr); @@ -1139,13 +1141,21 @@ util_scan_gen_scan_entry(struct wlan_objmgr_pdev *pdev, if (scan_entry->ie_list.p2p) scan_entry->is_p2p = true; + if (chan_idx) { + uint8_t band_mask = BIT(wlan_reg_freq_to_band( + rx_param->chan_freq)); + + scan_entry->channel.chan_freq = + wlan_reg_chan_band_to_freq( + pdev, chan_idx, + band_mask); + } /* If no channel info is present in beacon use meta channel */ - if (!scan_entry->channel.chan_idx) { - scan_entry->channel.chan_idx = - rx_param->channel; - } else if (rx_param->channel != - scan_entry->channel.chan_idx) { - if (!wlan_reg_chan_is_49ghz(pdev, scan_entry->channel.chan_idx)) + if (!scan_entry->channel.chan_freq) { + scan_entry->channel.chan_freq = rx_param->chan_freq; + } else if (rx_param->chan_freq != + scan_entry->channel.chan_freq) { + if (!wlan_reg_is_49ghz_freq(scan_entry->channel.chan_freq)) scan_entry->channel_mismatch = true; } @@ -1161,7 +1171,7 @@ util_scan_gen_scan_entry(struct wlan_objmgr_pdev *pdev, } qdf_mem_copy(&scan_entry->mbssid_info, mbssid_info, sizeof(scan_entry->mbssid_info)); - if (WLAN_CHAN_IS_5GHZ(scan_entry->channel.chan_idx)) + if (WLAN_REG_IS_5GHZ_CH_FREQ(scan_entry->channel.chan_freq)) scan_entry->phy_mode = util_scan_get_phymode_5g(scan_entry); else scan_entry->phy_mode = util_scan_get_phymode_2g(scan_entry);