Skip to content

Commit 7e7c892

Browse files
greearblinvjw
authored andcommitted
wireless: Support ht-capabilities over-rides.
This allows users to disable features such as HT, HT40, and to modify the MCS, AMPDU, and AMSDU settings for drivers that support it. The MCS, AMPDU, and AMSDU features that may be disabled are are reported in the phy-info netlink message as a mask. Attemping to disable features that are not supported will take no affect, but will not return errors. This is to aid backwards compatibility in user-space apps that may not be clever enough to deal with parsing the the capabilities mask. This patch only enables the infrastructure. An additional patch will enable the feature in mac80211. Signed-off-by: Ben Greear <greearb@candelatech.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent dd76986 commit 7e7c892

6 files changed

Lines changed: 132 additions & 7 deletions

File tree

‎include/linux/nl80211.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,17 @@ enum nl80211_commands {
11691169
* @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire
11701170
* probe-response frame. The DA field in the 802.11 header is zero-ed out,
11711171
* to be filled by the FW.
1172+
* @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable
1173+
* this feature. Currently, only supported in mac80211 drivers.
1174+
* @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the
1175+
* ATTR_HT_CAPABILITY to which attention should be paid.
1176+
* Currently, only mac80211 NICs support this feature.
1177+
* The values that may be configured are:
1178+
* MCS rates, MAX-AMSDU, HT-20-40 and HT_CAP_SGI_40
1179+
* AMPDU density and AMPDU factor.
1180+
* All values are treated as suggestions and may be ignored
1181+
* by the driver as required. The actual values may be seen in
1182+
* the station debugfs ht_caps file.
11721183
*
11731184
* @NL80211_ATTR_DFS_REGION: region for regulatory rules which this country
11741185
* abides to when initiating radiation on DFS channels. A country maps
@@ -1414,6 +1425,9 @@ enum nl80211_attrs {
14141425

14151426
NL80211_ATTR_DFS_REGION,
14161427

1428+
NL80211_ATTR_DISABLE_HT,
1429+
NL80211_ATTR_HT_CAPABILITY_MASK,
1430+
14171431
/* add attributes here, update the policy in nl80211.c */
14181432

14191433
__NL80211_ATTR_AFTER_LAST,

‎include/net/cfg80211.h‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,15 @@ struct cfg80211_auth_request {
10431043
bool local_state_change;
10441044
};
10451045

1046+
/**
1047+
* enum cfg80211_assoc_req_flags - Over-ride default behaviour in association.
1048+
*
1049+
* @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n)
1050+
*/
1051+
enum cfg80211_assoc_req_flags {
1052+
ASSOC_REQ_DISABLE_HT = BIT(0),
1053+
};
1054+
10461055
/**
10471056
* struct cfg80211_assoc_request - (Re)Association request data
10481057
*
@@ -1054,13 +1063,20 @@ struct cfg80211_auth_request {
10541063
* @use_mfp: Use management frame protection (IEEE 802.11w) in this association
10551064
* @crypto: crypto settings
10561065
* @prev_bssid: previous BSSID, if not %NULL use reassociate frame
1066+
* @flags: See &enum cfg80211_assoc_req_flags
1067+
* @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
1068+
* will be used in ht_capa. Un-supported values will be ignored.
1069+
* @ht_capa_mask: The bits of ht_capa which are to be used.
10571070
*/
10581071
struct cfg80211_assoc_request {
10591072
struct cfg80211_bss *bss;
10601073
const u8 *ie, *prev_bssid;
10611074
size_t ie_len;
10621075
struct cfg80211_crypto_settings crypto;
10631076
bool use_mfp;
1077+
u32 flags;
1078+
struct ieee80211_ht_cap ht_capa;
1079+
struct ieee80211_ht_cap ht_capa_mask;
10641080
};
10651081

10661082
/**
@@ -1159,6 +1175,10 @@ struct cfg80211_ibss_params {
11591175
* @key_len: length of WEP key for shared key authentication
11601176
* @key_idx: index of WEP key for shared key authentication
11611177
* @key: WEP key for shared key authentication
1178+
* @flags: See &enum cfg80211_assoc_req_flags
1179+
* @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
1180+
* will be used in ht_capa. Un-supported values will be ignored.
1181+
* @ht_capa_mask: The bits of ht_capa which are to be used.
11621182
*/
11631183
struct cfg80211_connect_params {
11641184
struct ieee80211_channel *channel;
@@ -1172,6 +1192,9 @@ struct cfg80211_connect_params {
11721192
struct cfg80211_crypto_settings crypto;
11731193
const u8 *key;
11741194
u8 key_len, key_idx;
1195+
u32 flags;
1196+
struct ieee80211_ht_cap ht_capa;
1197+
struct ieee80211_ht_cap ht_capa_mask;
11751198
};
11761199

11771200
/**
@@ -1938,6 +1961,8 @@ struct wiphy_wowlan_support {
19381961
* @wowlan: WoWLAN support information
19391962
*
19401963
* @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features.
1964+
* @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden.
1965+
* If null, then none can be over-ridden.
19411966
*/
19421967
struct wiphy {
19431968
/* assign these fields before you register the wiphy */
@@ -2027,6 +2052,8 @@ struct wiphy {
20272052
/* dir in debugfs: ieee80211/<wiphyname> */
20282053
struct dentry *debugfsdir;
20292054

2055+
const struct ieee80211_ht_cap *ht_capa_mod_mask;
2056+
20302057
#ifdef CONFIG_NET_NS
20312058
/* the network namespace this phy lives in currently */
20322059
struct net *_net;

‎net/wireless/core.h‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,17 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
341341
const u8 *bssid, const u8 *prev_bssid,
342342
const u8 *ssid, int ssid_len,
343343
const u8 *ie, int ie_len, bool use_mfp,
344-
struct cfg80211_crypto_settings *crypt);
344+
struct cfg80211_crypto_settings *crypt,
345+
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
346+
struct ieee80211_ht_cap *ht_capa_mask);
345347
int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
346348
struct net_device *dev, struct ieee80211_channel *chan,
347349
const u8 *bssid, const u8 *prev_bssid,
348350
const u8 *ssid, int ssid_len,
349351
const u8 *ie, int ie_len, bool use_mfp,
350-
struct cfg80211_crypto_settings *crypt);
352+
struct cfg80211_crypto_settings *crypt,
353+
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
354+
struct ieee80211_ht_cap *ht_capa_mask);
351355
int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
352356
struct net_device *dev, const u8 *bssid,
353357
const u8 *ie, int ie_len, u16 reason,
@@ -379,6 +383,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
379383
bool channel_type_valid, unsigned int wait,
380384
const u8 *buf, size_t len, bool no_cck,
381385
bool dont_wait_for_ack, u64 *cookie);
386+
void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
387+
const struct ieee80211_ht_cap *ht_capa_mask);
382388

