~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/net/wireless/ath/ath9k/recv.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
               (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP);
35
35
}
36
36
 
37
 
static struct ieee80211_hw * ath_get_virt_hw(struct ath_softc *sc,
38
 
                                             struct ieee80211_hdr *hdr)
39
 
{
40
 
        struct ieee80211_hw *hw = sc->pri_wiphy->hw;
41
 
        int i;
42
 
 
43
 
        spin_lock_bh(&sc->wiphy_lock);
44
 
        for (i = 0; i < sc->num_sec_wiphy; i++) {
45
 
                struct ath_wiphy *aphy = sc->sec_wiphy[i];
46
 
                if (aphy == NULL)
47
 
                        continue;
48
 
                if (compare_ether_addr(hdr->addr1, aphy->hw->wiphy->perm_addr)
49
 
                    == 0) {
50
 
                        hw = aphy->hw;
51
 
                        break;
52
 
                }
53
 
        }
54
 
        spin_unlock_bh(&sc->wiphy_lock);
55
 
        return hw;
56
 
}
57
 
 
58
37
/*
59
38
 * Setup and link descriptors.
60
39
 *
230
209
        int error = 0, i;
231
210
        u32 size;
232
211
 
233
 
 
234
 
        common->rx_bufsize = roundup(IEEE80211_MAX_MPDU_LEN +
235
 
                                     ah->caps.rx_status_len,
236
 
                                     min(common->cachelsz, (u16)64));
237
 
 
238
212
        ath9k_hw_set_rx_bufsize(ah, common->rx_bufsize -
239
213
                                    ah->caps.rx_status_len);
240
214
 
321
295
        sc->sc_flags &= ~SC_OP_RXFLUSH;
322
296
        spin_lock_init(&sc->rx.rxbuflock);
323
297
 
 
298
        common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
 
299
                             sc->sc_ah->caps.rx_status_len;
 
300
 
324
301
        if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
325
302
                return ath_rx_edma_init(sc, nbufs);
326
303
        } else {
327
 
                common->rx_bufsize = roundup(IEEE80211_MAX_MPDU_LEN,
328
 
                                min(common->cachelsz, (u16)64));
329
 
 
330
304
                ath_dbg(common, ATH_DBG_CONFIG, "cachelsz %u rxbufsize %u\n",
331
305
                        common->cachelsz, common->rx_bufsize);
332
306
 
439
413
         * mode interface or when in monitor mode. AP mode does not need this
440
414
         * since it receives all in-BSS frames anyway.
441
415
         */
442
 
        if (((sc->sc_ah->opmode != NL80211_IFTYPE_AP) &&
443
 
             (sc->rx.rxfilter & FIF_PROMISC_IN_BSS)) ||
444
 
            (sc->sc_ah->is_monitoring))
 
416
        if (sc->sc_ah->is_monitoring)
445
417
                rfilt |= ATH9K_RX_FILTER_PROM;
446
418
 
447
419
        if (sc->rx.rxfilter & FIF_CONTROL)
463
435
        if (conf_is_ht(&sc->hw->conf))
464
436
                rfilt |= ATH9K_RX_FILTER_COMP_BAR;
465
437
 
466
 
        if (sc->sec_wiphy || (sc->nvifs > 1) ||
467
 
            (sc->rx.rxfilter & FIF_OTHER_BSS)) {
 
438
        if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
468
439
                /* The following may also be needed for other older chips */
469
440
                if (sc->sc_ah->hw_version.macVersion == AR_SREV_VERSION_9160)
470
441
                        rfilt |= ATH9K_RX_FILTER_PROM;
515
486
bool ath_stoprecv(struct ath_softc *sc)
516
487
{
517
488
        struct ath_hw *ah = sc->sc_ah;
518
 
        bool stopped;
 
489
        bool stopped, reset = false;
519
490
 
520
491
        spin_lock_bh(&sc->rx.rxbuflock);
521
492
        ath9k_hw_abortpcurecv(ah);
522
493
        ath9k_hw_setrxfilter(ah, 0);
523
 
        stopped = ath9k_hw_stopdmarecv(ah);
 
494
        stopped = ath9k_hw_stopdmarecv(ah, &reset);
524
495
 
525
496
        if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
526
497
                ath_edma_stop_recv(sc);
535
506
                        "confusing the DMA engine when we start RX up\n");
536
507
                ATH_DBG_WARN_ON_ONCE(!stopped);
537
508
        }
