iwl-commands.h 135 KB

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