iwl-commands.h 133 KB

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