]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ath9k: move rate descriptor reading into a helper
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Wed, 4 Nov 2009 02:10:30 +0000 (18:10 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 11 Nov 2009 22:09:06 +0000 (17:09 -0500)
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>
drivers/net/wireless/ath/ath9k/recv.c

index 9e6dded399fdb8a649dfb672af9ddcc17cbb69fe..9eae9467c2751af994ff2f212319be25e5cee0f6 100644 (file)
@@ -148,6 +148,47 @@ static bool ath9k_rx_accept(struct ath_common *common,
        return true;
 }
 
+static u8 ath9k_process_rate(struct ath_common *common,
+                            struct ieee80211_hw *hw,
+                            struct ath_rx_status *rx_stats,
+                            struct ieee80211_rx_status *rxs,
+                            struct sk_buff *skb)
+{
+       struct ieee80211_supported_band *sband;
+       enum ieee80211_band band;
+       unsigned int i = 0;
+
+       band = hw->conf.channel->band;
+       sband = hw->wiphy->bands[band];
+
+       if (rx_stats->rs_rate & 0x80) {
+               /* HT rate */
+               rxs->flag |= RX_FLAG_HT;
+               if (rx_stats->rs_flags & ATH9K_RX_2040)
+                       rxs->flag |= RX_FLAG_40MHZ;
+               if (rx_stats->rs_flags & ATH9K_RX_GI)
+                       rxs->flag |= RX_FLAG_SHORT_GI;
+               return rx_stats->rs_rate & 0x7f;
+       }
+
+       for (i = 0; i < sband->n_bitrates; i++) {
+               if (sband->bitrates[i].hw_value == rx_stats->rs_rate)
+                       return i;
+               if (sband->bitrates[i].hw_value_short == rx_stats->rs_rate) {
+                       rxs->flag |= RX_FLAG_SHORTPRE;
+                       return i;
+               }
+       }
+
+       /* No valid hardware bitrate found -- we should not get here */
+       ath_print(common, ATH_DBG_XMIT, "unsupported hw bitrate detected "
+                 "0x%02x using 1 Mbit\n", rx_stats->rs_rate);
+       if ((common->debug_mask & ATH_DBG_XMIT))
+               print_hex_dump_bytes("", DUMP_PREFIX_NONE, skb->data, skb->len);
+
+        return 0;
+}
+
 /*
  * For Decrypt or Demic errors, we only mark packet status here and always push
  * 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,
        if (!ath9k_rx_accept(common, skb, rx_status, rx_stats, decrypt_error))
                goto rx_next;
 
-       if (rx_stats->rs_rate & 0x80) {
-               /* HT rate */
-               rx_status->flag |= RX_FLAG_HT;
-               if (rx_stats->rs_flags & ATH9K_RX_2040)
-                       rx_status->flag |= RX_FLAG_40MHZ;
-               if (rx_stats->rs_flags & ATH9K_RX_GI)
-                       rx_status->flag |= RX_FLAG_SHORT_GI;
-               rx_status->rate_idx = rx_stats->rs_rate & 0x7f;
-       } else {
-               struct ieee80211_supported_band *sband;
-               unsigned int i = 0;
-               enum ieee80211_band band;
-
-               band = hw->conf.channel->band;
-               sband = hw->wiphy->bands[band];
-
-               for (i = 0; i < sband->n_bitrates; i++) {
-                       if (sband->bitrates[i].hw_value == rx_stats->rs_rate) {
-                               rx_status->rate_idx = i;
-                               break;
-                       }
-                       if (sband->bitrates[i].hw_value_short ==
-                           rx_stats->rs_rate) {
-                               rx_status->rate_idx = i;
-                               rx_status->flag |= RX_FLAG_SHORTPRE;
-                               break;
-                       }
-               }
-       }
 
        rcu_read_lock();
        /* XXX: use ieee80211_find_sta! */
@@ -227,6 +239,8 @@ static int ath_rx_prepare(struct ath_common *common,
        if (ieee80211_is_beacon(fc))
                ah->stats.avgbrssi = rx_stats->rs_rssi;
 
+       rx_status->rate_idx = ath9k_process_rate(common, hw,
+                                                rx_stats, rx_status, skb);
        rx_status->mactime = ath9k_hw_extend_tsf(ah, rx_stats->rs_tstamp);
        rx_status->band = hw->conf.channel->band;
        rx_status->freq = hw->conf.channel->center_freq;