2 * Atheros AR9170 driver
4 * Hardware-specific definitions
6 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
7 * Copyright 2009, 2010, Christian Lamparter <chunkeey@googlemail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, see
20 * http://www.gnu.org/licenses/.
22 * This file incorporates work covered by the following copyright and
24 * Copyright (c) 2007-2008 Atheros Communications, Inc.
26 * Permission to use, copy, modify, and/or distribute this software for any
27 * purpose with or without fee is hereby granted, provided that the above
28 * copyright notice and this permission notice appear in all copies.
30 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
31 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
33 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
34 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
35 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
36 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
39 #ifndef __CARL9170_SHARED_WLAN_H
40 #define __CARL9170_SHARED_WLAN_H
44 #define AR9170_RX_PHY_RATE_CCK_1M 0x0a
45 #define AR9170_RX_PHY_RATE_CCK_2M 0x14
46 #define AR9170_RX_PHY_RATE_CCK_5M 0x37
47 #define AR9170_RX_PHY_RATE_CCK_11M 0x6e
49 #define AR9170_ENC_ALG_NONE 0x0
50 #define AR9170_ENC_ALG_WEP64 0x1
51 #define AR9170_ENC_ALG_TKIP 0x2
52 #define AR9170_ENC_ALG_AESCCMP 0x4
53 #define AR9170_ENC_ALG_WEP128 0x5
54 #define AR9170_ENC_ALG_WEP256 0x6
55 #define AR9170_ENC_ALG_CENC 0x7
57 #define AR9170_RX_ENC_SOFTWARE 0x8
59 #define AR9170_RX_STATUS_MODULATION_MASK 0x03
60 #define AR9170_RX_STATUS_MODULATION_CCK 0x00
61 #define AR9170_RX_STATUS_MODULATION_OFDM 0x01
62 #define AR9170_RX_STATUS_MODULATION_HT 0x02
63 #define AR9170_RX_STATUS_MODULATION_DUPOFDM 0x03
65 /* depends on modulation */
66 #define AR9170_RX_STATUS_SHORT_PREAMBLE 0x08
67 #define AR9170_RX_STATUS_GREENFIELD 0x08
69 #define AR9170_RX_STATUS_MPDU_MASK 0x30
70 #define AR9170_RX_STATUS_MPDU_SINGLE 0x00
71 #define AR9170_RX_STATUS_MPDU_FIRST 0x20
72 #define AR9170_RX_STATUS_MPDU_MIDDLE 0x30
73 #define AR9170_RX_STATUS_MPDU_LAST 0x10
75 #define AR9170_RX_ERROR_RXTO 0x01
76 #define AR9170_RX_ERROR_OVERRUN 0x02
77 #define AR9170_RX_ERROR_DECRYPT 0x04
78 #define AR9170_RX_ERROR_FCS 0x08
79 #define AR9170_RX_ERROR_WRONG_RA 0x10
80 #define AR9170_RX_ERROR_PLCP 0x20
81 #define AR9170_RX_ERROR_MMIC 0x40
82 #define AR9170_RX_ERROR_FATAL 0x80
84 /* these are either-or */
85 #define AR9170_TX_MAC_PROT_RTS 0x0001
86 #define AR9170_TX_MAC_PROT_CTS 0x0002
87 #define AR9170_TX_MAC_PROT_MASK 0x0003
89 #define AR9170_TX_MAC_NO_ACK 0x0004
90 /* if unset, MAC will only do SIFS space before frame */
91 #define AR9170_TX_MAC_BACKOFF 0x0008
92 #define AR9170_TX_MAC_BURST 0x0010
93 #define AR9170_TX_MAC_AGGR 0x0020
95 /* encryption is a two-bit field */
96 #define AR9170_TX_MAC_ENCR_NONE 0x0000
97 #define AR9170_TX_MAC_ENCR_RC4 0x0040
98 #define AR9170_TX_MAC_ENCR_CENC 0x0080
99 #define AR9170_TX_MAC_ENCR_AES 0x00c0
101 #define AR9170_TX_MAC_MMIC 0x0100
102 #define AR9170_TX_MAC_HW_DURATION 0x0200
103 #define AR9170_TX_MAC_QOS_S 10
104 #define AR9170_TX_MAC_QOS 0x0c00
105 #define AR9170_TX_MAC_DISABLE_TXOP 0x1000
106 #define AR9170_TX_MAC_TXOP_RIFS 0x2000
107 #define AR9170_TX_MAC_IMM_BA 0x4000
110 #define AR9170_TX_PHY_MOD_CCK 0x00000000
111 #define AR9170_TX_PHY_MOD_OFDM 0x00000001
112 #define AR9170_TX_PHY_MOD_HT 0x00000002
114 /* depends on modulation */
115 #define AR9170_TX_PHY_SHORT_PREAMBLE 0x00000004
116 #define AR9170_TX_PHY_GREENFIELD 0x00000004
118 #define AR9170_TX_PHY_BW_S 3
119 #define AR9170_TX_PHY_BW (3 << AR9170_TX_PHY_BW_SHIFT)
120 #define AR9170_TX_PHY_BW_20MHZ 0
121 #define AR9170_TX_PHY_BW_40MHZ 2
122 #define AR9170_TX_PHY_BW_40MHZ_DUP 3
124 #define AR9170_TX_PHY_TX_HEAVY_CLIP_S 6
125 #define AR9170_TX_PHY_TX_HEAVY_CLIP (7 << \
126 AR9170_TX_PHY_TX_HEAVY_CLIP_S)
128 #define AR9170_TX_PHY_TX_PWR_S 9
129 #define AR9170_TX_PHY_TX_PWR (0x3f << \
130 AR9170_TX_PHY_TX_PWR_S)
132 #define AR9170_TX_PHY_TXCHAIN_S 15
133 #define AR9170_TX_PHY_TXCHAIN (7 << \
134 AR9170_TX_PHY_TXCHAIN_S)
135 #define AR9170_TX_PHY_TXCHAIN_1 1
136 /* use for cck, ofdm 6/9/12/18/24 and HT if capable */
137 #define AR9170_TX_PHY_TXCHAIN_2 5
139 #define AR9170_TX_PHY_MCS_S 18
140 #define AR9170_TX_PHY_MCS (0x7f << \
143 #define AR9170_TX_PHY_RATE_CCK_1M 0x0
144 #define AR9170_TX_PHY_RATE_CCK_2M 0x1
145 #define AR9170_TX_PHY_RATE_CCK_5M 0x2
146 #define AR9170_TX_PHY_RATE_CCK_11M 0x3
148 /* same as AR9170_RX_PHY_RATE */
149 #define AR9170_TXRX_PHY_RATE_OFDM_6M 0xb
150 #define AR9170_TXRX_PHY_RATE_OFDM_9M 0xf
151 #define AR9170_TXRX_PHY_RATE_OFDM_12M 0xa
152 #define AR9170_TXRX_PHY_RATE_OFDM_18M 0xe
153 #define AR9170_TXRX_PHY_RATE_OFDM_24M 0x9
154 #define AR9170_TXRX_PHY_RATE_OFDM_36M 0xd
155 #define AR9170_TXRX_PHY_RATE_OFDM_48M 0x8
156 #define AR9170_TXRX_PHY_RATE_OFDM_54M 0xc
158 #define AR9170_TXRX_PHY_RATE_HT_MCS0 0x0
159 #define AR9170_TXRX_PHY_RATE_HT_MCS1 0x1
160 #define AR9170_TXRX_PHY_RATE_HT_MCS2 0x2
161 #define AR9170_TXRX_PHY_RATE_HT_MCS3 0x3
162 #define AR9170_TXRX_PHY_RATE_HT_MCS4 0x4
163 #define AR9170_TXRX_PHY_RATE_HT_MCS5 0x5
164 #define AR9170_TXRX_PHY_RATE_HT_MCS6 0x6
165 #define AR9170_TXRX_PHY_RATE_HT_MCS7 0x7
166 #define AR9170_TXRX_PHY_RATE_HT_MCS8 0x8
167 #define AR9170_TXRX_PHY_RATE_HT_MCS9 0x9
168 #define AR9170_TXRX_PHY_RATE_HT_MCS10 0xa
169 #define AR9170_TXRX_PHY_RATE_HT_MCS11 0xb
170 #define AR9170_TXRX_PHY_RATE_HT_MCS12 0xc
171 #define AR9170_TXRX_PHY_RATE_HT_MCS13 0xd
172 #define AR9170_TXRX_PHY_RATE_HT_MCS14 0xe
173 #define AR9170_TXRX_PHY_RATE_HT_MCS15 0xf
175 #define AR9170_TX_PHY_SHORT_GI 0x80000000
177 #ifdef __CARL9170FW__
178 struct ar9170_tx_hw_mac_control {
182 * Beware of compiler bugs in all gcc pre 4.4!
209 struct ar9170_tx_hw_phy_control {
213 * Beware of compiler bugs in all gcc pre 4.4!
232 struct carl9170_tx_superdesc {
239 u8 ampdu_commit_density:1;
240 u8 ampdu_commit_factor:1;
241 u8 ampdu_unused_bit:1;
247 u8 tries[CARL9170_TX_MAX_RATES];
248 struct ar9170_tx_hw_phy_control rr[CARL9170_TX_MAX_RETRY_RATES];
251 struct ar9170_tx_hwdesc {
253 struct ar9170_tx_hw_mac_control mac;
254 struct ar9170_tx_hw_phy_control phy;
257 struct ar9170_tx_frame {
258 struct ar9170_tx_hwdesc hdr;
261 struct ieee80211_hdr i3e;
266 struct carl9170_tx_superframe {
267 struct carl9170_tx_superdesc s;
268 struct ar9170_tx_frame f;
271 #endif /* __CARL9170FW__ */
273 struct _ar9170_tx_hwdesc {
279 #define CARL9170_TX_SUPER_AMPDU_DENSITY_S 0
280 #define CARL9170_TX_SUPER_AMPDU_DENSITY 0x7
281 #define CARL9170_TX_SUPER_AMPDU_FACTOR 0x18
282 #define CARL9170_TX_SUPER_AMPDU_FACTOR_S 3
283 #define CARL9170_TX_SUPER_AMPDU_COMMIT_DENSITY 0x20
284 #define CARL9170_TX_SUPER_AMPDU_COMMIT_DENSITY_S 5
285 #define CARL9170_TX_SUPER_AMPDU_COMMIT_FACTOR 0x40
286 #define CARL9170_TX_SUPER_AMPDU_COMMIT_FACTOR_S 6
288 #define CARL9170_TX_SUPER_MISC_QUEUE 0x7
289 #define CARL9170_TX_SUPER_MISC_QUEUE_S 0
290 #define CARL9170_TX_SUPER_MISC_VIF_ID 0x38
291 #define CARL9170_TX_SUPER_MISC_VIF_ID_S 3
292 #define CARL9170_TX_SUPER_MISC_FILL_IN_TSF 0x40
293 #define CARL9170_TX_SUPER_MISC_CAB 0x80
295 struct _carl9170_tx_superdesc {
303 u8 tries[CARL9170_TX_MAX_RATES];
304 __le32 rr[CARL9170_TX_MAX_RETRY_RATES];
307 struct _carl9170_tx_superframe {
308 struct _carl9170_tx_superdesc s;
309 struct _ar9170_tx_hwdesc f;
313 #define CARL9170_TX_SUPERDESC_LEN 24
314 #define AR9170_TX_HWDESC_LEN 8
315 #define AR9170_TX_SUPERFRAME_LEN (CARL9170_TX_HWDESC_LEN + \
316 AR9170_TX_SUPERDESC_LEN)
318 struct ar9170_rx_head {
322 struct ar9170_rx_phystatus {
325 u8 rssi_ant0, rssi_ant1, rssi_ant2,
326 rssi_ant0x, rssi_ant1x, rssi_ant2x,
332 u8 evm_stream0[6], evm_stream1[6];
336 struct ar9170_rx_macstatus {
342 struct ar9170_rx_frame_single {
343 struct ar9170_rx_head phy_head;
344 struct ieee80211_hdr i3e;
345 struct ar9170_rx_phystatus phy_tail;
346 struct ar9170_rx_macstatus macstatus;
349 struct ar9170_rx_frame_head {
350 struct ar9170_rx_head phy_head;
351 struct ieee80211_hdr i3e;
352 struct ar9170_rx_macstatus macstatus;
355 struct ar9170_rx_frame_middle {
356 struct ieee80211_hdr i3e;
357 struct ar9170_rx_macstatus macstatus;
360 struct ar9170_rx_frame_tail {
361 struct ieee80211_hdr i3e;
362 struct ar9170_rx_phystatus phy_tail;
363 struct ar9170_rx_macstatus macstatus;
366 struct ar9170_rx_frame {
368 struct ar9170_rx_frame_single single;
369 struct ar9170_rx_frame_head head;
370 struct ar9170_rx_frame_middle middle;
371 struct ar9170_rx_frame_tail tail;
375 static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_macstatus *t)
377 return (t->SAidx & 0xc0) >> 4 |
378 (t->DAidx & 0xc0) >> 6;
393 static const u8 ar9170_qmap[__AR9170_NUM_TXQ] = { 2, 1, 0, 3 };
395 #define AR9170_TXQ_DEPTH 32
397 #endif /* __CARL9170_SHARED_WLAN_H */