~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
15
 */
16
16
 
 
17
#include <linux/dma-mapping.h>
17
18
#include "ath9k.h"
18
19
#include "ar9003_mac.h"
19
20
 
39
40
                        result = true;
40
41
                break;
41
42
        case 1:
 
43
        case 2:
42
44
                if ((((curr_main_set == ATH_ANT_DIV_COMB_LNA2) &&
43
45
                        (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) &&
44
46
                                (alt_rssi_avg >= (main_rssi_avg - 5))) ||
203
205
 
204
206
static void ath_rx_edma_cleanup(struct ath_softc *sc)
205
207
{
 
208
        struct ath_hw *ah = sc->sc_ah;
 
209
        struct ath_common *common = ath9k_hw_common(ah);
206
210
        struct ath_buf *bf;
207
211
 
208
212
        ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_LP);
209
213
        ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_HP);
210
214
 
211
215
        list_for_each_entry(bf, &sc->rx.rxbuf, list) {
212
 
                if (bf->bf_mpdu)
 
216
                if (bf->bf_mpdu) {
 
217
                        dma_unmap_single(sc->dev, bf->bf_buf_addr,
 
218
                                        common->rx_bufsize,
 
219
                                        DMA_BIDIRECTIONAL);
213
220
                        dev_kfree_skb_any(bf->bf_mpdu);
 
221
                        bf->bf_buf_addr = 0;
 
222
                        bf->bf_mpdu = NULL;
 
223
                }
214
224
        }
215
225
 
216
226
        INIT_LIST_HEAD(&sc->rx.rxbuf);
573
583
 
574
584
static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb)
575
585
{
576
 
        struct ieee80211_mgmt *mgmt;
577
586
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
578
587
 
579
588
        if (skb->len < 24 + 8 + 2 + 2)
580
589
                return;
581
590
 
582
 
        mgmt = (struct ieee80211_mgmt *)skb->data;
583
 
        if (memcmp(common->curbssid, mgmt->bssid, ETH_ALEN) != 0) {
584
 
                /* TODO:  This doesn't work well if you have stations
585
 
                 * associated to two different APs because curbssid
586
 
                 * is just the last AP that any of the stations associated
587
 
                 * with.
588
 
                 */
589
 
                return; /* not from our current AP */
590
 
        }
591
 
 
592
591
        sc->ps_flags &= ~PS_WAIT_FOR_BEACON;
593
592
 
594
593
        if (sc->ps_flags & PS_BEACON_SYNC) {
596
595
                ath_dbg(common, ATH_DBG_PS,
597
596
                        "Reconfigure Beacon timers based on timestamp from the AP\n");
598
597
                ath_set_beacon(sc);
599
 
                sc->ps_flags &= ~PS_TSFOOR_SYNC;
600
598
        }
601
599
 
602
600
        if (ath_beacon_dtim_pending_cab(skb)) {
625
623
        }
626
624
}
627
625
 
628
 
static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb)
 
626
static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb, bool mybeacon)
629
627
{
630
628
        struct ieee80211_hdr *hdr;
631
629
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
634
632
 
635
633
        /* Process Beacon and CAB receive in PS state */
636
634
        if (((sc->ps_flags & PS_WAIT_FOR_BEACON) || ath9k_check_auto_sleep(sc))
637
 
            && ieee80211_is_beacon(hdr->frame_control))
 
635
            && mybeacon)
638
636
                ath_rx_ps_beacon(sc, skb);
639
637
        else if ((sc->ps_flags & PS_WAIT_FOR_CAB) &&
640
638
                 (ieee80211_is_data(hdr->frame_control) ||
757
755
         * on.  All this is necessary because of our use of
758
756
         * a self-linked list to avoid rx overruns.
759
757
         */
760
 
        ret = ath9k_hw_rxprocdesc(ah, ds, rs, 0);
 
758
        ret = ath9k_hw_rxprocdesc(ah, ds, rs);
761
759
        if (ret == -EINPROGRESS) {
762
760
                struct ath_rx_status trs;
763
761
                struct ath_buf *tbf;
783
781
                 */
784
782
 
785
783
                tds = tbf->bf_desc;
786
 
                ret = ath9k_hw_rxprocdesc(ah, tds, &trs, 0);
 
784
                ret = ath9k_hw_rxprocdesc(ah, tds, &trs);
787
785
                if (ret == -EINPROGRESS)
788
786
                        return NULL;
789
787
        }
810
808
                            struct ath_rx_status *rx_stats,
811
809
                            bool *decrypt_error)
812
810
{
813
 
#define is_mc_or_valid_tkip_keyix ((is_mc ||                    \
814
 
                (rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID && \
815
 
                test_bit(rx_stats->rs_keyix, common->tkip_keymap))))
