iwl-4965-commands.h 95 KB

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