~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2008-2009 Atheros Communications Inc.
 
2
 * Copyright (c) 2008-2011 Atheros Communications Inc.
3
3
 *
4
4
 * Permission to use, copy, modify, and/or distribute this software for any
5
5
 * purpose with or without fee is hereby granted, provided that the above
28
28
                (alt_rssi_avg > main_rssi_avg + mindelta)) && (pkt_count > 50);
29
29
}
30
30
 
 
31
static inline bool ath_ant_div_comb_alt_check(u8 div_group, int alt_ratio,
 
32
                                        int curr_main_set, int curr_alt_set,
 
33
                                        int alt_rssi_avg, int main_rssi_avg)
 
34
{
 
35
        bool result = false;
 
36
        switch (div_group) {
 
37
        case 0:
 
38
                if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)
 
39
                        result = true;
 
40
                break;
 
41
        case 1:
 
42
                if ((((curr_main_set == ATH_ANT_DIV_COMB_LNA2) &&
 
43
                        (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) &&
 
44
                                (alt_rssi_avg >= (main_rssi_avg - 5))) ||
 
45
                        ((curr_main_set == ATH_ANT_DIV_COMB_LNA1) &&
 
46
                        (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) &&
 
47
                                (alt_rssi_avg >= (main_rssi_avg - 2)))) &&
 
48
                                                        (alt_rssi_avg >= 4))
 
49
                        result = true;
 
50
                else
 
51
                        result = false;
 
52
                break;
 
53
        }
 
54
 
 
55
        return result;
 
56
}
 
57
 
31
58
static inline bool ath9k_check_auto_sleep(struct ath_softc *sc)
32
59
{
33
60
        return sc->ps_enabled &&
75
102
                *sc->rx.rxlink = bf->bf_daddr;
76
103
 
77
104
        sc->rx.rxlink = &ds->ds_link;
78
 
        ath9k_hw_rxena(ah);
79
105
}
80
106
 
81
107
static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
426
452
        else
427
453
                rfilt |= ATH9K_RX_FILTER_BEACON;
428
454
 
429
 
        if ((AR_SREV_9280_20_OR_LATER(sc->sc_ah) ||
430
 
            AR_SREV_9285_12_OR_LATER(sc->sc_ah)) &&
431
 
            (sc->sc_ah->opmode == NL80211_IFTYPE_AP) &&
 
455
        if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
432
456
            (sc->rx.rxfilter & FIF_PSPOLL))
433
457
                rfilt |= ATH9K_RX_FILTER_PSPOLL;
434
458
 
574
598
                sc->ps_flags &= ~PS_BEACON_SYNC;
575
599
                ath_dbg(common, ATH_DBG_PS,
576
600
                        "Reconfigure Beacon timers based on timestamp from the AP\n");
577
 
                ath_beacon_config(sc, NULL);
 
601
                ath_set_beacon(sc);
 
602
                sc->ps_flags &= ~PS_TSFOOR_SYNC;
578
603
        }
579
604
 
580
605
        if (ath_beacon_dtim_pending_cab(skb)) {
919
944
        int last_rssi;
920
945
        __le16 fc;
921
946
 
922
 
        if (ah->opmode != NL80211_IFTYPE_STATION)
 
947
        if ((ah->opmode != NL80211_IFTYPE_STATION) &&
 
948
            (ah->opmode != NL80211_IFTYPE_ADHOC))
923
949
                return;
924
950
 
925
951
        fc = hdr->frame_control;
1291
1317
        }
1292
1318
}
1293
1319
 
1294
 
static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf)
 
1320
static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf,
 
1321
                struct ath_ant_comb *antcomb, int alt_ratio)
