aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/tx.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/tx.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/tx.c')
-rw-r--r--net/mac80211/tx.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 3523daa0b15c..f82301b6cef2 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -40,12 +40,22 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx,
40 struct sk_buff *skb, int group_addr, 40 struct sk_buff *skb, int group_addr,
41 int next_frag_len) 41 int next_frag_len)
42{ 42{
43 int rate, mrate, erp, dur, i, shift; 43 int rate, mrate, erp, dur, i, shift = 0;
44 struct ieee80211_rate *txrate; 44 struct ieee80211_rate *txrate;
45 struct ieee80211_local *local = tx->local; 45 struct ieee80211_local *local = tx->local;
46 struct ieee80211_supported_band *sband; 46 struct ieee80211_supported_band *sband;
47 struct ieee80211_hdr *hdr; 47 struct ieee80211_hdr *hdr;
48 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 48 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
49 struct ieee80211_chanctx_conf *chanctx_conf;
50 u32 rate_flags = 0;
51
52 rcu_read_lock();
53 chanctx_conf = rcu_dereference(tx->sdata->vif.chanctx_conf);
54 if (chanctx_conf) {
55 shift = ieee80211_chandef_get_shift(&chanctx_conf->def);
56 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def);
57 }
58 rcu_read_unlock();
49 59
50 /* assume HW handles this */ 60 /* assume HW handles this */
51 if (tx->rate.flags & IEEE80211_TX_RC_MCS) 61 if (tx->rate.flags & IEEE80211_TX_RC_MCS)
@@ -122,8 +132,11 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx,
122 if (r->bitrate > txrate->bitrate) 132 if (r->bitrate > txrate->bitrate)
123 break; 133 break;
124 134
135 if ((rate_flags & r->flags) != rate_flags)
136 continue;
137
125 if (tx->sdata->vif.bss_conf.basic_rates & BIT(i)) 138 if (tx->sdata->vif.bss_conf.basic_rates & BIT(i))
126 rate = r->bitrate; 139 rate = DIV_ROUND_UP(r->bitrate, 1 << shift);
127 140
128 switch (sband->band) { 141 switch (sband->band) {
129 case IEEE80211_BAND_2GHZ: { 142 case IEEE80211_BAND_2GHZ: {
@@ -150,11 +163,9 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx,
150 if (rate == -1) { 163 if (rate == -1) {
151 /* No matching basic rate found; use highest suitable mandatory 164 /* No matching basic rate found; use highest suitable mandatory
152 * PHY rate */ 165 * PHY rate */
153 rate = mrate; 166 rate = DIV_ROUND_UP(mrate, 1 << shift);
154 } 167 }
155 168
156 shift = ieee80211_vif_get_shift(&tx->sdata->vif);
157
158 /* Don't calculate ACKs for QoS Frames with NoAck Policy set */ 169 /* Don't calculate ACKs for QoS Frames with NoAck Policy set */
159 if (ieee80211_is_data_qos(hdr->frame_control) && 170 if (ieee80211_is_data_qos(hdr->frame_control) &&
160 *(ieee80211_get_qos_ctl(hdr)) & IEEE80211_QOS_CTL_ACK_POLICY_NOACK) 171 *(ieee80211_get_qos_ctl(hdr)) & IEEE80211_QOS_CTL_ACK_POLICY_NOACK)