Skip to content

Commit cca16fb

Browse files
jmberg-intelgregkh
authored andcommitted
wifi: mac80211: add strict mode disabling workarounds
[ Upstream commit 3ad4fce ] Add a strict mode where we disable certain workarounds and have additional checks such as, for now, that VHT capabilities from association response match those from beacon/probe response. We can extend the checks in the future. Make it an opt-in setting by the driver so it can be set there in some driver-specific way, for example. Also allow setting this one hw flag through the hwflags debugfs, by writing a new strict=0 or strict=1 value. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Reviewed-by: Ilan Peer <ilan.peer@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20250205110958.5cecb0469479.I4a69617dc60ba0d6308416ffbc3102cfd08ba068@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c6e50cb commit cca16fb

File tree

3 files changed

+79
-16
lines changed

3 files changed

+79
-16
lines changed

include/net/mac80211.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,11 @@ struct ieee80211_txq {
28262826
* implements MLO, so operation can continue on other links when one
28272827
* link is switching.
28282828
*
2829+
* @IEEE80211_HW_STRICT: strictly enforce certain things mandated by the spec
2830+
* but otherwise ignored/worked around for interoperability. This is a
2831+
* HW flag so drivers can opt in according to their own control, e.g. in
2832+
* testing.
2833+
*
28292834
* @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
28302835
*/
28312836
enum ieee80211_hw_flags {
@@ -2885,6 +2890,7 @@ enum ieee80211_hw_flags {
28852890
IEEE80211_HW_DISALLOW_PUNCTURING,
28862891
IEEE80211_HW_DISALLOW_PUNCTURING_5GHZ,
28872892
IEEE80211_HW_HANDLES_QUIET_CSA,
2893+
IEEE80211_HW_STRICT,
28882894

28892895
/* keep last, obviously */
28902896
NUM_IEEE80211_HW_FLAGS

net/mac80211/debugfs.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ static const char *hw_flag_names[] = {
499499
FLAG(DISALLOW_PUNCTURING),
500500
FLAG(DISALLOW_PUNCTURING_5GHZ),
501501
FLAG(HANDLES_QUIET_CSA),
502+
FLAG(STRICT),
502503
#undef FLAG
503504
};
504505

@@ -531,6 +532,46 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf,
531532
return rv;
532533
}
533534

535+
static ssize_t hwflags_write(struct file *file, const char __user *user_buf,
536+
size_t count, loff_t *ppos)
537+
{
538+
struct ieee80211_local *local = file->private_data;
539+
char buf[100];
540+
int val;
541+
542+
if (count >= sizeof(buf))
543+
return -EINVAL;
544+
545+
if (copy_from_user(buf, user_buf, count))
546+
return -EFAULT;
547+
548+
if (count && buf[count - 1] == '\n')
549+
buf[count - 1] = '\0';
550+
else
551+
buf[count] = '\0';
552+
553+
if (sscanf(buf, "strict=%d", &val) == 1) {
554+
switch (val) {
555+
case 0:
556+
ieee80211_hw_set(&local->hw, STRICT);
557+
return count;
558+
case 1:
559+
__clear_bit(IEEE80211_HW_STRICT, local->hw.flags);
560+
return count;
561+
default:
562+
return -EINVAL;
563+
}
564+
}
565+
566+
return -EINVAL;
567+
}
568+
569+
static const struct file_operations hwflags_ops = {
570+
.open = simple_open,
571+
.read = hwflags_read,
572+
.write = hwflags_write,
573+
};
574+
534575
static ssize_t misc_read(struct file *file, char __user *user_buf,
535576
size_t count, loff_t *ppos)
536577
{
@@ -581,7 +622,6 @@ static ssize_t queues_read(struct file *file, char __user *user_buf,
581622
return simple_read_from_buffer(user_buf, count, ppos, buf, res);
582623
}
583624

584-
DEBUGFS_READONLY_FILE_OPS(hwflags);
585625
DEBUGFS_READONLY_FILE_OPS(queues);
586626
DEBUGFS_READONLY_FILE_OPS(misc);
587627

@@ -659,7 +699,7 @@ void debugfs_hw_add(struct ieee80211_local *local)
659699
#ifdef CONFIG_PM
660700
DEBUGFS_ADD_MODE(reset, 0200);
661701
#endif
662-
DEBUGFS_ADD(hwflags);
702+
DEBUGFS_ADD_MODE(hwflags, 0600);
663703
DEBUGFS_ADD(user_power);
664704
DEBUGFS_ADD(power);
665705
DEBUGFS_ADD(hw_conf);

net/mac80211/mlme.c

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ ieee80211_determine_ap_chan(struct ieee80211_sub_if_data *sdata,
166166
bool no_vht = false;
167167
u32 ht_cfreq;
168168

169+
if (ieee80211_hw_check(&sdata->local->hw, STRICT))
170+
ignore_ht_channel_mismatch = false;
171+
169172
*chandef = (struct cfg80211_chan_def) {
170173
.chan = channel,
171174
.width = NL80211_CHAN_WIDTH_20_NOHT,
@@ -385,7 +388,7 @@ ieee80211_verify_peer_he_mcs_support(struct ieee80211_sub_if_data *sdata,
385388
* zeroes, which is nonsense, and completely inconsistent with itself
386389
* (it doesn't have 8 streams). Accept the settings in this case anyway.
387390
*/
388-
if (!ap_min_req_set)
391+
if (!ieee80211_hw_check(&sdata->local->hw, STRICT) && !ap_min_req_set)
389392
return true;
390393

391394
/* make sure the AP is consistent with itself
@@ -445,7 +448,7 @@ ieee80211_verify_sta_he_mcs_support(struct ieee80211_sub_if_data *sdata,
445448
* zeroes, which is nonsense, and completely inconsistent with itself
446449
* (it doesn't have 8 streams). Accept the settings in this case anyway.
447450
*/
448-
if (!ap_min_req_set)
451+
if (!ieee80211_hw_check(&sdata->local->hw, STRICT) && !ap_min_req_set)
449452
return true;
450453

451454
/* Need to go over for 80MHz, 160MHz and for 80+80 */
@@ -1212,13 +1215,15 @@ static bool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,
12121215
* Some APs apparently get confused if our capabilities are better
12131216
* than theirs, so restrict what we advertise in the assoc request.
12141217
*/
1215-
if (!(ap_vht_cap->vht_cap_info &
1216-
cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)))
1217-
cap &= ~(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
1218-
IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1219-
else if (!(ap_vht_cap->vht_cap_info &
1220-
cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE)))
1221-
cap &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
1218+
if (!ieee80211_hw_check(&local->hw, STRICT)) {
1219+
if (!(ap_vht_cap->vht_cap_info &
1220+
cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE)))
1221+
cap &= ~(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
1222+
IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1223+
else if (!(ap_vht_cap->vht_cap_info &
1224+
cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE)))
1225+
cap &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
1226+
}
12221227

12231228
/*
12241229
* If some other vif is using the MU-MIMO capability we cannot associate
@@ -1260,14 +1265,16 @@ static bool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,
12601265
return mu_mimo_owner;
12611266
}
12621267

1263-
static void ieee80211_assoc_add_rates(struct sk_buff *skb,
1268+
static void ieee80211_assoc_add_rates(struct ieee80211_local *local,
1269+
struct sk_buff *skb,
12641270
enum nl80211_chan_width width,
12651271
struct ieee80211_supported_band *sband,
12661272
struct ieee80211_mgd_assoc_data *assoc_data)
12671273
{
12681274
u32 rates;
12691275

1270-
if (assoc_data->supp_rates_len) {
1276+
if (assoc_data->supp_rates_len &&
1277+
!ieee80211_hw_check(&local->hw, STRICT)) {
12711278
/*
12721279
* Get all rates supported by the device and the AP as
12731280
* some APs don't like getting a superset of their rates
@@ -1481,7 +1488,7 @@ static size_t ieee80211_assoc_link_elems(struct ieee80211_sub_if_data *sdata,
14811488
*capab |= WLAN_CAPABILITY_SPECTRUM_MGMT;
14821489

14831490
if (sband->band != NL80211_BAND_S1GHZ)
1484-
ieee80211_assoc_add_rates(skb, width, sband, assoc_data);
1491+
ieee80211_assoc_add_rates(local, skb, width, sband, assoc_data);
14851492

14861493
if (*capab & WLAN_CAPABILITY_SPECTRUM_MGMT ||
14871494
*capab & WLAN_CAPABILITY_RADIO_MEASURE) {
@@ -1925,7 +1932,8 @@ static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
19251932
* for some reason check it and want it to be set, set the bit for all
19261933
* pre-EHT connections as we used to do.
19271934
*/
1928-
if (link->u.mgd.conn.mode < IEEE80211_CONN_MODE_EHT)
1935+
if (link->u.mgd.conn.mode < IEEE80211_CONN_MODE_EHT &&
1936+
!ieee80211_hw_check(&local->hw, STRICT))
19291937
capab |= WLAN_CAPABILITY_ESS;
19301938

19311939
/* add the elements for the assoc (main) link */
@@ -4710,7 +4718,7 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link,
47104718
* 2G/3G/4G wifi routers, reported models include the "Onda PN51T",
47114719
* "Vodafone PocketWiFi 2", "ZTE MF60" and a similar T-Mobile device.
47124720
*/
4713-
if (!is_6ghz &&
4721+
if (!ieee80211_hw_check(&local->hw, STRICT) && !is_6ghz &&
47144722
((assoc_data->wmm && !elems->wmm_param) ||
47154723
(link->u.mgd.conn.mode >= IEEE80211_CONN_MODE_HT &&
47164724
(!elems->ht_cap_elem || !elems->ht_operation)) ||
@@ -4846,6 +4854,15 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link,
48464854
bss_vht_cap = (const void *)elem->data;
48474855
}
48484856

4857+
if (ieee80211_hw_check(&local->hw, STRICT) &&
4858+
(!bss_vht_cap || memcmp(bss_vht_cap, elems->vht_cap_elem,
4859+
sizeof(*bss_vht_cap)))) {
4860+
rcu_read_unlock();
4861+
ret = false;
4862+
link_info(link, "VHT capabilities mismatch\n");
4863+
goto out;
4864+
}
4865+
48494866
ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
48504867
elems->vht_cap_elem,
48514868
bss_vht_cap, link_sta);

0 commit comments

Comments
 (0)