summaryrefslogtreecommitdiffstats
path: root/net/mac80211/rate.c
diff options
context:
space:
mode:
authorSimon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>2013-07-08 10:55:53 -0400
committerJohannes Berg <johannes.berg@intel.com>2013-07-16 02:58:06 -0400
commit2103dec14792be2c2194a454630b01120d30e5cb (patch)
tree6bc0cd39eb2fe5317f0383ed7c4c238fb98ec114 /net/mac80211/rate.c
parenta5e70697d0c4836e69c60de92db27eac9ae71e05 (diff)
mac80211: select and adjust bitrates according to channel mode
The various components accessing the bitrates table must use consider the used channel bandwidth to select only available rates or calculate the bitrate correctly. There are some rates in reduced bandwidth modes which can't be represented as multiples of 500kbps, like 2.25 MBit/s in 5 MHz mode. The standard suggests to round up to the next multiple of 500kbps, just do that in mac80211 as well. Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de> [make rate unsigned in ieee80211_add_tx_radiotap_header(), squash fix] Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Diffstat (limited to 'net/mac80211/rate.c')
-rw-r--r--net/mac80211/rate.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 30d58d2d13e2..ba63ac851c2b 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -232,37 +232,28 @@ static void rc_send_low_broadcast(s8 *idx, u32 basic_rates,
232 /* could not find a basic rate; use original selection */ 232 /* could not find a basic rate; use original selection */
233} 233}
234 234
235static inline s8 235static void __rate_control_send_low(struct ieee80211_hw *hw,
236rate_lowest_non_cck_index(struct ieee80211_supported_band *sband, 236 struct ieee80211_supported_band *sband,
237 struct ieee80211_sta *sta) 237 struct ieee80211_sta *sta,
238 struct ieee80211_tx_info *info)
238{ 239{
239 int i; 240 int i;
241 u32 rate_flags =
242 ieee80211_chandef_rate_flags(&hw->conf.chandef);
240 243
244 if ((sband->band == IEEE80211_BAND_2GHZ) &&
245 (info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
246 rate_flags |= IEEE80211_RATE_ERP_G;
247
248 info->control.rates[0].idx = 0;
241 for (i = 0; i < sband->n_bitrates; i++) { 249 for (i = 0; i < sband->n_bitrates; i++) {
242 struct ieee80211_rate *srate = &sband->bitrates[i]; 250 if (!rate_supported(sta, sband->band, i))
243 if ((srate->bitrate == 10) || (srate->bitrate == 20) ||
244 (srate->bitrate == 55) || (srate->bitrate == 110))
245 continue; 251 continue;
246 252
247 if (rate_supported(sta, sband->band, i)) 253 info->control.rates[0].idx = i;
248 return i; 254 break;
249 } 255 }
250 256 WARN_ON_ONCE(i == sband->n_bitrates);
251 /* No matching rate found */
252 return 0;
253}
254
255static void __rate_control_send_low(struct ieee80211_hw *hw,
256 struct ieee80211_supported_band *sband,
257 struct ieee80211_sta *sta,
258 struct ieee80211_tx_info *info)
259{
260 if ((sband->band != IEEE80211_BAND_2GHZ) ||
261 !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
262 info->control.rates[0].idx = rate_lowest_index(sband, sta);
263 else
264 info->control.rates[0].idx =
265 rate_lowest_non_cck_index(sband, sta);
266 257
267 info->control.rates[0].count = 258 info->control.rates[0].count =
268 (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 259 (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
@@ -585,6 +576,7 @@ static void rate_control_apply_mask(struct ieee80211_sub_if_data *sdata,
585 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]; 576 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
586 bool has_mcs_mask; 577 bool has_mcs_mask;
587 u32 mask; 578 u32 mask;
579 u32 rate_flags;
588 int i; 580 int i;
589 581
590 /* 582 /*
@@ -594,6 +586,12 @@ static void rate_control_apply_mask(struct ieee80211_sub_if_data *sdata,
594 */ 586 */
595 mask = sdata->rc_rateidx_mask[info->band]; 587 mask = sdata->rc_rateidx_mask[info->band];
596 has_mcs_mask = sdata->rc_has_mcs_mask[info->band]; 588 has_mcs_mask = sdata->rc_has_mcs_mask[info->band];
589 rate_flags =
590 ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef);
591 for (i = 0; i < sband->n_bitrates; i++)
592 if ((rate_flags & sband->bitrates[i].flags) != rate_flags)
593 mask &= ~BIT(i);
594
597 if (mask == (1 << sband->n_bitrates) - 1 && !has_mcs_mask) 595 if (mask == (1 << sband->n_bitrates) - 1 && !has_mcs_mask)
598 return; 596 return;
599 597