Skip to content

Commit 74608ac

Browse files
Simon Wunderlichjmberg-intel
authored andcommitted
cfg80211/mac80211: get mandatory rates based on scan width
Mandatory rates for 5 and 10 MHz are different from the rates used for 20 MHz in 2.4 GHz mode, as they use OFDM only. Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
1 parent 2103dec commit 74608ac

4 files changed

Lines changed: 32 additions & 10 deletions

File tree

‎include/net/cfg80211.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3128,11 +3128,13 @@ ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
31283128
/**
31293129
* ieee80211_mandatory_rates - get mandatory rates for a given band
31303130
* @sband: the band to look for rates in
3131+
* @scan_width: width of the control channel
31313132
*
31323133
* This function returns a bitmap of the mandatory rates for the given
31333134
* band, bits are set according to the rate position in the bitrates array.
31343135
*/
3135-
u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband);
3136+
u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband,
3137+
enum nl80211_bss_scan_width scan_width);
31363138

31373139
/*
31383140
* Radiotap parsing functions -- for controlled injection support

‎net/mac80211/ibss.c‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid,
371371
struct sta_info *sta;
372372
struct ieee80211_chanctx_conf *chanctx_conf;
373373
struct ieee80211_supported_band *sband;
374+
enum nl80211_bss_scan_width scan_width;
374375
int band;
375376

376377
/*
@@ -399,6 +400,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid,
399400
if (WARN_ON_ONCE(!chanctx_conf))
400401
return NULL;
401402
band = chanctx_conf->def.chan->band;
403+
scan_width = cfg80211_chandef_to_scan_width(&chanctx_conf->def);
402404
rcu_read_unlock();
403405

404406
sta = sta_info_alloc(sdata, addr, GFP_KERNEL);
@@ -412,7 +414,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid,
412414
/* make sure mandatory rates are always added */
413415
sband = local->hw.wiphy->bands[band];
414416
sta->sta.supp_rates[band] = supp_rates |
415-
ieee80211_mandatory_rates(sband);
417+
ieee80211_mandatory_rates(sband, scan_width);
416418

417419
return ieee80211_ibss_finish_sta(sta);
418420
}
@@ -476,6 +478,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
476478
u64 beacon_timestamp, rx_timestamp;
477479
u32 supp_rates = 0;
478480
enum ieee80211_band band = rx_status->band;
481+
enum nl80211_bss_scan_width scan_width;
479482
struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
480483
bool rates_updated = false;
481484

@@ -504,9 +507,15 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
504507

505508
prev_rates = sta->sta.supp_rates[band];
506509
/* make sure mandatory rates are always added */
507-
sta->sta.supp_rates[band] = supp_rates |
508-
ieee80211_mandatory_rates(sband);
510+
scan_width = NL80211_BSS_CHAN_WIDTH_20;
511+
if (rx_status->flag & RX_FLAG_5MHZ)
512+
scan_width = NL80211_BSS_CHAN_WIDTH_5;
513+
if (rx_status->flag & RX_FLAG_10MHZ)
514+
scan_width = NL80211_BSS_CHAN_WIDTH_10;
509515

516+
sta->sta.supp_rates[band] = supp_rates |
517+
ieee80211_mandatory_rates(sband,
518+
scan_width);
510519
if (sta->sta.supp_rates[band] != prev_rates) {
511520
ibss_dbg(sdata,
512521
"updated supp_rates set for %pM based on beacon/probe_resp (0x%x -> 0x%x)\n",
@@ -640,6 +649,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
640649
struct sta_info *sta;
641650
struct ieee80211_chanctx_conf *chanctx_conf;
642651
struct ieee80211_supported_band *sband;
652+
enum nl80211_bss_scan_width scan_width;
643653
int band;
644654

645655
/*
@@ -665,6 +675,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
665675
return;
666676
}
667677
band = chanctx_conf->def.chan->band;
678+
scan_width = cfg80211_chandef_to_scan_width(&chanctx_conf->def);
668679
rcu_read_unlock();
669680

670681
sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
@@ -676,7 +687,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
676687
/* make sure mandatory rates are always added */
677688
sband = local->hw.wiphy->bands[band];
678689
sta->sta.supp_rates[band] = supp_rates |
679-
ieee80211_mandatory_rates(sband);
690+
ieee80211_mandatory_rates(sband, scan_width);
680691

681692
spin_lock(&ifibss->incomplete_lock);
682693
list_add(&sta->list, &ifibss->incomplete_stations);

‎net/wireless/mesh.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,12 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
167167
* basic rates
168168
*/
169169
if (!setup->basic_rates) {
170+
enum nl80211_bss_scan_width scan_width;
170171
struct ieee80211_supported_band *sband =
171172
rdev->wiphy.bands[setup->chandef.chan->band];
172-
setup->basic_rates = ieee80211_mandatory_rates(sband);
173+
scan_width = cfg80211_chandef_to_scan_width(&setup->chandef);
174+
setup->basic_rates = ieee80211_mandatory_rates(sband,
175+
scan_width);
173176
}
174177

175178
if (!cfg80211_reg_can_beacon(&rdev->wiphy, &setup->chandef))

‎net/wireless/util.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
3333
}
3434
EXPORT_SYMBOL(ieee80211_get_response_rate);
3535

36-
u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband)
36+
u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband,
37+
enum nl80211_bss_scan_width scan_width)
3738
{
3839
struct ieee80211_rate *bitrates;
3940
u32 mandatory_rates = 0;
@@ -43,10 +44,15 @@ u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband)
4344
if (WARN_ON(!sband))
4445
return 1;
4546

46-
if (sband->band == IEEE80211_BAND_2GHZ)
47-
mandatory_flag = IEEE80211_RATE_MANDATORY_B;
48-
else
47+
if (sband->band == IEEE80211_BAND_2GHZ) {
48+
if (scan_width == NL80211_BSS_CHAN_WIDTH_5 ||
49+
scan_width == NL80211_BSS_CHAN_WIDTH_10)
50+
mandatory_flag = IEEE80211_RATE_MANDATORY_G;
51+
else
52+
mandatory_flag = IEEE80211_RATE_MANDATORY_B;
53+
} else {
4954
mandatory_flag = IEEE80211_RATE_MANDATORY_A;
55+
}
5056

5157
bitrates = sband->bitrates;
5258
for (i = 0; i < sband->n_bitrates; i++)

0 commit comments

Comments
 (0)