iwl-commands.h 132 KB

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