383389
/* SME */
384390
int __cfg80211_connect(struct cfg80211_registered_device *rdev,

‎net/wireless/mlme.c‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,32 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
501501
return err;
502502
}
503503

504+
/* Do a logical ht_capa &= ht_capa_mask. */
505+
void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
506+
const struct ieee80211_ht_cap *ht_capa_mask)
507+
{
508+
int i;
509+
u8 *p1, *p2;
510+
if (!ht_capa_mask) {
511+
memset(ht_capa, 0, sizeof(*ht_capa));
512+
return;
513+
}
514+
515+
p1 = (u8*)(ht_capa);
516+
p2 = (u8*)(ht_capa_mask);
517+
for (i = 0; i<sizeof(*ht_capa); i++)
518+
p1[i] &= p2[i];
519+
}
520+
504521
int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
505522
struct net_device *dev,
506523
struct ieee80211_channel *chan,
507524
const u8 *bssid, const u8 *prev_bssid,
508525
const u8 *ssid, int ssid_len,
509526
const u8 *ie, int ie_len, bool use_mfp,
510-
struct cfg80211_crypto_settings *crypt)
527+
struct cfg80211_crypto_settings *crypt,
528+
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
529+
struct ieee80211_ht_cap *ht_capa_mask)
511530
{
512531
struct wireless_dev *wdev = dev->ieee80211_ptr;
513532
struct cfg80211_assoc_request req;
@@ -537,6 +556,15 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
537556
memcpy(&req.crypto, crypt, sizeof(req.crypto));
538557
req.use_mfp = use_mfp;
539558
req.prev_bssid = prev_bssid;
559+
req.flags = assoc_flags;
560+
if (ht_capa)
561+
memcpy(&req.ht_capa, ht_capa, sizeof(req.ht_capa));
562+
if (ht_capa_mask)
563+
memcpy(&req.ht_capa_mask, ht_capa_mask,
564+
sizeof(req.ht_capa_mask));
565+
cfg80211_oper_and_ht_capa(&req.ht_capa_mask,
566+
rdev->wiphy.ht_capa_mod_mask);
567+
540568
req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
541569
WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
542570
if (!req.bss) {
@@ -574,14 +602,17 @@ int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
574602
const u8 *bssid, const u8 *prev_bssid,
575603
const u8 *ssid, int ssid_len,
576604
const u8 *ie, int ie_len, bool use_mfp,
577-
struct cfg80211_crypto_settings *crypt)
605+
struct cfg80211_crypto_settings *crypt,
606+
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
607+
struct ieee80211_ht_cap *ht_capa_mask)
578608
{
579609
struct wireless_dev *wdev = dev->ieee80211_ptr;
580610
int err;
581611

582612
wdev_lock(wdev);
583613
err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
584-
ssid, ssid_len, ie, ie_len, use_mfp, crypt);
614+
ssid, ssid_len, ie, ie_len, use_mfp, crypt,
615+
assoc_flags, ht_capa, ht_capa_mask);
585616
wdev_unlock(wdev);
586617