538
 
        return stopped;
 
509
        return stopped && !reset;
539
510
}
540
511
 
541
512
void ath_flushrecv(struct ath_softc *sc)
588
559
                return;
589
560
 
590
561
        mgmt = (struct ieee80211_mgmt *)skb->data;
591
 
        if (memcmp(common->curbssid, mgmt->bssid, ETH_ALEN) != 0)
 
562
        if (memcmp(common->curbssid, mgmt->bssid, ETH_ALEN) != 0) {
 
563
                /* TODO:  This doesn't work well if you have stations
 
564
                 * associated to two different APs because curbssid
 
565
                 * is just the last AP that any of the stations associated
 
566
                 * with.
 
567
                 */
592
568
                return; /* not from our current AP */
 
569
        }
593
570
 
594
571
        sc->ps_flags &= ~PS_WAIT_FOR_BEACON;
595
572
 
662
639
        }
663
640
}
664
641
 
665
 
static void ath_rx_send_to_mac80211(struct ieee80211_hw *hw,
666
 
                                    struct ath_softc *sc, struct sk_buff *skb)
667
 
{
668
 
        struct ieee80211_hdr *hdr;
669
 
 
670
 
        hdr = (struct ieee80211_hdr *)skb->data;
671
 
 
672
 
        /* Send the frame to mac80211 */
673
 
        if (is_multicast_ether_addr(hdr->addr1)) {
674
 
                int i;
675
 
                /*
676
 
                 * Deliver broadcast/multicast frames to all suitable
677
 
                 * virtual wiphys.
678
 
                 */
679
 
                /* TODO: filter based on channel configuration */
680
 
                for (i = 0; i < sc->num_sec_wiphy; i++) {
681
 
                        struct ath_wiphy *aphy = sc->sec_wiphy[i];
682
 
                        struct sk_buff *nskb;
683
 
                        if (aphy == NULL)
684
 
                                continue;
685
 
                        nskb = skb_copy(skb, GFP_ATOMIC);
686
 
                        if (!nskb)
687
 
                                continue;
688
 
                        ieee80211_rx(aphy->hw, nskb);
689
 
                }
690
 
                ieee80211_rx(sc->hw, skb);
691
 
        } else
692
 
                /* Deliver unicast frames based on receiver address */
693
 
                ieee80211_rx(hw, skb);
694
 
}
695
 
 
696
642
static bool ath_edma_get_buffers(struct ath_softc *sc,
697
643
                                 enum ath9k_rx_qtype qtype)
698
644
{
862
808
        if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len))
863
809
                return false;
864
810
 
865
 
        /*
866
 
         * rs_more indicates chained descriptors which can be used
867
 
         * to link buffers together for a sort of scatter-gather
868
 
         * operation.
869
 
         * reject the frame, we don't support scatter-gather yet and
870
 
         * the frame is probably corrupt anyway
871
 
         */
 
811
        /* Only use error bits from the last fragment */
872
812
        if (rx_stats->rs_more)
873
 
                return false;
 
813
                return true;
874
814
 
