ath9k: fix issues with ad-hoc beacon slot selection
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 570-ath9k_fix_adhoc_beacons.patch
1 --- a/drivers/net/wireless/ath/ath9k/beacon.c
2 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
3 @@ -351,9 +351,7 @@ void ath_beacon_tasklet(unsigned long da
4 struct ath_buf *bf = NULL;
5 struct ieee80211_vif *vif;
6 int slot;
7 - u32 bfaddr, bc = 0, tsftu;
8 - u64 tsf;
9 - u16 intval;
10 + u32 bfaddr, bc = 0;
11
12 /*
13 * Check if the previous beacon has gone out. If
14 @@ -388,17 +386,27 @@ void ath_beacon_tasklet(unsigned long da
15 * on the tsf to safeguard against missing an swba.
16 */
17
18 - intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
19
20 - tsf = ath9k_hw_gettsf64(ah);
21 - tsf += TU_TO_USEC(ah->config.sw_beacon_response_time);
22 - tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
23 - slot = (tsftu % (intval * ATH_BCBUF)) / intval;
24 - vif = sc->beacon.bslot[slot];
25 + if (ah->opmode == NL80211_IFTYPE_AP) {
26 + u16 intval;
27 + u32 tsftu;
28 + u64 tsf;
29 +
30 + intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
31 + tsf = ath9k_hw_gettsf64(ah);
32 + tsf += TU_TO_USEC(ah->config.sw_beacon_response_time);
33 + tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
34 + slot = (tsftu % (intval * ATH_BCBUF)) / intval;
35 + vif = sc->beacon.bslot[slot];
36 +
37 + ath_dbg(common, ATH_DBG_BEACON,
38 + "slot %d [tsf %llu tsftu %u intval %u] vif %p\n",
39 + slot, tsf, tsftu / ATH_BCBUF, intval, vif);
40 + } else {
41 + slot = 0;
42 + vif = sc->beacon.bslot[slot];
43 + }
44
45 - ath_dbg(common, ATH_DBG_BEACON,
46 - "slot %d [tsf %llu tsftu %u intval %u] vif %p\n",
47 - slot, tsf, tsftu / ATH_BCBUF, intval, vif);
48
49 bfaddr = 0;
50 if (vif) {