1295
1322
{
1296
 
        /* Adjust the fast_div_bias based on main and alt lna conf */
1297
 
        switch ((ant_conf->main_lna_conf << 4) | ant_conf->alt_lna_conf) {
1298
 
        case (0x01): /* A-B LNA2 */
1299
 
                ant_conf->fast_div_bias = 0x3b;
1300
 
                break;
1301
 
        case (0x02): /* A-B LNA1 */
1302
 
                ant_conf->fast_div_bias = 0x3d;
1303
 
                break;
1304
 
        case (0x03): /* A-B A+B */
1305
 
                ant_conf->fast_div_bias = 0x1;
1306
 
                break;
1307
 
        case (0x10): /* LNA2 A-B */
1308
 
                ant_conf->fast_div_bias = 0x7;
1309
 
                break;
1310
 
        case (0x12): /* LNA2 LNA1 */
1311
 
                ant_conf->fast_div_bias = 0x2;
1312
 
                break;
1313
 
        case (0x13): /* LNA2 A+B */
1314
 
                ant_conf->fast_div_bias = 0x7;
1315
 
                break;
1316
 
        case (0x20): /* LNA1 A-B */
1317
 
                ant_conf->fast_div_bias = 0x6;
1318
 
                break;
1319
 
        case (0x21): /* LNA1 LNA2 */
1320
 
                ant_conf->fast_div_bias = 0x0;
1321
 
                break;
1322
 
        case (0x23): /* LNA1 A+B */
1323
 
                ant_conf->fast_div_bias = 0x6;
1324
 
                break;
1325
 
        case (0x30): /* A+B A-B */
1326
 
                ant_conf->fast_div_bias = 0x1;
1327
 
                break;
1328
 
        case (0x31): /* A+B LNA2 */
1329
 
                ant_conf->fast_div_bias = 0x3b;
1330
 
                break;
1331
 
        case (0x32): /* A+B LNA1 */
1332
 
                ant_conf->fast_div_bias = 0x3d;
1333
 
                break;
1334
 
        default:
1335
 
                break;
 
1323
        if (ant_conf->div_group == 0) {
 
1324
                /* Adjust the fast_div_bias based on main and alt lna conf */
 
1325
                switch ((ant_conf->main_lna_conf << 4) |
 
1326
                                ant_conf->alt_lna_conf) {
 
1327
                case (0x01): /* A-B LNA2 */
 
1328
                        ant_conf->fast_div_bias = 0x3b;
 
1329
                        break;
 
1330
                case (0x02): /* A-B LNA1 */
 
1331
                        ant_conf->fast_div_bias = 0x3d;
 
1332
                        break;
 
1333
                case (0x03): /* A-B A+B */
 
1334
                        ant_conf->fast_div_bias = 0x1;
 
1335
                        break;
 
1336
                case (0x10): /* LNA2 A-B */
 
1337
                        ant_conf->fast_div_bias = 0x7;
 
1338
                        break;
 
1339
                case (0x12): /* LNA2 LNA1 */
 
1340
                        ant_conf->fast_div_bias = 0x2;
 
1341
                        break;
 
1342
                case (0x13): /* LNA2 A+B */
 
1343
                        ant_conf->fast_div_bias = 0x7;
 
1344
                        break;
 
1345
                case (0x20): /* LNA1 A-B */
 
1346
                        ant_conf->fast_div_bias = 0x6;
 
1347
                        break;
 
1348
                case (0x21): /* LNA1 LNA2 */
 
1349
                        ant_conf->fast_div_bias = 0x0;
 
1350
                        break;
 
1351
                case (0x23): /* LNA1 A+B */
 
1352
                        ant_conf->fast_div_bias = 0x6;
 
1353
                        break;
 
1354
                case (0x30): /* A+B A-B */
 
1355
                        ant_conf->fast_div_bias = 0x1;
 
1356
                        break;
 
1357
                case (0x31): /* A+B LNA2 */
 
1358
                        ant_conf->fast_div_bias = 0x3b;
 
1359
                        break;
 
1360
                case (0x32): /* A+B LNA1 */
 
1361
                        ant_conf->fast_div_bias = 0x3d;
 
1362
                        break;
 
1363
                default:
 
1364
                        break;
 
1365
                }
 
1366
        } else if (ant_conf->div_group == 2) {
 
1367
                /* Adjust the fast_div_bias based on main and alt_lna_conf */
 
1368
                switch ((ant_conf->main_lna_conf << 4) |
 
1369
                                ant_conf->alt_lna_conf) {
 
1370
                case (0x01): /* A-B LNA2 */
 
1371
                        ant_conf->fast_div_bias = 0x1;
 
1372
                        ant_conf->main_gaintb = 0;
 
1373
                        ant_conf->alt_gaintb = 0;
 
1374
                        break;
 
1375
                case (0x02): /* A-B LNA1 */
 
1376
                        ant_conf->fast_div_bias = 0x1;
 
1377
                        ant_conf->main_gaintb = 0;
 
1378
                        ant_conf->alt_gaintb = 0;
 
1379
                        break;
 
1380
                case (0x03): /* A-B A+B */
 
1381
                        ant_conf->fast_div_bias = 0x1;
 
1382
                        ant_conf->main_gaintb = 0;
 
1383
                        ant_conf->alt_gaintb = 0;
 
1384
                        break;
 
1385
                case (0x10): /* LNA2 A-B */
 
1386
                        if (!(antcomb->scan) &&
 
1387
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1388
                                ant_conf->fast_div_bias = 0x1;
 
1389
                        else
 
1390
                                ant_conf->fast_div_bias = 0x2;
 
1391
                        ant_conf->main_gaintb = 0;
 
1392
                        ant_conf->alt_gaintb = 0;
 
1393
                        break;
 
1394
                case (0x12): /* LNA2 LNA1 */
 
1395
                        ant_conf->fast_div_bias = 0x1;
 
1396
                        ant_conf->main_gaintb = 0;
 
1397
                        ant_conf->alt_gaintb = 0;
 
1398
                        break;
 
1399
                case (0x13): /* LNA2 A+B */
 
1400
                        if (!(antcomb->scan) &&
 
1401
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1402
                                ant_conf->fast_div_bias = 0x1;
 
1403
                        else
 
1404
                                ant_conf->fast_div_bias = 0x2;
 
1405
                        ant_conf->main_gaintb = 0;
 
1406
                        ant_conf->alt_gaintb = 0;
 
1407
                        break;
 
1408
                case (0x20): /* LNA1 A-B */
 
1409
                        if (!(antcomb->scan) &&
 
1410
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1411
                                ant_conf->fast_div_bias = 0x1;
 
1412
                        else
 
1413
                                ant_conf->fast_div_bias = 0x2;
 
1414
                        ant_conf->main_gaintb = 0;
 
1415
                        ant_conf->alt_gaintb = 0;
 
1416
                        break;
 
1417
                case (0x21): /* LNA1 LNA2 */
 
1418
                        ant_conf->fast_div_bias = 0x1;
 
1419
                        ant_conf->main_gaintb = 0;
 
1420
                        ant_conf->alt_gaintb = 0;
 
1421
                        break;
 
1422
                case (0x23): /* LNA1 A+B */
 
1423
                        if (!(antcomb->scan) &&
 
1424
                                (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
 
1425
                                ant_conf->fast_div_bias = 0x1;
 
1426
                        else
 
1427
                                ant_conf->fast_div_bias = 0x2;
 
1428
                        ant_conf->main_gaintb = 0;
 
1429
                        ant_conf->alt_gaintb = 0;
 
1430
                        break;
 
1431
                case (0x30): /* A+B A-B */
 
1432
                        ant_conf->fast_div_bias = 0x1;
 
1433
                        ant_conf->main_gaintb = 0;
 
1434
                        ant_conf->alt_gaintb = 0;
 
1435
                        break;
 
1436
                case (0x31): /* A+B LNA2 */
 
1437
                        ant_conf->fast_div_bias = 0x1;
 
1438
                        ant_conf->main_gaintb = 0;
 
1439
                        ant_conf->alt_gaintb = 0;
 
1440
                        break;
 
1441
                case (0x32): /* A+B LNA1 */
 
1442
                        ant_conf->fast_div_bias = 0x1;
 
1443
                        ant_conf->main_gaintb = 0;
 
1444
                        ant_conf->alt_gaintb = 0;
 
1445
                        break;
 
1446
                default:
 
1447
                        break;
 
1448
                }
 
1449
 
1336
1450
        }
 
1451
 
1337
1452
}
1338
1453
 
1339
1454
/* Antenna diversity and combining */
1342
1457
        struct ath_hw_antcomb_conf div_ant_conf;
1343
1458
        struct ath_ant_comb *antcomb = &sc->ant_comb;
1344
1459
        int alt_ratio = 0, alt_rssi_avg = 0, main_rssi_avg = 0, curr_alt_set;
1345
 
        int curr_main_set, curr_bias;
 
1460
        int curr_main_set;
1346
1461
        int main_rssi = rs->rs_rssi_ctl0;
1347
1462
        int alt_rssi = rs->rs_rssi_ctl1;
1348
1463
        int rx_ant_conf,  main_ant_conf;
1353
1468
        main_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_MAIN_SHIFT) &
1354
1469
                         ATH_ANT_RX_MASK;
1355
1470
 
1356
 
        /* Record packet only when alt_rssi is positive */
1357
 
        if (alt_rssi > 0) {
 
1471
        /* Record packet only when both main_rssi and  alt_rssi is positive */
 
1472
        if (main_rssi > 0 && alt_rssi > 0) {
1358
1473
                antcomb->total_pkt_count++;
1359
1474
                antcomb->main_total_rssi += main_rssi;
1360
1475
                antcomb->alt_total_rssi  += alt_rssi;
1396
1511
        ath9k_hw_antdiv_comb_conf_get(sc->sc_ah, &div_ant_conf);
1397
1512
        curr_alt_set = div_ant_conf.alt_lna_conf;
1398
1513
        curr_main_set = div_ant_conf.main_lna_conf;
1399
 
        curr_bias = div_ant_conf.fast_div_bias;
1400
1514
 
1401
1515
        antcomb->count++;
1402
1516
 
1415
1529
        }
1416
1530
 
1417
1531
        if (!antcomb->scan) {
1418
 
                if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) {
 
1532
                if (ath_ant_div_comb_alt_check(div_ant_conf.div_group,
 
1533
                                        alt_ratio, curr_main_set, curr_alt_set,
 
1534
                                        alt_rssi_avg, main_rssi_avg)) {
1419
1535
                        if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) {
1420
1536
                                /* Switch main and alt LNA */
1421
1537
                                div_ant_conf.main_lna_conf =
1444
1560
                }
1445
1561
 
1446
1562
                if ((alt_rssi_avg < (main_rssi_avg +
1447
 
                    ATH_ANT_DIV_COMB_LNA1_LNA2_DELTA)))
 
1563
                                                div_ant_conf.lna1_lna2_delta)))
1448
1564
                        goto div_comb_done;
1449
1565
        }
1450
1566
 
1558
1674
        antcomb->quick_scan_cnt++;
1559
1675
 
1560
1676
div_comb_done:
1561
 
        ath_ant_div_conf_fast_divbias(&div_ant_conf);
1562
 
 
 
1677
        ath_ant_div_conf_fast_divbias(&div_ant_conf, antcomb, alt_ratio);
1563
1678
        ath9k_hw_antdiv_comb_conf_set(sc->sc_ah, &div_ant_conf);
1564
1679
 
1565
1680
        antcomb->scan_start_time = jiffies;
1746
1861
                if ((sc->ps_flags & (PS_WAIT_FOR_BEACON |
1747
1862
                                              PS_WAIT_FOR_CAB |
1748
1863
                                              PS_WAIT_FOR_PSPOLL_DATA)) ||
1749
 
                                        unlikely(ath9k_check_auto_sleep(sc)))
 
1864
                                                ath9k_check_auto_sleep(sc))
1750
1865
                        ath_rx_ps(sc, skb);
1751
1866
                spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1752
1867
 
1767
1882
                } else {
1768
1883
                        list_move_tail(&bf->list, &sc->rx.rxbuf);
1769
1884
                        ath_rx_buf_link(sc, bf);
 
1885
                        ath9k_hw_rxena(ah);
1770
1886
                }
1771
1887
        } while (1);
1772
1888