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

« back to all changes in this revision

Viewing changes to drivers/net/wireless/ath/ath9k/beacon.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
 
19
20
#define FUDGE 2
72
73
        struct sk_buff *skb = bf->bf_mpdu;
73
74
        struct ath_hw *ah = sc->sc_ah;
74
75
        struct ath_common *common = ath9k_hw_common(ah);
75
 
        struct ath_desc *ds;
76
 
        struct ath9k_11n_rate_series series[4];
77
 
        int flags, ctsrate = 0, ctsduration = 0;
 
76
        struct ath_tx_info info;
78
77
        struct ieee80211_supported_band *sband;
 
78
        u8 chainmask = ah->txchainmask;
79
79
        u8 rate = 0;
80
80
 
81
81
        ath9k_reset_beacon_status(sc);
82
82
 
83
 
        ds = bf->bf_desc;
84
 
        flags = ATH9K_TXDESC_NOACK;
85
 
 
86
 
        ds->ds_link = 0;
87
 
 
88
83
        sband = &sc->sbands[common->hw->conf.channel->band];
89
84
        rate = sband->bitrates[rateidx].hw_value;
90
85
        if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
91
86
                rate |= sband->bitrates[rateidx].hw_value_short;
92
87
 
93
 
        ath9k_hw_set11n_txdesc(ah, ds, skb->len + FCS_LEN,
94
 
                               ATH9K_PKT_TYPE_BEACON,
95
 
                               MAX_RATE_POWER,
96
 
                               ATH9K_TXKEYIX_INVALID,
97
 
                               ATH9K_KEY_TYPE_CLEAR,
98
 
                               flags);
99
 
 
100
 
        /* NB: beacon's BufLen must be a multiple of 4 bytes */
101
 
        ath9k_hw_filltxdesc(ah, ds, roundup(skb->len, 4),
102
 
                            true, true, ds, bf->bf_buf_addr,
103
 
                            sc->beacon.beaconq);
104
 
 
105
 
        memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4);
106
 
        series[0].Tries = 1;
107
 
        series[0].Rate = rate;
108
 
        series[0].ChSel = ath_txchainmask_reduction(sc,
109
 
                        common->tx_chainmask, series[0].Rate);
110
 
        series[0].RateFlags = (ctsrate) ? ATH9K_RATESERIES_RTS_CTS : 0;
111
 
        ath9k_hw_set11n_ratescenario(ah, ds, ds, 0, ctsrate, ctsduration,
112
 
                                     series, 4, 0);
 
88
        memset(&info, 0, sizeof(info));
 
89
        info.pkt_len = skb->len + FCS_LEN;
 
90
        info.type = ATH9K_PKT_TYPE_BEACON;
 
91
        info.txpower = MAX_RATE_POWER;
 
92
        info.keyix = ATH9K_TXKEYIX_INVALID;
 
93
        info.keytype = ATH9K_KEY_TYPE_CLEAR;
 
94
        info.flags = ATH9K_TXDESC_NOACK;
 
95
 
 
96
        info.buf_addr[0] = bf->bf_buf_addr;
 
97
        info.buf_len[0] = roundup(skb->len, 4);
 
98
 
 
99
        info.is_first = true;
 
100
        info.is_last = true;
 
101
 
 
102
        info.qcu = sc->beacon.beaconq;
 
103
 
 
104
        info.rates[0].Tries = 1;
 
105
        info.rates[0].Rate = rate;
 
106
        info.rates[0].ChSel = ath_txchainmask_reduction(sc, chainmask, rate);
 
107
 
 
108
        ath9k_hw_set_txdesc(ah, bf->bf_desc, &info);
113
109
}
114
110
 
115
111
static void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
360
356
        struct ath_common *common = ath9k_hw_common(ah);
361
357
        struct ath_buf *bf = NULL;
362
358
        struct ieee80211_vif *vif;
 
359
        struct ath_tx_status ts;
363
360
        int slot;
364
361
        u32 bfaddr, bc = 0;
365
362
 
384
381
                        ath_dbg(common, ATH_DBG_BSTUCK,
385
382
                                "beacon is officially stuck\n");
386
383
                        sc->sc_flags |= SC_OP_TSF_RESET;
387
 
                        ath_reset(sc, true);
 
384
                        ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
388
385
                }
389
386
 
390
387
                return;
464
461
                ath9k_hw_txstart(ah, sc->beacon.beaconq);
465
462
 
466
463
                sc->beacon.ast_be_xmit += bc;     /* XXX per-vif? */
 
464
                if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
 
465
                        spin_lock_bh(&sc->sc_pcu_lock);
 
466
                        ath9k_hw_txprocdesc(ah, bf->bf_desc, (void *)&ts);
 
467
                        spin_unlock_bh(&sc->sc_pcu_lock);
 
468
                }
467
469
        }
468
470
}
469
471
 
496
498
        u32 nexttbtt, intval;
497
499
 