816
 
 
 
811
        struct ath_softc *sc = (struct ath_softc *) common->priv;
 
812
        bool is_mc, is_valid_tkip, strip_mic, mic_error;
817
813
        struct ath_hw *ah = common->ah;
818
814
        __le16 fc;
819
815
        u8 rx_status_len = ah->caps.rx_status_len;
820
816
 
821
817
        fc = hdr->frame_control;
822
818
 
 
819
        is_mc = !!is_multicast_ether_addr(hdr->addr1);
 
820
        is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
 
821
                test_bit(rx_stats->rs_keyix, common->tkip_keymap);
 
822
        strip_mic = is_valid_tkip && ieee80211_is_data(fc) &&
 
823
                !(rx_stats->rs_status &
 
824
                (ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC |
 
825
                 ATH9K_RXERR_KEYMISS));
 
826
 
823
827
        if (!rx_stats->rs_datalen)
824
828
                return false;
825
829
        /*
834
838
        if (rx_stats->rs_more)
835
839
                return true;
836
840
 
 
841
        mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
 
842
                !ieee80211_has_morefrags(fc) &&
 
843
                !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
 
844
                (rx_stats->rs_status & ATH9K_RXERR_MIC);
 
845
 
837
846
        /*
838
847
         * The rx_stats->rs_status will not be set until the end of the
839
848
         * chained descriptors so it can be ignored if rs_more is set. The
841
850
         * descriptors.
842
851
         */
843
852
        if (rx_stats->rs_status != 0) {
844
 
                if (rx_stats->rs_status & ATH9K_RXERR_CRC)
 
853
                u8 status_mask;
 
854
 
 
855
                if (rx_stats->rs_status & ATH9K_RXERR_CRC) {
845
856
                        rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
 
857
                        mic_error = false;
 
858
                }
846
859
                if (rx_stats->rs_status & ATH9K_RXERR_PHY)
847
860
                        return false;
848
861
 
849
 
                if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
 
862
                if ((rx_stats->rs_status & ATH9K_RXERR_DECRYPT) ||
 
863
                    (!is_mc && (rx_stats->rs_status & ATH9K_RXERR_KEYMISS))) {
850
864
                        *decrypt_error = true;
851
 
                } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
852
 
                        bool is_mc;
853
 
                        /*
854
 
                         * The MIC error bit is only valid if the frame
855
 
                         * is not a control frame or fragment, and it was
856
 
                         * decrypted using a valid TKIP key.
857
 
                         */
858
 
                        is_mc = !!is_multicast_ether_addr(hdr->addr1);
 
865
                        mic_error = false;
 
866
                }
859
867
 
860
 
                        if (!ieee80211_is_ctl(fc) &&
861
 
                            !ieee80211_has_morefrags(fc) &&
862
 
                            !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
863
 
                            is_mc_or_valid_tkip_keyix)
864
 
                                rxs->flag |= RX_FLAG_MMIC_ERROR;
865
 
                        else
866
 
                                rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
867
 
                }
868
868
                /*
869
869
                 * Reject error frames with the exception of
870
870
                 * decryption and MIC failures. For monitor mode,
871
871
                 * we also ignore the CRC error.
872
872
                 */
873
 
                if (ah->is_monitoring) {
874
 
                        if (rx_stats->rs_status &
875
 
                            ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
876
 
                              ATH9K_RXERR_CRC))
877
 
                                return false;
