commands.h 130 KB

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