Skip to content

Commit a615323

Browse files
benzeajmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: always apply 6 GHz probe limitations
When scanning on 6 GHz we allocate a set of short-SSIDs and BSSIDs to probe. However, when we need to do an active scan because of a hidden SSID, then we could add too many entries for probing causing an assertion in the firmware input validation. Reshuffle the code a bit to first calculate the maximum number of short-SSIDs and BSSIDs that are permitted for the channel. Then ensure that we do not set more than the permitted number of bits in the bitmasks and turn on force_passive when we have surpassed the limit. While at it, also change the logic so that allow_passive is always disabled in case a hidden SSID is included. Previously, we might not have done so if we added the short-SSID based on the number of BSSIDs already in the request. Signed-off-by: Benjamin Berg <[email protected]> Reviewed-by: Ilan Peer <[email protected]> Signed-off-by: Miri Korenblit <[email protected]> Link: https://msgid.link/20240319100755.e0b114b68d1d.Ib86afccdb955f0d221ef5d7b8afdc1d67c3542ef@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 8f892e2 commit a615323

File tree

1 file changed

+89
-66
lines changed
  • drivers/net/wireless/intel/iwlwifi/mvm

1 file changed

+89
-66
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/scan.c

Lines changed: 89 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,8 +1750,9 @@ iwl_mvm_umac_scan_cfg_channels_v7_6g(struct iwl_mvm *mvm,
17501750
&cp->channel_config[ch_cnt];
17511751

17521752
u32 s_ssid_bitmap = 0, bssid_bitmap = 0, flags = 0;
1753-
u8 j, k, s_max = 0, b_max = 0, n_used_bssid_entries;
1754-
bool force_passive, found = false, allow_passive = true,
1753+
u8 j, k, n_s_ssids = 0, n_bssids = 0;
1754+
u8 max_s_ssids, max_bssids;
1755+
bool force_passive = false, found = false, allow_passive = true,
17551756
unsolicited_probe_on_chan = false, psc_no_listen = false;
17561757
s8 psd_20 = IEEE80211_RNR_TBTT_PARAMS_PSD_RESERVED;
17571758

@@ -1774,20 +1775,15 @@ iwl_mvm_umac_scan_cfg_channels_v7_6g(struct iwl_mvm *mvm,
17741775
cfg->v5.iter_count = 1;
17751776
cfg->v5.iter_interval = 0;
17761777

1777-
/*
1778-
* The optimize the scan time, i.e., reduce the scan dwell time
1779-
* on each channel, the below logic tries to set 3 direct BSSID
1780-
* probe requests for each broadcast probe request with a short
1781-
* SSID.
1782-
* TODO: improve this logic
1783-
*/
1784-
n_used_bssid_entries = 3;
17851778
for (j = 0; j < params->n_6ghz_params; j++) {
17861779
s8 tmp_psd_20;
17871780

17881781
if (!(scan_6ghz_params[j].channel_idx == i))
17891782
continue;
17901783

1784+
unsolicited_probe_on_chan |=
1785+
scan_6ghz_params[j].unsolicited_probe;
1786+
17911787
/* Use the highest PSD value allowed as advertised by
17921788
* APs for this channel
17931789
*/
@@ -1799,12 +1795,69 @@ iwl_mvm_umac_scan_cfg_channels_v7_6g(struct iwl_mvm *mvm,
17991795
psd_20 < tmp_psd_20))
18001796
psd_20 = tmp_psd_20;
18011797

1802-
found = false;
1803-
unsolicited_probe_on_chan |=
1804-
scan_6ghz_params[j].unsolicited_probe;
18051798
psc_no_listen |= scan_6ghz_params[j].psc_no_listen;
1799+
}
1800+
1801+
/*
1802+
* In the following cases apply passive scan:
1803+
* 1. Non fragmented scan:
1804+
* - PSC channel with NO_LISTEN_FLAG on should be treated
1805+
* like non PSC channel
1806+
* - Non PSC channel with more than 3 short SSIDs or more
1807+
* than 9 BSSIDs.
1808+
* - Non PSC Channel with unsolicited probe response and
1809+
* more than 2 short SSIDs or more than 6 BSSIDs.
1810+
* - PSC channel with more than 2 short SSIDs or more than
1811+
* 6 BSSIDs.
1812+
* 3. Fragmented scan:
1813+
* - PSC channel with more than 1 SSID or 3 BSSIDs.
1814+
* - Non PSC channel with more than 2 SSIDs or 6 BSSIDs.
1815+
* - Non PSC channel with unsolicited probe response and
1816+
* more than 1 SSID or more than 3 BSSIDs.
1817+
*/
1818+
if (!iwl_mvm_is_scan_fragmented(params->type)) {
1819+
if (!cfg80211_channel_is_psc(params->channels[i]) ||
1820+
flags & IWL_UHB_CHAN_CFG_FLAG_PSC_CHAN_NO_LISTEN) {
1821+
if (unsolicited_probe_on_chan) {
1822+
max_s_ssids = 2;
1823+
max_bssids = 6;
1824+
} else {
1825+
max_s_ssids = 3;
1826+
max_bssids = 9;
1827+
}
1828+
} else {
1829+
max_s_ssids = 2;
1830+
max_bssids = 6;
1831+
}
1832+
} else if (cfg80211_channel_is_psc(params->channels[i])) {
1833+
max_s_ssids = 1;
1834+
max_bssids = 3;
1835+
} else {
1836+
if (unsolicited_probe_on_chan) {
1837+
max_s_ssids = 1;
1838+
max_bssids = 3;
1839+
} else {
1840+
max_s_ssids = 2;
1841+
max_bssids = 6;
1842+
}
1843+
}
1844+
1845+
/*
1846+
* The optimize the scan time, i.e., reduce the scan dwell time
1847+
* on each channel, the below logic tries to set 3 direct BSSID
1848+
* probe requests for each broadcast probe request with a short
1849+
* SSID.
1850+
* TODO: improve this logic
1851+
*/
1852+
for (j = 0; j < params->n_6ghz_params; j++) {
1853+
if (!(scan_6ghz_params[j].channel_idx == i))
1854+
continue;
1855+
1856+
found = false;
18061857

1807-
for (k = 0; k < pp->short_ssid_num; k++) {
1858+
for (k = 0;
1859+
k < pp->short_ssid_num && n_s_ssids < max_s_ssids;
1860+
k++) {
18081861
if (!scan_6ghz_params[j].unsolicited_probe &&
18091862
le32_to_cpu(pp->short_ssid[k]) ==
18101863
scan_6ghz_params[j].short_ssid) {
@@ -1815,25 +1868,25 @@ iwl_mvm_umac_scan_cfg_channels_v7_6g(struct iwl_mvm *mvm,
18151868
}
18161869

18171870
/*
1818-
* Use short SSID only to create a new
1819-
* iteration during channel dwell or in
1820-
* case that the short SSID has a
1821-
* matching SSID, i.e., scan for hidden
1822-
* APs.
1871+
* Prefer creating BSSID entries unless
1872+
* the short SSID probe can be done in
1873+
* the same channel dwell iteration.
1874+
*
1875+
* We also need to create a short SSID
1876+
* entry for any hidden AP.
18231877
*/
1824-
if (n_used_bssid_entries >= 3) {
1825-
s_ssid_bitmap |= BIT(k);
1826-
s_max++;
1827-
n_used_bssid_entries -= 3;
1828-
found = true;
1878+
if (3 * n_s_ssids > n_bssids &&
1879+
!pp->direct_scan[k].len)
18291880
break;
1830-
} else if (pp->direct_scan[k].len) {
1831-
s_ssid_bitmap |= BIT(k);
1832-
s_max++;
1833-
found = true;
1881+
1882+
/* Hidden AP, cannot do passive scan */
1883+
if (pp->direct_scan[k].len)
18341884
allow_passive = false;
1835-
break;
1836-
}
1885+
1886+
s_ssid_bitmap |= BIT(k);
1887+
n_s_ssids++;
1888+
found = true;
1889+
break;
18371890
}
18381891
}
18391892

@@ -1845,9 +1898,12 @@ iwl_mvm_umac_scan_cfg_channels_v7_6g(struct iwl_mvm *mvm,
18451898
scan_6ghz_params[j].bssid,
18461899
ETH_ALEN)) {
18471900
if (!(bssid_bitmap & BIT(k))) {
1848-
bssid_bitmap |= BIT(k);
1849-
b_max++;
1850-
n_used_bssid_entries++;
1901+
if (n_bssids < max_bssids) {
1902+
bssid_bitmap |= BIT(k);
1903+
n_bssids++;
1904+
} else {
1905+
force_passive = TRUE;
1906+
}
18511907
}
18521908
break;
18531909
}
@@ -1861,39 +1917,6 @@ iwl_mvm_umac_scan_cfg_channels_v7_6g(struct iwl_mvm *mvm,
18611917
if (unsolicited_probe_on_chan)
18621918
flags |= IWL_UHB_CHAN_CFG_FLAG_UNSOLICITED_PROBE_RES;
18631919

1864-
/*
1865-
* In the following cases apply passive scan:
1866-
* 1. Non fragmented scan:
1867-
* - PSC channel with NO_LISTEN_FLAG on should be treated
1868-
* like non PSC channel
1869-
* - Non PSC channel with more than 3 short SSIDs or more
1870-
* than 9 BSSIDs.
1871-
* - Non PSC Channel with unsolicited probe response and
1872-
* more than 2 short SSIDs or more than 6 BSSIDs.
1873-
* - PSC channel with more than 2 short SSIDs or more than
1874-
* 6 BSSIDs.
1875-
* 3. Fragmented scan:
1876-
* - PSC channel with more than 1 SSID or 3 BSSIDs.
1877-
* - Non PSC channel with more than 2 SSIDs or 6 BSSIDs.
1878-
* - Non PSC channel with unsolicited probe response and
1879-
* more than 1 SSID or more than 3 BSSIDs.
1880-
*/
1881-
if (!iwl_mvm_is_scan_fragmented(params->type)) {
1882-
if (!cfg80211_channel_is_psc(params->channels[i]) ||
1883-
flags & IWL_UHB_CHAN_CFG_FLAG_PSC_CHAN_NO_LISTEN) {
1884-
force_passive = (s_max > 3 || b_max > 9);
1885-
force_passive |= (unsolicited_probe_on_chan &&
1886-
(s_max > 2 || b_max > 6));
1887-
} else {
1888-
force_passive = (s_max > 2 || b_max > 6);
1889-
}
1890-
} else if (cfg80211_channel_is_psc(params->channels[i])) {
1891-
force_passive = (s_max > 1 || b_max > 3);
1892-
} else {
1893-
force_passive = (s_max > 2 || b_max > 6);
1894-
force_passive |= (unsolicited_probe_on_chan &&
1895-
(s_max > 1 || b_max > 3));
1896-
}
18971920
if ((allow_passive && force_passive) ||
18981921
(!(bssid_bitmap | s_ssid_bitmap) &&
18991922
!cfg80211_channel_is_psc(params->channels[i])))

0 commit comments

Comments
 (0)