iwl-4965-commands.h 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called LICENSE.GPL.
  26. *
  27. * Contact Information:
  28. * James P. Ketrenos <ipw2100-admin@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *
  62. *****************************************************************************/
  63. /*
  64. * Please use this file (iwl-4965-commands.h) only for uCode API definitions.
  65. * Please use iwl-4965-hw.h for hardware-related definitions.
  66. * Please use iwl-4965.h for driver implementation definitions.
  67. */
  68. #ifndef __iwl4965_commands_h__
  69. #define __iwl4965_commands_h__
  70. enum {
  71. REPLY_ALIVE = 0x1,
  72. REPLY_ERROR = 0x2,
  73. /* RXON and QOS commands */
  74. REPLY_RXON = 0x10,
  75. REPLY_RXON_ASSOC = 0x11,
  76. REPLY_QOS_PARAM = 0x13,
  77. REPLY_RXON_TIMING = 0x14,
  78. /* Multi-Station support */
  79. REPLY_ADD_STA = 0x18,
  80. REPLY_REMOVE_STA = 0x19, /* not used */
  81. REPLY_REMOVE_ALL_STA = 0x1a, /* not used */
  82. /* RX, TX, LEDs */
  83. REPLY_TX = 0x1c,
  84. REPLY_RATE_SCALE = 0x47, /* 3945 only */
  85. REPLY_LEDS_CMD = 0x48,
  86. REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */
  87. /* 802.11h related */
  88. RADAR_NOTIFICATION = 0x70, /* not used */
  89. REPLY_QUIET_CMD = 0x71, /* not used */
  90. REPLY_CHANNEL_SWITCH = 0x72,
  91. CHANNEL_SWITCH_NOTIFICATION = 0x73,
  92. REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
  93. SPECTRUM_MEASURE_NOTIFICATION = 0x75,
  94. /* Power Management */
  95. POWER_TABLE_CMD = 0x77,
  96. PM_SLEEP_NOTIFICATION = 0x7A,
  97. PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
  98. /* Scan commands and notifications */
  99. REPLY_SCAN_CMD = 0x80,
  100. REPLY_SCAN_ABORT_CMD = 0x81,
  101. SCAN_START_NOTIFICATION = 0x82,
  102. SCAN_RESULTS_NOTIFICATION = 0x83,
  103. SCAN_COMPLETE_NOTIFICATION = 0x84,
  104. /* IBSS/AP commands */
  105. BEACON_NOTIFICATION = 0x90,
  106. REPLY_TX_BEACON = 0x91,
  107. WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */
  108. /* Miscellaneous commands */
  109. QUIET_NOTIFICATION = 0x96, /* not used */
  110. REPLY_TX_PWR_TABLE_CMD = 0x97,
  111. MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
  112. /* BT config command */
  113. REPLY_BT_CONFIG = 0x9b,
  114. /* 4965 Statistics */
  115. REPLY_STATISTICS_CMD = 0x9c,
  116. STATISTICS_NOTIFICATION = 0x9d,
  117. /* RF-KILL commands and notifications */
  118. REPLY_CARD_STATE_CMD = 0xa0,
  119. CARD_STATE_NOTIFICATION = 0xa1,
  120. /* Missed beacons notification */
  121. MISSED_BEACONS_NOTIFICATION = 0xa2,
  122. REPLY_CT_KILL_CONFIG_CMD = 0xa4,
  123. SENSITIVITY_CMD = 0xa8,
  124. REPLY_PHY_CALIBRATION_CMD = 0xb0,
  125. REPLY_RX_PHY_CMD = 0xc0,
  126. REPLY_RX_MPDU_CMD = 0xc1,
  127. REPLY_4965_RX = 0xc3,
  128. REPLY_COMPRESSED_BA = 0xc5,
  129. REPLY_MAX = 0xff
  130. };
  131. /******************************************************************************
  132. * (0)
  133. * Commonly used structures and definitions:
  134. * Command header, rate_n_flags
  135. *
  136. *****************************************************************************/
  137. #define IWL_CMD_FAILED_MSK 0x40
  138. struct iwl4965_cmd_header {
  139. u8 cmd;
  140. u8 flags;
  141. /* We have 15 LSB to use as we please (MSB indicates
  142. * a frame Rx'd from the HW). We encode the following
  143. * information into the sequence field:
  144. *
  145. * 0:7 index in fifo
  146. * 8:13 fifo selection
  147. * 14:14 bit indicating if this packet references the 'extra'
  148. * storage at the end of the memory queue
  149. * 15:15 (Rx indication)
  150. *
  151. */
  152. __le16 sequence;
  153. /* command data follows immediately */
  154. u8 data[0];
  155. } __attribute__ ((packed));
  156. /**
  157. * 4965 rate_n_flags bit fields
  158. *
  159. * rate_n_flags format is used in following 4965 commands:
  160. * REPLY_4965_RX (response only)
  161. * REPLY_TX (both command and response)
  162. * REPLY_TX_LINK_QUALITY_CMD
  163. *
  164. * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
  165. * 2-0: 0) 6 Mbps
  166. * 1) 12 Mbps
  167. * 2) 18 Mbps
  168. * 3) 24 Mbps
  169. * 4) 36 Mbps
  170. * 5) 48 Mbps
  171. * 6) 54 Mbps
  172. * 7) 60 Mbps
  173. *
  174. * 3: 0) Single stream (SISO)
  175. * 1) Dual stream (MIMO)
  176. *
  177. * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps FAT duplicate data
  178. *
  179. * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
  180. * 3-0: 0xD) 6 Mbps
  181. * 0xF) 9 Mbps
  182. * 0x5) 12 Mbps
  183. * 0x7) 18 Mbps
  184. * 0x9) 24 Mbps
  185. * 0xB) 36 Mbps
  186. * 0x1) 48 Mbps
  187. * 0x3) 54 Mbps
  188. *
  189. * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
  190. * 3-0: 10) 1 Mbps
  191. * 20) 2 Mbps
  192. * 55) 5.5 Mbps
  193. * 110) 11 Mbps
  194. */
  195. #define RATE_MCS_CODE_MSK 0x7
  196. #define RATE_MCS_MIMO_POS 3
  197. #define RATE_MCS_MIMO_MSK 0x8
  198. #define RATE_MCS_HT_DUP_POS 5
  199. #define RATE_MCS_HT_DUP_MSK 0x20
  200. /* (1) HT format, (0) legacy format in bits 7:0 */
  201. #define RATE_MCS_FLAGS_POS 8
  202. #define RATE_MCS_HT_POS 8
  203. #define RATE_MCS_HT_MSK 0x100
  204. /* (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */
  205. #define RATE_MCS_CCK_POS 9
  206. #define RATE_MCS_CCK_MSK 0x200
  207. /* (1) Use Green Field preamble */
  208. #define RATE_MCS_GF_POS 10
  209. #define RATE_MCS_GF_MSK 0x400
  210. /* (1) Use 40Mhz FAT channel width, (0) use 20 MHz legacy channel width */
  211. #define RATE_MCS_FAT_POS 11
  212. #define RATE_MCS_FAT_MSK 0x800
  213. /* (1) Duplicate data on both 20MHz channels. FAT (bit 11) must be set. */
  214. #define RATE_MCS_DUP_POS 12
  215. #define RATE_MCS_DUP_MSK 0x1000
  216. /* (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
  217. #define RATE_MCS_SGI_POS 13
  218. #define RATE_MCS_SGI_MSK 0x2000
  219. /**
  220. * rate_n_flags Tx antenna masks (4965 has 2 transmitters):
  221. * bit14:15 01 B inactive, A active
  222. * 10 B active, A inactive
  223. * 11 Both active
  224. */
  225. #define RATE_MCS_ANT_A_POS 14
  226. #define RATE_MCS_ANT_B_POS 15
  227. #define RATE_MCS_ANT_A_MSK 0x4000
  228. #define RATE_MCS_ANT_B_MSK 0x8000
  229. #define RATE_MCS_ANT_AB_MSK 0xc000
  230. /******************************************************************************
  231. * (0a)
  232. * Alive and Error Commands & Responses:
  233. *
  234. *****************************************************************************/
  235. #define UCODE_VALID_OK __constant_cpu_to_le32(0x1)
  236. #define INITIALIZE_SUBTYPE (9)
  237. /*
  238. * REPLY_ALIVE = 0x1 (response only, not a command)
  239. */
  240. struct iwl4965_alive_resp {
  241. u8 ucode_minor;
  242. u8 ucode_major;
  243. __le16 reserved1;
  244. u8 sw_rev[8];
  245. u8 ver_type;
  246. u8 ver_subtype;
  247. __le16 reserved2;
  248. __le32 log_event_table_ptr;
  249. __le32 error_event_table_ptr;
  250. __le32 timestamp;
  251. __le32 is_valid;
  252. } __attribute__ ((packed));
  253. struct iwl4965_init_alive_resp {
  254. u8 ucode_minor;
  255. u8 ucode_major;
  256. __le16 reserved1;
  257. u8 sw_rev[8];
  258. u8 ver_type;
  259. u8 ver_subtype;
  260. __le16 reserved2;
  261. __le32 log_event_table_ptr;
  262. __le32 error_event_table_ptr;
  263. __le32 timestamp;
  264. __le32 is_valid;
  265. /* calibration values from "initialize" uCode */
  266. __le32 voltage; /* signed */
  267. __le32 therm_r1[2]; /* signed 1st for normal, 2nd for FAT channel */
  268. __le32 therm_r2[2]; /* signed */
  269. __le32 therm_r3[2]; /* signed */
  270. __le32 therm_r4[2]; /* signed */
  271. __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
  272. * 2 Tx chains */
  273. } __attribute__ ((packed));
  274. union tsf {
  275. u8 byte[8];
  276. __le16 word[4];
  277. __le32 dw[2];
  278. };
  279. /*
  280. * REPLY_ERROR = 0x2 (response only, not a command)
  281. */
  282. struct iwl4965_error_resp {
  283. __le32 error_type;
  284. u8 cmd_id;
  285. u8 reserved1;
  286. __le16 bad_cmd_seq_num;
  287. __le32 error_info;
  288. union tsf timestamp;
  289. } __attribute__ ((packed));
  290. /******************************************************************************
  291. * (1)
  292. * RXON Commands & Responses:
  293. *
  294. *****************************************************************************/
  295. /*
  296. * Rx config defines & structure
  297. */
  298. /* rx_config device types */
  299. enum {
  300. RXON_DEV_TYPE_AP = 1,
  301. RXON_DEV_TYPE_ESS = 3,
  302. RXON_DEV_TYPE_IBSS = 4,
  303. RXON_DEV_TYPE_SNIFFER = 6,
  304. };
  305. #define RXON_RX_CHAIN_DRIVER_FORCE_MSK __constant_cpu_to_le16(0x1<<0)
  306. #define RXON_RX_CHAIN_VALID_MSK __constant_cpu_to_le16(0x7<<1)
  307. #define RXON_RX_CHAIN_VALID_POS (1)
  308. #define RXON_RX_CHAIN_FORCE_SEL_MSK __constant_cpu_to_le16(0x7<<4)
  309. #define RXON_RX_CHAIN_FORCE_SEL_POS (4)
  310. #define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK __constant_cpu_to_le16(0x7<<7)
  311. #define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
  312. #define RXON_RX_CHAIN_CNT_MSK __constant_cpu_to_le16(0x3<<10)
  313. #define RXON_RX_CHAIN_CNT_POS (10)
  314. #define RXON_RX_CHAIN_MIMO_CNT_MSK __constant_cpu_to_le16(0x3<<12)
  315. #define RXON_RX_CHAIN_MIMO_CNT_POS (12)
  316. #define RXON_RX_CHAIN_MIMO_FORCE_MSK __constant_cpu_to_le16(0x1<<14)
  317. #define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
  318. /* rx_config flags */
  319. /* band & modulation selection */
  320. #define RXON_FLG_BAND_24G_MSK __constant_cpu_to_le32(1 << 0)
  321. #define RXON_FLG_CCK_MSK __constant_cpu_to_le32(1 << 1)
  322. /* auto detection enable */
  323. #define RXON_FLG_AUTO_DETECT_MSK __constant_cpu_to_le32(1 << 2)
  324. /* TGg protection when tx */
  325. #define RXON_FLG_TGG_PROTECT_MSK __constant_cpu_to_le32(1 << 3)
  326. /* cck short slot & preamble */
  327. #define RXON_FLG_SHORT_SLOT_MSK __constant_cpu_to_le32(1 << 4)
  328. #define RXON_FLG_SHORT_PREAMBLE_MSK __constant_cpu_to_le32(1 << 5)
  329. /* antenna selection */
  330. #define RXON_FLG_DIS_DIV_MSK __constant_cpu_to_le32(1 << 7)
  331. #define RXON_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0x0f00)
  332. #define RXON_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
  333. #define RXON_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
  334. /* radar detection enable */
  335. #define RXON_FLG_RADAR_DETECT_MSK __constant_cpu_to_le32(1 << 12)
  336. #define RXON_FLG_TGJ_NARROW_BAND_MSK __constant_cpu_to_le32(1 << 13)
  337. /* rx response to host with 8-byte TSF
  338. * (according to ON_AIR deassertion) */
  339. #define RXON_FLG_TSF2HOST_MSK __constant_cpu_to_le32(1 << 15)
  340. /* HT flags */
  341. #define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
  342. #define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK __constant_cpu_to_le32(0x1<<22)
  343. #define RXON_FLG_HT_OPERATING_MODE_POS (23)
  344. #define RXON_FLG_HT_PROT_MSK __constant_cpu_to_le32(0x1<<23)
  345. #define RXON_FLG_FAT_PROT_MSK __constant_cpu_to_le32(0x2<<23)
  346. #define RXON_FLG_CHANNEL_MODE_POS (25)
  347. #define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3<<25)
  348. #define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1<<25)
  349. #define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2<<25)
  350. /* rx_config filter flags */
  351. /* accept all data frames */
  352. #define RXON_FILTER_PROMISC_MSK __constant_cpu_to_le32(1 << 0)
  353. /* pass control & management to host */
  354. #define RXON_FILTER_CTL2HOST_MSK __constant_cpu_to_le32(1 << 1)
  355. /* accept multi-cast */
  356. #define RXON_FILTER_ACCEPT_GRP_MSK __constant_cpu_to_le32(1 << 2)
  357. /* don't decrypt uni-cast frames */
  358. #define RXON_FILTER_DIS_DECRYPT_MSK __constant_cpu_to_le32(1 << 3)
  359. /* don't decrypt multi-cast frames */
  360. #define RXON_FILTER_DIS_GRP_DECRYPT_MSK __constant_cpu_to_le32(1 << 4)
  361. /* STA is associated */
  362. #define RXON_FILTER_ASSOC_MSK __constant_cpu_to_le32(1 << 5)
  363. /* transfer to host non bssid beacons in associated state */
  364. #define RXON_FILTER_BCON_AWARE_MSK __constant_cpu_to_le32(1 << 6)
  365. /*
  366. * REPLY_RXON = 0x10 (command, has simple generic response)
  367. */
  368. struct iwl4965_rxon_cmd {
  369. u8 node_addr[6];
  370. __le16 reserved1;
  371. u8 bssid_addr[6];
  372. __le16 reserved2;
  373. u8 wlap_bssid_addr[6];
  374. __le16 reserved3;
  375. u8 dev_type;
  376. u8 air_propagation;
  377. __le16 rx_chain;
  378. u8 ofdm_basic_rates;
  379. u8 cck_basic_rates;
  380. __le16 assoc_id;
  381. __le32 flags;
  382. __le32 filter_flags;
  383. __le16 channel;
  384. u8 ofdm_ht_single_stream_basic_rates;
  385. u8 ofdm_ht_dual_stream_basic_rates;
  386. } __attribute__ ((packed));
  387. /*
  388. * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
  389. */
  390. struct iwl4965_rxon_assoc_cmd {
  391. __le32 flags;
  392. __le32 filter_flags;
  393. u8 ofdm_basic_rates;
  394. u8 cck_basic_rates;
  395. u8 ofdm_ht_single_stream_basic_rates;
  396. u8 ofdm_ht_dual_stream_basic_rates;
  397. __le16 rx_chain_select_flags;
  398. __le16 reserved;
  399. } __attribute__ ((packed));
  400. /*
  401. * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
  402. */
  403. struct iwl4965_rxon_time_cmd {
  404. union tsf timestamp;
  405. __le16 beacon_interval;
  406. __le16 atim_window;
  407. __le32 beacon_init_val;
  408. __le16 listen_interval;
  409. __le16 reserved;
  410. } __attribute__ ((packed));
  411. struct iwl4965_tx_power {
  412. u8 tx_gain; /* gain for analog radio */
  413. u8 dsp_atten; /* gain for DSP */
  414. } __attribute__ ((packed));
  415. #define POWER_TABLE_NUM_ENTRIES 33
  416. #define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
  417. #define POWER_TABLE_CCK_ENTRY 32
  418. union iwl4965_tx_power_dual_stream {
  419. struct {
  420. u8 radio_tx_gain[2];
  421. u8 dsp_predis_atten[2];
  422. } s;
  423. u32 dw;
  424. };
  425. struct tx_power_dual_stream {
  426. __le32 dw;
  427. } __attribute__ ((packed));
  428. struct iwl4965_tx_power_db {
  429. struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
  430. } __attribute__ ((packed));
  431. /*
  432. * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
  433. */
  434. struct iwl4965_channel_switch_cmd {
  435. u8 band;
  436. u8 expect_beacon;
  437. __le16 channel;
  438. __le32 rxon_flags;
  439. __le32 rxon_filter_flags;
  440. __le32 switch_time;
  441. struct iwl4965_tx_power_db tx_power;
  442. } __attribute__ ((packed));
  443. /*
  444. * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
  445. */
  446. struct iwl4965_csa_notification {
  447. __le16 band;
  448. __le16 channel;
  449. __le32 status; /* 0 - OK, 1 - fail */
  450. } __attribute__ ((packed));
  451. /******************************************************************************
  452. * (2)
  453. * Quality-of-Service (QOS) Commands & Responses:
  454. *
  455. *****************************************************************************/
  456. struct iwl4965_ac_qos {
  457. __le16 cw_min;
  458. __le16 cw_max;
  459. u8 aifsn;
  460. u8 reserved1;
  461. __le16 edca_txop;
  462. } __attribute__ ((packed));
  463. /* QoS flags defines */
  464. #define QOS_PARAM_FLG_UPDATE_EDCA_MSK __constant_cpu_to_le32(0x01)
  465. #define QOS_PARAM_FLG_TGN_MSK __constant_cpu_to_le32(0x02)
  466. #define QOS_PARAM_FLG_TXOP_TYPE_MSK __constant_cpu_to_le32(0x10)
  467. /*
  468. * TXFIFO Queue number defines
  469. */
  470. /* number of Access categories (AC) (EDCA), queues 0..3 */
  471. #define AC_NUM 4
  472. /*
  473. * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
  474. */
  475. struct iwl4965_qosparam_cmd {
  476. __le32 qos_flags;
  477. struct iwl4965_ac_qos ac[AC_NUM];
  478. } __attribute__ ((packed));
  479. /******************************************************************************
  480. * (3)
  481. * Add/Modify Stations Commands & Responses:
  482. *
  483. *****************************************************************************/
  484. /*
  485. * Multi station support
  486. */
  487. #define IWL_AP_ID 0
  488. #define IWL_MULTICAST_ID 1
  489. #define IWL_STA_ID 2
  490. #define IWL3945_BROADCAST_ID 24
  491. #define IWL3945_STATION_COUNT 25
  492. #define IWL4965_BROADCAST_ID 31
  493. #define IWL4965_STATION_COUNT 32
  494. #define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
  495. #define IWL_INVALID_STATION 255
  496. #define STA_FLG_PWR_SAVE_MSK __constant_cpu_to_le32(1<<8);
  497. #define STA_FLG_RTS_MIMO_PROT_MSK __constant_cpu_to_le32(1 << 17)
  498. #define STA_FLG_AGG_MPDU_8US_MSK __constant_cpu_to_le32(1 << 18)
  499. #define STA_FLG_MAX_AGG_SIZE_POS (19)
  500. #define STA_FLG_MAX_AGG_SIZE_MSK __constant_cpu_to_le32(3 << 19)
  501. #define STA_FLG_FAT_EN_MSK __constant_cpu_to_le32(1 << 21)
  502. #define STA_FLG_MIMO_DIS_MSK __constant_cpu_to_le32(1 << 22)
  503. #define STA_FLG_AGG_MPDU_DENSITY_POS (23)
  504. #define STA_FLG_AGG_MPDU_DENSITY_MSK __constant_cpu_to_le32(7 << 23)
  505. #define STA_CONTROL_MODIFY_MSK 0x01
  506. /* key flags __le16*/
  507. #define STA_KEY_FLG_ENCRYPT_MSK __constant_cpu_to_le16(0x7)
  508. #define STA_KEY_FLG_NO_ENC __constant_cpu_to_le16(0x0)
  509. #define STA_KEY_FLG_WEP __constant_cpu_to_le16(0x1)
  510. #define STA_KEY_FLG_CCMP __constant_cpu_to_le16(0x2)
  511. #define STA_KEY_FLG_TKIP __constant_cpu_to_le16(0x3)
  512. #define STA_KEY_FLG_KEYID_POS 8
  513. #define STA_KEY_FLG_INVALID __constant_cpu_to_le16(0x0800)
  514. /* modify flags */
  515. #define STA_MODIFY_KEY_MASK 0x01
  516. #define STA_MODIFY_TID_DISABLE_TX 0x02
  517. #define STA_MODIFY_TX_RATE_MSK 0x04
  518. #define STA_MODIFY_ADDBA_TID_MSK 0x08
  519. #define STA_MODIFY_DELBA_TID_MSK 0x10
  520. #define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
  521. struct iwl4965_keyinfo {
  522. __le16 key_flags;
  523. u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
  524. u8 reserved1;
  525. __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
  526. __le16 reserved2;
  527. u8 key[16]; /* 16-byte unicast decryption key */
  528. } __attribute__ ((packed));
  529. struct sta_id_modify {
  530. u8 addr[ETH_ALEN];
  531. __le16 reserved1;
  532. u8 sta_id;
  533. u8 modify_mask;
  534. __le16 reserved2;
  535. } __attribute__ ((packed));
  536. /*
  537. * REPLY_ADD_STA = 0x18 (command)
  538. */
  539. struct iwl4965_addsta_cmd {
  540. u8 mode;
  541. u8 reserved[3];
  542. struct sta_id_modify sta;
  543. struct iwl4965_keyinfo key;
  544. __le32 station_flags;
  545. __le32 station_flags_msk;
  546. __le16 tid_disable_tx;
  547. __le16 reserved1;
  548. u8 add_immediate_ba_tid;
  549. u8 remove_immediate_ba_tid;
  550. __le16 add_immediate_ba_ssn;
  551. __le32 reserved2;
  552. } __attribute__ ((packed));
  553. /*
  554. * REPLY_ADD_STA = 0x18 (response)
  555. */
  556. struct iwl4965_add_sta_resp {
  557. u8 status;
  558. } __attribute__ ((packed));
  559. #define ADD_STA_SUCCESS_MSK 0x1
  560. /******************************************************************************
  561. * (4)
  562. * Rx Responses:
  563. *
  564. *****************************************************************************/
  565. struct iwl4965_rx_frame_stats {
  566. u8 phy_count;
  567. u8 id;
  568. u8 rssi;
  569. u8 agc;
  570. __le16 sig_avg;
  571. __le16 noise_diff;
  572. u8 payload[0];
  573. } __attribute__ ((packed));
  574. struct iwl4965_rx_frame_hdr {
  575. __le16 channel;
  576. __le16 phy_flags;
  577. u8 reserved1;
  578. u8 rate;
  579. __le16 len;
  580. u8 payload[0];
  581. } __attribute__ ((packed));
  582. #define RX_RES_STATUS_NO_CRC32_ERROR __constant_cpu_to_le32(1 << 0)
  583. #define RX_RES_STATUS_NO_RXE_OVERFLOW __constant_cpu_to_le32(1 << 1)
  584. #define RX_RES_PHY_FLAGS_BAND_24_MSK __constant_cpu_to_le16(1 << 0)
  585. #define RX_RES_PHY_FLAGS_MOD_CCK_MSK __constant_cpu_to_le16(1 << 1)
  586. #define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK __constant_cpu_to_le16(1 << 2)
  587. #define RX_RES_PHY_FLAGS_NARROW_BAND_MSK __constant_cpu_to_le16(1 << 3)
  588. #define RX_RES_PHY_FLAGS_ANTENNA_MSK __constant_cpu_to_le16(0xf0)
  589. #define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
  590. #define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
  591. #define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
  592. #define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
  593. #define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
  594. #define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
  595. #define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
  596. #define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
  597. #define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
  598. #define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
  599. struct iwl4965_rx_frame_end {
  600. __le32 status;
  601. __le64 timestamp;
  602. __le32 beacon_timestamp;
  603. } __attribute__ ((packed));
  604. /*
  605. * REPLY_3945_RX = 0x1b (response only, not a command)
  606. *
  607. * NOTE: DO NOT dereference from casts to this structure
  608. * It is provided only for calculating minimum data set size.
  609. * The actual offsets of the hdr and end are dynamic based on
  610. * stats.phy_count
  611. */
  612. struct iwl4965_rx_frame {
  613. struct iwl4965_rx_frame_stats stats;
  614. struct iwl4965_rx_frame_hdr hdr;
  615. struct iwl4965_rx_frame_end end;
  616. } __attribute__ ((packed));
  617. /* Fixed (non-configurable) rx data from phy */
  618. #define RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
  619. #define RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
  620. #define IWL_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
  621. #define IWL_AGC_DB_POS (7)
  622. struct iwl4965_rx_non_cfg_phy {
  623. __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
  624. __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
  625. u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
  626. u8 pad[0];
  627. } __attribute__ ((packed));
  628. /*
  629. * REPLY_4965_RX = 0xc3 (response only, not a command)
  630. * Used only for legacy (non 11n) frames.
  631. */
  632. #define RX_RES_PHY_CNT 14
  633. struct iwl4965_rx_phy_res {
  634. u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
  635. u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
  636. u8 stat_id; /* configurable DSP phy data set ID */
  637. u8 reserved1;
  638. __le64 timestamp; /* TSF at on air rise */
  639. __le32 beacon_time_stamp; /* beacon at on-air rise */
  640. __le16 phy_flags; /* general phy flags: band, modulation, ... */
  641. __le16 channel; /* channel number */
  642. __le16 non_cfg_phy[RX_RES_PHY_CNT]; /* upto 14 phy entries */
  643. __le32 reserved2;
  644. __le32 rate_n_flags;
  645. __le16 byte_count; /* frame's byte-count */
  646. __le16 reserved3;
  647. } __attribute__ ((packed));
  648. struct iwl4965_rx_mpdu_res_start {
  649. __le16 byte_count;
  650. __le16 reserved;
  651. } __attribute__ ((packed));
  652. /******************************************************************************
  653. * (5)
  654. * Tx Commands & Responses:
  655. *
  656. *****************************************************************************/
  657. /* Tx flags */
  658. #define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1)
  659. #define TX_CMD_FLG_CTS_MSK __constant_cpu_to_le32(1 << 2)
  660. #define TX_CMD_FLG_ACK_MSK __constant_cpu_to_le32(1 << 3)
  661. #define TX_CMD_FLG_STA_RATE_MSK __constant_cpu_to_le32(1 << 4)
  662. #define TX_CMD_FLG_IMM_BA_RSP_MASK __constant_cpu_to_le32(1 << 6)
  663. #define TX_CMD_FLG_FULL_TXOP_PROT_MSK __constant_cpu_to_le32(1 << 7)
  664. #define TX_CMD_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0xf00)
  665. #define TX_CMD_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
  666. #define TX_CMD_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
  667. /* ucode ignores BT priority for this frame */
  668. #define TX_CMD_FLG_BT_DIS_MSK __constant_cpu_to_le32(1 << 12)
  669. /* ucode overrides sequence control */
  670. #define TX_CMD_FLG_SEQ_CTL_MSK __constant_cpu_to_le32(1 << 13)
  671. /* signal that this frame is non-last MPDU */
  672. #define TX_CMD_FLG_MORE_FRAG_MSK __constant_cpu_to_le32(1 << 14)
  673. /* calculate TSF in outgoing frame */
  674. #define TX_CMD_FLG_TSF_MSK __constant_cpu_to_le32(1 << 16)
  675. /* activate TX calibration. */
  676. #define TX_CMD_FLG_CALIB_MSK __constant_cpu_to_le32(1 << 17)
  677. /* signals that 2 bytes pad was inserted
  678. after the MAC header */
  679. #define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20)
  680. /* HCCA-AP - disable duration overwriting. */
  681. #define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25)
  682. /*
  683. * TX command security control
  684. */
  685. #define TX_CMD_SEC_WEP 0x01
  686. #define TX_CMD_SEC_CCM 0x02
  687. #define TX_CMD_SEC_TKIP 0x03
  688. #define TX_CMD_SEC_MSK 0x03
  689. #define TX_CMD_SEC_SHIFT 6
  690. #define TX_CMD_SEC_KEY128 0x08
  691. /*
  692. * TX command Frame life time
  693. */
  694. struct iwl4965_dram_scratch {
  695. u8 try_cnt;
  696. u8 bt_kill_cnt;
  697. __le16 reserved;
  698. } __attribute__ ((packed));
  699. /*
  700. * REPLY_TX = 0x1c (command)
  701. */
  702. struct iwl4965_tx_cmd {
  703. __le16 len;
  704. __le16 next_frame_len;
  705. __le32 tx_flags;
  706. struct iwl4965_dram_scratch scratch;
  707. __le32 rate_n_flags;
  708. u8 sta_id;
  709. u8 sec_ctl;
  710. u8 initial_rate_index;
  711. u8 reserved;
  712. u8 key[16];
  713. __le16 next_frame_flags;
  714. __le16 reserved2;
  715. union {
  716. __le32 life_time;
  717. __le32 attempt;
  718. } stop_time;
  719. __le32 dram_lsb_ptr;
  720. u8 dram_msb_ptr;
  721. u8 rts_retry_limit; /*byte 50 */
  722. u8 data_retry_limit; /*byte 51 */
  723. u8 tid_tspec;
  724. union {
  725. __le16 pm_frame_timeout;
  726. __le16 attempt_duration;
  727. } timeout;
  728. __le16 driver_txop;
  729. u8 payload[0];
  730. struct ieee80211_hdr hdr[0];
  731. } __attribute__ ((packed));
  732. /* TX command response is sent after *all* transmission attempts.
  733. *
  734. * NOTES:
  735. *
  736. * TX_STATUS_FAIL_NEXT_FRAG
  737. *
  738. * If the fragment flag in the MAC header for the frame being transmitted
  739. * is set and there is insufficient time to transmit the next frame, the
  740. * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
  741. *
  742. * TX_STATUS_FIFO_UNDERRUN
  743. *
  744. * Indicates the host did not provide bytes to the FIFO fast enough while
  745. * a TX was in progress.
  746. *
  747. * TX_STATUS_FAIL_MGMNT_ABORT
  748. *
  749. * This status is only possible if the ABORT ON MGMT RX parameter was
  750. * set to true with the TX command.
  751. *
  752. * If the MSB of the status parameter is set then an abort sequence is
  753. * required. This sequence consists of the host activating the TX Abort
  754. * control line, and then waiting for the TX Abort command response. This
  755. * indicates that a the device is no longer in a transmit state, and that the
  756. * command FIFO has been cleared. The host must then deactivate the TX Abort
  757. * control line. Receiving is still allowed in this case.
  758. */
  759. enum {
  760. TX_STATUS_SUCCESS = 0x01,
  761. TX_STATUS_DIRECT_DONE = 0x02,
  762. TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
  763. TX_STATUS_FAIL_LONG_LIMIT = 0x83,
  764. TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
  765. TX_STATUS_FAIL_MGMNT_ABORT = 0x85,
  766. TX_STATUS_FAIL_NEXT_FRAG = 0x86,
  767. TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
  768. TX_STATUS_FAIL_DEST_PS = 0x88,
  769. TX_STATUS_FAIL_ABORTED = 0x89,
  770. TX_STATUS_FAIL_BT_RETRY = 0x8a,
  771. TX_STATUS_FAIL_STA_INVALID = 0x8b,
  772. TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
  773. TX_STATUS_FAIL_TID_DISABLE = 0x8d,
  774. TX_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
  775. TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
  776. TX_STATUS_FAIL_TX_LOCKED = 0x90,
  777. TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
  778. };
  779. #define TX_PACKET_MODE_REGULAR 0x0000
  780. #define TX_PACKET_MODE_BURST_SEQ 0x0100
  781. #define TX_PACKET_MODE_BURST_FIRST 0x0200
  782. enum {
  783. TX_POWER_PA_NOT_ACTIVE = 0x0,
  784. };
  785. enum {
  786. TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
  787. TX_STATUS_DELAY_MSK = 0x00000040,
  788. TX_STATUS_ABORT_MSK = 0x00000080,
  789. TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
  790. TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
  791. TX_RESERVED = 0x00780000, /* bits 19:22 */
  792. TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
  793. TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
  794. };
  795. /* *******************************
  796. * TX aggregation state
  797. ******************************* */
  798. enum {
  799. AGG_TX_STATE_TRANSMITTED = 0x00,
  800. AGG_TX_STATE_UNDERRUN_MSK = 0x01,
  801. AGG_TX_STATE_BT_PRIO_MSK = 0x02,
  802. AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
  803. AGG_TX_STATE_ABORT_MSK = 0x08,
  804. AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
  805. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
  806. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
  807. AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
  808. AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
  809. AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
  810. AGG_TX_STATE_DUMP_TX_MSK = 0x200,
  811. AGG_TX_STATE_DELAY_TX_MSK = 0x400
  812. };
  813. #define AGG_TX_STATE_LAST_SENT_MSK \
  814. (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
  815. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
  816. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
  817. #define AGG_TX_STATE_TRY_CNT_POS 12
  818. #define AGG_TX_STATE_TRY_CNT_MSK 0xf000
  819. #define AGG_TX_STATE_SEQ_NUM_POS 16
  820. #define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
  821. /*
  822. * REPLY_TX = 0x1c (response)
  823. */
  824. struct iwl4965_tx_resp {
  825. u8 frame_count; /* 1 no aggregation, >1 aggregation */
  826. u8 bt_kill_count;
  827. u8 failure_rts;
  828. u8 failure_frame;
  829. __le32 rate_n_flags;
  830. __le16 wireless_media_time;
  831. __le16 reserved;
  832. __le32 pa_power1;
  833. __le32 pa_power2;
  834. __le32 status; /* TX status (for aggregation status of 1st frame) */
  835. } __attribute__ ((packed));
  836. /*
  837. * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
  838. */
  839. struct iwl4965_compressed_ba_resp {
  840. __le32 sta_addr_lo32;
  841. __le16 sta_addr_hi16;
  842. __le16 reserved;
  843. u8 sta_id;
  844. u8 tid;
  845. __le16 ba_seq_ctl;
  846. __le32 ba_bitmap0;
  847. __le32 ba_bitmap1;
  848. __le16 scd_flow;
  849. __le16 scd_ssn;
  850. } __attribute__ ((packed));
  851. /*
  852. * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
  853. */
  854. struct iwl4965_txpowertable_cmd {
  855. u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
  856. u8 reserved;
  857. __le16 channel;
  858. struct iwl4965_tx_power_db tx_power;
  859. } __attribute__ ((packed));
  860. /*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
  861. #define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1<<0)
  862. #define LINK_QUAL_AC_NUM AC_NUM
  863. #define LINK_QUAL_MAX_RETRY_NUM 16
  864. #define LINK_QUAL_ANT_A_MSK (1<<0)
  865. #define LINK_QUAL_ANT_B_MSK (1<<1)
  866. #define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
  867. struct iwl4965_link_qual_general_params {
  868. u8 flags;
  869. u8 mimo_delimiter;
  870. u8 single_stream_ant_msk;
  871. u8 dual_stream_ant_msk;
  872. u8 start_rate_index[LINK_QUAL_AC_NUM];
  873. } __attribute__ ((packed));
  874. struct iwl4965_link_qual_agg_params {
  875. __le16 agg_time_limit;
  876. u8 agg_dis_start_th;
  877. u8 agg_frame_cnt_limit;
  878. __le32 reserved;
  879. } __attribute__ ((packed));
  880. /*
  881. * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
  882. */
  883. struct iwl4965_link_quality_cmd {
  884. u8 sta_id;
  885. u8 reserved1;
  886. __le16 control;
  887. struct iwl4965_link_qual_general_params general_params;
  888. struct iwl4965_link_qual_agg_params agg_params;
  889. struct {
  890. __le32 rate_n_flags;
  891. } rs_table[LINK_QUAL_MAX_RETRY_NUM];
  892. __le32 reserved2;
  893. } __attribute__ ((packed));
  894. /*
  895. * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
  896. */
  897. struct iwl4965_bt_cmd {
  898. u8 flags;
  899. u8 lead_time;
  900. u8 max_kill;
  901. u8 reserved;
  902. __le32 kill_ack_mask;
  903. __le32 kill_cts_mask;
  904. } __attribute__ ((packed));
  905. /******************************************************************************
  906. * (6)
  907. * Spectrum Management (802.11h) Commands, Responses, Notifications:
  908. *
  909. *****************************************************************************/
  910. /*
  911. * Spectrum Management
  912. */
  913. #define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
  914. RXON_FILTER_CTL2HOST_MSK | \
  915. RXON_FILTER_ACCEPT_GRP_MSK | \
  916. RXON_FILTER_DIS_DECRYPT_MSK | \
  917. RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
  918. RXON_FILTER_ASSOC_MSK | \
  919. RXON_FILTER_BCON_AWARE_MSK)
  920. struct iwl4965_measure_channel {
  921. __le32 duration; /* measurement duration in extended beacon
  922. * format */
  923. u8 channel; /* channel to measure */
  924. u8 type; /* see enum iwl4965_measure_type */
  925. __le16 reserved;
  926. } __attribute__ ((packed));
  927. /*
  928. * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
  929. */
  930. struct iwl4965_spectrum_cmd {
  931. __le16 len; /* number of bytes starting from token */
  932. u8 token; /* token id */
  933. u8 id; /* measurement id -- 0 or 1 */
  934. u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
  935. u8 periodic; /* 1 = periodic */
  936. __le16 path_loss_timeout;
  937. __le32 start_time; /* start time in extended beacon format */
  938. __le32 reserved2;
  939. __le32 flags; /* rxon flags */
  940. __le32 filter_flags; /* rxon filter flags */
  941. __le16 channel_count; /* minimum 1, maximum 10 */
  942. __le16 reserved3;
  943. struct iwl4965_measure_channel channels[10];
  944. } __attribute__ ((packed));
  945. /*
  946. * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
  947. */
  948. struct iwl4965_spectrum_resp {
  949. u8 token;
  950. u8 id; /* id of the prior command replaced, or 0xff */
  951. __le16 status; /* 0 - command will be handled
  952. * 1 - cannot handle (conflicts with another
  953. * measurement) */
  954. } __attribute__ ((packed));
  955. enum iwl4965_measurement_state {
  956. IWL_MEASUREMENT_START = 0,
  957. IWL_MEASUREMENT_STOP = 1,
  958. };
  959. enum iwl4965_measurement_status {
  960. IWL_MEASUREMENT_OK = 0,
  961. IWL_MEASUREMENT_CONCURRENT = 1,
  962. IWL_MEASUREMENT_CSA_CONFLICT = 2,
  963. IWL_MEASUREMENT_TGH_CONFLICT = 3,
  964. /* 4-5 reserved */
  965. IWL_MEASUREMENT_STOPPED = 6,
  966. IWL_MEASUREMENT_TIMEOUT = 7,
  967. IWL_MEASUREMENT_PERIODIC_FAILED = 8,
  968. };
  969. #define NUM_ELEMENTS_IN_HISTOGRAM 8
  970. struct iwl4965_measurement_histogram {
  971. __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
  972. __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
  973. } __attribute__ ((packed));
  974. /* clear channel availability counters */
  975. struct iwl4965_measurement_cca_counters {
  976. __le32 ofdm;
  977. __le32 cck;
  978. } __attribute__ ((packed));
  979. enum iwl4965_measure_type {
  980. IWL_MEASURE_BASIC = (1 << 0),
  981. IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
  982. IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
  983. IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
  984. IWL_MEASURE_FRAME = (1 << 4),
  985. /* bits 5:6 are reserved */
  986. IWL_MEASURE_IDLE = (1 << 7),
  987. };
  988. /*
  989. * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
  990. */
  991. struct iwl4965_spectrum_notification {
  992. u8 id; /* measurement id -- 0 or 1 */
  993. u8 token;
  994. u8 channel_index; /* index in measurement channel list */
  995. u8 state; /* 0 - start, 1 - stop */
  996. __le32 start_time; /* lower 32-bits of TSF */
  997. u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
  998. u8 channel;
  999. u8 type; /* see enum iwl4965_measurement_type */
  1000. u8 reserved1;
  1001. /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
  1002. * valid if applicable for measurement type requested. */
  1003. __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
  1004. __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
  1005. __le32 cca_time; /* channel load time in usecs */
  1006. u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
  1007. * unidentified */
  1008. u8 reserved2[3];
  1009. struct iwl4965_measurement_histogram histogram;
  1010. __le32 stop_time; /* lower 32-bits of TSF */
  1011. __le32 status; /* see iwl4965_measurement_status */
  1012. } __attribute__ ((packed));
  1013. /******************************************************************************
  1014. * (7)
  1015. * Power Management Commands, Responses, Notifications:
  1016. *
  1017. *****************************************************************************/
  1018. /**
  1019. * struct iwl4965_powertable_cmd - Power Table Command
  1020. * @flags: See below:
  1021. *
  1022. * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
  1023. *
  1024. * PM allow:
  1025. * bit 0 - '0' Driver not allow power management
  1026. * '1' Driver allow PM (use rest of parameters)
  1027. * uCode send sleep notifications:
  1028. * bit 1 - '0' Don't send sleep notification
  1029. * '1' send sleep notification (SEND_PM_NOTIFICATION)
  1030. * Sleep over DTIM
  1031. * bit 2 - '0' PM have to walk up every DTIM
  1032. * '1' PM could sleep over DTIM till listen Interval.
  1033. * PCI power managed
  1034. * bit 3 - '0' (PCI_LINK_CTRL & 0x1)
  1035. * '1' !(PCI_LINK_CTRL & 0x1)
  1036. * Force sleep Modes
  1037. * bit 31/30- '00' use both mac/xtal sleeps
  1038. * '01' force Mac sleep
  1039. * '10' force xtal sleep
  1040. * '11' Illegal set
  1041. *
  1042. * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
  1043. * ucode assume sleep over DTIM is allowed and we don't need to wakeup
  1044. * for every DTIM.
  1045. */
  1046. #define IWL_POWER_VEC_SIZE 5
  1047. #define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK __constant_cpu_to_le16(1<<0)
  1048. #define IWL_POWER_SLEEP_OVER_DTIM_MSK __constant_cpu_to_le16(1<<2)
  1049. #define IWL_POWER_PCI_PM_MSK __constant_cpu_to_le16(1<<3)
  1050. struct iwl4965_powertable_cmd {
  1051. __le16 flags;
  1052. u8 keep_alive_seconds;
  1053. u8 debug_flags;
  1054. __le32 rx_data_timeout;
  1055. __le32 tx_data_timeout;
  1056. __le32 sleep_interval[IWL_POWER_VEC_SIZE];
  1057. __le32 keep_alive_beacons;
  1058. } __attribute__ ((packed));
  1059. /*
  1060. * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
  1061. * 3945 and 4965 identical.
  1062. */
  1063. struct iwl4965_sleep_notification {
  1064. u8 pm_sleep_mode;
  1065. u8 pm_wakeup_src;
  1066. __le16 reserved;
  1067. __le32 sleep_time;
  1068. __le32 tsf_low;
  1069. __le32 bcon_timer;
  1070. } __attribute__ ((packed));
  1071. /* Sleep states. 3945 and 4965 identical. */
  1072. enum {
  1073. IWL_PM_NO_SLEEP = 0,
  1074. IWL_PM_SLP_MAC = 1,
  1075. IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
  1076. IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
  1077. IWL_PM_SLP_PHY = 4,
  1078. IWL_PM_SLP_REPENT = 5,
  1079. IWL_PM_WAKEUP_BY_TIMER = 6,
  1080. IWL_PM_WAKEUP_BY_DRIVER = 7,
  1081. IWL_PM_WAKEUP_BY_RFKILL = 8,
  1082. /* 3 reserved */
  1083. IWL_PM_NUM_OF_MODES = 12,
  1084. };
  1085. /*
  1086. * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
  1087. */
  1088. #define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
  1089. #define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
  1090. #define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
  1091. struct iwl4965_card_state_cmd {
  1092. __le32 status; /* CARD_STATE_CMD_* request new power state */
  1093. } __attribute__ ((packed));
  1094. /*
  1095. * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
  1096. */
  1097. struct iwl4965_card_state_notif {
  1098. __le32 flags;
  1099. } __attribute__ ((packed));
  1100. #define HW_CARD_DISABLED 0x01
  1101. #define SW_CARD_DISABLED 0x02
  1102. #define RF_CARD_DISABLED 0x04
  1103. #define RXON_CARD_DISABLED 0x10
  1104. struct iwl4965_ct_kill_config {
  1105. __le32 reserved;
  1106. __le32 critical_temperature_M;
  1107. __le32 critical_temperature_R;
  1108. } __attribute__ ((packed));
  1109. /******************************************************************************
  1110. * (8)
  1111. * Scan Commands, Responses, Notifications:
  1112. *
  1113. *****************************************************************************/
  1114. struct iwl4965_scan_channel {
  1115. /* type is defined as:
  1116. * 0:0 active (0 - passive)
  1117. * 1:4 SSID direct
  1118. * If 1 is set then corresponding SSID IE is transmitted in probe
  1119. * 5:7 reserved
  1120. */
  1121. u8 type;
  1122. u8 channel;
  1123. struct iwl4965_tx_power tpc;
  1124. __le16 active_dwell;
  1125. __le16 passive_dwell;
  1126. } __attribute__ ((packed));
  1127. struct iwl4965_ssid_ie {
  1128. u8 id;
  1129. u8 len;
  1130. u8 ssid[32];
  1131. } __attribute__ ((packed));
  1132. #define PROBE_OPTION_MAX 0x4
  1133. #define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF)
  1134. #define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1)
  1135. #define IWL_MAX_SCAN_SIZE 1024
  1136. /*
  1137. * REPLY_SCAN_CMD = 0x80 (command)
  1138. */
  1139. struct iwl4965_scan_cmd {
  1140. __le16 len;
  1141. u8 reserved0;
  1142. u8 channel_count;
  1143. __le16 quiet_time; /* dwell only this long on quiet chnl
  1144. * (active scan) */
  1145. __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
  1146. __le16 good_CRC_th; /* passive -> active promotion threshold */
  1147. __le16 rx_chain;
  1148. __le32 max_out_time; /* max usec to be out of associated (service)
  1149. * chnl */
  1150. __le32 suspend_time; /* pause scan this long when returning to svc
  1151. * chnl.
  1152. * 3945 -- 31:24 # beacons, 19:0 additional usec,
  1153. * 4965 -- 31:22 # beacons, 21:0 additional usec.
  1154. */
  1155. __le32 flags;
  1156. __le32 filter_flags;
  1157. struct iwl4965_tx_cmd tx_cmd;
  1158. struct iwl4965_ssid_ie direct_scan[PROBE_OPTION_MAX];
  1159. u8 data[0];
  1160. /*
  1161. * The channels start after the probe request payload and are of type:
  1162. *
  1163. * struct iwl4965_scan_channel channels[0];
  1164. *
  1165. * NOTE: Only one band of channels can be scanned per pass. You
  1166. * can not mix 2.4GHz channels and 5.2GHz channels and must
  1167. * request a scan multiple times (not concurrently)
  1168. *
  1169. */
  1170. } __attribute__ ((packed));
  1171. /* Can abort will notify by complete notification with abort status. */
  1172. #define CAN_ABORT_STATUS __constant_cpu_to_le32(0x1)
  1173. /* complete notification statuses */
  1174. #define ABORT_STATUS 0x2
  1175. /*
  1176. * REPLY_SCAN_CMD = 0x80 (response)
  1177. */
  1178. struct iwl4965_scanreq_notification {
  1179. __le32 status; /* 1: okay, 2: cannot fulfill request */
  1180. } __attribute__ ((packed));
  1181. /*
  1182. * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
  1183. */
  1184. struct iwl4965_scanstart_notification {
  1185. __le32 tsf_low;
  1186. __le32 tsf_high;
  1187. __le32 beacon_timer;
  1188. u8 channel;
  1189. u8 band;
  1190. u8 reserved[2];
  1191. __le32 status;
  1192. } __attribute__ ((packed));
  1193. #define SCAN_OWNER_STATUS 0x1;
  1194. #define MEASURE_OWNER_STATUS 0x2;
  1195. #define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
  1196. /*
  1197. * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
  1198. */
  1199. struct iwl4965_scanresults_notification {
  1200. u8 channel;
  1201. u8 band;
  1202. u8 reserved[2];
  1203. __le32 tsf_low;
  1204. __le32 tsf_high;
  1205. __le32 statistics[NUMBER_OF_STATISTICS];
  1206. } __attribute__ ((packed));
  1207. /*
  1208. * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
  1209. */
  1210. struct iwl4965_scancomplete_notification {
  1211. u8 scanned_channels;
  1212. u8 status;
  1213. u8 reserved;
  1214. u8 last_channel;
  1215. __le32 tsf_low;
  1216. __le32 tsf_high;
  1217. } __attribute__ ((packed));
  1218. /******************************************************************************
  1219. * (9)
  1220. * IBSS/AP Commands and Notifications:
  1221. *
  1222. *****************************************************************************/
  1223. /*
  1224. * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
  1225. */
  1226. struct iwl4965_beacon_notif {
  1227. struct iwl4965_tx_resp beacon_notify_hdr;
  1228. __le32 low_tsf;
  1229. __le32 high_tsf;
  1230. __le32 ibss_mgr_status;
  1231. } __attribute__ ((packed));
  1232. /*
  1233. * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
  1234. */
  1235. struct iwl4965_tx_beacon_cmd {
  1236. struct iwl4965_tx_cmd tx;
  1237. __le16 tim_idx;
  1238. u8 tim_size;
  1239. u8 reserved1;
  1240. struct ieee80211_hdr frame[0]; /* beacon frame */
  1241. } __attribute__ ((packed));
  1242. /******************************************************************************
  1243. * (10)
  1244. * Statistics Commands and Notifications:
  1245. *
  1246. *****************************************************************************/
  1247. #define IWL_TEMP_CONVERT 260
  1248. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  1249. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  1250. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  1251. /* Used for passing to driver number of successes and failures per rate */
  1252. struct rate_histogram {
  1253. union {
  1254. __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  1255. __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  1256. __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  1257. } success;
  1258. union {
  1259. __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  1260. __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  1261. __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  1262. } failed;
  1263. } __attribute__ ((packed));
  1264. /* statistics command response */
  1265. struct statistics_rx_phy {
  1266. __le32 ina_cnt;
  1267. __le32 fina_cnt;
  1268. __le32 plcp_err;
  1269. __le32 crc32_err;
  1270. __le32 overrun_err;
  1271. __le32 early_overrun_err;
  1272. __le32 crc32_good;
  1273. __le32 false_alarm_cnt;
  1274. __le32 fina_sync_err_cnt;
  1275. __le32 sfd_timeout;
  1276. __le32 fina_timeout;
  1277. __le32 unresponded_rts;
  1278. __le32 rxe_frame_limit_overrun;
  1279. __le32 sent_ack_cnt;
  1280. __le32 sent_cts_cnt;
  1281. __le32 sent_ba_rsp_cnt;
  1282. __le32 dsp_self_kill;
  1283. __le32 mh_format_err;
  1284. __le32 re_acq_main_rssi_sum;
  1285. __le32 reserved3;
  1286. } __attribute__ ((packed));
  1287. struct statistics_rx_ht_phy {
  1288. __le32 plcp_err;
  1289. __le32 overrun_err;
  1290. __le32 early_overrun_err;
  1291. __le32 crc32_good;
  1292. __le32 crc32_err;
  1293. __le32 mh_format_err;
  1294. __le32 agg_crc32_good;
  1295. __le32 agg_mpdu_cnt;
  1296. __le32 agg_cnt;
  1297. __le32 reserved2;
  1298. } __attribute__ ((packed));
  1299. struct statistics_rx_non_phy {
  1300. __le32 bogus_cts; /* CTS received when not expecting CTS */
  1301. __le32 bogus_ack; /* ACK received when not expecting ACK */
  1302. __le32 non_bssid_frames; /* number of frames with BSSID that
  1303. * doesn't belong to the STA BSSID */
  1304. __le32 filtered_frames; /* count frames that were dumped in the
  1305. * filtering process */
  1306. __le32 non_channel_beacons; /* beacons with our bss id but not on
  1307. * our serving channel */
  1308. __le32 channel_beacons; /* beacons with our bss id and in our
  1309. * serving channel */
  1310. __le32 num_missed_bcon; /* number of missed beacons */
  1311. __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
  1312. * ADC was in saturation */
  1313. __le32 ina_detection_search_time;/* total time (in 0.8us) searched
  1314. * for INA */
  1315. __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
  1316. __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
  1317. __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
  1318. __le32 interference_data_flag; /* flag for interference data
  1319. * availability. 1 when data is
  1320. * available. */
  1321. __le32 channel_load; /* counts RX Enable time */
  1322. __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
  1323. * and CCK) counter */
  1324. __le32 beacon_rssi_a;
  1325. __le32 beacon_rssi_b;
  1326. __le32 beacon_rssi_c;
  1327. __le32 beacon_energy_a;
  1328. __le32 beacon_energy_b;
  1329. __le32 beacon_energy_c;
  1330. } __attribute__ ((packed));
  1331. struct statistics_rx {
  1332. struct statistics_rx_phy ofdm;
  1333. struct statistics_rx_phy cck;
  1334. struct statistics_rx_non_phy general;
  1335. struct statistics_rx_ht_phy ofdm_ht;
  1336. } __attribute__ ((packed));
  1337. struct statistics_tx_non_phy_agg {
  1338. __le32 ba_timeout;
  1339. __le32 ba_reschedule_frames;
  1340. __le32 scd_query_agg_frame_cnt;
  1341. __le32 scd_query_no_agg;
  1342. __le32 scd_query_agg;
  1343. __le32 scd_query_mismatch;
  1344. __le32 frame_not_ready;
  1345. __le32 underrun;
  1346. __le32 bt_prio_kill;
  1347. __le32 rx_ba_rsp_cnt;
  1348. __le32 reserved2;
  1349. __le32 reserved3;
  1350. } __attribute__ ((packed));
  1351. struct statistics_tx {
  1352. __le32 preamble_cnt;
  1353. __le32 rx_detected_cnt;
  1354. __le32 bt_prio_defer_cnt;
  1355. __le32 bt_prio_kill_cnt;
  1356. __le32 few_bytes_cnt;
  1357. __le32 cts_timeout;
  1358. __le32 ack_timeout;
  1359. __le32 expected_ack_cnt;
  1360. __le32 actual_ack_cnt;
  1361. __le32 dump_msdu_cnt;
  1362. __le32 burst_abort_next_frame_mismatch_cnt;
  1363. __le32 burst_abort_missing_next_frame_cnt;
  1364. __le32 cts_timeout_collision;
  1365. __le32 ack_or_ba_timeout_collision;
  1366. struct statistics_tx_non_phy_agg agg;
  1367. } __attribute__ ((packed));
  1368. struct statistics_dbg {
  1369. __le32 burst_check;
  1370. __le32 burst_count;
  1371. __le32 reserved[4];
  1372. } __attribute__ ((packed));
  1373. struct statistics_div {
  1374. __le32 tx_on_a;
  1375. __le32 tx_on_b;
  1376. __le32 exec_time;
  1377. __le32 probe_time;
  1378. __le32 reserved1;
  1379. __le32 reserved2;
  1380. } __attribute__ ((packed));
  1381. struct statistics_general {
  1382. __le32 temperature;
  1383. __le32 temperature_m;
  1384. struct statistics_dbg dbg;
  1385. __le32 sleep_time;
  1386. __le32 slots_out;
  1387. __le32 slots_idle;
  1388. __le32 ttl_timestamp;
  1389. struct statistics_div div;
  1390. __le32 rx_enable_counter;
  1391. __le32 reserved1;
  1392. __le32 reserved2;
  1393. __le32 reserved3;
  1394. } __attribute__ ((packed));
  1395. /*
  1396. * REPLY_STATISTICS_CMD = 0x9c,
  1397. * 3945 and 4965 identical.
  1398. *
  1399. * This command triggers an immediate response containing uCode statistics.
  1400. * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
  1401. *
  1402. * If the CLEAR_STATS configuration flag is set, uCode will clear its
  1403. * internal copy of the statistics (counters) after issuing the response.
  1404. * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
  1405. *
  1406. * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
  1407. * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
  1408. * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
  1409. */
  1410. #define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */
  1411. #define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */
  1412. struct iwl4965_statistics_cmd {
  1413. __le32 configuration_flags; /* IWL_STATS_CONF_* */
  1414. } __attribute__ ((packed));
  1415. /*
  1416. * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
  1417. *
  1418. * By default, uCode issues this notification after receiving a beacon
  1419. * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
  1420. * REPLY_STATISTICS_CMD 0x9c, above.
  1421. *
  1422. * Statistics counters continue to increment beacon after beacon, but are
  1423. * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
  1424. * 0x9c with CLEAR_STATS bit set (see above).
  1425. *
  1426. * uCode also issues this notification during scans. uCode clears statistics
  1427. * appropriately so that each notification contains statistics for only the
  1428. * one channel that has just been scanned.
  1429. */
  1430. #define STATISTICS_REPLY_FLG_BAND_24G_MSK __constant_cpu_to_le32(0x2)
  1431. #define STATISTICS_REPLY_FLG_FAT_MODE_MSK __constant_cpu_to_le32(0x8)
  1432. struct iwl4965_notif_statistics {
  1433. __le32 flag;
  1434. struct statistics_rx rx;
  1435. struct statistics_tx tx;
  1436. struct statistics_general general;
  1437. } __attribute__ ((packed));
  1438. /*
  1439. * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
  1440. */
  1441. /* if ucode missed CONSECUTIVE_MISSED_BCONS_TH beacons in a row,
  1442. * then this notification will be sent. */
  1443. #define CONSECUTIVE_MISSED_BCONS_TH 20
  1444. struct iwl4965_missed_beacon_notif {
  1445. __le32 consequtive_missed_beacons;
  1446. __le32 total_missed_becons;
  1447. __le32 num_expected_beacons;
  1448. __le32 num_recvd_beacons;
  1449. } __attribute__ ((packed));
  1450. /******************************************************************************
  1451. * (11)
  1452. * Rx Calibration Commands:
  1453. *
  1454. * With the uCode used for open source drivers, most Tx calibration (except
  1455. * for Tx Power) and most Rx calibration is done by uCode during the
  1456. * "initialize" phase of uCode boot. Driver must calibrate only:
  1457. *
  1458. * 1) Tx power (depends on temperature), described elsewhere
  1459. * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
  1460. * 3) Receiver sensitivity (to optimize signal detection)
  1461. *
  1462. *****************************************************************************/
  1463. /**
  1464. * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
  1465. *
  1466. * This command sets up the Rx signal detector for a sensitivity level that
  1467. * is high enough to lock onto all signals within the associated network,
  1468. * but low enough to ignore signals that are below a certain threshold, so as
  1469. * not to have too many "false alarms". False alarms are signals that the
  1470. * Rx DSP tries to lock onto, but then discards after determining that they
  1471. * are noise.
  1472. *
  1473. * The optimum number of false alarms is between 5 and 50 per 200 TUs
  1474. * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
  1475. * time listening, not transmitting). Driver must adjust sensitivity so that
  1476. * the ratio of actual false alarms to actual Rx time falls within this range.
  1477. *
  1478. * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
  1479. * received beacon. These provide information to the driver to analyze the
  1480. * sensitivity. Don't analyze statistics that come in from scanning, or any
  1481. * other non-associated-network source. Pertinent statistics include:
  1482. *
  1483. * From "general" statistics (struct statistics_rx_non_phy):
  1484. *
  1485. * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
  1486. * Measure of energy of desired signal. Used for establishing a level
  1487. * below which the device does not detect signals.
  1488. *
  1489. * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
  1490. * Measure of background noise in silent period after beacon.
  1491. *
  1492. * channel_load
  1493. * uSecs of actual Rx time during beacon period (varies according to
  1494. * how much time was spent transmitting).
  1495. *
  1496. * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
  1497. *
  1498. * false_alarm_cnt
  1499. * Signal locks abandoned early (before phy-level header).
  1500. *
  1501. * plcp_err
  1502. * Signal locks abandoned late (during phy-level header).
  1503. *
  1504. * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
  1505. * beacon to beacon, i.e. each value is an accumulation of all errors
  1506. * before and including the latest beacon. Values will wrap around to 0
  1507. * after counting up to 2^32 - 1. Driver must differentiate vs.
  1508. * previous beacon's values to determine # false alarms in the current
  1509. * beacon period.
  1510. *
  1511. * Total number of false alarms = false_alarms + plcp_errs
  1512. *
  1513. * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
  1514. * (notice that the start points for OFDM are at or close to settings for
  1515. * maximum sensitivity):
  1516. *
  1517. * START / MIN / MAX
  1518. * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
  1519. * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
  1520. * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
  1521. * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
  1522. *
  1523. * If actual rate of OFDM false alarms (+ plcp_errors) is too high
  1524. * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
  1525. * by *adding* 1 to all 4 of the table entries above, up to the max for
  1526. * each entry. Conversely, if false alarm rate is too low (less than 5
  1527. * for each 204.8 msecs listening), *subtract* 1 from each entry to
  1528. * increase sensitivity.
  1529. *
  1530. * For CCK sensitivity, keep track of the following:
  1531. *
  1532. * 1). 20-beacon history of maximum background noise, indicated by
  1533. * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
  1534. * 3 receivers. For any given beacon, the "silence reference" is
  1535. * the maximum of last 60 samples (20 beacons * 3 receivers).
  1536. *
  1537. * 2). 10-beacon history of strongest signal level, as indicated
  1538. * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
  1539. * i.e. the strength of the signal through the best receiver at the
  1540. * moment. These measurements are "upside down", with lower values
  1541. * for stronger signals, so max energy will be *minimum* value.
  1542. *
  1543. * Then for any given beacon, the driver must determine the *weakest*
  1544. * of the strongest signals; this is the minimum level that needs to be
  1545. * successfully detected, when using the best receiver at the moment.
  1546. * "Max cck energy" is the maximum (higher value means lower energy!)
  1547. * of the last 10 minima. Once this is determined, driver must add
  1548. * a little margin by adding "6" to it.
  1549. *
  1550. * 3). Number of consecutive beacon periods with too few false alarms.
  1551. * Reset this to 0 at the first beacon period that falls within the
  1552. * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
  1553. *
  1554. * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
  1555. * (notice that the start points for CCK are at maximum sensitivity):
  1556. *
  1557. * START / MIN / MAX
  1558. * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
  1559. * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
  1560. * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
  1561. *
  1562. * If actual rate of CCK false alarms (+ plcp_errors) is too high
  1563. * (greater than 50 for each 204.8 msecs listening), method for reducing
  1564. * sensitivity is:
  1565. *
  1566. * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
  1567. * up to max 400.
  1568. *
  1569. * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
  1570. * sensitivity has been reduced a significant amount; bring it up to
  1571. * a moderate 161. Otherwise, *add* 3, up to max 200.
  1572. *
  1573. * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
  1574. * sensitivity has been reduced only a moderate or small amount;
  1575. * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
  1576. * down to min 0. Otherwise (if gain has been significantly reduced),
  1577. * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
  1578. *
  1579. * b) Save a snapshot of the "silence reference".
  1580. *
  1581. * If actual rate of CCK false alarms (+ plcp_errors) is too low
  1582. * (less than 5 for each 204.8 msecs listening), method for increasing
  1583. * sensitivity is used only if:
  1584. *
  1585. * 1a) Previous beacon did not have too many false alarms
  1586. * 1b) AND difference between previous "silence reference" and current
  1587. * "silence reference" (prev - current) is 2 or more,
  1588. * OR 2) 100 or more consecutive beacon periods have had rate of
  1589. * less than 5 false alarms per 204.8 milliseconds rx time.
  1590. *
  1591. * Method for increasing sensitivity:
  1592. *
  1593. * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
  1594. * down to min 125.
  1595. *
  1596. * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
  1597. * down to min 200.
  1598. *
  1599. * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
  1600. *
  1601. * If actual rate of CCK false alarms (+ plcp_errors) is within good range
  1602. * (between 5 and 50 for each 204.8 msecs listening):
  1603. *
  1604. * 1) Save a snapshot of the silence reference.
  1605. *
  1606. * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
  1607. * give some extra margin to energy threshold by *subtracting* 8
  1608. * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
  1609. *
  1610. * For all cases (too few, too many, good range), make sure that the CCK
  1611. * detection threshold (energy) is below the energy level for robust
  1612. * detection over the past 10 beacon periods, the "Max cck energy".
  1613. * Lower values mean higher energy; this means making sure that the value
  1614. * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
  1615. *
  1616. * Driver should set the following entries to fixed values:
  1617. *
  1618. * HD_MIN_ENERGY_OFDM_DET_INDEX 100
  1619. * HD_BARKER_CORR_TH_ADD_MIN_INDEX 190
  1620. * HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX 390
  1621. * HD_OFDM_ENERGY_TH_IN_INDEX 62
  1622. */
  1623. /*
  1624. * Table entries in SENSITIVITY_CMD (struct iwl4965_sensitivity_cmd)
  1625. */
  1626. #define HD_TABLE_SIZE (11) /* number of entries */
  1627. #define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
  1628. #define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
  1629. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
  1630. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
  1631. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
  1632. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
  1633. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
  1634. #define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
  1635. #define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
  1636. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
  1637. #define HD_OFDM_ENERGY_TH_IN_INDEX (10)
  1638. /* Control field in struct iwl4965_sensitivity_cmd */
  1639. #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE __constant_cpu_to_le16(0)
  1640. #define SENSITIVITY_CMD_CONTROL_WORK_TABLE __constant_cpu_to_le16(1)
  1641. /**
  1642. * struct iwl4965_sensitivity_cmd
  1643. * @control: (1) updates working table, (0) updates default table
  1644. * @table: energy threshold values, use HD_* as index into table
  1645. *
  1646. * Always use "1" in "control" to update uCode's working table and DSP.
  1647. */
  1648. struct iwl4965_sensitivity_cmd {
  1649. __le16 control; /* always use "1" */
  1650. __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
  1651. } __attribute__ ((packed));
  1652. /**
  1653. * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
  1654. *
  1655. * This command sets the relative gains of 4965's 3 radio receiver chains.
  1656. *
  1657. * After the first association, driver should accumulate signal and noise
  1658. * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
  1659. * beacons from the associated network (don't collect statistics that come
  1660. * in from scanning, or any other non-network source).
  1661. *
  1662. * DISCONNECTED ANTENNA:
  1663. *
  1664. * Driver should determine which antennas are actually connected, by comparing
  1665. * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
  1666. * following values over 20 beacons, one accumulator for each of the chains
  1667. * a/b/c, from struct statistics_rx_non_phy:
  1668. *
  1669. * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
  1670. *
  1671. * Find the strongest signal from among a/b/c. Compare the other two to the
  1672. * strongest. If any signal is more than 15 dB (times 20, unless you
  1673. * divide the accumulated values by 20) below the strongest, the driver
  1674. * considers that antenna to be disconnected, and should not try to use that
  1675. * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
  1676. * driver should declare the stronger one as connected, and attempt to use it
  1677. * (A and B are the only 2 Tx chains!).
  1678. *
  1679. *
  1680. * RX BALANCE:
  1681. *
  1682. * Driver should balance the 3 receivers (but just the ones that are connected
  1683. * to antennas, see above) for gain, by comparing the average signal levels
  1684. * detected during the silence after each beacon (background noise).
  1685. * Accumulate (add) the following values over 20 beacons, one accumulator for
  1686. * each of the chains a/b/c, from struct statistics_rx_non_phy:
  1687. *
  1688. * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
  1689. *
  1690. * Find the weakest background noise level from among a/b/c. This Rx chain
  1691. * will be the reference, with 0 gain adjustment. Attenuate other channels by
  1692. * finding noise difference:
  1693. *
  1694. * (accum_noise[i] - accum_noise[reference]) / 30
  1695. *
  1696. * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
  1697. * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
  1698. * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
  1699. * and set bit 2 to indicate "reduce gain". The value for the reference
  1700. * (weakest) chain should be "0".
  1701. *
  1702. * diff_gain_[abc] bit fields:
  1703. * 2: (1) reduce gain, (0) increase gain
  1704. * 1-0: amount of gain, units of 1.5 dB
  1705. */
  1706. /* "Differential Gain" opcode used in REPLY_PHY_CALIBRATION_CMD. */
  1707. #define PHY_CALIBRATE_DIFF_GAIN_CMD (7)
  1708. struct iwl4965_calibration_cmd {
  1709. u8 opCode; /* PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
  1710. u8 flags; /* not used */
  1711. __le16 reserved;
  1712. s8 diff_gain_a; /* see above */
  1713. s8 diff_gain_b;
  1714. s8 diff_gain_c;
  1715. u8 reserved1;
  1716. } __attribute__ ((packed));
  1717. /******************************************************************************
  1718. * (12)
  1719. * Miscellaneous Commands:
  1720. *
  1721. *****************************************************************************/
  1722. /*
  1723. * LEDs Command & Response
  1724. * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
  1725. *
  1726. * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
  1727. * this command turns it on or off, or sets up a periodic blinking cycle.
  1728. */
  1729. struct iwl4965_led_cmd {
  1730. __le32 interval; /* "interval" in uSec */
  1731. u8 id; /* 1: Activity, 2: Link, 3: Tech */
  1732. u8 off; /* # intervals off while blinking;
  1733. * "0", with >0 "on" value, turns LED on */
  1734. u8 on; /* # intervals on while blinking;
  1735. * "0", regardless of "off", turns LED off */
  1736. u8 reserved;
  1737. } __attribute__ ((packed));
  1738. /******************************************************************************
  1739. * (13)
  1740. * Union of all expected notifications/responses:
  1741. *
  1742. *****************************************************************************/
  1743. struct iwl4965_rx_packet {
  1744. __le32 len;
  1745. struct iwl4965_cmd_header hdr;
  1746. union {
  1747. struct iwl4965_alive_resp alive_frame;
  1748. struct iwl4965_rx_frame rx_frame;
  1749. struct iwl4965_tx_resp tx_resp;
  1750. struct iwl4965_spectrum_notification spectrum_notif;
  1751. struct iwl4965_csa_notification csa_notif;
  1752. struct iwl4965_error_resp err_resp;
  1753. struct iwl4965_card_state_notif card_state_notif;
  1754. struct iwl4965_beacon_notif beacon_status;
  1755. struct iwl4965_add_sta_resp add_sta;
  1756. struct iwl4965_sleep_notification sleep_notif;
  1757. struct iwl4965_spectrum_resp spectrum;
  1758. struct iwl4965_notif_statistics stats;
  1759. struct iwl4965_compressed_ba_resp compressed_ba;
  1760. struct iwl4965_missed_beacon_notif missed_beacon;
  1761. __le32 status;
  1762. u8 raw[0];
  1763. } u;
  1764. } __attribute__ ((packed));
  1765. #define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame))
  1766. #endif /* __iwl4965_commands_h__ */