wlan.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. /*
  2. * Shared Atheros AR9170 Header
  3. *
  4. * RX/TX meta descriptor format
  5. *
  6. * Copyright 2008, Johannes Berg <[email protected]>
  7. * Copyright 2009-2011 Christian Lamparter <[email protected]>
  8. *
  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.
  12. *
  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.
  17. *
  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/.
  21. *
  22. * This file incorporates work covered by the following copyright and
  23. * permission notice:
  24. * Copyright (c) 2007-2008 Atheros Communications, Inc.
  25. *
  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.
  29. *
  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.
  37. */
  38. #ifndef __CARL9170_SHARED_WLAN_H
  39. #define __CARL9170_SHARED_WLAN_H
  40. #include "fwcmd.h"
  41. #define AR9170_RX_PHY_RATE_CCK_1M 0x0a
  42. #define AR9170_RX_PHY_RATE_CCK_2M 0x14
  43. #define AR9170_RX_PHY_RATE_CCK_5M 0x37
  44. #define AR9170_RX_PHY_RATE_CCK_11M 0x6e
  45. #define AR9170_ENC_ALG_NONE 0x0
  46. #define AR9170_ENC_ALG_WEP64 0x1
  47. #define AR9170_ENC_ALG_TKIP 0x2
  48. #define AR9170_ENC_ALG_AESCCMP 0x4
  49. #define AR9170_ENC_ALG_WEP128 0x5
  50. #define AR9170_ENC_ALG_WEP256 0x6
  51. #define AR9170_ENC_ALG_CENC 0x7
  52. #define AR9170_RX_ENC_SOFTWARE 0x8
  53. #define AR9170_RX_STATUS_MODULATION 0x03
  54. #define AR9170_RX_STATUS_MODULATION_S 0
  55. #define AR9170_RX_STATUS_MODULATION_CCK 0x00
  56. #define AR9170_RX_STATUS_MODULATION_OFDM 0x01
  57. #define AR9170_RX_STATUS_MODULATION_HT 0x02
  58. #define AR9170_RX_STATUS_MODULATION_DUPOFDM 0x03
  59. /* depends on modulation */
  60. #define AR9170_RX_STATUS_SHORT_PREAMBLE 0x08
  61. #define AR9170_RX_STATUS_GREENFIELD 0x08
  62. #define AR9170_RX_STATUS_MPDU 0x30
  63. #define AR9170_RX_STATUS_MPDU_S 4
  64. #define AR9170_RX_STATUS_MPDU_SINGLE 0x00
  65. #define AR9170_RX_STATUS_MPDU_FIRST 0x20
  66. #define AR9170_RX_STATUS_MPDU_MIDDLE 0x30
  67. #define AR9170_RX_STATUS_MPDU_LAST 0x10
  68. #define AR9170_RX_STATUS_CONT_AGGR 0x40
  69. #define AR9170_RX_STATUS_TOTAL_ERROR 0x80
  70. #define AR9170_RX_ERROR_RXTO 0x01
  71. #define AR9170_RX_ERROR_OVERRUN 0x02
  72. #define AR9170_RX_ERROR_DECRYPT 0x04
  73. #define AR9170_RX_ERROR_FCS 0x08
  74. #define AR9170_RX_ERROR_WRONG_RA 0x10
  75. #define AR9170_RX_ERROR_PLCP 0x20
  76. #define AR9170_RX_ERROR_MMIC 0x40
  77. /* these are either-or */
  78. #define AR9170_TX_MAC_PROT_RTS 0x0001
  79. #define AR9170_TX_MAC_PROT_CTS 0x0002
  80. #define AR9170_TX_MAC_PROT 0x0003
  81. #define AR9170_TX_MAC_NO_ACK 0x0004
  82. /* if unset, MAC will only do SIFS space before frame */
  83. #define AR9170_TX_MAC_BACKOFF 0x0008
  84. #define AR9170_TX_MAC_BURST 0x0010
  85. #define AR9170_TX_MAC_AGGR 0x0020
  86. /* encryption is a two-bit field */
  87. #define AR9170_TX_MAC_ENCR_NONE 0x0000
  88. #define AR9170_TX_MAC_ENCR_RC4 0x0040
  89. #define AR9170_TX_MAC_ENCR_CENC 0x0080
  90. #define AR9170_TX_MAC_ENCR_AES 0x00c0
  91. #define AR9170_TX_MAC_MMIC 0x0100
  92. #define AR9170_TX_MAC_HW_DURATION 0x0200
  93. #define AR9170_TX_MAC_QOS_S 10
  94. #define AR9170_TX_MAC_QOS 0x0c00
  95. #define AR9170_TX_MAC_DISABLE_TXOP 0x1000
  96. #define AR9170_TX_MAC_TXOP_RIFS 0x2000
  97. #define AR9170_TX_MAC_IMM_BA 0x4000
  98. /* either-or */
  99. #define AR9170_TX_PHY_MOD_CCK 0x00000000
  100. #define AR9170_TX_PHY_MOD_OFDM 0x00000001
  101. #define AR9170_TX_PHY_MOD_HT 0x00000002
  102. /* depends on modulation */
  103. #define AR9170_TX_PHY_SHORT_PREAMBLE 0x00000004
  104. #define AR9170_TX_PHY_GREENFIELD 0x00000004
  105. #define AR9170_TX_PHY_BW_S 3
  106. #define AR9170_TX_PHY_BW (3 << AR9170_TX_PHY_BW_SHIFT)
  107. #define AR9170_TX_PHY_BW_20MHZ 0
  108. #define AR9170_TX_PHY_BW_40MHZ 2
  109. #define AR9170_TX_PHY_BW_40MHZ_DUP 3
  110. #define AR9170_TX_PHY_TX_HEAVY_CLIP_S 6
  111. #define AR9170_TX_PHY_TX_HEAVY_CLIP (7 << \
  112. AR9170_TX_PHY_TX_HEAVY_CLIP_S)
  113. #define AR9170_TX_PHY_TX_PWR_S 9
  114. #define AR9170_TX_PHY_TX_PWR (0x3f << \
  115. AR9170_TX_PHY_TX_PWR_S)
  116. #define AR9170_TX_PHY_TXCHAIN_S 15
  117. #define AR9170_TX_PHY_TXCHAIN (7 << \
  118. AR9170_TX_PHY_TXCHAIN_S)
  119. #define AR9170_TX_PHY_TXCHAIN_1 1
  120. /* use for cck, ofdm 6/9/12/18/24 and HT if capable */
  121. #define AR9170_TX_PHY_TXCHAIN_2 5
  122. #define AR9170_TX_PHY_MCS_S 18
  123. #define AR9170_TX_PHY_MCS (0x7f << \
  124. AR9170_TX_PHY_MCS_S)
  125. #define AR9170_TX_PHY_RATE_CCK_1M 0x0
  126. #define AR9170_TX_PHY_RATE_CCK_2M 0x1
  127. #define AR9170_TX_PHY_RATE_CCK_5M 0x2
  128. #define AR9170_TX_PHY_RATE_CCK_11M 0x3
  129. /* same as AR9170_RX_PHY_RATE */
  130. #define AR9170_TXRX_PHY_RATE_OFDM_6M 0xb
  131. #define AR9170_TXRX_PHY_RATE_OFDM_9M 0xf
  132. #define AR9170_TXRX_PHY_RATE_OFDM_12M 0xa
  133. #define AR9170_TXRX_PHY_RATE_OFDM_18M 0xe
  134. #define AR9170_TXRX_PHY_RATE_OFDM_24M 0x9
  135. #define AR9170_TXRX_PHY_RATE_OFDM_36M 0xd
  136. #define AR9170_TXRX_PHY_RATE_OFDM_48M 0x8
  137. #define AR9170_TXRX_PHY_RATE_OFDM_54M 0xc
  138. #define AR9170_TXRX_PHY_RATE_HT_MCS0 0x0
  139. #define AR9170_TXRX_PHY_RATE_HT_MCS1 0x1
  140. #define AR9170_TXRX_PHY_RATE_HT_MCS2 0x2
  141. #define AR9170_TXRX_PHY_RATE_HT_MCS3 0x3
  142. #define AR9170_TXRX_PHY_RATE_HT_MCS4 0x4
  143. #define AR9170_TXRX_PHY_RATE_HT_MCS5 0x5
  144. #define AR9170_TXRX_PHY_RATE_HT_MCS6 0x6
  145. #define AR9170_TXRX_PHY_RATE_HT_MCS7 0x7
  146. #define AR9170_TXRX_PHY_RATE_HT_MCS8 0x8
  147. #define AR9170_TXRX_PHY_RATE_HT_MCS9 0x9
  148. #define AR9170_TXRX_PHY_RATE_HT_MCS10 0xa
  149. #define AR9170_TXRX_PHY_RATE_HT_MCS11 0xb
  150. #define AR9170_TXRX_PHY_RATE_HT_MCS12 0xc
  151. #define AR9170_TXRX_PHY_RATE_HT_MCS13 0xd
  152. #define AR9170_TXRX_PHY_RATE_HT_MCS14 0xe
  153. #define AR9170_TXRX_PHY_RATE_HT_MCS15 0xf
  154. #define AR9170_TX_PHY_SHORT_GI 0x80000000
  155. #ifdef __CARL9170FW__
  156. struct ar9170_tx_hw_mac_control {
  157. union {
  158. struct {
  159. /*
  160. * Beware of compiler bugs in all gcc pre 4.4!
  161. */
  162. u8 erp_prot:2;
  163. u8 no_ack:1;
  164. u8 backoff:1;
  165. u8 burst:1;
  166. u8 ampdu:1;
  167. u8 enc_mode:2;
  168. u8 hw_mmic:1;
  169. u8 hw_duration:1;
  170. u8 qos_queue:2;
  171. u8 disable_txop:1;
  172. u8 txop_rifs:1;
  173. u8 ba_end:1;
  174. u8 probe:1;
  175. } __packed;
  176. __le16 set;
  177. } __packed;
  178. } __packed;
  179. struct ar9170_tx_hw_phy_control {
  180. union {
  181. struct {
  182. /*
  183. * Beware of compiler bugs in all gcc pre 4.4!
  184. */
  185. u8 modulation:2;
  186. u8 preamble:1;
  187. u8 bandwidth:2;
  188. u8:1;
  189. u8 heavy_clip:3;
  190. u8 tx_power:6;
  191. u8 chains:3;
  192. u8 mcs:7;
  193. u8:6;
  194. u8 short_gi:1;
  195. } __packed;
  196. __le32 set;
  197. } __packed;
  198. } __packed;
  199. struct ar9170_tx_rate_info {
  200. u8 tries:3;
  201. u8 erp_prot:2;
  202. u8 ampdu:1;
  203. u8 free:2; /* free for use (e.g.:RIFS/TXOP/AMPDU) */
  204. } __packed;
  205. struct carl9170_tx_superdesc {
  206. __le16 len;
  207. u8 rix;
  208. u8 cnt;
  209. u8 cookie;
  210. u8 ampdu_density:3;
  211. u8 ampdu_factor:2;
  212. u8 ampdu_commit_density:1;
  213. u8 ampdu_commit_factor:1;
  214. u8 ampdu_unused_bit:1;
  215. u8 queue:2;
  216. u8 assign_seq:1;
  217. u8 vif_id:3;
  218. u8 fill_in_tsf:1;
  219. u8 cab:1;
  220. u8 padding2;
  221. struct ar9170_tx_rate_info ri[CARL9170_TX_MAX_RATES];
  222. struct ar9170_tx_hw_phy_control rr[CARL9170_TX_MAX_RETRY_RATES];
  223. } __packed;
  224. struct ar9170_tx_hwdesc {
  225. __le16 length;
  226. struct ar9170_tx_hw_mac_control mac;
  227. struct ar9170_tx_hw_phy_control phy;
  228. } __packed;
  229. struct ar9170_tx_frame {
  230. struct ar9170_tx_hwdesc hdr;
  231. union {
  232. struct ieee80211_hdr i3e;
  233. u8 payload[0];
  234. } data;
  235. } __packed;
  236. struct carl9170_tx_superframe {
  237. struct carl9170_tx_superdesc s;
  238. struct ar9170_tx_frame f;
  239. } __packed __aligned(4);
  240. #endif /* __CARL9170FW__ */
  241. struct _ar9170_tx_hwdesc {
  242. __le16 length;
  243. __le16 mac_control;
  244. __le32 phy_control;
  245. } __packed;
  246. #define CARL9170_TX_SUPER_AMPDU_DENSITY_S 0
  247. #define CARL9170_TX_SUPER_AMPDU_DENSITY 0x7
  248. #define CARL9170_TX_SUPER_AMPDU_FACTOR 0x18
  249. #define CARL9170_TX_SUPER_AMPDU_FACTOR_S 3
  250. #define CARL9170_TX_SUPER_AMPDU_COMMIT_DENSITY 0x20
  251. #define CARL9170_TX_SUPER_AMPDU_COMMIT_DENSITY_S 5
  252. #define CARL9170_TX_SUPER_AMPDU_COMMIT_FACTOR 0x40
  253. #define CARL9170_TX_SUPER_AMPDU_COMMIT_FACTOR_S 6
  254. #define CARL9170_TX_SUPER_MISC_QUEUE 0x3
  255. #define CARL9170_TX_SUPER_MISC_QUEUE_S 0
  256. #define CARL9170_TX_SUPER_MISC_ASSIGN_SEQ 0x4
  257. #define CARL9170_TX_SUPER_MISC_VIF_ID 0x38
  258. #define CARL9170_TX_SUPER_MISC_VIF_ID_S 3
  259. #define CARL9170_TX_SUPER_MISC_FILL_IN_TSF 0x40
  260. #define CARL9170_TX_SUPER_MISC_CAB 0x80
  261. #define CARL9170_TX_SUPER_RI_TRIES 0x7
  262. #define CARL9170_TX_SUPER_RI_TRIES_S 0
  263. #define CARL9170_TX_SUPER_RI_ERP_PROT 0x18
  264. #define CARL9170_TX_SUPER_RI_ERP_PROT_S 3
  265. #define CARL9170_TX_SUPER_RI_AMPDU 0x20
  266. #define CARL9170_TX_SUPER_RI_AMPDU_S 5
  267. struct _carl9170_tx_superdesc {
  268. __le16 len;
  269. u8 rix;
  270. u8 cnt;
  271. u8 cookie;
  272. u8 ampdu_settings;
  273. u8 misc;
  274. u8 padding;
  275. u8 ri[CARL9170_TX_MAX_RATES];
  276. __le32 rr[CARL9170_TX_MAX_RETRY_RATES];
  277. } __packed;
  278. struct _carl9170_tx_superframe {
  279. struct _carl9170_tx_superdesc s;
  280. struct _ar9170_tx_hwdesc f;
  281. u8 frame_data[];
  282. } __packed __aligned(4);
  283. #define CARL9170_TX_SUPERDESC_LEN 24
  284. #define AR9170_TX_HWDESC_LEN 8
  285. #define CARL9170_TX_SUPERFRAME_LEN (CARL9170_TX_SUPERDESC_LEN + \
  286. AR9170_TX_HWDESC_LEN)
  287. struct ar9170_rx_head {
  288. u8 plcp[12];
  289. } __packed;
  290. #define AR9170_RX_HEAD_LEN 12
  291. struct ar9170_rx_phystatus {
  292. union {
  293. struct {
  294. u8 rssi_ant0, rssi_ant1, rssi_ant2,
  295. rssi_ant0x, rssi_ant1x, rssi_ant2x,
  296. rssi_combined;
  297. } __packed;
  298. u8 rssi[7];
  299. } __packed;
  300. u8 evm_stream0[6], evm_stream1[6];
  301. u8 phy_err;
  302. } __packed;
  303. #define AR9170_RX_PHYSTATUS_LEN 20
  304. struct ar9170_rx_macstatus {
  305. u8 SAidx, DAidx;
  306. u8 error;
  307. u8 status;
  308. } __packed;
  309. #define AR9170_RX_MACSTATUS_LEN 4
  310. struct ar9170_rx_frame_single {
  311. struct ar9170_rx_head phy_head;
  312. struct ieee80211_hdr i3e __packed __aligned(2);
  313. struct ar9170_rx_phystatus phy_tail;
  314. struct ar9170_rx_macstatus macstatus;
  315. };
  316. struct ar9170_rx_frame_head {
  317. struct ar9170_rx_head phy_head;
  318. struct ieee80211_hdr i3e __packed __aligned(2);
  319. struct ar9170_rx_macstatus macstatus;
  320. };
  321. struct ar9170_rx_frame_middle {
  322. struct ieee80211_hdr i3e __packed __aligned(2);
  323. struct ar9170_rx_macstatus macstatus;
  324. };
  325. struct ar9170_rx_frame_tail {
  326. struct ieee80211_hdr i3e __packed __aligned(2);
  327. struct ar9170_rx_phystatus phy_tail;
  328. struct ar9170_rx_macstatus macstatus;
  329. };
  330. struct ar9170_rx_frame {
  331. union {
  332. struct ar9170_rx_frame_single single;
  333. struct ar9170_rx_frame_head head;
  334. struct ar9170_rx_frame_middle middle;
  335. struct ar9170_rx_frame_tail tail;
  336. };
  337. };
  338. static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_macstatus *t)
  339. {
  340. return (t->SAidx & 0xc0) >> 4 |
  341. (t->DAidx & 0xc0) >> 6;
  342. }
  343. /*
  344. * This is an workaround for several undocumented bugs.
  345. * Don't mess with the QoS/AC <-> HW Queue map, if you don't
  346. * know what you are doing.
  347. *
  348. * Known problems [hardware]:
  349. * * The MAC does not aggregate frames on anything other
  350. * than the first HW queue.
  351. * * when an AMPDU is placed [in the first hw queue] and
  352. * additional frames are already queued on a different
  353. * hw queue, the MAC will ALWAYS freeze.
  354. *
  355. * In a nutshell: The hardware can either do QoS or
  356. * Aggregation but not both at the same time. As a
  357. * result, this makes the device pretty much useless
  358. * for any serious 802.11n setup.
  359. */
  360. enum ar9170_txq {
  361. AR9170_TXQ_BK = 0, /* TXQ0 */
  362. AR9170_TXQ_BE, /* TXQ1 */
  363. AR9170_TXQ_VI, /* TXQ2 */
  364. AR9170_TXQ_VO, /* TXQ3 */
  365. __AR9170_NUM_TXQ,
  366. };
  367. #define AR9170_TXQ_DEPTH 32
  368. #endif /* __CARL9170_SHARED_WLAN_H */