iwl-4965-commands.h 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319
  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. /* Bluetooth device coexistance config command */
  113. REPLY_BT_CONFIG = 0x9b,
  114. /* 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, txpower
  135. *
  136. *****************************************************************************/
  137. /* iwl4965_cmd_header flags value */
  138. #define IWL_CMD_FAILED_MSK 0x40
  139. /**
  140. * struct iwl4965_cmd_header
  141. *
  142. * This header format appears in the beginning of each command sent from the
  143. * driver, and each response/notification received from uCode.
  144. */
  145. struct iwl4965_cmd_header {
  146. u8 cmd; /* Command ID: REPLY_RXON, etc. */
  147. u8 flags; /* IWL_CMD_* */
  148. /*
  149. * The driver sets up the sequence number to values of its chosing.
  150. * uCode does not use this value, but passes it back to the driver
  151. * when sending the response to each driver-originated command, so
  152. * the driver can match the response to the command. Since the values
  153. * don't get used by uCode, the driver may set up an arbitrary format.
  154. *
  155. * There is one exception: uCode sets bit 15 when it originates
  156. * the response/notification, i.e. when the response/notification
  157. * is not a direct response to a command sent by the driver. For
  158. * example, uCode issues REPLY_3945_RX when it sends a received frame
  159. * to the driver; it is not a direct response to any driver command.
  160. *
  161. * The Linux driver uses the following format:
  162. *
  163. * 0:7 index/position within Tx queue
  164. * 8:13 Tx queue selection
  165. * 14:14 driver sets this to indicate command is in the 'huge'
  166. * storage at the end of the command buffers, i.e. scan cmd
  167. * 15:15 uCode sets this in uCode-originated response/notification
  168. */
  169. __le16 sequence;
  170. /* command or response/notification data follows immediately */
  171. u8 data[0];
  172. } __attribute__ ((packed));
  173. /**
  174. * 4965 rate_n_flags bit fields
  175. *
  176. * rate_n_flags format is used in following 4965 commands:
  177. * REPLY_4965_RX (response only)
  178. * REPLY_TX (both command and response)
  179. * REPLY_TX_LINK_QUALITY_CMD
  180. *
  181. * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
  182. * 2-0: 0) 6 Mbps
  183. * 1) 12 Mbps
  184. * 2) 18 Mbps
  185. * 3) 24 Mbps
  186. * 4) 36 Mbps
  187. * 5) 48 Mbps
  188. * 6) 54 Mbps
  189. * 7) 60 Mbps
  190. *
  191. * 3: 0) Single stream (SISO)
  192. * 1) Dual stream (MIMO)
  193. *
  194. * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps FAT duplicate data
  195. *
  196. * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
  197. * 3-0: 0xD) 6 Mbps
  198. * 0xF) 9 Mbps
  199. * 0x5) 12 Mbps
  200. * 0x7) 18 Mbps
  201. * 0x9) 24 Mbps
  202. * 0xB) 36 Mbps
  203. * 0x1) 48 Mbps
  204. * 0x3) 54 Mbps
  205. *
  206. * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
  207. * 3-0: 10) 1 Mbps
  208. * 20) 2 Mbps
  209. * 55) 5.5 Mbps
  210. * 110) 11 Mbps
  211. */
  212. #define RATE_MCS_CODE_MSK 0x7
  213. #define RATE_MCS_MIMO_POS 3
  214. #define RATE_MCS_MIMO_MSK 0x8
  215. #define RATE_MCS_HT_DUP_POS 5
  216. #define RATE_MCS_HT_DUP_MSK 0x20
  217. /* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
  218. #define RATE_MCS_FLAGS_POS 8
  219. #define RATE_MCS_HT_POS 8
  220. #define RATE_MCS_HT_MSK 0x100
  221. /* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */
  222. #define RATE_MCS_CCK_POS 9
  223. #define RATE_MCS_CCK_MSK 0x200
  224. /* Bit 10: (1) Use Green Field preamble */
  225. #define RATE_MCS_GF_POS 10
  226. #define RATE_MCS_GF_MSK 0x400
  227. /* Bit 11: (1) Use 40Mhz FAT chnl width, (0) use 20 MHz legacy chnl width */
  228. #define RATE_MCS_FAT_POS 11
  229. #define RATE_MCS_FAT_MSK 0x800
  230. /* Bit 12: (1) Duplicate data on both 20MHz chnls. FAT (bit 11) must be set. */
  231. #define RATE_MCS_DUP_POS 12
  232. #define RATE_MCS_DUP_MSK 0x1000
  233. /* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
  234. #define RATE_MCS_SGI_POS 13
  235. #define RATE_MCS_SGI_MSK 0x2000
  236. /**
  237. * rate_n_flags Tx antenna masks (4965 has 2 transmitters):
  238. * bit14:15 01 B inactive, A active
  239. * 10 B active, A inactive
  240. * 11 Both active
  241. */
  242. #define RATE_MCS_ANT_A_POS 14
  243. #define RATE_MCS_ANT_B_POS 15
  244. #define RATE_MCS_ANT_A_MSK 0x4000
  245. #define RATE_MCS_ANT_B_MSK 0x8000
  246. #define RATE_MCS_ANT_AB_MSK 0xc000
  247. /**
  248. * struct iwl4965_tx_power - txpower format used in REPLY_SCAN_CMD
  249. *
  250. * Scan uses only one transmitter, so only one analog/dsp gain pair is needed.
  251. */
  252. struct iwl4965_tx_power {
  253. u8 tx_gain; /* gain for analog radio */
  254. u8 dsp_atten; /* gain for DSP */
  255. } __attribute__ ((packed));
  256. #define POWER_TABLE_NUM_ENTRIES 33
  257. #define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
  258. #define POWER_TABLE_CCK_ENTRY 32
  259. /**
  260. * union iwl4965_tx_power_dual_stream
  261. *
  262. * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
  263. * Use __le32 version (struct tx_power_dual_stream) when building command.
  264. *
  265. * Driver provides radio gain and DSP attenuation settings to device in pairs,
  266. * one value for each transmitter chain. The first value is for transmitter A,
  267. * second for transmitter B.
  268. *
  269. * For SISO bit rates, both values in a pair should be identical.
  270. * For MIMO rates, one value may be different from the other,
  271. * in order to balance the Tx output between the two transmitters.
  272. *
  273. * See more details in doc for TXPOWER in iwl-4965-hw.h.
  274. */
  275. union iwl4965_tx_power_dual_stream {
  276. struct {
  277. u8 radio_tx_gain[2];
  278. u8 dsp_predis_atten[2];
  279. } s;
  280. u32 dw;
  281. };
  282. /**
  283. * struct tx_power_dual_stream
  284. *
  285. * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
  286. *
  287. * Same format as iwl_tx_power_dual_stream, but __le32
  288. */
  289. struct tx_power_dual_stream {
  290. __le32 dw;
  291. } __attribute__ ((packed));
  292. /**
  293. * struct iwl4965_tx_power_db
  294. *
  295. * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
  296. */
  297. struct iwl4965_tx_power_db {
  298. struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
  299. } __attribute__ ((packed));
  300. /******************************************************************************
  301. * (0a)
  302. * Alive and Error Commands & Responses:
  303. *
  304. *****************************************************************************/
  305. #define UCODE_VALID_OK __constant_cpu_to_le32(0x1)
  306. #define INITIALIZE_SUBTYPE (9)
  307. /*
  308. * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
  309. *
  310. * uCode issues this "initialize alive" notification once the initialization
  311. * uCode image has completed its work, and is ready to load the runtime image.
  312. * This is the *first* "alive" notification that the driver will receive after
  313. * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
  314. *
  315. * See comments documenting "BSM" (bootstrap state machine).
  316. *
  317. * For 4965, this notification contains important calibration data for
  318. * calculating txpower settings:
  319. *
  320. * 1) Power supply voltage indication. The voltage sensor outputs higher
  321. * values for lower voltage, and vice versa.
  322. *
  323. * 2) Temperature measurement parameters, for each of two channel widths
  324. * (20 MHz and 40 MHz) supported by the radios. Temperature sensing
  325. * is done via one of the receiver chains, and channel width influences
  326. * the results.
  327. *
  328. * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
  329. * for each of 5 frequency ranges.
  330. */
  331. struct iwl4965_init_alive_resp {
  332. u8 ucode_minor;
  333. u8 ucode_major;
  334. __le16 reserved1;
  335. u8 sw_rev[8];
  336. u8 ver_type;
  337. u8 ver_subtype; /* "9" for initialize alive */
  338. __le16 reserved2;
  339. __le32 log_event_table_ptr;
  340. __le32 error_event_table_ptr;
  341. __le32 timestamp;
  342. __le32 is_valid;
  343. /* calibration values from "initialize" uCode */
  344. __le32 voltage; /* signed, higher value is lower voltage */
  345. __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for FAT channel*/
  346. __le32 therm_r2[2]; /* signed */
  347. __le32 therm_r3[2]; /* signed */
  348. __le32 therm_r4[2]; /* signed */
  349. __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups,
  350. * 2 Tx chains */
  351. } __attribute__ ((packed));
  352. /**
  353. * REPLY_ALIVE = 0x1 (response only, not a command)
  354. *
  355. * uCode issues this "alive" notification once the runtime image is ready
  356. * to receive commands from the driver. This is the *second* "alive"
  357. * notification that the driver will receive after rebooting uCode;
  358. * this "alive" is indicated by subtype field != 9.
  359. *
  360. * See comments documenting "BSM" (bootstrap state machine).
  361. *
  362. * This response includes two pointers to structures within the device's
  363. * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
  364. *
  365. * 1) log_event_table_ptr indicates base of the event log. This traces
  366. * a 256-entry history of uCode execution within a circular buffer.
  367. * Its header format is:
  368. *
  369. * __le32 log_size; log capacity (in number of entries)
  370. * __le32 type; (1) timestamp with each entry, (0) no timestamp
  371. * __le32 wraps; # times uCode has wrapped to top of circular buffer
  372. * __le32 write_index; next circular buffer entry that uCode would fill
  373. *
  374. * The header is followed by the circular buffer of log entries. Entries
  375. * with timestamps have the following format:
  376. *
  377. * __le32 event_id; range 0 - 1500
  378. * __le32 timestamp; low 32 bits of TSF (of network, if associated)
  379. * __le32 data; event_id-specific data value
  380. *
  381. * Entries without timestamps contain only event_id and data.
  382. *
  383. * 2) error_event_table_ptr indicates base of the error log. This contains
  384. * information about any uCode error that occurs. For 4965, the format
  385. * of the error log is:
  386. *
  387. * __le32 valid; (nonzero) valid, (0) log is empty
  388. * __le32 error_id; type of error
  389. * __le32 pc; program counter
  390. * __le32 blink1; branch link
  391. * __le32 blink2; branch link
  392. * __le32 ilink1; interrupt link
  393. * __le32 ilink2; interrupt link
  394. * __le32 data1; error-specific data
  395. * __le32 data2; error-specific data
  396. * __le32 line; source code line of error
  397. * __le32 bcon_time; beacon timer
  398. * __le32 tsf_low; network timestamp function timer
  399. * __le32 tsf_hi; network timestamp function timer
  400. *
  401. * The Linux driver can print both logs to the system log when a uCode error
  402. * occurs.
  403. */
  404. struct iwl4965_alive_resp {
  405. u8 ucode_minor;
  406. u8 ucode_major;
  407. __le16 reserved1;
  408. u8 sw_rev[8];
  409. u8 ver_type;
  410. u8 ver_subtype; /* not "9" for runtime alive */
  411. __le16 reserved2;
  412. __le32 log_event_table_ptr; /* SRAM address for event log */
  413. __le32 error_event_table_ptr; /* SRAM address for error log */
  414. __le32 timestamp;
  415. __le32 is_valid;
  416. } __attribute__ ((packed));
  417. union tsf {
  418. u8 byte[8];
  419. __le16 word[4];
  420. __le32 dw[2];
  421. };
  422. /*
  423. * REPLY_ERROR = 0x2 (response only, not a command)
  424. */
  425. struct iwl4965_error_resp {
  426. __le32 error_type;
  427. u8 cmd_id;
  428. u8 reserved1;
  429. __le16 bad_cmd_seq_num;
  430. __le32 error_info;
  431. union tsf timestamp;
  432. } __attribute__ ((packed));
  433. /******************************************************************************
  434. * (1)
  435. * RXON Commands & Responses:
  436. *
  437. *****************************************************************************/
  438. /*
  439. * Rx config defines & structure
  440. */
  441. /* rx_config device types */
  442. enum {
  443. RXON_DEV_TYPE_AP = 1,
  444. RXON_DEV_TYPE_ESS = 3,
  445. RXON_DEV_TYPE_IBSS = 4,
  446. RXON_DEV_TYPE_SNIFFER = 6,
  447. };
  448. #define RXON_RX_CHAIN_DRIVER_FORCE_MSK __constant_cpu_to_le16(0x1<<0)
  449. #define RXON_RX_CHAIN_VALID_MSK __constant_cpu_to_le16(0x7<<1)
  450. #define RXON_RX_CHAIN_VALID_POS (1)
  451. #define RXON_RX_CHAIN_FORCE_SEL_MSK __constant_cpu_to_le16(0x7<<4)
  452. #define RXON_RX_CHAIN_FORCE_SEL_POS (4)
  453. #define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK __constant_cpu_to_le16(0x7<<7)
  454. #define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
  455. #define RXON_RX_CHAIN_CNT_MSK __constant_cpu_to_le16(0x3<<10)
  456. #define RXON_RX_CHAIN_CNT_POS (10)
  457. #define RXON_RX_CHAIN_MIMO_CNT_MSK __constant_cpu_to_le16(0x3<<12)
  458. #define RXON_RX_CHAIN_MIMO_CNT_POS (12)
  459. #define RXON_RX_CHAIN_MIMO_FORCE_MSK __constant_cpu_to_le16(0x1<<14)
  460. #define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
  461. /* rx_config flags */
  462. /* band & modulation selection */
  463. #define RXON_FLG_BAND_24G_MSK __constant_cpu_to_le32(1 << 0)
  464. #define RXON_FLG_CCK_MSK __constant_cpu_to_le32(1 << 1)
  465. /* auto detection enable */
  466. #define RXON_FLG_AUTO_DETECT_MSK __constant_cpu_to_le32(1 << 2)
  467. /* TGg protection when tx */
  468. #define RXON_FLG_TGG_PROTECT_MSK __constant_cpu_to_le32(1 << 3)
  469. /* cck short slot & preamble */
  470. #define RXON_FLG_SHORT_SLOT_MSK __constant_cpu_to_le32(1 << 4)
  471. #define RXON_FLG_SHORT_PREAMBLE_MSK __constant_cpu_to_le32(1 << 5)
  472. /* antenna selection */
  473. #define RXON_FLG_DIS_DIV_MSK __constant_cpu_to_le32(1 << 7)
  474. #define RXON_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0x0f00)
  475. #define RXON_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
  476. #define RXON_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
  477. /* radar detection enable */
  478. #define RXON_FLG_RADAR_DETECT_MSK __constant_cpu_to_le32(1 << 12)
  479. #define RXON_FLG_TGJ_NARROW_BAND_MSK __constant_cpu_to_le32(1 << 13)
  480. /* rx response to host with 8-byte TSF
  481. * (according to ON_AIR deassertion) */
  482. #define RXON_FLG_TSF2HOST_MSK __constant_cpu_to_le32(1 << 15)
  483. /* HT flags */
  484. #define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
  485. #define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK __constant_cpu_to_le32(0x1<<22)
  486. #define RXON_FLG_HT_OPERATING_MODE_POS (23)
  487. #define RXON_FLG_HT_PROT_MSK __constant_cpu_to_le32(0x1<<23)
  488. #define RXON_FLG_FAT_PROT_MSK __constant_cpu_to_le32(0x2<<23)
  489. #define RXON_FLG_CHANNEL_MODE_POS (25)
  490. #define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3<<25)
  491. #define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1<<25)
  492. #define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2<<25)
  493. /* rx_config filter flags */
  494. /* accept all data frames */
  495. #define RXON_FILTER_PROMISC_MSK __constant_cpu_to_le32(1 << 0)
  496. /* pass control & management to host */
  497. #define RXON_FILTER_CTL2HOST_MSK __constant_cpu_to_le32(1 << 1)
  498. /* accept multi-cast */
  499. #define RXON_FILTER_ACCEPT_GRP_MSK __constant_cpu_to_le32(1 << 2)
  500. /* don't decrypt uni-cast frames */
  501. #define RXON_FILTER_DIS_DECRYPT_MSK __constant_cpu_to_le32(1 << 3)
  502. /* don't decrypt multi-cast frames */
  503. #define RXON_FILTER_DIS_GRP_DECRYPT_MSK __constant_cpu_to_le32(1 << 4)
  504. /* STA is associated */
  505. #define RXON_FILTER_ASSOC_MSK __constant_cpu_to_le32(1 << 5)
  506. /* transfer to host non bssid beacons in associated state */
  507. #define RXON_FILTER_BCON_AWARE_MSK __constant_cpu_to_le32(1 << 6)
  508. /**
  509. * REPLY_RXON = 0x10 (command, has simple generic response)
  510. *
  511. * RXON tunes the radio tuner to a service channel, and sets up a number
  512. * of parameters that are used primarily for Rx, but also for Tx operations.
  513. *
  514. * NOTE: When tuning to a new channel, driver must set the
  515. * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent
  516. * info within the device, including the station tables, tx retry
  517. * rate tables, and txpower tables. Driver must build a new station
  518. * table and txpower table before transmitting anything on the RXON
  519. * channel.
  520. *
  521. * NOTE: All RXONs wipe clean the internal txpower table. Driver must
  522. * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
  523. * regardless of whether RXON_FILTER_ASSOC_MSK is set.
  524. */
  525. struct iwl4965_rxon_cmd {
  526. u8 node_addr[6];
  527. __le16 reserved1;
  528. u8 bssid_addr[6];
  529. __le16 reserved2;
  530. u8 wlap_bssid_addr[6];
  531. __le16 reserved3;
  532. u8 dev_type;
  533. u8 air_propagation;
  534. __le16 rx_chain;
  535. u8 ofdm_basic_rates;
  536. u8 cck_basic_rates;
  537. __le16 assoc_id;
  538. __le32 flags;
  539. __le32 filter_flags;
  540. __le16 channel;
  541. u8 ofdm_ht_single_stream_basic_rates;
  542. u8 ofdm_ht_dual_stream_basic_rates;
  543. } __attribute__ ((packed));
  544. /*
  545. * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
  546. */
  547. struct iwl4965_rxon_assoc_cmd {
  548. __le32 flags;
  549. __le32 filter_flags;
  550. u8 ofdm_basic_rates;
  551. u8 cck_basic_rates;
  552. u8 ofdm_ht_single_stream_basic_rates;
  553. u8 ofdm_ht_dual_stream_basic_rates;
  554. __le16 rx_chain_select_flags;
  555. __le16 reserved;
  556. } __attribute__ ((packed));
  557. /*
  558. * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
  559. */
  560. struct iwl4965_rxon_time_cmd {
  561. union tsf timestamp;
  562. __le16 beacon_interval;
  563. __le16 atim_window;
  564. __le32 beacon_init_val;
  565. __le16 listen_interval;
  566. __le16 reserved;
  567. } __attribute__ ((packed));
  568. /*
  569. * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
  570. */
  571. struct iwl4965_channel_switch_cmd {
  572. u8 band;
  573. u8 expect_beacon;
  574. __le16 channel;
  575. __le32 rxon_flags;
  576. __le32 rxon_filter_flags;
  577. __le32 switch_time;
  578. struct iwl4965_tx_power_db tx_power;
  579. } __attribute__ ((packed));
  580. /*
  581. * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
  582. */
  583. struct iwl4965_csa_notification {
  584. __le16 band;
  585. __le16 channel;
  586. __le32 status; /* 0 - OK, 1 - fail */
  587. } __attribute__ ((packed));
  588. /******************************************************************************
  589. * (2)
  590. * Quality-of-Service (QOS) Commands & Responses:
  591. *
  592. *****************************************************************************/
  593. /**
  594. * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
  595. * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
  596. *
  597. * @cw_min: Contention window, start value in numbers of slots.
  598. * Should be a power-of-2, minus 1. Device's default is 0x0f.
  599. * @cw_max: Contention window, max value in numbers of slots.
  600. * Should be a power-of-2, minus 1. Device's default is 0x3f.
  601. * @aifsn: Number of slots in Arbitration Interframe Space (before
  602. * performing random backoff timing prior to Tx). Device default 1.
  603. * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
  604. *
  605. * Device will automatically increase contention window by (2*CW) + 1 for each
  606. * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
  607. * value, to cap the CW value.
  608. */
  609. struct iwl4965_ac_qos {
  610. __le16 cw_min;
  611. __le16 cw_max;
  612. u8 aifsn;
  613. u8 reserved1;
  614. __le16 edca_txop;
  615. } __attribute__ ((packed));
  616. /* QoS flags defines */
  617. #define QOS_PARAM_FLG_UPDATE_EDCA_MSK __constant_cpu_to_le32(0x01)
  618. #define QOS_PARAM_FLG_TGN_MSK __constant_cpu_to_le32(0x02)
  619. #define QOS_PARAM_FLG_TXOP_TYPE_MSK __constant_cpu_to_le32(0x10)
  620. /* Number of Access Categories (AC) (EDCA), queues 0..3 */
  621. #define AC_NUM 4
  622. /*
  623. * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
  624. *
  625. * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
  626. * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
  627. */
  628. struct iwl4965_qosparam_cmd {
  629. __le32 qos_flags;
  630. struct iwl4965_ac_qos ac[AC_NUM];
  631. } __attribute__ ((packed));
  632. /******************************************************************************
  633. * (3)
  634. * Add/Modify Stations Commands & Responses:
  635. *
  636. *****************************************************************************/
  637. /*
  638. * Multi station support
  639. */
  640. /* Special, dedicated locations within device's station table */
  641. #define IWL_AP_ID 0
  642. #define IWL_MULTICAST_ID 1
  643. #define IWL_STA_ID 2
  644. #define IWL4965_BROADCAST_ID 31
  645. #define IWL4965_STATION_COUNT 32
  646. #define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/
  647. #define IWL_INVALID_STATION 255
  648. #define STA_FLG_PWR_SAVE_MSK __constant_cpu_to_le32(1<<8);
  649. #define STA_FLG_RTS_MIMO_PROT_MSK __constant_cpu_to_le32(1 << 17)
  650. #define STA_FLG_AGG_MPDU_8US_MSK __constant_cpu_to_le32(1 << 18)
  651. #define STA_FLG_MAX_AGG_SIZE_POS (19)
  652. #define STA_FLG_MAX_AGG_SIZE_MSK __constant_cpu_to_le32(3 << 19)
  653. #define STA_FLG_FAT_EN_MSK __constant_cpu_to_le32(1 << 21)
  654. #define STA_FLG_MIMO_DIS_MSK __constant_cpu_to_le32(1 << 22)
  655. #define STA_FLG_AGG_MPDU_DENSITY_POS (23)
  656. #define STA_FLG_AGG_MPDU_DENSITY_MSK __constant_cpu_to_le32(7 << 23)
  657. /* Use in mode field. 1: modify existing entry, 0: add new station entry */
  658. #define STA_CONTROL_MODIFY_MSK 0x01
  659. /* key flags __le16*/
  660. #define STA_KEY_FLG_ENCRYPT_MSK __constant_cpu_to_le16(0x7)
  661. #define STA_KEY_FLG_NO_ENC __constant_cpu_to_le16(0x0)
  662. #define STA_KEY_FLG_WEP __constant_cpu_to_le16(0x1)
  663. #define STA_KEY_FLG_CCMP __constant_cpu_to_le16(0x2)
  664. #define STA_KEY_FLG_TKIP __constant_cpu_to_le16(0x3)
  665. #define STA_KEY_FLG_KEYID_POS 8
  666. #define STA_KEY_FLG_INVALID __constant_cpu_to_le16(0x0800)
  667. /* Flags indicate whether to modify vs. don't change various station params */
  668. #define STA_MODIFY_KEY_MASK 0x01
  669. #define STA_MODIFY_TID_DISABLE_TX 0x02
  670. #define STA_MODIFY_TX_RATE_MSK 0x04
  671. #define STA_MODIFY_ADDBA_TID_MSK 0x08
  672. #define STA_MODIFY_DELBA_TID_MSK 0x10
  673. /* Receiver address (actually, Rx station's index into station table),
  674. * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
  675. #define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid))
  676. struct iwl4965_keyinfo {
  677. __le16 key_flags;
  678. u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
  679. u8 reserved1;
  680. __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
  681. __le16 reserved2;
  682. u8 key[16]; /* 16-byte unicast decryption key */
  683. } __attribute__ ((packed));
  684. /**
  685. * struct sta_id_modify
  686. * @addr[ETH_ALEN]: station's MAC address
  687. * @sta_id: index of station in uCode's station table
  688. * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
  689. *
  690. * Driver selects unused table index when adding new station,
  691. * or the index to a pre-existing station entry when modifying that station.
  692. * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
  693. *
  694. * modify_mask flags select which parameters to modify vs. leave alone.
  695. */
  696. struct sta_id_modify {
  697. u8 addr[ETH_ALEN];
  698. __le16 reserved1;
  699. u8 sta_id;
  700. u8 modify_mask;
  701. __le16 reserved2;
  702. } __attribute__ ((packed));
  703. /*
  704. * REPLY_ADD_STA = 0x18 (command)
  705. *
  706. * The device contains an internal table of per-station information,
  707. * with info on security keys, aggregation parameters, and Tx rates for
  708. * initial Tx attempt and any retries (4965 uses REPLY_TX_LINK_QUALITY_CMD,
  709. * 3945 uses REPLY_RATE_SCALE to set up rate tables).
  710. *
  711. * REPLY_ADD_STA sets up the table entry for one station, either creating
  712. * a new entry, or modifying a pre-existing one.
  713. *
  714. * NOTE: RXON command (without "associated" bit set) wipes the station table
  715. * clean. Moving into RF_KILL state does this also. Driver must set up
  716. * new station table before transmitting anything on the RXON channel
  717. * (except active scans or active measurements; those commands carry
  718. * their own txpower/rate setup data).
  719. *
  720. * When getting started on a new channel, driver must set up the
  721. * IWL_BROADCAST_ID entry (last entry in the table). For a client
  722. * station in a BSS, once an AP is selected, driver sets up the AP STA
  723. * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP
  724. * are all that are needed for a BSS client station. If the device is
  725. * used as AP, or in an IBSS network, driver must set up station table
  726. * entries for all STAs in network, starting with index IWL_STA_ID.
  727. */
  728. struct iwl4965_addsta_cmd {
  729. u8 mode; /* 1: modify existing, 0: add new station */
  730. u8 reserved[3];
  731. struct sta_id_modify sta;
  732. struct iwl4965_keyinfo key;
  733. __le32 station_flags; /* STA_FLG_* */
  734. __le32 station_flags_msk; /* STA_FLG_* */
  735. /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
  736. * corresponding to bit (e.g. bit 5 controls TID 5).
  737. * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
  738. __le16 tid_disable_tx;
  739. __le16 reserved1;
  740. /* TID for which to add block-ack support.
  741. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
  742. u8 add_immediate_ba_tid;
  743. /* TID for which to remove block-ack support.
  744. * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
  745. u8 remove_immediate_ba_tid;
  746. /* Starting Sequence Number for added block-ack support.
  747. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
  748. __le16 add_immediate_ba_ssn;
  749. __le32 reserved2;
  750. } __attribute__ ((packed));
  751. #define ADD_STA_SUCCESS_MSK 0x1
  752. #define ADD_STA_NO_ROOM_IN_TABLE 0x2
  753. #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4
  754. #define ADD_STA_MODIFY_NON_EXIST_STA 0x8
  755. /*
  756. * REPLY_ADD_STA = 0x18 (response)
  757. */
  758. struct iwl4965_add_sta_resp {
  759. u8 status; /* ADD_STA_* */
  760. } __attribute__ ((packed));
  761. /******************************************************************************
  762. * (4)
  763. * Rx Responses:
  764. *
  765. *****************************************************************************/
  766. struct iwl4965_rx_frame_stats {
  767. u8 phy_count;
  768. u8 id;
  769. u8 rssi;
  770. u8 agc;
  771. __le16 sig_avg;
  772. __le16 noise_diff;
  773. u8 payload[0];
  774. } __attribute__ ((packed));
  775. struct iwl4965_rx_frame_hdr {
  776. __le16 channel;
  777. __le16 phy_flags;
  778. u8 reserved1;
  779. u8 rate;
  780. __le16 len;
  781. u8 payload[0];
  782. } __attribute__ ((packed));
  783. #define RX_RES_STATUS_NO_CRC32_ERROR __constant_cpu_to_le32(1 << 0)
  784. #define RX_RES_STATUS_NO_RXE_OVERFLOW __constant_cpu_to_le32(1 << 1)
  785. #define RX_RES_PHY_FLAGS_BAND_24_MSK __constant_cpu_to_le16(1 << 0)
  786. #define RX_RES_PHY_FLAGS_MOD_CCK_MSK __constant_cpu_to_le16(1 << 1)
  787. #define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK __constant_cpu_to_le16(1 << 2)
  788. #define RX_RES_PHY_FLAGS_NARROW_BAND_MSK __constant_cpu_to_le16(1 << 3)
  789. #define RX_RES_PHY_FLAGS_ANTENNA_MSK __constant_cpu_to_le16(0xf0)
  790. #define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
  791. #define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
  792. #define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
  793. #define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
  794. #define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
  795. #define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
  796. #define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
  797. #define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
  798. #define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
  799. #define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
  800. struct iwl4965_rx_frame_end {
  801. __le32 status;
  802. __le64 timestamp;
  803. __le32 beacon_timestamp;
  804. } __attribute__ ((packed));
  805. /*
  806. * REPLY_3945_RX = 0x1b (response only, not a command)
  807. *
  808. * NOTE: DO NOT dereference from casts to this structure
  809. * It is provided only for calculating minimum data set size.
  810. * The actual offsets of the hdr and end are dynamic based on
  811. * stats.phy_count
  812. */
  813. struct iwl4965_rx_frame {
  814. struct iwl4965_rx_frame_stats stats;
  815. struct iwl4965_rx_frame_hdr hdr;
  816. struct iwl4965_rx_frame_end end;
  817. } __attribute__ ((packed));
  818. /* Fixed (non-configurable) rx data from phy */
  819. #define RX_PHY_FLAGS_ANTENNAE_OFFSET (4)
  820. #define RX_PHY_FLAGS_ANTENNAE_MASK (0x70)
  821. #define IWL_AGC_DB_MASK (0x3f80) /* MASK(7,13) */
  822. #define IWL_AGC_DB_POS (7)
  823. struct iwl4965_rx_non_cfg_phy {
  824. __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */
  825. __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */
  826. u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */
  827. u8 pad[0];
  828. } __attribute__ ((packed));
  829. /*
  830. * REPLY_4965_RX = 0xc3 (response only, not a command)
  831. * Used only for legacy (non 11n) frames.
  832. */
  833. #define RX_RES_PHY_CNT 14
  834. struct iwl4965_rx_phy_res {
  835. u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
  836. u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
  837. u8 stat_id; /* configurable DSP phy data set ID */
  838. u8 reserved1;
  839. __le64 timestamp; /* TSF at on air rise */
  840. __le32 beacon_time_stamp; /* beacon at on-air rise */
  841. __le16 phy_flags; /* general phy flags: band, modulation, ... */
  842. __le16 channel; /* channel number */
  843. __le16 non_cfg_phy[RX_RES_PHY_CNT]; /* upto 14 phy entries */
  844. __le32 reserved2;
  845. __le32 rate_n_flags; /* RATE_MCS_* */
  846. __le16 byte_count; /* frame's byte-count */
  847. __le16 reserved3;
  848. } __attribute__ ((packed));
  849. struct iwl4965_rx_mpdu_res_start {
  850. __le16 byte_count;
  851. __le16 reserved;
  852. } __attribute__ ((packed));
  853. /******************************************************************************
  854. * (5)
  855. * Tx Commands & Responses:
  856. *
  857. * Driver must place each REPLY_TX command into one of the prioritized Tx
  858. * queues in host DRAM, shared between driver and device (see comments for
  859. * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode
  860. * are preparing to transmit, the device pulls the Tx command over the PCI
  861. * bus via one of the device's Tx DMA channels, to fill an internal FIFO
  862. * from which data will be transmitted.
  863. *
  864. * uCode handles all timing and protocol related to control frames
  865. * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler
  866. * handle reception of block-acks; uCode updates the host driver via
  867. * REPLY_COMPRESSED_BA (4965).
  868. *
  869. * uCode handles retrying Tx when an ACK is expected but not received.
  870. * This includes trying lower data rates than the one requested in the Tx
  871. * command, as set up by the REPLY_RATE_SCALE (for 3945) or
  872. * REPLY_TX_LINK_QUALITY_CMD (4965).
  873. *
  874. * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
  875. * This command must be executed after every RXON command, before Tx can occur.
  876. *****************************************************************************/
  877. /* REPLY_TX Tx flags field */
  878. /* 1: Use Request-To-Send protocol before this frame.
  879. * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */
  880. #define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1)
  881. /* 1: Transmit Clear-To-Send to self before this frame.
  882. * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
  883. * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. */
  884. #define TX_CMD_FLG_CTS_MSK __constant_cpu_to_le32(1 << 2)
  885. /* 1: Expect ACK from receiving station
  886. * 0: Don't expect ACK (MAC header's duration field s/b 0)
  887. * Set this for unicast frames, but not broadcast/multicast. */
  888. #define TX_CMD_FLG_ACK_MSK __constant_cpu_to_le32(1 << 3)
  889. /* For 4965:
  890. * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
  891. * Tx command's initial_rate_index indicates first rate to try;
  892. * uCode walks through table for additional Tx attempts.
  893. * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
  894. * This rate will be used for all Tx attempts; it will not be scaled. */
  895. #define TX_CMD_FLG_STA_RATE_MSK __constant_cpu_to_le32(1 << 4)
  896. /* 1: Expect immediate block-ack.
  897. * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
  898. #define TX_CMD_FLG_IMM_BA_RSP_MASK __constant_cpu_to_le32(1 << 6)
  899. /* 1: Frame requires full Tx-Op protection.
  900. * Set this if either RTS or CTS Tx Flag gets set. */
  901. #define TX_CMD_FLG_FULL_TXOP_PROT_MSK __constant_cpu_to_le32(1 << 7)
  902. /* Tx antenna selection field; used only for 3945, reserved (0) for 4965.
  903. * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
  904. #define TX_CMD_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0xf00)
  905. #define TX_CMD_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
  906. #define TX_CMD_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
  907. /* 1: Ignore Bluetooth priority for this frame.
  908. * 0: Delay Tx until Bluetooth device is done (normal usage). */
  909. #define TX_CMD_FLG_BT_DIS_MSK __constant_cpu_to_le32(1 << 12)
  910. /* 1: uCode overrides sequence control field in MAC header.
  911. * 0: Driver provides sequence control field in MAC header.
  912. * Set this for management frames, non-QOS data frames, non-unicast frames,
  913. * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
  914. #define TX_CMD_FLG_SEQ_CTL_MSK __constant_cpu_to_le32(1 << 13)
  915. /* 1: This frame is non-last MPDU; more fragments are coming.
  916. * 0: Last fragment, or not using fragmentation. */
  917. #define TX_CMD_FLG_MORE_FRAG_MSK __constant_cpu_to_le32(1 << 14)
  918. /* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
  919. * 0: No TSF required in outgoing frame.
  920. * Set this for transmitting beacons and probe responses. */
  921. #define TX_CMD_FLG_TSF_MSK __constant_cpu_to_le32(1 << 16)
  922. /* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
  923. * alignment of frame's payload data field.
  924. * 0: No pad
  925. * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
  926. * field (but not both). Driver must align frame data (i.e. data following
  927. * MAC header) to DWORD boundary. */
  928. #define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20)
  929. /* HCCA-AP - disable duration overwriting. */
  930. #define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25)
  931. /*
  932. * TX command security control
  933. */
  934. #define TX_CMD_SEC_WEP 0x01
  935. #define TX_CMD_SEC_CCM 0x02
  936. #define TX_CMD_SEC_TKIP 0x03
  937. #define TX_CMD_SEC_MSK 0x03
  938. #define TX_CMD_SEC_SHIFT 6
  939. #define TX_CMD_SEC_KEY128 0x08
  940. /*
  941. * 4965 uCode updates these Tx attempt count values in host DRAM.
  942. * Used for managing Tx retries when expecting block-acks.
  943. * Driver should set these fields to 0.
  944. */
  945. struct iwl4965_dram_scratch {
  946. u8 try_cnt; /* Tx attempts */
  947. u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */
  948. __le16 reserved;
  949. } __attribute__ ((packed));
  950. /*
  951. * REPLY_TX = 0x1c (command)
  952. */
  953. struct iwl4965_tx_cmd {
  954. /*
  955. * MPDU byte count:
  956. * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
  957. * + 8 byte IV for CCM or TKIP (not used for WEP)
  958. * + Data payload
  959. * + 8-byte MIC (not used for CCM/WEP)
  960. * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
  961. * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
  962. * Range: 14-2342 bytes.
  963. */
  964. __le16 len;
  965. /*
  966. * MPDU or MSDU byte count for next frame.
  967. * Used for fragmentation and bursting, but not 11n aggregation.
  968. * Same as "len", but for next frame. Set to 0 if not applicable.
  969. */
  970. __le16 next_frame_len;
  971. __le32 tx_flags; /* TX_CMD_FLG_* */
  972. /* 4965's uCode may modify this field of the Tx command (in host DRAM!).
  973. * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
  974. struct iwl4965_dram_scratch scratch;
  975. /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
  976. __le32 rate_n_flags; /* RATE_MCS_* */
  977. /* Index of destination station in uCode's station table */
  978. u8 sta_id;
  979. /* Type of security encryption: CCM or TKIP */
  980. u8 sec_ctl; /* TX_CMD_SEC_* */
  981. /*
  982. * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
  983. * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for
  984. * data frames, this field may be used to selectively reduce initial
  985. * rate (via non-0 value) for special frames (e.g. management), while
  986. * still supporting rate scaling for all frames.
  987. */
  988. u8 initial_rate_index;
  989. u8 reserved;
  990. u8 key[16];
  991. __le16 next_frame_flags;
  992. __le16 reserved2;
  993. union {
  994. __le32 life_time;
  995. __le32 attempt;
  996. } stop_time;
  997. /* Host DRAM physical address pointer to "scratch" in this command.
  998. * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */
  999. __le32 dram_lsb_ptr;
  1000. u8 dram_msb_ptr;
  1001. u8 rts_retry_limit; /*byte 50 */
  1002. u8 data_retry_limit; /*byte 51 */
  1003. u8 tid_tspec;
  1004. union {
  1005. __le16 pm_frame_timeout;
  1006. __le16 attempt_duration;
  1007. } timeout;
  1008. /*
  1009. * Duration of EDCA burst Tx Opportunity, in 32-usec units.
  1010. * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
  1011. */
  1012. __le16 driver_txop;
  1013. /*
  1014. * MAC header goes here, followed by 2 bytes padding if MAC header
  1015. * length is 26 or 30 bytes, followed by payload data
  1016. */
  1017. u8 payload[0];
  1018. struct ieee80211_hdr hdr[0];
  1019. } __attribute__ ((packed));
  1020. /* TX command response is sent after *all* transmission attempts.
  1021. *
  1022. * NOTES:
  1023. *
  1024. * TX_STATUS_FAIL_NEXT_FRAG
  1025. *
  1026. * If the fragment flag in the MAC header for the frame being transmitted
  1027. * is set and there is insufficient time to transmit the next frame, the
  1028. * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
  1029. *
  1030. * TX_STATUS_FIFO_UNDERRUN
  1031. *
  1032. * Indicates the host did not provide bytes to the FIFO fast enough while
  1033. * a TX was in progress.
  1034. *
  1035. * TX_STATUS_FAIL_MGMNT_ABORT
  1036. *
  1037. * This status is only possible if the ABORT ON MGMT RX parameter was
  1038. * set to true with the TX command.
  1039. *
  1040. * If the MSB of the status parameter is set then an abort sequence is
  1041. * required. This sequence consists of the host activating the TX Abort
  1042. * control line, and then waiting for the TX Abort command response. This
  1043. * indicates that a the device is no longer in a transmit state, and that the
  1044. * command FIFO has been cleared. The host must then deactivate the TX Abort
  1045. * control line. Receiving is still allowed in this case.
  1046. */
  1047. enum {
  1048. TX_STATUS_SUCCESS = 0x01,
  1049. TX_STATUS_DIRECT_DONE = 0x02,
  1050. TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
  1051. TX_STATUS_FAIL_LONG_LIMIT = 0x83,
  1052. TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
  1053. TX_STATUS_FAIL_MGMNT_ABORT = 0x85,
  1054. TX_STATUS_FAIL_NEXT_FRAG = 0x86,
  1055. TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
  1056. TX_STATUS_FAIL_DEST_PS = 0x88,
  1057. TX_STATUS_FAIL_ABORTED = 0x89,
  1058. TX_STATUS_FAIL_BT_RETRY = 0x8a,
  1059. TX_STATUS_FAIL_STA_INVALID = 0x8b,
  1060. TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
  1061. TX_STATUS_FAIL_TID_DISABLE = 0x8d,
  1062. TX_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
  1063. TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
  1064. TX_STATUS_FAIL_TX_LOCKED = 0x90,
  1065. TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
  1066. };
  1067. #define TX_PACKET_MODE_REGULAR 0x0000
  1068. #define TX_PACKET_MODE_BURST_SEQ 0x0100
  1069. #define TX_PACKET_MODE_BURST_FIRST 0x0200
  1070. enum {
  1071. TX_POWER_PA_NOT_ACTIVE = 0x0,
  1072. };
  1073. enum {
  1074. TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
  1075. TX_STATUS_DELAY_MSK = 0x00000040,
  1076. TX_STATUS_ABORT_MSK = 0x00000080,
  1077. TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
  1078. TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
  1079. TX_RESERVED = 0x00780000, /* bits 19:22 */
  1080. TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
  1081. TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
  1082. };
  1083. /* *******************************
  1084. * TX aggregation status
  1085. ******************************* */
  1086. enum {
  1087. AGG_TX_STATE_TRANSMITTED = 0x00,
  1088. AGG_TX_STATE_UNDERRUN_MSK = 0x01,
  1089. AGG_TX_STATE_BT_PRIO_MSK = 0x02,
  1090. AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
  1091. AGG_TX_STATE_ABORT_MSK = 0x08,
  1092. AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
  1093. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
  1094. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
  1095. AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
  1096. AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
  1097. AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
  1098. AGG_TX_STATE_DUMP_TX_MSK = 0x200,
  1099. AGG_TX_STATE_DELAY_TX_MSK = 0x400
  1100. };
  1101. #define AGG_TX_STATE_LAST_SENT_MSK \
  1102. (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
  1103. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
  1104. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
  1105. /* # tx attempts for first frame in aggregation */
  1106. #define AGG_TX_STATE_TRY_CNT_POS 12
  1107. #define AGG_TX_STATE_TRY_CNT_MSK 0xf000
  1108. /* Command ID and sequence number of Tx command for this frame */
  1109. #define AGG_TX_STATE_SEQ_NUM_POS 16
  1110. #define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
  1111. /*
  1112. * REPLY_TX = 0x1c (response)
  1113. *
  1114. * This response may be in one of two slightly different formats, indicated
  1115. * by the frame_count field:
  1116. *
  1117. * 1) No aggregation (frame_count == 1). This reports Tx results for
  1118. * a single frame. Multiple attempts, at various bit rates, may have
  1119. * been made for this frame.
  1120. *
  1121. * 2) Aggregation (frame_count > 1). This reports Tx results for
  1122. * 2 or more frames that used block-acknowledge. All frames were
  1123. * transmitted at same rate. Rate scaling may have been used if first
  1124. * frame in this new agg block failed in previous agg block(s).
  1125. *
  1126. * Note that, for aggregation, ACK (block-ack) status is not delivered here;
  1127. * block-ack has not been received by the time the 4965 records this status.
  1128. * This status relates to reasons the tx might have been blocked or aborted
  1129. * within the sending station (this 4965), rather than whether it was
  1130. * received successfully by the destination station.
  1131. */
  1132. struct iwl4965_tx_resp {
  1133. u8 frame_count; /* 1 no aggregation, >1 aggregation */
  1134. u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
  1135. u8 failure_rts; /* # failures due to unsuccessful RTS */
  1136. u8 failure_frame; /* # failures due to no ACK (unused for agg) */
  1137. /* For non-agg: Rate at which frame was successful.
  1138. * For agg: Rate at which all frames were transmitted. */
  1139. __le32 rate_n_flags; /* RATE_MCS_* */
  1140. /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
  1141. * For agg: RTS + CTS + aggregation tx time + block-ack time. */
  1142. __le16 wireless_media_time; /* uSecs */
  1143. __le16 reserved;
  1144. __le32 pa_power1; /* RF power amplifier measurement (not used) */
  1145. __le32 pa_power2;
  1146. /*
  1147. * For non-agg: frame status TX_STATUS_*
  1148. * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
  1149. * fields follow this one, up to frame_count.
  1150. * Bit fields:
  1151. * 11- 0: AGG_TX_STATE_* status code
  1152. * 15-12: Retry count for 1st frame in aggregation (retries
  1153. * occur if tx failed for this frame when it was a
  1154. * member of a previous aggregation block). If rate
  1155. * scaling is used, retry count indicates the rate
  1156. * table entry used for all frames in the new agg.
  1157. * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
  1158. */
  1159. __le32 status; /* TX status (for aggregation status of 1st frame) */
  1160. } __attribute__ ((packed));
  1161. /*
  1162. * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
  1163. *
  1164. * Reports Block-Acknowledge from recipient station
  1165. */
  1166. struct iwl4965_compressed_ba_resp {
  1167. __le32 sta_addr_lo32;
  1168. __le16 sta_addr_hi16;
  1169. __le16 reserved;
  1170. /* Index of recipient (BA-sending) station in uCode's station table */
  1171. u8 sta_id;
  1172. u8 tid;
  1173. __le16 ba_seq_ctl;
  1174. __le32 ba_bitmap0;
  1175. __le32 ba_bitmap1;
  1176. __le16 scd_flow;
  1177. __le16 scd_ssn;
  1178. } __attribute__ ((packed));
  1179. /*
  1180. * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
  1181. */
  1182. struct iwl4965_txpowertable_cmd {
  1183. u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
  1184. u8 reserved;
  1185. __le16 channel;
  1186. struct iwl4965_tx_power_db tx_power;
  1187. } __attribute__ ((packed));
  1188. /*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
  1189. #define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1<<0)
  1190. #define LINK_QUAL_AC_NUM AC_NUM
  1191. #define LINK_QUAL_MAX_RETRY_NUM 16
  1192. #define LINK_QUAL_ANT_A_MSK (1<<0)
  1193. #define LINK_QUAL_ANT_B_MSK (1<<1)
  1194. #define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
  1195. struct iwl4965_link_qual_general_params {
  1196. u8 flags;
  1197. u8 mimo_delimiter;
  1198. u8 single_stream_ant_msk;
  1199. u8 dual_stream_ant_msk;
  1200. u8 start_rate_index[LINK_QUAL_AC_NUM];
  1201. } __attribute__ ((packed));
  1202. struct iwl4965_link_qual_agg_params {
  1203. __le16 agg_time_limit;
  1204. u8 agg_dis_start_th;
  1205. u8 agg_frame_cnt_limit;
  1206. __le32 reserved;
  1207. } __attribute__ ((packed));
  1208. /*
  1209. * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
  1210. */
  1211. struct iwl4965_link_quality_cmd {
  1212. u8 sta_id;
  1213. u8 reserved1;
  1214. __le16 control;
  1215. struct iwl4965_link_qual_general_params general_params;
  1216. struct iwl4965_link_qual_agg_params agg_params;
  1217. struct {
  1218. __le32 rate_n_flags;
  1219. } rs_table[LINK_QUAL_MAX_RETRY_NUM];
  1220. __le32 reserved2;
  1221. } __attribute__ ((packed));
  1222. /*
  1223. * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
  1224. */
  1225. struct iwl4965_bt_cmd {
  1226. u8 flags;
  1227. u8 lead_time;
  1228. u8 max_kill;
  1229. u8 reserved;
  1230. __le32 kill_ack_mask;
  1231. __le32 kill_cts_mask;
  1232. } __attribute__ ((packed));
  1233. /******************************************************************************
  1234. * (6)
  1235. * Spectrum Management (802.11h) Commands, Responses, Notifications:
  1236. *
  1237. *****************************************************************************/
  1238. /*
  1239. * Spectrum Management
  1240. */
  1241. #define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
  1242. RXON_FILTER_CTL2HOST_MSK | \
  1243. RXON_FILTER_ACCEPT_GRP_MSK | \
  1244. RXON_FILTER_DIS_DECRYPT_MSK | \
  1245. RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
  1246. RXON_FILTER_ASSOC_MSK | \
  1247. RXON_FILTER_BCON_AWARE_MSK)
  1248. struct iwl4965_measure_channel {
  1249. __le32 duration; /* measurement duration in extended beacon
  1250. * format */
  1251. u8 channel; /* channel to measure */
  1252. u8 type; /* see enum iwl4965_measure_type */
  1253. __le16 reserved;
  1254. } __attribute__ ((packed));
  1255. /*
  1256. * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
  1257. */
  1258. struct iwl4965_spectrum_cmd {
  1259. __le16 len; /* number of bytes starting from token */
  1260. u8 token; /* token id */
  1261. u8 id; /* measurement id -- 0 or 1 */
  1262. u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
  1263. u8 periodic; /* 1 = periodic */
  1264. __le16 path_loss_timeout;
  1265. __le32 start_time; /* start time in extended beacon format */
  1266. __le32 reserved2;
  1267. __le32 flags; /* rxon flags */
  1268. __le32 filter_flags; /* rxon filter flags */
  1269. __le16 channel_count; /* minimum 1, maximum 10 */
  1270. __le16 reserved3;
  1271. struct iwl4965_measure_channel channels[10];
  1272. } __attribute__ ((packed));
  1273. /*
  1274. * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
  1275. */
  1276. struct iwl4965_spectrum_resp {
  1277. u8 token;
  1278. u8 id; /* id of the prior command replaced, or 0xff */
  1279. __le16 status; /* 0 - command will be handled
  1280. * 1 - cannot handle (conflicts with another
  1281. * measurement) */
  1282. } __attribute__ ((packed));
  1283. enum iwl4965_measurement_state {
  1284. IWL_MEASUREMENT_START = 0,
  1285. IWL_MEASUREMENT_STOP = 1,
  1286. };
  1287. enum iwl4965_measurement_status {
  1288. IWL_MEASUREMENT_OK = 0,
  1289. IWL_MEASUREMENT_CONCURRENT = 1,
  1290. IWL_MEASUREMENT_CSA_CONFLICT = 2,
  1291. IWL_MEASUREMENT_TGH_CONFLICT = 3,
  1292. /* 4-5 reserved */
  1293. IWL_MEASUREMENT_STOPPED = 6,
  1294. IWL_MEASUREMENT_TIMEOUT = 7,
  1295. IWL_MEASUREMENT_PERIODIC_FAILED = 8,
  1296. };
  1297. #define NUM_ELEMENTS_IN_HISTOGRAM 8
  1298. struct iwl4965_measurement_histogram {
  1299. __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
  1300. __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
  1301. } __attribute__ ((packed));
  1302. /* clear channel availability counters */
  1303. struct iwl4965_measurement_cca_counters {
  1304. __le32 ofdm;
  1305. __le32 cck;
  1306. } __attribute__ ((packed));
  1307. enum iwl4965_measure_type {
  1308. IWL_MEASURE_BASIC = (1 << 0),
  1309. IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
  1310. IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
  1311. IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
  1312. IWL_MEASURE_FRAME = (1 << 4),
  1313. /* bits 5:6 are reserved */
  1314. IWL_MEASURE_IDLE = (1 << 7),
  1315. };
  1316. /*
  1317. * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
  1318. */
  1319. struct iwl4965_spectrum_notification {
  1320. u8 id; /* measurement id -- 0 or 1 */
  1321. u8 token;
  1322. u8 channel_index; /* index in measurement channel list */
  1323. u8 state; /* 0 - start, 1 - stop */
  1324. __le32 start_time; /* lower 32-bits of TSF */
  1325. u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
  1326. u8 channel;
  1327. u8 type; /* see enum iwl4965_measurement_type */
  1328. u8 reserved1;
  1329. /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
  1330. * valid if applicable for measurement type requested. */
  1331. __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
  1332. __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
  1333. __le32 cca_time; /* channel load time in usecs */
  1334. u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
  1335. * unidentified */
  1336. u8 reserved2[3];
  1337. struct iwl4965_measurement_histogram histogram;
  1338. __le32 stop_time; /* lower 32-bits of TSF */
  1339. __le32 status; /* see iwl4965_measurement_status */
  1340. } __attribute__ ((packed));
  1341. /******************************************************************************
  1342. * (7)
  1343. * Power Management Commands, Responses, Notifications:
  1344. *
  1345. *****************************************************************************/
  1346. /**
  1347. * struct iwl4965_powertable_cmd - Power Table Command
  1348. * @flags: See below:
  1349. *
  1350. * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
  1351. *
  1352. * PM allow:
  1353. * bit 0 - '0' Driver not allow power management
  1354. * '1' Driver allow PM (use rest of parameters)
  1355. * uCode send sleep notifications:
  1356. * bit 1 - '0' Don't send sleep notification
  1357. * '1' send sleep notification (SEND_PM_NOTIFICATION)
  1358. * Sleep over DTIM
  1359. * bit 2 - '0' PM have to walk up every DTIM
  1360. * '1' PM could sleep over DTIM till listen Interval.
  1361. * PCI power managed
  1362. * bit 3 - '0' (PCI_LINK_CTRL & 0x1)
  1363. * '1' !(PCI_LINK_CTRL & 0x1)
  1364. * Force sleep Modes
  1365. * bit 31/30- '00' use both mac/xtal sleeps
  1366. * '01' force Mac sleep
  1367. * '10' force xtal sleep
  1368. * '11' Illegal set
  1369. *
  1370. * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
  1371. * ucode assume sleep over DTIM is allowed and we don't need to wakeup
  1372. * for every DTIM.
  1373. */
  1374. #define IWL_POWER_VEC_SIZE 5
  1375. #define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK __constant_cpu_to_le16(1<<0)
  1376. #define IWL_POWER_SLEEP_OVER_DTIM_MSK __constant_cpu_to_le16(1<<2)
  1377. #define IWL_POWER_PCI_PM_MSK __constant_cpu_to_le16(1<<3)
  1378. struct iwl4965_powertable_cmd {
  1379. __le16 flags;
  1380. u8 keep_alive_seconds;
  1381. u8 debug_flags;
  1382. __le32 rx_data_timeout;
  1383. __le32 tx_data_timeout;
  1384. __le32 sleep_interval[IWL_POWER_VEC_SIZE];
  1385. __le32 keep_alive_beacons;
  1386. } __attribute__ ((packed));
  1387. /*
  1388. * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
  1389. * 3945 and 4965 identical.
  1390. */
  1391. struct iwl4965_sleep_notification {
  1392. u8 pm_sleep_mode;
  1393. u8 pm_wakeup_src;
  1394. __le16 reserved;
  1395. __le32 sleep_time;
  1396. __le32 tsf_low;
  1397. __le32 bcon_timer;
  1398. } __attribute__ ((packed));
  1399. /* Sleep states. 3945 and 4965 identical. */
  1400. enum {
  1401. IWL_PM_NO_SLEEP = 0,
  1402. IWL_PM_SLP_MAC = 1,
  1403. IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
  1404. IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
  1405. IWL_PM_SLP_PHY = 4,
  1406. IWL_PM_SLP_REPENT = 5,
  1407. IWL_PM_WAKEUP_BY_TIMER = 6,
  1408. IWL_PM_WAKEUP_BY_DRIVER = 7,
  1409. IWL_PM_WAKEUP_BY_RFKILL = 8,
  1410. /* 3 reserved */
  1411. IWL_PM_NUM_OF_MODES = 12,
  1412. };
  1413. /*
  1414. * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
  1415. */
  1416. #define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
  1417. #define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
  1418. #define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
  1419. struct iwl4965_card_state_cmd {
  1420. __le32 status; /* CARD_STATE_CMD_* request new power state */
  1421. } __attribute__ ((packed));
  1422. /*
  1423. * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
  1424. */
  1425. struct iwl4965_card_state_notif {
  1426. __le32 flags;
  1427. } __attribute__ ((packed));
  1428. #define HW_CARD_DISABLED 0x01
  1429. #define SW_CARD_DISABLED 0x02
  1430. #define RF_CARD_DISABLED 0x04
  1431. #define RXON_CARD_DISABLED 0x10
  1432. struct iwl4965_ct_kill_config {
  1433. __le32 reserved;
  1434. __le32 critical_temperature_M;
  1435. __le32 critical_temperature_R;
  1436. } __attribute__ ((packed));
  1437. /******************************************************************************
  1438. * (8)
  1439. * Scan Commands, Responses, Notifications:
  1440. *
  1441. *****************************************************************************/
  1442. struct iwl4965_scan_channel {
  1443. /* type is defined as:
  1444. * 0:0 active (0 - passive)
  1445. * 1:4 SSID direct
  1446. * If 1 is set then corresponding SSID IE is transmitted in probe
  1447. * 5:7 reserved
  1448. */
  1449. u8 type;
  1450. u8 channel;
  1451. struct iwl4965_tx_power tpc;
  1452. __le16 active_dwell;
  1453. __le16 passive_dwell;
  1454. } __attribute__ ((packed));
  1455. struct iwl4965_ssid_ie {
  1456. u8 id;
  1457. u8 len;
  1458. u8 ssid[32];
  1459. } __attribute__ ((packed));
  1460. #define PROBE_OPTION_MAX 0x4
  1461. #define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF)
  1462. #define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1)
  1463. #define IWL_MAX_SCAN_SIZE 1024
  1464. /*
  1465. * REPLY_SCAN_CMD = 0x80 (command)
  1466. */
  1467. struct iwl4965_scan_cmd {
  1468. __le16 len;
  1469. u8 reserved0;
  1470. u8 channel_count;
  1471. __le16 quiet_time; /* dwell only this long on quiet chnl
  1472. * (active scan) */
  1473. __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
  1474. __le16 good_CRC_th; /* passive -> active promotion threshold */
  1475. __le16 rx_chain;
  1476. __le32 max_out_time; /* max usec to be out of associated (service)
  1477. * chnl */
  1478. __le32 suspend_time; /* pause scan this long when returning to svc
  1479. * chnl.
  1480. * 3945 -- 31:24 # beacons, 19:0 additional usec,
  1481. * 4965 -- 31:22 # beacons, 21:0 additional usec.
  1482. */
  1483. __le32 flags;
  1484. __le32 filter_flags;
  1485. struct iwl4965_tx_cmd tx_cmd;
  1486. struct iwl4965_ssid_ie direct_scan[PROBE_OPTION_MAX];
  1487. u8 data[0];
  1488. /*
  1489. * The channels start after the probe request payload and are of type:
  1490. *
  1491. * struct iwl4965_scan_channel channels[0];
  1492. *
  1493. * NOTE: Only one band of channels can be scanned per pass. You
  1494. * can not mix 2.4GHz channels and 5.2GHz channels and must
  1495. * request a scan multiple times (not concurrently)
  1496. *
  1497. */
  1498. } __attribute__ ((packed));
  1499. /* Can abort will notify by complete notification with abort status. */
  1500. #define CAN_ABORT_STATUS __constant_cpu_to_le32(0x1)
  1501. /* complete notification statuses */
  1502. #define ABORT_STATUS 0x2
  1503. /*
  1504. * REPLY_SCAN_CMD = 0x80 (response)
  1505. */
  1506. struct iwl4965_scanreq_notification {
  1507. __le32 status; /* 1: okay, 2: cannot fulfill request */
  1508. } __attribute__ ((packed));
  1509. /*
  1510. * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
  1511. */
  1512. struct iwl4965_scanstart_notification {
  1513. __le32 tsf_low;
  1514. __le32 tsf_high;
  1515. __le32 beacon_timer;
  1516. u8 channel;
  1517. u8 band;
  1518. u8 reserved[2];
  1519. __le32 status;
  1520. } __attribute__ ((packed));
  1521. #define SCAN_OWNER_STATUS 0x1;
  1522. #define MEASURE_OWNER_STATUS 0x2;
  1523. #define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
  1524. /*
  1525. * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
  1526. */
  1527. struct iwl4965_scanresults_notification {
  1528. u8 channel;
  1529. u8 band;
  1530. u8 reserved[2];
  1531. __le32 tsf_low;
  1532. __le32 tsf_high;
  1533. __le32 statistics[NUMBER_OF_STATISTICS];
  1534. } __attribute__ ((packed));
  1535. /*
  1536. * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
  1537. */
  1538. struct iwl4965_scancomplete_notification {
  1539. u8 scanned_channels;
  1540. u8 status;
  1541. u8 reserved;
  1542. u8 last_channel;
  1543. __le32 tsf_low;
  1544. __le32 tsf_high;
  1545. } __attribute__ ((packed));
  1546. /******************************************************************************
  1547. * (9)
  1548. * IBSS/AP Commands and Notifications:
  1549. *
  1550. *****************************************************************************/
  1551. /*
  1552. * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
  1553. */
  1554. struct iwl4965_beacon_notif {
  1555. struct iwl4965_tx_resp beacon_notify_hdr;
  1556. __le32 low_tsf;
  1557. __le32 high_tsf;
  1558. __le32 ibss_mgr_status;
  1559. } __attribute__ ((packed));
  1560. /*
  1561. * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
  1562. */
  1563. struct iwl4965_tx_beacon_cmd {
  1564. struct iwl4965_tx_cmd tx;
  1565. __le16 tim_idx;
  1566. u8 tim_size;
  1567. u8 reserved1;
  1568. struct ieee80211_hdr frame[0]; /* beacon frame */
  1569. } __attribute__ ((packed));
  1570. /******************************************************************************
  1571. * (10)
  1572. * Statistics Commands and Notifications:
  1573. *
  1574. *****************************************************************************/
  1575. #define IWL_TEMP_CONVERT 260
  1576. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  1577. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  1578. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  1579. /* Used for passing to driver number of successes and failures per rate */
  1580. struct rate_histogram {
  1581. union {
  1582. __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  1583. __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  1584. __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  1585. } success;
  1586. union {
  1587. __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  1588. __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  1589. __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  1590. } failed;
  1591. } __attribute__ ((packed));
  1592. /* statistics command response */
  1593. struct statistics_rx_phy {
  1594. __le32 ina_cnt;
  1595. __le32 fina_cnt;
  1596. __le32 plcp_err;
  1597. __le32 crc32_err;
  1598. __le32 overrun_err;
  1599. __le32 early_overrun_err;
  1600. __le32 crc32_good;
  1601. __le32 false_alarm_cnt;
  1602. __le32 fina_sync_err_cnt;
  1603. __le32 sfd_timeout;
  1604. __le32 fina_timeout;
  1605. __le32 unresponded_rts;
  1606. __le32 rxe_frame_limit_overrun;
  1607. __le32 sent_ack_cnt;
  1608. __le32 sent_cts_cnt;
  1609. __le32 sent_ba_rsp_cnt;
  1610. __le32 dsp_self_kill;
  1611. __le32 mh_format_err;
  1612. __le32 re_acq_main_rssi_sum;
  1613. __le32 reserved3;
  1614. } __attribute__ ((packed));
  1615. struct statistics_rx_ht_phy {
  1616. __le32 plcp_err;
  1617. __le32 overrun_err;
  1618. __le32 early_overrun_err;
  1619. __le32 crc32_good;
  1620. __le32 crc32_err;
  1621. __le32 mh_format_err;
  1622. __le32 agg_crc32_good;
  1623. __le32 agg_mpdu_cnt;
  1624. __le32 agg_cnt;
  1625. __le32 reserved2;
  1626. } __attribute__ ((packed));
  1627. struct statistics_rx_non_phy {
  1628. __le32 bogus_cts; /* CTS received when not expecting CTS */
  1629. __le32 bogus_ack; /* ACK received when not expecting ACK */
  1630. __le32 non_bssid_frames; /* number of frames with BSSID that
  1631. * doesn't belong to the STA BSSID */
  1632. __le32 filtered_frames; /* count frames that were dumped in the
  1633. * filtering process */
  1634. __le32 non_channel_beacons; /* beacons with our bss id but not on
  1635. * our serving channel */
  1636. __le32 channel_beacons; /* beacons with our bss id and in our
  1637. * serving channel */
  1638. __le32 num_missed_bcon; /* number of missed beacons */
  1639. __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
  1640. * ADC was in saturation */
  1641. __le32 ina_detection_search_time;/* total time (in 0.8us) searched
  1642. * for INA */
  1643. __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
  1644. __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
  1645. __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
  1646. __le32 interference_data_flag; /* flag for interference data
  1647. * availability. 1 when data is
  1648. * available. */
  1649. __le32 channel_load; /* counts RX Enable time */
  1650. __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
  1651. * and CCK) counter */
  1652. __le32 beacon_rssi_a;
  1653. __le32 beacon_rssi_b;
  1654. __le32 beacon_rssi_c;
  1655. __le32 beacon_energy_a;
  1656. __le32 beacon_energy_b;
  1657. __le32 beacon_energy_c;
  1658. } __attribute__ ((packed));
  1659. struct statistics_rx {
  1660. struct statistics_rx_phy ofdm;
  1661. struct statistics_rx_phy cck;
  1662. struct statistics_rx_non_phy general;
  1663. struct statistics_rx_ht_phy ofdm_ht;
  1664. } __attribute__ ((packed));
  1665. struct statistics_tx_non_phy_agg {
  1666. __le32 ba_timeout;
  1667. __le32 ba_reschedule_frames;
  1668. __le32 scd_query_agg_frame_cnt;
  1669. __le32 scd_query_no_agg;
  1670. __le32 scd_query_agg;
  1671. __le32 scd_query_mismatch;
  1672. __le32 frame_not_ready;
  1673. __le32 underrun;
  1674. __le32 bt_prio_kill;
  1675. __le32 rx_ba_rsp_cnt;
  1676. __le32 reserved2;
  1677. __le32 reserved3;
  1678. } __attribute__ ((packed));
  1679. struct statistics_tx {
  1680. __le32 preamble_cnt;
  1681. __le32 rx_detected_cnt;
  1682. __le32 bt_prio_defer_cnt;
  1683. __le32 bt_prio_kill_cnt;
  1684. __le32 few_bytes_cnt;
  1685. __le32 cts_timeout;
  1686. __le32 ack_timeout;
  1687. __le32 expected_ack_cnt;
  1688. __le32 actual_ack_cnt;
  1689. __le32 dump_msdu_cnt;
  1690. __le32 burst_abort_next_frame_mismatch_cnt;
  1691. __le32 burst_abort_missing_next_frame_cnt;
  1692. __le32 cts_timeout_collision;
  1693. __le32 ack_or_ba_timeout_collision;
  1694. struct statistics_tx_non_phy_agg agg;
  1695. } __attribute__ ((packed));
  1696. struct statistics_dbg {
  1697. __le32 burst_check;
  1698. __le32 burst_count;
  1699. __le32 reserved[4];
  1700. } __attribute__ ((packed));
  1701. struct statistics_div {
  1702. __le32 tx_on_a;
  1703. __le32 tx_on_b;
  1704. __le32 exec_time;
  1705. __le32 probe_time;
  1706. __le32 reserved1;
  1707. __le32 reserved2;
  1708. } __attribute__ ((packed));
  1709. struct statistics_general {
  1710. __le32 temperature;
  1711. __le32 temperature_m;
  1712. struct statistics_dbg dbg;
  1713. __le32 sleep_time;
  1714. __le32 slots_out;
  1715. __le32 slots_idle;
  1716. __le32 ttl_timestamp;
  1717. struct statistics_div div;
  1718. __le32 rx_enable_counter;
  1719. __le32 reserved1;
  1720. __le32 reserved2;
  1721. __le32 reserved3;
  1722. } __attribute__ ((packed));
  1723. /*
  1724. * REPLY_STATISTICS_CMD = 0x9c,
  1725. * 3945 and 4965 identical.
  1726. *
  1727. * This command triggers an immediate response containing uCode statistics.
  1728. * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
  1729. *
  1730. * If the CLEAR_STATS configuration flag is set, uCode will clear its
  1731. * internal copy of the statistics (counters) after issuing the response.
  1732. * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
  1733. *
  1734. * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
  1735. * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
  1736. * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
  1737. */
  1738. #define IWL_STATS_CONF_CLEAR_STATS __constant_cpu_to_le32(0x1) /* see above */
  1739. #define IWL_STATS_CONF_DISABLE_NOTIF __constant_cpu_to_le32(0x2)/* see above */
  1740. struct iwl4965_statistics_cmd {
  1741. __le32 configuration_flags; /* IWL_STATS_CONF_* */
  1742. } __attribute__ ((packed));
  1743. /*
  1744. * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
  1745. *
  1746. * By default, uCode issues this notification after receiving a beacon
  1747. * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
  1748. * REPLY_STATISTICS_CMD 0x9c, above.
  1749. *
  1750. * Statistics counters continue to increment beacon after beacon, but are
  1751. * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
  1752. * 0x9c with CLEAR_STATS bit set (see above).
  1753. *
  1754. * uCode also issues this notification during scans. uCode clears statistics
  1755. * appropriately so that each notification contains statistics for only the
  1756. * one channel that has just been scanned.
  1757. */
  1758. #define STATISTICS_REPLY_FLG_BAND_24G_MSK __constant_cpu_to_le32(0x2)
  1759. #define STATISTICS_REPLY_FLG_FAT_MODE_MSK __constant_cpu_to_le32(0x8)
  1760. struct iwl4965_notif_statistics {
  1761. __le32 flag;
  1762. struct statistics_rx rx;
  1763. struct statistics_tx tx;
  1764. struct statistics_general general;
  1765. } __attribute__ ((packed));
  1766. /*
  1767. * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
  1768. */
  1769. /* if ucode missed CONSECUTIVE_MISSED_BCONS_TH beacons in a row,
  1770. * then this notification will be sent. */
  1771. #define CONSECUTIVE_MISSED_BCONS_TH 20
  1772. struct iwl4965_missed_beacon_notif {
  1773. __le32 consequtive_missed_beacons;
  1774. __le32 total_missed_becons;
  1775. __le32 num_expected_beacons;
  1776. __le32 num_recvd_beacons;
  1777. } __attribute__ ((packed));
  1778. /******************************************************************************
  1779. * (11)
  1780. * Rx Calibration Commands:
  1781. *
  1782. * With the uCode used for open source drivers, most Tx calibration (except
  1783. * for Tx Power) and most Rx calibration is done by uCode during the
  1784. * "initialize" phase of uCode boot. Driver must calibrate only:
  1785. *
  1786. * 1) Tx power (depends on temperature), described elsewhere
  1787. * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
  1788. * 3) Receiver sensitivity (to optimize signal detection)
  1789. *
  1790. *****************************************************************************/
  1791. /**
  1792. * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
  1793. *
  1794. * This command sets up the Rx signal detector for a sensitivity level that
  1795. * is high enough to lock onto all signals within the associated network,
  1796. * but low enough to ignore signals that are below a certain threshold, so as
  1797. * not to have too many "false alarms". False alarms are signals that the
  1798. * Rx DSP tries to lock onto, but then discards after determining that they
  1799. * are noise.
  1800. *
  1801. * The optimum number of false alarms is between 5 and 50 per 200 TUs
  1802. * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
  1803. * time listening, not transmitting). Driver must adjust sensitivity so that
  1804. * the ratio of actual false alarms to actual Rx time falls within this range.
  1805. *
  1806. * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
  1807. * received beacon. These provide information to the driver to analyze the
  1808. * sensitivity. Don't analyze statistics that come in from scanning, or any
  1809. * other non-associated-network source. Pertinent statistics include:
  1810. *
  1811. * From "general" statistics (struct statistics_rx_non_phy):
  1812. *
  1813. * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
  1814. * Measure of energy of desired signal. Used for establishing a level
  1815. * below which the device does not detect signals.
  1816. *
  1817. * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
  1818. * Measure of background noise in silent period after beacon.
  1819. *
  1820. * channel_load
  1821. * uSecs of actual Rx time during beacon period (varies according to
  1822. * how much time was spent transmitting).
  1823. *
  1824. * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
  1825. *
  1826. * false_alarm_cnt
  1827. * Signal locks abandoned early (before phy-level header).
  1828. *
  1829. * plcp_err
  1830. * Signal locks abandoned late (during phy-level header).
  1831. *
  1832. * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
  1833. * beacon to beacon, i.e. each value is an accumulation of all errors
  1834. * before and including the latest beacon. Values will wrap around to 0
  1835. * after counting up to 2^32 - 1. Driver must differentiate vs.
  1836. * previous beacon's values to determine # false alarms in the current
  1837. * beacon period.
  1838. *
  1839. * Total number of false alarms = false_alarms + plcp_errs
  1840. *
  1841. * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
  1842. * (notice that the start points for OFDM are at or close to settings for
  1843. * maximum sensitivity):
  1844. *
  1845. * START / MIN / MAX
  1846. * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
  1847. * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
  1848. * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
  1849. * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
  1850. *
  1851. * If actual rate of OFDM false alarms (+ plcp_errors) is too high
  1852. * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
  1853. * by *adding* 1 to all 4 of the table entries above, up to the max for
  1854. * each entry. Conversely, if false alarm rate is too low (less than 5
  1855. * for each 204.8 msecs listening), *subtract* 1 from each entry to
  1856. * increase sensitivity.
  1857. *
  1858. * For CCK sensitivity, keep track of the following:
  1859. *
  1860. * 1). 20-beacon history of maximum background noise, indicated by
  1861. * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
  1862. * 3 receivers. For any given beacon, the "silence reference" is
  1863. * the maximum of last 60 samples (20 beacons * 3 receivers).
  1864. *
  1865. * 2). 10-beacon history of strongest signal level, as indicated
  1866. * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
  1867. * i.e. the strength of the signal through the best receiver at the
  1868. * moment. These measurements are "upside down", with lower values
  1869. * for stronger signals, so max energy will be *minimum* value.
  1870. *
  1871. * Then for any given beacon, the driver must determine the *weakest*
  1872. * of the strongest signals; this is the minimum level that needs to be
  1873. * successfully detected, when using the best receiver at the moment.
  1874. * "Max cck energy" is the maximum (higher value means lower energy!)
  1875. * of the last 10 minima. Once this is determined, driver must add
  1876. * a little margin by adding "6" to it.
  1877. *
  1878. * 3). Number of consecutive beacon periods with too few false alarms.
  1879. * Reset this to 0 at the first beacon period that falls within the
  1880. * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
  1881. *
  1882. * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
  1883. * (notice that the start points for CCK are at maximum sensitivity):
  1884. *
  1885. * START / MIN / MAX
  1886. * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
  1887. * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
  1888. * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
  1889. *
  1890. * If actual rate of CCK false alarms (+ plcp_errors) is too high
  1891. * (greater than 50 for each 204.8 msecs listening), method for reducing
  1892. * sensitivity is:
  1893. *
  1894. * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
  1895. * up to max 400.
  1896. *
  1897. * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
  1898. * sensitivity has been reduced a significant amount; bring it up to
  1899. * a moderate 161. Otherwise, *add* 3, up to max 200.
  1900. *
  1901. * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
  1902. * sensitivity has been reduced only a moderate or small amount;
  1903. * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
  1904. * down to min 0. Otherwise (if gain has been significantly reduced),
  1905. * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
  1906. *
  1907. * b) Save a snapshot of the "silence reference".
  1908. *
  1909. * If actual rate of CCK false alarms (+ plcp_errors) is too low
  1910. * (less than 5 for each 204.8 msecs listening), method for increasing
  1911. * sensitivity is used only if:
  1912. *
  1913. * 1a) Previous beacon did not have too many false alarms
  1914. * 1b) AND difference between previous "silence reference" and current
  1915. * "silence reference" (prev - current) is 2 or more,
  1916. * OR 2) 100 or more consecutive beacon periods have had rate of
  1917. * less than 5 false alarms per 204.8 milliseconds rx time.
  1918. *
  1919. * Method for increasing sensitivity:
  1920. *
  1921. * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
  1922. * down to min 125.
  1923. *
  1924. * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
  1925. * down to min 200.
  1926. *
  1927. * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
  1928. *
  1929. * If actual rate of CCK false alarms (+ plcp_errors) is within good range
  1930. * (between 5 and 50 for each 204.8 msecs listening):
  1931. *
  1932. * 1) Save a snapshot of the silence reference.
  1933. *
  1934. * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
  1935. * give some extra margin to energy threshold by *subtracting* 8
  1936. * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
  1937. *
  1938. * For all cases (too few, too many, good range), make sure that the CCK
  1939. * detection threshold (energy) is below the energy level for robust
  1940. * detection over the past 10 beacon periods, the "Max cck energy".
  1941. * Lower values mean higher energy; this means making sure that the value
  1942. * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
  1943. *
  1944. * Driver should set the following entries to fixed values:
  1945. *
  1946. * HD_MIN_ENERGY_OFDM_DET_INDEX 100
  1947. * HD_BARKER_CORR_TH_ADD_MIN_INDEX 190
  1948. * HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX 390
  1949. * HD_OFDM_ENERGY_TH_IN_INDEX 62
  1950. */
  1951. /*
  1952. * Table entries in SENSITIVITY_CMD (struct iwl4965_sensitivity_cmd)
  1953. */
  1954. #define HD_TABLE_SIZE (11) /* number of entries */
  1955. #define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
  1956. #define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
  1957. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
  1958. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
  1959. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
  1960. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
  1961. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
  1962. #define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
  1963. #define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
  1964. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
  1965. #define HD_OFDM_ENERGY_TH_IN_INDEX (10)
  1966. /* Control field in struct iwl4965_sensitivity_cmd */
  1967. #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE __constant_cpu_to_le16(0)
  1968. #define SENSITIVITY_CMD_CONTROL_WORK_TABLE __constant_cpu_to_le16(1)
  1969. /**
  1970. * struct iwl4965_sensitivity_cmd
  1971. * @control: (1) updates working table, (0) updates default table
  1972. * @table: energy threshold values, use HD_* as index into table
  1973. *
  1974. * Always use "1" in "control" to update uCode's working table and DSP.
  1975. */
  1976. struct iwl4965_sensitivity_cmd {
  1977. __le16 control; /* always use "1" */
  1978. __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
  1979. } __attribute__ ((packed));
  1980. /**
  1981. * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
  1982. *
  1983. * This command sets the relative gains of 4965's 3 radio receiver chains.
  1984. *
  1985. * After the first association, driver should accumulate signal and noise
  1986. * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
  1987. * beacons from the associated network (don't collect statistics that come
  1988. * in from scanning, or any other non-network source).
  1989. *
  1990. * DISCONNECTED ANTENNA:
  1991. *
  1992. * Driver should determine which antennas are actually connected, by comparing
  1993. * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
  1994. * following values over 20 beacons, one accumulator for each of the chains
  1995. * a/b/c, from struct statistics_rx_non_phy:
  1996. *
  1997. * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
  1998. *
  1999. * Find the strongest signal from among a/b/c. Compare the other two to the
  2000. * strongest. If any signal is more than 15 dB (times 20, unless you
  2001. * divide the accumulated values by 20) below the strongest, the driver
  2002. * considers that antenna to be disconnected, and should not try to use that
  2003. * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
  2004. * driver should declare the stronger one as connected, and attempt to use it
  2005. * (A and B are the only 2 Tx chains!).
  2006. *
  2007. *
  2008. * RX BALANCE:
  2009. *
  2010. * Driver should balance the 3 receivers (but just the ones that are connected
  2011. * to antennas, see above) for gain, by comparing the average signal levels
  2012. * detected during the silence after each beacon (background noise).
  2013. * Accumulate (add) the following values over 20 beacons, one accumulator for
  2014. * each of the chains a/b/c, from struct statistics_rx_non_phy:
  2015. *
  2016. * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
  2017. *
  2018. * Find the weakest background noise level from among a/b/c. This Rx chain
  2019. * will be the reference, with 0 gain adjustment. Attenuate other channels by
  2020. * finding noise difference:
  2021. *
  2022. * (accum_noise[i] - accum_noise[reference]) / 30
  2023. *
  2024. * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
  2025. * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
  2026. * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
  2027. * and set bit 2 to indicate "reduce gain". The value for the reference
  2028. * (weakest) chain should be "0".
  2029. *
  2030. * diff_gain_[abc] bit fields:
  2031. * 2: (1) reduce gain, (0) increase gain
  2032. * 1-0: amount of gain, units of 1.5 dB
  2033. */
  2034. /* "Differential Gain" opcode used in REPLY_PHY_CALIBRATION_CMD. */
  2035. #define PHY_CALIBRATE_DIFF_GAIN_CMD (7)
  2036. struct iwl4965_calibration_cmd {
  2037. u8 opCode; /* PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
  2038. u8 flags; /* not used */
  2039. __le16 reserved;
  2040. s8 diff_gain_a; /* see above */
  2041. s8 diff_gain_b;
  2042. s8 diff_gain_c;
  2043. u8 reserved1;
  2044. } __attribute__ ((packed));
  2045. /******************************************************************************
  2046. * (12)
  2047. * Miscellaneous Commands:
  2048. *
  2049. *****************************************************************************/
  2050. /*
  2051. * LEDs Command & Response
  2052. * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
  2053. *
  2054. * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
  2055. * this command turns it on or off, or sets up a periodic blinking cycle.
  2056. */
  2057. struct iwl4965_led_cmd {
  2058. __le32 interval; /* "interval" in uSec */
  2059. u8 id; /* 1: Activity, 2: Link, 3: Tech */
  2060. u8 off; /* # intervals off while blinking;
  2061. * "0", with >0 "on" value, turns LED on */
  2062. u8 on; /* # intervals on while blinking;
  2063. * "0", regardless of "off", turns LED off */
  2064. u8 reserved;
  2065. } __attribute__ ((packed));
  2066. /******************************************************************************
  2067. * (13)
  2068. * Union of all expected notifications/responses:
  2069. *
  2070. *****************************************************************************/
  2071. struct iwl4965_rx_packet {
  2072. __le32 len;
  2073. struct iwl4965_cmd_header hdr;
  2074. union {
  2075. struct iwl4965_alive_resp alive_frame;
  2076. struct iwl4965_rx_frame rx_frame;
  2077. struct iwl4965_tx_resp tx_resp;
  2078. struct iwl4965_spectrum_notification spectrum_notif;
  2079. struct iwl4965_csa_notification csa_notif;
  2080. struct iwl4965_error_resp err_resp;
  2081. struct iwl4965_card_state_notif card_state_notif;
  2082. struct iwl4965_beacon_notif beacon_status;
  2083. struct iwl4965_add_sta_resp add_sta;
  2084. struct iwl4965_sleep_notification sleep_notif;
  2085. struct iwl4965_spectrum_resp spectrum;
  2086. struct iwl4965_notif_statistics stats;
  2087. struct iwl4965_compressed_ba_resp compressed_ba;
  2088. struct iwl4965_missed_beacon_notif missed_beacon;
  2089. __le32 status;
  2090. u8 raw[0];
  2091. } u;
  2092. } __attribute__ ((packed));
  2093. #define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame))
  2094. #endif /* __iwl4965_commands_h__ */