aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_beacon.c84
1 files changed, 2 insertions, 82 deletions
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
index 9ff9e6e5df06..fc16c10549b1 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
@@ -62,97 +62,17 @@ void ath9k_htc_beaconq_config(struct ath9k_htc_priv *priv)
62 } 62 }
63} 63}
64 64
65
66static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv, 65static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv,
67 struct ath_beacon_config *bss_conf) 66 struct ath_beacon_config *bss_conf)
68{ 67{
69 struct ath_common *common = ath9k_hw_common(priv->ah);
70 struct ath9k_beacon_state bs; 68 struct ath9k_beacon_state bs;
71 enum ath9k_int imask = 0; 69 enum ath9k_int imask = 0;
72 int dtimperiod, dtimcount;
73 int bmiss_timeout;
74 u32 nexttbtt = 0, intval, tsftu;
75 __be32 htc_imask = 0; 70 __be32 htc_imask = 0;
76 u64 tsf;
77 int num_beacons, offset, dtim_dec_count;
78 int ret __attribute__ ((unused)); 71 int ret __attribute__ ((unused));
79 u8 cmd_rsp; 72 u8 cmd_rsp;
80 73
81 memset(&bs, 0, sizeof(bs)); 74 if (ath9k_cmn_beacon_config_sta(priv->ah, bss_conf, &bs) == -EPERM)
82 75 return;
83 intval = bss_conf->beacon_interval;
84 bmiss_timeout = (ATH_DEFAULT_BMISS_LIMIT * bss_conf->beacon_interval);
85
86 /*
87 * Setup dtim parameters according to
88 * last beacon we received (which may be none).
89 */
90 dtimperiod = bss_conf->dtim_period;
91 if (dtimperiod <= 0) /* NB: 0 if not known */
92 dtimperiod = 1;
93 dtimcount = 1;
94 if (dtimcount >= dtimperiod) /* NB: sanity check */
95 dtimcount = 0;
96
97 /*
98 * Pull nexttbtt forward to reflect the current
99 * TSF and calculate dtim state for the result.
100 */
101 tsf = ath9k_hw_gettsf64(priv->ah);
102 tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE;
103
104 num_beacons = tsftu / intval + 1;
105 offset = tsftu % intval;
106 nexttbtt = tsftu - offset;
107 if (offset)
108 nexttbtt += intval;
109
110 /* DTIM Beacon every dtimperiod Beacon */
111 dtim_dec_count = num_beacons % dtimperiod;
112 dtimcount -= dtim_dec_count;
113 if (dtimcount < 0)
114 dtimcount += dtimperiod;
115
116 bs.bs_intval = TU_TO_USEC(intval);
117 bs.bs_nexttbtt = TU_TO_USEC(nexttbtt);
118 bs.bs_dtimperiod = dtimperiod * bs.bs_intval;
119 bs.bs_nextdtim = bs.bs_nexttbtt + dtimcount * bs.bs_intval;
120
121 /*
122 * Calculate the number of consecutive beacons to miss* before taking
123 * a BMISS interrupt. The configuration is specified in TU so we only
124 * need calculate based on the beacon interval. Note that we clamp the
125 * result to at most 15 beacons.
126 */
127 bs.bs_bmissthreshold = DIV_ROUND_UP(bmiss_timeout, intval);
128 if (bs.bs_bmissthreshold > 15)
129 bs.bs_bmissthreshold = 15;
130 else if (bs.bs_bmissthreshold <= 0)
131 bs.bs_bmissthreshold = 1;
132
133 /*
134 * Calculate sleep duration. The configuration is given in ms.
135 * We ensure a multiple of the beacon period is used. Also, if the sleep
136 * duration is greater than the DTIM period then it makes senses
137 * to make it a multiple of that.
138 *
139 * XXX fixed at 100ms
140 */
141
142 bs.bs_sleepduration = TU_TO_USEC(roundup(IEEE80211_MS_TO_TU(100),
143 intval));
144 if (bs.bs_sleepduration > bs.bs_dtimperiod)
145 bs.bs_sleepduration = bs.bs_dtimperiod;
146
147 /* TSF out of range threshold fixed at 1 second */
148 bs.bs_tsfoor_threshold = ATH9K_TSFOOR_THRESHOLD;
149
150 ath_dbg(common, CONFIG, "intval: %u tsf: %llu tsftu: %u\n",
151 intval, tsf, tsftu);
152 ath_dbg(common, CONFIG, "bmiss: %u sleep: %u\n",
153 bs.bs_bmissthreshold, bs.bs_sleepduration);
154
155 /* Set the computed STA beacon timers */
156 76
157 WMI_CMD(WMI_DISABLE_INTR_CMDID); 77 WMI_CMD(WMI_DISABLE_INTR_CMDID);
158 ath9k_hw_set_sta_beacon_timers(priv->ah, &bs); 78 ath9k_hw_set_sta_beacon_timers(priv->ah, &bs);