875
815
        /*
876
816
         * The rx_stats->rs_status will not be set until the end of the
974
914
                               struct ieee80211_hdr *hdr,
975
915
                               struct ath_rx_status *rx_stats)
976
916
{
977
 
        struct ath_wiphy *aphy = hw->priv;
 
917
        struct ath_softc *sc = hw->priv;
978
918
        struct ath_hw *ah = common->ah;
979
919
        int last_rssi;
980
920
        __le16 fc;
984
924
 
985
925
        fc = hdr->frame_control;
986
926
        if (!ieee80211_is_beacon(fc) ||
987
 
            compare_ether_addr(hdr->addr3, common->curbssid))
 
927
            compare_ether_addr(hdr->addr3, common->curbssid)) {
 
928
                /* TODO:  This doesn't work well if you have stations
 
929
                 * associated to two different APs because curbssid
 
930
                 * is just the last AP that any of the stations associated
 
931
                 * with.
 
932
                 */
988
933
                return;
 
934
        }
989
935
 
990
936
        if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr)
991
 
                ATH_RSSI_LPF(aphy->last_rssi, rx_stats->rs_rssi);
 
937
                ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
992
938
 
993
 
        last_rssi = aphy->last_rssi;
 
939
        last_rssi = sc->last_rssi;
994
940
        if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
995
941
                rx_stats->rs_rssi = ATH_EP_RND(last_rssi,
996
942
                                              ATH_RSSI_EP_MULTIPLIER);
1022
968
        if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error))
1023
969
                return -EINVAL;
1024
970
 
 
971
        /* Only use status info from the last fragment */
 
972
        if (rx_stats->rs_more)
 
973
                return 0;
 
974
 
1025
975
        ath9k_process_rssi(common, hw, hdr, rx_stats);
1026
976
 
1027
977
        if (ath9k_process_rate(common, hw, rx_stats, rx_status))
1031
981
        rx_status->freq = hw->conf.channel->center_freq;
1032
982
        rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
1033
983
        rx_status->antenna = rx_stats->rs_antenna;
1034
 
        rx_status->flag |= RX_FLAG_TSFT;
 
984
        rx_status->flag |= RX_FLAG_MACTIME_MPDU;
1035
985
 
1036
986
        return 0;
1037
987
}
1623
1573
int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1624
1574
{
1625
1575
        struct ath_buf *bf;
1626
 
        struct sk_buff *skb = NULL, *requeue_skb;
 
1576
        struct sk_buff *skb = NULL, *requeue_skb, *hdr_skb;
1627
1577
        struct ieee80211_rx_status *rxs;
1628
1578
        struct ath_hw *ah = sc->sc_ah;
1629
1579
        struct ath_common *common = ath9k_hw_common(ah);
1632
1582
         * virtual wiphy so to account for that we iterate over the active
1633
1583
         * wiphys and find the appropriate wiphy and therefore hw.
1634
1584
         */
1635
 
        struct ieee80211_hw *hw = NULL;
 
1585
        struct ieee80211_hw *hw = sc->hw;
1636
1586
        struct ieee80211_hdr *hdr;
1637
1587
        int retval;
1638
1588
        bool decrypt_error = false;
1674
1624
                if (!skb)
1675
1625
                        continue;
1676
1626
 
1677
 
                hdr = (struct ieee80211_hdr *) (skb->data + rx_status_len);
1678
 
                rxs =  IEEE80211_SKB_RXCB(skb);
 
1627
                /*
 
1628
                 * Take frame header from the first fragment and RX status from
 
1629
                 * the last one.
 
1630
                 */
 
1631
                if (sc->rx.frag)
 
1632
                        hdr_skb = sc->rx.frag;
 
1633
                else
 
1634
                        hdr_skb = skb;
1679
1635
 
1680
 
                hw = ath_get_virt_hw(sc, hdr);
 
1636
                hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len);
 
1637
                rxs = IEEE80211_SKB_RXCB(hdr_skb);
1681
1638
 
1682
1639
                ath_debug_stat_rx(sc, &rs);
1683
1640
 
1686
1643
                 * chain it back at the queue without processing it.
1687
1644
                 */
1688
1645
                if (flush)
1689
 
                        goto requeue;
 
1646
                        goto requeue_drop_frag;
1690
1647
 
1691
1648
                retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
1692
1649
                                                 rxs, &decrypt_error);
