iwl-commands.h 143 KB

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