iwl-commands.h 144 KB

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