iwl-4965-commands.h 60 KB

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