iwl-commands.h 129 KB

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