587618
return err;

‎net/wireless/nl80211.c‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
200200
[NL80211_ATTR_PROBE_RESP] = { .type = NLA_BINARY,
201201
.len = IEEE80211_MAX_DATA_LEN },
202202
[NL80211_ATTR_DFS_REGION] = { .type = NLA_U8 },
203+
[NL80211_ATTR_DISABLE_HT] = { .type = NLA_FLAG },
204+
[NL80211_ATTR_HT_CAPABILITY_MASK] = {
205+
.len = NL80211_HT_CAPABILITY_LEN
206+
},
203207
};
204208

205209
/* policy for the key attributes */
@@ -1032,6 +1036,11 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
10321036

10331037
NLA_PUT_U32(msg, NL80211_ATTR_FEATURE_FLAGS, dev->wiphy.features);
10341038

1039+
if (dev->wiphy.ht_capa_mod_mask)
1040+
NLA_PUT(msg, NL80211_ATTR_HT_CAPABILITY_MASK,
1041+
sizeof(*dev->wiphy.ht_capa_mod_mask),
1042+
dev->wiphy.ht_capa_mod_mask);
1043+
10351044
return genlmsg_end(msg, hdr);
10361045

10371046
nla_put_failure:
@@ -4413,6 +4422,9 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
44134422
const u8 *bssid, *ssid, *ie = NULL, *prev_bssid = NULL;
44144423
int err, ssid_len, ie_len = 0;
44154424
bool use_mfp = false;
4425+
u32 flags = 0;
4426+
struct ieee80211_ht_cap *ht_capa = NULL;
4427+
struct ieee80211_ht_cap *ht_capa_mask = NULL;
44164428

44174429
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
44184430
return -EINVAL;
@@ -4456,11 +4468,25 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
44564468
if (info->attrs[NL80211_ATTR_PREV_BSSID])
44574469
prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]);
44584470

4471+
if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT]))
4472+
flags |= ASSOC_REQ_DISABLE_HT;
4473+
4474+
if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
4475+
ht_capa_mask =
4476+
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]);
4477+
4478+
if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) {
4479+
if (!ht_capa_mask)
4480+
return -EINVAL;
4481+
ht_capa = nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
4482+
}
4483+
44594484
err = nl80211_crypto_settings(rdev, info, &crypto, 1);
44604485
if (!err)
44614486
err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
44624487
ssid, ssid_len, ie, ie_len, use_mfp,
4463-
&crypto);
4488+
&crypto, flags, ht_capa,
4489+
ht_capa_mask);
44644490

44654491
return err;
44664492
}
@@ -4950,6 +4976,22 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
49504976
return PTR_ERR(connkeys);
49514977
}
49524978

4979+
if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT]))
4980+
connect.flags |= ASSOC_REQ_DISABLE_HT;
4981+
4982+
if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
4983+
memcpy(&connect.ht_capa_mask,
4984+
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]),
4985+
sizeof(connect.ht_capa_mask));
4986+
4987+
if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) {
4988+
if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
4989+
return -EINVAL;
4990+
memcpy(&connect.ht_capa,
4991+
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]),
4992+
sizeof(connect.ht_capa));
4993+
}
4994+
49534995
err = cfg80211_connect(rdev, dev, &connect, connkeys);
49544996
if (err)
49554997
kfree(connkeys);

‎net/wireless/sme.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
189189
prev_bssid,
190190
params->ssid, params->ssid_len,
191191
params->ie, params->ie_len,
192-
false, &params->crypto);
192+
false, &params->crypto,
193+
params->flags, &params->ht_capa,
194+
&params->ht_capa_mask);
193195
if (err)
194196
__cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
195197
NULL, 0,
@@ -773,6 +775,9 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
773775
wdev->connect_keys = NULL;
774776
}
775777

778+
cfg80211_oper_and_ht_capa(&connect->ht_capa_mask,
779+
rdev->wiphy.ht_capa_mod_mask);
780+
776781
if (connkeys && connkeys->def >= 0) {
777782
int idx;
778783
u32 cipher;

0 commit comments

Comments
 (0)