modify the inclusion of supported channels IE
Subsystems (2)
cover modify the inclusion of supported channels IE
The 80211-2012 specification defines in 8.4.2.20 that the supported channels information element should contain a list of the channel subbands in which the station is capable to operate. Change the mac80211 implementation to add all the channels currently enabled by the device (excluding disabled channels).
Note: the implementation is not complete as it missing an better handling for subband in bands other than 2.4 GHz.
Ilan Peer (2):
cfg80211: Add a function to get the number of enabled channels
mac80211: Add all enabled channels to the supported channels element
include/net/cfg80211.h | 9 ++++++ net/mac80211/mlme.c | 80 ++++++++++++++++++++++++++++++++++++++++++------ net/wireless/util.c | 21 +++++++++++++ 3 files changed, 100 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/2 cfg80211: Add a function to get the number of enabled channels
Add a utility function to get the number of channels enabled by the device.
--- include/net/cfg80211.h | 9 +++++++++ net/wireless/util.c | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+)
include/net/cfg80211.h +9 -0
@@ -4532,6 +4532,15 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,*/ void cfg80211_crit_proto_stopped (struct wireless_dev *wdev,gfp_t gfp); +/** +* ieee80211_get_num_enabled_channels - get the number of channels supported +* and enabled by the device. +* @wiphy: the wiphy +* +* Return: the number of channels supported and enabled by the device. +*/ +unsigned int ieee80211_get_num_enabled_channels (struct wiphy *wiphy); +/* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */
net/wireless/util.c +21 -0
@@ -1462,6 +1462,27 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,return 0 ; } +unsigned int ieee80211_get_num_enabled_channels (struct wiphy *wiphy) +{ +struct ieee80211_supported_band *sband; +unsigned int n_channels, i, j; + +for (i =0 , n_channels =0 ; i <IEEE80211_NUM_BANDS ; i++) { + sband = wiphy->bands[i]; +if (!sband) +continue ; + +for (j =0 ; j < sband->n_channels; j++) { +if (!(sband->channels[j].flags & +IEEE80211_CHAN_DISABLED )) + n_channels++; + } + } + +return n_channels; +} +EXPORT_SYMBOL (ieee80211_get_num_enabled_channels); +/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ const unsigned char rfc1042_header[] __aligned(2) =
Signature · 1 line
1.7.10.4
PATCH v2 1/2 cfg80211: Add a function to get the number of supported channels
Add a utility function to get the number of channels supported by the device, and update the places in the code that need this data.
--- include/net/cfg80211.h | 9 +++++++++ net/wireless/nl80211.c | 13 ++----------- net/wireless/scan.c | 7 ++----- net/wireless/sme.c | 13 +++---------- net/wireless/util.c | 13 +++++++++++++ 5 files changed, 29 insertions(+), 26 deletions(-)
include/net/cfg80211.h +9 -0
@@ -4640,6 +4640,15 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,*/ void cfg80211_crit_proto_stopped (struct wireless_dev *wdev,gfp_t gfp); +/** +* ieee80211_get_num_supported_channels - get the number of channels supported +* by the device. +* @wiphy: the wiphy +* +* Return: the number of channels supported by the device. +*/ +unsigned int ieee80211_get_num_supported_channels (struct wiphy *wiphy); +/* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */
net/wireless/nl80211.c +2 -11
@@ -5285,12 +5285,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) goto unlock; } }else { -enum ieee80211_band band; - n_channels =0 ; - -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) -if (wiphy->bands[band]) - n_channels += wiphy->bands[band]->n_channels; + n_channels =ieee80211_get_num_supported_channels (wiphy); }if (info->attrs[NL80211_ATTR_SCAN_SSIDS ])
@@ -5498,11 +5493,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,if (!n_channels)return -EINVAL ; }else { - n_channels =0 ; - -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) -if (wiphy->bands[band]) - n_channels += wiphy->bands[band]->n_channels; + n_channels =ieee80211_get_num_supported_channels (wiphy); }if (info->attrs[NL80211_ATTR_SCAN_SSIDS ])
net/wireless/scan.c +2 -5
@@ -1089,11 +1089,8 @@ int cfg80211_wext_siwscan(struct net_device *dev,/* Determine number of channels, needed to allocate creq */ if (wreq && wreq->num_channels) n_channels = wreq->num_channels; -else { -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) -if (wiphy->bands[band]) - n_channels += wiphy->bands[band]->n_channels; - } +else + n_channles =ieee80211_get_num_supported_channels (wiphy); creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + n_channels * sizeof(void *),
net/wireless/sme.c +3 -10
@@ -70,18 +70,11 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)if (rdev->scan_req)return -EBUSY ; -if (wdev->conn->params.channel) { +if (wdev->conn->params.channel) n_channels =1 ; - }else { -enum ieee80211_band band; - n_channels =0 ; +else + n_channels =ieee80211_get_num_supported_channels (wdev->wiphy); -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) { -if (!wdev->wiphy->bands[band]) -continue ; - n_channels += wdev->wiphy->bands[band]->n_channels; - } - } request =kzalloc (sizeof (*request) +sizeof (request->ssids[0 ]) +sizeof (request->channels[0 ]) * n_channels,GFP_KERNEL );
net/wireless/util.c +13 -0
@@ -1479,6 +1479,19 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,return 0 ; } +unsigned int ieee80211_get_num_supported_channels (struct wiphy *wiphy) +{ +enum ieee80211_band band; +unsigned int n_channels; + +for (band =0 , n_channels =0 ; band <IEEE80211_NUM_BANDS ; band++) +if (wiphy->bands[band]) + n_channels += wiphy->bands[band]->n_channels; + +return n_channels; +} +EXPORT_SYMBOL (ieee80211_get_num_supported_channels); +/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ const unsigned char rfc1042_header[] __aligned(2) =
Signature · 1 line
1.7.10.4
Johannes Berg
maintainerRe: [PATCH 1/2 v2] cfg80211: Add a function to get the number of supported channels
net/wireless/scan.c int cfg80211_wext_siwscan(struct net_device *dev, · line 1093
Quoted 2 lines · Ilan Peer
net/wireless/scan.c +2
-0+else + n_channles =ieee80211_get_num_supported_channels (wiphy);
err ...
johannes
Johannes Berg
maintainerRe: [PATCH 1/2 v2] cfg80211: Add a function to get the number of supported channels
In reply to Ilan Peernet/wireless/util.c int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, · line 1485
Quoted 4 lines · Ilan Peer
net/wireless/util.c +4
-0+unsigned int ieee80211_get_num_supported_channels (struct wiphy *wiphy) +{ +enum ieee80211_band band; +unsigned int n_channels;
Seems nicer to do the = 0 here rather than in the loop?
net/wireless/util.c int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, · line 1487
Quoted 1 line
net/wireless/util.c +1
-0+for (band =0 , n_channels =0 ; band <IEEE80211_NUM_BANDS ; band++)
johannes
PATCH v3 1/2 cfg80211: Add a function to get the number of supported channels
In reply to Ilan PeerAdd a utility function to get the number of channels supported by the device, and update the places in the code that need this data.
--- include/net/cfg80211.h | 9 +++++++++ net/wireless/nl80211.c | 13 ++----------- net/wireless/scan.c | 7 ++----- net/wireless/sme.c | 13 +++---------- net/wireless/util.c | 13 +++++++++++++ 5 files changed, 29 insertions(+), 26 deletions(-)
include/net/cfg80211.h +9 -0
@@ -4640,6 +4640,15 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,*/ void cfg80211_crit_proto_stopped (struct wireless_dev *wdev,gfp_t gfp); +/** +* ieee80211_get_num_supported_channels - get the number of channels supported +* by the device. +* @wiphy: the wiphy +* +* Return: the number of channels supported by the device. +*/ +unsigned int ieee80211_get_num_supported_channels (struct wiphy *wiphy); +/* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */
net/wireless/nl80211.c +2 -11
@@ -5285,12 +5285,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) goto unlock; } }else { -enum ieee80211_band band; - n_channels =0 ; - -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) -if (wiphy->bands[band]) - n_channels += wiphy->bands[band]->n_channels; + n_channels =ieee80211_get_num_supported_channels (wiphy); }if (info->attrs[NL80211_ATTR_SCAN_SSIDS ])
@@ -5498,11 +5493,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,if (!n_channels)return -EINVAL ; }else { - n_channels =0 ; - -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) -if (wiphy->bands[band]) - n_channels += wiphy->bands[band]->n_channels; + n_channels =ieee80211_get_num_supported_channels (wiphy); }if (info->attrs[NL80211_ATTR_SCAN_SSIDS ])
net/wireless/scan.c +2 -5
@@ -1089,11 +1089,8 @@ int cfg80211_wext_siwscan(struct net_device *dev,/* Determine number of channels, needed to allocate creq */ if (wreq && wreq->num_channels) n_channels = wreq->num_channels; -else { -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) -if (wiphy->bands[band]) - n_channels += wiphy->bands[band]->n_channels; - } +else + n_channles =ieee80211_get_num_supported_channels (wiphy); creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + n_channels * sizeof(void *),
net/wireless/sme.c +3 -10
@@ -70,18 +70,11 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)if (rdev->scan_req)return -EBUSY ; -if (wdev->conn->params.channel) { +if (wdev->conn->params.channel) n_channels =1 ; - }else { -enum ieee80211_band band; - n_channels =0 ; +else + n_channels =ieee80211_get_num_supported_channels (wdev->wiphy); -for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) { -if (!wdev->wiphy->bands[band]) -continue ; - n_channels += wdev->wiphy->bands[band]->n_channels; - } - } request =kzalloc (sizeof (*request) +sizeof (request->ssids[0 ]) +sizeof (request->channels[0 ]) * n_channels,GFP_KERNEL );
net/wireless/util.c +13 -0
@@ -1479,6 +1479,19 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,return 0 ; } +unsigned int ieee80211_get_num_supported_channels (struct wiphy *wiphy) +{ +enum ieee80211_band band; +unsigned int n_channels; + +for (band =0 , n_channels =0 ; band <IEEE80211_NUM_BANDS ; band++) +if (wiphy->bands[band]) + n_channels += wiphy->bands[band]->n_channels; + +return n_channels; +} +EXPORT_SYMBOL (ieee80211_get_num_supported_channels); +/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ const unsigned char rfc1042_header[] __aligned(2) =
Signature · 1 line
1.7.10.4
Johannes Berg
maintainerRe: [PATCH 1/2 v3] cfg80211: Add a function to get the number of supported channels
Quoted 2 lines · Ilan Peer
Add a utility function to get the number of channels supported by the device, and update the places in the code that need this data.
Applied with some fixes.
johannes
RFC PATCH 2/2 mac80211: Add all enabled channels to the supported channels element
In reply to Ilan PeerIn the current implementation, in case that the AP supports spectrum management, the supported channels information element added to the association and re-association frames includes only the channels that where in the same band as that of the operating channel of the AP. However, the 80211-2012 specification defines in 8.4.2.20 that the supported channels information element should contain a list of the channel subbands in which the station is capable to operate.
Fix this gap by including all the channels enabled by the device (excluding channels that are marked as disabled).
--- net/mac80211/mlme.c | 80 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 10 deletions(-)
net/mac80211/mlme.c +70 -10
@@ -540,6 +540,70 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,ieee80211_ie_build_vht_cap (pos, &vht_cap, cap); } +static void ieee80211_add_supported_channels (struct ieee80211_local *local, +struct sk_buff *skb, +unsigned int n_channels) +{ +struct ieee80211_supported_band *sband; +unsigned int i, j; +u8 *pos, *len_pos; + +if (!n_channels) +return ; + + pos =skb_put (skb,2 ); + *pos++ =WLAN_EID_SUPPORTED_CHANNELS ; + len_pos = pos; + *len_pos =0 ; + +for (i =0 ; i <IEEE80211_NUM_BANDS ; i++) { +u8 chan, first_chan =0 , count =0 ; + + sband = local->hw.wiphy->bands[i]; +if (!sband) +continue ; + +for (j =0 ; j < sband->n_channels; j++) { +u16 center_freq; + +if (sband->channels[j].flags &IEEE80211_CHAN_DISABLED ) +continue ; + + center_freq = sband->channels[j].center_freq; + chan =ieee80211_frequency_to_channel (center_freq); + +if (first_chan ==0 ) { +/* first subband */ + first_chan = chan; + count =1 ; + }else if (first_chan + count == chan) { +/* continue the subband. +* TODO: this is really only useful for 2.4, +* need to add spacing considerations for other +* bands as well (the definition of a subband +* in the 802.11 spec. is a bit vague). +*/ + count++; + }else { +/* store the subband and start a new one */ + pos =skb_put (skb,2 ); + *pos++ = first_chan; + *pos = count; + *len_pos +=2 ; + first_chan = chan; + count =1 ; + } + } + +if (first_chan) { + pos =skb_put (skb,2 ); + *pos++ = first_chan; + *pos = count; + *len_pos +=2 ; + } + } +} +static void ieee80211_send_assoc (struct ieee80211_sub_if_data *sdata) {struct ieee80211_local *local = sdata->local;
@@ -555,6 +619,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)struct ieee80211_chanctx_conf *chanctx_conf;struct ieee80211_channel *chan;u32 rate_flags, rates =0 ; +unsigned int n_channels;sdata_assert_lock (sdata);
@@ -597,12 +662,15 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) } } +/* Get the number of enabled channels for spectrum management */ + n_channels =ieee80211_get_num_enabled_channels (local->hw.wiphy); + skb = alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + /* bit too much but doesn't matter */ 2 + assoc_data->ssid_len + /* SSID */ 4 + rates_len + /* (extended) rates */ 4 + /* power capability */ - 2 + 2 * sband->n_channels + /* supported channels */ + 2 + 2 * n_channels + /* supported channels */ 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ 2 + sizeof(struct ieee80211_vht_cap) + /* VHT */ assoc_data->ie_len + /* extra IEs */
@@ -704,15 +772,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) *pos++ =ieee80211_chandef_max_power (&chanctx_conf->def);/* 2. supported channels */ -/* TODO: get this in reg domain format */ - pos =skb_put (skb,2 * sband->n_channels +2 ); - *pos++ =WLAN_EID_SUPPORTED_CHANNELS ; - *pos++ =2 * sband->n_channels; -for (i =0 ; i < sband->n_channels; i++) { - *pos++ =ieee80211_frequency_to_channel ( - sband->channels[i].center_freq); - *pos++ =1 ;/* one channel in the subband*/ - } +ieee80211_add_supported_channels (local, skb, n_channels); }/* if present, add any custom IEs that go before HT */
Signature · 1 line
1.7.10.4
RE: [PATCH 2/2] [RFC] mac80211: Add all enabled channels to the supported channels element
Quoted 18 lines
In the current implementation, in case that the AP supports spectrum management, the supported channels information element added to the association and re-association frames includes only the channels that where in the same band as that of the operating channel of the AP. However, the 80211-2012 specification defines in 8.4.2.20 that the supported channels information element should contain a list of the channel subbands in which the station is capable to operate.
net/mac80211/mlme.c +9
-0+ +if (first_chan ==0 ) { +/* first subband */ + first_chan = chan; + count =1 ; + }else if (first_chan + count == chan) { +/* continue the subband. +* TODO: this is really only useful for 2.4, +* need to add spacing considerations for other
net/mac80211/mlme.c static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, · line 585
Quoted 3 lines
net/mac80211/mlme.c +3
-0+* bands as well (the definition of a subband +* in the 802.11 spec. is a bit vague). +*/
Any suggestions on how to better handle this?
Thanks in advance :)
Ilan.
Johannes Berg
maintainerRe: [PATCH 2/2] [RFC] mac80211: Add all enabled channels to the supported channels element
In reply to Ilan PeerQuoted 16 lines · Ilan Peer
+ chan =
ieee80211_frequency_to_channel(center_freq);net/mac80211/mlme.c +8
-0+ +if (first_chan ==0 ) { +/* first subband */ + first_chan = chan; + count =1 ; + }else if (first_chan + count == chan) { +/* continue the subband. +* TODO: this is really only useful for 2.4,
(quoted diff) +2
-0+ * need to add spacing considerations for other + * bands as well (the definition of asubband
+ * in the 802.11 spec. is a bit
vague).
net/mac80211/mlme.c static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, · line 586
Quoted 2 lines
net/mac80211/mlme.c +2
-0+*/ + count++;
I agree this is very vague - anyone have a good idea who to ask?
As it is now, I'm not sure it's correct at all, even in the version we have today, since different operating classes could have different requirements. Especially since we support 5/10 MHz now, I suspect even ieee80211_frequency_to_channel() really should be taught about operating classes in some form?
net/mac80211/mlme.c static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) · line 666
Quoted 2 lines
net/mac80211/mlme.c +2
-0+/* Get the number of enabled channels for spectrum management */ + n_channels =ieee80211_get_num_enabled_channels (local->hw.wiphy);
I would prefer you did this with an upper bound rather than the number of enabled channels - we don't need a good estimate, worst case we'll allocate a few bytes too many, but if we get it completely wrong e.g. because the channel flags are being changed, then we could overrun the SKB allocation, I think?
It'd also be faster to iterate only the bands and add up n_channels rather than checking each channel's enabled bit.
johannes
RE: [PATCH 2/2] [RFC] mac80211: Add all enabled channels to the supported channels element
PiA+ICsgICAgICAgICAgICAgICAgICAgICAgIGNoYW4gPQ0KPiA+IGllZWU4MDIxMV9mcmVxdWVu Y3lfdG9fY2hhbm5lbChjZW50ZXJfZnJlcSk7DQo+ID4gKw0KPiA+ICsgICAgICAgICAgICAgICAg ICAgICAgIGlmIChmaXJzdF9jaGFuID09IDApIHsNCj4gPiArICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIC8qIGZpcnN0IHN1YmJhbmQgKi8NCj4gPiArICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIGZpcnN0X2NoYW4gPSBjaGFuOw0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgY291bnQgPSAxOw0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBp ZiAoZmlyc3RfY2hhbiArIGNvdW50ID09IGNoYW4pIHsNCj4gPiArICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIC8qIGNvbnRpbnVlIHRoZSBzdWJiYW5kLg0KPiA+ICsgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICogVE9ETzogdGhpcyBpcyByZWFsbHkgb25seSB1c2VmdWwNCj4g PiBmb3IgMi40LA0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICogbmVlZCB0 byBhZGQgc3BhY2luZyBjb25zaWRlcmF0aW9ucyBmb3Igb3RoZXINCj4gPiArICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAqIGJhbmRzIGFzIHdlbGwgKHRoZSBkZWZpbml0aW9uIG9mIGEN Cj4gPiBzdWJiYW5kDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKiBpbiB0 aGUgODAyLjExIHNwZWMuIGlzIGEgYml0DQo+ID4gdmFndWUpLg0KPiA+ICsgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICovDQo+ID4gKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBjb3VudCsrOw0KPiANCj4gSSBhZ3JlZSB0aGlzIGlzIHZlcnkgdmFndWUgLSBhbnlvbmUgaGF2 ZSBhIGdvb2QgaWRlYSB3aG8gdG8gYXNrPw0KPiANCj4gQXMgaXQgaXMgbm93LCBJJ20gbm90IHN1 cmUgaXQncyBjb3JyZWN0IGF0IGFsbCwgZXZlbiBpbiB0aGUgdmVyc2lvbiB3ZSBoYXZlIHRvZGF5 LA0KPiBzaW5jZSBkaWZmZXJlbnQgb3BlcmF0aW5nIGNsYXNzZXMgY291bGQgaGF2ZSBkaWZmZXJl bnQgcmVxdWlyZW1lbnRzLg0KPiBFc3BlY2lhbGx5IHNpbmNlIHdlIHN1cHBvcnQgNS8xMCBNSHog bm93LCBJIHN1c3BlY3QgZXZlbg0KPiBpZWVlODAyMTFfZnJlcXVlbmN5X3RvX2NoYW5uZWwoKSBy ZWFsbHkgc2hvdWxkIGJlIHRhdWdodCBhYm91dCBvcGVyYXRpbmcNCj4gY2xhc3NlcyBpbiBzb21l IGZvcm0/DQo+IA0KPiA+ICsJLyogR2V0IHRoZSBudW1iZXIgb2YgZW5hYmxlZCBjaGFubmVscyBm b3Igc3BlY3RydW0gbWFuYWdlbWVudA0KPiAqLw0KPiA+ICsJbl9jaGFubmVscyA9IGllZWU4MDIx MV9nZXRfbnVtX2VuYWJsZWRfY2hhbm5lbHMobG9jYWwtDQo+ID5ody53aXBoeSk7DQo+IA0KPiBJ IHdvdWxkIHByZWZlciB5b3UgZGlkIHRoaXMgd2l0aCBhbiB1cHBlciBib3VuZCByYXRoZXIgdGhh biB0aGUgbnVtYmVyIG9mDQo+IGVuYWJsZWQgY2hhbm5lbHMgLSB3ZSBkb24ndCBuZWVkIGEgZ29v ZCBlc3RpbWF0ZSwgd29yc3QgY2FzZSB3ZSdsbCBhbGxvY2F0ZQ0KPiBhIGZldyBieXRlcyB0b28g bWFueSwgYnV0IGlmIHdlIGdldCBpdCBjb21wbGV0ZWx5IHdyb25nIGUuZy4NCj4gYmVjYXVzZSB0 aGUgY2hhbm5lbCBmbGFncyBhcmUgYmVpbmcgY2hhbmdlZCwgdGhlbiB3ZSBjb3VsZCBvdmVycnVu IHRoZSBTS0INCj4gYWxsb2NhdGlvbiwgSSB0aGluaz8NCj4gDQo+IEl0J2QgYWxzbyBiZSBmYXN0 ZXIgdG8gaXRlcmF0ZSBvbmx5IHRoZSBiYW5kcyBhbmQgYWRkIHVwIG5fY2hhbm5lbHMgcmF0aGVy DQo+IHRoYW4gY2hlY2tpbmcgZWFjaCBjaGFubmVsJ3MgZW5hYmxlZCBiaXQuDQo+DQoNClN1cmUu IEknbGwgbW9kaWZ5IHRoZSB1dGlsaXR5IGZ1bmN0aW9uIGFzIHRoZSBzYW1lIGxvZ2ljIHRoYXQg eW91IHN1Z2dlc3RlZCBpcyB1c2VkIGluIGEgY291cGxlIG9mIG90aGVyICBwbGFjZXMgaW4gdGhl IGNvZGUuDQoNCklsYW4uDQo=
RFC PATCH v2 2/2 mac80211: Add all enabled channels to the supported channels element
In reply to Ilan PeerIn the current implementation, in case that the AP supports spectrum management, the supported channels information element added to the association and re-association frames includes only the channels that where in the same band as that of the operating channel of the AP. However, the 80211-2012 specification defines in 8.4.2.20 that the supported channels information element should contain a list of the channel subbands in which the station is capable to operate.
Fix this gap by include all the channels enabled by the station (excluding channels that are marked as disabled).
--- net/mac80211/mlme.c | 77 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 10 deletions(-)
net/mac80211/mlme.c +67 -10
@@ -540,6 +540,67 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,ieee80211_ie_build_vht_cap (pos, &vht_cap, cap); } +static void ieee80211_add_supported_channels (struct ieee80211_local *local, +struct sk_buff *skb, +unsigned int n_channels) +{ +struct ieee80211_supported_band *sband; +unsigned int i, j; +u8 *pos, *len_pos; + + pos =skb_put (skb,2 ); + *pos++ =WLAN_EID_SUPPORTED_CHANNELS ; + len_pos = pos; + *len_pos =0 ; + +for (i =0 ; i <IEEE80211_NUM_BANDS ; i++) { +u8 chan, first_chan =0 , count =0 ; + + sband = local->hw.wiphy->bands[i]; +if (!sband) +continue ; + +for (j =0 ; j < sband->n_channels; j++) { +u16 center_freq; + +if (sband->channels[j].flags &IEEE80211_CHAN_DISABLED ) +continue ; + + center_freq = sband->channels[j].center_freq; + chan =ieee80211_frequency_to_channel (center_freq); + +if (first_chan ==0 ) { +/* first subband */ + first_chan = chan; + count =1 ; + }else if (first_chan + count == chan) { +/* continue the subband. +* TODO: this is really only useful for 2.4, +* need to add spacing considerations for other +* bands as well (the definition of a subband +* in the 802.11 spec. is a bit vague). +*/ + count++; + }else { +/* store the subband and start a new one */ + pos =skb_put (skb,2 ); + *pos++ = first_chan; + *pos = count; + *len_pos +=2 ; + first_chan = chan; + count =1 ; + } + } + +if (first_chan) { + pos =skb_put (skb,2 ); + *pos++ = first_chan; + *pos = count; + *len_pos +=2 ; + } + } +} +static void ieee80211_send_assoc (struct ieee80211_sub_if_data *sdata) {struct ieee80211_local *local = sdata->local;
@@ -555,6 +616,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)struct ieee80211_chanctx_conf *chanctx_conf;struct ieee80211_channel *chan;u32 rate_flags, rates =0 ; +unsigned int n_channels;sdata_assert_lock (sdata);
@@ -597,12 +659,15 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) } } +/* Get the number of supported channels for spectrum management */ + n_channels =ieee80211_get_num_supported_channels (local->hw.wiphy); + skb = alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + /* bit too much but doesn't matter */ 2 + assoc_data->ssid_len + /* SSID */ 4 + rates_len + /* (extended) rates */ 4 + /* power capability */ - 2 + 2 * sband->n_channels + /* supported channels */ + 2 + 2 * n_channels + /* supported channels */ 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ 2 + sizeof(struct ieee80211_vht_cap) + /* VHT */ assoc_data->ie_len + /* extra IEs */
@@ -704,15 +769,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) *pos++ =ieee80211_chandef_max_power (&chanctx_conf->def);/* 2. supported channels */ -/* TODO: get this in reg domain format */ - pos =skb_put (skb,2 * sband->n_channels +2 ); - *pos++ =WLAN_EID_SUPPORTED_CHANNELS ; - *pos++ =2 * sband->n_channels; -for (i =0 ; i < sband->n_channels; i++) { - *pos++ =ieee80211_frequency_to_channel ( - sband->channels[i].center_freq); - *pos++ =1 ;/* one channel in the subband*/ - } +ieee80211_add_supported_channels (local, skb, n_channels); }/* if present, add any custom IEs that go before HT */
Signature · 1 line
1.7.10.4