blob: af273358c7cbaf0cc3220c10a5a655b01f86fc92 [file] [log] [blame]
Nick Kossifidisc6e387a2008-08-29 22:45:39 +03001/*
2 * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
3 * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
4 * Copyright (c) 2007-2008 Matthew W. S. Bell <mentor@madwifi.org>
5 * Copyright (c) 2007-2008 Luis Rodriguez <mcgrof@winlab.rutgers.edu>
6 * Copyright (c) 2007-2008 Pavel Roskin <proski@gnu.org>
7 * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
8 *
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 *
21 */
22
23/*********************************\
24* Protocol Control Unit Functions *
25\*********************************/
26
Luis R. Rodriguezbcd8f542009-09-09 22:43:17 -070027#include <asm/unaligned.h>
28
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030029#include "ath5k.h"
30#include "reg.h"
31#include "debug.h"
32#include "base.h"
33
34/*******************\
35* Generic functions *
36\*******************/
37
38/**
39 * ath5k_hw_set_opmode - Set PCU operating mode
40 *
41 * @ah: The &struct ath5k_hw
Bruno Randolfccfe5552010-03-09 16:55:38 +090042 * @op_mode: &enum nl80211_iftype operating mode
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030043 *
44 * Initialize PCU for the various operating modes (AP/STA etc)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030045 */
Bruno Randolfccfe5552010-03-09 16:55:38 +090046int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030047{
Luis R. Rodriguez954fece2009-09-10 10:51:33 -070048 struct ath_common *common = ath5k_hw_common(ah);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030049 u32 pcu_reg, beacon_reg, low_id, high_id;
50
Bruno Randolfccfe5552010-03-09 16:55:38 +090051 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_MODE, "mode %d\n", op_mode);
Nick Kossifidisf07a6c42008-10-29 04:28:28 +020052
53 /* Preserve rest settings */
54 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
55 pcu_reg &= ~(AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_AP
56 | AR5K_STA_ID1_KEYSRCH_MODE
57 | (ah->ah_version == AR5K_AR5210 ?
58 (AR5K_STA_ID1_PWR_SV | AR5K_STA_ID1_NO_PSPOLL) : 0));
59
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030060 beacon_reg = 0;
61
Bruno Randolfccfe5552010-03-09 16:55:38 +090062 switch (op_mode) {
Johannes Berg05c914f2008-09-11 00:01:58 +020063 case NL80211_IFTYPE_ADHOC:
Nick Kossifidisf07a6c42008-10-29 04:28:28 +020064 pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_KEYSRCH_MODE;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030065 beacon_reg |= AR5K_BCR_ADHOC;
Nick Kossifidisf07a6c42008-10-29 04:28:28 +020066 if (ah->ah_version == AR5K_AR5210)
67 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
68 else
Steve Brown4fb74042008-12-23 07:57:05 -050069 AR5K_REG_ENABLE_BITS(ah, AR5K_CFG, AR5K_CFG_IBSS);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030070 break;
71
Johannes Berg05c914f2008-09-11 00:01:58 +020072 case NL80211_IFTYPE_AP:
73 case NL80211_IFTYPE_MESH_POINT:
Nick Kossifidisf07a6c42008-10-29 04:28:28 +020074 pcu_reg |= AR5K_STA_ID1_AP | AR5K_STA_ID1_KEYSRCH_MODE;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030075 beacon_reg |= AR5K_BCR_AP;
Nick Kossifidisf07a6c42008-10-29 04:28:28 +020076 if (ah->ah_version == AR5K_AR5210)
77 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
78 else
Steve Brown4fb74042008-12-23 07:57:05 -050079 AR5K_REG_DISABLE_BITS(ah, AR5K_CFG, AR5K_CFG_IBSS);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030080 break;
81
Johannes Berg05c914f2008-09-11 00:01:58 +020082 case NL80211_IFTYPE_STATION:
Nick Kossifidisf07a6c42008-10-29 04:28:28 +020083 pcu_reg |= AR5K_STA_ID1_KEYSRCH_MODE
84 | (ah->ah_version == AR5K_AR5210 ?
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030085 AR5K_STA_ID1_PWR_SV : 0);
Johannes Berg05c914f2008-09-11 00:01:58 +020086 case NL80211_IFTYPE_MONITOR:
Nick Kossifidisf07a6c42008-10-29 04:28:28 +020087 pcu_reg |= AR5K_STA_ID1_KEYSRCH_MODE
88 | (ah->ah_version == AR5K_AR5210 ?
Nick Kossifidisc6e387a2008-08-29 22:45:39 +030089 AR5K_STA_ID1_NO_PSPOLL : 0);
90 break;
91
92 default:
93 return -EINVAL;
94 }
95
96 /*
97 * Set PCU registers
98 */
Luis R. Rodriguez954fece2009-09-10 10:51:33 -070099 low_id = get_unaligned_le32(common->macaddr);
100 high_id = get_unaligned_le16(common->macaddr + 4);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300101 ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0);
102 ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1);
103
104 /*
105 * Set Beacon Control Register on 5210
106 */
107 if (ah->ah_version == AR5K_AR5210)
108 ath5k_hw_reg_write(ah, beacon_reg, AR5K_BCR);
109
110 return 0;
111}
112
113/**
Bruno Randolf495391d2010-03-25 14:49:36 +0900114 * ath5k_hw_update - Update MIB counters (mac layer statistics)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300115 *
116 * @ah: The &struct ath5k_hw
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300117 *
Bruno Randolf495391d2010-03-25 14:49:36 +0900118 * Reads MIB counters from PCU and updates sw statistics. Is called after a
119 * MIB interrupt, because one of these counters might have reached their maximum
120 * and triggered the MIB interrupt, to let us read and clear the counter.
121 *
122 * Is called in interrupt context!
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300123 */
Bruno Randolf495391d2010-03-25 14:49:36 +0900124void ath5k_hw_update_mib_counters(struct ath5k_hw *ah)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300125{
Bruno Randolf495391d2010-03-25 14:49:36 +0900126 struct ath5k_statistics *stats = &ah->ah_sc->stats;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300127
128 /* Read-And-Clear */
Bruno Randolf495391d2010-03-25 14:49:36 +0900129 stats->ack_fail += ath5k_hw_reg_read(ah, AR5K_ACK_FAIL);
130 stats->rts_fail += ath5k_hw_reg_read(ah, AR5K_RTS_FAIL);
131 stats->rts_ok += ath5k_hw_reg_read(ah, AR5K_RTS_OK);
132 stats->fcs_error += ath5k_hw_reg_read(ah, AR5K_FCS_FAIL);
133 stats->beacons += ath5k_hw_reg_read(ah, AR5K_BEACON_CNT);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300134}
135
136/**
137 * ath5k_hw_set_ack_bitrate - set bitrate for ACKs
138 *
139 * @ah: The &struct ath5k_hw
140 * @high: Flag to determine if we want to use high transmition rate
141 * for ACKs or not
142 *
143 * If high flag is set, we tell hw to use a set of control rates based on
144 * the current transmition rate (check out control_rates array inside reset.c).
145 * If not hw just uses the lowest rate available for the current modulation
146 * scheme being used (1Mbit for CCK and 6Mbits for OFDM).
147 */
148void ath5k_hw_set_ack_bitrate_high(struct ath5k_hw *ah, bool high)
149{
150 if (ah->ah_version != AR5K_AR5212)
151 return;
152 else {
153 u32 val = AR5K_STA_ID1_BASE_RATE_11B | AR5K_STA_ID1_ACKCTS_6MB;
154 if (high)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300155 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, val);
Bruno Randolf0edc9a62010-04-12 16:38:47 +0900156 else
157 AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1, val);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300158 }
159}
160
161
162/******************\
163* ACK/CTS Timeouts *
164\******************/
165
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300166/**
167 * ath5k_hw_set_ack_timeout - Set ACK timeout on PCU
168 *
169 * @ah: The &struct ath5k_hw
170 * @timeout: Timeout in usec
171 */
Pavel Roskin626ede62010-02-18 20:28:02 -0500172static int ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300173{
Lukáš Turek3578e6e2009-12-21 22:50:50 +0100174 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_ACK))
175 <= timeout)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300176 return -EINVAL;
177
178 AR5K_REG_WRITE_BITS(ah, AR5K_TIME_OUT, AR5K_TIME_OUT_ACK,
Lukáš Turek3578e6e2009-12-21 22:50:50 +0100179 ath5k_hw_htoclock(ah, timeout));
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300180
181 return 0;
182}
183
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300184/**
185 * ath5k_hw_set_cts_timeout - Set CTS timeout on PCU
186 *
187 * @ah: The &struct ath5k_hw
188 * @timeout: Timeout in usec
189 */
Pavel Roskin626ede62010-02-18 20:28:02 -0500190static int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300191{
Lukáš Turek3578e6e2009-12-21 22:50:50 +0100192 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_CTS))
193 <= timeout)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300194 return -EINVAL;
195
196 AR5K_REG_WRITE_BITS(ah, AR5K_TIME_OUT, AR5K_TIME_OUT_CTS,
Lukáš Turek3578e6e2009-12-21 22:50:50 +0100197 ath5k_hw_htoclock(ah, timeout));
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300198
199 return 0;
200}
201
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300202/**
Lukáš Turek3578e6e2009-12-21 22:50:50 +0100203 * ath5k_hw_htoclock - Translate usec to hw clock units
204 *
205 * @ah: The &struct ath5k_hw
206 * @usec: value in microseconds
207 */
208unsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec)
209{
210 return usec * ath5k_hw_get_clockrate(ah);
211}
212
213/**
214 * ath5k_hw_clocktoh - Translate hw clock units to usec
215 * @clock: value in hw clock units
216 */
217unsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock)
218{
219 return clock / ath5k_hw_get_clockrate(ah);
220}
221
222/**
223 * ath5k_hw_get_clockrate - Get the clock rate for current mode
224 *
225 * @ah: The &struct ath5k_hw
226 */
227unsigned int ath5k_hw_get_clockrate(struct ath5k_hw *ah)
228{
229 struct ieee80211_channel *channel = ah->ah_current_channel;
230 int clock;
231
232 if (channel->hw_value & CHANNEL_5GHZ)
233 clock = 40; /* 802.11a */
234 else if (channel->hw_value & CHANNEL_CCK)
235 clock = 22; /* 802.11b */
236 else
237 clock = 44; /* 802.11g */
238
239 /* Clock rate in turbo modes is twice the normal rate */
240 if (channel->hw_value & CHANNEL_TURBO)
241 clock *= 2;
242
243 return clock;
244}
245
246/**
Lukáš Turek6e08d222009-12-21 22:50:51 +0100247 * ath5k_hw_get_default_slottime - Get the default slot time for current mode
248 *
249 * @ah: The &struct ath5k_hw
250 */
Pavel Roskin626ede62010-02-18 20:28:02 -0500251static unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah)
Lukáš Turek6e08d222009-12-21 22:50:51 +0100252{
253 struct ieee80211_channel *channel = ah->ah_current_channel;
254
255 if (channel->hw_value & CHANNEL_TURBO)
256 return 6; /* both turbo modes */
257
258 if (channel->hw_value & CHANNEL_CCK)
259 return 20; /* 802.11b */
260
261 return 9; /* 802.11 a/g */
262}
263
264/**
265 * ath5k_hw_get_default_sifs - Get the default SIFS for current mode
266 *
267 * @ah: The &struct ath5k_hw
268 */
Pavel Roskin626ede62010-02-18 20:28:02 -0500269static unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah)
Lukáš Turek6e08d222009-12-21 22:50:51 +0100270{
271 struct ieee80211_channel *channel = ah->ah_current_channel;
272
273 if (channel->hw_value & CHANNEL_TURBO)
274 return 8; /* both turbo modes */
275
276 if (channel->hw_value & CHANNEL_5GHZ)
277 return 16; /* 802.11a */
278
279 return 10; /* 802.11 b/g */
280}
281
282/**
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300283 * ath5k_hw_set_lladdr - Set station id
284 *
285 * @ah: The &struct ath5k_hw
286 * @mac: The card's mac address
287 *
288 * Set station id on hw using the provided mac address
289 */
290int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac)
291{
Luis R. Rodriguez954fece2009-09-10 10:51:33 -0700292 struct ath_common *common = ath5k_hw_common(ah);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300293 u32 low_id, high_id;
Bob Copelandf6bac3e2008-11-26 16:17:11 -0500294 u32 pcu_reg;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300295
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300296 /* Set new station ID */
Luis R. Rodriguez954fece2009-09-10 10:51:33 -0700297 memcpy(common->macaddr, mac, ETH_ALEN);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300298
Bob Copelandf6bac3e2008-11-26 16:17:11 -0500299 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
300
Luis R. Rodriguezbcd8f542009-09-09 22:43:17 -0700301 low_id = get_unaligned_le32(mac);
302 high_id = get_unaligned_le16(mac + 4);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300303
304 ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0);
Bob Copelandf6bac3e2008-11-26 16:17:11 -0500305 ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300306
307 return 0;
308}
309
310/**
311 * ath5k_hw_set_associd - Set BSSID for association
312 *
313 * @ah: The &struct ath5k_hw
314 * @bssid: BSSID
315 * @assoc_id: Assoc id
316 *
317 * Sets the BSSID which trigers the "SME Join" operation
318 */
Luis R. Rodriguezbe5d6b72009-10-06 20:44:31 -0400319void ath5k_hw_set_associd(struct ath5k_hw *ah)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300320{
Luis R. Rodriguez954fece2009-09-10 10:51:33 -0700321 struct ath_common *common = ath5k_hw_common(ah);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300322 u16 tim_offset = 0;
323
324 /*
325 * Set simple BSSID mask on 5212
326 */
Luis R. Rodrigueza72d57a2009-10-06 20:44:29 -0400327 if (ah->ah_version == AR5K_AR5212)
328 ath_hw_setbssidmask(common);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300329
330 /*
331 * Set BSSID which triggers the "SME Join" operation
332 */
Luis R. Rodriguezabba0682009-10-06 20:44:32 -0400333 ath5k_hw_reg_write(ah,
334 get_unaligned_le32(common->curbssid),
Luis R. Rodrigueza3f86bf2009-10-06 20:44:33 -0400335 AR5K_BSS_ID0);
Luis R. Rodriguezabba0682009-10-06 20:44:32 -0400336 ath5k_hw_reg_write(ah,
337 get_unaligned_le16(common->curbssid + 4) |
338 ((common->curaid & 0x3fff) << AR5K_BSS_ID1_AID_S),
Luis R. Rodrigueza3f86bf2009-10-06 20:44:33 -0400339 AR5K_BSS_ID1);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300340
Luis R. Rodriguezbe5d6b72009-10-06 20:44:31 -0400341 if (common->curaid == 0) {
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300342 ath5k_hw_disable_pspoll(ah);
343 return;
344 }
345
346 AR5K_REG_WRITE_BITS(ah, AR5K_BEACON, AR5K_BEACON_TIM,
Luis R. Rodriguezabba0682009-10-06 20:44:32 -0400347 tim_offset ? tim_offset + 4 : 0);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300348
349 ath5k_hw_enable_pspoll(ah, NULL, 0);
350}
351
Luis R. Rodriguez13b81552009-09-10 17:52:45 -0700352void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask)
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300353{
Luis R. Rodriguez954fece2009-09-10 10:51:33 -0700354 struct ath_common *common = ath5k_hw_common(ah);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300355
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200356 /* Cache bssid mask so that we can restore it
357 * on reset */
Luis R. Rodriguez954fece2009-09-10 10:51:33 -0700358 memcpy(common->bssidmask, mask, ETH_ALEN);
Luis R. Rodriguez13b81552009-09-10 17:52:45 -0700359 if (ah->ah_version == AR5K_AR5212)
360 ath_hw_setbssidmask(common);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300361}
362
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300363/************\
364* RX Control *
365\************/
366
367/**
368 * ath5k_hw_start_rx_pcu - Start RX engine
369 *
370 * @ah: The &struct ath5k_hw
371 *
372 * Starts RX engine on PCU so that hw can process RXed frames
373 * (ACK etc).
374 *
375 * NOTE: RX DMA should be already enabled using ath5k_hw_start_rx_dma
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300376 */
377void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah)
378{
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300379 AR5K_REG_DISABLE_BITS(ah, AR5K_DIAG_SW, AR5K_DIAG_SW_DIS_RX);
380}
381
382/**
383 * at5k_hw_stop_rx_pcu - Stop RX engine
384 *
385 * @ah: The &struct ath5k_hw
386 *
387 * Stops RX engine on PCU
388 *
389 * TODO: Detach ANI here
390 */
391void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah)
392{
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300393 AR5K_REG_ENABLE_BITS(ah, AR5K_DIAG_SW, AR5K_DIAG_SW_DIS_RX);
394}
395
396/*
397 * Set multicast filter
398 */
399void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1)
400{
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300401 ath5k_hw_reg_write(ah, filter0, AR5K_MCAST_FILTER0);
402 ath5k_hw_reg_write(ah, filter1, AR5K_MCAST_FILTER1);
403}
404
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300405/**
406 * ath5k_hw_get_rx_filter - Get current rx filter
407 *
408 * @ah: The &struct ath5k_hw
409 *
410 * Returns the RX filter by reading rx filter and
411 * phy error filter registers. RX filter is used
412 * to set the allowed frame types that PCU will accept
413 * and pass to the driver. For a list of frame types
414 * check out reg.h.
415 */
416u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah)
417{
418 u32 data, filter = 0;
419
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300420 filter = ath5k_hw_reg_read(ah, AR5K_RX_FILTER);
421
422 /*Radar detection for 5212*/
423 if (ah->ah_version == AR5K_AR5212) {
424 data = ath5k_hw_reg_read(ah, AR5K_PHY_ERR_FIL);
425
426 if (data & AR5K_PHY_ERR_FIL_RADAR)
427 filter |= AR5K_RX_FILTER_RADARERR;
428 if (data & (AR5K_PHY_ERR_FIL_OFDM | AR5K_PHY_ERR_FIL_CCK))
429 filter |= AR5K_RX_FILTER_PHYERR;
430 }
431
432 return filter;
433}
434
435/**
436 * ath5k_hw_set_rx_filter - Set rx filter
437 *
438 * @ah: The &struct ath5k_hw
439 * @filter: RX filter mask (see reg.h)
440 *
441 * Sets RX filter register and also handles PHY error filter
442 * register on 5212 and newer chips so that we have proper PHY
443 * error reporting.
444 */
445void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter)
446{
447 u32 data = 0;
448
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300449 /* Set PHY error filter register on 5212*/
450 if (ah->ah_version == AR5K_AR5212) {
451 if (filter & AR5K_RX_FILTER_RADARERR)
452 data |= AR5K_PHY_ERR_FIL_RADAR;
453 if (filter & AR5K_RX_FILTER_PHYERR)
454 data |= AR5K_PHY_ERR_FIL_OFDM | AR5K_PHY_ERR_FIL_CCK;
455 }
456
457 /*
458 * The AR5210 uses promiscous mode to detect radar activity
459 */
460 if (ah->ah_version == AR5K_AR5210 &&
461 (filter & AR5K_RX_FILTER_RADARERR)) {
462 filter &= ~AR5K_RX_FILTER_RADARERR;
463 filter |= AR5K_RX_FILTER_PROM;
464 }
465
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200466 /*Zero length DMA (phy error reporting) */
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300467 if (data)
468 AR5K_REG_ENABLE_BITS(ah, AR5K_RXCFG, AR5K_RXCFG_ZLFDMA);
469 else
470 AR5K_REG_DISABLE_BITS(ah, AR5K_RXCFG, AR5K_RXCFG_ZLFDMA);
471
472 /*Write RX Filter register*/
473 ath5k_hw_reg_write(ah, filter & 0xff, AR5K_RX_FILTER);
474
475 /*Write PHY error filter register on 5212*/
476 if (ah->ah_version == AR5K_AR5212)
477 ath5k_hw_reg_write(ah, data, AR5K_PHY_ERR_FIL);
478
479}
480
481
482/****************\
483* Beacon control *
484\****************/
485
Benoit Papillault1c0fc652010-04-16 00:07:26 +0200486#define ATH5K_MAX_TSF_READ 10
487
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300488/**
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300489 * ath5k_hw_get_tsf64 - Get the full 64bit TSF
490 *
491 * @ah: The &struct ath5k_hw
492 *
493 * Returns the current TSF
494 */
495u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah)
496{
Benoit Papillault1c0fc652010-04-16 00:07:26 +0200497 u32 tsf_lower, tsf_upper1, tsf_upper2;
498 int i;
499
500 /*
501 * While reading TSF upper and then lower part, the clock is still
502 * counting (or jumping in case of IBSS merge) so we might get
503 * inconsistent values. To avoid this, we read the upper part again
504 * and check it has not been changed. We make the hypothesis that a
505 * maximum of 3 changes can happens in a row (we use 10 as a safe
506 * value).
507 *
508 * Impact on performance is pretty small, since in most cases, only
509 * 3 register reads are needed.
510 */
511
512 tsf_upper1 = ath5k_hw_reg_read(ah, AR5K_TSF_U32);
513 for (i = 0; i < ATH5K_MAX_TSF_READ; i++) {
514 tsf_lower = ath5k_hw_reg_read(ah, AR5K_TSF_L32);
515 tsf_upper2 = ath5k_hw_reg_read(ah, AR5K_TSF_U32);
516 if (tsf_upper2 == tsf_upper1)
517 break;
518 tsf_upper1 = tsf_upper2;
519 }
520
521 WARN_ON( i == ATH5K_MAX_TSF_READ );
522
Benoit Papillault1c0fc652010-04-16 00:07:26 +0200523 return (((u64)tsf_upper1 << 32) | tsf_lower);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300524}
525
526/**
Alina Friedrichsen8cab7582009-01-23 05:39:13 +0100527 * ath5k_hw_set_tsf64 - Set a new 64bit TSF
528 *
529 * @ah: The &struct ath5k_hw
530 * @tsf64: The new 64bit TSF
531 *
532 * Sets the new TSF
533 */
534void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64)
535{
Alina Friedrichsen8cab7582009-01-23 05:39:13 +0100536 ath5k_hw_reg_write(ah, tsf64 & 0xffffffff, AR5K_TSF_L32);
Alina Friedrichsen0ad65bd2009-03-02 23:29:48 +0100537 ath5k_hw_reg_write(ah, (tsf64 >> 32) & 0xffffffff, AR5K_TSF_U32);
Alina Friedrichsen8cab7582009-01-23 05:39:13 +0100538}
539
540/**
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300541 * ath5k_hw_reset_tsf - Force a TSF reset
542 *
543 * @ah: The &struct ath5k_hw
544 *
545 * Forces a TSF reset on PCU
546 */
547void ath5k_hw_reset_tsf(struct ath5k_hw *ah)
548{
Bob Copeland14be9942008-09-28 12:09:43 -0400549 u32 val;
550
Bob Copeland14be9942008-09-28 12:09:43 -0400551 val = ath5k_hw_reg_read(ah, AR5K_BEACON) | AR5K_BEACON_RESET_TSF;
552
553 /*
554 * Each write to the RESET_TSF bit toggles a hardware internal
555 * signal to reset TSF, but if left high it will cause a TSF reset
556 * on the next chip reset as well. Thus we always write the value
557 * twice to clear the signal.
558 */
559 ath5k_hw_reg_write(ah, val, AR5K_BEACON);
560 ath5k_hw_reg_write(ah, val, AR5K_BEACON);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300561}
562
563/*
564 * Initialize beacon timers
565 */
566void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
567{
568 u32 timer1, timer2, timer3;
569
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300570 /*
571 * Set the additional timers by mode
572 */
Bruno Randolfccfe5552010-03-09 16:55:38 +0900573 switch (ah->ah_sc->opmode) {
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200574 case NL80211_IFTYPE_MONITOR:
Johannes Berg05c914f2008-09-11 00:01:58 +0200575 case NL80211_IFTYPE_STATION:
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200576 /* In STA mode timer1 is used as next wakeup
577 * timer and timer2 as next CFP duration start
578 * timer. Both in 1/8TUs. */
579 /* TODO: PCF handling */
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300580 if (ah->ah_version == AR5K_AR5210) {
581 timer1 = 0xffffffff;
582 timer2 = 0xffffffff;
583 } else {
584 timer1 = 0x0000ffff;
585 timer2 = 0x0007ffff;
586 }
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200587 /* Mark associated AP as PCF incapable for now */
588 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_PCF);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300589 break;
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200590 case NL80211_IFTYPE_ADHOC:
591 AR5K_REG_ENABLE_BITS(ah, AR5K_TXCFG, AR5K_TXCFG_ADHOC_BCN_ATIM);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300592 default:
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200593 /* On non-STA modes timer1 is used as next DMA
594 * beacon alert (DBA) timer and timer2 as next
595 * software beacon alert. Both in 1/8TUs. */
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300596 timer1 = (next_beacon - AR5K_TUNE_DMA_BEACON_RESP) << 3;
597 timer2 = (next_beacon - AR5K_TUNE_SW_BEACON_RESP) << 3;
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200598 break;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300599 }
600
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200601 /* Timer3 marks the end of our ATIM window
602 * a zero length window is not allowed because
603 * we 'll get no beacons */
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300604 timer3 = next_beacon + (ah->ah_atim_window ? ah->ah_atim_window : 1);
605
606 /*
607 * Set the beacon register and enable all timers.
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300608 */
Nick Kossifidis35edf8a2009-06-12 16:09:53 -0700609 /* When in AP or Mesh Point mode zero timer0 to start TSF */
Bruno Randolfccfe5552010-03-09 16:55:38 +0900610 if (ah->ah_sc->opmode == NL80211_IFTYPE_AP ||
611 ah->ah_sc->opmode == NL80211_IFTYPE_MESH_POINT)
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200612 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0);
Nick Kossifidis428cbd42009-04-30 15:55:47 -0400613
614 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300615 ath5k_hw_reg_write(ah, timer1, AR5K_TIMER1);
616 ath5k_hw_reg_write(ah, timer2, AR5K_TIMER2);
617 ath5k_hw_reg_write(ah, timer3, AR5K_TIMER3);
618
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200619 /* Force a TSF reset if requested and enable beacons */
620 if (interval & AR5K_BEACON_RESET_TSF)
621 ath5k_hw_reset_tsf(ah);
622
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300623 ath5k_hw_reg_write(ah, interval & (AR5K_BEACON_PERIOD |
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200624 AR5K_BEACON_ENABLE),
625 AR5K_BEACON);
626
627 /* Flush any pending BMISS interrupts on ISR by
628 * performing a clear-on-write operation on PISR
629 * register for the BMISS bit (writing a bit on
630 * ISR togles a reset for that bit and leaves
631 * the rest bits intact) */
632 if (ah->ah_version == AR5K_AR5210)
633 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_ISR);
634 else
635 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_PISR);
636
637 /* TODO: Set enchanced sleep registers on AR5212
638 * based on vif->bss_conf params, until then
639 * disable power save reporting.*/
640 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_PWR_SV);
641
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300642}
643
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300644
645/*********************\
646* Key table functions *
647\*********************/
648
649/*
650 * Reset a key entry on the table
651 */
652int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry)
653{
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200654 unsigned int i, type;
Bob Copeland17683c62008-10-29 23:24:26 -0400655 u16 micentry = entry + AR5K_KEYTABLE_MIC_OFFSET;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300656
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300657 AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE);
658
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200659 type = ath5k_hw_reg_read(ah, AR5K_KEYTABLE_TYPE(entry));
660
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300661 for (i = 0; i < AR5K_KEYCACHE_SIZE; i++)
662 ath5k_hw_reg_write(ah, 0, AR5K_KEYTABLE_OFF(entry, i));
663
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200664 /* Reset associated MIC entry if TKIP
665 * is enabled located at offset (entry + 64) */
666 if (type == AR5K_KEYTABLE_TYPE_TKIP) {
Bob Copeland17683c62008-10-29 23:24:26 -0400667 AR5K_ASSERT_ENTRY(micentry, AR5K_KEYTABLE_SIZE);
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200668 for (i = 0; i < AR5K_KEYCACHE_SIZE / 2 ; i++)
Bob Copeland17683c62008-10-29 23:24:26 -0400669 ath5k_hw_reg_write(ah, 0,
670 AR5K_KEYTABLE_OFF(micentry, i));
Nick Kossifidisf07a6c42008-10-29 04:28:28 +0200671 }
672
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300673 /*
674 * Set NULL encryption on AR5212+
675 *
676 * Note: AR5K_KEYTABLE_TYPE -> AR5K_KEYTABLE_OFF(entry, 5)
677 * AR5K_KEYTABLE_TYPE_NULL -> 0x00000007
678 *
679 * Note2: Windows driver (ndiswrapper) sets this to
680 * 0x00000714 instead of 0x00000007
681 */
Jiri Slabyded7a7e2009-04-25 14:09:23 +0200682 if (ah->ah_version >= AR5K_AR5211) {
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300683 ath5k_hw_reg_write(ah, AR5K_KEYTABLE_TYPE_NULL,
684 AR5K_KEYTABLE_TYPE(entry));
685
Bob Copeland17683c62008-10-29 23:24:26 -0400686 if (type == AR5K_KEYTABLE_TYPE_TKIP) {
687 ath5k_hw_reg_write(ah, AR5K_KEYTABLE_TYPE_NULL,
688 AR5K_KEYTABLE_TYPE(micentry));
689 }
690 }
691
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300692 return 0;
693}
694
Bob Copeland67143492008-11-25 20:55:21 -0500695static
696int ath5k_keycache_type(const struct ieee80211_key_conf *key)
697{
Johannes Berg97359d12010-08-10 09:46:38 +0200698 switch (key->cipher) {
699 case WLAN_CIPHER_SUITE_TKIP:
Bob Copeland67143492008-11-25 20:55:21 -0500700 return AR5K_KEYTABLE_TYPE_TKIP;
Johannes Berg97359d12010-08-10 09:46:38 +0200701 case WLAN_CIPHER_SUITE_CCMP:
Bob Copeland67143492008-11-25 20:55:21 -0500702 return AR5K_KEYTABLE_TYPE_CCM;
Johannes Berg97359d12010-08-10 09:46:38 +0200703 case WLAN_CIPHER_SUITE_WEP40:
704 return AR5K_KEYTABLE_TYPE_40;
705 case WLAN_CIPHER_SUITE_WEP104:
706 return AR5K_KEYTABLE_TYPE_104;
Jouni Malinen3cfcf6a2009-01-08 13:32:02 +0200707 default:
708 return -EINVAL;
Bob Copeland67143492008-11-25 20:55:21 -0500709 }
Bob Copeland67143492008-11-25 20:55:21 -0500710}
711
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300712/*
713 * Set a key entry on the table
714 */
715int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry,
716 const struct ieee80211_key_conf *key, const u8 *mac)
717{
718 unsigned int i;
Bob Copeland3f64b432008-10-29 23:19:14 -0400719 int keylen;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300720 __le32 key_v[5] = {};
Bob Copeland3f64b432008-10-29 23:19:14 -0400721 __le32 key0 = 0, key1 = 0;
722 __le32 *rxmic, *txmic;
Roel Kluin672cf3c2009-01-18 23:50:27 +0100723 int keytype;
Bob Copeland3f64b432008-10-29 23:19:14 -0400724 u16 micentry = entry + AR5K_KEYTABLE_MIC_OFFSET;
725 bool is_tkip;
Bob Copeland67143492008-11-25 20:55:21 -0500726 const u8 *key_ptr;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300727
Johannes Berg97359d12010-08-10 09:46:38 +0200728 is_tkip = (key->cipher == WLAN_CIPHER_SUITE_TKIP);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300729
Bob Copeland3f64b432008-10-29 23:19:14 -0400730 /*
731 * key->keylen comes in from mac80211 in bytes.
732 * TKIP is 128 bit + 128 bit mic
733 */
734 keylen = (is_tkip) ? (128 / 8) : key->keylen;
735
736 if (entry > AR5K_KEYTABLE_SIZE ||
737 (is_tkip && micentry > AR5K_KEYTABLE_SIZE))
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300738 return -EOPNOTSUPP;
739
Bob Copeland67143492008-11-25 20:55:21 -0500740 if (unlikely(keylen > 16))
741 return -EOPNOTSUPP;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300742
Bob Copeland67143492008-11-25 20:55:21 -0500743 keytype = ath5k_keycache_type(key);
744 if (keytype < 0)
745 return keytype;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300746
Bob Copeland67143492008-11-25 20:55:21 -0500747 /*
748 * each key block is 6 bytes wide, written as pairs of
749 * alternating 32 and 16 bit le values.
750 */
751 key_ptr = key->key;
752 for (i = 0; keylen >= 6; keylen -= 6) {
753 memcpy(&key_v[i], key_ptr, 6);
754 i += 2;
755 key_ptr += 6;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300756 }
Bob Copeland67143492008-11-25 20:55:21 -0500757 if (keylen)
758 memcpy(&key_v[i], key_ptr, keylen);
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300759
Bob Copeland3f64b432008-10-29 23:19:14 -0400760 /* intentionally corrupt key until mic is installed */
761 if (is_tkip) {
762 key0 = key_v[0] = ~key_v[0];
763 key1 = key_v[1] = ~key_v[1];
764 }
765
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300766 for (i = 0; i < ARRAY_SIZE(key_v); i++)
767 ath5k_hw_reg_write(ah, le32_to_cpu(key_v[i]),
768 AR5K_KEYTABLE_OFF(entry, i));
769
770 ath5k_hw_reg_write(ah, keytype, AR5K_KEYTABLE_TYPE(entry));
771
Bob Copeland3f64b432008-10-29 23:19:14 -0400772 if (is_tkip) {
773 /* Install rx/tx MIC */
774 rxmic = (__le32 *) &key->key[16];
775 txmic = (__le32 *) &key->key[24];
Bob Copelandf6504702008-11-26 16:17:25 -0500776
777 if (ah->ah_combined_mic) {
778 key_v[0] = rxmic[0];
Bob Copeland388cdf32008-12-09 23:05:38 -0500779 key_v[1] = cpu_to_le32(le32_to_cpu(txmic[0]) >> 16);
Bob Copelandf6504702008-11-26 16:17:25 -0500780 key_v[2] = rxmic[1];
Bob Copeland388cdf32008-12-09 23:05:38 -0500781 key_v[3] = cpu_to_le32(le32_to_cpu(txmic[0]) & 0xffff);
Bob Copelandf6504702008-11-26 16:17:25 -0500782 key_v[4] = txmic[1];
783 } else {
784 key_v[0] = rxmic[0];
785 key_v[1] = 0;
786 key_v[2] = rxmic[1];
787 key_v[3] = 0;
788 key_v[4] = 0;
789 }
Bob Copeland3f64b432008-10-29 23:19:14 -0400790 for (i = 0; i < ARRAY_SIZE(key_v); i++)
791 ath5k_hw_reg_write(ah, le32_to_cpu(key_v[i]),
792 AR5K_KEYTABLE_OFF(micentry, i));
793
794 ath5k_hw_reg_write(ah, AR5K_KEYTABLE_TYPE_NULL,
795 AR5K_KEYTABLE_TYPE(micentry));
796 ath5k_hw_reg_write(ah, 0, AR5K_KEYTABLE_MAC0(micentry));
797 ath5k_hw_reg_write(ah, 0, AR5K_KEYTABLE_MAC1(micentry));
798
799 /* restore first 2 words of key */
800 ath5k_hw_reg_write(ah, le32_to_cpu(~key0),
801 AR5K_KEYTABLE_OFF(entry, 0));
802 ath5k_hw_reg_write(ah, le32_to_cpu(~key1),
803 AR5K_KEYTABLE_OFF(entry, 1));
804 }
805
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300806 return ath5k_hw_set_key_lladdr(ah, entry, mac);
807}
808
809int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac)
810{
811 u32 low_id, high_id;
812
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300813 /* Invalid entry (key table overflow) */
814 AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE);
815
Luis R. Rodriguezbcd8f542009-09-09 22:43:17 -0700816 /*
817 * MAC may be NULL if it's a broadcast key. In this case no need to
818 * to compute get_unaligned_le32 and get_unaligned_le16 as we
819 * already know it.
820 */
Johannes Bergdc822b52008-12-29 12:55:09 +0100821 if (!mac) {
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300822 low_id = 0xffffffff;
823 high_id = 0xffff | AR5K_KEYTABLE_VALID;
824 } else {
Luis R. Rodriguezbcd8f542009-09-09 22:43:17 -0700825 low_id = get_unaligned_le32(mac);
826 high_id = get_unaligned_le16(mac + 4) | AR5K_KEYTABLE_VALID;
Nick Kossifidisc6e387a2008-08-29 22:45:39 +0300827 }
828
829 ath5k_hw_reg_write(ah, low_id, AR5K_KEYTABLE_MAC0(entry));
830 ath5k_hw_reg_write(ah, high_id, AR5K_KEYTABLE_MAC1(entry));
831
832 return 0;
833}
834
Lukáš Turek6e08d222009-12-21 22:50:51 +0100835/**
836 * ath5k_hw_set_coverage_class - Set IEEE 802.11 coverage class
837 *
838 * @ah: The &struct ath5k_hw
839 * @coverage_class: IEEE 802.11 coverage class number
840 *
841 * Sets slot time, ACK timeout and CTS timeout for given coverage class.
842 */
843void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class)
844{
845 /* As defined by IEEE 802.11-2007 17.3.8.6 */
846 int slot_time = ath5k_hw_get_default_slottime(ah) + 3 * coverage_class;
847 int ack_timeout = ath5k_hw_get_default_sifs(ah) + slot_time;
848 int cts_timeout = ack_timeout;
849
850 ath5k_hw_set_slot_time(ah, slot_time);
851 ath5k_hw_set_ack_timeout(ah, ack_timeout);
852 ath5k_hw_set_cts_timeout(ah, cts_timeout);
853
854 ah->ah_coverage_class = coverage_class;
855}