ar5523_hw.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. /*
  2. * Copyright (c) 2006 Damien Bergamini <damien.bergamini@free.fr>
  3. * Copyright (c) 2006 Sam Leffler, Errno Consulting
  4. * Copyright (c) 2007 Christoph Hellwig <hch@lst.de>
  5. * Copyright (c) 2008-2009 Weongyo Jeong <weongyo@freebsd.org>
  6. * Copyright (c) 2012 Pontus Fuchs <pontus.fuchs@gmail.com>
  7. *
  8. * Permission to use, copy, modify, and/or distribute this software for any
  9. * purpose with or without fee is hereby granted, provided that the above
  10. * copyright notice and this permission notice appear in all copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. */
  20. /* all fields are big endian */
  21. struct ar5523_fwblock {
  22. __be32 flags;
  23. #define AR5523_WRITE_BLOCK (1 << 4)
  24. __be32 len;
  25. #define AR5523_MAX_FWBLOCK_SIZE 2048
  26. __be32 total;
  27. __be32 remain;
  28. __be32 rxtotal;
  29. __be32 pad[123];
  30. } __packed;
  31. #define AR5523_MAX_RXCMDSZ 1024
  32. #define AR5523_MAX_TXCMDSZ 1024
  33. struct ar5523_cmd_hdr {
  34. __be32 len;
  35. __be32 code;
  36. /* NB: these are defined for rev 1.5 firmware; rev 1.6 is different */
  37. /* messages from Host -> Target */
  38. #define WDCMSG_HOST_AVAILABLE 0x01
  39. #define WDCMSG_BIND 0x02
  40. #define WDCMSG_TARGET_RESET 0x03
  41. #define WDCMSG_TARGET_GET_CAPABILITY 0x04
  42. #define WDCMSG_TARGET_SET_CONFIG 0x05
  43. #define WDCMSG_TARGET_GET_STATUS 0x06
  44. #define WDCMSG_TARGET_GET_STATS 0x07
  45. #define WDCMSG_TARGET_START 0x08
  46. #define WDCMSG_TARGET_STOP 0x09
  47. #define WDCMSG_TARGET_ENABLE 0x0a
  48. #define WDCMSG_TARGET_DISABLE 0x0b
  49. #define WDCMSG_CREATE_CONNECTION 0x0c
  50. #define WDCMSG_UPDATE_CONNECT_ATTR 0x0d
  51. #define WDCMSG_DELETE_CONNECT 0x0e
  52. #define WDCMSG_SEND 0x0f
  53. #define WDCMSG_FLUSH 0x10
  54. /* messages from Target -> Host */
  55. #define WDCMSG_STATS_UPDATE 0x11
  56. #define WDCMSG_BMISS 0x12
  57. #define WDCMSG_DEVICE_AVAIL 0x13
  58. #define WDCMSG_SEND_COMPLETE 0x14
  59. #define WDCMSG_DATA_AVAIL 0x15
  60. #define WDCMSG_SET_PWR_MODE 0x16
  61. #define WDCMSG_BMISS_ACK 0x17
  62. #define WDCMSG_SET_LED_STEADY 0x18
  63. #define WDCMSG_SET_LED_BLINK 0x19
  64. /* more messages */
  65. #define WDCMSG_SETUP_BEACON_DESC 0x1a
  66. #define WDCMSG_BEACON_INIT 0x1b
  67. #define WDCMSG_RESET_KEY_CACHE 0x1c
  68. #define WDCMSG_RESET_KEY_CACHE_ENTRY 0x1d
  69. #define WDCMSG_SET_KEY_CACHE_ENTRY 0x1e
  70. #define WDCMSG_SET_DECOMP_MASK 0x1f
  71. #define WDCMSG_SET_REGULATORY_DOMAIN 0x20
  72. #define WDCMSG_SET_LED_STATE 0x21
  73. #define WDCMSG_WRITE_ASSOCID 0x22
  74. #define WDCMSG_SET_STA_BEACON_TIMERS 0x23
  75. #define WDCMSG_GET_TSF 0x24
  76. #define WDCMSG_RESET_TSF 0x25
  77. #define WDCMSG_SET_ADHOC_MODE 0x26
  78. #define WDCMSG_SET_BASIC_RATE 0x27
  79. #define WDCMSG_MIB_CONTROL 0x28
  80. #define WDCMSG_GET_CHANNEL_DATA 0x29
  81. #define WDCMSG_GET_CUR_RSSI 0x2a
  82. #define WDCMSG_SET_ANTENNA_SWITCH 0x2b
  83. #define WDCMSG_USE_SHORT_SLOT_TIME 0x2f
  84. #define WDCMSG_SET_POWER_MODE 0x30
  85. #define WDCMSG_SETUP_PSPOLL_DESC 0x31
  86. #define WDCMSG_SET_RX_MULTICAST_FILTER 0x32
  87. #define WDCMSG_RX_FILTER 0x33
  88. #define WDCMSG_PER_CALIBRATION 0x34
  89. #define WDCMSG_RESET 0x35
  90. #define WDCMSG_DISABLE 0x36
  91. #define WDCMSG_PHY_DISABLE 0x37
  92. #define WDCMSG_SET_TX_POWER_LIMIT 0x38
  93. #define WDCMSG_SET_TX_QUEUE_PARAMS 0x39
  94. #define WDCMSG_SETUP_TX_QUEUE 0x3a
  95. #define WDCMSG_RELEASE_TX_QUEUE 0x3b
  96. #define WDCMSG_SET_DEFAULT_KEY 0x43
  97. __u32 priv; /* driver private data,
  98. don't care about endianess */
  99. __be32 magic;
  100. __be32 reserved2[4];
  101. };
  102. struct ar5523_cmd_host_available {
  103. __be32 sw_ver_major;
  104. __be32 sw_ver_minor;
  105. __be32 sw_ver_patch;
  106. __be32 sw_ver_build;
  107. } __packed;
  108. #define ATH_SW_VER_MAJOR 1
  109. #define ATH_SW_VER_MINOR 5
  110. #define ATH_SW_VER_PATCH 0
  111. #define ATH_SW_VER_BUILD 9999
  112. struct ar5523_chunk {
  113. u8 seqnum; /* sequence number for ordering */
  114. u8 flags;
  115. #define UATH_CFLAGS_FINAL 0x01 /* final chunk of a msg */
  116. #define UATH_CFLAGS_RXMSG 0x02 /* chunk contains rx completion */
  117. #define UATH_CFLAGS_DEBUG 0x04 /* for debugging */
  118. __be16 length; /* chunk size in bytes */
  119. /* chunk data follows */
  120. } __packed;
  121. /*
  122. * Message format for a WDCMSG_DATA_AVAIL message from Target to Host.
  123. */
  124. struct ar5523_rx_desc {
  125. __be32 len; /* msg length including header */
  126. __be32 code; /* WDCMSG_DATA_AVAIL */
  127. __be32 gennum; /* generation number */
  128. __be32 status; /* start of RECEIVE_INFO */
  129. #define UATH_STATUS_OK 0
  130. #define UATH_STATUS_STOP_IN_PROGRESS 1
  131. #define UATH_STATUS_CRC_ERR 2
  132. #define UATH_STATUS_PHY_ERR 3
  133. #define UATH_STATUS_DECRYPT_CRC_ERR 4
  134. #define UATH_STATUS_DECRYPT_MIC_ERR 5
  135. #define UATH_STATUS_DECOMP_ERR 6
  136. #define UATH_STATUS_KEY_ERR 7
  137. #define UATH_STATUS_ERR 8
  138. __be32 tstamp_low; /* low-order 32-bits of rx timestamp */
  139. __be32 tstamp_high; /* high-order 32-bits of rx timestamp */
  140. __be32 framelen; /* frame length */
  141. __be32 rate; /* rx rate code */
  142. __be32 antenna;
  143. __be32 rssi;
  144. __be32 channel;
  145. __be32 phyerror;
  146. __be32 connix; /* key table ix for bss traffic */
  147. __be32 decrypterror;
  148. __be32 keycachemiss;
  149. __be32 pad; /* XXX? */
  150. } __packed;
  151. struct ar5523_tx_desc {
  152. __be32 msglen;
  153. u32 msgid; /* msg id (supplied by host) */
  154. __be32 type; /* opcode: WDMSG_SEND or WDCMSG_FLUSH */
  155. __be32 txqid; /* tx queue id and flags */
  156. #define UATH_TXQID_MASK 0x0f
  157. #define UATH_TXQID_MINRATE 0x10 /* use min tx rate */
  158. #define UATH_TXQID_FF 0x20 /* content is fast frame */
  159. __be32 connid; /* tx connection id */
  160. #define UATH_ID_INVALID 0xffffffff /* for sending prior to connection */
  161. __be32 flags; /* non-zero if response desired */
  162. #define UATH_TX_NOTIFY (1 << 24) /* f/w will send a UATH_NOTIF_TX */
  163. __be32 buflen; /* payload length */
  164. } __packed;
  165. #define AR5523_ID_BSS 2
  166. #define AR5523_ID_BROADCAST 0xffffffff
  167. /* structure for command UATH_CMD_WRITE_MAC */
  168. struct ar5523_write_mac {
  169. __be32 reg;
  170. __be32 len;
  171. u8 data[32];
  172. } __packed;
  173. struct ar5523_cmd_rateset {
  174. __u8 length;
  175. #define AR5523_MAX_NRATES 32
  176. __u8 set[AR5523_MAX_NRATES];
  177. };
  178. struct ar5523_cmd_set_associd { /* AR5523_WRITE_ASSOCID */
  179. __be32 defaultrateix;
  180. __be32 associd;
  181. __be32 timoffset;
  182. __be32 turboprime;
  183. __u8 bssid[6];
  184. } __packed;
  185. /* structure for command WDCMSG_RESET */
  186. struct ar5523_cmd_reset {
  187. __be32 flags; /* channel flags */
  188. #define UATH_CHAN_TURBO 0x0100
  189. #define UATH_CHAN_CCK 0x0200
  190. #define UATH_CHAN_OFDM 0x0400
  191. #define UATH_CHAN_2GHZ 0x1000
  192. #define UATH_CHAN_5GHZ 0x2000
  193. __be32 freq; /* channel frequency */
  194. __be32 maxrdpower;
  195. __be32 cfgctl;
  196. __be32 twiceantennareduction;
  197. __be32 channelchange;
  198. __be32 keeprccontent;
  199. } __packed;
  200. /* structure for command WDCMSG_SET_BASIC_RATE */
  201. struct ar5523_cmd_rates {
  202. __be32 connid;
  203. __be32 keeprccontent;
  204. __be32 size;
  205. struct ar5523_cmd_rateset rateset;
  206. } __packed;
  207. enum {
  208. WLAN_MODE_NONE = 0,
  209. WLAN_MODE_11b,
  210. WLAN_MODE_11a,
  211. WLAN_MODE_11g,
  212. WLAN_MODE_11a_TURBO,
  213. WLAN_MODE_11g_TURBO,
  214. WLAN_MODE_11a_TURBO_PRIME,
  215. WLAN_MODE_11g_TURBO_PRIME,
  216. WLAN_MODE_11a_XR,
  217. WLAN_MODE_11g_XR,
  218. };
  219. struct ar5523_cmd_connection_attr {
  220. __be32 longpreambleonly;
  221. struct ar5523_cmd_rateset rateset;
  222. __be32 wlanmode;
  223. } __packed;
  224. /* structure for command AR5523_CREATE_CONNECTION */
  225. struct ar5523_cmd_create_connection {
  226. __be32 connid;
  227. __be32 bssid;
  228. __be32 size;
  229. struct ar5523_cmd_connection_attr connattr;
  230. } __packed;
  231. struct ar5523_cmd_ledsteady { /* WDCMSG_SET_LED_STEADY */
  232. __be32 lednum;
  233. #define UATH_LED_LINK 0
  234. #define UATH_LED_ACTIVITY 1
  235. __be32 ledmode;
  236. #define UATH_LED_OFF 0
  237. #define UATH_LED_ON 1
  238. } __packed;
  239. struct ar5523_cmd_ledblink { /* WDCMSG_SET_LED_BLINK */
  240. __be32 lednum;
  241. __be32 ledmode;
  242. __be32 blinkrate;
  243. __be32 slowmode;
  244. } __packed;
  245. struct ar5523_cmd_ledstate { /* WDCMSG_SET_LED_STATE */
  246. __be32 connected;
  247. } __packed;
  248. struct ar5523_cmd_txq_attr {
  249. __be32 priority;
  250. __be32 aifs;
  251. __be32 logcwmin;
  252. __be32 logcwmax;
  253. __be32 bursttime;
  254. __be32 mode;
  255. __be32 qflags;
  256. } __packed;
  257. struct ar5523_cmd_txq_setup { /* WDCMSG_SETUP_TX_QUEUE */
  258. __be32 qid;
  259. __be32 len;
  260. struct ar5523_cmd_txq_attr attr;
  261. } __packed;
  262. struct ar5523_cmd_rx_filter { /* WDCMSG_RX_FILTER */
  263. __be32 bits;
  264. #define UATH_FILTER_RX_UCAST 0x00000001
  265. #define UATH_FILTER_RX_MCAST 0x00000002
  266. #define UATH_FILTER_RX_BCAST 0x00000004
  267. #define UATH_FILTER_RX_CONTROL 0x00000008
  268. #define UATH_FILTER_RX_BEACON 0x00000010 /* beacon frames */
  269. #define UATH_FILTER_RX_PROM 0x00000020 /* promiscuous mode */
  270. #define UATH_FILTER_RX_PHY_ERR 0x00000040 /* phy errors */
  271. #define UATH_FILTER_RX_PHY_RADAR 0x00000080 /* radar phy errors */
  272. #define UATH_FILTER_RX_XR_POOL 0x00000400 /* XR group polls */
  273. #define UATH_FILTER_RX_PROBE_REQ 0x00000800
  274. __be32 op;
  275. #define UATH_FILTER_OP_INIT 0x0
  276. #define UATH_FILTER_OP_SET 0x1
  277. #define UATH_FILTER_OP_CLEAR 0x2
  278. #define UATH_FILTER_OP_TEMP 0x3
  279. #define UATH_FILTER_OP_RESTORE 0x4
  280. } __packed;
  281. enum {
  282. CFG_NONE, /* Sentinal to indicate "no config" */
  283. CFG_REG_DOMAIN, /* Regulatory Domain */
  284. CFG_RATE_CONTROL_ENABLE,
  285. CFG_DEF_XMIT_DATA_RATE, /* NB: if rate control is not enabled */
  286. CFG_HW_TX_RETRIES,
  287. CFG_SW_TX_RETRIES,
  288. CFG_SLOW_CLOCK_ENABLE,
  289. CFG_COMP_PROC,
  290. CFG_USER_RTS_THRESHOLD,
  291. CFG_XR2NORM_RATE_THRESHOLD,
  292. CFG_XRMODE_SWITCH_COUNT,
  293. CFG_PROTECTION_TYPE,
  294. CFG_BURST_SEQ_THRESHOLD,
  295. CFG_ABOLT,
  296. CFG_IQ_LOG_COUNT_MAX,
  297. CFG_MODE_CTS,
  298. CFG_WME_ENABLED,
  299. CFG_GPRS_CBR_PERIOD,
  300. CFG_SERVICE_TYPE,
  301. /* MAC Address to use. Overrides EEPROM */
  302. CFG_MAC_ADDR,
  303. CFG_DEBUG_EAR,
  304. CFG_INIT_REGS,
  305. /* An ID for use in error & debug messages */
  306. CFG_DEBUG_ID,
  307. CFG_COMP_WIN_SZ,
  308. CFG_DIVERSITY_CTL,
  309. CFG_TP_SCALE,
  310. CFG_TPC_HALF_DBM5,
  311. CFG_TPC_HALF_DBM2,
  312. CFG_OVERRD_TX_POWER,
  313. CFG_USE_32KHZ_CLOCK,
  314. CFG_GMODE_PROTECTION,
  315. CFG_GMODE_PROTECT_RATE_INDEX,
  316. CFG_GMODE_NON_ERP_PREAMBLE,
  317. CFG_WDC_TRANSPORT_CHUNK_SIZE,
  318. };
  319. enum {
  320. /* Sentinal to indicate "no capability" */
  321. CAP_NONE,
  322. CAP_ALL, /* ALL capabilities */
  323. CAP_TARGET_VERSION,
  324. CAP_TARGET_REVISION,
  325. CAP_MAC_VERSION,
  326. CAP_MAC_REVISION,
  327. CAP_PHY_REVISION,
  328. CAP_ANALOG_5GHz_REVISION,
  329. CAP_ANALOG_2GHz_REVISION,
  330. /* Target supports WDC message debug features */
  331. CAP_DEBUG_WDCMSG_SUPPORT,
  332. CAP_REG_DOMAIN,
  333. CAP_COUNTRY_CODE,
  334. CAP_REG_CAP_BITS,
  335. CAP_WIRELESS_MODES,
  336. CAP_CHAN_SPREAD_SUPPORT,
  337. CAP_SLEEP_AFTER_BEACON_BROKEN,
  338. CAP_COMPRESS_SUPPORT,
  339. CAP_BURST_SUPPORT,
  340. CAP_FAST_FRAMES_SUPPORT,
  341. CAP_CHAP_TUNING_SUPPORT,
  342. CAP_TURBOG_SUPPORT,
  343. CAP_TURBO_PRIME_SUPPORT,
  344. CAP_DEVICE_TYPE,
  345. CAP_XR_SUPPORT,
  346. CAP_WME_SUPPORT,
  347. CAP_TOTAL_QUEUES,
  348. CAP_CONNECTION_ID_MAX, /* Should absorb CAP_KEY_CACHE_SIZE */
  349. CAP_LOW_5GHZ_CHAN,
  350. CAP_HIGH_5GHZ_CHAN,
  351. CAP_LOW_2GHZ_CHAN,
  352. CAP_HIGH_2GHZ_CHAN,
  353. CAP_MIC_AES_CCM,
  354. CAP_MIC_CKIP,
  355. CAP_MIC_TKIP,
  356. CAP_MIC_TKIP_WME,
  357. CAP_CIPHER_AES_CCM,
  358. CAP_CIPHER_CKIP,
  359. CAP_CIPHER_TKIP,
  360. CAP_TWICE_ANTENNAGAIN_5G,
  361. CAP_TWICE_ANTENNAGAIN_2G,
  362. };
  363. enum {
  364. ST_NONE, /* Sentinal to indicate "no status" */
  365. ST_ALL,
  366. ST_SERVICE_TYPE,
  367. ST_WLAN_MODE,
  368. ST_FREQ,
  369. ST_BAND,
  370. ST_LAST_RSSI,
  371. ST_PS_FRAMES_DROPPED,
  372. ST_CACHED_DEF_ANT,
  373. ST_COUNT_OTHER_RX_ANT,
  374. ST_USE_FAST_DIVERSITY,
  375. ST_MAC_ADDR,
  376. ST_RX_GENERATION_NUM,
  377. ST_TX_QUEUE_DEPTH,
  378. ST_SERIAL_NUMBER,
  379. ST_WDC_TRANSPORT_CHUNK_SIZE,
  380. };
  381. enum {
  382. TARGET_DEVICE_AWAKE,
  383. TARGET_DEVICE_SLEEP,
  384. TARGET_DEVICE_PWRDN,
  385. TARGET_DEVICE_PWRSAVE,
  386. TARGET_DEVICE_SUSPEND,
  387. TARGET_DEVICE_RESUME,
  388. };
  389. /* this is in net/ieee80211.h, but that conflicts with the mac80211 headers */
  390. #define IEEE80211_2ADDR_LEN 16
  391. #define AR5523_MIN_RXBUFSZ \
  392. (((sizeof(__be32) + IEEE80211_2ADDR_LEN + \
  393. sizeof(struct ar5523_rx_desc)) + 3) & ~3)