Merge branch 'master' of git://git.infradead.org/users/linville/wireless
[linux-2.6-block.git] / drivers / net / wireless / ath / ath9k / recv.c
index 9a4850154fb251246d07d6c3ae3935fb889769a7..49843500fe7cd5faafd5f809fcf5515b2e50b4ab 100644 (file)
@@ -205,14 +205,22 @@ static void ath_rx_remove_buffer(struct ath_softc *sc,
 
 static void ath_rx_edma_cleanup(struct ath_softc *sc)
 {
+       struct ath_hw *ah = sc->sc_ah;
+       struct ath_common *common = ath9k_hw_common(ah);
        struct ath_buf *bf;
 
        ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_LP);
        ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_HP);
 
        list_for_each_entry(bf, &sc->rx.rxbuf, list) {
-               if (bf->bf_mpdu)
+               if (bf->bf_mpdu) {
+                       dma_unmap_single(sc->dev, bf->bf_buf_addr,
+                                       common->rx_bufsize,
+                                       DMA_BIDIRECTIONAL);
                        dev_kfree_skb_any(bf->bf_mpdu);
+                       bf->bf_buf_addr = 0;
+                       bf->bf_mpdu = NULL;
+               }
        }
 
        INIT_LIST_HEAD(&sc->rx.rxbuf);
@@ -601,7 +609,6 @@ static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb)
                ath_dbg(common, ATH_DBG_PS,
                        "Reconfigure Beacon timers based on timestamp from the AP\n");
                ath_set_beacon(sc);
-               sc->ps_flags &= ~PS_TSFOOR_SYNC;
        }
 
        if (ath_beacon_dtim_pending_cab(skb)) {
@@ -762,7 +769,7 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
         * on.  All this is necessary because of our use of
         * a self-linked list to avoid rx overruns.
         */
-       ret = ath9k_hw_rxprocdesc(ah, ds, rs, 0);
+       ret = ath9k_hw_rxprocdesc(ah, ds, rs);
        if (ret == -EINPROGRESS) {
                struct ath_rx_status trs;
                struct ath_buf *tbf;
@@ -788,7 +795,7 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
                 */
 
                tds = tbf->bf_desc;
-               ret = ath9k_hw_rxprocdesc(ah, tds, &trs, 0);
+               ret = ath9k_hw_rxprocdesc(ah, tds, &trs);
                if (ret == -EINPROGRESS)
                        return NULL;
        }
@@ -825,7 +832,8 @@ static bool ath9k_rx_accept(struct ath_common *common,
        is_mc = !!is_multicast_ether_addr(hdr->addr1);
        is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
                test_bit(rx_stats->rs_keyix, common->tkip_keymap);
-       strip_mic = is_valid_tkip && !(rx_stats->rs_status &
+       strip_mic = is_valid_tkip && ieee80211_is_data(fc) &&
+               !(rx_stats->rs_status &
                (ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC));
 
        if (!rx_stats->rs_datalen)
@@ -937,7 +945,7 @@ static int ath9k_process_rate(struct ath_common *common,
         * No valid hardware bitrate found -- we should not get here
         * because hardware has already validated this frame as OK.
         */
-       ath_dbg(common, ATH_DBG_XMIT,
+       ath_dbg(common, ATH_DBG_ANY,
                "unsupported hw bitrate detected 0x%02x using 1 Mbit\n",
                rx_stats->rs_rate);
 
@@ -952,23 +960,12 @@ static void ath9k_process_rssi(struct ath_common *common,
        struct ath_softc *sc = hw->priv;
        struct ath_hw *ah = common->ah;
        int last_rssi;
-       __le16 fc;
 
-       if ((ah->opmode != NL80211_IFTYPE_STATION) &&
-           (ah->opmode != NL80211_IFTYPE_ADHOC))
+       if (!rx_stats->is_mybeacon ||
+           ((ah->opmode != NL80211_IFTYPE_STATION) &&
+            (ah->opmode != NL80211_IFTYPE_ADHOC)))
                return;
 
-       fc = hdr->frame_control;
-       if (!ieee80211_is_beacon(fc) ||
-           compare_ether_addr(hdr->addr3, common->curbssid)) {
-               /* TODO:  This doesn't work well if you have stations
-                * associated to two different APs because curbssid
-                * is just the last AP that any of the stations associated
-                * with.
-                */
-               return;
-       }
-
        if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr)
                ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
 
@@ -995,6 +992,8 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common,
                                   struct ieee80211_rx_status *rx_status,
                                   bool *decrypt_error)
 {
+       struct ath_hw *ah = common->ah;
+
        memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
 
        /*
@@ -1015,7 +1014,7 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common,
 
        rx_status->band = hw->conf.channel->band;
        rx_status->freq = hw->conf.channel->center_freq;
-       rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
+       rx_status->signal = ah->noise + rx_stats->rs_rssi;
        rx_status->antenna = rx_stats->rs_antenna;
        rx_status->flag |= RX_FLAG_MACTIME_MPDU;
 
@@ -1783,11 +1782,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
        struct ieee80211_rx_status *rxs;
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
-       /*
-        * The hw can technically differ from common->hw when using ath9k
-        * virtual wiphy so to account for that we iterate over the active
-        * wiphys and find the appropriate wiphy and therefore hw.
-        */
        struct ieee80211_hw *hw = sc->hw;
        struct ieee80211_hdr *hdr;
        int retval;
@@ -1841,6 +1835,11 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
 
                hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len);
                rxs = IEEE80211_SKB_RXCB(hdr_skb);
+               if (ieee80211_is_beacon(hdr->frame_control) &&
+                   !compare_ether_addr(hdr->addr3, common->curbssid))
+                       rs.is_mybeacon = true;
+               else
+                       rs.is_mybeacon = false;
 
                ath_debug_stat_rx(sc, &rs);
 
@@ -1848,7 +1847,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
                 * If we're asked to flush receive queue, directly
                 * chain it back at the queue without processing it.
                 */
-               if (flush)
+               if (sc->sc_flags & SC_OP_RXFLUSH)
                        goto requeue_drop_frag;
 
                retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
@@ -1959,7 +1958,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
                        ath_rx_ps(sc, skb);
                spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
 
-               if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
+               if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx == 3)
                        ath_ant_comb_scan(sc, &rs);
 
                ieee80211_rx(hw, skb);
@@ -1976,11 +1975,17 @@ requeue:
                } else {
                        list_move_tail(&bf->list, &sc->rx.rxbuf);
                        ath_rx_buf_link(sc, bf);
-                       ath9k_hw_rxena(ah);
+                       if (!flush)
+                               ath9k_hw_rxena(ah);
                }
        } while (1);
 
        spin_unlock_bh(&sc->rx.rxbuflock);
 
+       if (!(ah->imask & ATH9K_INT_RXEOL)) {
+               ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
+               ath9k_hw_set_interrupts(ah, ah->imask);
+       }
+
        return 0;
 }