498
500
        /* NB: the beacon interval is kept internally in TU's */
499
 
        intval = TU_TO_USEC(conf->beacon_interval & ATH9K_BEACON_PERIOD);
 
501
        intval = TU_TO_USEC(conf->beacon_interval);
500
502
        intval /= ATH_BCBUF;    /* for staggered beacons */
501
503
        nexttbtt = intval;
502
504
 
510
512
        /* Set the computed AP beacon timers */
511
513
 
512
514
        ath9k_hw_disable_interrupts(ah);
 
515
        sc->sc_flags |= SC_OP_TSF_RESET;
513
516
        ath9k_beacon_init(sc, nexttbtt, intval);
514
517
        sc->beacon.bmisscnt = 0;
515
 
        ath9k_hw_set_interrupts(ah, ah->imask);
 
518
        ath9k_hw_set_interrupts(ah);
 
519
        ath9k_hw_enable_interrupts(ah);
516
520
}
517
521
 
518
522
/*
543
547
        }
544
548
 
545
549
        memset(&bs, 0, sizeof(bs));
546
 
        intval = conf->beacon_interval & ATH9K_BEACON_PERIOD;
 
550
        intval = conf->beacon_interval;
547
551
 
548
552
        /*
549
553
         * Setup dtim and cfp parameters according to
639
643
        ath9k_hw_set_sta_beacon_timers(ah, &bs);
640
644
        ah->imask |= ATH9K_INT_BMISS;
641
645
 
642
 
        /*
643
 
         * If the beacon config is called beacause of TSFOOR,
644
 
         * Interrupts will be enabled back at the end of ath9k_tasklet
645
 
         */
646
 
        if (!(sc->ps_flags & PS_TSFOOR_SYNC))
647
 
                ath9k_hw_set_interrupts(ah, ah->imask);
 
646
        ath9k_hw_set_interrupts(ah);
 
647
        ath9k_hw_enable_interrupts(ah);
648
648
}
649
649
 
650
650
static void ath_beacon_config_adhoc(struct ath_softc *sc,
652
652
{
653
653
        struct ath_hw *ah = sc->sc_ah;
654
654
        struct ath_common *common = ath9k_hw_common(ah);
655
 
        u32 tsf, delta, intval, nexttbtt;
 
655
        u32 tsf, intval, nexttbtt;
656
656
 
657
657
        ath9k_reset_beacon_status(sc);
658
658
 
659
 
        tsf = ath9k_hw_gettsf32(ah) + TU_TO_USEC(FUDGE);
660
 
        intval = TU_TO_USEC(conf->beacon_interval & ATH9K_BEACON_PERIOD);
661
 
 
662
 
        if (!sc->beacon.bc_tstamp)
663
 
                nexttbtt = tsf + intval;
664
 
        else {
665
 
                if (tsf > sc->beacon.bc_tstamp)
666
 
                        delta = (tsf - sc->beacon.bc_tstamp);
667
 
                else
668
 
                        delta = (tsf + 1 + (~0U - sc->beacon.bc_tstamp));
669
 
                nexttbtt = tsf + intval - (delta % intval);
670
 
        }
 
659
        intval = TU_TO_USEC(conf->beacon_interval);
 
660
        tsf = roundup(ath9k_hw_gettsf32(ah) + TU_TO_USEC(FUDGE), intval);
 
661
        nexttbtt = tsf + intval;
671
662
 
672
663
        ath_dbg(common, ATH_DBG_BEACON,
673
664
                "IBSS nexttbtt %u intval %u (%u)\n",
687
678
        ath9k_hw_disable_interrupts(ah);
688
679
        ath9k_beacon_init(sc, nexttbtt, intval);
689
680
        sc->beacon.bmisscnt = 0;
690
 
        /*
691
 
         * If the beacon config is called beacause of TSFOOR,
692
 
         * Interrupts will be enabled back at the end of ath9k_tasklet
693
 
         */
694
 
        if (!(sc->ps_flags & PS_TSFOOR_SYNC))
695
 
                ath9k_hw_set_interrupts(ah, ah->imask);
 
681
 
 
682
        ath9k_hw_set_interrupts(ah);
 
683
        ath9k_hw_enable_interrupts(ah);
696
684
}
697
685
 
698
686
static bool ath9k_allow_beacon_config(struct ath_softc *sc,
833
821
        if (status) {
834
822
                /* Re-enable beaconing */
835
823
                ah->imask |= ATH9K_INT_SWBA;
836
 
                ath9k_hw_set_interrupts(ah, ah->imask);
 
824
                ath9k_hw_set_interrupts(ah);
837
825
        } else {
838
826
                /* Disable SWBA interrupt */
839
827
                ah->imask &= ~ATH9K_INT_SWBA;
840
 
                ath9k_hw_set_interrupts(ah, ah->imask);
 
828
                ath9k_hw_set_interrupts(ah);
841
829
                tasklet_kill(&sc->bcon_tasklet);
842
830
                ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq);
843
831
        }