aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-11-03 21:10:30 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-11-11 17:09:06 -0500
commit9878841e1360266fa4522fbdc2448fcdce95e0dd (patch)
tree7b8064daf47c1fbc453ae80a0c8f253715210055 /drivers
parent14077f5b7a28bdcd166faed2c0b36fad9f3eadda (diff)
ath9k: move rate descriptor reading into a helper
ath9k_process_rate() now does all the rx status processing to read the rate the hardware passed and translate it to whatever mac80211 wants. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c72
1 files changed, 43 insertions, 29 deletions
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 9e6dded399fd..9eae9467c275 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -148,6 +148,47 @@ static bool ath9k_rx_accept(struct ath_common *common,
148 return true; 148 return true;
149} 149}
150 150
151static u8 ath9k_process_rate(struct ath_common *common,
152 struct ieee80211_hw *hw,
153 struct ath_rx_status *rx_stats,
154 struct ieee80211_rx_status *rxs,
155 struct sk_buff *skb)
156{
157 struct ieee80211_supported_band *sband;
158 enum ieee80211_band band;
159 unsigned int i = 0;
160
161 band = hw->conf.channel->band;
162 sband = hw->wiphy->bands[band];
163
164 if (rx_stats->rs_rate & 0x80) {
165 /* HT rate */
166 rxs->flag |= RX_FLAG_HT;
167 if (rx_stats->rs_flags & ATH9K_RX_2040)
168 rxs->flag |= RX_FLAG_40MHZ;
169 if (rx_stats->rs_flags & ATH9K_RX_GI)
170 rxs->flag |= RX_FLAG_SHORT_GI;
171 return rx_stats->rs_rate & 0x7f;
172 }
173
174 for (i = 0; i < sband->n_bitrates; i++) {
175 if (sband->bitrates[i].hw_value == rx_stats->rs_rate)
176 return i;
177 if (sband->bitrates[i].hw_value_short == rx_stats->rs_rate) {
178 rxs->flag |= RX_FLAG_SHORTPRE;
179 return i;
180 }
181 }
182
183 /* No valid hardware bitrate found -- we should not get here */
184 ath_print(common, ATH_DBG_XMIT, "unsupported hw bitrate detected "
185 "0x%02x using 1 Mbit\n", rx_stats->rs_rate);
186 if ((common->debug_mask & ATH_DBG_XMIT))
187 print_hex_dump_bytes("", DUMP_PREFIX_NONE, skb->data, skb->len);
188
189 return 0;
190}
191
151/* 192/*
152 * For Decrypt or Demic errors, we only mark packet status here and always push 193 * For Decrypt or Demic errors, we only mark packet status here and always push
153 * up the frame up to let mac80211 handle the actual error case, be it no 194 * up the frame up to let mac80211 handle the actual error case, be it no
@@ -173,35 +214,6 @@ static int ath_rx_prepare(struct ath_common *common,
173 if (!ath9k_rx_accept(common, skb, rx_status, rx_stats, decrypt_error)) 214 if (!ath9k_rx_accept(common, skb, rx_status, rx_stats, decrypt_error))
174 goto rx_next; 215 goto rx_next;
175 216
176 if (rx_stats->rs_rate & 0x80) {
177 /* HT rate */
178 rx_status->flag |= RX_FLAG_HT;
179 if (rx_stats->rs_flags & ATH9K_RX_2040)
180 rx_status->flag |= RX_FLAG_40MHZ;
181 if (rx_stats->rs_flags & ATH9K_RX_GI)
182 rx_status->flag |= RX_FLAG_SHORT_GI;
183 rx_status->rate_idx = rx_stats->rs_rate & 0x7f;
184 } else {
185 struct ieee80211_supported_band *sband;
186 unsigned int i = 0;
187 enum ieee80211_band band;
188
189 band = hw->conf.channel->band;
190 sband = hw->wiphy->bands[band];
191
192 for (i = 0; i < sband->n_bitrates; i++) {
193 if (sband->bitrates[i].hw_value == rx_stats->rs_rate) {
194 rx_status->rate_idx = i;
195 break;
196 }
197 if (sband->bitrates[i].hw_value_short ==
198 rx_stats->rs_rate) {
199 rx_status->rate_idx = i;
200 rx_status->flag |= RX_FLAG_SHORTPRE;
201 break;
202 }
203 }
204 }
205 217
206 rcu_read_lock(); 218 rcu_read_lock();
207 /* XXX: use ieee80211_find_sta! */ 219 /* XXX: use ieee80211_find_sta! */
@@ -227,6 +239,8 @@ static int ath_rx_prepare(struct ath_common *common,
227 if (ieee80211_is_beacon(fc)) 239 if (ieee80211_is_beacon(fc))
228 ah->stats.avgbrssi = rx_stats->rs_rssi; 240 ah->stats.avgbrssi = rx_stats->rs_rssi;
229 241
242 rx_status->rate_idx = ath9k_process_rate(common, hw,
243 rx_stats, rx_status, skb);
230 rx_status->mactime = ath9k_hw_extend_tsf(ah, rx_stats->rs_tstamp); 244 rx_status->mactime = ath9k_hw_extend_tsf(ah, rx_stats->rs_tstamp);
231 rx_status->band = hw->conf.channel->band; 245 rx_status->band = hw->conf.channel->band;
232 rx_status->freq = hw->conf.channel->center_freq; 246 rx_status->freq = hw->conf.channel->center_freq;