878
 
                } else {
879
 
                        if (rx_stats->rs_status &
880
 
                            ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
881
 
                                return false;
882
 
                        }
883
 
                }
 
873
                status_mask = ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
 
874
                              ATH9K_RXERR_KEYMISS;
 
875
 
 
876
                if (ah->is_monitoring && (sc->rx.rxfilter & FIF_FCSFAIL))
 
877
                        status_mask |= ATH9K_RXERR_CRC;
 
878
 
 
879
                if (rx_stats->rs_status & ~status_mask)
 
880
                        return false;
884
881
        }
 
882
 
 
883
        /*
 
884
         * For unicast frames the MIC error bit can have false positives,
 
885
         * so all MIC error reports need to be validated in software.
 
886
         * False negatives are not common, so skip software verification
 
887
         * if the hardware considers the MIC valid.
 
888
         */
 
889
        if (strip_mic)
 
890
                rxs->flag |= RX_FLAG_MMIC_STRIPPED;
 
891
        else if (is_mc && mic_error)
 
892
                rxs->flag |= RX_FLAG_MMIC_ERROR;
 
893
 
885
894
        return true;
886
895
}
887
896
 
924
933
         * No valid hardware bitrate found -- we should not get here
925
934
         * because hardware has already validated this frame as OK.
926
935
         */
927
 
        ath_dbg(common, ATH_DBG_XMIT,
 
936
        ath_dbg(common, ATH_DBG_ANY,
928
937
                "unsupported hw bitrate detected 0x%02x using 1 Mbit\n",
929
938
                rx_stats->rs_rate);
930
939
 
939
948
        struct ath_softc *sc = hw->priv;
940
949
        struct ath_hw *ah = common->ah;
941
950
        int last_rssi;
942
 
        __le16 fc;
943
 
 
944
 
        if ((ah->opmode != NL80211_IFTYPE_STATION) &&
945
 
            (ah->opmode != NL80211_IFTYPE_ADHOC))
946
 
                return;
947
 
 
948
 
        fc = hdr->frame_control;
949
 
        if (!ieee80211_is_beacon(fc) ||
950
 
            compare_ether_addr(hdr->addr3, common->curbssid)) {
951
 
                /* TODO:  This doesn't work well if you have stations
952
 
                 * associated to two different APs because curbssid
953
 
                 * is just the last AP that any of the stations associated
954
 
                 * with.
955
 
                 */
956
 
                return;
957
 
        }
 
951
 
 
952
        if (!rx_stats->is_mybeacon ||
 
953
            ((ah->opmode != NL80211_IFTYPE_STATION) &&
 
954
             (ah->opmode != NL80211_IFTYPE_ADHOC)))
 
955
                return;
958
956
 
959
957
        if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr)
960
958
                ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
982
980
                                   struct ieee80211_rx_status *rx_status,
983
981
                                   bool *decrypt_error)
