iwl-commands.h 133 KB

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