1693
1650
                if (retval)
1694
 
                        goto requeue;
 
1651
                        goto requeue_drop_frag;
1695
1652
 
1696
1653
                rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
1697
1654
                if (rs.rs_tstamp > tsf_lower &&
1711
1668
                 * skb and put it at the tail of the sc->rx.rxbuf list for
1712
1669
                 * processing. */
1713
1670
                if (!requeue_skb)
1714
 
                        goto requeue;
 
1671
                        goto requeue_drop_frag;
1715
1672
 
1716
1673
                /* Unmap the frame */
1717
1674
                dma_unmap_single(sc->dev, bf->bf_buf_addr,
1722
1679
                if (ah->caps.rx_status_len)
1723
1680
                        skb_pull(skb, ah->caps.rx_status_len);
1724
1681
 
1725
 
                ath9k_rx_skb_postprocess(common, skb, &rs,
1726
 
                                         rxs, decrypt_error);
 
1682
                if (!rs.rs_more)
 
1683
                        ath9k_rx_skb_postprocess(common, hdr_skb, &rs,
 
1684
                                                 rxs, decrypt_error);
1727
1685
 
1728
1686
                /* We will now give hardware our shiny new allocated skb */
1729
1687
                bf->bf_mpdu = requeue_skb;
1736
1694
                        bf->bf_mpdu = NULL;
1737
1695
                        bf->bf_buf_addr = 0;
1738
1696
                        ath_err(common, "dma_mapping_error() on RX\n");
1739
 
                        ath_rx_send_to_mac80211(hw, sc, skb);
 
1697
                        ieee80211_rx(hw, skb);
1740
1698
                        break;
1741
1699
                }
1742
1700
 
 
1701
                if (rs.rs_more) {
 
1702
                        /*
 
1703
                         * rs_more indicates chained descriptors which can be
 
1704
                         * used to link buffers together for a sort of
 
1705
                         * scatter-gather operation.
 
1706
                         */
 
1707
                        if (sc->rx.frag) {
 
1708
                                /* too many fragments - cannot handle frame */
 
1709
                                dev_kfree_skb_any(sc->rx.frag);
 
1710
                                dev_kfree_skb_any(skb);
 
1711
                                skb = NULL;
 
1712
                        }
 
1713
                        sc->rx.frag = skb;
 
1714
                        goto requeue;
 
1715
                }
 
1716
 
 
1717
                if (sc->rx.frag) {
 
1718
                        int space = skb->len - skb_tailroom(hdr_skb);
 
1719
 
 
1720
                        sc->rx.frag = NULL;
 
1721
 
 
1722
                        if (pskb_expand_head(hdr_skb, 0, space, GFP_ATOMIC) < 0) {
 
1723
                                dev_kfree_skb(skb);
 
1724
                                goto requeue_drop_frag;
 
1725
                        }
 
1726
 
 
1727
                        skb_copy_from_linear_data(skb, skb_put(hdr_skb, skb->len),
 
1728
                                                  skb->len);
 
1729
                        dev_kfree_skb_any(skb);
 
1730
                        skb = hdr_skb;
 
1731
                }
 
1732
 
1743
1733
                /*
1744
1734
                 * change the default rx antenna if rx diversity chooses the
1745
1735
                 * other antenna 3 times in a row.
1763
1753
                if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
1764
1754
                        ath_ant_comb_scan(sc, &rs);
1765
1755
 
1766
 
                ath_rx_send_to_mac80211(hw, sc, skb);
 
1756
                ieee80211_rx(hw, skb);
1767
1757
 
 
1758
requeue_drop_frag:
 
1759
                if (sc->rx.frag) {
 
1760
                        dev_kfree_skb_any(sc->rx.frag);
 
1761
                        sc->rx.frag = NULL;
 
1762
                }
1768
1763
requeue:
1769
1764
                if (edma) {
1770
1765
                        list_add_tail(&bf->list, &sc->rx.rxbuf);