984
982
{
 
983
        struct ath_hw *ah = common->ah;
 
984
 
985
985
        memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
986
986
 
987
987
        /*
1002
1002
 
1003
1003
        rx_status->band = hw->conf.channel->band;
1004
1004
        rx_status->freq = hw->conf.channel->center_freq;
1005
 
        rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
 
1005
        rx_status->signal = ah->noise + rx_stats->rs_rssi;
1006
1006
        rx_status->antenna = rx_stats->rs_antenna;
1007
1007
        rx_status->flag |= RX_FLAG_MACTIME_MPDU;
1008
1008
 
1072
1072
                antcomb->rssi_lna1 = main_rssi_avg;
1073
1073
 
1074
1074
        switch ((ant_conf.main_lna_conf << 4) | ant_conf.alt_lna_conf) {
1075
 
        case (0x10): /* LNA2 A-B */
 
1075
        case 0x10: /* LNA2 A-B */
1076
1076
                antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
1077
1077
                antcomb->first_quick_scan_conf =
1078
1078
                        ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
1079
1079
                antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1;
1080
1080
                break;
1081
 
        case (0x20): /* LNA1 A-B */
 
1081
        case 0x20: /* LNA1 A-B */
1082
1082
                antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
1083
1083
                antcomb->first_quick_scan_conf =
1084
1084
                        ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
1085
1085
                antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA2;
1086
1086
                break;
1087
 
        case (0x21): /* LNA1 LNA2 */
 
1087
        case 0x21: /* LNA1 LNA2 */
1088
1088
                antcomb->main_conf = ATH_ANT_DIV_COMB_LNA2;
1089
1089
                antcomb->first_quick_scan_conf =
1090
1090
                        ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
1091
1091
                antcomb->second_quick_scan_conf =
1092
1092
                        ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
1093
1093
                break;
1094
 
        case (0x12): /* LNA2 LNA1 */
 
1094
        case 0x12: /* LNA2 LNA1 */
1095
1095
                antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1;
1096
1096
                antcomb->first_quick_scan_conf =
1097
1097
                        ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
1098
1098
                antcomb->second_quick_scan_conf =
1099
1099
                        ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
1100
1100
                break;
1101
 
        case (0x13): /* LNA2 A+B */
 
1101
        case 0x13: /* LNA2 A+B */
1102
1102
                antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
1103
1103
                antcomb->first_quick_scan_conf =
1104
1104
                        ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
1105
1105
                antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1;
1106
1106
                break;
1107
 
        case (0x23): /* LNA1 A+B */
 
1107
        case 0x23: /* LNA1 A+B */
1108
1108
                antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
1109
1109
                antcomb->first_quick_scan_conf =
1110
1110
                        ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
1321
1321
                /* Adjust the fast_div_bias based on main and alt lna conf */
1322
1322
                switch ((ant_conf->main_lna_conf << 4) |
1323
1323
                                ant_conf->alt_lna_conf) {
1324
 
                case (0x01): /* A-B LNA2 */
 
1324
                case 0x01: /* A-B LNA2 */
1325
1325
                        ant_conf->fast_div_bias = 0x3b;
1326
1326
                        break;
1327
 
                case (0x02): /* A-B LNA1 */
 
1327
                case 0x02: /* A-B LNA1 */
1328
1328
                        ant_conf->fast_div_bias = 0x3d;
1329
1329
                        break;
1330
 
                case (0x03): /* A-B A+B */
 
1330
                case 0x03: /* A-B A+B */
1331
1331
                        ant_conf->fast_div_bias = 0x1;
1332
1332
                        break;
1333
 
                case (0x10): /* LNA2 A-B */
 
1333
                case 0x10: /* LNA2 A-B */
1334
1334
                        ant_conf->fast_div_bias = 0x7;
1335
1335
                        break;
1336
 
                case (0x12): /* LNA2 LNA1 */
 
1336
                case 0x12: /* LNA2 LNA1 */
1337
1337
                        ant_conf->fast_div_bias = 0x2;
1338
1338
                        break;
1339
 
                case (0x13): /* LNA2 A+B */
 
1339
                case 0x13: /* LNA2 A+B */
1340
1340
                        ant_conf->fast_div_bias = 0x7;
1341
1341
                        break;
1342
 
                case (0x20): /* LNA1 A-B */
 
1342
                case 0x20: /* LNA1 A-B */
1343
1343
                        ant_conf->fast_div_bias = 0x6;
1344
1344
                        break;
1345
 
                case (0x21): /* LNA1 LNA2 */
 
1345
                case 0x21: /* LNA1 LNA2 */
1346
1346
                        ant_conf->fast_div_bias = 0x0;
1347
1347
                        break;
1348
 
                case (0x23): /* LNA1 A+B */
 
1348
                case 0x23: /* LNA1 A+B */
1349
1349
                        ant_conf->fast_div_bias = 0x6;
1350
1350
                        break;
1351
 
                case (0x30): /* A+B A-B */
 
1351
                case 0x30: /* A+B A-B */
1352
1352
                        ant_conf->fast_div_bias = 0x1;
1353
1353
                        break;
1354
 
                case (0x31): /* A+B LNA2 */
 
1354
                case 0x31: /* A+B LNA2 */
1355
1355
                        ant_conf->fast_div_bias = 0x3b;
1356
1356
                        break;
1357
 
                case (0x32): /* A+B LNA1 */
 
1357
                case 0x32: /* A+B LNA1 */
1358
1358
                        ant_conf->fast_div_bias = 0x3d;
1359
1359
                        break;
1360
1360
                default:
1361
1361
                        break;
1362
1362
                }
 
1363
        } else if (ant_conf->div_group == 1) {
 
1364
                /* Adjust the fast_div_bias based on main and alt_lna_conf */
 
1365
                switch ((ant_conf->main_lna_conf << 4) |
 
1366
                        ant_conf->alt_lna_conf) {
 
1367
                case 0x01: /* A-B LNA2 */
 
1368
                        ant_conf->fast_div_bias = 0x1;
 
1369
                        ant_conf->main_gaintb = 0;
 
1370
                        ant_conf->alt_gaintb = 0;
 
1371
                        break;
 
1372
                case 0x02: /* A-B LNA1 */
 
1373
                        ant_conf->fast_div_bias = 0x1;
 
1374
                        ant_conf->main_gaintb = 0;
 
1375
                        ant_conf->alt_gaintb = 0;
 
1376
                        break;
 
1377
                case 0x03: /* A-B A+B */
 
1378
                        ant_conf->fast_div_bias = 0x1;
 
1379
                        ant_conf->main_gaintb = 0;
 
1380
                        ant_conf->alt_gaintb = 0;
 
1381
                        break;
 
1382
                case 0x10: /* LNA2 A-B */
 
1383
                        if (!(antcomb->scan) &&
 
1384
                            (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1385
                                ant_conf->fast_div_bias = 0x3f;
 
1386
                        else
 
1387
                                ant_conf->fast_div_bias = 0x1;
 
1388
                        ant_conf->main_gaintb = 0;
 
1389
                        ant_conf->alt_gaintb = 0;
 
1390
                        break;
 
1391
                case 0x12: /* LNA2 LNA1 */
 
1392
                        ant_conf->fast_div_bias = 0x1;
 
1393
                        ant_conf->main_gaintb = 0;
 
1394
                        ant_conf->alt_gaintb = 0;
 
1395
                        break;
 
1396
                case 0x13: /* LNA2 A+B */
 
1397
                        if (!(antcomb->scan) &&
 
1398
                            (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1399
                                ant_conf->fast_div_bias = 0x3f;
 
1400
                        else
 
1401
                                ant_conf->fast_div_bias = 0x1;
 
1402
                        ant_conf->main_gaintb = 0;
 
1403
                        ant_conf->alt_gaintb = 0;
 
1404
                        break;
 
1405
                case 0x20: /* LNA1 A-B */
 
1406
                        if (!(antcomb->scan) &&
 
1407
                            (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1408
                                ant_conf->fast_div_bias = 0x3f;
 
1409
                        else
 
1410
                                ant_conf->fast_div_bias = 0x1;
 
1411
                        ant_conf->main_gaintb = 0;
 
1412
                        ant_conf->alt_gaintb = 0;
 
1413
                        break;
 
1414
                case 0x21: /* LNA1 LNA2 */
 
1415
                        ant_conf->fast_div_bias = 0x1;
 
1416
                        ant_conf->main_gaintb = 0;
 
1417
                        ant_conf->alt_gaintb = 0;
 
1418
                        break;
 
1419
                case 0x23: /* LNA1 A+B */
 
1420
                        if (!(antcomb->scan) &&
 
1421
                            (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1422
                                ant_conf->fast_div_bias = 0x3f;
 
1423
                        else
 
1424
                                ant_conf->fast_div_bias = 0x1;
 
1425
                        ant_conf->main_gaintb = 0;
 
1426
                        ant_conf->alt_gaintb = 0;
 
1427
                        break;
 
1428
                case 0x30: /* A+B A-B */
 
1429
                        ant_conf->fast_div_bias = 0x1;
 
1430
                        ant_conf->main_gaintb = 0;
 
1431
                        ant_conf->alt_gaintb = 0;
 
1432
                        break;
 
1433
                case 0x31: /* A+B LNA2 */
 
1434
                        ant_conf->fast_div_bias = 0x1;
 
1435
                        ant_conf->main_gaintb = 0;
 
1436
                        ant_conf->alt_gaintb = 0;
 
1437
                        break;
 
1438
                case 0x32: /* A+B LNA1 */
 
1439
                        ant_conf->fast_div_bias = 0x1;
 
1440
                        ant_conf->main_gaintb = 0;
 
1441
                        ant_conf->alt_gaintb = 0;
 
1442
                        break;
 
1443
                default:
 
1444
                        break;
 
1445
                }
1363
1446
        } else if (ant_conf->div_group == 2) {
1364
1447
                /* Adjust the fast_div_bias based on main and alt_lna_conf */
1365
1448
                switch ((ant_conf->main_lna_conf << 4) |
1366
1449
                                ant_conf->alt_lna_conf) {
1367
 
                case (0x01): /* A-B LNA2 */
1368
 
                        ant_conf->fast_div_bias = 0x1;
1369
 
                        ant_conf->main_gaintb = 0;
1370
 
                        ant_conf->alt_gaintb = 0;
1371
 
                        break;
1372
 
                case (0x02): /* A-B LNA1 */
1373
 
                        ant_conf->fast_div_bias = 0x1;
1374
 
                        ant_conf->main_gaintb = 0;
1375
 
                        ant_conf->alt_gaintb = 0;
1376
 
                        break;
1377
 
                case (0x03): /* A-B A+B */
1378
 
                        ant_conf->fast_div_bias = 0x1;
1379
 
                        ant_conf->main_gaintb = 0;
1380
 
                        ant_conf->alt_gaintb = 0;
1381
 
                        break;
1382
 
                case (0x10): /* LNA2 A-B */
1383
 
                        if (!(antcomb->scan) &&
1384
 
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
1385
 
                                ant_conf->fast_div_bias = 0x1;
1386
 
                        else
1387
 
                                ant_conf->fast_div_bias = 0x2;
1388
 
                        ant_conf->main_gaintb = 0;
1389
 
                        ant_conf->alt_gaintb = 0;
1390
 
                        break;
1391
 
                case (0x12): /* LNA2 LNA1 */
1392
 
                        ant_conf->fast_div_bias = 0x1;
1393
 
                        ant_conf->main_gaintb = 0;
1394
 
                        ant_conf->alt_gaintb = 0;
1395
 
                        break;
1396
 
                case (0x13): /* LNA2 A+B */
1397
 
                        if (!(antcomb->scan) &&
1398
 
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
1399
 
                                ant_conf->fast_div_bias = 0x1;
1400
 
                        else
1401
 
                                ant_conf->fast_div_bias = 0x2;
1402
 
                        ant_conf->main_gaintb = 0;
1403
 
                        ant_conf->alt_gaintb = 0;
1404
 
                        break;
1405
 
                case (0x20): /* LNA1 A-B */
1406
 
                        if (!(antcomb->scan) &&
1407
 
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
1408
 
                                ant_conf->fast_div_bias = 0x1;
1409
 
                        else
1410
 
                                ant_conf->fast_div_bias = 0x2;
1411
 
                        ant_conf->main_gaintb = 0;
1412
 
                        ant_conf->alt_gaintb = 0;
1413
 
                        break;
1414
 
                case (0x21): /* LNA1 LNA2 */
1415
 
                        ant_conf->fast_div_bias = 0x1;
1416
 
                        ant_conf->main_gaintb = 0;
1417
 
                        ant_conf->alt_gaintb = 0;
1418
 
                        break;
1419
 
                case (0x23): /* LNA1 A+B */
1420
 
                        if (!(antcomb->scan) &&
1421
 
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
1422
 
                                ant_conf->fast_div_bias = 0x1;
1423
 
                        else
1424
 
                                ant_conf->fast_div_bias = 0x2;
1425
 
                        ant_conf->main_gaintb = 0;
1426
 
                        ant_conf->alt_gaintb = 0;
1427
 
                        break;
1428
 
                case (0x30): /* A+B A-B */
1429
 
                        ant_conf->fast_div_bias = 0x1;
1430
 
                        ant_conf->main_gaintb = 0;
1431
 
                        ant_conf->alt_gaintb = 0;
1432
 
                        break;
1433
 
                case (0x31): /* A+B LNA2 */
1434
 
                        ant_conf->fast_div_bias = 0x1;
1435
 
                        ant_conf->main_gaintb = 0;
1436
 
                        ant_conf->alt_gaintb = 0;
1437
 
                        break;
1438
 
                case (0x32): /* A+B LNA1 */
 
1450
                case 0x01: /* A-B LNA2 */
 
1451
                        ant_conf->fast_div_bias = 0x1;
 
1452
                        ant_conf->main_gaintb = 0;
 
1453
                        ant_conf->alt_gaintb = 0;
 
1454
                        break;
 
1455
                case 0x02: /* A-B LNA1 */
 
1456
                        ant_conf->fast_div_bias = 0x1;
 
1457
                        ant_conf->main_gaintb = 0;
 
1458
                        ant_conf->alt_gaintb = 0;
 
1459
                        break;
 
1460
                case 0x03: /* A-B A+B */
 
1461
                        ant_conf->fast_div_bias = 0x1;
 
1462
                        ant_conf->main_gaintb = 0;
 
1463
                        ant_conf->alt_gaintb = 0;
 
1464
                        break;
 
1465
                case 0x10: /* LNA2 A-B */
 
1466
                        if (!(antcomb->scan) &&
 
1467
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1468
                                ant_conf->fast_div_bias = 0x1;
 
1469
                        else
 
1470
                                ant_conf->fast_div_bias = 0x2;
 
1471
                        ant_conf->main_gaintb = 0;
 
1472
                        ant_conf->alt_gaintb = 0;
 
1473
                        break;
 
1474
                case 0x12: /* LNA2 LNA1 */
 
1475
                        ant_conf->fast_div_bias = 0x1;
 
1476
                        ant_conf->main_gaintb = 0;
 
1477
                        ant_conf->alt_gaintb = 0;
 
1478
                        break;
 
1479
                case 0x13: /* LNA2 A+B */
 
1480
                        if (!(antcomb->scan) &&
 
1481
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1482
                                ant_conf->fast_div_bias = 0x1;
 
1483
                        else
 
1484
                                ant_conf->fast_div_bias = 0x2;
 
1485
                        ant_conf->main_gaintb = 0;
 
1486
                        ant_conf->alt_gaintb = 0;
 
1487
                        break;
 
1488
                case 0x20: /* LNA1 A-B */
 
1489
                        if (!(antcomb->scan) &&
 
1490
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1491
                                ant_conf->fast_div_bias = 0x1;
 
1492
                        else
 
1493
                                ant_conf->fast_div_bias = 0x2;
 
1494
                        ant_conf->main_gaintb = 0;
 
1495
                        ant_conf->alt_gaintb = 0;
 
1496
                        break;
 
1497
                case 0x21: /* LNA1 LNA2 */
 
1498
                        ant_conf->fast_div_bias = 0x1;
 
1499
                        ant_conf->main_gaintb = 0;
 
1500
                        ant_conf->alt_gaintb = 0;
 
1501
                        break;
 
1502
                case 0x23: /* LNA1 A+B */
 
1503
                        if (!(antcomb->scan) &&
 
1504
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1505
                                ant_conf->fast_div_bias = 0x1;
 
1506
                        else
 
1507
                                ant_conf->fast_div_bias = 0x2;
 
1508
                        ant_conf->main_gaintb = 0;
 
1509
                        ant_conf->alt_gaintb = 0;
 
1510
                        break;
 
1511
                case 0x30: /* A+B A-B */
 
1512
                        ant_conf->fast_div_bias = 0x1;
 
1513
                        ant_conf->main_gaintb = 0;
 
1514
                        ant_conf->alt_gaintb = 0;
 
1515
                        break;
 
1516
                case 0x31: /* A+B LNA2 */
 
1517
                        ant_conf->fast_div_bias = 0x1;
 
1518
                        ant_conf->main_gaintb = 0;
 
1519
                        ant_conf->alt_gaintb = 0;
 
1520
                        break;
 
1521
                case 0x32: /* A+B LNA1 */
1439
1522
                        ant_conf->fast_div_bias = 0x1;
1440
1523
                        ant_conf->main_gaintb = 0;
1441
1524
                        ant_conf->alt_gaintb = 0;
1443
1526
                default:
1444
1527
                        break;
1445
1528
                }
1446
 
 
1447
1529
        }
1448
 
 
1449
1530
}
1450
1531
 
1451
1532
/* Antenna diversity and combining */
1689
1770
        struct ieee80211_rx_status *rxs;
1690
1771
        struct ath_hw *ah = sc->sc_ah;
1691
1772
        struct ath_common *common = ath9k_hw_common(ah);
1692
 
        /*
1693
 
         * The hw can technically differ from common->hw when using ath9k
1694
 
         * virtual wiphy so to account for that we iterate over the active
1695
 
         * wiphys and find the appropriate wiphy and therefore hw.
1696
 
         */
1697
1773
        struct ieee80211_hw *hw = sc->hw;
1698
1774
        struct ieee80211_hdr *hdr;
1699
1775
        int retval;
1747
1823
 
1748
1824
                hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len);
1749
1825
                rxs = IEEE80211_SKB_RXCB(hdr_skb);
 
1826
                if (ieee80211_is_beacon(hdr->frame_control) &&
 
1827
                    !compare_ether_addr(hdr->addr3, common->curbssid))
 
1828
                        rs.is_mybeacon = true;
 
1829
                else
 
1830
                        rs.is_mybeacon = false;
1750
1831
 
1751
1832
                ath_debug_stat_rx(sc, &rs);
1752
1833
 
1754
1835
                 * If we're asked to flush receive queue, directly
1755
1836
                 * chain it back at the queue without processing it.
1756
1837
                 */
1757
 
                if (flush)
 
1838
                if (sc->sc_flags & SC_OP_RXFLUSH)
1758
1839
                        goto requeue_drop_frag;
1759
1840
 
1760
1841
                retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
1853
1934
                        sc->rx.rxotherant = 0;
1854
1935
                }
1855
1936
 
 
1937
                if (rxs->flag & RX_FLAG_MMIC_STRIPPED)
 
1938
                        skb_trim(skb, skb->len - 8);
 
1939
 
1856
1940
                spin_lock_irqsave(&sc->sc_pm_lock, flags);
1857
1941
 
1858
1942
                if ((sc->ps_flags & (PS_WAIT_FOR_BEACON |
1859
 
                                              PS_WAIT_FOR_CAB |
1860
 
                                              PS_WAIT_FOR_PSPOLL_DATA)) ||
1861
 
                                                ath9k_check_auto_sleep(sc))
1862
 
                        ath_rx_ps(sc, skb);
 
1943
                                     PS_WAIT_FOR_CAB |
 
1944
                                     PS_WAIT_FOR_PSPOLL_DATA)) ||
 
1945
                    ath9k_check_auto_sleep(sc))
 
1946
                        ath_rx_ps(sc, skb, rs.is_mybeacon);
1863
1947
                spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1864
1948
 
1865
 
                if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
 
1949
                if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx == 3)
1866
1950
                        ath_ant_comb_scan(sc, &rs);
1867
1951
 
1868
1952
                ieee80211_rx(hw, skb);
1879
1963
                } else {
1880
1964
                        list_move_tail(&bf->list, &sc->rx.rxbuf);
1881
1965
                        ath_rx_buf_link(sc, bf);
1882
 
                        ath9k_hw_rxena(ah);
 
1966
                        if (!flush)
 
1967
                                ath9k_hw_rxena(ah);
1883
1968
                }
1884
1969
        } while (1);
1885
1970
 
1886
1971
        spin_unlock_bh(&sc->rx.rxbuflock);
1887
1972
 
 
1973
        if (!(ah->imask & ATH9K_INT_RXEOL)) {
 
1974
                ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
 
1975
                ath9k_hw_set_interrupts(ah);
 
1976
        }
 
1977
 
1888
1978
        return 0;
1889
1979
}