iwl-commands.h 144 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470
  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. /* PAN commands */
  159. REPLY_WIPAN_PARAMS = 0xb2,
  160. REPLY_WIPAN_RXON = 0xb3, /* use REPLY_RXON structure */
  161. REPLY_WIPAN_RXON_TIMING = 0xb4, /* use REPLY_RXON_TIMING structure */
  162. REPLY_WIPAN_RXON_ASSOC = 0xb6, /* use REPLY_RXON_ASSOC structure */
  163. REPLY_WIPAN_QOS_PARAM = 0xb7, /* use REPLY_QOS_PARAM structure */
  164. REPLY_WIPAN_WEPKEY = 0xb8, /* use REPLY_WEPKEY structure */
  165. REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9,
  166. REPLY_WIPAN_NOA_NOTIFICATION = 0xbc,
  167. REPLY_WIPAN_DEACTIVATION_COMPLETE = 0xbd,
  168. REPLY_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. /* following only for 5000 series and up */
  1801. u8 txed; /* number of frames sent */
  1802. u8 txed_2_done; /* number of frames acked */
  1803. } __packed;
  1804. /*
  1805. * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
  1806. *
  1807. * See details under "TXPOWER" in iwl-4965-hw.h.
  1808. */
  1809. struct iwl3945_txpowertable_cmd {
  1810. u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
  1811. u8 reserved;
  1812. __le16 channel;
  1813. struct iwl3945_power_per_rate power[IWL_MAX_RATES];
  1814. } __packed;
  1815. struct iwl4965_txpowertable_cmd {
  1816. u8 band; /* 0: 5 GHz, 1: 2.4 GHz */
  1817. u8 reserved;
  1818. __le16 channel;
  1819. struct iwl4965_tx_power_db tx_power;
  1820. } __packed;
  1821. /**
  1822. * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
  1823. *
  1824. * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
  1825. *
  1826. * NOTE: The table of rates passed to the uCode via the
  1827. * RATE_SCALE command sets up the corresponding order of
  1828. * rates used for all related commands, including rate
  1829. * masks, etc.
  1830. *
  1831. * For example, if you set 9MB (PLCP 0x0f) as the first
  1832. * rate in the rate table, the bit mask for that rate
  1833. * when passed through ofdm_basic_rates on the REPLY_RXON
  1834. * command would be bit 0 (1 << 0)
  1835. */
  1836. struct iwl3945_rate_scaling_info {
  1837. __le16 rate_n_flags;
  1838. u8 try_cnt;
  1839. u8 next_rate_index;
  1840. } __packed;
  1841. struct iwl3945_rate_scaling_cmd {
  1842. u8 table_id;
  1843. u8 reserved[3];
  1844. struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
  1845. } __packed;
  1846. /*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
  1847. #define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0)
  1848. /* # of EDCA prioritized tx fifos */
  1849. #define LINK_QUAL_AC_NUM AC_NUM
  1850. /* # entries in rate scale table to support Tx retries */
  1851. #define LINK_QUAL_MAX_RETRY_NUM 16
  1852. /* Tx antenna selection values */
  1853. #define LINK_QUAL_ANT_A_MSK (1 << 0)
  1854. #define LINK_QUAL_ANT_B_MSK (1 << 1)
  1855. #define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
  1856. /**
  1857. * struct iwl_link_qual_general_params
  1858. *
  1859. * Used in REPLY_TX_LINK_QUALITY_CMD
  1860. */
  1861. struct iwl_link_qual_general_params {
  1862. u8 flags;
  1863. /* No entries at or above this (driver chosen) index contain MIMO */
  1864. u8 mimo_delimiter;
  1865. /* Best single antenna to use for single stream (legacy, SISO). */
  1866. u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */
  1867. /* Best antennas to use for MIMO (unused for 4965, assumes both). */
  1868. u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */
  1869. /*
  1870. * If driver needs to use different initial rates for different
  1871. * EDCA QOS access categories (as implemented by tx fifos 0-3),
  1872. * this table will set that up, by indicating the indexes in the
  1873. * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
  1874. * Otherwise, driver should set all entries to 0.
  1875. *
  1876. * Entry usage:
  1877. * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
  1878. * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
  1879. */
  1880. u8 start_rate_index[LINK_QUAL_AC_NUM];
  1881. } __packed;
  1882. #define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */
  1883. #define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000)
  1884. #define LINK_QUAL_AGG_TIME_LIMIT_MIN (100)
  1885. #define LINK_QUAL_AGG_DISABLE_START_DEF (3)
  1886. #define LINK_QUAL_AGG_DISABLE_START_MAX (255)
  1887. #define LINK_QUAL_AGG_DISABLE_START_MIN (0)
  1888. #define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31)
  1889. #define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63)
  1890. #define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0)
  1891. /**
  1892. * struct iwl_link_qual_agg_params
  1893. *
  1894. * Used in REPLY_TX_LINK_QUALITY_CMD
  1895. */
  1896. struct iwl_link_qual_agg_params {
  1897. /*
  1898. *Maximum number of uSec in aggregation.
  1899. * default set to 4000 (4 milliseconds) if not configured in .cfg
  1900. */
  1901. __le16 agg_time_limit;
  1902. /*
  1903. * Number of Tx retries allowed for a frame, before that frame will
  1904. * no longer be considered for the start of an aggregation sequence
  1905. * (scheduler will then try to tx it as single frame).
  1906. * Driver should set this to 3.
  1907. */
  1908. u8 agg_dis_start_th;
  1909. /*
  1910. * Maximum number of frames in aggregation.
  1911. * 0 = no limit (default). 1 = no aggregation.
  1912. * Other values = max # frames in aggregation.
  1913. */
  1914. u8 agg_frame_cnt_limit;
  1915. __le32 reserved;
  1916. } __packed;
  1917. /*
  1918. * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
  1919. *
  1920. * For agn devices only; 3945 uses REPLY_RATE_SCALE.
  1921. *
  1922. * Each station in the agn device's internal station table has its own table
  1923. * of 16
  1924. * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
  1925. * an ACK is not received. This command replaces the entire table for
  1926. * one station.
  1927. *
  1928. * NOTE: Station must already be in agn device's station table.
  1929. * Use REPLY_ADD_STA.
  1930. *
  1931. * The rate scaling procedures described below work well. Of course, other
  1932. * procedures are possible, and may work better for particular environments.
  1933. *
  1934. *
  1935. * FILLING THE RATE TABLE
  1936. *
  1937. * Given a particular initial rate and mode, as determined by the rate
  1938. * scaling algorithm described below, the Linux driver uses the following
  1939. * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
  1940. * Link Quality command:
  1941. *
  1942. *
  1943. * 1) If using High-throughput (HT) (SISO or MIMO) initial rate:
  1944. * a) Use this same initial rate for first 3 entries.
  1945. * b) Find next lower available rate using same mode (SISO or MIMO),
  1946. * use for next 3 entries. If no lower rate available, switch to
  1947. * legacy mode (no HT40 channel, no MIMO, no short guard interval).
  1948. * c) If using MIMO, set command's mimo_delimiter to number of entries
  1949. * using MIMO (3 or 6).
  1950. * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
  1951. * no MIMO, no short guard interval), at the next lower bit rate
  1952. * (e.g. if second HT bit rate was 54, try 48 legacy), and follow
  1953. * legacy procedure for remaining table entries.
  1954. *
  1955. * 2) If using legacy initial rate:
  1956. * a) Use the initial rate for only one entry.
  1957. * b) For each following entry, reduce the rate to next lower available
  1958. * rate, until reaching the lowest available rate.
  1959. * c) When reducing rate, also switch antenna selection.
  1960. * d) Once lowest available rate is reached, repeat this rate until
  1961. * rate table is filled (16 entries), switching antenna each entry.
  1962. *
  1963. *
  1964. * ACCUMULATING HISTORY
  1965. *
  1966. * The rate scaling algorithm for agn devices, as implemented in Linux driver,
  1967. * uses two sets of frame Tx success history: One for the current/active
  1968. * modulation mode, and one for a speculative/search mode that is being
  1969. * attempted. If the speculative mode turns out to be more effective (i.e.
  1970. * actual transfer rate is better), then the driver continues to use the
  1971. * speculative mode as the new current active mode.
  1972. *
  1973. * Each history set contains, separately for each possible rate, data for a
  1974. * sliding window of the 62 most recent tx attempts at that rate. The data
  1975. * includes a shifting bitmap of success(1)/failure(0), and sums of successful
  1976. * and attempted frames, from which the driver can additionally calculate a
  1977. * success ratio (success / attempted) and number of failures
  1978. * (attempted - success), and control the size of the window (attempted).
  1979. * The driver uses the bit map to remove successes from the success sum, as
  1980. * the oldest tx attempts fall out of the window.
  1981. *
  1982. * When the agn device makes multiple tx attempts for a given frame, each
  1983. * attempt might be at a different rate, and have different modulation
  1984. * characteristics (e.g. antenna, fat channel, short guard interval), as set
  1985. * up in the rate scaling table in the Link Quality command. The driver must
  1986. * determine which rate table entry was used for each tx attempt, to determine
  1987. * which rate-specific history to update, and record only those attempts that
  1988. * match the modulation characteristics of the history set.
  1989. *
  1990. * When using block-ack (aggregation), all frames are transmitted at the same
  1991. * rate, since there is no per-attempt acknowledgment from the destination
  1992. * station. The Tx response struct iwl_tx_resp indicates the Tx rate in
  1993. * rate_n_flags field. After receiving a block-ack, the driver can update
  1994. * history for the entire block all at once.
  1995. *
  1996. *
  1997. * FINDING BEST STARTING RATE:
  1998. *
  1999. * When working with a selected initial modulation mode (see below), the
  2000. * driver attempts to find a best initial rate. The initial rate is the
  2001. * first entry in the Link Quality command's rate table.
  2002. *
  2003. * 1) Calculate actual throughput (success ratio * expected throughput, see
  2004. * table below) for current initial rate. Do this only if enough frames
  2005. * have been attempted to make the value meaningful: at least 6 failed
  2006. * tx attempts, or at least 8 successes. If not enough, don't try rate
  2007. * scaling yet.
  2008. *
  2009. * 2) Find available rates adjacent to current initial rate. Available means:
  2010. * a) supported by hardware &&
  2011. * b) supported by association &&
  2012. * c) within any constraints selected by user
  2013. *
  2014. * 3) Gather measured throughputs for adjacent rates. These might not have
  2015. * enough history to calculate a throughput. That's okay, we might try
  2016. * using one of them anyway!
  2017. *
  2018. * 4) Try decreasing rate if, for current rate:
  2019. * a) success ratio is < 15% ||
  2020. * b) lower adjacent rate has better measured throughput ||
  2021. * c) higher adjacent rate has worse throughput, and lower is unmeasured
  2022. *
  2023. * As a sanity check, if decrease was determined above, leave rate
  2024. * unchanged if:
  2025. * a) lower rate unavailable
  2026. * b) success ratio at current rate > 85% (very good)
  2027. * c) current measured throughput is better than expected throughput
  2028. * of lower rate (under perfect 100% tx conditions, see table below)
  2029. *
  2030. * 5) Try increasing rate if, for current rate:
  2031. * a) success ratio is < 15% ||
  2032. * b) both adjacent rates' throughputs are unmeasured (try it!) ||
  2033. * b) higher adjacent rate has better measured throughput ||
  2034. * c) lower adjacent rate has worse throughput, and higher is unmeasured
  2035. *
  2036. * As a sanity check, if increase was determined above, leave rate
  2037. * unchanged if:
  2038. * a) success ratio at current rate < 70%. This is not particularly
  2039. * good performance; higher rate is sure to have poorer success.
  2040. *
  2041. * 6) Re-evaluate the rate after each tx frame. If working with block-
  2042. * acknowledge, history and statistics may be calculated for the entire
  2043. * block (including prior history that fits within the history windows),
  2044. * before re-evaluation.
  2045. *
  2046. * FINDING BEST STARTING MODULATION MODE:
  2047. *
  2048. * After working with a modulation mode for a "while" (and doing rate scaling),
  2049. * the driver searches for a new initial mode in an attempt to improve
  2050. * throughput. The "while" is measured by numbers of attempted frames:
  2051. *
  2052. * For legacy mode, search for new mode after:
  2053. * 480 successful frames, or 160 failed frames
  2054. * For high-throughput modes (SISO or MIMO), search for new mode after:
  2055. * 4500 successful frames, or 400 failed frames
  2056. *
  2057. * Mode switch possibilities are (3 for each mode):
  2058. *
  2059. * For legacy:
  2060. * Change antenna, try SISO (if HT association), try MIMO (if HT association)
  2061. * For SISO:
  2062. * Change antenna, try MIMO, try shortened guard interval (SGI)
  2063. * For MIMO:
  2064. * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
  2065. *
  2066. * When trying a new mode, use the same bit rate as the old/current mode when
  2067. * trying antenna switches and shortened guard interval. When switching to
  2068. * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
  2069. * for which the expected throughput (under perfect conditions) is about the
  2070. * same or slightly better than the actual measured throughput delivered by
  2071. * the old/current mode.
  2072. *
  2073. * Actual throughput can be estimated by multiplying the expected throughput
  2074. * by the success ratio (successful / attempted tx frames). Frame size is
  2075. * not considered in this calculation; it assumes that frame size will average
  2076. * out to be fairly consistent over several samples. The following are
  2077. * metric values for expected throughput assuming 100% success ratio.
  2078. * Only G band has support for CCK rates:
  2079. *
  2080. * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60
  2081. *
  2082. * G: 7 13 35 58 40 57 72 98 121 154 177 186 186
  2083. * A: 0 0 0 0 40 57 72 98 121 154 177 186 186
  2084. * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202
  2085. * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211
  2086. * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251
  2087. * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257
  2088. * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257
  2089. * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264
  2090. * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289
  2091. * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293
  2092. *
  2093. * After the new mode has been tried for a short while (minimum of 6 failed
  2094. * frames or 8 successful frames), compare success ratio and actual throughput
  2095. * estimate of the new mode with the old. If either is better with the new
  2096. * mode, continue to use the new mode.
  2097. *
  2098. * Continue comparing modes until all 3 possibilities have been tried.
  2099. * If moving from legacy to HT, try all 3 possibilities from the new HT
  2100. * mode. After trying all 3, a best mode is found. Continue to use this mode
  2101. * for the longer "while" described above (e.g. 480 successful frames for
  2102. * legacy), and then repeat the search process.
  2103. *
  2104. */
  2105. struct iwl_link_quality_cmd {
  2106. /* Index of destination/recipient station in uCode's station table */
  2107. u8 sta_id;
  2108. u8 reserved1;
  2109. __le16 control; /* not used */
  2110. struct iwl_link_qual_general_params general_params;
  2111. struct iwl_link_qual_agg_params agg_params;
  2112. /*
  2113. * Rate info; when using rate-scaling, Tx command's initial_rate_index
  2114. * specifies 1st Tx rate attempted, via index into this table.
  2115. * agn devices works its way through table when retrying Tx.
  2116. */
  2117. struct {
  2118. __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */
  2119. } rs_table[LINK_QUAL_MAX_RETRY_NUM];
  2120. __le32 reserved2;
  2121. } __packed;
  2122. /*
  2123. * BT configuration enable flags:
  2124. * bit 0 - 1: BT channel announcement enabled
  2125. * 0: disable
  2126. * bit 1 - 1: priority of BT device enabled
  2127. * 0: disable
  2128. * bit 2 - 1: BT 2 wire support enabled
  2129. * 0: disable
  2130. */
  2131. #define BT_COEX_DISABLE (0x0)
  2132. #define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
  2133. #define BT_ENABLE_PRIORITY BIT(1)
  2134. #define BT_ENABLE_2_WIRE BIT(2)
  2135. #define BT_COEX_DISABLE (0x0)
  2136. #define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
  2137. #define BT_LEAD_TIME_MIN (0x0)
  2138. #define BT_LEAD_TIME_DEF (0x1E)
  2139. #define BT_LEAD_TIME_MAX (0xFF)
  2140. #define BT_MAX_KILL_MIN (0x1)
  2141. #define BT_MAX_KILL_DEF (0x5)
  2142. #define BT_MAX_KILL_MAX (0xFF)
  2143. #define BT_DURATION_LIMIT_DEF 625
  2144. #define BT_DURATION_LIMIT_MAX 1250
  2145. #define BT_DURATION_LIMIT_MIN 625
  2146. #define BT_ON_THRESHOLD_DEF 4
  2147. #define BT_ON_THRESHOLD_MAX 1000
  2148. #define BT_ON_THRESHOLD_MIN 1
  2149. #define BT_FRAG_THRESHOLD_DEF 0
  2150. #define BT_FRAG_THRESHOLD_MAX 0
  2151. #define BT_FRAG_THRESHOLD_MIN 0
  2152. #define BT_AGG_THRESHOLD_DEF 1200
  2153. #define BT_AGG_THRESHOLD_MAX 8000
  2154. #define BT_AGG_THRESHOLD_MIN 400
  2155. /*
  2156. * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
  2157. *
  2158. * 3945 and agn devices support hardware handshake with Bluetooth device on
  2159. * same platform. Bluetooth device alerts wireless device when it will Tx;
  2160. * wireless device can delay or kill its own Tx to accommodate.
  2161. */
  2162. struct iwl_bt_cmd {
  2163. u8 flags;
  2164. u8 lead_time;
  2165. u8 max_kill;
  2166. u8 reserved;
  2167. __le32 kill_ack_mask;
  2168. __le32 kill_cts_mask;
  2169. } __packed;
  2170. #define IWLAGN_BT_FLAG_CHANNEL_INHIBITION BIT(0)
  2171. #define IWLAGN_BT_FLAG_COEX_MODE_MASK (BIT(3)|BIT(4)|BIT(5))
  2172. #define IWLAGN_BT_FLAG_COEX_MODE_SHIFT 3
  2173. #define IWLAGN_BT_FLAG_COEX_MODE_DISABLED 0
  2174. #define IWLAGN_BT_FLAG_COEX_MODE_LEGACY_2W 1
  2175. #define IWLAGN_BT_FLAG_COEX_MODE_3W 2
  2176. #define IWLAGN_BT_FLAG_COEX_MODE_4W 3
  2177. #define IWLAGN_BT_FLAG_UCODE_DEFAULT BIT(6)
  2178. /* Disable Sync PSPoll on SCO/eSCO */
  2179. #define IWLAGN_BT_FLAG_SYNC_2_BT_DISABLE BIT(7)
  2180. #define IWLAGN_BT_PRIO_BOOST_MAX 0xFF
  2181. #define IWLAGN_BT_PRIO_BOOST_MIN 0x00
  2182. #define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0
  2183. #define IWLAGN_BT_MAX_KILL_DEFAULT 5
  2184. #define IWLAGN_BT3_T7_DEFAULT 1
  2185. #define IWLAGN_BT_KILL_ACK_MASK_DEFAULT cpu_to_le32(0xffff0000)
  2186. #define IWLAGN_BT_KILL_CTS_MASK_DEFAULT cpu_to_le32(0xffff0000)
  2187. #define IWLAGN_BT_KILL_ACK_CTS_MASK_SCO cpu_to_le32(0xffffffff)
  2188. #define IWLAGN_BT3_PRIO_SAMPLE_DEFAULT 2
  2189. #define IWLAGN_BT3_T2_DEFAULT 0xc
  2190. #define IWLAGN_BT_VALID_ENABLE_FLAGS cpu_to_le16(BIT(0))
  2191. #define IWLAGN_BT_VALID_BOOST cpu_to_le16(BIT(1))
  2192. #define IWLAGN_BT_VALID_MAX_KILL cpu_to_le16(BIT(2))
  2193. #define IWLAGN_BT_VALID_3W_TIMERS cpu_to_le16(BIT(3))
  2194. #define IWLAGN_BT_VALID_KILL_ACK_MASK cpu_to_le16(BIT(4))
  2195. #define IWLAGN_BT_VALID_KILL_CTS_MASK cpu_to_le16(BIT(5))
  2196. #define IWLAGN_BT_VALID_BT4_TIMES cpu_to_le16(BIT(6))
  2197. #define IWLAGN_BT_VALID_3W_LUT cpu_to_le16(BIT(7))
  2198. #define IWLAGN_BT_ALL_VALID_MSK (IWLAGN_BT_VALID_ENABLE_FLAGS | \
  2199. IWLAGN_BT_VALID_BOOST | \
  2200. IWLAGN_BT_VALID_MAX_KILL | \
  2201. IWLAGN_BT_VALID_3W_TIMERS | \
  2202. IWLAGN_BT_VALID_KILL_ACK_MASK | \
  2203. IWLAGN_BT_VALID_KILL_CTS_MASK | \
  2204. IWLAGN_BT_VALID_BT4_TIMES | \
  2205. IWLAGN_BT_VALID_3W_LUT)
  2206. struct iwlagn_bt_cmd {
  2207. u8 flags;
  2208. u8 ledtime; /* unused */
  2209. u8 max_kill;
  2210. u8 bt3_timer_t7_value;
  2211. __le32 kill_ack_mask;
  2212. __le32 kill_cts_mask;
  2213. u8 bt3_prio_sample_time;
  2214. u8 bt3_timer_t2_value;
  2215. __le16 bt4_reaction_time; /* unused */
  2216. __le32 bt3_lookup_table[12];
  2217. __le16 bt4_decision_time; /* unused */
  2218. __le16 valid;
  2219. u8 prio_boost;
  2220. /*
  2221. * set IWLAGN_BT_VALID_BOOST to "1" in "valid" bitmask
  2222. * if configure the following patterns
  2223. */
  2224. u8 tx_prio_boost; /* SW boost of WiFi tx priority */
  2225. __le16 rx_prio_boost; /* SW boost of WiFi rx priority */
  2226. };
  2227. #define IWLAGN_BT_SCO_ACTIVE cpu_to_le32(BIT(0))
  2228. struct iwlagn_bt_sco_cmd {
  2229. __le32 flags;
  2230. };
  2231. /******************************************************************************
  2232. * (6)
  2233. * Spectrum Management (802.11h) Commands, Responses, Notifications:
  2234. *
  2235. *****************************************************************************/
  2236. /*
  2237. * Spectrum Management
  2238. */
  2239. #define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \
  2240. RXON_FILTER_CTL2HOST_MSK | \
  2241. RXON_FILTER_ACCEPT_GRP_MSK | \
  2242. RXON_FILTER_DIS_DECRYPT_MSK | \
  2243. RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
  2244. RXON_FILTER_ASSOC_MSK | \
  2245. RXON_FILTER_BCON_AWARE_MSK)
  2246. struct iwl_measure_channel {
  2247. __le32 duration; /* measurement duration in extended beacon
  2248. * format */
  2249. u8 channel; /* channel to measure */
  2250. u8 type; /* see enum iwl_measure_type */
  2251. __le16 reserved;
  2252. } __packed;
  2253. /*
  2254. * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
  2255. */
  2256. struct iwl_spectrum_cmd {
  2257. __le16 len; /* number of bytes starting from token */
  2258. u8 token; /* token id */
  2259. u8 id; /* measurement id -- 0 or 1 */
  2260. u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */
  2261. u8 periodic; /* 1 = periodic */
  2262. __le16 path_loss_timeout;
  2263. __le32 start_time; /* start time in extended beacon format */
  2264. __le32 reserved2;
  2265. __le32 flags; /* rxon flags */
  2266. __le32 filter_flags; /* rxon filter flags */
  2267. __le16 channel_count; /* minimum 1, maximum 10 */
  2268. __le16 reserved3;
  2269. struct iwl_measure_channel channels[10];
  2270. } __packed;
  2271. /*
  2272. * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
  2273. */
  2274. struct iwl_spectrum_resp {
  2275. u8 token;
  2276. u8 id; /* id of the prior command replaced, or 0xff */
  2277. __le16 status; /* 0 - command will be handled
  2278. * 1 - cannot handle (conflicts with another
  2279. * measurement) */
  2280. } __packed;
  2281. enum iwl_measurement_state {
  2282. IWL_MEASUREMENT_START = 0,
  2283. IWL_MEASUREMENT_STOP = 1,
  2284. };
  2285. enum iwl_measurement_status {
  2286. IWL_MEASUREMENT_OK = 0,
  2287. IWL_MEASUREMENT_CONCURRENT = 1,
  2288. IWL_MEASUREMENT_CSA_CONFLICT = 2,
  2289. IWL_MEASUREMENT_TGH_CONFLICT = 3,
  2290. /* 4-5 reserved */
  2291. IWL_MEASUREMENT_STOPPED = 6,
  2292. IWL_MEASUREMENT_TIMEOUT = 7,
  2293. IWL_MEASUREMENT_PERIODIC_FAILED = 8,
  2294. };
  2295. #define NUM_ELEMENTS_IN_HISTOGRAM 8
  2296. struct iwl_measurement_histogram {
  2297. __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */
  2298. __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */
  2299. } __packed;
  2300. /* clear channel availability counters */
  2301. struct iwl_measurement_cca_counters {
  2302. __le32 ofdm;
  2303. __le32 cck;
  2304. } __packed;
  2305. enum iwl_measure_type {
  2306. IWL_MEASURE_BASIC = (1 << 0),
  2307. IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
  2308. IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
  2309. IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
  2310. IWL_MEASURE_FRAME = (1 << 4),
  2311. /* bits 5:6 are reserved */
  2312. IWL_MEASURE_IDLE = (1 << 7),
  2313. };
  2314. /*
  2315. * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
  2316. */
  2317. struct iwl_spectrum_notification {
  2318. u8 id; /* measurement id -- 0 or 1 */
  2319. u8 token;
  2320. u8 channel_index; /* index in measurement channel list */
  2321. u8 state; /* 0 - start, 1 - stop */
  2322. __le32 start_time; /* lower 32-bits of TSF */
  2323. u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */
  2324. u8 channel;
  2325. u8 type; /* see enum iwl_measurement_type */
  2326. u8 reserved1;
  2327. /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only
  2328. * valid if applicable for measurement type requested. */
  2329. __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */
  2330. __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */
  2331. __le32 cca_time; /* channel load time in usecs */
  2332. u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 -
  2333. * unidentified */
  2334. u8 reserved2[3];
  2335. struct iwl_measurement_histogram histogram;
  2336. __le32 stop_time; /* lower 32-bits of TSF */
  2337. __le32 status; /* see iwl_measurement_status */
  2338. } __packed;
  2339. /******************************************************************************
  2340. * (7)
  2341. * Power Management Commands, Responses, Notifications:
  2342. *
  2343. *****************************************************************************/
  2344. /**
  2345. * struct iwl_powertable_cmd - Power Table Command
  2346. * @flags: See below:
  2347. *
  2348. * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
  2349. *
  2350. * PM allow:
  2351. * bit 0 - '0' Driver not allow power management
  2352. * '1' Driver allow PM (use rest of parameters)
  2353. *
  2354. * uCode send sleep notifications:
  2355. * bit 1 - '0' Don't send sleep notification
  2356. * '1' send sleep notification (SEND_PM_NOTIFICATION)
  2357. *
  2358. * Sleep over DTIM
  2359. * bit 2 - '0' PM have to walk up every DTIM
  2360. * '1' PM could sleep over DTIM till listen Interval.
  2361. *
  2362. * PCI power managed
  2363. * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
  2364. * '1' !(PCI_CFG_LINK_CTRL & 0x1)
  2365. *
  2366. * Fast PD
  2367. * bit 4 - '1' Put radio to sleep when receiving frame for others
  2368. *
  2369. * Force sleep Modes
  2370. * bit 31/30- '00' use both mac/xtal sleeps
  2371. * '01' force Mac sleep
  2372. * '10' force xtal sleep
  2373. * '11' Illegal set
  2374. *
  2375. * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
  2376. * ucode assume sleep over DTIM is allowed and we don't need to wake up
  2377. * for every DTIM.
  2378. */
  2379. #define IWL_POWER_VEC_SIZE 5
  2380. #define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0))
  2381. #define IWL_POWER_POWER_SAVE_ENA_MSK cpu_to_le16(BIT(0))
  2382. #define IWL_POWER_POWER_MANAGEMENT_ENA_MSK cpu_to_le16(BIT(1))
  2383. #define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(BIT(2))
  2384. #define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3))
  2385. #define IWL_POWER_FAST_PD cpu_to_le16(BIT(4))
  2386. #define IWL_POWER_BEACON_FILTERING cpu_to_le16(BIT(5))
  2387. #define IWL_POWER_SHADOW_REG_ENA cpu_to_le16(BIT(6))
  2388. #define IWL_POWER_CT_KILL_SET cpu_to_le16(BIT(7))
  2389. #define IWL_POWER_BT_SCO_ENA cpu_to_le16(BIT(8))
  2390. #define IWL_POWER_ADVANCE_PM_ENA_MSK cpu_to_le16(BIT(9))
  2391. struct iwl3945_powertable_cmd {
  2392. __le16 flags;
  2393. u8 reserved[2];
  2394. __le32 rx_data_timeout;
  2395. __le32 tx_data_timeout;
  2396. __le32 sleep_interval[IWL_POWER_VEC_SIZE];
  2397. } __packed;
  2398. struct iwl_powertable_cmd {
  2399. __le16 flags;
  2400. u8 keep_alive_seconds; /* 3945 reserved */
  2401. u8 debug_flags; /* 3945 reserved */
  2402. __le32 rx_data_timeout;
  2403. __le32 tx_data_timeout;
  2404. __le32 sleep_interval[IWL_POWER_VEC_SIZE];
  2405. __le32 keep_alive_beacons;
  2406. } __packed;
  2407. /*
  2408. * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
  2409. * all devices identical.
  2410. */
  2411. struct iwl_sleep_notification {
  2412. u8 pm_sleep_mode;
  2413. u8 pm_wakeup_src;
  2414. __le16 reserved;
  2415. __le32 sleep_time;
  2416. __le32 tsf_low;
  2417. __le32 bcon_timer;
  2418. } __packed;
  2419. /* Sleep states. all devices identical. */
  2420. enum {
  2421. IWL_PM_NO_SLEEP = 0,
  2422. IWL_PM_SLP_MAC = 1,
  2423. IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
  2424. IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
  2425. IWL_PM_SLP_PHY = 4,
  2426. IWL_PM_SLP_REPENT = 5,
  2427. IWL_PM_WAKEUP_BY_TIMER = 6,
  2428. IWL_PM_WAKEUP_BY_DRIVER = 7,
  2429. IWL_PM_WAKEUP_BY_RFKILL = 8,
  2430. /* 3 reserved */
  2431. IWL_PM_NUM_OF_MODES = 12,
  2432. };
  2433. /*
  2434. * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
  2435. */
  2436. #define CARD_STATE_CMD_DISABLE 0x00 /* Put card to sleep */
  2437. #define CARD_STATE_CMD_ENABLE 0x01 /* Wake up card */
  2438. #define CARD_STATE_CMD_HALT 0x02 /* Power down permanently */
  2439. struct iwl_card_state_cmd {
  2440. __le32 status; /* CARD_STATE_CMD_* request new power state */
  2441. } __packed;
  2442. /*
  2443. * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
  2444. */
  2445. struct iwl_card_state_notif {
  2446. __le32 flags;
  2447. } __packed;
  2448. #define HW_CARD_DISABLED 0x01
  2449. #define SW_CARD_DISABLED 0x02
  2450. #define CT_CARD_DISABLED 0x04
  2451. #define RXON_CARD_DISABLED 0x10
  2452. struct iwl_ct_kill_config {
  2453. __le32 reserved;
  2454. __le32 critical_temperature_M;
  2455. __le32 critical_temperature_R;
  2456. } __packed;
  2457. /* 1000, and 6x00 */
  2458. struct iwl_ct_kill_throttling_config {
  2459. __le32 critical_temperature_exit;
  2460. __le32 reserved;
  2461. __le32 critical_temperature_enter;
  2462. } __packed;
  2463. /******************************************************************************
  2464. * (8)
  2465. * Scan Commands, Responses, Notifications:
  2466. *
  2467. *****************************************************************************/
  2468. #define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
  2469. #define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1)
  2470. /**
  2471. * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
  2472. *
  2473. * One for each channel in the scan list.
  2474. * Each channel can independently select:
  2475. * 1) SSID for directed active scans
  2476. * 2) Txpower setting (for rate specified within Tx command)
  2477. * 3) How long to stay on-channel (behavior may be modified by quiet_time,
  2478. * quiet_plcp_th, good_CRC_th)
  2479. *
  2480. * To avoid uCode errors, make sure the following are true (see comments
  2481. * under struct iwl_scan_cmd about max_out_time and quiet_time):
  2482. * 1) If using passive_dwell (i.e. passive_dwell != 0):
  2483. * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
  2484. * 2) quiet_time <= active_dwell
  2485. * 3) If restricting off-channel time (i.e. max_out_time !=0):
  2486. * passive_dwell < max_out_time
  2487. * active_dwell < max_out_time
  2488. */
  2489. /* FIXME: rename to AP1, remove tpc */
  2490. struct iwl3945_scan_channel {
  2491. /*
  2492. * type is defined as:
  2493. * 0:0 1 = active, 0 = passive
  2494. * 1:4 SSID direct bit map; if a bit is set, then corresponding
  2495. * SSID IE is transmitted in probe request.
  2496. * 5:7 reserved
  2497. */
  2498. u8 type;
  2499. u8 channel; /* band is selected by iwl3945_scan_cmd "flags" field */
  2500. struct iwl3945_tx_power tpc;
  2501. __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
  2502. __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
  2503. } __packed;
  2504. /* set number of direct probes u8 type */
  2505. #define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
  2506. struct iwl_scan_channel {
  2507. /*
  2508. * type is defined as:
  2509. * 0:0 1 = active, 0 = passive
  2510. * 1:20 SSID direct bit map; if a bit is set, then corresponding
  2511. * SSID IE is transmitted in probe request.
  2512. * 21:31 reserved
  2513. */
  2514. __le32 type;
  2515. __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */
  2516. u8 tx_gain; /* gain for analog radio */
  2517. u8 dsp_atten; /* gain for DSP */
  2518. __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */
  2519. __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */
  2520. } __packed;
  2521. /* set number of direct probes __le32 type */
  2522. #define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
  2523. /**
  2524. * struct iwl_ssid_ie - directed scan network information element
  2525. *
  2526. * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in
  2527. * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel;
  2528. * each channel may select different ssids from among the 20 (4) entries.
  2529. * SSID IEs get transmitted in reverse order of entry.
  2530. */
  2531. struct iwl_ssid_ie {
  2532. u8 id;
  2533. u8 len;
  2534. u8 ssid[32];
  2535. } __packed;
  2536. #define PROBE_OPTION_MAX_3945 4
  2537. #define PROBE_OPTION_MAX 20
  2538. #define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF)
  2539. #define IWL_GOOD_CRC_TH_DISABLED 0
  2540. #define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
  2541. #define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
  2542. #define IWL_MAX_SCAN_SIZE 1024
  2543. #define IWL_MAX_CMD_SIZE 4096
  2544. /*
  2545. * REPLY_SCAN_CMD = 0x80 (command)
  2546. *
  2547. * The hardware scan command is very powerful; the driver can set it up to
  2548. * maintain (relatively) normal network traffic while doing a scan in the
  2549. * background. The max_out_time and suspend_time control the ratio of how
  2550. * long the device stays on an associated network channel ("service channel")
  2551. * vs. how long it's away from the service channel, i.e. tuned to other channels
  2552. * for scanning.
  2553. *
  2554. * max_out_time is the max time off-channel (in usec), and suspend_time
  2555. * is how long (in "extended beacon" format) that the scan is "suspended"
  2556. * after returning to the service channel. That is, suspend_time is the
  2557. * time that we stay on the service channel, doing normal work, between
  2558. * scan segments. The driver may set these parameters differently to support
  2559. * scanning when associated vs. not associated, and light vs. heavy traffic
  2560. * loads when associated.
  2561. *
  2562. * After receiving this command, the device's scan engine does the following;
  2563. *
  2564. * 1) Sends SCAN_START notification to driver
  2565. * 2) Checks to see if it has time to do scan for one channel
  2566. * 3) Sends NULL packet, with power-save (PS) bit set to 1,
  2567. * to tell AP that we're going off-channel
  2568. * 4) Tunes to first channel in scan list, does active or passive scan
  2569. * 5) Sends SCAN_RESULT notification to driver
  2570. * 6) Checks to see if it has time to do scan on *next* channel in list
  2571. * 7) Repeats 4-6 until it no longer has time to scan the next channel
  2572. * before max_out_time expires
  2573. * 8) Returns to service channel
  2574. * 9) Sends NULL packet with PS=0 to tell AP that we're back
  2575. * 10) Stays on service channel until suspend_time expires
  2576. * 11) Repeats entire process 2-10 until list is complete
  2577. * 12) Sends SCAN_COMPLETE notification
  2578. *
  2579. * For fast, efficient scans, the scan command also has support for staying on
  2580. * a channel for just a short time, if doing active scanning and getting no
  2581. * responses to the transmitted probe request. This time is controlled by
  2582. * quiet_time, and the number of received packets below which a channel is
  2583. * considered "quiet" is controlled by quiet_plcp_threshold.
  2584. *
  2585. * For active scanning on channels that have regulatory restrictions against
  2586. * blindly transmitting, the scan can listen before transmitting, to make sure
  2587. * that there is already legitimate activity on the channel. If enough
  2588. * packets are cleanly received on the channel (controlled by good_CRC_th,
  2589. * typical value 1), the scan engine starts transmitting probe requests.
  2590. *
  2591. * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
  2592. *
  2593. * To avoid uCode errors, see timing restrictions described under
  2594. * struct iwl_scan_channel.
  2595. */
  2596. struct iwl3945_scan_cmd {
  2597. __le16 len;
  2598. u8 reserved0;
  2599. u8 channel_count; /* # channels in channel list */
  2600. __le16 quiet_time; /* dwell only this # millisecs on quiet channel
  2601. * (only for active scan) */
  2602. __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
  2603. __le16 good_CRC_th; /* passive -> active promotion threshold */
  2604. __le16 reserved1;
  2605. __le32 max_out_time; /* max usec to be away from associated (service)
  2606. * channel */
  2607. __le32 suspend_time; /* pause scan this long (in "extended beacon
  2608. * format") when returning to service channel:
  2609. * 3945; 31:24 # beacons, 19:0 additional usec,
  2610. * 4965; 31:22 # beacons, 21:0 additional usec.
  2611. */
  2612. __le32 flags; /* RXON_FLG_* */
  2613. __le32 filter_flags; /* RXON_FILTER_* */
  2614. /* For active scans (set to all-0s for passive scans).
  2615. * Does not include payload. Must specify Tx rate; no rate scaling. */
  2616. struct iwl3945_tx_cmd tx_cmd;
  2617. /* For directed active scans (set to all-0s otherwise) */
  2618. struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
  2619. /*
  2620. * Probe request frame, followed by channel list.
  2621. *
  2622. * Size of probe request frame is specified by byte count in tx_cmd.
  2623. * Channel list follows immediately after probe request frame.
  2624. * Number of channels in list is specified by channel_count.
  2625. * Each channel in list is of type:
  2626. *
  2627. * struct iwl3945_scan_channel channels[0];
  2628. *
  2629. * NOTE: Only one band of channels can be scanned per pass. You
  2630. * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
  2631. * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
  2632. * before requesting another scan.
  2633. */
  2634. u8 data[0];
  2635. } __packed;
  2636. struct iwl_scan_cmd {
  2637. __le16 len;
  2638. u8 reserved0;
  2639. u8 channel_count; /* # channels in channel list */
  2640. __le16 quiet_time; /* dwell only this # millisecs on quiet channel
  2641. * (only for active scan) */
  2642. __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
  2643. __le16 good_CRC_th; /* passive -> active promotion threshold */
  2644. __le16 rx_chain; /* RXON_RX_CHAIN_* */
  2645. __le32 max_out_time; /* max usec to be away from associated (service)
  2646. * channel */
  2647. __le32 suspend_time; /* pause scan this long (in "extended beacon
  2648. * format") when returning to service chnl:
  2649. * 3945; 31:24 # beacons, 19:0 additional usec,
  2650. * 4965; 31:22 # beacons, 21:0 additional usec.
  2651. */
  2652. __le32 flags; /* RXON_FLG_* */
  2653. __le32 filter_flags; /* RXON_FILTER_* */
  2654. /* For active scans (set to all-0s for passive scans).
  2655. * Does not include payload. Must specify Tx rate; no rate scaling. */
  2656. struct iwl_tx_cmd tx_cmd;
  2657. /* For directed active scans (set to all-0s otherwise) */
  2658. struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
  2659. /*
  2660. * Probe request frame, followed by channel list.
  2661. *
  2662. * Size of probe request frame is specified by byte count in tx_cmd.
  2663. * Channel list follows immediately after probe request frame.
  2664. * Number of channels in list is specified by channel_count.
  2665. * Each channel in list is of type:
  2666. *
  2667. * struct iwl_scan_channel channels[0];
  2668. *
  2669. * NOTE: Only one band of channels can be scanned per pass. You
  2670. * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
  2671. * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
  2672. * before requesting another scan.
  2673. */
  2674. u8 data[0];
  2675. } __packed;
  2676. /* Can abort will notify by complete notification with abort status. */
  2677. #define CAN_ABORT_STATUS cpu_to_le32(0x1)
  2678. /* complete notification statuses */
  2679. #define ABORT_STATUS 0x2
  2680. /*
  2681. * REPLY_SCAN_CMD = 0x80 (response)
  2682. */
  2683. struct iwl_scanreq_notification {
  2684. __le32 status; /* 1: okay, 2: cannot fulfill request */
  2685. } __packed;
  2686. /*
  2687. * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
  2688. */
  2689. struct iwl_scanstart_notification {
  2690. __le32 tsf_low;
  2691. __le32 tsf_high;
  2692. __le32 beacon_timer;
  2693. u8 channel;
  2694. u8 band;
  2695. u8 reserved[2];
  2696. __le32 status;
  2697. } __packed;
  2698. #define SCAN_OWNER_STATUS 0x1;
  2699. #define MEASURE_OWNER_STATUS 0x2;
  2700. #define IWL_PROBE_STATUS_OK 0
  2701. #define IWL_PROBE_STATUS_TX_FAILED BIT(0)
  2702. /* error statuses combined with TX_FAILED */
  2703. #define IWL_PROBE_STATUS_FAIL_TTL BIT(1)
  2704. #define IWL_PROBE_STATUS_FAIL_BT BIT(2)
  2705. #define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
  2706. /*
  2707. * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
  2708. */
  2709. struct iwl_scanresults_notification {
  2710. u8 channel;
  2711. u8 band;
  2712. u8 probe_status;
  2713. u8 num_probe_not_sent; /* not enough time to send */
  2714. __le32 tsf_low;
  2715. __le32 tsf_high;
  2716. __le32 statistics[NUMBER_OF_STATISTICS];
  2717. } __packed;
  2718. /*
  2719. * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
  2720. */
  2721. struct iwl_scancomplete_notification {
  2722. u8 scanned_channels;
  2723. u8 status;
  2724. u8 bt_status; /* BT On/Off status */
  2725. u8 last_channel;
  2726. __le32 tsf_low;
  2727. __le32 tsf_high;
  2728. } __packed;
  2729. /******************************************************************************
  2730. * (9)
  2731. * IBSS/AP Commands and Notifications:
  2732. *
  2733. *****************************************************************************/
  2734. enum iwl_ibss_manager {
  2735. IWL_NOT_IBSS_MANAGER = 0,
  2736. IWL_IBSS_MANAGER = 1,
  2737. };
  2738. /*
  2739. * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
  2740. */
  2741. struct iwl3945_beacon_notif {
  2742. struct iwl3945_tx_resp beacon_notify_hdr;
  2743. __le32 low_tsf;
  2744. __le32 high_tsf;
  2745. __le32 ibss_mgr_status;
  2746. } __packed;
  2747. struct iwl4965_beacon_notif {
  2748. struct iwl4965_tx_resp beacon_notify_hdr;
  2749. __le32 low_tsf;
  2750. __le32 high_tsf;
  2751. __le32 ibss_mgr_status;
  2752. } __packed;
  2753. struct iwlagn_beacon_notif {
  2754. struct iwlagn_tx_resp beacon_notify_hdr;
  2755. __le32 low_tsf;
  2756. __le32 high_tsf;
  2757. __le32 ibss_mgr_status;
  2758. } __packed;
  2759. /*
  2760. * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
  2761. */
  2762. struct iwl3945_tx_beacon_cmd {
  2763. struct iwl3945_tx_cmd tx;
  2764. __le16 tim_idx;
  2765. u8 tim_size;
  2766. u8 reserved1;
  2767. struct ieee80211_hdr frame[0]; /* beacon frame */
  2768. } __packed;
  2769. struct iwl_tx_beacon_cmd {
  2770. struct iwl_tx_cmd tx;
  2771. __le16 tim_idx;
  2772. u8 tim_size;
  2773. u8 reserved1;
  2774. struct ieee80211_hdr frame[0]; /* beacon frame */
  2775. } __packed;
  2776. /******************************************************************************
  2777. * (10)
  2778. * Statistics Commands and Notifications:
  2779. *
  2780. *****************************************************************************/
  2781. #define IWL_TEMP_CONVERT 260
  2782. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  2783. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  2784. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  2785. /* Used for passing to driver number of successes and failures per rate */
  2786. struct rate_histogram {
  2787. union {
  2788. __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  2789. __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  2790. __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  2791. } success;
  2792. union {
  2793. __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  2794. __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  2795. __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  2796. } failed;
  2797. } __packed;
  2798. /* statistics command response */
  2799. struct iwl39_statistics_rx_phy {
  2800. __le32 ina_cnt;
  2801. __le32 fina_cnt;
  2802. __le32 plcp_err;
  2803. __le32 crc32_err;
  2804. __le32 overrun_err;
  2805. __le32 early_overrun_err;
  2806. __le32 crc32_good;
  2807. __le32 false_alarm_cnt;
  2808. __le32 fina_sync_err_cnt;
  2809. __le32 sfd_timeout;
  2810. __le32 fina_timeout;
  2811. __le32 unresponded_rts;
  2812. __le32 rxe_frame_limit_overrun;
  2813. __le32 sent_ack_cnt;
  2814. __le32 sent_cts_cnt;
  2815. } __packed;
  2816. struct iwl39_statistics_rx_non_phy {
  2817. __le32 bogus_cts; /* CTS received when not expecting CTS */
  2818. __le32 bogus_ack; /* ACK received when not expecting ACK */
  2819. __le32 non_bssid_frames; /* number of frames with BSSID that
  2820. * doesn't belong to the STA BSSID */
  2821. __le32 filtered_frames; /* count frames that were dumped in the
  2822. * filtering process */
  2823. __le32 non_channel_beacons; /* beacons with our bss id but not on
  2824. * our serving channel */
  2825. } __packed;
  2826. struct iwl39_statistics_rx {
  2827. struct iwl39_statistics_rx_phy ofdm;
  2828. struct iwl39_statistics_rx_phy cck;
  2829. struct iwl39_statistics_rx_non_phy general;
  2830. } __packed;
  2831. struct iwl39_statistics_tx {
  2832. __le32 preamble_cnt;
  2833. __le32 rx_detected_cnt;
  2834. __le32 bt_prio_defer_cnt;
  2835. __le32 bt_prio_kill_cnt;
  2836. __le32 few_bytes_cnt;
  2837. __le32 cts_timeout;
  2838. __le32 ack_timeout;
  2839. __le32 expected_ack_cnt;
  2840. __le32 actual_ack_cnt;
  2841. } __packed;
  2842. struct statistics_dbg {
  2843. __le32 burst_check;
  2844. __le32 burst_count;
  2845. __le32 wait_for_silence_timeout_cnt;
  2846. __le32 reserved[3];
  2847. } __packed;
  2848. struct iwl39_statistics_div {
  2849. __le32 tx_on_a;
  2850. __le32 tx_on_b;
  2851. __le32 exec_time;
  2852. __le32 probe_time;
  2853. } __packed;
  2854. struct iwl39_statistics_general {
  2855. __le32 temperature;
  2856. struct statistics_dbg dbg;
  2857. __le32 sleep_time;
  2858. __le32 slots_out;
  2859. __le32 slots_idle;
  2860. __le32 ttl_timestamp;
  2861. struct iwl39_statistics_div div;
  2862. } __packed;
  2863. struct statistics_rx_phy {
  2864. __le32 ina_cnt;
  2865. __le32 fina_cnt;
  2866. __le32 plcp_err;
  2867. __le32 crc32_err;
  2868. __le32 overrun_err;
  2869. __le32 early_overrun_err;
  2870. __le32 crc32_good;
  2871. __le32 false_alarm_cnt;
  2872. __le32 fina_sync_err_cnt;
  2873. __le32 sfd_timeout;
  2874. __le32 fina_timeout;
  2875. __le32 unresponded_rts;
  2876. __le32 rxe_frame_limit_overrun;
  2877. __le32 sent_ack_cnt;
  2878. __le32 sent_cts_cnt;
  2879. __le32 sent_ba_rsp_cnt;
  2880. __le32 dsp_self_kill;
  2881. __le32 mh_format_err;
  2882. __le32 re_acq_main_rssi_sum;
  2883. __le32 reserved3;
  2884. } __packed;
  2885. struct statistics_rx_ht_phy {
  2886. __le32 plcp_err;
  2887. __le32 overrun_err;
  2888. __le32 early_overrun_err;
  2889. __le32 crc32_good;
  2890. __le32 crc32_err;
  2891. __le32 mh_format_err;
  2892. __le32 agg_crc32_good;
  2893. __le32 agg_mpdu_cnt;
  2894. __le32 agg_cnt;
  2895. __le32 unsupport_mcs;
  2896. } __packed;
  2897. #define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1)
  2898. struct statistics_rx_non_phy {
  2899. __le32 bogus_cts; /* CTS received when not expecting CTS */
  2900. __le32 bogus_ack; /* ACK received when not expecting ACK */
  2901. __le32 non_bssid_frames; /* number of frames with BSSID that
  2902. * doesn't belong to the STA BSSID */
  2903. __le32 filtered_frames; /* count frames that were dumped in the
  2904. * filtering process */
  2905. __le32 non_channel_beacons; /* beacons with our bss id but not on
  2906. * our serving channel */
  2907. __le32 channel_beacons; /* beacons with our bss id and in our
  2908. * serving channel */
  2909. __le32 num_missed_bcon; /* number of missed beacons */
  2910. __le32 adc_rx_saturation_time; /* count in 0.8us units the time the
  2911. * ADC was in saturation */
  2912. __le32 ina_detection_search_time;/* total time (in 0.8us) searched
  2913. * for INA */
  2914. __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */
  2915. __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */
  2916. __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */
  2917. __le32 interference_data_flag; /* flag for interference data
  2918. * availability. 1 when data is
  2919. * available. */
  2920. __le32 channel_load; /* counts RX Enable time in uSec */
  2921. __le32 dsp_false_alarms; /* DSP false alarm (both OFDM
  2922. * and CCK) counter */
  2923. __le32 beacon_rssi_a;
  2924. __le32 beacon_rssi_b;
  2925. __le32 beacon_rssi_c;
  2926. __le32 beacon_energy_a;
  2927. __le32 beacon_energy_b;
  2928. __le32 beacon_energy_c;
  2929. } __packed;
  2930. struct statistics_rx_non_phy_bt {
  2931. struct statistics_rx_non_phy common;
  2932. /* additional stats for bt */
  2933. __le32 num_bt_kills;
  2934. __le32 reserved[2];
  2935. } __packed;
  2936. struct statistics_rx {
  2937. struct statistics_rx_phy ofdm;
  2938. struct statistics_rx_phy cck;
  2939. struct statistics_rx_non_phy general;
  2940. struct statistics_rx_ht_phy ofdm_ht;
  2941. } __packed;
  2942. struct statistics_rx_bt {
  2943. struct statistics_rx_phy ofdm;
  2944. struct statistics_rx_phy cck;
  2945. struct statistics_rx_non_phy_bt general;
  2946. struct statistics_rx_ht_phy ofdm_ht;
  2947. } __packed;
  2948. /**
  2949. * struct statistics_tx_power - current tx power
  2950. *
  2951. * @ant_a: current tx power on chain a in 1/2 dB step
  2952. * @ant_b: current tx power on chain b in 1/2 dB step
  2953. * @ant_c: current tx power on chain c in 1/2 dB step
  2954. */
  2955. struct statistics_tx_power {
  2956. u8 ant_a;
  2957. u8 ant_b;
  2958. u8 ant_c;
  2959. u8 reserved;
  2960. } __packed;
  2961. struct statistics_tx_non_phy_agg {
  2962. __le32 ba_timeout;
  2963. __le32 ba_reschedule_frames;
  2964. __le32 scd_query_agg_frame_cnt;
  2965. __le32 scd_query_no_agg;
  2966. __le32 scd_query_agg;
  2967. __le32 scd_query_mismatch;
  2968. __le32 frame_not_ready;
  2969. __le32 underrun;
  2970. __le32 bt_prio_kill;
  2971. __le32 rx_ba_rsp_cnt;
  2972. } __packed;
  2973. struct statistics_tx {
  2974. __le32 preamble_cnt;
  2975. __le32 rx_detected_cnt;
  2976. __le32 bt_prio_defer_cnt;
  2977. __le32 bt_prio_kill_cnt;
  2978. __le32 few_bytes_cnt;
  2979. __le32 cts_timeout;
  2980. __le32 ack_timeout;
  2981. __le32 expected_ack_cnt;
  2982. __le32 actual_ack_cnt;
  2983. __le32 dump_msdu_cnt;
  2984. __le32 burst_abort_next_frame_mismatch_cnt;
  2985. __le32 burst_abort_missing_next_frame_cnt;
  2986. __le32 cts_timeout_collision;
  2987. __le32 ack_or_ba_timeout_collision;
  2988. struct statistics_tx_non_phy_agg agg;
  2989. /*
  2990. * "tx_power" are optional parameters provided by uCode,
  2991. * 6000 series is the only device provide the information,
  2992. * Those are reserved fields for all the other devices
  2993. */
  2994. struct statistics_tx_power tx_power;
  2995. __le32 reserved1;
  2996. } __packed;
  2997. struct statistics_div {
  2998. __le32 tx_on_a;
  2999. __le32 tx_on_b;
  3000. __le32 exec_time;
  3001. __le32 probe_time;
  3002. __le32 reserved1;
  3003. __le32 reserved2;
  3004. } __packed;
  3005. struct statistics_general_common {
  3006. __le32 temperature; /* radio temperature */
  3007. __le32 temperature_m; /* for 5000 and up, this is radio voltage */
  3008. struct statistics_dbg dbg;
  3009. __le32 sleep_time;
  3010. __le32 slots_out;
  3011. __le32 slots_idle;
  3012. __le32 ttl_timestamp;
  3013. struct statistics_div div;
  3014. __le32 rx_enable_counter;
  3015. /*
  3016. * num_of_sos_states:
  3017. * count the number of times we have to re-tune
  3018. * in order to get out of bad PHY status
  3019. */
  3020. __le32 num_of_sos_states;
  3021. } __packed;
  3022. struct statistics_bt_activity {
  3023. /* Tx statistics */
  3024. __le32 hi_priority_tx_req_cnt;
  3025. __le32 hi_priority_tx_denied_cnt;
  3026. __le32 lo_priority_tx_req_cnt;
  3027. __le32 lo_priority_tx_denied_cnt;
  3028. /* Rx statistics */
  3029. __le32 hi_priority_rx_req_cnt;
  3030. __le32 hi_priority_rx_denied_cnt;
  3031. __le32 lo_priority_rx_req_cnt;
  3032. __le32 lo_priority_rx_denied_cnt;
  3033. } __packed;
  3034. struct statistics_general {
  3035. struct statistics_general_common common;
  3036. __le32 reserved2;
  3037. __le32 reserved3;
  3038. } __packed;
  3039. struct statistics_general_bt {
  3040. struct statistics_general_common common;
  3041. struct statistics_bt_activity activity;
  3042. __le32 reserved2;
  3043. __le32 reserved3;
  3044. } __packed;
  3045. #define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0)
  3046. #define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1)
  3047. #define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2)
  3048. /*
  3049. * REPLY_STATISTICS_CMD = 0x9c,
  3050. * all devices identical.
  3051. *
  3052. * This command triggers an immediate response containing uCode statistics.
  3053. * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
  3054. *
  3055. * If the CLEAR_STATS configuration flag is set, uCode will clear its
  3056. * internal copy of the statistics (counters) after issuing the response.
  3057. * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
  3058. *
  3059. * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
  3060. * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag
  3061. * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
  3062. */
  3063. #define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */
  3064. #define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
  3065. struct iwl_statistics_cmd {
  3066. __le32 configuration_flags; /* IWL_STATS_CONF_* */
  3067. } __packed;
  3068. /*
  3069. * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
  3070. *
  3071. * By default, uCode issues this notification after receiving a beacon
  3072. * while associated. To disable this behavior, set DISABLE_NOTIF flag in the
  3073. * REPLY_STATISTICS_CMD 0x9c, above.
  3074. *
  3075. * Statistics counters continue to increment beacon after beacon, but are
  3076. * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
  3077. * 0x9c with CLEAR_STATS bit set (see above).
  3078. *
  3079. * uCode also issues this notification during scans. uCode clears statistics
  3080. * appropriately so that each notification contains statistics for only the
  3081. * one channel that has just been scanned.
  3082. */
  3083. #define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2)
  3084. #define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8)
  3085. struct iwl3945_notif_statistics {
  3086. __le32 flag;
  3087. struct iwl39_statistics_rx rx;
  3088. struct iwl39_statistics_tx tx;
  3089. struct iwl39_statistics_general general;
  3090. } __packed;
  3091. struct iwl_notif_statistics {
  3092. __le32 flag;
  3093. struct statistics_rx rx;
  3094. struct statistics_tx tx;
  3095. struct statistics_general general;
  3096. } __packed;
  3097. struct iwl_bt_notif_statistics {
  3098. __le32 flag;
  3099. struct statistics_rx_bt rx;
  3100. struct statistics_tx tx;
  3101. struct statistics_general_bt general;
  3102. } __packed;
  3103. /*
  3104. * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
  3105. *
  3106. * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed
  3107. * in regardless of how many missed beacons, which mean when driver receive the
  3108. * notification, inside the command, it can find all the beacons information
  3109. * which include number of total missed beacons, number of consecutive missed
  3110. * beacons, number of beacons received and number of beacons expected to
  3111. * receive.
  3112. *
  3113. * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
  3114. * in order to bring the radio/PHY back to working state; which has no relation
  3115. * to when driver will perform sensitivity calibration.
  3116. *
  3117. * Driver should set it own missed_beacon_threshold to decide when to perform
  3118. * sensitivity calibration based on number of consecutive missed beacons in
  3119. * order to improve overall performance, especially in noisy environment.
  3120. *
  3121. */
  3122. #define IWL_MISSED_BEACON_THRESHOLD_MIN (1)
  3123. #define IWL_MISSED_BEACON_THRESHOLD_DEF (5)
  3124. #define IWL_MISSED_BEACON_THRESHOLD_MAX IWL_MISSED_BEACON_THRESHOLD_DEF
  3125. struct iwl_missed_beacon_notif {
  3126. __le32 consecutive_missed_beacons;
  3127. __le32 total_missed_becons;
  3128. __le32 num_expected_beacons;
  3129. __le32 num_recvd_beacons;
  3130. } __packed;
  3131. /******************************************************************************
  3132. * (11)
  3133. * Rx Calibration Commands:
  3134. *
  3135. * With the uCode used for open source drivers, most Tx calibration (except
  3136. * for Tx Power) and most Rx calibration is done by uCode during the
  3137. * "initialize" phase of uCode boot. Driver must calibrate only:
  3138. *
  3139. * 1) Tx power (depends on temperature), described elsewhere
  3140. * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas)
  3141. * 3) Receiver sensitivity (to optimize signal detection)
  3142. *
  3143. *****************************************************************************/
  3144. /**
  3145. * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
  3146. *
  3147. * This command sets up the Rx signal detector for a sensitivity level that
  3148. * is high enough to lock onto all signals within the associated network,
  3149. * but low enough to ignore signals that are below a certain threshold, so as
  3150. * not to have too many "false alarms". False alarms are signals that the
  3151. * Rx DSP tries to lock onto, but then discards after determining that they
  3152. * are noise.
  3153. *
  3154. * The optimum number of false alarms is between 5 and 50 per 200 TUs
  3155. * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
  3156. * time listening, not transmitting). Driver must adjust sensitivity so that
  3157. * the ratio of actual false alarms to actual Rx time falls within this range.
  3158. *
  3159. * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
  3160. * received beacon. These provide information to the driver to analyze the
  3161. * sensitivity. Don't analyze statistics that come in from scanning, or any
  3162. * other non-associated-network source. Pertinent statistics include:
  3163. *
  3164. * From "general" statistics (struct statistics_rx_non_phy):
  3165. *
  3166. * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
  3167. * Measure of energy of desired signal. Used for establishing a level
  3168. * below which the device does not detect signals.
  3169. *
  3170. * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
  3171. * Measure of background noise in silent period after beacon.
  3172. *
  3173. * channel_load
  3174. * uSecs of actual Rx time during beacon period (varies according to
  3175. * how much time was spent transmitting).
  3176. *
  3177. * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
  3178. *
  3179. * false_alarm_cnt
  3180. * Signal locks abandoned early (before phy-level header).
  3181. *
  3182. * plcp_err
  3183. * Signal locks abandoned late (during phy-level header).
  3184. *
  3185. * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from
  3186. * beacon to beacon, i.e. each value is an accumulation of all errors
  3187. * before and including the latest beacon. Values will wrap around to 0
  3188. * after counting up to 2^32 - 1. Driver must differentiate vs.
  3189. * previous beacon's values to determine # false alarms in the current
  3190. * beacon period.
  3191. *
  3192. * Total number of false alarms = false_alarms + plcp_errs
  3193. *
  3194. * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
  3195. * (notice that the start points for OFDM are at or close to settings for
  3196. * maximum sensitivity):
  3197. *
  3198. * START / MIN / MAX
  3199. * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120
  3200. * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210
  3201. * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140
  3202. * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270
  3203. *
  3204. * If actual rate of OFDM false alarms (+ plcp_errors) is too high
  3205. * (greater than 50 for each 204.8 msecs listening), reduce sensitivity
  3206. * by *adding* 1 to all 4 of the table entries above, up to the max for
  3207. * each entry. Conversely, if false alarm rate is too low (less than 5
  3208. * for each 204.8 msecs listening), *subtract* 1 from each entry to
  3209. * increase sensitivity.
  3210. *
  3211. * For CCK sensitivity, keep track of the following:
  3212. *
  3213. * 1). 20-beacon history of maximum background noise, indicated by
  3214. * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
  3215. * 3 receivers. For any given beacon, the "silence reference" is
  3216. * the maximum of last 60 samples (20 beacons * 3 receivers).
  3217. *
  3218. * 2). 10-beacon history of strongest signal level, as indicated
  3219. * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
  3220. * i.e. the strength of the signal through the best receiver at the
  3221. * moment. These measurements are "upside down", with lower values
  3222. * for stronger signals, so max energy will be *minimum* value.
  3223. *
  3224. * Then for any given beacon, the driver must determine the *weakest*
  3225. * of the strongest signals; this is the minimum level that needs to be
  3226. * successfully detected, when using the best receiver at the moment.
  3227. * "Max cck energy" is the maximum (higher value means lower energy!)
  3228. * of the last 10 minima. Once this is determined, driver must add
  3229. * a little margin by adding "6" to it.
  3230. *
  3231. * 3). Number of consecutive beacon periods with too few false alarms.
  3232. * Reset this to 0 at the first beacon period that falls within the
  3233. * "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
  3234. *
  3235. * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
  3236. * (notice that the start points for CCK are at maximum sensitivity):
  3237. *
  3238. * START / MIN / MAX
  3239. * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200
  3240. * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400
  3241. * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100
  3242. *
  3243. * If actual rate of CCK false alarms (+ plcp_errors) is too high
  3244. * (greater than 50 for each 204.8 msecs listening), method for reducing
  3245. * sensitivity is:
  3246. *
  3247. * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
  3248. * up to max 400.
  3249. *
  3250. * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
  3251. * sensitivity has been reduced a significant amount; bring it up to
  3252. * a moderate 161. Otherwise, *add* 3, up to max 200.
  3253. *
  3254. * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
  3255. * sensitivity has been reduced only a moderate or small amount;
  3256. * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
  3257. * down to min 0. Otherwise (if gain has been significantly reduced),
  3258. * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
  3259. *
  3260. * b) Save a snapshot of the "silence reference".
  3261. *
  3262. * If actual rate of CCK false alarms (+ plcp_errors) is too low
  3263. * (less than 5 for each 204.8 msecs listening), method for increasing
  3264. * sensitivity is used only if:
  3265. *
  3266. * 1a) Previous beacon did not have too many false alarms
  3267. * 1b) AND difference between previous "silence reference" and current
  3268. * "silence reference" (prev - current) is 2 or more,
  3269. * OR 2) 100 or more consecutive beacon periods have had rate of
  3270. * less than 5 false alarms per 204.8 milliseconds rx time.
  3271. *
  3272. * Method for increasing sensitivity:
  3273. *
  3274. * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
  3275. * down to min 125.
  3276. *
  3277. * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
  3278. * down to min 200.
  3279. *
  3280. * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
  3281. *
  3282. * If actual rate of CCK false alarms (+ plcp_errors) is within good range
  3283. * (between 5 and 50 for each 204.8 msecs listening):
  3284. *
  3285. * 1) Save a snapshot of the silence reference.
  3286. *
  3287. * 2) If previous beacon had too many CCK false alarms (+ plcp_errors),
  3288. * give some extra margin to energy threshold by *subtracting* 8
  3289. * from value in HD_MIN_ENERGY_CCK_DET_INDEX.
  3290. *
  3291. * For all cases (too few, too many, good range), make sure that the CCK
  3292. * detection threshold (energy) is below the energy level for robust
  3293. * detection over the past 10 beacon periods, the "Max cck energy".
  3294. * Lower values mean higher energy; this means making sure that the value
  3295. * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
  3296. *
  3297. */
  3298. /*
  3299. * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
  3300. */
  3301. #define HD_TABLE_SIZE (11) /* number of entries */
  3302. #define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */
  3303. #define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
  3304. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
  3305. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
  3306. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
  3307. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
  3308. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
  3309. #define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
  3310. #define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
  3311. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
  3312. #define HD_OFDM_ENERGY_TH_IN_INDEX (10)
  3313. /*
  3314. * Additional table entries in enhance SENSITIVITY_CMD
  3315. */
  3316. #define HD_INA_NON_SQUARE_DET_OFDM_INDEX (11)
  3317. #define HD_INA_NON_SQUARE_DET_CCK_INDEX (12)
  3318. #define HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX (13)
  3319. #define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX (14)
  3320. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (15)
  3321. #define HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX (16)
  3322. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX (17)
  3323. #define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX (18)
  3324. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX (19)
  3325. #define HD_CCK_NON_SQUARE_DET_SLOPE_INDEX (20)
  3326. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX (21)
  3327. #define HD_RESERVED (22)
  3328. /* number of entries for enhanced tbl */
  3329. #define ENHANCE_HD_TABLE_SIZE (23)
  3330. /* number of additional entries for enhanced tbl */
  3331. #define ENHANCE_HD_TABLE_ENTRIES (ENHANCE_HD_TABLE_SIZE - HD_TABLE_SIZE)
  3332. #define HD_INA_NON_SQUARE_DET_OFDM_DATA cpu_to_le16(0)
  3333. #define HD_INA_NON_SQUARE_DET_CCK_DATA cpu_to_le16(0)
  3334. #define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA cpu_to_le16(0)
  3335. #define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(668)
  3336. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
  3337. #define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(486)
  3338. #define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(37)
  3339. #define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA cpu_to_le16(853)
  3340. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA cpu_to_le16(4)
  3341. #define HD_CCK_NON_SQUARE_DET_SLOPE_DATA cpu_to_le16(476)
  3342. #define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA cpu_to_le16(99)
  3343. /* Control field in struct iwl_sensitivity_cmd */
  3344. #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0)
  3345. #define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1)
  3346. /**
  3347. * struct iwl_sensitivity_cmd
  3348. * @control: (1) updates working table, (0) updates default table
  3349. * @table: energy threshold values, use HD_* as index into table
  3350. *
  3351. * Always use "1" in "control" to update uCode's working table and DSP.
  3352. */
  3353. struct iwl_sensitivity_cmd {
  3354. __le16 control; /* always use "1" */
  3355. __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */
  3356. } __packed;
  3357. /*
  3358. *
  3359. */
  3360. struct iwl_enhance_sensitivity_cmd {
  3361. __le16 control; /* always use "1" */
  3362. __le16 enhance_table[ENHANCE_HD_TABLE_SIZE]; /* use HD_* as index */
  3363. } __packed;
  3364. /**
  3365. * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
  3366. *
  3367. * This command sets the relative gains of agn device's 3 radio receiver chains.
  3368. *
  3369. * After the first association, driver should accumulate signal and noise
  3370. * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
  3371. * beacons from the associated network (don't collect statistics that come
  3372. * in from scanning, or any other non-network source).
  3373. *
  3374. * DISCONNECTED ANTENNA:
  3375. *
  3376. * Driver should determine which antennas are actually connected, by comparing
  3377. * average beacon signal levels for the 3 Rx chains. Accumulate (add) the
  3378. * following values over 20 beacons, one accumulator for each of the chains
  3379. * a/b/c, from struct statistics_rx_non_phy:
  3380. *
  3381. * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
  3382. *
  3383. * Find the strongest signal from among a/b/c. Compare the other two to the
  3384. * strongest. If any signal is more than 15 dB (times 20, unless you
  3385. * divide the accumulated values by 20) below the strongest, the driver
  3386. * considers that antenna to be disconnected, and should not try to use that
  3387. * antenna/chain for Rx or Tx. If both A and B seem to be disconnected,
  3388. * driver should declare the stronger one as connected, and attempt to use it
  3389. * (A and B are the only 2 Tx chains!).
  3390. *
  3391. *
  3392. * RX BALANCE:
  3393. *
  3394. * Driver should balance the 3 receivers (but just the ones that are connected
  3395. * to antennas, see above) for gain, by comparing the average signal levels
  3396. * detected during the silence after each beacon (background noise).
  3397. * Accumulate (add) the following values over 20 beacons, one accumulator for
  3398. * each of the chains a/b/c, from struct statistics_rx_non_phy:
  3399. *
  3400. * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
  3401. *
  3402. * Find the weakest background noise level from among a/b/c. This Rx chain
  3403. * will be the reference, with 0 gain adjustment. Attenuate other channels by
  3404. * finding noise difference:
  3405. *
  3406. * (accum_noise[i] - accum_noise[reference]) / 30
  3407. *
  3408. * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
  3409. * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
  3410. * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
  3411. * and set bit 2 to indicate "reduce gain". The value for the reference
  3412. * (weakest) chain should be "0".
  3413. *
  3414. * diff_gain_[abc] bit fields:
  3415. * 2: (1) reduce gain, (0) increase gain
  3416. * 1-0: amount of gain, units of 1.5 dB
  3417. */
  3418. /* Phy calibration command for series */
  3419. /* The default calibrate table size if not specified by firmware */
  3420. #define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18
  3421. enum {
  3422. IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
  3423. IWL_PHY_CALIBRATE_DC_CMD = 8,
  3424. IWL_PHY_CALIBRATE_LO_CMD = 9,
  3425. IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
  3426. IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
  3427. IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16,
  3428. IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17,
  3429. IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD = 18,
  3430. IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19,
  3431. };
  3432. #define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253)
  3433. #define IWL_CALIB_INIT_CFG_ALL cpu_to_le32(0xffffffff)
  3434. /* This enum defines the bitmap of various calibrations to enable in both
  3435. * init ucode and runtime ucode through CALIBRATION_CFG_CMD.
  3436. */
  3437. enum iwl_ucode_calib_cfg {
  3438. IWL_CALIB_CFG_RX_BB_IDX,
  3439. IWL_CALIB_CFG_DC_IDX,
  3440. IWL_CALIB_CFG_TX_IQ_IDX,
  3441. IWL_CALIB_CFG_RX_IQ_IDX,
  3442. IWL_CALIB_CFG_NOISE_IDX,
  3443. IWL_CALIB_CFG_CRYSTAL_IDX,
  3444. IWL_CALIB_CFG_TEMPERATURE_IDX,
  3445. IWL_CALIB_CFG_PAPD_IDX,
  3446. };
  3447. struct iwl_calib_cfg_elmnt_s {
  3448. __le32 is_enable;
  3449. __le32 start;
  3450. __le32 send_res;
  3451. __le32 apply_res;
  3452. __le32 reserved;
  3453. } __packed;
  3454. struct iwl_calib_cfg_status_s {
  3455. struct iwl_calib_cfg_elmnt_s once;
  3456. struct iwl_calib_cfg_elmnt_s perd;
  3457. __le32 flags;
  3458. } __packed;
  3459. struct iwl_calib_cfg_cmd {
  3460. struct iwl_calib_cfg_status_s ucd_calib_cfg;
  3461. struct iwl_calib_cfg_status_s drv_calib_cfg;
  3462. __le32 reserved1;
  3463. } __packed;
  3464. struct iwl_calib_hdr {
  3465. u8 op_code;
  3466. u8 first_group;
  3467. u8 groups_num;
  3468. u8 data_valid;
  3469. } __packed;
  3470. struct iwl_calib_cmd {
  3471. struct iwl_calib_hdr hdr;
  3472. u8 data[0];
  3473. } __packed;
  3474. /* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
  3475. struct iwl_calib_diff_gain_cmd {
  3476. struct iwl_calib_hdr hdr;
  3477. s8 diff_gain_a; /* see above */
  3478. s8 diff_gain_b;
  3479. s8 diff_gain_c;
  3480. u8 reserved1;
  3481. } __packed;
  3482. struct iwl_calib_xtal_freq_cmd {
  3483. struct iwl_calib_hdr hdr;
  3484. u8 cap_pin1;
  3485. u8 cap_pin2;
  3486. u8 pad[2];
  3487. } __packed;
  3488. #define DEFAULT_RADIO_SENSOR_OFFSET 2700
  3489. struct iwl_calib_temperature_offset_cmd {
  3490. struct iwl_calib_hdr hdr;
  3491. s16 radio_sensor_offset;
  3492. s16 reserved;
  3493. } __packed;
  3494. /* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
  3495. struct iwl_calib_chain_noise_reset_cmd {
  3496. struct iwl_calib_hdr hdr;
  3497. u8 data[0];
  3498. };
  3499. /* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
  3500. struct iwl_calib_chain_noise_gain_cmd {
  3501. struct iwl_calib_hdr hdr;
  3502. u8 delta_gain_1;
  3503. u8 delta_gain_2;
  3504. u8 pad[2];
  3505. } __packed;
  3506. /******************************************************************************
  3507. * (12)
  3508. * Miscellaneous Commands:
  3509. *
  3510. *****************************************************************************/
  3511. /*
  3512. * LEDs Command & Response
  3513. * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
  3514. *
  3515. * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
  3516. * this command turns it on or off, or sets up a periodic blinking cycle.
  3517. */
  3518. struct iwl_led_cmd {
  3519. __le32 interval; /* "interval" in uSec */
  3520. u8 id; /* 1: Activity, 2: Link, 3: Tech */
  3521. u8 off; /* # intervals off while blinking;
  3522. * "0", with >0 "on" value, turns LED on */
  3523. u8 on; /* # intervals on while blinking;
  3524. * "0", regardless of "off", turns LED off */
  3525. u8 reserved;
  3526. } __packed;
  3527. /*
  3528. * station priority table entries
  3529. * also used as potential "events" value for both
  3530. * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
  3531. */
  3532. /*
  3533. * COEX events entry flag masks
  3534. * RP - Requested Priority
  3535. * WP - Win Medium Priority: priority assigned when the contention has been won
  3536. */
  3537. #define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG (0x1)
  3538. #define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG (0x2)
  3539. #define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG (0x4)
  3540. #define COEX_CU_UNASSOC_IDLE_RP 4
  3541. #define COEX_CU_UNASSOC_MANUAL_SCAN_RP 4
  3542. #define COEX_CU_UNASSOC_AUTO_SCAN_RP 4
  3543. #define COEX_CU_CALIBRATION_RP 4
  3544. #define COEX_CU_PERIODIC_CALIBRATION_RP 4
  3545. #define COEX_CU_CONNECTION_ESTAB_RP 4
  3546. #define COEX_CU_ASSOCIATED_IDLE_RP 4
  3547. #define COEX_CU_ASSOC_MANUAL_SCAN_RP 4
  3548. #define COEX_CU_ASSOC_AUTO_SCAN_RP 4
  3549. #define COEX_CU_ASSOC_ACTIVE_LEVEL_RP 4
  3550. #define COEX_CU_RF_ON_RP 6
  3551. #define COEX_CU_RF_OFF_RP 4
  3552. #define COEX_CU_STAND_ALONE_DEBUG_RP 6
  3553. #define COEX_CU_IPAN_ASSOC_LEVEL_RP 4
  3554. #define COEX_CU_RSRVD1_RP 4
  3555. #define COEX_CU_RSRVD2_RP 4
  3556. #define COEX_CU_UNASSOC_IDLE_WP 3
  3557. #define COEX_CU_UNASSOC_MANUAL_SCAN_WP 3
  3558. #define COEX_CU_UNASSOC_AUTO_SCAN_WP 3
  3559. #define COEX_CU_CALIBRATION_WP 3
  3560. #define COEX_CU_PERIODIC_CALIBRATION_WP 3
  3561. #define COEX_CU_CONNECTION_ESTAB_WP 3
  3562. #define COEX_CU_ASSOCIATED_IDLE_WP 3
  3563. #define COEX_CU_ASSOC_MANUAL_SCAN_WP 3
  3564. #define COEX_CU_ASSOC_AUTO_SCAN_WP 3
  3565. #define COEX_CU_ASSOC_ACTIVE_LEVEL_WP 3
  3566. #define COEX_CU_RF_ON_WP 3
  3567. #define COEX_CU_RF_OFF_WP 3
  3568. #define COEX_CU_STAND_ALONE_DEBUG_WP 6
  3569. #define COEX_CU_IPAN_ASSOC_LEVEL_WP 3
  3570. #define COEX_CU_RSRVD1_WP 3
  3571. #define COEX_CU_RSRVD2_WP 3
  3572. #define COEX_UNASSOC_IDLE_FLAGS 0
  3573. #define COEX_UNASSOC_MANUAL_SCAN_FLAGS \
  3574. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3575. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3576. #define COEX_UNASSOC_AUTO_SCAN_FLAGS \
  3577. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3578. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3579. #define COEX_CALIBRATION_FLAGS \
  3580. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3581. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3582. #define COEX_PERIODIC_CALIBRATION_FLAGS 0
  3583. /*
  3584. * COEX_CONNECTION_ESTAB:
  3585. * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
  3586. */
  3587. #define COEX_CONNECTION_ESTAB_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. #define COEX_ASSOCIATED_IDLE_FLAGS 0
  3592. #define COEX_ASSOC_MANUAL_SCAN_FLAGS \
  3593. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3594. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3595. #define COEX_ASSOC_AUTO_SCAN_FLAGS \
  3596. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3597. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3598. #define COEX_ASSOC_ACTIVE_LEVEL_FLAGS 0
  3599. #define COEX_RF_ON_FLAGS 0
  3600. #define COEX_RF_OFF_FLAGS 0
  3601. #define COEX_STAND_ALONE_DEBUG_FLAGS \
  3602. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3603. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
  3604. #define COEX_IPAN_ASSOC_LEVEL_FLAGS \
  3605. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3606. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
  3607. COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
  3608. #define COEX_RSRVD1_FLAGS 0
  3609. #define COEX_RSRVD2_FLAGS 0
  3610. /*
  3611. * COEX_CU_RF_ON is the event wrapping all radio ownership.
  3612. * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
  3613. */
  3614. #define COEX_CU_RF_ON_FLAGS \
  3615. (COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG | \
  3616. COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG | \
  3617. COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
  3618. enum {
  3619. /* un-association part */
  3620. COEX_UNASSOC_IDLE = 0,
  3621. COEX_UNASSOC_MANUAL_SCAN = 1,
  3622. COEX_UNASSOC_AUTO_SCAN = 2,
  3623. /* calibration */
  3624. COEX_CALIBRATION = 3,
  3625. COEX_PERIODIC_CALIBRATION = 4,
  3626. /* connection */
  3627. COEX_CONNECTION_ESTAB = 5,
  3628. /* association part */
  3629. COEX_ASSOCIATED_IDLE = 6,
  3630. COEX_ASSOC_MANUAL_SCAN = 7,
  3631. COEX_ASSOC_AUTO_SCAN = 8,
  3632. COEX_ASSOC_ACTIVE_LEVEL = 9,
  3633. /* RF ON/OFF */
  3634. COEX_RF_ON = 10,
  3635. COEX_RF_OFF = 11,
  3636. COEX_STAND_ALONE_DEBUG = 12,
  3637. /* IPAN */
  3638. COEX_IPAN_ASSOC_LEVEL = 13,
  3639. /* reserved */
  3640. COEX_RSRVD1 = 14,
  3641. COEX_RSRVD2 = 15,
  3642. COEX_NUM_OF_EVENTS = 16
  3643. };
  3644. /*
  3645. * Coexistence WIFI/WIMAX Command
  3646. * COEX_PRIORITY_TABLE_CMD = 0x5a
  3647. *
  3648. */
  3649. struct iwl_wimax_coex_event_entry {
  3650. u8 request_prio;
  3651. u8 win_medium_prio;
  3652. u8 reserved;
  3653. u8 flags;
  3654. } __packed;
  3655. /* COEX flag masks */
  3656. /* Station table is valid */
  3657. #define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1)
  3658. /* UnMask wake up src at unassociated sleep */
  3659. #define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4)
  3660. /* UnMask wake up src at associated sleep */
  3661. #define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8)
  3662. /* Enable CoEx feature. */
  3663. #define COEX_FLAGS_COEX_ENABLE_MSK (0x80)
  3664. struct iwl_wimax_coex_cmd {
  3665. u8 flags;
  3666. u8 reserved[3];
  3667. struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
  3668. } __packed;
  3669. /*
  3670. * Coexistence MEDIUM NOTIFICATION
  3671. * COEX_MEDIUM_NOTIFICATION = 0x5b
  3672. *
  3673. * notification from uCode to host to indicate medium changes
  3674. *
  3675. */
  3676. /*
  3677. * status field
  3678. * bit 0 - 2: medium status
  3679. * bit 3: medium change indication
  3680. * bit 4 - 31: reserved
  3681. */
  3682. /* status option values, (0 - 2 bits) */
  3683. #define COEX_MEDIUM_BUSY (0x0) /* radio belongs to WiMAX */
  3684. #define COEX_MEDIUM_ACTIVE (0x1) /* radio belongs to WiFi */
  3685. #define COEX_MEDIUM_PRE_RELEASE (0x2) /* received radio release */
  3686. #define COEX_MEDIUM_MSK (0x7)
  3687. /* send notification status (1 bit) */
  3688. #define COEX_MEDIUM_CHANGED (0x8)
  3689. #define COEX_MEDIUM_CHANGED_MSK (0x8)
  3690. #define COEX_MEDIUM_SHIFT (3)
  3691. struct iwl_coex_medium_notification {
  3692. __le32 status;
  3693. __le32 events;
  3694. } __packed;
  3695. /*
  3696. * Coexistence EVENT Command
  3697. * COEX_EVENT_CMD = 0x5c
  3698. *
  3699. * send from host to uCode for coex event request.
  3700. */
  3701. /* flags options */
  3702. #define COEX_EVENT_REQUEST_MSK (0x1)
  3703. struct iwl_coex_event_cmd {
  3704. u8 flags;
  3705. u8 event;
  3706. __le16 reserved;
  3707. } __packed;
  3708. struct iwl_coex_event_resp {
  3709. __le32 status;
  3710. } __packed;
  3711. /******************************************************************************
  3712. * Bluetooth Coexistence commands
  3713. *
  3714. *****************************************************************************/
  3715. /*
  3716. * BT Status notification
  3717. * REPLY_BT_COEX_PROFILE_NOTIF = 0xce
  3718. */
  3719. enum iwl_bt_coex_profile_traffic_load {
  3720. IWL_BT_COEX_TRAFFIC_LOAD_NONE = 0,
  3721. IWL_BT_COEX_TRAFFIC_LOAD_LOW = 1,
  3722. IWL_BT_COEX_TRAFFIC_LOAD_HIGH = 2,
  3723. IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS = 3,
  3724. /*
  3725. * There are no more even though below is a u8, the
  3726. * indication from the BT device only has two bits.
  3727. */
  3728. };
  3729. #define BT_UART_MSG_FRAME1MSGTYPE_POS (0)
  3730. #define BT_UART_MSG_FRAME1MSGTYPE_MSK \
  3731. (0x7 << BT_UART_MSG_FRAME1MSGTYPE_POS)
  3732. #define BT_UART_MSG_FRAME1SSN_POS (3)
  3733. #define BT_UART_MSG_FRAME1SSN_MSK \
  3734. (0x3 << BT_UART_MSG_FRAME1SSN_POS)
  3735. #define BT_UART_MSG_FRAME1UPDATEREQ_POS (5)
  3736. #define BT_UART_MSG_FRAME1UPDATEREQ_MSK \
  3737. (0x1 << BT_UART_MSG_FRAME1UPDATEREQ_POS)
  3738. #define BT_UART_MSG_FRAME1RESERVED_POS (6)
  3739. #define BT_UART_MSG_FRAME1RESERVED_MSK \
  3740. (0x3 << BT_UART_MSG_FRAME1RESERVED_POS)
  3741. #define BT_UART_MSG_FRAME2OPENCONNECTIONS_POS (0)
  3742. #define BT_UART_MSG_FRAME2OPENCONNECTIONS_MSK \
  3743. (0x3 << BT_UART_MSG_FRAME2OPENCONNECTIONS_POS)
  3744. #define BT_UART_MSG_FRAME2TRAFFICLOAD_POS (2)
  3745. #define BT_UART_MSG_FRAME2TRAFFICLOAD_MSK \
  3746. (0x3 << BT_UART_MSG_FRAME2TRAFFICLOAD_POS)
  3747. #define BT_UART_MSG_FRAME2CHLSEQN_POS (4)
  3748. #define BT_UART_MSG_FRAME2CHLSEQN_MSK \
  3749. (0x1 << BT_UART_MSG_FRAME2CHLSEQN_POS)
  3750. #define BT_UART_MSG_FRAME2INBAND_POS (5)
  3751. #define BT_UART_MSG_FRAME2INBAND_MSK \
  3752. (0x1 << BT_UART_MSG_FRAME2INBAND_POS)
  3753. #define BT_UART_MSG_FRAME2RESERVED_POS (6)
  3754. #define BT_UART_MSG_FRAME2RESERVED_MSK \
  3755. (0x3 << BT_UART_MSG_FRAME2RESERVED_POS)
  3756. #define BT_UART_MSG_FRAME3SCOESCO_POS (0)
  3757. #define BT_UART_MSG_FRAME3SCOESCO_MSK \
  3758. (0x1 << BT_UART_MSG_FRAME3SCOESCO_POS)
  3759. #define BT_UART_MSG_FRAME3SNIFF_POS (1)
  3760. #define BT_UART_MSG_FRAME3SNIFF_MSK \
  3761. (0x1 << BT_UART_MSG_FRAME3SNIFF_POS)
  3762. #define BT_UART_MSG_FRAME3A2DP_POS (2)
  3763. #define BT_UART_MSG_FRAME3A2DP_MSK \
  3764. (0x1 << BT_UART_MSG_FRAME3A2DP_POS)
  3765. #define BT_UART_MSG_FRAME3ACL_POS (3)
  3766. #define BT_UART_MSG_FRAME3ACL_MSK \
  3767. (0x1 << BT_UART_MSG_FRAME3ACL_POS)
  3768. #define BT_UART_MSG_FRAME3MASTER_POS (4)
  3769. #define BT_UART_MSG_FRAME3MASTER_MSK \
  3770. (0x1 << BT_UART_MSG_FRAME3MASTER_POS)
  3771. #define BT_UART_MSG_FRAME3OBEX_POS (5)
  3772. #define BT_UART_MSG_FRAME3OBEX_MSK \
  3773. (0x1 << BT_UART_MSG_FRAME3OBEX_POS)
  3774. #define BT_UART_MSG_FRAME3RESERVED_POS (6)
  3775. #define BT_UART_MSG_FRAME3RESERVED_MSK \
  3776. (0x3 << BT_UART_MSG_FRAME3RESERVED_POS)
  3777. #define BT_UART_MSG_FRAME4IDLEDURATION_POS (0)
  3778. #define BT_UART_MSG_FRAME4IDLEDURATION_MSK \
  3779. (0x3F << BT_UART_MSG_FRAME4IDLEDURATION_POS)
  3780. #define BT_UART_MSG_FRAME4RESERVED_POS (6)
  3781. #define BT_UART_MSG_FRAME4RESERVED_MSK \
  3782. (0x3 << BT_UART_MSG_FRAME4RESERVED_POS)
  3783. #define BT_UART_MSG_FRAME5TXACTIVITY_POS (0)
  3784. #define BT_UART_MSG_FRAME5TXACTIVITY_MSK \
  3785. (0x3 << BT_UART_MSG_FRAME5TXACTIVITY_POS)
  3786. #define BT_UART_MSG_FRAME5RXACTIVITY_POS (2)
  3787. #define BT_UART_MSG_FRAME5RXACTIVITY_MSK \
  3788. (0x3 << BT_UART_MSG_FRAME5RXACTIVITY_POS)
  3789. #define BT_UART_MSG_FRAME5ESCORETRANSMIT_POS (4)
  3790. #define BT_UART_MSG_FRAME5ESCORETRANSMIT_MSK \
  3791. (0x3 << BT_UART_MSG_FRAME5ESCORETRANSMIT_POS)
  3792. #define BT_UART_MSG_FRAME5RESERVED_POS (6)
  3793. #define BT_UART_MSG_FRAME5RESERVED_MSK \
  3794. (0x3 << BT_UART_MSG_FRAME5RESERVED_POS)
  3795. #define BT_UART_MSG_FRAME6SNIFFINTERVAL_POS (0)
  3796. #define BT_UART_MSG_FRAME6SNIFFINTERVAL_MSK \
  3797. (0x1F << BT_UART_MSG_FRAME6SNIFFINTERVAL_POS)
  3798. #define BT_UART_MSG_FRAME6DISCOVERABLE_POS (5)
  3799. #define BT_UART_MSG_FRAME6DISCOVERABLE_MSK \
  3800. (0x1 << BT_UART_MSG_FRAME6DISCOVERABLE_POS)
  3801. #define BT_UART_MSG_FRAME6RESERVED_POS (6)
  3802. #define BT_UART_MSG_FRAME6RESERVED_MSK \
  3803. (0x3 << BT_UART_MSG_FRAME6RESERVED_POS)
  3804. #define BT_UART_MSG_FRAME7SNIFFACTIVITY_POS (0)
  3805. #define BT_UART_MSG_FRAME7SNIFFACTIVITY_MSK \
  3806. (0x7 << BT_UART_MSG_FRAME7SNIFFACTIVITY_POS)
  3807. #define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS (3)
  3808. #define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_MSK \
  3809. (0x3 << BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS)
  3810. #define BT_UART_MSG_FRAME7CONNECTABLE_POS (5)
  3811. #define BT_UART_MSG_FRAME7CONNECTABLE_MSK \
  3812. (0x1 << BT_UART_MSG_FRAME7CONNECTABLE_POS)
  3813. #define BT_UART_MSG_FRAME7RESERVED_POS (6)
  3814. #define BT_UART_MSG_FRAME7RESERVED_MSK \
  3815. (0x3 << BT_UART_MSG_FRAME7RESERVED_POS)
  3816. struct iwl_bt_uart_msg {
  3817. u8 header;
  3818. u8 frame1;
  3819. u8 frame2;
  3820. u8 frame3;
  3821. u8 frame4;
  3822. u8 frame5;
  3823. u8 frame6;
  3824. u8 frame7;
  3825. } __attribute__((packed));
  3826. struct iwl_bt_coex_profile_notif {
  3827. struct iwl_bt_uart_msg last_bt_uart_msg;
  3828. u8 bt_status; /* 0 - off, 1 - on */
  3829. u8 bt_traffic_load; /* 0 .. 3? */
  3830. u8 bt_ci_compliance; /* 0 - not complied, 1 - complied */
  3831. u8 reserved;
  3832. } __attribute__((packed));
  3833. #define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS 0
  3834. #define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_MSK 0x1
  3835. #define IWL_BT_COEX_PRIO_TBL_PRIO_POS 1
  3836. #define IWL_BT_COEX_PRIO_TBL_PRIO_MASK 0x0e
  3837. #define IWL_BT_COEX_PRIO_TBL_RESERVED_POS 4
  3838. #define IWL_BT_COEX_PRIO_TBL_RESERVED_MASK 0xf0
  3839. #define IWL_BT_COEX_PRIO_TBL_PRIO_SHIFT 1
  3840. /*
  3841. * BT Coexistence Priority table
  3842. * REPLY_BT_COEX_PRIO_TABLE = 0xcc
  3843. */
  3844. enum bt_coex_prio_table_events {
  3845. BT_COEX_PRIO_TBL_EVT_INIT_CALIB1 = 0,
  3846. BT_COEX_PRIO_TBL_EVT_INIT_CALIB2 = 1,
  3847. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1 = 2,
  3848. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2 = 3, /* DC calib */
  3849. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1 = 4,
  3850. BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2 = 5,
  3851. BT_COEX_PRIO_TBL_EVT_DTIM = 6,
  3852. BT_COEX_PRIO_TBL_EVT_SCAN52 = 7,
  3853. BT_COEX_PRIO_TBL_EVT_SCAN24 = 8,
  3854. BT_COEX_PRIO_TBL_EVT_RESERVED0 = 9,
  3855. BT_COEX_PRIO_TBL_EVT_RESERVED1 = 10,
  3856. BT_COEX_PRIO_TBL_EVT_RESERVED2 = 11,
  3857. BT_COEX_PRIO_TBL_EVT_RESERVED3 = 12,
  3858. BT_COEX_PRIO_TBL_EVT_RESERVED4 = 13,
  3859. BT_COEX_PRIO_TBL_EVT_RESERVED5 = 14,
  3860. BT_COEX_PRIO_TBL_EVT_RESERVED6 = 15,
  3861. /* BT_COEX_PRIO_TBL_EVT_MAX should always be last */
  3862. BT_COEX_PRIO_TBL_EVT_MAX,
  3863. };
  3864. enum bt_coex_prio_table_priorities {
  3865. BT_COEX_PRIO_TBL_DISABLED = 0,
  3866. BT_COEX_PRIO_TBL_PRIO_LOW = 1,
  3867. BT_COEX_PRIO_TBL_PRIO_HIGH = 2,
  3868. BT_COEX_PRIO_TBL_PRIO_BYPASS = 3,
  3869. BT_COEX_PRIO_TBL_PRIO_COEX_OFF = 4,
  3870. BT_COEX_PRIO_TBL_PRIO_COEX_ON = 5,
  3871. BT_COEX_PRIO_TBL_PRIO_RSRVD1 = 6,
  3872. BT_COEX_PRIO_TBL_PRIO_RSRVD2 = 7,
  3873. BT_COEX_PRIO_TBL_MAX,
  3874. };
  3875. struct iwl_bt_coex_prio_table_cmd {
  3876. u8 prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX];
  3877. } __attribute__((packed));
  3878. #define IWL_BT_COEX_ENV_CLOSE 0
  3879. #define IWL_BT_COEX_ENV_OPEN 1
  3880. /*
  3881. * BT Protection Envelope
  3882. * REPLY_BT_COEX_PROT_ENV = 0xcd
  3883. */
  3884. struct iwl_bt_coex_prot_env_cmd {
  3885. u8 action; /* 0 = closed, 1 = open */
  3886. u8 type; /* 0 .. 15 */
  3887. u8 reserved[2];
  3888. } __attribute__((packed));
  3889. /******************************************************************************
  3890. * (13)
  3891. * Union of all expected notifications/responses:
  3892. *
  3893. *****************************************************************************/
  3894. struct iwl_rx_packet {
  3895. /*
  3896. * The first 4 bytes of the RX frame header contain both the RX frame
  3897. * size and some flags.
  3898. * Bit fields:
  3899. * 31: flag flush RB request
  3900. * 30: flag ignore TC (terminal counter) request
  3901. * 29: flag fast IRQ request
  3902. * 28-14: Reserved
  3903. * 13-00: RX frame size
  3904. */
  3905. __le32 len_n_flags;
  3906. struct iwl_cmd_header hdr;
  3907. union {
  3908. struct iwl3945_rx_frame rx_frame;
  3909. struct iwl3945_tx_resp tx_resp;
  3910. struct iwl3945_beacon_notif beacon_status;
  3911. struct iwl_alive_resp alive_frame;
  3912. struct iwl_spectrum_notification spectrum_notif;
  3913. struct iwl_csa_notification csa_notif;
  3914. struct iwl_error_resp err_resp;
  3915. struct iwl_card_state_notif card_state_notif;
  3916. struct iwl_add_sta_resp add_sta;
  3917. struct iwl_rem_sta_resp rem_sta;
  3918. struct iwl_sleep_notification sleep_notif;
  3919. struct iwl_spectrum_resp spectrum;
  3920. struct iwl_notif_statistics stats;
  3921. struct iwl_bt_notif_statistics stats_bt;
  3922. struct iwl_compressed_ba_resp compressed_ba;
  3923. struct iwl_missed_beacon_notif missed_beacon;
  3924. struct iwl_coex_medium_notification coex_medium_notif;
  3925. struct iwl_coex_event_resp coex_event;
  3926. struct iwl_bt_coex_profile_notif bt_coex_profile_notif;
  3927. __le32 status;
  3928. u8 raw[0];
  3929. } u;
  3930. } __packed;
  3931. int iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
  3932. /*
  3933. * REPLY_WIPAN_PARAMS = 0xb2 (Commands and Notification)
  3934. */
  3935. /*
  3936. * Minimum slot time in TU
  3937. */
  3938. #define IWL_MIN_SLOT_TIME 20
  3939. /**
  3940. * struct iwl_wipan_slot
  3941. * @width: Time in TU
  3942. * @type:
  3943. * 0 - BSS
  3944. * 1 - PAN
  3945. */
  3946. struct iwl_wipan_slot {
  3947. __le16 width;
  3948. u8 type;
  3949. u8 reserved;
  3950. } __packed;
  3951. #define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_CTS BIT(1) /* reserved */
  3952. #define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_QUIET BIT(2) /* reserved */
  3953. #define IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE BIT(3) /* reserved */
  3954. #define IWL_WIPAN_PARAMS_FLG_FILTER_BEACON_NOTIF BIT(4)
  3955. #define IWL_WIPAN_PARAMS_FLG_FULL_SLOTTED_MODE BIT(5)
  3956. /**
  3957. * struct iwl_wipan_params_cmd
  3958. * @flags:
  3959. * bit0: reserved
  3960. * bit1: CP leave channel with CTS
  3961. * bit2: CP leave channel qith Quiet
  3962. * bit3: slotted mode
  3963. * 1 - work in slotted mode
  3964. * 0 - work in non slotted mode
  3965. * bit4: filter beacon notification
  3966. * bit5: full tx slotted mode. if this flag is set,
  3967. * uCode will perform leaving channel methods in context switch
  3968. * also when working in same channel mode
  3969. * @num_slots: 1 - 10
  3970. */
  3971. struct iwl_wipan_params_cmd {
  3972. __le16 flags;
  3973. u8 reserved;
  3974. u8 num_slots;
  3975. struct iwl_wipan_slot slots[10];
  3976. } __packed;
  3977. /*
  3978. * REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9
  3979. *
  3980. * TODO: Figure out what this is used for,
  3981. * it can only switch between 2.4 GHz
  3982. * channels!!
  3983. */
  3984. struct iwl_wipan_p2p_channel_switch_cmd {
  3985. __le16 channel;
  3986. __le16 reserved;
  3987. };
  3988. /*
  3989. * REPLY_WIPAN_NOA_NOTIFICATION = 0xbc
  3990. *
  3991. * This is used by the device to notify us of the
  3992. * NoA schedule it determined so we can forward it
  3993. * to userspace for inclusion in probe responses.
  3994. *
  3995. * In beacons, the NoA schedule is simply appended
  3996. * to the frame we give the device.
  3997. */
  3998. struct iwl_wipan_noa_descriptor {
  3999. u8 count;
  4000. __le32 duration;
  4001. __le32 interval;
  4002. __le32 starttime;
  4003. } __packed;
  4004. struct iwl_wipan_noa_attribute {
  4005. u8 id;
  4006. __le16 length;
  4007. u8 index;
  4008. u8 ct_window;
  4009. struct iwl_wipan_noa_descriptor descr0, descr1;
  4010. u8 reserved;
  4011. } __packed;
  4012. struct iwl_wipan_noa_notification {
  4013. u32 noa_active;
  4014. struct iwl_wipan_noa_attribute noa_attribute;
  4015. } __packed;
  4016. #endif /* __iwl_commands_h__ */