iwl-commands.h 148 KB

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