commands.h 130 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009
  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 - 2014 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 COPYING.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@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 - 2014 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 (commands.h) only for uCode API definitions.
  65. * Please use iwl-xxxx-hw.h for hardware-related definitions.
  66. * Please use dev.h for driver implementation definitions.
  67. */
  68. #ifndef __iwl_commands_h__
  69. #define __iwl_commands_h__
  70. #include <linux/ieee80211.h>
  71. #include <linux/types.h>
  72. enum {
  73. REPLY_ALIVE = 0x1,
  74. REPLY_ERROR = 0x2,
  75. REPLY_ECHO = 0x3, /* test command */
  76. /* RXON and QOS commands */
  77. REPLY_RXON = 0x10,
  78. REPLY_RXON_ASSOC = 0x11,
  79. REPLY_QOS_PARAM = 0x13,
  80. REPLY_RXON_TIMING = 0x14,
  81. /* Multi-Station support */
  82. REPLY_ADD_STA = 0x18,
  83. REPLY_REMOVE_STA = 0x19,
  84. REPLY_REMOVE_ALL_STA = 0x1a, /* not used */
  85. REPLY_TXFIFO_FLUSH = 0x1e,
  86. /* Security */
  87. REPLY_WEPKEY = 0x20,
  88. /* RX, TX, LEDs */
  89. REPLY_TX = 0x1c,
  90. REPLY_LEDS_CMD = 0x48,
  91. REPLY_TX_LINK_QUALITY_CMD = 0x4e,
  92. /* WiMAX coexistence */
  93. COEX_PRIORITY_TABLE_CMD = 0x5a,
  94. COEX_MEDIUM_NOTIFICATION = 0x5b,
  95. COEX_EVENT_CMD = 0x5c,
  96. /* Calibration */
  97. TEMPERATURE_NOTIFICATION = 0x62,
  98. CALIBRATION_CFG_CMD = 0x65,
  99. CALIBRATION_RES_NOTIFICATION = 0x66,
  100. CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
  101. /* 802.11h related */
  102. REPLY_QUIET_CMD = 0x71, /* not used */
  103. REPLY_CHANNEL_SWITCH = 0x72,
  104. CHANNEL_SWITCH_NOTIFICATION = 0x73,
  105. REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
  106. SPECTRUM_MEASURE_NOTIFICATION = 0x75,
  107. /* Power Management */
  108. POWER_TABLE_CMD = 0x77,
  109. PM_SLEEP_NOTIFICATION = 0x7A,
  110. PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
  111. /* Scan commands and notifications */
  112. REPLY_SCAN_CMD = 0x80,
  113. REPLY_SCAN_ABORT_CMD = 0x81,
  114. SCAN_START_NOTIFICATION = 0x82,
  115. SCAN_RESULTS_NOTIFICATION = 0x83,
  116. SCAN_COMPLETE_NOTIFICATION = 0x84,
  117. /* IBSS/AP commands */
  118. BEACON_NOTIFICATION = 0x90,
  119. REPLY_TX_BEACON = 0x91,
  120. WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */
  121. /* Miscellaneous commands */
  122. REPLY_TX_POWER_DBM_CMD = 0x95,
  123. QUIET_NOTIFICATION = 0x96, /* not used */
  124. REPLY_TX_PWR_TABLE_CMD = 0x97,
  125. REPLY_TX_POWER_DBM_CMD_V1 = 0x98, /* old version of API */
  126. TX_ANT_CONFIGURATION_CMD = 0x98,
  127. MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
  128. /* Bluetooth device coexistence config command */
  129. REPLY_BT_CONFIG = 0x9b,
  130. /* Statistics */
  131. REPLY_STATISTICS_CMD = 0x9c,
  132. STATISTICS_NOTIFICATION = 0x9d,
  133. /* RF-KILL commands and notifications */
  134. REPLY_CARD_STATE_CMD = 0xa0,
  135. CARD_STATE_NOTIFICATION = 0xa1,
  136. /* Missed beacons notification */
  137. MISSED_BEACONS_NOTIFICATION = 0xa2,
  138. REPLY_CT_KILL_CONFIG_CMD = 0xa4,
  139. SENSITIVITY_CMD = 0xa8,
  140. REPLY_PHY_CALIBRATION_CMD = 0xb0,
  141. REPLY_RX_PHY_CMD = 0xc0,
  142. REPLY_RX_MPDU_CMD = 0xc1,
  143. REPLY_RX = 0xc3,
  144. REPLY_COMPRESSED_BA = 0xc5,
  145. /* BT Coex */
  146. REPLY_BT_COEX_PRIO_TABLE = 0xcc,
  147. REPLY_BT_COEX_PROT_ENV = 0xcd,
  148. REPLY_BT_COEX_PROFILE_NOTIF = 0xce,
  149. /* PAN commands */
  150. REPLY_WIPAN_PARAMS = 0xb2,
  151. REPLY_WIPAN_RXON = 0xb3, /* use REPLY_RXON structure */
  152. REPLY_WIPAN_RXON_TIMING = 0xb4, /* use REPLY_RXON_TIMING structure */
  153. REPLY_WIPAN_RXON_ASSOC = 0xb6, /* use REPLY_RXON_ASSOC structure */
  154. REPLY_WIPAN_QOS_PARAM = 0xb7, /* use REPLY_QOS_PARAM structure */
  155. REPLY_WIPAN_WEPKEY = 0xb8, /* use REPLY_WEPKEY structure */
  156. REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9,
  157. REPLY_WIPAN_NOA_NOTIFICATION = 0xbc,
  158. REPLY_WIPAN_DEACTIVATION_COMPLETE = 0xbd,
  159. REPLY_WOWLAN_PATTERNS = 0xe0,
  160. REPLY_WOWLAN_WAKEUP_FILTER = 0xe1,
  161. REPLY_WOWLAN_TSC_RSC_PARAMS = 0xe2,
  162. REPLY_WOWLAN_TKIP_PARAMS = 0xe3,
  163. REPLY_WOWLAN_KEK_KCK_MATERIAL = 0xe4,
  164. REPLY_WOWLAN_GET_STATUS = 0xe5,
  165. REPLY_D3_CONFIG = 0xd3,
  166. REPLY_MAX = 0xff
  167. };
  168. /*
  169. * Minimum number of queues. MAX_NUM is defined in hw specific files.
  170. * Set the minimum to accommodate
  171. * - 4 standard TX queues
  172. * - the command queue
  173. * - 4 PAN TX queues
  174. * - the PAN multicast queue, and
  175. * - the AUX (TX during scan dwell) queue.
  176. */
  177. #define IWL_MIN_NUM_QUEUES 11
  178. /*
  179. * Command queue depends on iPAN support.
  180. */
  181. #define IWL_DEFAULT_CMD_QUEUE_NUM 4
  182. #define IWL_IPAN_CMD_QUEUE_NUM 9
  183. #define IWL_TX_FIFO_BK 0 /* shared */
  184. #define IWL_TX_FIFO_BE 1
  185. #define IWL_TX_FIFO_VI 2 /* shared */
  186. #define IWL_TX_FIFO_VO 3
  187. #define IWL_TX_FIFO_BK_IPAN IWL_TX_FIFO_BK
  188. #define IWL_TX_FIFO_BE_IPAN 4
  189. #define IWL_TX_FIFO_VI_IPAN IWL_TX_FIFO_VI
  190. #define IWL_TX_FIFO_VO_IPAN 5
  191. /* re-uses the VO FIFO, uCode will properly flush/schedule */
  192. #define IWL_TX_FIFO_AUX 5
  193. #define IWL_TX_FIFO_UNUSED 255
  194. #define IWLAGN_CMD_FIFO_NUM 7
  195. /*
  196. * This queue number is required for proper operation
  197. * because the ucode will stop/start the scheduler as
  198. * required.
  199. */
  200. #define IWL_IPAN_MCAST_QUEUE 8
  201. /******************************************************************************
  202. * (0)
  203. * Commonly used structures and definitions:
  204. * Command header, rate_n_flags, txpower
  205. *
  206. *****************************************************************************/
  207. /**
  208. * iwlagn rate_n_flags bit fields
  209. *
  210. * rate_n_flags format is used in following iwlagn commands:
  211. * REPLY_RX (response only)
  212. * REPLY_RX_MPDU (response only)
  213. * REPLY_TX (both command and response)
  214. * REPLY_TX_LINK_QUALITY_CMD
  215. *
  216. * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
  217. * 2-0: 0) 6 Mbps
  218. * 1) 12 Mbps
  219. * 2) 18 Mbps
  220. * 3) 24 Mbps
  221. * 4) 36 Mbps
  222. * 5) 48 Mbps
  223. * 6) 54 Mbps
  224. * 7) 60 Mbps
  225. *
  226. * 4-3: 0) Single stream (SISO)
  227. * 1) Dual stream (MIMO)
  228. * 2) Triple stream (MIMO)
  229. *
  230. * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
  231. *
  232. * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
  233. * 3-0: 0xD) 6 Mbps
  234. * 0xF) 9 Mbps
  235. * 0x5) 12 Mbps
  236. * 0x7) 18 Mbps
  237. * 0x9) 24 Mbps
  238. * 0xB) 36 Mbps
  239. * 0x1) 48 Mbps
  240. * 0x3) 54 Mbps
  241. *
  242. * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
  243. * 6-0: 10) 1 Mbps
  244. * 20) 2 Mbps
  245. * 55) 5.5 Mbps
  246. * 110) 11 Mbps
  247. */
  248. #define RATE_MCS_CODE_MSK 0x7
  249. #define RATE_MCS_SPATIAL_POS 3
  250. #define RATE_MCS_SPATIAL_MSK 0x18
  251. #define RATE_MCS_HT_DUP_POS 5
  252. #define RATE_MCS_HT_DUP_MSK 0x20
  253. /* Both legacy and HT use bits 7:0 as the CCK/OFDM rate or HT MCS */
  254. #define RATE_MCS_RATE_MSK 0xff
  255. /* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
  256. #define RATE_MCS_FLAGS_POS 8
  257. #define RATE_MCS_HT_POS 8
  258. #define RATE_MCS_HT_MSK 0x100
  259. /* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */
  260. #define RATE_MCS_CCK_POS 9
  261. #define RATE_MCS_CCK_MSK 0x200
  262. /* Bit 10: (1) Use Green Field preamble */
  263. #define RATE_MCS_GF_POS 10
  264. #define RATE_MCS_GF_MSK 0x400
  265. /* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */
  266. #define RATE_MCS_HT40_POS 11
  267. #define RATE_MCS_HT40_MSK 0x800
  268. /* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */
  269. #define RATE_MCS_DUP_POS 12
  270. #define RATE_MCS_DUP_MSK 0x1000
  271. /* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
  272. #define RATE_MCS_SGI_POS 13
  273. #define RATE_MCS_SGI_MSK 0x2000
  274. /**
  275. * rate_n_flags Tx antenna masks
  276. * 4965 has 2 transmitters
  277. * 5100 has 1 transmitter B
  278. * 5150 has 1 transmitter A
  279. * 5300 has 3 transmitters
  280. * 5350 has 3 transmitters
  281. * bit14:16
  282. */
  283. #define RATE_MCS_ANT_POS 14
  284. #define RATE_MCS_ANT_A_MSK 0x04000
  285. #define RATE_MCS_ANT_B_MSK 0x08000
  286. #define RATE_MCS_ANT_C_MSK 0x10000
  287. #define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK)
  288. #define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
  289. #define RATE_ANT_NUM 3
  290. #define POWER_TABLE_NUM_ENTRIES 33
  291. #define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32
  292. #define POWER_TABLE_CCK_ENTRY 32
  293. #define IWL_PWR_NUM_HT_OFDM_ENTRIES 24
  294. #define IWL_PWR_CCK_ENTRIES 2
  295. /**
  296. * struct tx_power_dual_stream
  297. *
  298. * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
  299. *
  300. * Same format as iwl_tx_power_dual_stream, but __le32
  301. */
  302. struct tx_power_dual_stream {
  303. __le32 dw;
  304. } __packed;
  305. /**
  306. * Command REPLY_TX_POWER_DBM_CMD = 0x98
  307. * struct iwlagn_tx_power_dbm_cmd
  308. */
  309. #define IWLAGN_TX_POWER_AUTO 0x7f
  310. #define IWLAGN_TX_POWER_NO_CLOSED (0x1 << 6)
  311. struct iwlagn_tx_power_dbm_cmd {
  312. s8 global_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
  313. u8 flags;
  314. s8 srv_chan_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
  315. u8 reserved;
  316. } __packed;
  317. /**
  318. * Command TX_ANT_CONFIGURATION_CMD = 0x98
  319. * This command is used to configure valid Tx antenna.
  320. * By default uCode concludes the valid antenna according to the radio flavor.
  321. * This command enables the driver to override/modify this conclusion.
  322. */
  323. struct iwl_tx_ant_config_cmd {
  324. __le32 valid;
  325. } __packed;
  326. /******************************************************************************
  327. * (0a)
  328. * Alive and Error Commands & Responses:
  329. *
  330. *****************************************************************************/
  331. #define UCODE_VALID_OK cpu_to_le32(0x1)
  332. /**
  333. * REPLY_ALIVE = 0x1 (response only, not a command)
  334. *
  335. * uCode issues this "alive" notification once the runtime image is ready
  336. * to receive commands from the driver. This is the *second* "alive"
  337. * notification that the driver will receive after rebooting uCode;
  338. * this "alive" is indicated by subtype field != 9.
  339. *
  340. * See comments documenting "BSM" (bootstrap state machine).
  341. *
  342. * This response includes two pointers to structures within the device's
  343. * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
  344. *
  345. * 1) log_event_table_ptr indicates base of the event log. This traces
  346. * a 256-entry history of uCode execution within a circular buffer.
  347. * Its header format is:
  348. *
  349. * __le32 log_size; log capacity (in number of entries)
  350. * __le32 type; (1) timestamp with each entry, (0) no timestamp
  351. * __le32 wraps; # times uCode has wrapped to top of circular buffer
  352. * __le32 write_index; next circular buffer entry that uCode would fill
  353. *
  354. * The header is followed by the circular buffer of log entries. Entries
  355. * with timestamps have the following format:
  356. *
  357. * __le32 event_id; range 0 - 1500
  358. * __le32 timestamp; low 32 bits of TSF (of network, if associated)
  359. * __le32 data; event_id-specific data value
  360. *
  361. * Entries without timestamps contain only event_id and data.
  362. *
  363. *
  364. * 2) error_event_table_ptr indicates base of the error log. This contains
  365. * information about any uCode error that occurs. For agn, the format
  366. * of the error log is defined by struct iwl_error_event_table.
  367. *
  368. * The Linux driver can print both logs to the system log when a uCode error
  369. * occurs.
  370. */
  371. /*
  372. * Note: This structure is read from the device with IO accesses,
  373. * and the reading already does the endian conversion. As it is
  374. * read with u32-sized accesses, any members with a different size
  375. * need to be ordered correctly though!
  376. */
  377. struct iwl_error_event_table {
  378. u32 valid; /* (nonzero) valid, (0) log is empty */
  379. u32 error_id; /* type of error */
  380. u32 pc; /* program counter */
  381. u32 blink1; /* branch link */
  382. u32 blink2; /* branch link */
  383. u32 ilink1; /* interrupt link */
  384. u32 ilink2; /* interrupt link */
  385. u32 data1; /* error-specific data */
  386. u32 data2; /* error-specific data */
  387. u32 line; /* source code line of error */
  388. u32 bcon_time; /* beacon timer */
  389. u32 tsf_low; /* network timestamp function timer */
  390. u32 tsf_hi; /* network timestamp function timer */
  391. u32 gp1; /* GP1 timer register */
  392. u32 gp2; /* GP2 timer register */
  393. u32 gp3; /* GP3 timer register */
  394. u32 ucode_ver; /* uCode version */
  395. u32 hw_ver; /* HW Silicon version */
  396. u32 brd_ver; /* HW board version */
  397. u32 log_pc; /* log program counter */
  398. u32 frame_ptr; /* frame pointer */
  399. u32 stack_ptr; /* stack pointer */
  400. u32 hcmd; /* last host command header */
  401. u32 isr0; /* isr status register LMPM_NIC_ISR0:
  402. * rxtx_flag */
  403. u32 isr1; /* isr status register LMPM_NIC_ISR1:
  404. * host_flag */
  405. u32 isr2; /* isr status register LMPM_NIC_ISR2:
  406. * enc_flag */
  407. u32 isr3; /* isr status register LMPM_NIC_ISR3:
  408. * time_flag */
  409. u32 isr4; /* isr status register LMPM_NIC_ISR4:
  410. * wico interrupt */
  411. u32 isr_pref; /* isr status register LMPM_NIC_PREF_STAT */
  412. u32 wait_event; /* wait event() caller address */
  413. u32 l2p_control; /* L2pControlField */
  414. u32 l2p_duration; /* L2pDurationField */
  415. u32 l2p_mhvalid; /* L2pMhValidBits */
  416. u32 l2p_addr_match; /* L2pAddrMatchStat */
  417. u32 lmpm_pmg_sel; /* indicate which clocks are turned on
  418. * (LMPM_PMG_SEL) */
  419. u32 u_timestamp; /* indicate when the date and time of the
  420. * compilation */
  421. u32 flow_handler; /* FH read/write pointers, RX credit */
  422. } __packed;
  423. struct iwl_alive_resp {
  424. u8 ucode_minor;
  425. u8 ucode_major;
  426. __le16 reserved1;
  427. u8 sw_rev[8];
  428. u8 ver_type;
  429. u8 ver_subtype; /* not "9" for runtime alive */
  430. __le16 reserved2;
  431. __le32 log_event_table_ptr; /* SRAM address for event log */
  432. __le32 error_event_table_ptr; /* SRAM address for error log */
  433. __le32 timestamp;
  434. __le32 is_valid;
  435. } __packed;
  436. /*
  437. * REPLY_ERROR = 0x2 (response only, not a command)
  438. */
  439. struct iwl_error_resp {
  440. __le32 error_type;
  441. u8 cmd_id;
  442. u8 reserved1;
  443. __le16 bad_cmd_seq_num;
  444. __le32 error_info;
  445. __le64 timestamp;
  446. } __packed;
  447. /******************************************************************************
  448. * (1)
  449. * RXON Commands & Responses:
  450. *
  451. *****************************************************************************/
  452. /*
  453. * Rx config defines & structure
  454. */
  455. /* rx_config device types */
  456. enum {
  457. RXON_DEV_TYPE_AP = 1,
  458. RXON_DEV_TYPE_ESS = 3,
  459. RXON_DEV_TYPE_IBSS = 4,
  460. RXON_DEV_TYPE_SNIFFER = 6,
  461. RXON_DEV_TYPE_CP = 7,
  462. RXON_DEV_TYPE_2STA = 8,
  463. RXON_DEV_TYPE_P2P = 9,
  464. };
  465. #define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0)
  466. #define RXON_RX_CHAIN_DRIVER_FORCE_POS (0)
  467. #define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1)
  468. #define RXON_RX_CHAIN_VALID_POS (1)
  469. #define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4)
  470. #define RXON_RX_CHAIN_FORCE_SEL_POS (4)
  471. #define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7)
  472. #define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
  473. #define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10)
  474. #define RXON_RX_CHAIN_CNT_POS (10)
  475. #define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12)
  476. #define RXON_RX_CHAIN_MIMO_CNT_POS (12)
  477. #define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14)
  478. #define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
  479. /* rx_config flags */
  480. /* band & modulation selection */
  481. #define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0)
  482. #define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1)
  483. /* auto detection enable */
  484. #define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2)
  485. /* TGg protection when tx */
  486. #define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3)
  487. /* cck short slot & preamble */
  488. #define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4)
  489. #define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5)
  490. /* antenna selection */
  491. #define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7)
  492. #define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00)
  493. #define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
  494. #define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
  495. /* radar detection enable */
  496. #define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12)
  497. #define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13)
  498. /* rx response to host with 8-byte TSF
  499. * (according to ON_AIR deassertion) */
  500. #define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15)
  501. /* HT flags */
  502. #define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
  503. #define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22)
  504. #define RXON_FLG_HT_OPERATING_MODE_POS (23)
  505. #define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23)
  506. #define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23)
  507. #define RXON_FLG_CHANNEL_MODE_POS (25)
  508. #define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25)
  509. /* channel mode */
  510. enum {
  511. CHANNEL_MODE_LEGACY = 0,
  512. CHANNEL_MODE_PURE_40 = 1,
  513. CHANNEL_MODE_MIXED = 2,
  514. CHANNEL_MODE_RESERVED = 3,
  515. };
  516. #define RXON_FLG_CHANNEL_MODE_LEGACY cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
  517. #define RXON_FLG_CHANNEL_MODE_PURE_40 cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
  518. #define RXON_FLG_CHANNEL_MODE_MIXED cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
  519. /* CTS to self (if spec allows) flag */
  520. #define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30)
  521. /* rx_config filter flags */
  522. /* accept all data frames */
  523. #define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0)
  524. /* pass control & management to host */
  525. #define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1)
  526. /* accept multi-cast */
  527. #define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2)
  528. /* don't decrypt uni-cast frames */
  529. #define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3)
  530. /* don't decrypt multi-cast frames */
  531. #define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
  532. /* STA is associated */
  533. #define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5)
  534. /* transfer to host non bssid beacons in associated state */
  535. #define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6)
  536. /**
  537. * REPLY_RXON = 0x10 (command, has simple generic response)
  538. *
  539. * RXON tunes the radio tuner to a service channel, and sets up a number
  540. * of parameters that are used primarily for Rx, but also for Tx operations.
  541. *
  542. * NOTE: When tuning to a new channel, driver must set the
  543. * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent
  544. * info within the device, including the station tables, tx retry
  545. * rate tables, and txpower tables. Driver must build a new station
  546. * table and txpower table before transmitting anything on the RXON
  547. * channel.
  548. *
  549. * NOTE: All RXONs wipe clean the internal txpower table. Driver must
  550. * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
  551. * regardless of whether RXON_FILTER_ASSOC_MSK is set.
  552. */
  553. struct iwl_rxon_cmd {
  554. u8 node_addr[6];
  555. __le16 reserved1;
  556. u8 bssid_addr[6];
  557. __le16 reserved2;
  558. u8 wlap_bssid_addr[6];
  559. __le16 reserved3;
  560. u8 dev_type;
  561. u8 air_propagation;
  562. __le16 rx_chain;
  563. u8 ofdm_basic_rates;
  564. u8 cck_basic_rates;
  565. __le16 assoc_id;
  566. __le32 flags;
  567. __le32 filter_flags;
  568. __le16 channel;
  569. u8 ofdm_ht_single_stream_basic_rates;
  570. u8 ofdm_ht_dual_stream_basic_rates;
  571. u8 ofdm_ht_triple_stream_basic_rates;
  572. u8 reserved5;
  573. __le16 acquisition_data;
  574. __le16 reserved6;
  575. } __packed;
  576. /*
  577. * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
  578. */
  579. struct iwl_rxon_assoc_cmd {
  580. __le32 flags;
  581. __le32 filter_flags;
  582. u8 ofdm_basic_rates;
  583. u8 cck_basic_rates;
  584. __le16 reserved1;
  585. u8 ofdm_ht_single_stream_basic_rates;
  586. u8 ofdm_ht_dual_stream_basic_rates;
  587. u8 ofdm_ht_triple_stream_basic_rates;
  588. u8 reserved2;
  589. __le16 rx_chain_select_flags;
  590. __le16 acquisition_data;
  591. __le32 reserved3;
  592. } __packed;
  593. #define IWL_CONN_MAX_LISTEN_INTERVAL 10
  594. #define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */
  595. /*
  596. * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
  597. */
  598. struct iwl_rxon_time_cmd {
  599. __le64 timestamp;
  600. __le16 beacon_interval;
  601. __le16 atim_window;
  602. __le32 beacon_init_val;
  603. __le16 listen_interval;
  604. u8 dtim_period;
  605. u8 delta_cp_bss_tbtts;
  606. } __packed;
  607. /*
  608. * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
  609. */
  610. /**
  611. * struct iwl5000_channel_switch_cmd
  612. * @band: 0- 5.2GHz, 1- 2.4GHz
  613. * @expect_beacon: 0- resume transmits after channel switch
  614. * 1- wait for beacon to resume transmits
  615. * @channel: new channel number
  616. * @rxon_flags: Rx on flags
  617. * @rxon_filter_flags: filtering parameters
  618. * @switch_time: switch time in extended beacon format
  619. * @reserved: reserved bytes
  620. */
  621. struct iwl5000_channel_switch_cmd {
  622. u8 band;
  623. u8 expect_beacon;
  624. __le16 channel;
  625. __le32 rxon_flags;
  626. __le32 rxon_filter_flags;
  627. __le32 switch_time;
  628. __le32 reserved[2][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
  629. } __packed;
  630. /**
  631. * struct iwl6000_channel_switch_cmd
  632. * @band: 0- 5.2GHz, 1- 2.4GHz
  633. * @expect_beacon: 0- resume transmits after channel switch
  634. * 1- wait for beacon to resume transmits
  635. * @channel: new channel number
  636. * @rxon_flags: Rx on flags
  637. * @rxon_filter_flags: filtering parameters
  638. * @switch_time: switch time in extended beacon format
  639. * @reserved: reserved bytes
  640. */
  641. struct iwl6000_channel_switch_cmd {
  642. u8 band;
  643. u8 expect_beacon;
  644. __le16 channel;
  645. __le32 rxon_flags;
  646. __le32 rxon_filter_flags;
  647. __le32 switch_time;
  648. __le32 reserved[3][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
  649. } __packed;
  650. /*
  651. * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
  652. */
  653. struct iwl_csa_notification {
  654. __le16 band;
  655. __le16 channel;
  656. __le32 status; /* 0 - OK, 1 - fail */
  657. } __packed;
  658. /******************************************************************************
  659. * (2)
  660. * Quality-of-Service (QOS) Commands & Responses:
  661. *
  662. *****************************************************************************/
  663. /**
  664. * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
  665. * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
  666. *
  667. * @cw_min: Contention window, start value in numbers of slots.
  668. * Should be a power-of-2, minus 1. Device's default is 0x0f.
  669. * @cw_max: Contention window, max value in numbers of slots.
  670. * Should be a power-of-2, minus 1. Device's default is 0x3f.
  671. * @aifsn: Number of slots in Arbitration Interframe Space (before
  672. * performing random backoff timing prior to Tx). Device default 1.
  673. * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0.
  674. *
  675. * Device will automatically increase contention window by (2*CW) + 1 for each
  676. * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW
  677. * value, to cap the CW value.
  678. */
  679. struct iwl_ac_qos {
  680. __le16 cw_min;
  681. __le16 cw_max;
  682. u8 aifsn;
  683. u8 reserved1;
  684. __le16 edca_txop;
  685. } __packed;
  686. /* QoS flags defines */
  687. #define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01)
  688. #define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02)
  689. #define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10)
  690. /* Number of Access Categories (AC) (EDCA), queues 0..3 */
  691. #define AC_NUM 4
  692. /*
  693. * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
  694. *
  695. * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
  696. * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
  697. */
  698. struct iwl_qosparam_cmd {
  699. __le32 qos_flags;
  700. struct iwl_ac_qos ac[AC_NUM];
  701. } __packed;
  702. /******************************************************************************
  703. * (3)
  704. * Add/Modify Stations Commands & Responses:
  705. *
  706. *****************************************************************************/
  707. /*
  708. * Multi station support
  709. */
  710. /* Special, dedicated locations within device's station table */
  711. #define IWL_AP_ID 0
  712. #define IWL_AP_ID_PAN 1
  713. #define IWL_STA_ID 2
  714. #define IWLAGN_PAN_BCAST_ID 14
  715. #define IWLAGN_BROADCAST_ID 15
  716. #define IWLAGN_STATION_COUNT 16
  717. #define IWL_TID_NON_QOS IWL_MAX_TID_COUNT
  718. #define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2)
  719. #define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8)
  720. #define STA_FLG_PAN_STATION cpu_to_le32(1 << 13)
  721. #define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
  722. #define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
  723. #define STA_FLG_MAX_AGG_SIZE_POS (19)
  724. #define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19)
  725. #define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21)
  726. #define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22)
  727. #define STA_FLG_AGG_MPDU_DENSITY_POS (23)
  728. #define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23)
  729. /* Use in mode field. 1: modify existing entry, 0: add new station entry */
  730. #define STA_CONTROL_MODIFY_MSK 0x01
  731. /* key flags __le16*/
  732. #define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007)
  733. #define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000)
  734. #define STA_KEY_FLG_WEP cpu_to_le16(0x0001)
  735. #define STA_KEY_FLG_CCMP cpu_to_le16(0x0002)
  736. #define STA_KEY_FLG_TKIP cpu_to_le16(0x0003)
  737. #define STA_KEY_FLG_KEYID_POS 8
  738. #define STA_KEY_FLG_INVALID cpu_to_le16(0x0800)
  739. /* wep key is either from global key (0) or from station info array (1) */
  740. #define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008)
  741. /* wep key in STA: 5-bytes (0) or 13-bytes (1) */
  742. #define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
  743. #define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
  744. #define STA_KEY_MAX_NUM 8
  745. #define STA_KEY_MAX_NUM_PAN 16
  746. /* must not match WEP_INVALID_OFFSET */
  747. #define IWLAGN_HW_KEY_DEFAULT 0xfe
  748. /* Flags indicate whether to modify vs. don't change various station params */
  749. #define STA_MODIFY_KEY_MASK 0x01
  750. #define STA_MODIFY_TID_DISABLE_TX 0x02
  751. #define STA_MODIFY_TX_RATE_MSK 0x04
  752. #define STA_MODIFY_ADDBA_TID_MSK 0x08
  753. #define STA_MODIFY_DELBA_TID_MSK 0x10
  754. #define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20
  755. /* agn */
  756. struct iwl_keyinfo {
  757. __le16 key_flags;
  758. u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */
  759. u8 reserved1;
  760. __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
  761. u8 key_offset;
  762. u8 reserved2;
  763. u8 key[16]; /* 16-byte unicast decryption key */
  764. __le64 tx_secur_seq_cnt;
  765. __le64 hw_tkip_mic_rx_key;
  766. __le64 hw_tkip_mic_tx_key;
  767. } __packed;
  768. /**
  769. * struct sta_id_modify
  770. * @addr[ETH_ALEN]: station's MAC address
  771. * @sta_id: index of station in uCode's station table
  772. * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
  773. *
  774. * Driver selects unused table index when adding new station,
  775. * or the index to a pre-existing station entry when modifying that station.
  776. * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
  777. *
  778. * modify_mask flags select which parameters to modify vs. leave alone.
  779. */
  780. struct sta_id_modify {
  781. u8 addr[ETH_ALEN];
  782. __le16 reserved1;
  783. u8 sta_id;
  784. u8 modify_mask;
  785. __le16 reserved2;
  786. } __packed;
  787. /*
  788. * REPLY_ADD_STA = 0x18 (command)
  789. *
  790. * The device contains an internal table of per-station information,
  791. * with info on security keys, aggregation parameters, and Tx rates for
  792. * initial Tx attempt and any retries (agn devices uses
  793. * REPLY_TX_LINK_QUALITY_CMD,
  794. *
  795. * REPLY_ADD_STA sets up the table entry for one station, either creating
  796. * a new entry, or modifying a pre-existing one.
  797. *
  798. * NOTE: RXON command (without "associated" bit set) wipes the station table
  799. * clean. Moving into RF_KILL state does this also. Driver must set up
  800. * new station table before transmitting anything on the RXON channel
  801. * (except active scans or active measurements; those commands carry
  802. * their own txpower/rate setup data).
  803. *
  804. * When getting started on a new channel, driver must set up the
  805. * IWL_BROADCAST_ID entry (last entry in the table). For a client
  806. * station in a BSS, once an AP is selected, driver sets up the AP STA
  807. * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP
  808. * are all that are needed for a BSS client station. If the device is
  809. * used as AP, or in an IBSS network, driver must set up station table
  810. * entries for all STAs in network, starting with index IWL_STA_ID.
  811. */
  812. struct iwl_addsta_cmd {
  813. u8 mode; /* 1: modify existing, 0: add new station */
  814. u8 reserved[3];
  815. struct sta_id_modify sta;
  816. struct iwl_keyinfo key;
  817. __le32 station_flags; /* STA_FLG_* */
  818. __le32 station_flags_msk; /* STA_FLG_* */
  819. /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
  820. * corresponding to bit (e.g. bit 5 controls TID 5).
  821. * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
  822. __le16 tid_disable_tx;
  823. __le16 legacy_reserved;
  824. /* TID for which to add block-ack support.
  825. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
  826. u8 add_immediate_ba_tid;
  827. /* TID for which to remove block-ack support.
  828. * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
  829. u8 remove_immediate_ba_tid;
  830. /* Starting Sequence Number for added block-ack support.
  831. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
  832. __le16 add_immediate_ba_ssn;
  833. /*
  834. * Number of packets OK to transmit to station even though
  835. * it is asleep -- used to synchronise PS-poll and u-APSD
  836. * responses while ucode keeps track of STA sleep state.
  837. */
  838. __le16 sleep_tx_count;
  839. __le16 reserved2;
  840. } __packed;
  841. #define ADD_STA_SUCCESS_MSK 0x1
  842. #define ADD_STA_NO_ROOM_IN_TABLE 0x2
  843. #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4
  844. #define ADD_STA_MODIFY_NON_EXIST_STA 0x8
  845. /*
  846. * REPLY_ADD_STA = 0x18 (response)
  847. */
  848. struct iwl_add_sta_resp {
  849. u8 status; /* ADD_STA_* */
  850. } __packed;
  851. #define REM_STA_SUCCESS_MSK 0x1
  852. /*
  853. * REPLY_REM_STA = 0x19 (response)
  854. */
  855. struct iwl_rem_sta_resp {
  856. u8 status;
  857. } __packed;
  858. /*
  859. * REPLY_REM_STA = 0x19 (command)
  860. */
  861. struct iwl_rem_sta_cmd {
  862. u8 num_sta; /* number of removed stations */
  863. u8 reserved[3];
  864. u8 addr[ETH_ALEN]; /* MAC addr of the first station */
  865. u8 reserved2[2];
  866. } __packed;
  867. /* WiFi queues mask */
  868. #define IWL_SCD_BK_MSK BIT(0)
  869. #define IWL_SCD_BE_MSK BIT(1)
  870. #define IWL_SCD_VI_MSK BIT(2)
  871. #define IWL_SCD_VO_MSK BIT(3)
  872. #define IWL_SCD_MGMT_MSK BIT(3)
  873. /* PAN queues mask */
  874. #define IWL_PAN_SCD_BK_MSK BIT(4)
  875. #define IWL_PAN_SCD_BE_MSK BIT(5)
  876. #define IWL_PAN_SCD_VI_MSK BIT(6)
  877. #define IWL_PAN_SCD_VO_MSK BIT(7)
  878. #define IWL_PAN_SCD_MGMT_MSK BIT(7)
  879. #define IWL_PAN_SCD_MULTICAST_MSK BIT(8)
  880. #define IWL_AGG_TX_QUEUE_MSK 0xffc00
  881. #define IWL_DROP_ALL BIT(1)
  882. /*
  883. * REPLY_TXFIFO_FLUSH = 0x1e(command and response)
  884. *
  885. * When using full FIFO flush this command checks the scheduler HW block WR/RD
  886. * pointers to check if all the frames were transferred by DMA into the
  887. * relevant TX FIFO queue. Only when the DMA is finished and the queue is
  888. * empty the command can finish.
  889. * This command is used to flush the TXFIFO from transmit commands, it may
  890. * operate on single or multiple queues, the command queue can't be flushed by
  891. * this command. The command response is returned when all the queue flush
  892. * operations are done. Each TX command flushed return response with the FLUSH
  893. * status set in the TX response status. When FIFO flush operation is used,
  894. * the flush operation ends when both the scheduler DMA done and TXFIFO empty
  895. * are set.
  896. *
  897. * @queue_control: bit mask for which queues to flush
  898. * @flush_control: flush controls
  899. * 0: Dump single MSDU
  900. * 1: Dump multiple MSDU according to PS, INVALID STA, TTL, TID disable.
  901. * 2: Dump all FIFO
  902. */
  903. struct iwl_txfifo_flush_cmd_v3 {
  904. __le32 queue_control;
  905. __le16 flush_control;
  906. __le16 reserved;
  907. } __packed;
  908. struct iwl_txfifo_flush_cmd_v2 {
  909. __le16 queue_control;
  910. __le16 flush_control;
  911. } __packed;
  912. /*
  913. * REPLY_WEP_KEY = 0x20
  914. */
  915. struct iwl_wep_key {
  916. u8 key_index;
  917. u8 key_offset;
  918. u8 reserved1[2];
  919. u8 key_size;
  920. u8 reserved2[3];
  921. u8 key[16];
  922. } __packed;
  923. struct iwl_wep_cmd {
  924. u8 num_keys;
  925. u8 global_key_type;
  926. u8 flags;
  927. u8 reserved;
  928. struct iwl_wep_key key[0];
  929. } __packed;
  930. #define WEP_KEY_WEP_TYPE 1
  931. #define WEP_KEYS_MAX 4
  932. #define WEP_INVALID_OFFSET 0xff
  933. #define WEP_KEY_LEN_64 5
  934. #define WEP_KEY_LEN_128 13
  935. /******************************************************************************
  936. * (4)
  937. * Rx Responses:
  938. *
  939. *****************************************************************************/
  940. #define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0)
  941. #define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1)
  942. #define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0)
  943. #define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1)
  944. #define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2)
  945. #define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3)
  946. #define RX_RES_PHY_FLAGS_ANTENNA_MSK 0x70
  947. #define RX_RES_PHY_FLAGS_ANTENNA_POS 4
  948. #define RX_RES_PHY_FLAGS_AGG_MSK cpu_to_le16(1 << 7)
  949. #define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8)
  950. #define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8)
  951. #define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8)
  952. #define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8)
  953. #define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8)
  954. #define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8)
  955. #define RX_RES_STATUS_STATION_FOUND (1<<6)
  956. #define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7)
  957. #define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11)
  958. #define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11)
  959. #define RX_RES_STATUS_DECRYPT_OK (0x3 << 11)
  960. #define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11)
  961. #define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11)
  962. #define RX_MPDU_RES_STATUS_ICV_OK (0x20)
  963. #define RX_MPDU_RES_STATUS_MIC_OK (0x40)
  964. #define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7)
  965. #define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800)
  966. #define IWLAGN_RX_RES_PHY_CNT 8
  967. #define IWLAGN_RX_RES_AGC_IDX 1
  968. #define IWLAGN_RX_RES_RSSI_AB_IDX 2
  969. #define IWLAGN_RX_RES_RSSI_C_IDX 3
  970. #define IWLAGN_OFDM_AGC_MSK 0xfe00
  971. #define IWLAGN_OFDM_AGC_BIT_POS 9
  972. #define IWLAGN_OFDM_RSSI_INBAND_A_BITMSK 0x00ff
  973. #define IWLAGN_OFDM_RSSI_ALLBAND_A_BITMSK 0xff00
  974. #define IWLAGN_OFDM_RSSI_A_BIT_POS 0
  975. #define IWLAGN_OFDM_RSSI_INBAND_B_BITMSK 0xff0000
  976. #define IWLAGN_OFDM_RSSI_ALLBAND_B_BITMSK 0xff000000
  977. #define IWLAGN_OFDM_RSSI_B_BIT_POS 16
  978. #define IWLAGN_OFDM_RSSI_INBAND_C_BITMSK 0x00ff
  979. #define IWLAGN_OFDM_RSSI_ALLBAND_C_BITMSK 0xff00
  980. #define IWLAGN_OFDM_RSSI_C_BIT_POS 0
  981. struct iwlagn_non_cfg_phy {
  982. __le32 non_cfg_phy[IWLAGN_RX_RES_PHY_CNT]; /* up to 8 phy entries */
  983. } __packed;
  984. /*
  985. * REPLY_RX = 0xc3 (response only, not a command)
  986. * Used only for legacy (non 11n) frames.
  987. */
  988. struct iwl_rx_phy_res {
  989. u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */
  990. u8 cfg_phy_cnt; /* configurable DSP phy data byte count */
  991. u8 stat_id; /* configurable DSP phy data set ID */
  992. u8 reserved1;
  993. __le64 timestamp; /* TSF at on air rise */
  994. __le32 beacon_time_stamp; /* beacon at on-air rise */
  995. __le16 phy_flags; /* general phy flags: band, modulation, ... */
  996. __le16 channel; /* channel number */
  997. u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
  998. __le32 rate_n_flags; /* RATE_MCS_* */
  999. __le16 byte_count; /* frame's byte-count */
  1000. __le16 frame_time; /* frame's time on the air */
  1001. } __packed;
  1002. struct iwl_rx_mpdu_res_start {
  1003. __le16 byte_count;
  1004. __le16 reserved;
  1005. } __packed;
  1006. /******************************************************************************
  1007. * (5)
  1008. * Tx Commands & Responses:
  1009. *
  1010. * Driver must place each REPLY_TX command into one of the prioritized Tx
  1011. * queues in host DRAM, shared between driver and device (see comments for
  1012. * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode
  1013. * are preparing to transmit, the device pulls the Tx command over the PCI
  1014. * bus via one of the device's Tx DMA channels, to fill an internal FIFO
  1015. * from which data will be transmitted.
  1016. *
  1017. * uCode handles all timing and protocol related to control frames
  1018. * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler
  1019. * handle reception of block-acks; uCode updates the host driver via
  1020. * REPLY_COMPRESSED_BA.
  1021. *
  1022. * uCode handles retrying Tx when an ACK is expected but not received.
  1023. * This includes trying lower data rates than the one requested in the Tx
  1024. * command, as set up by the REPLY_TX_LINK_QUALITY_CMD (agn).
  1025. *
  1026. * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
  1027. * This command must be executed after every RXON command, before Tx can occur.
  1028. *****************************************************************************/
  1029. /* REPLY_TX Tx flags field */
  1030. /*
  1031. * 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
  1032. * before this frame. if CTS-to-self required check
  1033. * RXON_FLG_SELF_CTS_EN status.
  1034. */
  1035. #define TX_CMD_FLG_PROT_REQUIRE_MSK cpu_to_le32(1 << 0)
  1036. /* 1: Expect ACK from receiving station
  1037. * 0: Don't expect ACK (MAC header's duration field s/b 0)
  1038. * Set this for unicast frames, but not broadcast/multicast. */
  1039. #define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
  1040. /* For agn devices:
  1041. * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
  1042. * Tx command's initial_rate_index indicates first rate to try;
  1043. * uCode walks through table for additional Tx attempts.
  1044. * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
  1045. * This rate will be used for all Tx attempts; it will not be scaled. */
  1046. #define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
  1047. /* 1: Expect immediate block-ack.
  1048. * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */
  1049. #define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6)
  1050. /* Tx antenna selection field; reserved (0) for agn devices. */
  1051. #define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
  1052. /* 1: Ignore Bluetooth priority for this frame.
  1053. * 0: Delay Tx until Bluetooth device is done (normal usage). */
  1054. #define TX_CMD_FLG_IGNORE_BT cpu_to_le32(1 << 12)
  1055. /* 1: uCode overrides sequence control field in MAC header.
  1056. * 0: Driver provides sequence control field in MAC header.
  1057. * Set this for management frames, non-QOS data frames, non-unicast frames,
  1058. * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
  1059. #define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
  1060. /* 1: This frame is non-last MPDU; more fragments are coming.
  1061. * 0: Last fragment, or not using fragmentation. */
  1062. #define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
  1063. /* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
  1064. * 0: No TSF required in outgoing frame.
  1065. * Set this for transmitting beacons and probe responses. */
  1066. #define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
  1067. /* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
  1068. * alignment of frame's payload data field.
  1069. * 0: No pad
  1070. * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
  1071. * field (but not both). Driver must align frame data (i.e. data following
  1072. * MAC header) to DWORD boundary. */
  1073. #define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
  1074. /* accelerate aggregation support
  1075. * 0 - no CCMP encryption; 1 - CCMP encryption */
  1076. #define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
  1077. /* HCCA-AP - disable duration overwriting. */
  1078. #define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
  1079. /*
  1080. * TX command security control
  1081. */
  1082. #define TX_CMD_SEC_WEP 0x01
  1083. #define TX_CMD_SEC_CCM 0x02
  1084. #define TX_CMD_SEC_TKIP 0x03
  1085. #define TX_CMD_SEC_MSK 0x03
  1086. #define TX_CMD_SEC_SHIFT 6
  1087. #define TX_CMD_SEC_KEY128 0x08
  1088. /*
  1089. * REPLY_TX = 0x1c (command)
  1090. */
  1091. /*
  1092. * 4965 uCode updates these Tx attempt count values in host DRAM.
  1093. * Used for managing Tx retries when expecting block-acks.
  1094. * Driver should set these fields to 0.
  1095. */
  1096. struct iwl_dram_scratch {
  1097. u8 try_cnt; /* Tx attempts */
  1098. u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */
  1099. __le16 reserved;
  1100. } __packed;
  1101. struct iwl_tx_cmd {
  1102. /*
  1103. * MPDU byte count:
  1104. * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
  1105. * + 8 byte IV for CCM or TKIP (not used for WEP)
  1106. * + Data payload
  1107. * + 8-byte MIC (not used for CCM/WEP)
  1108. * NOTE: Does not include Tx command bytes, post-MAC pad bytes,
  1109. * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
  1110. * Range: 14-2342 bytes.
  1111. */
  1112. __le16 len;
  1113. /*
  1114. * MPDU or MSDU byte count for next frame.
  1115. * Used for fragmentation and bursting, but not 11n aggregation.
  1116. * Same as "len", but for next frame. Set to 0 if not applicable.
  1117. */
  1118. __le16 next_frame_len;
  1119. __le32 tx_flags; /* TX_CMD_FLG_* */
  1120. /* uCode may modify this field of the Tx command (in host DRAM!).
  1121. * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
  1122. struct iwl_dram_scratch scratch;
  1123. /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
  1124. __le32 rate_n_flags; /* RATE_MCS_* */
  1125. /* Index of destination station in uCode's station table */
  1126. u8 sta_id;
  1127. /* Type of security encryption: CCM or TKIP */
  1128. u8 sec_ctl; /* TX_CMD_SEC_* */
  1129. /*
  1130. * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
  1131. * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for
  1132. * data frames, this field may be used to selectively reduce initial
  1133. * rate (via non-0 value) for special frames (e.g. management), while
  1134. * still supporting rate scaling for all frames.
  1135. */
  1136. u8 initial_rate_index;
  1137. u8 reserved;
  1138. u8 key[16];
  1139. __le16 next_frame_flags;
  1140. __le16 reserved2;
  1141. union {
  1142. __le32 life_time;
  1143. __le32 attempt;
  1144. } stop_time;
  1145. /* Host DRAM physical address pointer to "scratch" in this command.
  1146. * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */
  1147. __le32 dram_lsb_ptr;
  1148. u8 dram_msb_ptr;
  1149. u8 rts_retry_limit; /*byte 50 */
  1150. u8 data_retry_limit; /*byte 51 */
  1151. u8 tid_tspec;
  1152. union {
  1153. __le16 pm_frame_timeout;
  1154. __le16 attempt_duration;
  1155. } timeout;
  1156. /*
  1157. * Duration of EDCA burst Tx Opportunity, in 32-usec units.
  1158. * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
  1159. */
  1160. __le16 driver_txop;
  1161. /*
  1162. * MAC header goes here, followed by 2 bytes padding if MAC header
  1163. * length is 26 or 30 bytes, followed by payload data
  1164. */
  1165. u8 payload[0];
  1166. struct ieee80211_hdr hdr[0];
  1167. } __packed;
  1168. /*
  1169. * TX command response is sent after *agn* transmission attempts.
  1170. *
  1171. * both postpone and abort status are expected behavior from uCode. there is
  1172. * no special operation required from driver; except for RFKILL_FLUSH,
  1173. * which required tx flush host command to flush all the tx frames in queues
  1174. */
  1175. enum {
  1176. TX_STATUS_SUCCESS = 0x01,
  1177. TX_STATUS_DIRECT_DONE = 0x02,
  1178. /* postpone TX */
  1179. TX_STATUS_POSTPONE_DELAY = 0x40,
  1180. TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
  1181. TX_STATUS_POSTPONE_BT_PRIO = 0x42,
  1182. TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
  1183. TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
  1184. /* abort TX */
  1185. TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
  1186. TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
  1187. TX_STATUS_FAIL_LONG_LIMIT = 0x83,
  1188. TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
  1189. TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
  1190. TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
  1191. TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
  1192. TX_STATUS_FAIL_DEST_PS = 0x88,
  1193. TX_STATUS_FAIL_HOST_ABORTED = 0x89,
  1194. TX_STATUS_FAIL_BT_RETRY = 0x8a,
  1195. TX_STATUS_FAIL_STA_INVALID = 0x8b,
  1196. TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
  1197. TX_STATUS_FAIL_TID_DISABLE = 0x8d,
  1198. TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
  1199. TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
  1200. TX_STATUS_FAIL_PASSIVE_NO_RX = 0x90,
  1201. TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
  1202. };
  1203. #define TX_PACKET_MODE_REGULAR 0x0000
  1204. #define TX_PACKET_MODE_BURST_SEQ 0x0100
  1205. #define TX_PACKET_MODE_BURST_FIRST 0x0200
  1206. enum {
  1207. TX_POWER_PA_NOT_ACTIVE = 0x0,
  1208. };
  1209. enum {
  1210. TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */
  1211. TX_STATUS_DELAY_MSK = 0x00000040,
  1212. TX_STATUS_ABORT_MSK = 0x00000080,
  1213. TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */
  1214. TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */
  1215. TX_RESERVED = 0x00780000, /* bits 19:22 */
  1216. TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */
  1217. TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */
  1218. };
  1219. /* *******************************
  1220. * TX aggregation status
  1221. ******************************* */
  1222. enum {
  1223. AGG_TX_STATE_TRANSMITTED = 0x00,
  1224. AGG_TX_STATE_UNDERRUN_MSK = 0x01,
  1225. AGG_TX_STATE_BT_PRIO_MSK = 0x02,
  1226. AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
  1227. AGG_TX_STATE_ABORT_MSK = 0x08,
  1228. AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
  1229. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
  1230. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
  1231. AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
  1232. AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
  1233. AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
  1234. AGG_TX_STATE_DUMP_TX_MSK = 0x200,
  1235. AGG_TX_STATE_DELAY_TX_MSK = 0x400
  1236. };
  1237. #define AGG_TX_STATUS_MSK 0x00000fff /* bits 0:11 */
  1238. #define AGG_TX_TRY_MSK 0x0000f000 /* bits 12:15 */
  1239. #define AGG_TX_TRY_POS 12
  1240. #define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
  1241. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
  1242. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
  1243. /* # tx attempts for first frame in aggregation */
  1244. #define AGG_TX_STATE_TRY_CNT_POS 12
  1245. #define AGG_TX_STATE_TRY_CNT_MSK 0xf000
  1246. /* Command ID and sequence number of Tx command for this frame */
  1247. #define AGG_TX_STATE_SEQ_NUM_POS 16
  1248. #define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
  1249. /*
  1250. * REPLY_TX = 0x1c (response)
  1251. *
  1252. * This response may be in one of two slightly different formats, indicated
  1253. * by the frame_count field:
  1254. *
  1255. * 1) No aggregation (frame_count == 1). This reports Tx results for
  1256. * a single frame. Multiple attempts, at various bit rates, may have
  1257. * been made for this frame.
  1258. *
  1259. * 2) Aggregation (frame_count > 1). This reports Tx results for
  1260. * 2 or more frames that used block-acknowledge. All frames were
  1261. * transmitted at same rate. Rate scaling may have been used if first
  1262. * frame in this new agg block failed in previous agg block(s).
  1263. *
  1264. * Note that, for aggregation, ACK (block-ack) status is not delivered here;
  1265. * block-ack has not been received by the time the agn device records
  1266. * this status.
  1267. * This status relates to reasons the tx might have been blocked or aborted
  1268. * within the sending station (this agn device), rather than whether it was
  1269. * received successfully by the destination station.
  1270. */
  1271. struct agg_tx_status {
  1272. __le16 status;
  1273. __le16 sequence;
  1274. } __packed;
  1275. /*
  1276. * definitions for initial rate index field
  1277. * bits [3:0] initial rate index
  1278. * bits [6:4] rate table color, used for the initial rate
  1279. * bit-7 invalid rate indication
  1280. * i.e. rate was not chosen from rate table
  1281. * or rate table color was changed during frame retries
  1282. * refer tlc rate info
  1283. */
  1284. #define IWL50_TX_RES_INIT_RATE_INDEX_POS 0
  1285. #define IWL50_TX_RES_INIT_RATE_INDEX_MSK 0x0f
  1286. #define IWL50_TX_RES_RATE_TABLE_COLOR_POS 4
  1287. #define IWL50_TX_RES_RATE_TABLE_COLOR_MSK 0x70
  1288. #define IWL50_TX_RES_INV_RATE_INDEX_MSK 0x80
  1289. /* refer to ra_tid */
  1290. #define IWLAGN_TX_RES_TID_POS 0
  1291. #define IWLAGN_TX_RES_TID_MSK 0x0f
  1292. #define IWLAGN_TX_RES_RA_POS 4
  1293. #define IWLAGN_TX_RES_RA_MSK 0xf0
  1294. struct iwlagn_tx_resp {
  1295. u8 frame_count; /* 1 no aggregation, >1 aggregation */
  1296. u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */
  1297. u8 failure_rts; /* # failures due to unsuccessful RTS */
  1298. u8 failure_frame; /* # failures due to no ACK (unused for agg) */
  1299. /* For non-agg: Rate at which frame was successful.
  1300. * For agg: Rate at which all frames were transmitted. */
  1301. __le32 rate_n_flags; /* RATE_MCS_* */
  1302. /* For non-agg: RTS + CTS + frame tx attempts time + ACK.
  1303. * For agg: RTS + CTS + aggregation tx time + block-ack time. */
  1304. __le16 wireless_media_time; /* uSecs */
  1305. u8 pa_status; /* RF power amplifier measurement (not used) */
  1306. u8 pa_integ_res_a[3];
  1307. u8 pa_integ_res_b[3];
  1308. u8 pa_integ_res_C[3];
  1309. __le32 tfd_info;
  1310. __le16 seq_ctl;
  1311. __le16 byte_cnt;
  1312. u8 tlc_info;
  1313. u8 ra_tid; /* tid (0:3), sta_id (4:7) */
  1314. __le16 frame_ctrl;
  1315. /*
  1316. * For non-agg: frame status TX_STATUS_*
  1317. * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status
  1318. * fields follow this one, up to frame_count.
  1319. * Bit fields:
  1320. * 11- 0: AGG_TX_STATE_* status code
  1321. * 15-12: Retry count for 1st frame in aggregation (retries
  1322. * occur if tx failed for this frame when it was a
  1323. * member of a previous aggregation block). If rate
  1324. * scaling is used, retry count indicates the rate
  1325. * table entry used for all frames in the new agg.
  1326. * 31-16: Sequence # for this frame's Tx cmd (not SSN!)
  1327. */
  1328. struct agg_tx_status status; /* TX status (in aggregation -
  1329. * status of 1st frame) */
  1330. } __packed;
  1331. /*
  1332. * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
  1333. *
  1334. * Reports Block-Acknowledge from recipient station
  1335. */
  1336. struct iwl_compressed_ba_resp {
  1337. __le32 sta_addr_lo32;
  1338. __le16 sta_addr_hi16;
  1339. __le16 reserved;
  1340. /* Index of recipient (BA-sending) station in uCode's station table */
  1341. u8 sta_id;
  1342. u8 tid;
  1343. __le16 seq_ctl;
  1344. __le64 bitmap;
  1345. __le16 scd_flow;
  1346. __le16 scd_ssn;
  1347. u8 txed; /* number of frames sent */
  1348. u8 txed_2_done; /* number of frames acked */
  1349. __le16 reserved1;
  1350. } __packed;
  1351. /*
  1352. * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
  1353. *
  1354. */
  1355. /*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
  1356. #define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0)
  1357. /* # of EDCA prioritized tx fifos */
  1358. #define LINK_QUAL_AC_NUM AC_NUM
  1359. /* # entries in rate scale table to support Tx retries */
  1360. #define LINK_QUAL_MAX_RETRY_NUM 16
  1361. /* Tx antenna selection values */
  1362. #define LINK_QUAL_ANT_A_MSK (1 << 0)
  1363. #define LINK_QUAL_ANT_B_MSK (1 << 1)
  1364. #define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
  1365. /**
  1366. * struct iwl_link_qual_general_params
  1367. *
  1368. * Used in REPLY_TX_LINK_QUALITY_CMD
  1369. */
  1370. struct iwl_link_qual_general_params {
  1371. u8 flags;
  1372. /* No entries at or above this (driver chosen) index contain MIMO */
  1373. u8 mimo_delimiter;
  1374. /* Best single antenna to use for single stream (legacy, SISO). */
  1375. u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */
  1376. /* Best antennas to use for MIMO (unused for 4965, assumes both). */
  1377. u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */
  1378. /*
  1379. * If driver needs to use different initial rates for different
  1380. * EDCA QOS access categories (as implemented by tx fifos 0-3),
  1381. * this table will set that up, by indicating the indexes in the
  1382. * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
  1383. * Otherwise, driver should set all entries to 0.
  1384. *
  1385. * Entry usage:
  1386. * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
  1387. * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
  1388. */
  1389. u8 start_rate_index[LINK_QUAL_AC_NUM];
  1390. } __packed;
  1391. #define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */
  1392. #define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000)
  1393. #define LINK_QUAL_AGG_TIME_LIMIT_MIN (100)
  1394. #define LINK_QUAL_AGG_DISABLE_START_DEF (3)
  1395. #define LINK_QUAL_AGG_DISABLE_START_MAX (255)
  1396. #define LINK_QUAL_AGG_DISABLE_START_MIN (0)
  1397. #define LINK_QUAL_AGG_FRAME_LIMIT_DEF (63)
  1398. #define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63)
  1399. #define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0)
  1400. /**
  1401. * struct iwl_link_qual_agg_params
  1402. *
  1403. * Used in REPLY_TX_LINK_QUALITY_CMD
  1404. */
  1405. struct iwl_link_qual_agg_params {
  1406. /*
  1407. *Maximum number of uSec in aggregation.
  1408. * default set to 4000 (4 milliseconds) if not configured in .cfg
  1409. */
  1410. __le16 agg_time_limit;
  1411. /*
  1412. * Number of Tx retries allowed for a frame, before that frame will
  1413. * no longer be considered for the start of an aggregation sequence
  1414. * (scheduler will then try to tx it as single frame).
  1415. * Driver should set this to 3.
  1416. */
  1417. u8 agg_dis_start_th;
  1418. /*
  1419. * Maximum number of frames in aggregation.
  1420. * 0 = no limit (default). 1 = no aggregation.
  1421. * Other values = max # frames in aggregation.
  1422. */
  1423. u8 agg_frame_cnt_limit;
  1424. __le32 reserved;
  1425. } __packed;
  1426. /*
  1427. * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
  1428. *
  1429. * For agn devices
  1430. *
  1431. * Each station in the agn device's internal station table has its own table
  1432. * of 16
  1433. * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
  1434. * an ACK is not received. This command replaces the entire table for
  1435. * one station.
  1436. *
  1437. * NOTE: Station must already be in agn device's station table.
  1438. * Use REPLY_ADD_STA.
  1439. *
  1440. * The rate scaling procedures described below work well. Of course, other
  1441. * procedures are possible, and may work better for particular environments.
  1442. *
  1443. *
  1444. * FILLING THE RATE TABLE
  1445. *
  1446. * Given a particular initial rate and mode, as determined by the rate
  1447. * scaling algorithm described below, the Linux driver uses the following
  1448. * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
  1449. * Link Quality command:
  1450. *
  1451. *
  1452. * 1) If using High-throughput (HT) (SISO or MIMO) initial rate:
  1453. * a) Use this same initial rate for first 3 entries.
  1454. * b) Find next lower available rate using same mode (SISO or MIMO),
  1455. * use for next 3 entries. If no lower rate available, switch to
  1456. * legacy mode (no HT40 channel, no MIMO, no short guard interval).
  1457. * c) If using MIMO, set command's mimo_delimiter to number of entries
  1458. * using MIMO (3 or 6).
  1459. * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
  1460. * no MIMO, no short guard interval), at the next lower bit rate
  1461. * (e.g. if second HT bit rate was 54, try 48 legacy), and follow
  1462. * legacy procedure for remaining table entries.
  1463. *
  1464. * 2) If using legacy initial rate:
  1465. * a) Use the initial rate for only one entry.
  1466. * b) For each following entry, reduce the rate to next lower available
  1467. * rate, until reaching the lowest available rate.
  1468. * c) When reducing rate, also switch antenna selection.
  1469. * d) Once lowest available rate is reached, repeat this rate until
  1470. * rate table is filled (16 entries), switching antenna each entry.
  1471. *
  1472. *
  1473. * ACCUMULATING HISTORY
  1474. *
  1475. * The rate scaling algorithm for agn devices, as implemented in Linux driver,
  1476. * uses two sets of frame Tx success history: One for the current/active
  1477. * modulation mode, and one for a speculative/search mode that is being
  1478. * attempted. If the speculative mode turns out to be more effective (i.e.
  1479. * actual transfer rate is better), then the driver continues to use the
  1480. * speculative mode as the new current active mode.
  1481. *
  1482. * Each history set contains, separately for each possible rate, data for a
  1483. * sliding window of the 62 most recent tx attempts at that rate. The data
  1484. * includes a shifting bitmap of success(1)/failure(0), and sums of successful
  1485. * and attempted frames, from which the driver can additionally calculate a
  1486. * success ratio (success / attempted) and number of failures
  1487. * (attempted - success), and control the size of the window (attempted).
  1488. * The driver uses the bit map to remove successes from the success sum, as
  1489. * the oldest tx attempts fall out of the window.
  1490. *
  1491. * When the agn device makes multiple tx attempts for a given frame, each
  1492. * attempt might be at a different rate, and have different modulation
  1493. * characteristics (e.g. antenna, fat channel, short guard interval), as set
  1494. * up in the rate scaling table in the Link Quality command. The driver must
  1495. * determine which rate table entry was used for each tx attempt, to determine
  1496. * which rate-specific history to update, and record only those attempts that
  1497. * match the modulation characteristics of the history set.
  1498. *
  1499. * When using block-ack (aggregation), all frames are transmitted at the same
  1500. * rate, since there is no per-attempt acknowledgment from the destination
  1501. * station. The Tx response struct iwl_tx_resp indicates the Tx rate in
  1502. * rate_n_flags field. After receiving a block-ack, the driver can update
  1503. * history for the entire block all at once.
  1504. *
  1505. *
  1506. * FINDING BEST STARTING RATE:
  1507. *
  1508. * When working with a selected initial modulation mode (see below), the
  1509. * driver attempts to find a best initial rate. The initial rate is the
  1510. * first entry in the Link Quality command's rate table.
  1511. *
  1512. * 1) Calculate actual throughput (success ratio * expected throughput, see
  1513. * table below) for current initial rate. Do this only if enough frames
  1514. * have been attempted to make the value meaningful: at least 6 failed
  1515. * tx attempts, or at least 8 successes. If not enough, don't try rate
  1516. * scaling yet.
  1517. *
  1518. * 2) Find available rates adjacent to current initial rate. Available means:
  1519. * a) supported by hardware &&
  1520. * b) supported by association &&
  1521. * c) within any constraints selected by user
  1522. *
  1523. * 3) Gather measured throughputs for adjacent rates. These might not have
  1524. * enough history to calculate a throughput. That's okay, we might try
  1525. * using one of them anyway!
  1526. *
  1527. * 4) Try decreasing rate if, for current rate:
  1528. * a) success ratio is < 15% ||
  1529. * b) lower adjacent rate has better measured throughput ||
  1530. * c) higher adjacent rate has worse throughput, and lower is unmeasured
  1531. *
  1532. * As a sanity check, if decrease was determined above, leave rate
  1533. * unchanged if:
  1534. * a) lower rate unavailable
  1535. * b) success ratio at current rate > 85% (very good)
  1536. * c) current measured throughput is better than expected throughput
  1537. * of lower rate (under perfect 100% tx conditions, see table below)
  1538. *
  1539. * 5) Try increasing rate if, for current rate:
  1540. * a) success ratio is < 15% ||
  1541. * b) both adjacent rates' throughputs are unmeasured (try it!) ||
  1542. * b) higher adjacent rate has better measured throughput ||
  1543. * c) lower adjacent rate has worse throughput, and higher is unmeasured
  1544. *
  1545. * As a sanity check, if increase was determined above, leave rate
  1546. * unchanged if:
  1547. * a) success ratio at current rate < 70%. This is not particularly
  1548. * good performance; higher rate is sure to have poorer success.
  1549. *
  1550. * 6) Re-evaluate the rate after each tx frame. If working with block-
  1551. * acknowledge, history and statistics may be calculated for the entire
  1552. * block (including prior history that fits within the history windows),
  1553. * before re-evaluation.
  1554. *
  1555. * FINDING BEST STARTING MODULATION MODE:
  1556. *
  1557. * After working with a modulation mode for a "while" (and doing rate scaling),
  1558. * the driver searches for a new initial mode in an attempt to improve
  1559. * throughput. The "while" is measured by numbers of attempted frames:
  1560. *
  1561. * For legacy mode, search for new mode after:
  1562. * 480 successful frames, or 160 failed frames
  1563. * For high-throughput modes (SISO or MIMO), search for new mode after:
  1564. * 4500 successful frames, or 400 failed frames
  1565. *
  1566. * Mode switch possibilities are (3 for each mode):
  1567. *
  1568. * For legacy:
  1569. * Change antenna, try SISO (if HT association), try MIMO (if HT association)
  1570. * For SISO:
  1571. * Change antenna, try MIMO, try shortened guard interval (SGI)
  1572. * For MIMO:
  1573. * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
  1574. *
  1575. * When trying a new mode, use the same bit rate as the old/current mode when
  1576. * trying antenna switches and shortened guard interval. When switching to
  1577. * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
  1578. * for which the expected throughput (under perfect conditions) is about the
  1579. * same or slightly better than the actual measured throughput delivered by
  1580. * the old/current mode.
  1581. *
  1582. * Actual throughput can be estimated by multiplying the expected throughput
  1583. * by the success ratio (successful / attempted tx frames). Frame size is
  1584. * not considered in this calculation; it assumes that frame size will average
  1585. * out to be fairly consistent over several samples. The following are
  1586. * metric values for expected throughput assuming 100% success ratio.
  1587. * Only G band has support for CCK rates:
  1588. *
  1589. * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60
  1590. *
  1591. * G: 7 13 35 58 40 57 72 98 121 154 177 186 186
  1592. * A: 0 0 0 0 40 57 72 98 121 154 177 186 186
  1593. * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202
  1594. * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211
  1595. * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251
  1596. * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257
  1597. * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257
  1598. * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264
  1599. * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289
  1600. * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293
  1601. *
  1602. * After the new mode has been tried for a short while (minimum of 6 failed
  1603. * frames or 8 successful frames), compare success ratio and actual throughput
  1604. * estimate of the new mode with the old. If either is better with the new
  1605. * mode, continue to use the new mode.
  1606. *
  1607. * Continue comparing modes until all 3 possibilities have been tried.
  1608. * If moving from legacy to HT, try all 3 possibilities from the new HT
  1609. * mode. After trying all 3, a best mode is found. Continue to use this mode
  1610. * for the longer "while" described above (e.g. 480 successful frames for
  1611. * legacy), and then repeat the search process.
  1612. *
  1613. */
  1614. struct iwl_link_quality_cmd {
  1615. /* Index of destination/recipient station in uCode's station table */
  1616. u8 sta_id;
  1617. u8 reserved1;
  1618. __le16 control; /* not used */
  1619. struct iwl_link_qual_general_params general_params;
  1620. struct iwl_link_qual_agg_params agg_params;
  1621. /*
  1622. * Rate info; when using rate-scaling, Tx command's initial_rate_index
  1623. * specifies 1st Tx rate attempted, via index into this table.
  1624. * agn devices works its way through table when retrying Tx.
  1625. */
  1626. struct {
  1627. __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */
  1628. } rs_table[LINK_QUAL_MAX_RETRY_NUM];
  1629. __le32 reserved2;
  1630. } __packed;
  1631. /*
  1632. * BT configuration enable flags:
  1633. * bit 0 - 1: BT channel announcement enabled
  1634. * 0: disable
  1635. * bit 1 - 1: priority of BT device enabled
  1636. * 0: disable
  1637. * bit 2 - 1: BT 2 wire support enabled
  1638. * 0: disable
  1639. */
  1640. #define BT_COEX_DISABLE (0x0)
  1641. #define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
  1642. #define BT_ENABLE_PRIORITY BIT(1)
  1643. #define BT_ENABLE_2_WIRE BIT(2)
  1644. #define BT_COEX_DISABLE (0x0)
  1645. #define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
  1646. #define BT_LEAD_TIME_MIN (0x0)
  1647. #define BT_LEAD_TIME_DEF (0x1E)
  1648. #define BT_LEAD_TIME_MAX (0xFF)
  1649. #define BT_MAX_KILL_MIN (0x1)
  1650. #define BT_MAX_KILL_DEF (0x5)
  1651. #define BT_MAX_KILL_MAX (0xFF)
  1652. #define BT_DURATION_LIMIT_DEF 625
  1653. #define BT_DURATION_LIMIT_MAX 1250
  1654. #define BT_DURATION_LIMIT_MIN 625
  1655. #define BT_ON_THRESHOLD_DEF 4
  1656. #define BT_ON_THRESHOLD_MAX 1000
  1657. #define BT_ON_THRESHOLD_MIN 1
  1658. #define BT_FRAG_THRESHOLD_DEF 0
  1659. #define BT_FRAG_THRESHOLD_MAX 0
  1660. #define BT_FRAG_THRESHOLD_MIN 0
  1661. #define BT_AGG_THRESHOLD_DEF 1200
  1662. #define BT_AGG_THRESHOLD_MAX 8000
  1663. #define BT_AGG_THRESHOLD_MIN 400
  1664. /*
  1665. * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
  1666. *
  1667. * agn devices support hardware handshake with Bluetooth device on
  1668. * same platform. Bluetooth device alerts wireless device when it will Tx;
  1669. * wireless device can delay or kill its own Tx to accommodate.
  1670. */
  1671. struct iwl_bt_cmd {
  1672. u8 flags;
  1673. u8 lead_time;
  1674. u8 max_kill;
  1675. u8 reserved;
  1676. __le32 kill_ack_mask;
  1677. __le32 kill_cts_mask;
  1678. } __packed;
  1679. #define IWLAGN_BT_FLAG_CHANNEL_INHIBITION BIT(0)
  1680. #define IWLAGN_BT_FLAG_COEX_MODE_MASK (BIT(3)|BIT(4)|BIT(5))
  1681. #define IWLAGN_BT_FLAG_COEX_MODE_SHIFT 3
  1682. #define IWLAGN_BT_FLAG_COEX_MODE_DISABLED 0
  1683. #define IWLAGN_BT_FLAG_COEX_MODE_LEGACY_2W 1
  1684. #define IWLAGN_BT_FLAG_COEX_MODE_3W 2
  1685. #define IWLAGN_BT_FLAG_COEX_MODE_4W 3
  1686. #define IWLAGN_BT_FLAG_UCODE_DEFAULT BIT(6)
  1687. /* Disable Sync PSPoll on SCO/eSCO */
  1688. #define IWLAGN_BT_FLAG_SYNC_2_BT_DISABLE BIT(7)
  1689. #define IWLAGN_BT_PSP_MIN_RSSI_THRESHOLD -75 /* dBm */
  1690. #define IWLAGN_BT_PSP_MAX_RSSI_THRESHOLD -65 /* dBm */
  1691. #define IWLAGN_BT_PRIO_BOOST_MAX 0xFF
  1692. #define IWLAGN_BT_PRIO_BOOST_MIN 0x00
  1693. #define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0
  1694. #define IWLAGN_BT_PRIO_BOOST_DEFAULT32 0xF0F0F0F0
  1695. #define IWLAGN_BT_MAX_KILL_DEFAULT 5
  1696. #define IWLAGN_BT3_T7_DEFAULT 1
  1697. enum iwl_bt_kill_idx {
  1698. IWL_BT_KILL_DEFAULT = 0,
  1699. IWL_BT_KILL_OVERRIDE = 1,
  1700. IWL_BT_KILL_REDUCE = 2,
  1701. };
  1702. #define IWLAGN_BT_KILL_ACK_MASK_DEFAULT cpu_to_le32(0xffff0000)
  1703. #define IWLAGN_BT_KILL_CTS_MASK_DEFAULT cpu_to_le32(0xffff0000)
  1704. #define IWLAGN_BT_KILL_ACK_CTS_MASK_SCO cpu_to_le32(0xffffffff)
  1705. #define IWLAGN_BT_KILL_ACK_CTS_MASK_REDUCE cpu_to_le32(0)
  1706. #define IWLAGN_BT3_PRIO_SAMPLE_DEFAULT 2
  1707. #define IWLAGN_BT3_T2_DEFAULT 0xc
  1708. #define IWLAGN_BT_VALID_ENABLE_FLAGS cpu_to_le16(BIT(0))
  1709. #define IWLAGN_BT_VALID_BOOST cpu_to_le16(BIT(1))
  1710. #define IWLAGN_BT_VALID_MAX_KILL cpu_to_le16(BIT(2))
  1711. #define IWLAGN_BT_VALID_3W_TIMERS cpu_to_le16(BIT(3))
  1712. #define IWLAGN_BT_VALID_KILL_ACK_MASK cpu_to_le16(BIT(4))
  1713. #define IWLAGN_BT_VALID_KILL_CTS_MASK cpu_to_le16(BIT(5))
  1714. #define IWLAGN_BT_VALID_REDUCED_TX_PWR cpu_to_le16(BIT(6))
  1715. #define IWLAGN_BT_VALID_3W_LUT cpu_to_le16(BIT(7))
  1716. #define IWLAGN_BT_ALL_VALID_MSK (IWLAGN_BT_VALID_ENABLE_FLAGS | \
  1717. IWLAGN_BT_VALID_BOOST | \
  1718. IWLAGN_BT_VALID_MAX_KILL | \
  1719. IWLAGN_BT_VALID_3W_TIMERS | \
  1720. IWLAGN_BT_VALID_KILL_ACK_MASK | \
  1721. IWLAGN_BT_VALID_KILL_CTS_MASK | \
  1722. IWLAGN_BT_VALID_REDUCED_TX_PWR | \
  1723. IWLAGN_BT_VALID_3W_LUT)
  1724. #define IWLAGN_BT_REDUCED_TX_PWR BIT(0)
  1725. #define IWLAGN_BT_DECISION_LUT_SIZE 12
  1726. struct iwl_basic_bt_cmd {
  1727. u8 flags;
  1728. u8 ledtime; /* unused */
  1729. u8 max_kill;
  1730. u8 bt3_timer_t7_value;
  1731. __le32 kill_ack_mask;
  1732. __le32 kill_cts_mask;
  1733. u8 bt3_prio_sample_time;
  1734. u8 bt3_timer_t2_value;
  1735. __le16 bt4_reaction_time; /* unused */
  1736. __le32 bt3_lookup_table[IWLAGN_BT_DECISION_LUT_SIZE];
  1737. /*
  1738. * bit 0: use reduced tx power for control frame
  1739. * bit 1 - 7: reserved
  1740. */
  1741. u8 reduce_txpower;
  1742. u8 reserved;
  1743. __le16 valid;
  1744. };
  1745. struct iwl_bt_cmd_v1 {
  1746. struct iwl_basic_bt_cmd basic;
  1747. u8 prio_boost;
  1748. /*
  1749. * set IWLAGN_BT_VALID_BOOST to "1" in "valid" bitmask
  1750. * if configure the following patterns
  1751. */
  1752. u8 tx_prio_boost; /* SW boost of WiFi tx priority */
  1753. __le16 rx_prio_boost; /* SW boost of WiFi rx priority */
  1754. };
  1755. struct iwl_bt_cmd_v2 {
  1756. struct iwl_basic_bt_cmd basic;
  1757. __le32 prio_boost;
  1758. /*
  1759. * set IWLAGN_BT_VALID_BOOST to "1" in "valid" bitmask
  1760. * if configure the following patterns
  1761. */
  1762. u8 reserved;
  1763. u8 tx_prio_boost; /* SW boost of WiFi tx priority */
  1764. __le16 rx_prio_boost; /* SW boost of WiFi rx priority */
  1765. };
  1766. #define IWLAGN_BT_SCO_ACTIVE cpu_to_le32(BIT(0))
  1767. struct iwlagn_bt_sco_cmd {
  1768. __le32 flags;
  1769. };
  1770. /******************************************************************************
  1771. * (6)
  1772. * Spectrum Management (802.11h) Commands, Responses, Notifications:
  1773. *
  1774. *****************************************************************************/
  1775. /*
  1776. * Spectrum Management
  1777. */
  1778. #define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
  1779. RXON_FILTER_CTL2HOST_MSK | \
  1780. RXON_FILTER_ACCEPT_GRP_MSK | \
  1781. RXON_FILTER_DIS_DECRYPT_MSK | \
  1782. RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
  1783. RXON_FILTER_ASSOC_MSK | \
  1784. RXON_FILTER_BCON_AWARE_MSK)
  1785. struct iwl_measure_channel {
  1786. __le32 duration; /* measurement duration in extended beacon
  1787. * format */
  1788. u8 channel; /* channel to measure */
  1789. u8 type; /* see enum iwl_measure_type */
  1790. __le16 reserved;
  1791. } __packed;
  1792. /*
  1793. * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
  1794. */
  1795. struct iwl_spectrum_cmd {
  1796. __le16 len; /* number of bytes starting from token */
  1797. u8 token; /* token id */
  1798. u8 id; /* measurement id -- 0 or 1 */
  1799. u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
  1800. u8 periodic; /* 1 = periodic */
  1801. __le16 path_loss_timeout;
  1802. __le32 start_time; /* start time in extended beacon format */
  1803. __le32 reserved2;
  1804. __le32 flags; /* rxon flags */
  1805. __le32 filter_flags; /* rxon filter flags */
  1806. __le16 channel_count; /* minimum 1, maximum 10 */
  1807. __le16 reserved3;
  1808. struct iwl_measure_channel channels[10];
  1809. } __packed;
  1810. /*
  1811. * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
  1812. */
  1813. struct iwl_spectrum_resp {
  1814. u8 token;
  1815. u8 id; /* id of the prior command replaced, or 0xff */
  1816. __le16 status; /* 0 - command will be handled
  1817. * 1 - cannot handle (conflicts with another
  1818. * measurement) */
  1819. } __packed;
  1820. enum iwl_measurement_state {
  1821. IWL_MEASUREMENT_START = 0,
  1822. IWL_MEASUREMENT_STOP = 1,
  1823. };
  1824. enum iwl_measurement_status {
  1825. IWL_MEASUREMENT_OK = 0,
  1826. IWL_MEASUREMENT_CONCURRENT = 1,
  1827. IWL_MEASUREMENT_CSA_CONFLICT = 2,
  1828. IWL_MEASUREMENT_TGH_CONFLICT = 3,
  1829. /* 4-5 reserved */
  1830. IWL_MEASUREMENT_STOPPED = 6,
  1831. IWL_MEASUREMENT_TIMEOUT = 7,
  1832. IWL_MEASUREMENT_PERIODIC_FAILED = 8,
  1833. };
  1834. #define NUM_ELEMENTS_IN_HISTOGRAM 8
  1835. struct iwl_measurement_histogram {
  1836. __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
  1837. __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
  1838. } __packed;
  1839. /* clear channel availability counters */
  1840. struct iwl_measurement_cca_counters {
  1841. __le32 ofdm;
  1842. __le32 cck;
  1843. } __packed;
  1844. enum iwl_measure_type {
  1845. IWL_MEASURE_BASIC = (1 << 0),
  1846. IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
  1847. IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
  1848. IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
  1849. IWL_MEASURE_FRAME = (1 << 4),
  1850. /* bits 5:6 are reserved */
  1851. IWL_MEASURE_IDLE = (1 << 7),
  1852. };
  1853. /*
  1854. * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
  1855. */
  1856. struct iwl_spectrum_notification {
  1857. u8 id; /* measurement id -- 0 or 1 */
  1858. u8 token;
  1859. u8 channel_index; /* index in measurement channel list */
  1860. u8 state; /* 0 - start, 1 - stop */
  1861. __le32 start_time; /* lower 32-bits of TSF */
  1862. u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
  1863. u8 channel;
  1864. u8 type; /* see enum iwl_measurement_type */
  1865. u8 reserved1;
  1866. /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
  1867. * valid if applicable for measurement type requested. */
  1868. __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
  1869. __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
  1870. __le32 cca_time; /* channel load time in usecs */
  1871. u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
  1872. * unidentified */
  1873. u8 reserved2[3];
  1874. struct iwl_measurement_histogram histogram;
  1875. __le32 stop_time; /* lower 32-bits of TSF */
  1876. __le32 status; /* see iwl_measurement_status */
  1877. } __packed;
  1878. /******************************************************************************
  1879. * (7)
  1880. * Power Management Commands, Responses, Notifications:
  1881. *
  1882. *****************************************************************************/
  1883. /**
  1884. * struct iwl_powertable_cmd - Power Table Command
  1885. * @flags: See below:
  1886. *
  1887. * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
  1888. *
  1889. * PM allow:
  1890. * bit 0 - '0' Driver not allow power management
  1891. * '1' Driver allow PM (use rest of parameters)
  1892. *
  1893. * uCode send sleep notifications:
  1894. * bit 1 - '0' Don't send sleep notification
  1895. * '1' send sleep notification (SEND_PM_NOTIFICATION)
  1896. *
  1897. * Sleep over DTIM
  1898. * bit 2 - '0' PM have to walk up every DTIM
  1899. * '1' PM could sleep over DTIM till listen Interval.
  1900. *
  1901. * PCI power managed
  1902. * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
  1903. * '1' !(PCI_CFG_LINK_CTRL & 0x1)
  1904. *
  1905. * Fast PD
  1906. * bit 4 - '1' Put radio to sleep when receiving frame for others
  1907. *
  1908. * Force sleep Modes
  1909. * bit 31/30- '00' use both mac/xtal sleeps
  1910. * '01' force Mac sleep
  1911. * '10' force xtal sleep
  1912. * '11' Illegal set
  1913. *
  1914. * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
  1915. * ucode assume sleep over DTIM is allowed and we don't need to wake up
  1916. * for every DTIM.
  1917. */
  1918. #define IWL_POWER_VEC_SIZE 5
  1919. #define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0))
  1920. #define IWL_POWER_POWER_SAVE_ENA_MSK cpu_to_le16(BIT(0))
  1921. #define IWL_POWER_POWER_MANAGEMENT_ENA_MSK cpu_to_le16(BIT(1))
  1922. #define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(BIT(2))
  1923. #define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3))
  1924. #define IWL_POWER_FAST_PD cpu_to_le16(BIT(4))
  1925. #define IWL_POWER_BEACON_FILTERING cpu_to_le16(BIT(5))
  1926. #define IWL_POWER_SHADOW_REG_ENA cpu_to_le16(BIT(6))
  1927. #define IWL_POWER_CT_KILL_SET cpu_to_le16(BIT(7))
  1928. #define IWL_POWER_BT_SCO_ENA cpu_to_le16(BIT(8))
  1929. #define IWL_POWER_ADVANCE_PM_ENA_MSK cpu_to_le16(BIT(9))
  1930. struct iwl_powertable_cmd {
  1931. __le16 flags;
  1932. u8 keep_alive_seconds;
  1933. u8 debug_flags;
  1934. __le32 rx_data_timeout;
  1935. __le32 tx_data_timeout;
  1936. __le32 sleep_interval[IWL_POWER_VEC_SIZE];
  1937. __le32 keep_alive_beacons;
  1938. } __packed;
  1939. /*
  1940. * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
  1941. * all devices identical.
  1942. */
  1943. struct iwl_sleep_notification {
  1944. u8 pm_sleep_mode;
  1945. u8 pm_wakeup_src;
  1946. __le16 reserved;
  1947. __le32 sleep_time;
  1948. __le32 tsf_low;
  1949. __le32 bcon_timer;
  1950. } __packed;
  1951. /* Sleep states. all devices identical. */
  1952. enum {
  1953. IWL_PM_NO_SLEEP = 0,
  1954. IWL_PM_SLP_MAC = 1,
  1955. IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
  1956. IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
  1957. IWL_PM_SLP_PHY = 4,
  1958. IWL_PM_SLP_REPENT = 5,
  1959. IWL_PM_WAKEUP_BY_TIMER = 6,
  1960. IWL_PM_WAKEUP_BY_DRIVER = 7,
  1961. IWL_PM_WAKEUP_BY_RFKILL = 8,
  1962. /* 3 reserved */
  1963. IWL_PM_NUM_OF_MODES = 12,
  1964. };
  1965. /*
  1966. * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
  1967. */
  1968. #define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
  1969. #define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
  1970. #define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
  1971. struct iwl_card_state_cmd {
  1972. __le32 status; /* CARD_STATE_CMD_* request new power state */
  1973. } __packed;
  1974. /*
  1975. * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
  1976. */
  1977. struct iwl_card_state_notif {
  1978. __le32 flags;
  1979. } __packed;
  1980. #define HW_CARD_DISABLED 0x01
  1981. #define SW_CARD_DISABLED 0x02
  1982. #define CT_CARD_DISABLED 0x04
  1983. #define RXON_CARD_DISABLED 0x10
  1984. struct iwl_ct_kill_config {
  1985. __le32 reserved;
  1986. __le32 critical_temperature_M;
  1987. __le32 critical_temperature_R;
  1988. } __packed;
  1989. /* 1000, and 6x00 */
  1990. struct iwl_ct_kill_throttling_config {
  1991. __le32 critical_temperature_exit;
  1992. __le32 reserved;
  1993. __le32 critical_temperature_enter;
  1994. } __packed;
  1995. /******************************************************************************
  1996. * (8)
  1997. * Scan Commands, Responses, Notifications:
  1998. *
  1999. *****************************************************************************/
  2000. #define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
  2001. #define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1)
  2002. /**
  2003. * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
  2004. *
  2005. * One for each channel in the scan list.
  2006. * Each channel can independently select:
  2007. * 1) SSID for directed active scans
  2008. * 2) Txpower setting (for rate specified within Tx command)
  2009. * 3) How long to stay on-channel (behavior may be modified by quiet_time,
  2010. * quiet_plcp_th, good_CRC_th)
  2011. *
  2012. * To avoid uCode errors, make sure the following are true (see comments
  2013. * under struct iwl_scan_cmd about max_out_time and quiet_time):
  2014. * 1) If using passive_dwell (i.e. passive_dwell != 0):
  2015. * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
  2016. * 2) quiet_time <= active_dwell
  2017. * 3) If restricting off-channel time (i.e. max_out_time !=0):
  2018. * passive_dwell < max_out_time
  2019. * active_dwell < max_out_time
  2020. */
  2021. struct iwl_scan_channel {
  2022. /*
  2023. * type is defined as:
  2024. * 0:0 1 = active, 0 = passive
  2025. * 1:20 SSID direct bit map; if a bit is set, then corresponding
  2026. * SSID IE is transmitted in probe request.
  2027. * 21:31 reserved
  2028. */
  2029. __le32 type;
  2030. __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */
  2031. u8 tx_gain; /* gain for analog radio */
  2032. u8 dsp_atten; /* gain for DSP */
  2033. __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
  2034. __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
  2035. } __packed;
  2036. /* set number of direct probes __le32 type */
  2037. #define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
  2038. /**
  2039. * struct iwl_ssid_ie - directed scan network information element
  2040. *
  2041. * Up to 20 of these may appear in REPLY_SCAN_CMD,
  2042. * selected by "type" bit field in struct iwl_scan_channel;
  2043. * each channel may select different ssids from among the 20 entries.
  2044. * SSID IEs get transmitted in reverse order of entry.
  2045. */
  2046. struct iwl_ssid_ie {
  2047. u8 id;
  2048. u8 len;
  2049. u8 ssid[32];
  2050. } __packed;
  2051. #define PROBE_OPTION_MAX 20
  2052. #define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
  2053. #define IWL_GOOD_CRC_TH_DISABLED 0
  2054. #define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
  2055. #define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
  2056. #define IWL_MAX_CMD_SIZE 4096
  2057. /*
  2058. * REPLY_SCAN_CMD = 0x80 (command)
  2059. *
  2060. * The hardware scan command is very powerful; the driver can set it up to
  2061. * maintain (relatively) normal network traffic while doing a scan in the
  2062. * background. The max_out_time and suspend_time control the ratio of how
  2063. * long the device stays on an associated network channel ("service channel")
  2064. * vs. how long it's away from the service channel, i.e. tuned to other channels
  2065. * for scanning.
  2066. *
  2067. * max_out_time is the max time off-channel (in usec), and suspend_time
  2068. * is how long (in "extended beacon" format) that the scan is "suspended"
  2069. * after returning to the service channel. That is, suspend_time is the
  2070. * time that we stay on the service channel, doing normal work, between
  2071. * scan segments. The driver may set these parameters differently to support
  2072. * scanning when associated vs. not associated, and light vs. heavy traffic
  2073. * loads when associated.
  2074. *
  2075. * After receiving this command, the device's scan engine does the following;
  2076. *
  2077. * 1) Sends SCAN_START notification to driver
  2078. * 2) Checks to see if it has time to do scan for one channel
  2079. * 3) Sends NULL packet, with power-save (PS) bit set to 1,
  2080. * to tell AP that we're going off-channel
  2081. * 4) Tunes to first channel in scan list, does active or passive scan
  2082. * 5) Sends SCAN_RESULT notification to driver
  2083. * 6) Checks to see if it has time to do scan on *next* channel in list
  2084. * 7) Repeats 4-6 until it no longer has time to scan the next channel
  2085. * before max_out_time expires
  2086. * 8) Returns to service channel
  2087. * 9) Sends NULL packet with PS=0 to tell AP that we're back
  2088. * 10) Stays on service channel until suspend_time expires
  2089. * 11) Repeats entire process 2-10 until list is complete
  2090. * 12) Sends SCAN_COMPLETE notification
  2091. *
  2092. * For fast, efficient scans, the scan command also has support for staying on
  2093. * a channel for just a short time, if doing active scanning and getting no
  2094. * responses to the transmitted probe request. This time is controlled by
  2095. * quiet_time, and the number of received packets below which a channel is
  2096. * considered "quiet" is controlled by quiet_plcp_threshold.
  2097. *
  2098. * For active scanning on channels that have regulatory restrictions against
  2099. * blindly transmitting, the scan can listen before transmitting, to make sure
  2100. * that there is already legitimate activity on the channel. If enough
  2101. * packets are cleanly received on the channel (controlled by good_CRC_th,
  2102. * typical value 1), the scan engine starts transmitting probe requests.
  2103. *
  2104. * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
  2105. *
  2106. * To avoid uCode errors, see timing restrictions described under
  2107. * struct iwl_scan_channel.
  2108. */
  2109. enum iwl_scan_flags {
  2110. /* BIT(0) currently unused */
  2111. IWL_SCAN_FLAGS_ACTION_FRAME_TX = BIT(1),
  2112. /* bits 2-7 reserved */
  2113. };
  2114. struct iwl_scan_cmd {
  2115. __le16 len;
  2116. u8 scan_flags; /* scan flags: see enum iwl_scan_flags */
  2117. u8 channel_count; /* # channels in channel list */
  2118. __le16 quiet_time; /* dwell only this # millisecs on quiet channel
  2119. * (only for active scan) */
  2120. __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
  2121. __le16 good_CRC_th; /* passive -> active promotion threshold */
  2122. __le16 rx_chain; /* RXON_RX_CHAIN_* */
  2123. __le32 max_out_time; /* max usec to be away from associated (service)
  2124. * channel */
  2125. __le32 suspend_time; /* pause scan this long (in "extended beacon
  2126. * format") when returning to service chnl:
  2127. */
  2128. __le32 flags; /* RXON_FLG_* */
  2129. __le32 filter_flags; /* RXON_FILTER_* */
  2130. /* For active scans (set to all-0s for passive scans).
  2131. * Does not include payload. Must specify Tx rate; no rate scaling. */
  2132. struct iwl_tx_cmd tx_cmd;
  2133. /* For directed active scans (set to all-0s otherwise) */
  2134. struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
  2135. /*
  2136. * Probe request frame, followed by channel list.
  2137. *
  2138. * Size of probe request frame is specified by byte count in tx_cmd.
  2139. * Channel list follows immediately after probe request frame.
  2140. * Number of channels in list is specified by channel_count.
  2141. * Each channel in list is of type:
  2142. *
  2143. * struct iwl_scan_channel channels[0];
  2144. *
  2145. * NOTE: Only one band of channels can be scanned per pass. You
  2146. * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
  2147. * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
  2148. * before requesting another scan.
  2149. */
  2150. u8 data[0];
  2151. } __packed;
  2152. /* Can abort will notify by complete notification with abort status. */
  2153. #define CAN_ABORT_STATUS cpu_to_le32(0x1)
  2154. /* complete notification statuses */
  2155. #define ABORT_STATUS 0x2
  2156. /*
  2157. * REPLY_SCAN_CMD = 0x80 (response)
  2158. */
  2159. struct iwl_scanreq_notification {
  2160. __le32 status; /* 1: okay, 2: cannot fulfill request */
  2161. } __packed;
  2162. /*
  2163. * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
  2164. */
  2165. struct iwl_scanstart_notification {
  2166. __le32 tsf_low;
  2167. __le32 tsf_high;
  2168. __le32 beacon_timer;
  2169. u8 channel;
  2170. u8 band;
  2171. u8 reserved[2];
  2172. __le32 status;
  2173. } __packed;
  2174. #define SCAN_OWNER_STATUS 0x1
  2175. #define MEASURE_OWNER_STATUS 0x2
  2176. #define IWL_PROBE_STATUS_OK 0
  2177. #define IWL_PROBE_STATUS_TX_FAILED BIT(0)
  2178. /* error statuses combined with TX_FAILED */
  2179. #define IWL_PROBE_STATUS_FAIL_TTL BIT(1)
  2180. #define IWL_PROBE_STATUS_FAIL_BT BIT(2)
  2181. #define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
  2182. /*
  2183. * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
  2184. */
  2185. struct iwl_scanresults_notification {
  2186. u8 channel;
  2187. u8 band;
  2188. u8 probe_status;
  2189. u8 num_probe_not_sent; /* not enough time to send */
  2190. __le32 tsf_low;
  2191. __le32 tsf_high;
  2192. __le32 statistics[NUMBER_OF_STATISTICS];
  2193. } __packed;
  2194. /*
  2195. * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
  2196. */
  2197. struct iwl_scancomplete_notification {
  2198. u8 scanned_channels;
  2199. u8 status;
  2200. u8 bt_status; /* BT On/Off status */
  2201. u8 last_channel;
  2202. __le32 tsf_low;
  2203. __le32 tsf_high;
  2204. } __packed;
  2205. /******************************************************************************
  2206. * (9)
  2207. * IBSS/AP Commands and Notifications:
  2208. *
  2209. *****************************************************************************/
  2210. enum iwl_ibss_manager {
  2211. IWL_NOT_IBSS_MANAGER = 0,
  2212. IWL_IBSS_MANAGER = 1,
  2213. };
  2214. /*
  2215. * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
  2216. */
  2217. struct iwlagn_beacon_notif {
  2218. struct iwlagn_tx_resp beacon_notify_hdr;
  2219. __le32 low_tsf;
  2220. __le32 high_tsf;
  2221. __le32 ibss_mgr_status;
  2222. } __packed;
  2223. /*
  2224. * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
  2225. */
  2226. struct iwl_tx_beacon_cmd {
  2227. struct iwl_tx_cmd tx;
  2228. __le16 tim_idx;
  2229. u8 tim_size;
  2230. u8 reserved1;
  2231. struct ieee80211_hdr frame[0]; /* beacon frame */
  2232. } __packed;
  2233. /******************************************************************************
  2234. * (10)
  2235. * Statistics Commands and Notifications:
  2236. *
  2237. *****************************************************************************/
  2238. #define IWL_TEMP_CONVERT 260
  2239. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  2240. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  2241. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  2242. /* Used for passing to driver number of successes and failures per rate */
  2243. struct rate_histogram {
  2244. union {
  2245. __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  2246. __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  2247. __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  2248. } success;
  2249. union {
  2250. __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  2251. __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  2252. __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  2253. } failed;
  2254. } __packed;
  2255. /* statistics command response */
  2256. struct statistics_dbg {
  2257. __le32 burst_check;
  2258. __le32 burst_count;
  2259. __le32 wait_for_silence_timeout_cnt;
  2260. __le32 reserved[3];
  2261. } __packed;
  2262. struct statistics_rx_phy {
  2263. __le32 ina_cnt;
  2264. __le32 fina_cnt;
  2265. __le32 plcp_err;
  2266. __le32 crc32_err;
  2267. __le32 overrun_err;
  2268. __le32 early_overrun_err;
  2269. __le32 crc32_good;
  2270. __le32 false_alarm_cnt;
  2271. __le32 fina_sync_err_cnt;
  2272. __le32 sfd_timeout;
  2273. __le32 fina_timeout;
  2274. __le32 unresponded_rts;
  2275. __le32 rxe_frame_limit_overrun;
  2276. __le32 sent_ack_cnt;
  2277. __le32 sent_cts_cnt;
  2278. __le32 sent_ba_rsp_cnt;
  2279. __le32 dsp_self_kill;
  2280. __le32 mh_format_err;
  2281. __le32 re_acq_main_rssi_sum;
  2282. __le32 reserved3;
  2283. } __packed;
  2284. struct statistics_rx_ht_phy {
  2285. __le32 plcp_err;
  2286. __le32 overrun_err;
  2287. __le32 early_overrun_err;
  2288. __le32 crc32_good;
  2289. __le32 crc32_err;
  2290. __le32 mh_format_err;
  2291. __le32 agg_crc32_good;
  2292. __le32 agg_mpdu_cnt;
  2293. __le32 agg_cnt;
  2294. __le32 unsupport_mcs;
  2295. } __packed;
  2296. #define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1)
  2297. struct statistics_rx_non_phy {
  2298. __le32 bogus_cts; /* CTS received when not expecting CTS */
  2299. __le32 bogus_ack; /* ACK received when not expecting ACK */
  2300. __le32 non_bssid_frames; /* number of frames with BSSID that
  2301. * doesn't belong to the STA BSSID */
  2302. __le32 filtered_frames; /* count frames that were dumped in the
  2303. * filtering process */
  2304. __le32 non_channel_beacons; /* beacons with our bss id but not on
  2305. * our serving channel */
  2306. __le32 channel_beacons; /* beacons with our bss id and in our
  2307. * serving channel */
  2308. __le32 num_missed_bcon; /* number of missed beacons */
  2309. __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
  2310. * ADC was in saturation */
  2311. __le32 ina_detection_search_time;/* total time (in 0.8us) searched
  2312. * for INA */
  2313. __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
  2314. __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
  2315. __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
  2316. __le32 interference_data_flag; /* flag for interference data
  2317. * availability. 1 when data is
  2318. * available. */
  2319. __le32 channel_load; /* counts RX Enable time in uSec */
  2320. __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
  2321. * and CCK) counter */
  2322. __le32 beacon_rssi_a;
  2323. __le32 beacon_rssi_b;
  2324. __le32 beacon_rssi_c;
  2325. __le32 beacon_energy_a;
  2326. __le32 beacon_energy_b;
  2327. __le32 beacon_energy_c;
  2328. } __packed;
  2329. struct statistics_rx_non_phy_bt {
  2330. struct statistics_rx_non_phy common;
  2331. /* additional stats for bt */
  2332. __le32 num_bt_kills;
  2333. __le32 reserved[2];
  2334. } __packed;
  2335. struct statistics_rx {
  2336. struct statistics_rx_phy ofdm;
  2337. struct statistics_rx_phy cck;
  2338. struct statistics_rx_non_phy general;
  2339. struct statistics_rx_ht_phy ofdm_ht;
  2340. } __packed;
  2341. struct statistics_rx_bt {
  2342. struct statistics_rx_phy ofdm;
  2343. struct statistics_rx_phy cck;
  2344. struct statistics_rx_non_phy_bt general;
  2345. struct statistics_rx_ht_phy ofdm_ht;
  2346. } __packed;
  2347. /**
  2348. * struct statistics_tx_power - current tx power
  2349. *
  2350. * @ant_a: current tx power on chain a in 1/2 dB step
  2351. * @ant_b: current tx power on chain b in 1/2 dB step
  2352. * @ant_c: current tx power on chain c in 1/2 dB step
  2353. */
  2354. struct statistics_tx_power {
  2355. u8 ant_a;
  2356. u8 ant_b;
  2357. u8 ant_c;
  2358. u8 reserved;
  2359. } __packed;
  2360. struct statistics_tx_non_phy_agg {
  2361. __le32 ba_timeout;
  2362. __le32 ba_reschedule_frames;
  2363. __le32 scd_query_agg_frame_cnt;
  2364. __le32 scd_query_no_agg;
  2365. __le32 scd_query_agg;
  2366. __le32 scd_query_mismatch;
  2367. __le32 frame_not_ready;
  2368. __le32 underrun;
  2369. __le32 bt_prio_kill;
  2370. __le32 rx_ba_rsp_cnt;
  2371. } __packed;
  2372. struct statistics_tx {
  2373. __le32 preamble_cnt;
  2374. __le32 rx_detected_cnt;
  2375. __le32 bt_prio_defer_cnt;
  2376. __le32 bt_prio_kill_cnt;
  2377. __le32 few_bytes_cnt;
  2378. __le32 cts_timeout;
  2379. __le32 ack_timeout;
  2380. __le32 expected_ack_cnt;
  2381. __le32 actual_ack_cnt;
  2382. __le32 dump_msdu_cnt;
  2383. __le32 burst_abort_next_frame_mismatch_cnt;
  2384. __le32 burst_abort_missing_next_frame_cnt;
  2385. __le32 cts_timeout_collision;
  2386. __le32 ack_or_ba_timeout_collision;
  2387. struct statistics_tx_non_phy_agg agg;
  2388. /*
  2389. * "tx_power" are optional parameters provided by uCode,
  2390. * 6000 series is the only device provide the information,
  2391. * Those are reserved fields for all the other devices
  2392. */
  2393. struct statistics_tx_power tx_power;
  2394. __le32 reserved1;
  2395. } __packed;
  2396. struct statistics_div {
  2397. __le32 tx_on_a;
  2398. __le32 tx_on_b;
  2399. __le32 exec_time;
  2400. __le32 probe_time;
  2401. __le32 reserved1;
  2402. __le32 reserved2;
  2403. } __packed;
  2404. struct statistics_general_common {
  2405. __le32 temperature; /* radio temperature */
  2406. __le32 temperature_m; /* radio voltage */
  2407. struct statistics_dbg dbg;
  2408. __le32 sleep_time;
  2409. __le32 slots_out;
  2410. __le32 slots_idle;
  2411. __le32 ttl_timestamp;
  2412. struct statistics_div div;
  2413. __le32 rx_enable_counter;
  2414. /*
  2415. * num_of_sos_states:
  2416. * count the number of times we have to re-tune
  2417. * in order to get out of bad PHY status
  2418. */
  2419. __le32 num_of_sos_states;
  2420. } __packed;
  2421. struct statistics_bt_activity {
  2422. /* Tx statistics */
  2423. __le32 hi_priority_tx_req_cnt;
  2424. __le32 hi_priority_tx_denied_cnt;
  2425. __le32 lo_priority_tx_req_cnt;
  2426. __le32 lo_priority_tx_denied_cnt;
  2427. /* Rx statistics */
  2428. __le32 hi_priority_rx_req_cnt;
  2429. __le32 hi_priority_rx_denied_cnt;
  2430. __le32 lo_priority_rx_req_cnt;
  2431. __le32 lo_priority_rx_denied_cnt;
  2432. } __packed;
  2433. struct statistics_general {
  2434. struct statistics_general_common common;
  2435. __le32 reserved2;
  2436. __le32 reserved3;
  2437. } __packed;
  2438. struct statistics_general_bt {
  2439. struct statistics_general_common common;
  2440. struct statistics_bt_activity activity;
  2441. __le32 reserved2;
  2442. __le32 reserved3;
  2443. } __packed;
  2444. #define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0)
  2445. #define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1)
  2446. #define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2)
  2447. /*
  2448. * REPLY_STATISTICS_CMD = 0x9c,
  2449. * all devices identical.
  2450. *
  2451. * This command triggers an immediate response containing uCode statistics.
  2452. * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
  2453. *
  2454. * If the CLEAR_STATS configuration flag is set, uCode will clear its
  2455. * internal copy of the statistics (counters) after issuing the response.
  2456. * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
  2457. *
  2458. * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
  2459. * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
  2460. * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
  2461. */
  2462. #define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
  2463. #define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
  2464. struct iwl_statistics_cmd {
  2465. __le32 configuration_flags; /* IWL_STATS_CONF_* */
  2466. } __packed;
  2467. /*
  2468. * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
  2469. *
  2470. * By default, uCode issues this notification after receiving a beacon
  2471. * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
  2472. * REPLY_STATISTICS_CMD 0x9c, above.
  2473. *
  2474. * Statistics counters continue to increment beacon after beacon, but are
  2475. * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
  2476. * 0x9c with CLEAR_STATS bit set (see above).
  2477. *
  2478. * uCode also issues this notification during scans. uCode clears statistics
  2479. * appropriately so that each notification contains statistics for only the
  2480. * one channel that has just been scanned.
  2481. */
  2482. #define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
  2483. #define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8)
  2484. struct iwl_notif_statistics {
  2485. __le32 flag;
  2486. struct statistics_rx rx;
  2487. struct statistics_tx tx;
  2488. struct statistics_general general;
  2489. } __packed;
  2490. struct iwl_bt_notif_statistics {
  2491. __le32 flag;
  2492. struct statistics_rx_bt rx;
  2493. struct statistics_tx tx;
  2494. struct statistics_general_bt general;
  2495. } __packed;
  2496. /*
  2497. * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
  2498. *
  2499. * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed
  2500. * in regardless of how many missed beacons, which mean when driver receive the
  2501. * notification, inside the command, it can find all the beacons information
  2502. * which include number of total missed beacons, number of consecutive missed
  2503. * beacons, number of beacons received and number of beacons expected to
  2504. * receive.
  2505. *
  2506. * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
  2507. * in order to bring the radio/PHY back to working state; which has no relation
  2508. * to when driver will perform sensitivity calibration.
  2509. *
  2510. * Driver should set it own missed_beacon_threshold to decide when to perform
  2511. * sensitivity calibration based on number of consecutive missed beacons in
  2512. * order to improve overall performance, especially in noisy environment.
  2513. *
  2514. */
  2515. #define IWL_MISSED_BEACON_THRESHOLD_MIN (1)
  2516. #define IWL_MISSED_BEACON_THRESHOLD_DEF (5)
  2517. #define IWL_MISSED_BEACON_THRESHOLD_MAX IWL_MISSED_BEACON_THRESHOLD_DEF
  2518. struct iwl_missed_beacon_notif {
  2519. __le32 consecutive_missed_beacons;
  2520. __le32 total_missed_becons;
  2521. __le32 num_expected_beacons;
  2522. __le32 num_recvd_beacons;
  2523. } __packed;
  2524. /******************************************************************************
  2525. * (11)
  2526. * Rx Calibration Commands:
  2527. *
  2528. * With the uCode used for open source drivers, most Tx calibration (except
  2529. * for Tx Power) and most Rx calibration is done by uCode during the
  2530. * "initialize" phase of uCode boot. Driver must calibrate only:
  2531. *
  2532. * 1) Tx power (depends on temperature), described elsewhere
  2533. * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
  2534. * 3) Receiver sensitivity (to optimize signal detection)
  2535. *
  2536. *****************************************************************************/
  2537. /**
  2538. * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
  2539. *
  2540. * This command sets up the Rx signal detector for a sensitivity level that
  2541. * is high enough to lock onto all signals within the associated network,
  2542. * but low enough to ignore signals that are below a certain threshold, so as
  2543. * not to have too many "false alarms". False alarms are signals that the
  2544. * Rx DSP tries to lock onto, but then discards after determining that they
  2545. * are noise.
  2546. *
  2547. * The optimum number of false alarms is between 5 and 50 per 200 TUs
  2548. * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
  2549. * time listening, not transmitting). Driver must adjust sensitivity so that
  2550. * the ratio of actual false alarms to actual Rx time falls within this range.
  2551. *
  2552. * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
  2553. * received beacon. These provide information to the driver to analyze the
  2554. * sensitivity. Don't analyze statistics that come in from scanning, or any
  2555. * other non-associated-network source. Pertinent statistics include:
  2556. *
  2557. * From "general" statistics (struct statistics_rx_non_phy):
  2558. *
  2559. * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
  2560. * Measure of energy of desired signal. Used for establishing a level
  2561. * below which the device does not detect signals.
  2562. *
  2563. * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
  2564. * Measure of background noise in silent period after beacon.
  2565. *
  2566. * channel_load
  2567. * uSecs of actual Rx time during beacon period (varies according to
  2568. * how much time was spent transmitting).
  2569. *
  2570. * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
  2571. *
  2572. * false_alarm_cnt
  2573. * Signal locks abandoned early (before phy-level header).
  2574. *
  2575. * plcp_err
  2576. * Signal locks abandoned late (during phy-level header).
  2577. *
  2578. * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
  2579. * beacon to beacon, i.e. each value is an accumulation of all errors
  2580. * before and including the latest beacon. Values will wrap around to 0
  2581. * after counting up to 2^32 - 1. Driver must differentiate vs.
  2582. * previous beacon's values to determine # false alarms in the current
  2583. * beacon period.
  2584. *
  2585. * Total number of false alarms = false_alarms + plcp_errs
  2586. *
  2587. * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
  2588. * (notice that the start points for OFDM are at or close to settings for
  2589. * maximum sensitivity):
  2590. *
  2591. * START / MIN / MAX
  2592. * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
  2593. * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
  2594. * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
  2595. * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
  2596. *
  2597. * If actual rate of OFDM false alarms (+ plcp_errors) is too high
  2598. * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
  2599. * by *adding* 1 to all 4 of the table entries above, up to the max for
  2600. * each entry. Conversely, if false alarm rate is too low (less than 5
  2601. * for each 204.8 msecs listening), *subtract* 1 from each entry to
  2602. * increase sensitivity.
  2603. *
  2604. * For CCK sensitivity, keep track of the following:
  2605. *
  2606. * 1). 20-beacon history of maximum background noise, indicated by
  2607. * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
  2608. * 3 receivers. For any given beacon, the "silence reference" is
  2609. * the maximum of last 60 samples (20 beacons * 3 receivers).
  2610. *
  2611. * 2). 10-beacon history of strongest signal level, as indicated
  2612. * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
  2613. * i.e. the strength of the signal through the best receiver at the
  2614. * moment. These measurements are "upside down", with lower values
  2615. * for stronger signals, so max energy will be *minimum* value.
  2616. *
  2617. * Then for any given beacon, the driver must determine the *weakest*
  2618. * of the strongest signals; this is the minimum level that needs to be
  2619. * successfully detected, when using the best receiver at the moment.
  2620. * "Max cck energy" is the maximum (higher value means lower energy!)
  2621. * of the last 10 minima. Once this is determined, driver must add
  2622. * a little margin by adding "6" to it.
  2623. *
  2624. * 3). Number of consecutive beacon periods with too few false alarms.
  2625. * Reset this to 0 at the first beacon period that falls within the
  2626. * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
  2627. *
  2628. * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
  2629. * (notice that the start points for CCK are at maximum sensitivity):
  2630. *
  2631. * START / MIN / MAX
  2632. * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
  2633. * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
  2634. * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
  2635. *
  2636. * If actual rate of CCK false alarms (+ plcp_errors) is too high
  2637. * (greater than 50 for each 204.8 msecs listening), method for reducing
  2638. * sensitivity is:
  2639. *
  2640. * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
  2641. * up to max 400.
  2642. *
  2643. * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
  2644. * sensitivity has been reduced a significant amount; bring it up to
  2645. * a moderate 161. Otherwise, *add* 3, up to max 200.
  2646. *
  2647. * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
  2648. * sensitivity has been reduced only a moderate or small amount;
  2649. * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
  2650. * down to min 0. Otherwise (if gain has been significantly reduced),
  2651. * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
  2652. *
  2653. * b) Save a snapshot of the "silence reference".
  2654. *
  2655. * If actual rate of CCK false alarms (+ plcp_errors) is too low
  2656. * (less than 5 for each 204.8 msecs listening), method for increasing
  2657. * sensitivity is used only if:
  2658. *
  2659. * 1a) Previous beacon did not have too many false alarms
  2660. * 1b) AND difference between previous "silence reference" and current
  2661. * "silence reference" (prev - current) is 2 or more,
  2662. * OR 2) 100 or more consecutive beacon periods have had rate of
  2663. * less than 5 false alarms per 204.8 milliseconds rx time.
  2664. *
  2665. * Method for increasing sensitivity:
  2666. *
  2667. * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
  2668. * down to min 125.
  2669. *
  2670. * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
  2671. * down to min 200.
  2672. *
  2673. * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
  2674. *
  2675. * If actual rate of CCK false alarms (+ plcp_errors) is within good range
  2676. * (between 5 and 50 for each 204.8 msecs listening):
  2677. *
  2678. * 1) Save a snapshot of the silence reference.
  2679. *
  2680. * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
  2681. * give some extra margin to energy threshold by *subtracting* 8
  2682. * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
  2683. *
  2684. * For all cases (too few, too many, good range), make sure that the CCK
  2685. * detection threshold (energy) is below the energy level for robust
  2686. * detection over the past 10 beacon periods, the "Max cck energy".
  2687. * Lower values mean higher energy; this means making sure that the value
  2688. * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
  2689. *
  2690. */
  2691. /*
  2692. * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
  2693. */
  2694. #define HD_TABLE_SIZE (11) /* number of entries */
  2695. #define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
  2696. #define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
  2697. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
  2698. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
  2699. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
  2700. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
  2701. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
  2702. #define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
  2703. #define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
  2704. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
  2705. #define HD_OFDM_ENERGY_TH_IN_INDEX (10)
  2706. /*
  2707. * Additional table entries in enhance SENSITIVITY_CMD
  2708. */
  2709. #define HD_INA_NON_SQUARE_DET_OFDM_INDEX (11)
  2710. #define HD_INA_NON_SQUARE_DET_CCK_INDEX (12)
  2711. #define HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX (13)
  2712. #define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX (14)
  2713. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (15)
  2714. #define HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX (16)
  2715. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX (17)
  2716. #define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX (18)
  2717. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (19)
  2718. #define HD_CCK_NON_SQUARE_DET_SLOPE_INDEX (20)
  2719. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX (21)
  2720. #define HD_RESERVED (22)
  2721. /* number of entries for enhanced tbl */
  2722. #define ENHANCE_HD_TABLE_SIZE (23)
  2723. /* number of additional entries for enhanced tbl */
  2724. #define ENHANCE_HD_TABLE_ENTRIES (ENHANCE_HD_TABLE_SIZE - HD_TABLE_SIZE)
  2725. #define HD_INA_NON_SQUARE_DET_OFDM_DATA_V1 cpu_to_le16(0)
  2726. #define HD_INA_NON_SQUARE_DET_CCK_DATA_V1 cpu_to_le16(0)
  2727. #define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA_V1 cpu_to_le16(0)
  2728. #define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA_V1 cpu_to_le16(668)
  2729. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA_V1 cpu_to_le16(4)
  2730. #define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA_V1 cpu_to_le16(486)
  2731. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA_V1 cpu_to_le16(37)
  2732. #define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA_V1 cpu_to_le16(853)
  2733. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA_V1 cpu_to_le16(4)
  2734. #define HD_CCK_NON_SQUARE_DET_SLOPE_DATA_V1 cpu_to_le16(476)
  2735. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA_V1 cpu_to_le16(99)
  2736. #define HD_INA_NON_SQUARE_DET_OFDM_DATA_V2 cpu_to_le16(1)
  2737. #define HD_INA_NON_SQUARE_DET_CCK_DATA_V2 cpu_to_le16(1)
  2738. #define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA_V2 cpu_to_le16(1)
  2739. #define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA_V2 cpu_to_le16(600)
  2740. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA_V2 cpu_to_le16(40)
  2741. #define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA_V2 cpu_to_le16(486)
  2742. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA_V2 cpu_to_le16(45)
  2743. #define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA_V2 cpu_to_le16(853)
  2744. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA_V2 cpu_to_le16(60)
  2745. #define HD_CCK_NON_SQUARE_DET_SLOPE_DATA_V2 cpu_to_le16(476)
  2746. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA_V2 cpu_to_le16(99)
  2747. /* Control field in struct iwl_sensitivity_cmd */
  2748. #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0)
  2749. #define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1)
  2750. /**
  2751. * struct iwl_sensitivity_cmd
  2752. * @control: (1) updates working table, (0) updates default table
  2753. * @table: energy threshold values, use HD_* as index into table
  2754. *
  2755. * Always use "1" in "control" to update uCode's working table and DSP.
  2756. */
  2757. struct iwl_sensitivity_cmd {
  2758. __le16 control; /* always use "1" */
  2759. __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
  2760. } __packed;
  2761. /*
  2762. *
  2763. */
  2764. struct iwl_enhance_sensitivity_cmd {
  2765. __le16 control; /* always use "1" */
  2766. __le16 enhance_table[ENHANCE_HD_TABLE_SIZE]; /* use HD_* as index */
  2767. } __packed;
  2768. /**
  2769. * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
  2770. *
  2771. * This command sets the relative gains of agn device's 3 radio receiver chains.
  2772. *
  2773. * After the first association, driver should accumulate signal and noise
  2774. * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
  2775. * beacons from the associated network (don't collect statistics that come
  2776. * in from scanning, or any other non-network source).
  2777. *
  2778. * DISCONNECTED ANTENNA:
  2779. *
  2780. * Driver should determine which antennas are actually connected, by comparing
  2781. * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
  2782. * following values over 20 beacons, one accumulator for each of the chains
  2783. * a/b/c, from struct statistics_rx_non_phy:
  2784. *
  2785. * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
  2786. *
  2787. * Find the strongest signal from among a/b/c. Compare the other two to the
  2788. * strongest. If any signal is more than 15 dB (times 20, unless you
  2789. * divide the accumulated values by 20) below the strongest, the driver
  2790. * considers that antenna to be disconnected, and should not try to use that
  2791. * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
  2792. * driver should declare the stronger one as connected, and attempt to use it
  2793. * (A and B are the only 2 Tx chains!).
  2794. *
  2795. *
  2796. * RX BALANCE:
  2797. *
  2798. * Driver should balance the 3 receivers (but just the ones that are connected
  2799. * to antennas, see above) for gain, by comparing the average signal levels
  2800. * detected during the silence after each beacon (background noise).
  2801. * Accumulate (add) the following values over 20 beacons, one accumulator for
  2802. * each of the chains a/b/c, from struct statistics_rx_non_phy:
  2803. *
  2804. * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
  2805. *
  2806. * Find the weakest background noise level from among a/b/c. This Rx chain
  2807. * will be the reference, with 0 gain adjustment. Attenuate other channels by
  2808. * finding noise difference:
  2809. *
  2810. * (accum_noise[i] - accum_noise[reference]) / 30
  2811. *
  2812. * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
  2813. * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
  2814. * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
  2815. * and set bit 2 to indicate "reduce gain". The value for the reference
  2816. * (weakest) chain should be "0".
  2817. *
  2818. * diff_gain_[abc] bit fields:
  2819. * 2: (1) reduce gain, (0) increase gain
  2820. * 1-0: amount of gain, units of 1.5 dB
  2821. */
  2822. /* Phy calibration command for series */
  2823. enum {
  2824. IWL_PHY_CALIBRATE_DC_CMD = 8,
  2825. IWL_PHY_CALIBRATE_LO_CMD = 9,
  2826. IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
  2827. IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
  2828. IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16,
  2829. IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17,
  2830. IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD = 18,
  2831. };
  2832. /* This enum defines the bitmap of various calibrations to enable in both
  2833. * init ucode and runtime ucode through CALIBRATION_CFG_CMD.
  2834. */
  2835. enum iwl_ucode_calib_cfg {
  2836. IWL_CALIB_CFG_RX_BB_IDX = BIT(0),
  2837. IWL_CALIB_CFG_DC_IDX = BIT(1),
  2838. IWL_CALIB_CFG_LO_IDX = BIT(2),
  2839. IWL_CALIB_CFG_TX_IQ_IDX = BIT(3),
  2840. IWL_CALIB_CFG_RX_IQ_IDX = BIT(4),
  2841. IWL_CALIB_CFG_NOISE_IDX = BIT(5),
  2842. IWL_CALIB_CFG_CRYSTAL_IDX = BIT(6),
  2843. IWL_CALIB_CFG_TEMPERATURE_IDX = BIT(7),
  2844. IWL_CALIB_CFG_PAPD_IDX = BIT(8),
  2845. IWL_CALIB_CFG_SENSITIVITY_IDX = BIT(9),
  2846. IWL_CALIB_CFG_TX_PWR_IDX = BIT(10),
  2847. };
  2848. #define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(IWL_CALIB_CFG_RX_BB_IDX | \
  2849. IWL_CALIB_CFG_DC_IDX | \
  2850. IWL_CALIB_CFG_LO_IDX | \
  2851. IWL_CALIB_CFG_TX_IQ_IDX | \
  2852. IWL_CALIB_CFG_RX_IQ_IDX | \
  2853. IWL_CALIB_CFG_CRYSTAL_IDX)
  2854. #define IWL_CALIB_RT_CFG_ALL cpu_to_le32(IWL_CALIB_CFG_RX_BB_IDX | \
  2855. IWL_CALIB_CFG_DC_IDX | \
  2856. IWL_CALIB_CFG_LO_IDX | \
  2857. IWL_CALIB_CFG_TX_IQ_IDX | \
  2858. IWL_CALIB_CFG_RX_IQ_IDX | \
  2859. IWL_CALIB_CFG_TEMPERATURE_IDX | \
  2860. IWL_CALIB_CFG_PAPD_IDX | \
  2861. IWL_CALIB_CFG_TX_PWR_IDX | \
  2862. IWL_CALIB_CFG_CRYSTAL_IDX)
  2863. #define IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK cpu_to_le32(BIT(0))
  2864. struct iwl_calib_cfg_elmnt_s {
  2865. __le32 is_enable;
  2866. __le32 start;
  2867. __le32 send_res;
  2868. __le32 apply_res;
  2869. __le32 reserved;
  2870. } __packed;
  2871. struct iwl_calib_cfg_status_s {
  2872. struct iwl_calib_cfg_elmnt_s once;
  2873. struct iwl_calib_cfg_elmnt_s perd;
  2874. __le32 flags;
  2875. } __packed;
  2876. struct iwl_calib_cfg_cmd {
  2877. struct iwl_calib_cfg_status_s ucd_calib_cfg;
  2878. struct iwl_calib_cfg_status_s drv_calib_cfg;
  2879. __le32 reserved1;
  2880. } __packed;
  2881. struct iwl_calib_hdr {
  2882. u8 op_code;
  2883. u8 first_group;
  2884. u8 groups_num;
  2885. u8 data_valid;
  2886. } __packed;
  2887. struct iwl_calib_cmd {
  2888. struct iwl_calib_hdr hdr;
  2889. u8 data[0];
  2890. } __packed;
  2891. struct iwl_calib_xtal_freq_cmd {
  2892. struct iwl_calib_hdr hdr;
  2893. u8 cap_pin1;
  2894. u8 cap_pin2;
  2895. u8 pad[2];
  2896. } __packed;
  2897. #define DEFAULT_RADIO_SENSOR_OFFSET cpu_to_le16(2700)
  2898. struct iwl_calib_temperature_offset_cmd {
  2899. struct iwl_calib_hdr hdr;
  2900. __le16 radio_sensor_offset;
  2901. __le16 reserved;
  2902. } __packed;
  2903. struct iwl_calib_temperature_offset_v2_cmd {
  2904. struct iwl_calib_hdr hdr;
  2905. __le16 radio_sensor_offset_high;
  2906. __le16 radio_sensor_offset_low;
  2907. __le16 burntVoltageRef;
  2908. __le16 reserved;
  2909. } __packed;
  2910. /* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
  2911. struct iwl_calib_chain_noise_reset_cmd {
  2912. struct iwl_calib_hdr hdr;
  2913. u8 data[0];
  2914. };
  2915. /* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
  2916. struct iwl_calib_chain_noise_gain_cmd {
  2917. struct iwl_calib_hdr hdr;
  2918. u8 delta_gain_1;
  2919. u8 delta_gain_2;
  2920. u8 pad[2];
  2921. } __packed;
  2922. /******************************************************************************
  2923. * (12)
  2924. * Miscellaneous Commands:
  2925. *
  2926. *****************************************************************************/
  2927. /*
  2928. * LEDs Command & Response
  2929. * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
  2930. *
  2931. * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
  2932. * this command turns it on or off, or sets up a periodic blinking cycle.
  2933. */
  2934. struct iwl_led_cmd {
  2935. __le32 interval; /* "interval" in uSec */
  2936. u8 id; /* 1: Activity, 2: Link, 3: Tech */
  2937. u8 off; /* # intervals off while blinking;
  2938. * "0", with >0 "on" value, turns LED on */
  2939. u8 on; /* # intervals on while blinking;
  2940. * "0", regardless of "off", turns LED off */
  2941. u8 reserved;
  2942. } __packed;
  2943. /*
  2944. * station priority table entries
  2945. * also used as potential "events" value for both
  2946. * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
  2947. */
  2948. /*
  2949. * COEX events entry flag masks
  2950. * RP - Requested Priority
  2951. * WP - Win Medium Priority: priority assigned when the contention has been won
  2952. */
  2953. #define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG (0x1)
  2954. #define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG (0x2)
  2955. #define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG (0x4)
  2956. #define COEX_CU_UNASSOC_IDLE_RP 4
  2957. #define COEX_CU_UNASSOC_MANUAL_SCAN_RP 4
  2958. #define COEX_CU_UNASSOC_AUTO_SCAN_RP 4
  2959. #define COEX_CU_CALIBRATION_RP 4
  2960. #define COEX_CU_PERIODIC_CALIBRATION_RP 4
  2961. #define COEX_CU_CONNECTION_ESTAB_RP 4
  2962. #define COEX_CU_ASSOCIATED_IDLE_RP 4
  2963. #define COEX_CU_ASSOC_MANUAL_SCAN_RP 4
  2964. #define COEX_CU_ASSOC_AUTO_SCAN_RP 4
  2965. #define COEX_CU_ASSOC_ACTIVE_LEVEL_RP 4
  2966. #define COEX_CU_RF_ON_RP 6
  2967. #define COEX_CU_RF_OFF_RP 4
  2968. #define COEX_CU_STAND_ALONE_DEBUG_RP 6
  2969. #define COEX_CU_IPAN_ASSOC_LEVEL_RP 4
  2970. #define COEX_CU_RSRVD1_RP 4
  2971. #define COEX_CU_RSRVD2_RP 4
  2972. #define COEX_CU_UNASSOC_IDLE_WP 3
  2973. #define COEX_CU_UNASSOC_MANUAL_SCAN_WP 3
  2974. #define COEX_CU_UNASSOC_AUTO_SCAN_WP 3
  2975. #define COEX_CU_CALIBRATION_WP 3
  2976. #define COEX_CU_PERIODIC_CALIBRATION_WP 3
  2977. #define COEX_CU_CONNECTION_ESTAB_WP 3
  2978. #define COEX_CU_ASSOCIATED_IDLE_WP 3
  2979. #define COEX_CU_ASSOC_MANUAL_SCAN_WP 3
  2980. #define COEX_CU_ASSOC_AUTO_SCAN_WP 3
  2981. #define COEX_CU_ASSOC_ACTIVE_LEVEL_WP 3
  2982. #define COEX_CU_RF_ON_WP 3
  2983. #define COEX_CU_RF_OFF_WP 3
  2984. #define COEX_CU_STAND_ALONE_DEBUG_WP 6
  2985. #define COEX_CU_IPAN_ASSOC_LEVEL_WP 3
  2986. #define COEX_CU_RSRVD1_WP 3
  2987. #define COEX_CU_RSRVD2_WP 3
  2988. #define COEX_UNASSOC_IDLE_FLAGS 0
  2989. #define COEX_UNASSOC_MANUAL_SCAN_FLAGS \
  2990. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  2991. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  2992. #define COEX_UNASSOC_AUTO_SCAN_FLAGS \
  2993. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  2994. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  2995. #define COEX_CALIBRATION_FLAGS \
  2996. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  2997. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  2998. #define COEX_PERIODIC_CALIBRATION_FLAGS 0
  2999. /*
  3000. * COEX_CONNECTION_ESTAB:
  3001. * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
  3002. */
  3003. #define COEX_CONNECTION_ESTAB_FLAGS \
  3004. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3005. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
  3006. COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
  3007. #define COEX_ASSOCIATED_IDLE_FLAGS 0
  3008. #define COEX_ASSOC_MANUAL_SCAN_FLAGS \
  3009. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3010. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3011. #define COEX_ASSOC_AUTO_SCAN_FLAGS \
  3012. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3013. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3014. #define COEX_ASSOC_ACTIVE_LEVEL_FLAGS 0
  3015. #define COEX_RF_ON_FLAGS 0
  3016. #define COEX_RF_OFF_FLAGS 0
  3017. #define COEX_STAND_ALONE_DEBUG_FLAGS \
  3018. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3019. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3020. #define COEX_IPAN_ASSOC_LEVEL_FLAGS \
  3021. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3022. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
  3023. COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
  3024. #define COEX_RSRVD1_FLAGS 0
  3025. #define COEX_RSRVD2_FLAGS 0
  3026. /*
  3027. * COEX_CU_RF_ON is the event wrapping all radio ownership.
  3028. * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
  3029. */
  3030. #define COEX_CU_RF_ON_FLAGS \
  3031. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3032. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
  3033. COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
  3034. enum {
  3035. /* un-association part */
  3036. COEX_UNASSOC_IDLE = 0,
  3037. COEX_UNASSOC_MANUAL_SCAN = 1,
  3038. COEX_UNASSOC_AUTO_SCAN = 2,
  3039. /* calibration */
  3040. COEX_CALIBRATION = 3,
  3041. COEX_PERIODIC_CALIBRATION = 4,
  3042. /* connection */
  3043. COEX_CONNECTION_ESTAB = 5,
  3044. /* association part */
  3045. COEX_ASSOCIATED_IDLE = 6,
  3046. COEX_ASSOC_MANUAL_SCAN = 7,
  3047. COEX_ASSOC_AUTO_SCAN = 8,
  3048. COEX_ASSOC_ACTIVE_LEVEL = 9,
  3049. /* RF ON/OFF */
  3050. COEX_RF_ON = 10,
  3051. COEX_RF_OFF = 11,
  3052. COEX_STAND_ALONE_DEBUG = 12,
  3053. /* IPAN */
  3054. COEX_IPAN_ASSOC_LEVEL = 13,
  3055. /* reserved */
  3056. COEX_RSRVD1 = 14,
  3057. COEX_RSRVD2 = 15,
  3058. COEX_NUM_OF_EVENTS = 16
  3059. };
  3060. /*
  3061. * Coexistence WIFI/WIMAX Command
  3062. * COEX_PRIORITY_TABLE_CMD = 0x5a
  3063. *
  3064. */
  3065. struct iwl_wimax_coex_event_entry {
  3066. u8 request_prio;
  3067. u8 win_medium_prio;
  3068. u8 reserved;
  3069. u8 flags;
  3070. } __packed;
  3071. /* COEX flag masks */
  3072. /* Station table is valid */
  3073. #define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1)
  3074. /* UnMask wake up src at unassociated sleep */
  3075. #define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4)
  3076. /* UnMask wake up src at associated sleep */
  3077. #define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8)
  3078. /* Enable CoEx feature. */
  3079. #define COEX_FLAGS_COEX_ENABLE_MSK (0x80)
  3080. struct iwl_wimax_coex_cmd {
  3081. u8 flags;
  3082. u8 reserved[3];
  3083. struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
  3084. } __packed;
  3085. /*
  3086. * Coexistence MEDIUM NOTIFICATION
  3087. * COEX_MEDIUM_NOTIFICATION = 0x5b
  3088. *
  3089. * notification from uCode to host to indicate medium changes
  3090. *
  3091. */
  3092. /*
  3093. * status field
  3094. * bit 0 - 2: medium status
  3095. * bit 3: medium change indication
  3096. * bit 4 - 31: reserved
  3097. */
  3098. /* status option values, (0 - 2 bits) */
  3099. #define COEX_MEDIUM_BUSY (0x0) /* radio belongs to WiMAX */
  3100. #define COEX_MEDIUM_ACTIVE (0x1) /* radio belongs to WiFi */
  3101. #define COEX_MEDIUM_PRE_RELEASE (0x2) /* received radio release */
  3102. #define COEX_MEDIUM_MSK (0x7)
  3103. /* send notification status (1 bit) */
  3104. #define COEX_MEDIUM_CHANGED (0x8)
  3105. #define COEX_MEDIUM_CHANGED_MSK (0x8)
  3106. #define COEX_MEDIUM_SHIFT (3)
  3107. struct iwl_coex_medium_notification {
  3108. __le32 status;
  3109. __le32 events;
  3110. } __packed;
  3111. /*
  3112. * Coexistence EVENT Command
  3113. * COEX_EVENT_CMD = 0x5c
  3114. *
  3115. * send from host to uCode for coex event request.
  3116. */
  3117. /* flags options */
  3118. #define COEX_EVENT_REQUEST_MSK (0x1)
  3119. struct iwl_coex_event_cmd {
  3120. u8 flags;
  3121. u8 event;
  3122. __le16 reserved;
  3123. } __packed;
  3124. struct iwl_coex_event_resp {
  3125. __le32 status;
  3126. } __packed;
  3127. /******************************************************************************
  3128. * Bluetooth Coexistence commands
  3129. *
  3130. *****************************************************************************/
  3131. /*
  3132. * BT Status notification
  3133. * REPLY_BT_COEX_PROFILE_NOTIF = 0xce
  3134. */
  3135. enum iwl_bt_coex_profile_traffic_load {
  3136. IWL_BT_COEX_TRAFFIC_LOAD_NONE = 0,
  3137. IWL_BT_COEX_TRAFFIC_LOAD_LOW = 1,
  3138. IWL_BT_COEX_TRAFFIC_LOAD_HIGH = 2,
  3139. IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS = 3,
  3140. /*
  3141. * There are no more even though below is a u8, the
  3142. * indication from the BT device only has two bits.
  3143. */
  3144. };
  3145. #define BT_SESSION_ACTIVITY_1_UART_MSG 0x1
  3146. #define BT_SESSION_ACTIVITY_2_UART_MSG 0x2
  3147. /* BT UART message - Share Part (BT -> WiFi) */
  3148. #define BT_UART_MSG_FRAME1MSGTYPE_POS (0)
  3149. #define BT_UART_MSG_FRAME1MSGTYPE_MSK \
  3150. (0x7 << BT_UART_MSG_FRAME1MSGTYPE_POS)
  3151. #define BT_UART_MSG_FRAME1SSN_POS (3)
  3152. #define BT_UART_MSG_FRAME1SSN_MSK \
  3153. (0x3 << BT_UART_MSG_FRAME1SSN_POS)
  3154. #define BT_UART_MSG_FRAME1UPDATEREQ_POS (5)
  3155. #define BT_UART_MSG_FRAME1UPDATEREQ_MSK \
  3156. (0x1 << BT_UART_MSG_FRAME1UPDATEREQ_POS)
  3157. #define BT_UART_MSG_FRAME1RESERVED_POS (6)
  3158. #define BT_UART_MSG_FRAME1RESERVED_MSK \
  3159. (0x3 << BT_UART_MSG_FRAME1RESERVED_POS)
  3160. #define BT_UART_MSG_FRAME2OPENCONNECTIONS_POS (0)
  3161. #define BT_UART_MSG_FRAME2OPENCONNECTIONS_MSK \
  3162. (0x3 << BT_UART_MSG_FRAME2OPENCONNECTIONS_POS)
  3163. #define BT_UART_MSG_FRAME2TRAFFICLOAD_POS (2)
  3164. #define BT_UART_MSG_FRAME2TRAFFICLOAD_MSK \
  3165. (0x3 << BT_UART_MSG_FRAME2TRAFFICLOAD_POS)
  3166. #define BT_UART_MSG_FRAME2CHLSEQN_POS (4)
  3167. #define BT_UART_MSG_FRAME2CHLSEQN_MSK \
  3168. (0x1 << BT_UART_MSG_FRAME2CHLSEQN_POS)
  3169. #define BT_UART_MSG_FRAME2INBAND_POS (5)
  3170. #define BT_UART_MSG_FRAME2INBAND_MSK \
  3171. (0x1 << BT_UART_MSG_FRAME2INBAND_POS)
  3172. #define BT_UART_MSG_FRAME2RESERVED_POS (6)
  3173. #define BT_UART_MSG_FRAME2RESERVED_MSK \
  3174. (0x3 << BT_UART_MSG_FRAME2RESERVED_POS)
  3175. #define BT_UART_MSG_FRAME3SCOESCO_POS (0)
  3176. #define BT_UART_MSG_FRAME3SCOESCO_MSK \
  3177. (0x1 << BT_UART_MSG_FRAME3SCOESCO_POS)
  3178. #define BT_UART_MSG_FRAME3SNIFF_POS (1)
  3179. #define BT_UART_MSG_FRAME3SNIFF_MSK \
  3180. (0x1 << BT_UART_MSG_FRAME3SNIFF_POS)
  3181. #define BT_UART_MSG_FRAME3A2DP_POS (2)
  3182. #define BT_UART_MSG_FRAME3A2DP_MSK \
  3183. (0x1 << BT_UART_MSG_FRAME3A2DP_POS)
  3184. #define BT_UART_MSG_FRAME3ACL_POS (3)
  3185. #define BT_UART_MSG_FRAME3ACL_MSK \
  3186. (0x1 << BT_UART_MSG_FRAME3ACL_POS)
  3187. #define BT_UART_MSG_FRAME3MASTER_POS (4)
  3188. #define BT_UART_MSG_FRAME3MASTER_MSK \
  3189. (0x1 << BT_UART_MSG_FRAME3MASTER_POS)
  3190. #define BT_UART_MSG_FRAME3OBEX_POS (5)
  3191. #define BT_UART_MSG_FRAME3OBEX_MSK \
  3192. (0x1 << BT_UART_MSG_FRAME3OBEX_POS)
  3193. #define BT_UART_MSG_FRAME3RESERVED_POS (6)
  3194. #define BT_UART_MSG_FRAME3RESERVED_MSK \
  3195. (0x3 << BT_UART_MSG_FRAME3RESERVED_POS)
  3196. #define BT_UART_MSG_FRAME4IDLEDURATION_POS (0)
  3197. #define BT_UART_MSG_FRAME4IDLEDURATION_MSK \
  3198. (0x3F << BT_UART_MSG_FRAME4IDLEDURATION_POS)
  3199. #define BT_UART_MSG_FRAME4RESERVED_POS (6)
  3200. #define BT_UART_MSG_FRAME4RESERVED_MSK \
  3201. (0x3 << BT_UART_MSG_FRAME4RESERVED_POS)
  3202. #define BT_UART_MSG_FRAME5TXACTIVITY_POS (0)
  3203. #define BT_UART_MSG_FRAME5TXACTIVITY_MSK \
  3204. (0x3 << BT_UART_MSG_FRAME5TXACTIVITY_POS)
  3205. #define BT_UART_MSG_FRAME5RXACTIVITY_POS (2)
  3206. #define BT_UART_MSG_FRAME5RXACTIVITY_MSK \
  3207. (0x3 << BT_UART_MSG_FRAME5RXACTIVITY_POS)
  3208. #define BT_UART_MSG_FRAME5ESCORETRANSMIT_POS (4)
  3209. #define BT_UART_MSG_FRAME5ESCORETRANSMIT_MSK \
  3210. (0x3 << BT_UART_MSG_FRAME5ESCORETRANSMIT_POS)
  3211. #define BT_UART_MSG_FRAME5RESERVED_POS (6)
  3212. #define BT_UART_MSG_FRAME5RESERVED_MSK \
  3213. (0x3 << BT_UART_MSG_FRAME5RESERVED_POS)
  3214. #define BT_UART_MSG_FRAME6SNIFFINTERVAL_POS (0)
  3215. #define BT_UART_MSG_FRAME6SNIFFINTERVAL_MSK \
  3216. (0x1F << BT_UART_MSG_FRAME6SNIFFINTERVAL_POS)
  3217. #define BT_UART_MSG_FRAME6DISCOVERABLE_POS (5)
  3218. #define BT_UART_MSG_FRAME6DISCOVERABLE_MSK \
  3219. (0x1 << BT_UART_MSG_FRAME6DISCOVERABLE_POS)
  3220. #define BT_UART_MSG_FRAME6RESERVED_POS (6)
  3221. #define BT_UART_MSG_FRAME6RESERVED_MSK \
  3222. (0x3 << BT_UART_MSG_FRAME6RESERVED_POS)
  3223. #define BT_UART_MSG_FRAME7SNIFFACTIVITY_POS (0)
  3224. #define BT_UART_MSG_FRAME7SNIFFACTIVITY_MSK \
  3225. (0x7 << BT_UART_MSG_FRAME7SNIFFACTIVITY_POS)
  3226. #define BT_UART_MSG_FRAME7PAGE_POS (3)
  3227. #define BT_UART_MSG_FRAME7PAGE_MSK \
  3228. (0x1 << BT_UART_MSG_FRAME7PAGE_POS)
  3229. #define BT_UART_MSG_FRAME7INQUIRY_POS (4)
  3230. #define BT_UART_MSG_FRAME7INQUIRY_MSK \
  3231. (0x1 << BT_UART_MSG_FRAME7INQUIRY_POS)
  3232. #define BT_UART_MSG_FRAME7CONNECTABLE_POS (5)
  3233. #define BT_UART_MSG_FRAME7CONNECTABLE_MSK \
  3234. (0x1 << BT_UART_MSG_FRAME7CONNECTABLE_POS)
  3235. #define BT_UART_MSG_FRAME7RESERVED_POS (6)
  3236. #define BT_UART_MSG_FRAME7RESERVED_MSK \
  3237. (0x3 << BT_UART_MSG_FRAME7RESERVED_POS)
  3238. /* BT Session Activity 2 UART message (BT -> WiFi) */
  3239. #define BT_UART_MSG_2_FRAME1RESERVED1_POS (5)
  3240. #define BT_UART_MSG_2_FRAME1RESERVED1_MSK \
  3241. (0x1<<BT_UART_MSG_2_FRAME1RESERVED1_POS)
  3242. #define BT_UART_MSG_2_FRAME1RESERVED2_POS (6)
  3243. #define BT_UART_MSG_2_FRAME1RESERVED2_MSK \
  3244. (0x3<<BT_UART_MSG_2_FRAME1RESERVED2_POS)
  3245. #define BT_UART_MSG_2_FRAME2AGGTRAFFICLOAD_POS (0)
  3246. #define BT_UART_MSG_2_FRAME2AGGTRAFFICLOAD_MSK \
  3247. (0x3F<<BT_UART_MSG_2_FRAME2AGGTRAFFICLOAD_POS)
  3248. #define BT_UART_MSG_2_FRAME2RESERVED_POS (6)
  3249. #define BT_UART_MSG_2_FRAME2RESERVED_MSK \
  3250. (0x3<<BT_UART_MSG_2_FRAME2RESERVED_POS)
  3251. #define BT_UART_MSG_2_FRAME3BRLASTTXPOWER_POS (0)
  3252. #define BT_UART_MSG_2_FRAME3BRLASTTXPOWER_MSK \
  3253. (0xF<<BT_UART_MSG_2_FRAME3BRLASTTXPOWER_POS)
  3254. #define BT_UART_MSG_2_FRAME3INQPAGESRMODE_POS (4)
  3255. #define BT_UART_MSG_2_FRAME3INQPAGESRMODE_MSK \
  3256. (0x1<<BT_UART_MSG_2_FRAME3INQPAGESRMODE_POS)
  3257. #define BT_UART_MSG_2_FRAME3LEMASTER_POS (5)
  3258. #define BT_UART_MSG_2_FRAME3LEMASTER_MSK \
  3259. (0x1<<BT_UART_MSG_2_FRAME3LEMASTER_POS)
  3260. #define BT_UART_MSG_2_FRAME3RESERVED_POS (6)
  3261. #define BT_UART_MSG_2_FRAME3RESERVED_MSK \
  3262. (0x3<<BT_UART_MSG_2_FRAME3RESERVED_POS)
  3263. #define BT_UART_MSG_2_FRAME4LELASTTXPOWER_POS (0)
  3264. #define BT_UART_MSG_2_FRAME4LELASTTXPOWER_MSK \
  3265. (0xF<<BT_UART_MSG_2_FRAME4LELASTTXPOWER_POS)
  3266. #define BT_UART_MSG_2_FRAME4NUMLECONN_POS (4)
  3267. #define BT_UART_MSG_2_FRAME4NUMLECONN_MSK \
  3268. (0x3<<BT_UART_MSG_2_FRAME4NUMLECONN_POS)
  3269. #define BT_UART_MSG_2_FRAME4RESERVED_POS (6)
  3270. #define BT_UART_MSG_2_FRAME4RESERVED_MSK \
  3271. (0x3<<BT_UART_MSG_2_FRAME4RESERVED_POS)
  3272. #define BT_UART_MSG_2_FRAME5BTMINRSSI_POS (0)
  3273. #define BT_UART_MSG_2_FRAME5BTMINRSSI_MSK \
  3274. (0xF<<BT_UART_MSG_2_FRAME5BTMINRSSI_POS)
  3275. #define BT_UART_MSG_2_FRAME5LESCANINITMODE_POS (4)
  3276. #define BT_UART_MSG_2_FRAME5LESCANINITMODE_MSK \
  3277. (0x1<<BT_UART_MSG_2_FRAME5LESCANINITMODE_POS)
  3278. #define BT_UART_MSG_2_FRAME5LEADVERMODE_POS (5)
  3279. #define BT_UART_MSG_2_FRAME5LEADVERMODE_MSK \
  3280. (0x1<<BT_UART_MSG_2_FRAME5LEADVERMODE_POS)
  3281. #define BT_UART_MSG_2_FRAME5RESERVED_POS (6)
  3282. #define BT_UART_MSG_2_FRAME5RESERVED_MSK \
  3283. (0x3<<BT_UART_MSG_2_FRAME5RESERVED_POS)
  3284. #define BT_UART_MSG_2_FRAME6LECONNINTERVAL_POS (0)
  3285. #define BT_UART_MSG_2_FRAME6LECONNINTERVAL_MSK \
  3286. (0x1F<<BT_UART_MSG_2_FRAME6LECONNINTERVAL_POS)
  3287. #define BT_UART_MSG_2_FRAME6RFU_POS (5)
  3288. #define BT_UART_MSG_2_FRAME6RFU_MSK \
  3289. (0x1<<BT_UART_MSG_2_FRAME6RFU_POS)
  3290. #define BT_UART_MSG_2_FRAME6RESERVED_POS (6)
  3291. #define BT_UART_MSG_2_FRAME6RESERVED_MSK \
  3292. (0x3<<BT_UART_MSG_2_FRAME6RESERVED_POS)
  3293. #define BT_UART_MSG_2_FRAME7LECONNSLAVELAT_POS (0)
  3294. #define BT_UART_MSG_2_FRAME7LECONNSLAVELAT_MSK \
  3295. (0x7<<BT_UART_MSG_2_FRAME7LECONNSLAVELAT_POS)
  3296. #define BT_UART_MSG_2_FRAME7LEPROFILE1_POS (3)
  3297. #define BT_UART_MSG_2_FRAME7LEPROFILE1_MSK \
  3298. (0x1<<BT_UART_MSG_2_FRAME7LEPROFILE1_POS)
  3299. #define BT_UART_MSG_2_FRAME7LEPROFILE2_POS (4)
  3300. #define BT_UART_MSG_2_FRAME7LEPROFILE2_MSK \
  3301. (0x1<<BT_UART_MSG_2_FRAME7LEPROFILE2_POS)
  3302. #define BT_UART_MSG_2_FRAME7LEPROFILEOTHER_POS (5)
  3303. #define BT_UART_MSG_2_FRAME7LEPROFILEOTHER_MSK \
  3304. (0x1<<BT_UART_MSG_2_FRAME7LEPROFILEOTHER_POS)
  3305. #define BT_UART_MSG_2_FRAME7RESERVED_POS (6)
  3306. #define BT_UART_MSG_2_FRAME7RESERVED_MSK \
  3307. (0x3<<BT_UART_MSG_2_FRAME7RESERVED_POS)
  3308. #define BT_ENABLE_REDUCED_TXPOWER_THRESHOLD (-62)
  3309. #define BT_DISABLE_REDUCED_TXPOWER_THRESHOLD (-65)
  3310. struct iwl_bt_uart_msg {
  3311. u8 header;
  3312. u8 frame1;
  3313. u8 frame2;
  3314. u8 frame3;
  3315. u8 frame4;
  3316. u8 frame5;
  3317. u8 frame6;
  3318. u8 frame7;
  3319. } __packed;
  3320. struct iwl_bt_coex_profile_notif {
  3321. struct iwl_bt_uart_msg last_bt_uart_msg;
  3322. u8 bt_status; /* 0 - off, 1 - on */
  3323. u8 bt_traffic_load; /* 0 .. 3? */
  3324. u8 bt_ci_compliance; /* 0 - not complied, 1 - complied */
  3325. u8 reserved;
  3326. } __packed;
  3327. #define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS 0
  3328. #define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_MSK 0x1
  3329. #define IWL_BT_COEX_PRIO_TBL_PRIO_POS 1
  3330. #define IWL_BT_COEX_PRIO_TBL_PRIO_MASK 0x0e
  3331. #define IWL_BT_COEX_PRIO_TBL_RESERVED_POS 4
  3332. #define IWL_BT_COEX_PRIO_TBL_RESERVED_MASK 0xf0
  3333. #define IWL_BT_COEX_PRIO_TBL_PRIO_SHIFT 1
  3334. /*
  3335. * BT Coexistence Priority table
  3336. * REPLY_BT_COEX_PRIO_TABLE = 0xcc
  3337. */
  3338. enum bt_coex_prio_table_events {
  3339. BT_COEX_PRIO_TBL_EVT_INIT_CALIB1 = 0,
  3340. BT_COEX_PRIO_TBL_EVT_INIT_CALIB2 = 1,
  3341. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1 = 2,
  3342. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2 = 3, /* DC calib */
  3343. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1 = 4,
  3344. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2 = 5,
  3345. BT_COEX_PRIO_TBL_EVT_DTIM = 6,
  3346. BT_COEX_PRIO_TBL_EVT_SCAN52 = 7,
  3347. BT_COEX_PRIO_TBL_EVT_SCAN24 = 8,
  3348. BT_COEX_PRIO_TBL_EVT_RESERVED0 = 9,
  3349. BT_COEX_PRIO_TBL_EVT_RESERVED1 = 10,
  3350. BT_COEX_PRIO_TBL_EVT_RESERVED2 = 11,
  3351. BT_COEX_PRIO_TBL_EVT_RESERVED3 = 12,
  3352. BT_COEX_PRIO_TBL_EVT_RESERVED4 = 13,
  3353. BT_COEX_PRIO_TBL_EVT_RESERVED5 = 14,
  3354. BT_COEX_PRIO_TBL_EVT_RESERVED6 = 15,
  3355. /* BT_COEX_PRIO_TBL_EVT_MAX should always be last */
  3356. BT_COEX_PRIO_TBL_EVT_MAX,
  3357. };
  3358. enum bt_coex_prio_table_priorities {
  3359. BT_COEX_PRIO_TBL_DISABLED = 0,
  3360. BT_COEX_PRIO_TBL_PRIO_LOW = 1,
  3361. BT_COEX_PRIO_TBL_PRIO_HIGH = 2,
  3362. BT_COEX_PRIO_TBL_PRIO_BYPASS = 3,
  3363. BT_COEX_PRIO_TBL_PRIO_COEX_OFF = 4,
  3364. BT_COEX_PRIO_TBL_PRIO_COEX_ON = 5,
  3365. BT_COEX_PRIO_TBL_PRIO_RSRVD1 = 6,
  3366. BT_COEX_PRIO_TBL_PRIO_RSRVD2 = 7,
  3367. BT_COEX_PRIO_TBL_MAX,
  3368. };
  3369. struct iwl_bt_coex_prio_table_cmd {
  3370. u8 prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX];
  3371. } __packed;
  3372. #define IWL_BT_COEX_ENV_CLOSE 0
  3373. #define IWL_BT_COEX_ENV_OPEN 1
  3374. /*
  3375. * BT Protection Envelope
  3376. * REPLY_BT_COEX_PROT_ENV = 0xcd
  3377. */
  3378. struct iwl_bt_coex_prot_env_cmd {
  3379. u8 action; /* 0 = closed, 1 = open */
  3380. u8 type; /* 0 .. 15 */
  3381. u8 reserved[2];
  3382. } __packed;
  3383. /*
  3384. * REPLY_D3_CONFIG
  3385. */
  3386. enum iwlagn_d3_wakeup_filters {
  3387. IWLAGN_D3_WAKEUP_RFKILL = BIT(0),
  3388. IWLAGN_D3_WAKEUP_SYSASSERT = BIT(1),
  3389. };
  3390. struct iwlagn_d3_config_cmd {
  3391. __le32 min_sleep_time;
  3392. __le32 wakeup_flags;
  3393. } __packed;
  3394. /*
  3395. * REPLY_WOWLAN_PATTERNS
  3396. */
  3397. #define IWLAGN_WOWLAN_MIN_PATTERN_LEN 16
  3398. #define IWLAGN_WOWLAN_MAX_PATTERN_LEN 128
  3399. struct iwlagn_wowlan_pattern {
  3400. u8 mask[IWLAGN_WOWLAN_MAX_PATTERN_LEN / 8];
  3401. u8 pattern[IWLAGN_WOWLAN_MAX_PATTERN_LEN];
  3402. u8 mask_size;
  3403. u8 pattern_size;
  3404. __le16 reserved;
  3405. } __packed;
  3406. #define IWLAGN_WOWLAN_MAX_PATTERNS 20
  3407. struct iwlagn_wowlan_patterns_cmd {
  3408. __le32 n_patterns;
  3409. struct iwlagn_wowlan_pattern patterns[];
  3410. } __packed;
  3411. /*
  3412. * REPLY_WOWLAN_WAKEUP_FILTER
  3413. */
  3414. enum iwlagn_wowlan_wakeup_filters {
  3415. IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET = BIT(0),
  3416. IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH = BIT(1),
  3417. IWLAGN_WOWLAN_WAKEUP_BEACON_MISS = BIT(2),
  3418. IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE = BIT(3),
  3419. IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL = BIT(4),
  3420. IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ = BIT(5),
  3421. IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE = BIT(6),
  3422. IWLAGN_WOWLAN_WAKEUP_ALWAYS = BIT(7),
  3423. IWLAGN_WOWLAN_WAKEUP_ENABLE_NET_DETECT = BIT(8),
  3424. };
  3425. struct iwlagn_wowlan_wakeup_filter_cmd {
  3426. __le32 enabled;
  3427. __le16 non_qos_seq;
  3428. __le16 reserved;
  3429. __le16 qos_seq[8];
  3430. };
  3431. /*
  3432. * REPLY_WOWLAN_TSC_RSC_PARAMS
  3433. */
  3434. #define IWLAGN_NUM_RSC 16
  3435. struct tkip_sc {
  3436. __le16 iv16;
  3437. __le16 pad;
  3438. __le32 iv32;
  3439. } __packed;
  3440. struct iwlagn_tkip_rsc_tsc {
  3441. struct tkip_sc unicast_rsc[IWLAGN_NUM_RSC];
  3442. struct tkip_sc multicast_rsc[IWLAGN_NUM_RSC];
  3443. struct tkip_sc tsc;
  3444. } __packed;
  3445. struct aes_sc {
  3446. __le64 pn;
  3447. } __packed;
  3448. struct iwlagn_aes_rsc_tsc {
  3449. struct aes_sc unicast_rsc[IWLAGN_NUM_RSC];
  3450. struct aes_sc multicast_rsc[IWLAGN_NUM_RSC];
  3451. struct aes_sc tsc;
  3452. } __packed;
  3453. union iwlagn_all_tsc_rsc {
  3454. struct iwlagn_tkip_rsc_tsc tkip;
  3455. struct iwlagn_aes_rsc_tsc aes;
  3456. };
  3457. struct iwlagn_wowlan_rsc_tsc_params_cmd {
  3458. union iwlagn_all_tsc_rsc all_tsc_rsc;
  3459. } __packed;
  3460. /*
  3461. * REPLY_WOWLAN_TKIP_PARAMS
  3462. */
  3463. #define IWLAGN_MIC_KEY_SIZE 8
  3464. #define IWLAGN_P1K_SIZE 5
  3465. struct iwlagn_mic_keys {
  3466. u8 tx[IWLAGN_MIC_KEY_SIZE];
  3467. u8 rx_unicast[IWLAGN_MIC_KEY_SIZE];
  3468. u8 rx_mcast[IWLAGN_MIC_KEY_SIZE];
  3469. } __packed;
  3470. struct iwlagn_p1k_cache {
  3471. __le16 p1k[IWLAGN_P1K_SIZE];
  3472. } __packed;
  3473. #define IWLAGN_NUM_RX_P1K_CACHE 2
  3474. struct iwlagn_wowlan_tkip_params_cmd {
  3475. struct iwlagn_mic_keys mic_keys;
  3476. struct iwlagn_p1k_cache tx;
  3477. struct iwlagn_p1k_cache rx_uni[IWLAGN_NUM_RX_P1K_CACHE];
  3478. struct iwlagn_p1k_cache rx_multi[IWLAGN_NUM_RX_P1K_CACHE];
  3479. } __packed;
  3480. /*
  3481. * REPLY_WOWLAN_KEK_KCK_MATERIAL
  3482. */
  3483. #define IWLAGN_KCK_MAX_SIZE 32
  3484. #define IWLAGN_KEK_MAX_SIZE 32
  3485. struct iwlagn_wowlan_kek_kck_material_cmd {
  3486. u8 kck[IWLAGN_KCK_MAX_SIZE];
  3487. u8 kek[IWLAGN_KEK_MAX_SIZE];
  3488. __le16 kck_len;
  3489. __le16 kek_len;
  3490. __le64 replay_ctr;
  3491. } __packed;
  3492. #define RF_KILL_INDICATOR_FOR_WOWLAN 0x87
  3493. /*
  3494. * REPLY_WOWLAN_GET_STATUS = 0xe5
  3495. */
  3496. struct iwlagn_wowlan_status {
  3497. __le64 replay_ctr;
  3498. __le32 rekey_status;
  3499. __le32 wakeup_reason;
  3500. u8 pattern_number;
  3501. u8 reserved1;
  3502. __le16 qos_seq_ctr[8];
  3503. __le16 non_qos_seq_ctr;
  3504. __le16 reserved2;
  3505. union iwlagn_all_tsc_rsc tsc_rsc;
  3506. __le16 reserved3;
  3507. } __packed;
  3508. /*
  3509. * REPLY_WIPAN_PARAMS = 0xb2 (Commands and Notification)
  3510. */
  3511. /*
  3512. * Minimum slot time in TU
  3513. */
  3514. #define IWL_MIN_SLOT_TIME 20
  3515. /**
  3516. * struct iwl_wipan_slot
  3517. * @width: Time in TU
  3518. * @type:
  3519. * 0 - BSS
  3520. * 1 - PAN
  3521. */
  3522. struct iwl_wipan_slot {
  3523. __le16 width;
  3524. u8 type;
  3525. u8 reserved;
  3526. } __packed;
  3527. #define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_CTS BIT(1) /* reserved */
  3528. #define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_QUIET BIT(2) /* reserved */
  3529. #define IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE BIT(3) /* reserved */
  3530. #define IWL_WIPAN_PARAMS_FLG_FILTER_BEACON_NOTIF BIT(4)
  3531. #define IWL_WIPAN_PARAMS_FLG_FULL_SLOTTED_MODE BIT(5)
  3532. /**
  3533. * struct iwl_wipan_params_cmd
  3534. * @flags:
  3535. * bit0: reserved
  3536. * bit1: CP leave channel with CTS
  3537. * bit2: CP leave channel qith Quiet
  3538. * bit3: slotted mode
  3539. * 1 - work in slotted mode
  3540. * 0 - work in non slotted mode
  3541. * bit4: filter beacon notification
  3542. * bit5: full tx slotted mode. if this flag is set,
  3543. * uCode will perform leaving channel methods in context switch
  3544. * also when working in same channel mode
  3545. * @num_slots: 1 - 10
  3546. */
  3547. struct iwl_wipan_params_cmd {
  3548. __le16 flags;
  3549. u8 reserved;
  3550. u8 num_slots;
  3551. struct iwl_wipan_slot slots[10];
  3552. } __packed;
  3553. /*
  3554. * REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9
  3555. *
  3556. * TODO: Figure out what this is used for,
  3557. * it can only switch between 2.4 GHz
  3558. * channels!!
  3559. */
  3560. struct iwl_wipan_p2p_channel_switch_cmd {
  3561. __le16 channel;
  3562. __le16 reserved;
  3563. };
  3564. /*
  3565. * REPLY_WIPAN_NOA_NOTIFICATION = 0xbc
  3566. *
  3567. * This is used by the device to notify us of the
  3568. * NoA schedule it determined so we can forward it
  3569. * to userspace for inclusion in probe responses.
  3570. *
  3571. * In beacons, the NoA schedule is simply appended
  3572. * to the frame we give the device.
  3573. */
  3574. struct iwl_wipan_noa_descriptor {
  3575. u8 count;
  3576. __le32 duration;
  3577. __le32 interval;
  3578. __le32 starttime;
  3579. } __packed;
  3580. struct iwl_wipan_noa_attribute {
  3581. u8 id;
  3582. __le16 length;
  3583. u8 index;
  3584. u8 ct_window;
  3585. struct iwl_wipan_noa_descriptor descr0, descr1;
  3586. u8 reserved;
  3587. } __packed;
  3588. struct iwl_wipan_noa_notification {
  3589. u32 noa_active;
  3590. struct iwl_wipan_noa_attribute noa_attribute;
  3591. } __packed;
  3592. #endif /* __iwl_commands_h__ */