nic.c 130 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic.c#2
  3. */
  4. /*! \file nic.c
  5. \brief Functions that provide operation in NIC's (Network Interface Card) point of view.
  6. This file includes functions which unite multiple hal(Hardware) operations
  7. and also take the responsibility of Software Resource Management in order
  8. to keep the synchronization with Hardware Manipulation.
  9. */
  10. /*
  11. ** Log: nic.c
  12. *
  13. * 07 17 2012 yuche.tsai
  14. * NULL
  15. * Compile no error before trial run.
  16. *
  17. * 05 02 2012 terry.wu
  18. * NULL
  19. * Set the default value of AP StaRec index to "STA_REC_INDEX_NOT_FOUND" in update firmware bss command.
  20. *
  21. * 03 02 2012 terry.wu
  22. * NULL
  23. * Sync CFG80211 modification from branch 2,2.
  24. *
  25. * 11 28 2011 cp.wu
  26. * [WCXRP00001125] [MT6620 Wi-Fi][Firmware] Strengthen Wi-Fi power off sequence to have a clearroom environment when
  27. * returining to ROM code
  28. * 1. Due to firmware now stops HIF DMA for powering off, do not try to receive any packet from firmware
  29. * 2. Take use of prAdapter->fgIsEnterD3ReqIssued for tracking whether it is powering off or not
  30. *
  31. * 11 22 2011 tsaiyuan.hsu
  32. * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
  33. * keep debug counter setting after wake up.
  34. *
  35. * 11 19 2011 yuche.tsai
  36. * NULL
  37. * Update RSSI for P2P.
  38. *
  39. * 11 18 2011 yuche.tsai
  40. * NULL
  41. * CONFIG P2P support RSSI query, default turned off.
  42. *
  43. * 11 07 2011 tsaiyuan.hsu
  44. * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
  45. * add debug counters and periodically dump counters for debugging.
  46. *
  47. * 11 04 2011 cp.wu
  48. * [WCXRP00001079] [MT5931][Driver] Release pending MMPDU only when BSS is being deactivated
  49. * pre-check for NULL before calling MMPDU free function
  50. *
  51. * 11 03 2011 wh.su
  52. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  53. * change the DBGLOG for "\n" and "\r\n". LABEL to LOUD for XLOG
  54. *
  55. * 11 01 2011 chinglan.wang
  56. * NULL
  57. * Modify the Wi-Fi method of the flush TX queue when disconnect the AP.
  58. * If disconnect the AP and flush all the data frame in the TX queue, WPS cannot do the 4-way handshake to connect to
  59. * the AP..
  60. *
  61. * 10 11 2011 terry.wu
  62. * NULL
  63. * Rewrite Assert Dump Function for Portability.
  64. *
  65. * 09 20 2011 cm.chang
  66. * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
  67. * New CMD definition about RLM parameters
  68. *
  69. * 08 15 2011 cp.wu
  70. * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
  71. * reuse firmware download logic of MT6620 for MT6628.
  72. *
  73. * 08 03 2011 terry.wu
  74. * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
  75. * Reply Probe Rsp in FW for Hotspot Mode.
  76. *
  77. *
  78. *
  79. * 08 03 2011 terry.wu
  80. * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
  81. * Reply Probe Rsp in FW for Hotspot Mode.
  82. *
  83. *
  84. * 08 03 2011 terry.wu
  85. * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
  86. * Reply Probe Rsp in FW for Hotspot Mode.
  87. *
  88. * 08 03 2011 terry.wu
  89. * [WCXRP00000899] [MT6620] [FW] Reply probe rsp in FW for hotspot mode
  90. * Reply Probe Rsp in FW for Hotspot Mode.
  91. *
  92. * 08 02 2011 yuche.tsai
  93. * [WCXRP00000896] [Volunteer Patch][WiFi Direct][Driver] GO with multiple client, TX deauth to a disconnecting device
  94. * issue.
  95. * Fix GO send deauth frame issue.
  96. *
  97. * 07 18 2011 chinghwa.yu
  98. * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
  99. * Add CMD/Event for RDD and BWCS.
  100. *
  101. * 07 11 2011 wh.su
  102. * [WCXRP00000849] [MT6620 Wi-Fi][Driver] Remove some of the WAPI define for make sure the value is initialize, for
  103. * customer not enable WAPI
  104. * For make sure wapi initial value is set.
  105. *
  106. * 06 27 2011 cp.wu
  107. * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work around some tricky
  108. * AP which use space character as hidden SSID
  109. * 1. correct logic
  110. * 2. replace only BSS-DESC which doesn't have a valid SSID.
  111. *
  112. * 06 27 2011 cp.wu
  113. * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work around some tricky
  114. * AP which use space character as hidden SSID
  115. * allow to have a single BSSID with multiple SSID to be presented in scanning result
  116. *
  117. * 05 12 2011 puff.wen
  118. * NULL
  119. * FW Assert information dump to driver
  120. *
  121. * 04 18 2011 terry.wu
  122. * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
  123. * Remove flag CFG_WIFI_DIRECT_MOVED.
  124. *
  125. * 04 15 2011 cp.wu
  126. * [WCXRP00000651] [MT6620 Wi-Fi][Driver] Refine RSSI buffering mechanism
  127. * ROLLBACK due to the special design is to workaround incorrect initial RCPI value coming from firmware domain.
  128. *
  129. * 04 14 2011 cm.chang
  130. * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
  131. * .
  132. *
  133. * 04 14 2011 cp.wu
  134. * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for
  135. * RESET_START and RESET_END events
  136. * 1. add code to put whole-chip resetting trigger when abnormal firmware assertion is detected
  137. * 2. add dummy function for both Win32 and Linux part.
  138. *
  139. * 04 12 2011 cp.wu
  140. * [WCXRP00000635] [MT6620 Wi-Fi][Driver] Clear pending security frames when QM clear pending data frames for
  141. * dedicated network type
  142. * clear pending security frames for dedicated network type when BSS is being deactivated/disconnected
  143. *
  144. * 04 12 2011 wh.su
  145. * NULL
  146. * enable the p2p check the cipher to set the bssInfo auth mode.
  147. *
  148. * 04 12 2011 wh.su
  149. * NULL
  150. * prepare the code for sync the auth mode and encryption status for P2P and BOW.
  151. *
  152. * 04 11 2011 yuche.tsai
  153. * [WCXRP00000627] [Volunteer Patch][MT6620][Driver] Pending MMPUD of P2P Network may crash system issue.
  154. * Fix kernel panic issue when MMPDU of P2P is pending in driver.
  155. *
  156. * 04 10 2011 george.huang
  157. * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
  158. * Fix compiler issue.
  159. *
  160. * 04 08 2011 george.huang
  161. * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
  162. * separate settings of P2P and AIS
  163. *
  164. * 04 08 2011 eddie.chen
  165. * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
  166. * Fix for sigma
  167. *
  168. * 04 07 2011 cp.wu
  169. * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside
  170. * wlanAdapterStart
  171. * .
  172. *
  173. * 04 07 2011 cp.wu
  174. * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure happend inside
  175. * wlanAdapterStart
  176. * implementation of internal error handling of nicAllocateAdapterMemory.
  177. *
  178. * 03 31 2011 chinglan.wang
  179. * [WCXRP00000613] [MT6620 Wi-Fi] [FW] [Driver] BssInfo can get the security mode which is WPA/WPA2/WAPI or not.
  180. * .
  181. *
  182. * 03 21 2011 cp.wu
  183. * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
  184. * portability improvement
  185. *
  186. * 03 17 2011 cp.wu
  187. * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
  188. * after system running for a long period
  189. * use pre-allocated buffer for storing enhanced interrupt response as well
  190. *
  191. * 03 16 2011 cp.wu
  192. * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
  193. * after system running for a long period
  194. * 1. pre-allocate physical continuous buffer while module is being loaded
  195. * 2. use pre-allocated physical continuous buffer for TX/RX DMA transfer
  196. *
  197. * The windows part remained the same as before, but added similar APIs to hide the difference.
  198. *
  199. * 03 15 2011 cp.wu
  200. * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous
  201. * memory consumption
  202. * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
  203. * 2. Use common coalescing buffer for both TX/RX directions
  204. *
  205. *
  206. * 03 10 2011 cm.chang
  207. * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
  208. * Add some functions to let AIS/Tethering or AIS/BOW be the same channel
  209. *
  210. * 03 07 2011 terry.wu
  211. * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
  212. * Toggle non-standard debug messages to comments.
  213. *
  214. * 03 02 2011 cp.wu
  215. * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after
  216. * connection is built.
  217. * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
  218. *
  219. * 02 08 2011 terry.wu
  220. * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
  221. * Use kalPrint to print firmware assert info.
  222. *
  223. * 02 01 2011 terry.wu
  224. * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
  225. * .
  226. *
  227. * 02 01 2011 cm.chang
  228. * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode
  229. * .
  230. *
  231. * 01 31 2011 terry.wu
  232. * [WCXRP00000412] [MT6620 Wi-Fi][FW/Driver] Dump firmware assert info at android kernel log
  233. * Print firmware ASSERT info at Android kernel log, driver side
  234. *
  235. * 01 27 2011 tsaiyuan.hsu
  236. * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
  237. * add roaming fsm
  238. * 1. not support 11r, only use strength of signal to determine roaming.
  239. * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
  240. * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
  241. * 4. assume that change of link quality in smooth way.
  242. *
  243. * 01 26 2011 cm.chang
  244. * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
  245. * Allocate system RAM if fixed message or mgmt buffer is not available
  246. *
  247. * 01 24 2011 cp.wu
  248. * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
  249. * 1. add an extra counter for tracking pending forward frames.
  250. * 2. notify TX service thread as well when there is pending forward frame
  251. * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
  252. *
  253. * 01 19 2011 cp.wu
  254. * [WCXRP00000372] [MT6620 Wi-Fi][Driver] Check bus access failure inside nicProcessIST()
  255. * check bus error and/or card removal when retrieving interrupt status from HAL
  256. *
  257. * 01 04 2011 cp.wu
  258. * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease
  259. * physically continuous memory demands
  260. * 1) correct typo in scan.c
  261. * 2) TX descriptors, RX descriptos and management buffer should use virtually continuous buffer instead of
  262. * physically contineous one
  263. *
  264. * 01 04 2011 cp.wu
  265. * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to ease
  266. * physically continuous memory demands
  267. * separate kalMemAlloc() into virtually-continuous and physically-continuous type to ease slab system pressure
  268. *
  269. * 12 30 2010 cp.wu
  270. * [WCXRP00000327] [MT6620 Wi-Fi][Driver] Improve HEC WHQA 6972 workaround coverage in driver side
  271. * host driver not to set FW-own when there is still pending interrupts
  272. *
  273. * 12 17 2010 cp.wu
  274. * [WCXRP00000270] [MT6620 Wi-Fi][Driver] Clear issues after concurrent networking support has been merged
  275. * before BSS disconnection is indicated to firmware, all correlated peer should be cleared and freed
  276. *
  277. * 12 07 2010 cm.chang
  278. * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
  279. * 1. BSSINFO include RLM parameter
  280. * 2. free all sta records when network is disconnected
  281. *
  282. * 12 02 2010 eddie.chen
  283. * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
  284. * Add more control value but dont use it now.
  285. *
  286. * 11 30 2010 eddie.chen
  287. * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
  288. * Add auto rate check window in registry
  289. *
  290. * 11 10 2010 eddie.chen
  291. * [WCXRP00000156] [MT6620][FW] Change Auto rate window to 64 and add throughput swcr
  292. * Use autorate parameter 1 as phy rate mask.
  293. *
  294. * 11 08 2010 cp.wu
  295. * [WCXRP00000166] [MT6620 Wi-Fi][Driver] use SDIO CMD52 for enabling/disabling interrupt to reduce transaction period
  296. * change to use CMD52 for enabling/disabling interrupt to reduce SDIO transaction time
  297. *
  298. * 10 26 2010 eddie.chen
  299. * [WCXRP00000134] [MT6620 Wi-Fi][Driver] Add a registry to enable auto rate for SQA test by using E1 EVB
  300. * Add auto rate parameter in registry.
  301. *
  302. * 10 18 2010 cp.wu
  303. * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to
  304. * BSOD when entering RF test with AIS associated
  305. * 1. remove redundant variables in STA_REC structure
  306. * 2. add STA-REC uninitialization routine for clearing pending events
  307. *
  308. * 10 18 2010 cp.wu
  309. * [WCXRP00000103] [MT6620 Wi-Fi][Driver] Driver crashed when using WZC to connect to AP#B with connection with AP#A
  310. * reset ptrs when IEs are going to be dropped
  311. *
  312. * 10 12 2010 cp.wu
  313. * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
  314. * add HT (802.11n) fixed rate support.
  315. *
  316. * 10 08 2010 cp.wu
  317. * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
  318. * adding fixed rate support for distance test. (from registry setting)
  319. *
  320. * 10 07 2010 cp.wu
  321. * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
  322. * add firmware download for MT5931.
  323. *
  324. * 10 05 2010 cp.wu
  325. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
  326. * load manufacture data when CFG_SUPPORT_NVRAM is set to 1
  327. *
  328. * 10 04 2010 cp.wu
  329. * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced by
  330. * ENUM_NETWORK_TYPE_INDEX_T only remove ENUM_NETWORK_TYPE_T definitions
  331. *
  332. * 09 21 2010 cp.wu
  333. * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test
  334. * with AIS associated
  335. * Do a complete reset with STA-REC null checking for RF test re-entry
  336. *
  337. * 09 08 2010 cp.wu
  338. * NULL
  339. * use static memory pool for storing IEs of scanning result.
  340. *
  341. * 09 06 2010 cp.wu
  342. * NULL
  343. * Androi/Linux: return current operating channel information
  344. *
  345. * 09 01 2010 cp.wu
  346. * NULL
  347. * HIFSYS Clock Source Workaround
  348. *
  349. * 08 26 2010 yuche.tsai
  350. * NULL
  351. * Fix someones coding error while enable WIFI_DIRECT.
  352. *
  353. * 08 25 2010 george.huang
  354. * NULL
  355. * update OID/ registry control path for PM related settings
  356. *
  357. * 08 24 2010 cm.chang
  358. * NULL
  359. * Support RLM initail channel of Ad-hoc, P2P and BOW
  360. *
  361. * 08 24 2010 chinghwa.yu
  362. * NULL
  363. * Update BOW for the 1st time.
  364. *
  365. * 08 23 2010 chinghwa.yu
  366. * NULL
  367. * Update for BOW.
  368. *
  369. * 08 20 2010 yuche.tsai
  370. * NULL
  371. * Add state change indication.
  372. *
  373. * 08 16 2010 yuche.tsai
  374. * NULL
  375. * Add support for P2P BSS update info.
  376. *
  377. * 08 12 2010 cp.wu
  378. * NULL
  379. * [removing debugging] not to dump beacon content.
  380. *
  381. * 08 12 2010 cp.wu
  382. * NULL
  383. * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
  384. *
  385. * 08 11 2010 cp.wu
  386. * NULL
  387. * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
  388. * 2) extending scanning result to 64 instead of 48
  389. *
  390. * 08 04 2010 yarco.yang
  391. * NULL
  392. * Add TX_AMPDU and ADDBA_REJECT command
  393. *
  394. * 08 03 2010 cp.wu
  395. * NULL
  396. * surpress compilation warning.
  397. *
  398. * 08 03 2010 cp.wu
  399. * NULL
  400. * Centralize mgmt/system service procedures into independent calls.
  401. *
  402. * 07 28 2010 cp.wu
  403. * NULL
  404. * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
  405. * 2) change nicMediaStateChange() API prototype
  406. *
  407. * 07 28 2010 cp.wu
  408. * NULL
  409. * sync. CMD_BSS_INFO structure change to CMD-EVENT v0.15.
  410. *
  411. * 07 24 2010 wh.su
  412. *
  413. * .support the Wi-Fi RSN
  414. *
  415. * 07 23 2010 cp.wu
  416. *
  417. * FIX: structure of CMD_SET_BSS_INFO has been changed but no follow-ups are done.
  418. *
  419. * 07 22 2010 george.huang
  420. *
  421. * .
  422. *
  423. * 07 22 2010 george.huang
  424. *
  425. * Update fgIsQoS information in BSS INFO by CMD
  426. *
  427. * 07 19 2010 cp.wu
  428. *
  429. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  430. * Add Ad-Hoc support to AIS-FSM
  431. *
  432. * 07 14 2010 yarco.yang
  433. *
  434. * 1. Remove CFG_MQM_MIGRATION
  435. * 2. Add CMD_UPDATE_WMM_PARMS command
  436. *
  437. * 07 08 2010 cp.wu
  438. *
  439. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  440. *
  441. * 07 07 2010 cp.wu
  442. * [WPD00003833][MT6620 and MT5931] Driver migration
  443. * update prStaRecOfAP with BSS-INFO.
  444. *
  445. * 07 06 2010 george.huang
  446. * [WPD00001556]Basic power managemenet function
  447. * Update arguments for nicUpdateBeaconIETemplate()
  448. *
  449. * 07 06 2010 cp.wu
  450. * [WPD00003833][MT6620 and MT5931] Driver migration
  451. * STA-REC is maintained by CNM only.
  452. *
  453. * 07 05 2010 cp.wu
  454. * [WPD00003833][MT6620 and MT5931] Driver migration
  455. * 1) ignore RSN checking when RSN is not turned on.
  456. * 2) set STA-REC deactivation callback as NULL
  457. * 3) add variable initialization API based on PHY configuration
  458. *
  459. * 07 01 2010 cm.chang
  460. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  461. * Support sync command of STA_REC
  462. *
  463. * 06 30 2010 cp.wu
  464. * [WPD00003833][MT6620 and MT5931] Driver migration
  465. * sync. with CMD/EVENT document ver0.07.
  466. *
  467. * 06 29 2010 cp.wu
  468. * [WPD00003833][MT6620 and MT5931] Driver migration
  469. * correct variable naming for 8-bit variable used in CMD_BEACON_TEMPLATE_UPDATE.
  470. *
  471. * 06 29 2010 cp.wu
  472. * [WPD00003833][MT6620 and MT5931] Driver migration
  473. * 1) sync to. CMD/EVENT document v0.03
  474. * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
  475. * 3) send command packet to indicate FW-PM after
  476. * a) 1st beacon is received after AIS has connected to an AP
  477. * b) IBSS-ALONE has been created
  478. * c) IBSS-MERGE has occurred
  479. *
  480. * 06 25 2010 george.huang
  481. * [WPD00001556]Basic power managemenet function
  482. * Create beacon update path, with expose bssUpdateBeaconContent()
  483. *
  484. * 06 22 2010 cp.wu
  485. * [WPD00003833][MT6620 and MT5931] Driver migration
  486. * fill fgIsUapsdConnection when indicating BSS-CREATE with AIS-STA mode.
  487. *
  488. * 06 22 2010 cp.wu
  489. * [WPD00003833][MT6620 and MT5931] Driver migration
  490. * 1) add command warpper for STA-REC/BSS-INFO sync.
  491. * 2) enhance command packet sending procedure for non-oid part
  492. * 3) add command packet definitions for STA-REC/BSS-INFO sync.
  493. *
  494. * 06 21 2010 cp.wu
  495. * [WPD00003833][MT6620 and MT5931] Driver migration
  496. * implement TX_DONE callback path.
  497. *
  498. * 06 21 2010 wh.su
  499. * [WPD00003840][MT6620 5931] Security migration
  500. * remove duplicate variable for migration.
  501. *
  502. * 06 21 2010 cp.wu
  503. * [WPD00003833][MT6620 and MT5931] Driver migration
  504. * TX descriptors are now allocated once for reducing allocation overhead
  505. *
  506. * 06 18 2010 cm.chang
  507. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  508. * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
  509. *
  510. * 06 11 2010 cp.wu
  511. * [WPD00003833][MT6620 and MT5931] Driver migration
  512. * 1) migrate assoc.c.
  513. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  514. * 3) add configuration options for CNM_MEM and RSN modules
  515. * 4) add data path for management frames
  516. * 5) eliminate rPacketInfo of MSDU_INFO_T
  517. *
  518. * 06 10 2010 cp.wu
  519. * [WPD00003833][MT6620 and MT5931] Driver migration
  520. * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
  521. * 2) when disconnected, indicate nic directly (no event is needed)
  522. *
  523. * 06 06 2010 kevin.huang
  524. * [WPD00003832][MT6620 5931] Create driver base
  525. * [MT6620 5931] Create driver base
  526. *
  527. * 04 26 2010 cp.wu
  528. * [WPD00001943]Create WiFi test driver framework on WinXP
  529. * 1) surpress compiler warning
  530. * 2) when acqruing LP-own, keep writing WHLPCR whenever OWN is not acquired yet
  531. *
  532. * 04 23 2010 cp.wu
  533. * [WPD00001943]Create WiFi test driver framework on WinXP
  534. * surpress compiler warning
  535. *
  536. * 04 13 2010 cp.wu
  537. * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
  538. * add framework for BT-over-Wi-Fi support.
  539. * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
  540. * * * * * * * * * * * * * 2) command sequence number is now increased atomically
  541. * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
  542. *
  543. * 04 12 2010 cp.wu
  544. * [WPD00001943]Create WiFi test driver framework on WinXP
  545. * add channel frequency <-> number conversion
  546. *
  547. * 04 06 2010 cp.wu
  548. * [WPD00001943]Create WiFi test driver framework on WinXP
  549. * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
  550. *
  551. * 04 06 2010 cp.wu
  552. * [WPD00003827][MT6620 Wi-Fi] Chariot fail and following ping fail, no pkt send from driver
  553. * correct nicProcessIST_impl() for interrupt status brought up by RX enhanced response
  554. *
  555. * 03 19 2010 cp.wu
  556. * [WPD00001943]Create WiFi test driver framework on WinXP
  557. * 1) add ACPI D0/D3 state switching support
  558. * * * * * * * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX response
  559. *
  560. * 03 17 2010 cp.wu
  561. * [WPD00001943]Create WiFi test driver framework on WinXP
  562. * always process TX interrupt first then RX interrupt.
  563. *
  564. * 02 25 2010 cp.wu
  565. * [WPD00001943]Create WiFi test driver framework on WinXP
  566. * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
  567. *
  568. * 02 23 2010 cp.wu
  569. * [WPD00001943]Create WiFi test driver framework on WinXP
  570. * add checksum offloading support.
  571. ** \main\maintrunk.MT6620WiFiDriver_Prj\27 2009-12-16 18:03:43 GMT mtk02752
  572. ** handling enhanced response which fields are fetched at different moments
  573. ** \main\maintrunk.MT6620WiFiDriver_Prj\26 2009-12-15 17:00:29 GMT mtk02752
  574. ** if RX enhanced response is used, D2H interrupt status should be coming from buffered result as well
  575. ** \main\maintrunk.MT6620WiFiDriver_Prj\25 2009-12-15 12:01:55 GMT mtk02752
  576. ** if TX_DONE bit is not set but WTSR0/WTSR1 is non-zero, then set TX_DONE
  577. ** bit due to time latency of interrupt status enhanced response
  578. ** \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-12-10 16:52:52 GMT mtk02752
  579. ** code clean
  580. ** \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-11-24 20:51:01 GMT mtk02752
  581. ** integrate with SD1 by invoking qmHandleMailboxRxMessage()
  582. ** \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-11-16 17:32:33 GMT mtk02752
  583. ** prepare code for invoking rxHandleMailboxRxMessage()
  584. ** \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-11-11 10:36:08 GMT mtk01084
  585. ** \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-11-09 22:56:41 GMT mtk01084
  586. ** modify HW access routines
  587. ** \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-10-30 18:17:20 GMT mtk01084
  588. ** prevent warning
  589. ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-10-29 19:54:57 GMT mtk01084
  590. ** init HIF
  591. ** \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-10-23 16:08:30 GMT mtk01084
  592. ** \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-10-13 21:59:12 GMT mtk01084
  593. ** update for new HW design
  594. ** \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-09-09 17:26:15 GMT mtk01084
  595. ** modify for CFG_TEST_WITH_MT5921
  596. ** \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-05-19 10:55:22 GMT mtk01461
  597. ** Unmask the unused HISR
  598. ** \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-05-18 15:59:13 GMT mtk01084
  599. ** remove debug purpose code
  600. ** \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-05-18 14:05:02 GMT mtk01084
  601. ** update for WIFI ownback part on initial
  602. ** \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-05-04 21:32:57 GMT mtk01084
  603. ** add temporarily code to set driver own on adapter initialization
  604. ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-04-28 10:35:41 GMT mtk01461
  605. ** Add init of TX aggregation and fix RX STATUS is DW align for SDIO_STATUS_ENHANCE mode
  606. ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-24 21:12:10 GMT mtk01104
  607. ** Add function nicRestoreSpiDefMode()
  608. ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-21 09:43:31 GMT mtk01461
  609. ** Revise for MTK coding style - nicInitializeAdapter()
  610. ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-04-17 19:52:47 GMT mtk01461
  611. ** Update allocate Adapter Memory for MGMT Memory pool
  612. ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-01 10:57:08 GMT mtk01461
  613. ** Refine the order of release memory from pucRxCoalescingBufCached
  614. ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-19 18:32:57 GMT mtk01084
  615. ** update for basic power management functions
  616. ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-18 21:00:14 GMT mtk01426
  617. ** Add CFG_SDIO_RX_ENHANCE support
  618. ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-16 09:10:27 GMT mtk01461
  619. ** Update TX PATH API
  620. ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:25:59 GMT mtk01426
  621. ** Init for develop
  622. **
  623. */
  624. /*******************************************************************************
  625. * C O M P I L E R F L A G S
  626. ********************************************************************************
  627. */
  628. /*******************************************************************************
  629. * E X T E R N A L R E F E R E N C E S
  630. ********************************************************************************
  631. */
  632. #include "precomp.h"
  633. /*******************************************************************************
  634. * C O N S T A N T S
  635. ********************************************************************************
  636. */
  637. const UINT_8 aucPhyCfg2PhyTypeSet[PHY_CONFIG_NUM] = {
  638. PHY_TYPE_SET_802_11ABG, /* PHY_CONFIG_802_11ABG */
  639. PHY_TYPE_SET_802_11BG, /* PHY_CONFIG_802_11BG */
  640. PHY_TYPE_SET_802_11G, /* PHY_CONFIG_802_11G */
  641. PHY_TYPE_SET_802_11A, /* PHY_CONFIG_802_11A */
  642. PHY_TYPE_SET_802_11B, /* PHY_CONFIG_802_11B */
  643. PHY_TYPE_SET_802_11ABGN, /* PHY_CONFIG_802_11ABGN */
  644. PHY_TYPE_SET_802_11BGN, /* PHY_CONFIG_802_11BGN */
  645. PHY_TYPE_SET_802_11AN, /* PHY_CONFIG_802_11AN */
  646. PHY_TYPE_SET_802_11GN /* PHY_CONFIG_802_11GN */
  647. };
  648. #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
  649. #define REQ_GATING_ENABLE_H2D_INT BIT(31)
  650. #define REQ_GATING_DISABLE_H2D_INT BIT(30)
  651. #define ACK_GATING_ENABLE_D2H_INT BIT(31)
  652. #define ACK_GATING_DISABLE_D2H_INT BIT(30)
  653. #define GATING_CONTROL_POLL_LIMIT 64
  654. #endif
  655. /*******************************************************************************
  656. * D A T A T Y P E S
  657. ********************************************************************************
  658. */
  659. /*******************************************************************************
  660. * P U B L I C D A T A
  661. ********************************************************************************
  662. */
  663. static INT_EVENT_MAP_T arIntEventMapTable[] = {
  664. {WHISR_ABNORMAL_INT, INT_EVENT_ABNORMAL},
  665. {WHISR_D2H_SW_INT, INT_EVENT_SW_INT},
  666. {WHISR_TX_DONE_INT, INT_EVENT_TX},
  667. {(WHISR_RX0_DONE_INT | WHISR_RX1_DONE_INT), INT_EVENT_RX}
  668. };
  669. static const UINT_8 ucIntEventMapSize = (sizeof(arIntEventMapTable) / sizeof(INT_EVENT_MAP_T));
  670. static IST_EVENT_FUNCTION apfnEventFuncTable[] = {
  671. nicProcessAbnormalInterrupt, /*!< INT_EVENT_ABNORMAL */
  672. nicProcessSoftwareInterrupt, /*!< INT_EVENT_SW_INT */
  673. nicProcessTxInterrupt, /*!< INT_EVENT_TX */
  674. nicProcessRxInterrupt, /*!< INT_EVENT_RX */
  675. };
  676. /*******************************************************************************
  677. * P R I V A T E D A T A
  678. ********************************************************************************
  679. */
  680. /*******************************************************************************
  681. * M A C R O S
  682. ********************************************************************************
  683. */
  684. /*! This macro is used to reduce coding errors inside nicAllocateAdapterMemory()
  685. * and also enhance the readability.
  686. */
  687. #define LOCAL_NIC_ALLOCATE_MEMORY(pucMem, u4Size, eMemType, pucComment) \
  688. { \
  689. DBGLOG(NIC, INFO, "Allocating %u bytes for %s.\n", u4Size, pucComment); \
  690. pucMem = (PUINT_8)kalMemAlloc(u4Size, eMemType); \
  691. if (pucMem == (PUINT_8)NULL) { \
  692. DBGLOG(NIC, ERROR, "Could not allocate %u bytes for %s.\n", u4Size, pucComment); \
  693. break; \
  694. } \
  695. ASSERT(((ULONG)pucMem % 4) == 0); \
  696. DBGLOG(NIC, TRACE, "Virtual Address = %p for %s.\n", pucMem, pucComment); \
  697. }
  698. /*******************************************************************************
  699. * F U N C T I O N D E C L A R A T I O N S
  700. ********************************************************************************
  701. */
  702. /*******************************************************************************
  703. * F U N C T I O N S
  704. ********************************************************************************
  705. */
  706. VOID HifDumpEnhanceModeData(P_ADAPTER_T prAdapter)
  707. {
  708. dumpMemory32((PUINT_32)prAdapter->prSDIOCtrl, sizeof(ENHANCE_MODE_DATA_STRUCT_T));
  709. }
  710. VOID HifRegDump(P_ADAPTER_T prAdapter)
  711. {
  712. UINT_32 i;
  713. UINT_32 RegVal = 0;
  714. for (i = 0; i <= 0x58; i += 4) {
  715. if ((i != MCR_WTDR0) && (i != MCR_WTDR1) && (i != MCR_WRDR0) &&
  716. (i != MCR_WRDR1) && (i != MCR_WSDIOCSR) && (i != MCR_WRPLR)) {
  717. HAL_MCR_RD(prAdapter, i, &RegVal);
  718. DBGLOG(NIC, WARN, "HIF Reg 0x%x = 0x%x\n", i, RegVal);
  719. }
  720. }
  721. DBGLOG(NIC, WARN, "\n\n");
  722. }
  723. BOOLEAN HifIsFwOwn(P_ADAPTER_T prAdapter)
  724. {
  725. return prAdapter->fgIsFwOwn;
  726. }
  727. /*----------------------------------------------------------------------------*/
  728. /*!
  729. * @brief This routine is responsible for the allocation of the data structures
  730. * inside the Adapter structure, include:
  731. * 1. SW_RFB_Ts
  732. * 2. Common coalescing buffer for TX PATH.
  733. *
  734. * @param prAdapter Pointer of Adapter Data Structure
  735. *
  736. * @retval WLAN_STATUS_SUCCESS - Has enough memory.
  737. * @retval WLAN_STATUS_RESOURCES - Memory is not enough.
  738. */
  739. /*----------------------------------------------------------------------------*/
  740. WLAN_STATUS nicAllocateAdapterMemory(IN P_ADAPTER_T prAdapter)
  741. {
  742. WLAN_STATUS status = WLAN_STATUS_RESOURCES;
  743. P_RX_CTRL_T prRxCtrl;
  744. P_TX_CTRL_T prTxCtrl;
  745. DEBUGFUNC("nicAllocateAdapterMemory");
  746. ASSERT(prAdapter);
  747. prRxCtrl = &prAdapter->rRxCtrl;
  748. prTxCtrl = &prAdapter->rTxCtrl;
  749. do {
  750. /* 4 <0> Reset all Memory Handler */
  751. #if CFG_DBG_MGT_BUF
  752. prAdapter->u4MemFreeDynamicCount = 0;
  753. prAdapter->u4MemAllocDynamicCount = 0;
  754. #endif
  755. prAdapter->pucMgtBufCached = (PUINT_8) NULL;
  756. prRxCtrl->pucRxCached = (PUINT_8) NULL;
  757. prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T) NULL;
  758. /* 4 <1> Memory for Management Memory Pool and CMD_INFO_T */
  759. /* Allocate memory for the CMD_INFO_T and its MGMT memory pool. */
  760. prAdapter->u4MgtBufCachedSize = MGT_BUFFER_SIZE;
  761. LOCAL_NIC_ALLOCATE_MEMORY(prAdapter->pucMgtBufCached,
  762. prAdapter->u4MgtBufCachedSize, VIR_MEM_TYPE, "COMMON MGMT MEMORY POOL");
  763. /* 4 <2> Memory for RX Descriptor */
  764. /* Initialize the number of rx buffers we will have in our queue. */
  765. /* <TODO> We may setup ucRxPacketDescriptors by GLUE Layer, and using
  766. * this variable directly.
  767. */
  768. /* Allocate memory for the SW receive structures. */
  769. prRxCtrl->u4RxCachedSize = CFG_RX_MAX_PKT_NUM * ALIGN_4(sizeof(SW_RFB_T));
  770. LOCAL_NIC_ALLOCATE_MEMORY(prRxCtrl->pucRxCached, prRxCtrl->u4RxCachedSize, VIR_MEM_TYPE, "SW_RFB_T");
  771. /* 4 <3> Memory for TX DEscriptor */
  772. prTxCtrl->u4TxCachedSize = CFG_TX_MAX_PKT_NUM * ALIGN_4(sizeof(MSDU_INFO_T));
  773. LOCAL_NIC_ALLOCATE_MEMORY(prTxCtrl->pucTxCached, prTxCtrl->u4TxCachedSize, VIR_MEM_TYPE, "MSDU_INFO_T");
  774. /* 4 <4> Memory for Common Coalescing Buffer */
  775. #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
  776. prAdapter->pucCoalescingBufCached = (PUINT_8) NULL;
  777. /* Allocate memory for the common coalescing buffer. */
  778. prAdapter->u4CoalescingBufCachedSize = CFG_COALESCING_BUFFER_SIZE > CFG_RX_COALESCING_BUFFER_SIZE ?
  779. CFG_COALESCING_BUFFER_SIZE : CFG_RX_COALESCING_BUFFER_SIZE;
  780. prAdapter->pucCoalescingBufCached = kalAllocateIOBuffer(prAdapter->u4CoalescingBufCachedSize);
  781. if (prAdapter->pucCoalescingBufCached == NULL) {
  782. DBGLOG(NIC, ERROR,
  783. "Could not allocate %u bytes for coalescing buffer.\n",
  784. prAdapter->u4CoalescingBufCachedSize);
  785. break;
  786. }
  787. #endif /* CFG_COALESCING_BUFFER_SIZE */
  788. /* 4 <5> Memory for enhanced interrupt response */
  789. prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)
  790. kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T));
  791. if (prAdapter->prSDIOCtrl == NULL) {
  792. DBGLOG(NIC, ERROR,
  793. "Could not allocate %zu bytes for interrupt response.\n",
  794. sizeof(ENHANCE_MODE_DATA_STRUCT_T));
  795. break;
  796. }
  797. status = WLAN_STATUS_SUCCESS;
  798. } while (FALSE);
  799. if (status != WLAN_STATUS_SUCCESS)
  800. nicReleaseAdapterMemory(prAdapter);
  801. return status;
  802. } /* end of nicAllocateAdapterMemory() */
  803. /*----------------------------------------------------------------------------*/
  804. /*!
  805. * @brief This routine is responsible for releasing the allocated memory by
  806. * nicAllocatedAdapterMemory().
  807. *
  808. * @param prAdapter Pointer of Adapter Data Structure
  809. *
  810. * @return (none)
  811. */
  812. /*----------------------------------------------------------------------------*/
  813. VOID nicReleaseAdapterMemory(IN P_ADAPTER_T prAdapter)
  814. {
  815. P_TX_CTRL_T prTxCtrl;
  816. P_RX_CTRL_T prRxCtrl;
  817. ASSERT(prAdapter);
  818. prTxCtrl = &prAdapter->rTxCtrl;
  819. prRxCtrl = &prAdapter->rRxCtrl;
  820. /* 4 <5> Memory for enhanced interrupt response */
  821. if (prAdapter->prSDIOCtrl) {
  822. kalReleaseIOBuffer((PVOID) prAdapter->prSDIOCtrl, sizeof(ENHANCE_MODE_DATA_STRUCT_T));
  823. prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T) NULL;
  824. }
  825. /* 4 <4> Memory for Common Coalescing Buffer */
  826. #if CFG_COALESCING_BUFFER_SIZE || CFG_SDIO_RX_AGG
  827. if (prAdapter->pucCoalescingBufCached) {
  828. kalReleaseIOBuffer((PVOID) prAdapter->pucCoalescingBufCached, prAdapter->u4CoalescingBufCachedSize);
  829. prAdapter->pucCoalescingBufCached = (PUINT_8) NULL;
  830. }
  831. #endif /* CFG_COALESCING_BUFFER_SIZE */
  832. /* 4 <3> Memory for TX Descriptor */
  833. if (prTxCtrl->pucTxCached) {
  834. kalMemFree((PVOID) prTxCtrl->pucTxCached, VIR_MEM_TYPE, prTxCtrl->u4TxCachedSize);
  835. prTxCtrl->pucTxCached = (PUINT_8) NULL;
  836. }
  837. /* 4 <2> Memory for RX Descriptor */
  838. if (prRxCtrl->pucRxCached) {
  839. kalMemFree((PVOID) prRxCtrl->pucRxCached, VIR_MEM_TYPE, prRxCtrl->u4RxCachedSize);
  840. prRxCtrl->pucRxCached = (PUINT_8) NULL;
  841. }
  842. /* 4 <1> Memory for Management Memory Pool */
  843. if (prAdapter->pucMgtBufCached) {
  844. kalMemFree((PVOID) prAdapter->pucMgtBufCached, VIR_MEM_TYPE, prAdapter->u4MgtBufCachedSize);
  845. prAdapter->pucMgtBufCached = (PUINT_8) NULL;
  846. }
  847. #if CFG_DBG_MGT_BUF
  848. /* Check if all allocated memories are free */
  849. ASSERT(prAdapter->u4MemFreeDynamicCount == prAdapter->u4MemAllocDynamicCount);
  850. #endif
  851. }
  852. /*----------------------------------------------------------------------------*/
  853. /*!
  854. * @brief disable global interrupt
  855. *
  856. * @param prAdapter pointer to the Adapter handler
  857. *
  858. * @return (none)
  859. */
  860. /*----------------------------------------------------------------------------*/
  861. VOID nicDisableInterrupt(IN P_ADAPTER_T prAdapter)
  862. {
  863. ASSERT(prAdapter);
  864. HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_CLR);
  865. prAdapter->fgIsIntEnable = FALSE;
  866. }
  867. /*----------------------------------------------------------------------------*/
  868. /*!
  869. * @brief enable global interrupt
  870. *
  871. * @param prAdapter pointer to the Adapter handler
  872. *
  873. * @return (none)
  874. */
  875. /*----------------------------------------------------------------------------*/
  876. VOID nicEnableInterrupt(IN P_ADAPTER_T prAdapter)
  877. {
  878. BOOLEAN fgIsIntEnableCache;
  879. ASSERT(prAdapter);
  880. fgIsIntEnableCache = prAdapter->fgIsIntEnable;
  881. prAdapter->fgIsIntEnable = TRUE; /* NOTE(Kevin): It must be placed before MCR GINT write. */
  882. /* If need enable INT and also set LPOwn at the same time. */
  883. if (prAdapter->fgIsIntEnableWithLPOwnSet) {
  884. prAdapter->fgIsIntEnableWithLPOwnSet = FALSE; /* NOTE(Kevin): It's better to place it
  885. * before MCR GINT write.
  886. */
  887. /* If INT was enabled, only set LPOwn */
  888. if (fgIsIntEnableCache) {
  889. HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET);
  890. prAdapter->fgIsFwOwn = TRUE;
  891. }
  892. /* If INT was not enabled, enable it and also set LPOwn now */
  893. else {
  894. HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET | WHLPCR_INT_EN_SET);
  895. prAdapter->fgIsFwOwn = TRUE;
  896. }
  897. }
  898. /* If INT was not enabled, enable it now */
  899. else if (!fgIsIntEnableCache)
  900. HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_INT_EN_SET);
  901. } /* end of nicEnableInterrupt() */
  902. #if CFG_SDIO_INTR_ENHANCE
  903. /*----------------------------------------------------------------------------*/
  904. /*!
  905. * @brief For SDIO enhance mode, set the max rx len and tx status
  906. *
  907. * @param prAdapter a pointer to adapter private data structure.
  908. *
  909. * @return - none
  910. */
  911. /*----------------------------------------------------------------------------*/
  912. VOID nicSDIOInit(IN P_ADAPTER_T prAdapter)
  913. {
  914. UINT_32 u4Value = 0;
  915. ASSERT(prAdapter);
  916. /* 4 <1> Check STATUS Buffer is DW alignment. */
  917. ASSERT(IS_ALIGN_4((ULONG)&prAdapter->prSDIOCtrl->u4WHISR));
  918. /* 4 <2> Setup STATUS count. */
  919. {
  920. HAL_MCR_RD(prAdapter, MCR_WHCR, &u4Value);
  921. /* 4 <2.1> Setup the number of maximum RX length to be report */
  922. u4Value &= ~(WHCR_MAX_HIF_RX_LEN_NUM);
  923. u4Value |= ((SDIO_MAXIMUM_RX_LEN_NUM << WHCR_OFFSET_MAX_HIF_RX_LEN_NUM));
  924. /* 4 <2.2> Setup RX enhancement mode */
  925. #if CFG_SDIO_RX_ENHANCE
  926. u4Value |= WHCR_RX_ENHANCE_MODE_EN;
  927. #else
  928. u4Value &= ~WHCR_RX_ENHANCE_MODE_EN;
  929. #endif /* CFG_SDIO_RX_AGG */
  930. HAL_MCR_WR(prAdapter, MCR_WHCR, u4Value);
  931. }
  932. return;
  933. } /* end of nicSDIOInit() */
  934. /*----------------------------------------------------------------------------*/
  935. /*!
  936. * @brief Read interrupt status from hardware
  937. *
  938. * @param prAdapter pointer to the Adapter handler
  939. * @param the interrupts
  940. *
  941. * @return N/A
  942. *
  943. */
  944. /*----------------------------------------------------------------------------*/
  945. VOID nicSDIOReadIntStatus(IN P_ADAPTER_T prAdapter, OUT PUINT_32 pu4IntStatus)
  946. {
  947. P_SDIO_CTRL_T prSDIOCtrl;
  948. DEBUGFUNC("nicSDIOReadIntStatus");
  949. ASSERT(prAdapter);
  950. ASSERT(pu4IntStatus);
  951. /*
  952. prSDIOCtrl is from IO buffer.
  953. prAdapter->prSDIOCtrl = (P_SDIO_CTRL_T)
  954. kalAllocateIOBuffer(sizeof(ENHANCE_MODE_DATA_STRUCT_T));
  955. */
  956. prSDIOCtrl = prAdapter->prSDIOCtrl;
  957. ASSERT(prSDIOCtrl);
  958. HAL_PORT_RD(prAdapter,
  959. MCR_WHISR,
  960. sizeof(ENHANCE_MODE_DATA_STRUCT_T), (PUINT_8) prSDIOCtrl, sizeof(ENHANCE_MODE_DATA_STRUCT_T));
  961. if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  962. *pu4IntStatus = 0;
  963. return;
  964. }
  965. /* workaround */
  966. if ((prSDIOCtrl->u4WHISR & WHISR_TX_DONE_INT) == 0 &&
  967. (prSDIOCtrl->rTxInfo.au4WTSR[0] | prSDIOCtrl->rTxInfo.au4WTSR[1])) {
  968. prSDIOCtrl->u4WHISR |= WHISR_TX_DONE_INT;
  969. }
  970. if ((prSDIOCtrl->u4WHISR & BIT(31)) == 0 &&
  971. HAL_GET_MAILBOX_READ_CLEAR(prAdapter) == TRUE &&
  972. (prSDIOCtrl->u4RcvMailbox0 != 0 || prSDIOCtrl->u4RcvMailbox1 != 0)) {
  973. prSDIOCtrl->u4WHISR |= BIT(31);
  974. }
  975. *pu4IntStatus = prSDIOCtrl->u4WHISR;
  976. } /* end of nicSDIOReadIntStatus() */
  977. #endif
  978. /*----------------------------------------------------------------------------*/
  979. /*!
  980. * @brief The function used to read interrupt status and then invoking
  981. * dispatching procedure for the appropriate functions
  982. * corresponding to specific interrupt bits
  983. *
  984. * @param prAdapter pointer to the Adapter handler
  985. *
  986. * @retval WLAN_STATUS_SUCCESS
  987. * @retval WLAN_STATUS_ADAPTER_NOT_READY
  988. */
  989. /*----------------------------------------------------------------------------*/
  990. WLAN_STATUS nicProcessIST(IN P_ADAPTER_T prAdapter)
  991. {
  992. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  993. UINT_32 u4IntStatus = 0;
  994. UINT_32 i;
  995. DEBUGFUNC("nicProcessIST");
  996. /* DBGLOG(NIC, LOUD, ("\n")); */
  997. ASSERT(prAdapter);
  998. if (prAdapter->rAcpiState == ACPI_STATE_D3) {
  999. DBGLOG(REQ, WARN, "Fail in set nicProcessIST! (Adapter not ready). ACPI=D%d, Radio=%d\n",
  1000. prAdapter->rAcpiState, prAdapter->fgIsRadioOff);
  1001. return WLAN_STATUS_ADAPTER_NOT_READY;
  1002. }
  1003. #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
  1004. if (prAdapter->fgIsClockGatingEnabled == TRUE)
  1005. nicDisableClockGating(prAdapter);
  1006. #endif
  1007. for (i = 0; i < CFG_IST_LOOP_COUNT; i++) { /* CFG_IST_LOOP_COUNT = 1 */
  1008. #if CFG_SDIO_INTR_ENHANCE
  1009. nicSDIOReadIntStatus(prAdapter, &u4IntStatus);
  1010. #else
  1011. HAL_MCR_RD(prAdapter, MCR_WHISR, &u4IntStatus);
  1012. #endif /* CFG_SDIO_INTR_ENHANCE */
  1013. /* DBGLOG(NIC, TRACE, ("u4IntStatus: 0x%x\n", u4IntStatus)); */
  1014. if (u4IntStatus & ~(WHIER_DEFAULT | WHIER_FW_OWN_BACK_INT_EN)) {
  1015. DBGLOG(INTR, WARN, "Un-handled HISR %#x, HISR = %#x (HIER:0x%x)\n",
  1016. (UINT_32) (u4IntStatus & ~WHIER_DEFAULT), u4IntStatus,
  1017. (UINT_32) WHIER_DEFAULT);
  1018. u4IntStatus &= WHIER_DEFAULT;
  1019. }
  1020. nicProcessIST_impl(prAdapter, u4IntStatus);
  1021. if (u4IntStatus == 0) {
  1022. if (i == 0)
  1023. u4Status = WLAN_STATUS_NOT_INDICATING;
  1024. break;
  1025. }
  1026. }
  1027. #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
  1028. if (prAdapter->fgIsClockGatingEnabled == FALSE)
  1029. nicEnableClockGating(prAdapter);
  1030. #endif
  1031. return u4Status;
  1032. } /* end of nicProcessIST() */
  1033. /*----------------------------------------------------------------------------*/
  1034. /*!
  1035. * @brief The function used to dispatch the appropriate functions for specific
  1036. * interrupt bits
  1037. *
  1038. * @param prAdapter pointer to the Adapter handler
  1039. * u4IntStatus interrupt status bits
  1040. *
  1041. * @retval WLAN_STATUS_SUCCESS
  1042. * @retval WLAN_STATUS_ADAPTER_NOT_READY
  1043. */
  1044. /*----------------------------------------------------------------------------*/
  1045. WLAN_STATUS nicProcessIST_impl(IN P_ADAPTER_T prAdapter, IN UINT_32 u4IntStatus)
  1046. {
  1047. UINT_32 u4IntCount = 0;
  1048. P_INT_EVENT_MAP_T prIntEventMap = NULL;
  1049. ASSERT(prAdapter);
  1050. prAdapter->u4IntStatus = u4IntStatus;
  1051. /* Process each of the interrupt status consequently */
  1052. prIntEventMap = &arIntEventMapTable[0];
  1053. for (u4IntCount = 0; u4IntCount < ucIntEventMapSize; prIntEventMap++, u4IntCount++) {
  1054. if (prIntEventMap->u4Int & prAdapter->u4IntStatus) {
  1055. if (prIntEventMap->u4Event == INT_EVENT_RX && prAdapter->fgIsEnterD3ReqIssued == TRUE) {
  1056. /* ignore */
  1057. } else if (apfnEventFuncTable[prIntEventMap->u4Event] != NULL) {
  1058. apfnEventFuncTable[prIntEventMap->u4Event] (prAdapter);
  1059. } else {
  1060. DBGLOG(INTR, WARN,
  1061. "Empty INTR handler! ISAR bit#: %u, event:%u, func: %p\n",
  1062. prIntEventMap->u4Int, prIntEventMap->u4Event,
  1063. apfnEventFuncTable[prIntEventMap->u4Event]);
  1064. ASSERT(0); /* to trap any NULL interrupt handler */
  1065. }
  1066. prAdapter->u4IntStatus &= ~prIntEventMap->u4Int;
  1067. }
  1068. }
  1069. return WLAN_STATUS_SUCCESS;
  1070. } /* end of nicProcessIST_impl() */
  1071. /*----------------------------------------------------------------------------*/
  1072. /*!
  1073. * @brief Verify the CHIP ID
  1074. *
  1075. * @param prAdapter a pointer to adapter private data structure.
  1076. *
  1077. *
  1078. * @retval TRUE CHIP ID is the same as the setting compiled
  1079. * @retval FALSE CHIP ID is different from the setting compiled
  1080. */
  1081. /*----------------------------------------------------------------------------*/
  1082. BOOLEAN nicVerifyChipID(IN P_ADAPTER_T prAdapter)
  1083. {
  1084. UINT_32 u4CIR = 0;
  1085. ASSERT(prAdapter);
  1086. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4CIR);
  1087. DBGLOG(NIC, TRACE, "Chip ID: 0x%x\n", (UINT_32) (u4CIR & WCIR_CHIP_ID));
  1088. DBGLOG(NIC, TRACE, "Revision ID: 0x%x\n", (UINT_32) ((u4CIR & WCIR_REVISION_ID) >> 16));
  1089. #if 0
  1090. if (((u4CIR & WCIR_CHIP_ID) != MTK_CHIP_REV_72) && ((u4CIR & WCIR_CHIP_ID) != MTK_CHIP_REV_82))
  1091. return FALSE;
  1092. #endif
  1093. prAdapter->ucRevID = (UINT_8) (((u4CIR & WCIR_REVISION_ID) >> 16) & 0xF);
  1094. return TRUE;
  1095. }
  1096. /*----------------------------------------------------------------------------*/
  1097. /*!
  1098. * @brief Initialize the MCR to the appropriate init value, and verify the init
  1099. * value
  1100. *
  1101. * @param prAdapter a pointer to adapter private data structure.
  1102. *
  1103. * @return -
  1104. */
  1105. /*----------------------------------------------------------------------------*/
  1106. VOID nicMCRInit(IN P_ADAPTER_T prAdapter)
  1107. {
  1108. ASSERT(prAdapter);
  1109. /* 4 <0> Initial value */
  1110. }
  1111. VOID nicHifInit(IN P_ADAPTER_T prAdapter)
  1112. {
  1113. ASSERT(prAdapter);
  1114. #if 0
  1115. /* reset event */
  1116. nicPutMailbox(prAdapter, 0, 0x52455345); /* RESE */
  1117. nicPutMailbox(prAdapter, 1, 0x545F5746); /* T_WF */
  1118. nicSetSwIntr(prAdapter, BIT(16));
  1119. #endif
  1120. }
  1121. /*----------------------------------------------------------------------------*/
  1122. /*!
  1123. * @brief Initialize the Adapter soft variable
  1124. *
  1125. * @param prAdapter pointer to the Adapter handler
  1126. *
  1127. * @return (none)
  1128. *
  1129. */
  1130. /*----------------------------------------------------------------------------*/
  1131. WLAN_STATUS nicInitializeAdapter(IN P_ADAPTER_T prAdapter)
  1132. {
  1133. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  1134. ASSERT(prAdapter);
  1135. prAdapter->fgIsIntEnableWithLPOwnSet = FALSE;
  1136. do {
  1137. if (!nicVerifyChipID(prAdapter)) {
  1138. u4Status = WLAN_STATUS_FAILURE;
  1139. break;
  1140. }
  1141. /* 4 <1> MCR init */
  1142. nicMCRInit(prAdapter);
  1143. #if CFG_SDIO_INTR_ENHANCE
  1144. nicSDIOInit(prAdapter);
  1145. #endif /* CFG_SDIO_INTR_ENHANCE */
  1146. HAL_MCR_WR(prAdapter, MCR_WHIER, WHIER_DEFAULT);
  1147. /* 4 <2> init FW HIF */
  1148. nicHifInit(prAdapter);
  1149. } while (FALSE);
  1150. return u4Status;
  1151. }
  1152. #if defined(_HIF_SPI)
  1153. /*----------------------------------------------------------------------------*/
  1154. /*!
  1155. * \brief Restore the SPI Mode Select to default mode,
  1156. * this is important while driver is unload, and this must be last mcr
  1157. * since the operation will let the hif use 8bit mode access
  1158. *
  1159. * \param[in] prAdapter a pointer to adapter private data structure.
  1160. * \param[in] eGPIO2_Mode GPIO2 operation mode
  1161. *
  1162. * \return (none)
  1163. */
  1164. /*----------------------------------------------------------------------------*/
  1165. void nicRestoreSpiDefMode(IN P_ADAPTER_T prAdapter)
  1166. {
  1167. ASSERT(prAdapter);
  1168. HAL_MCR_WR(prAdapter, MCR_WCSR, SPICSR_8BIT_MODE_DATA);
  1169. }
  1170. #endif
  1171. /*----------------------------------------------------------------------------*/
  1172. /*!
  1173. * @brief Process rx interrupt. When the rx
  1174. * Interrupt is asserted, it means there are frames in queue.
  1175. *
  1176. * @param prAdapter Pointer to the Adapter structure.
  1177. *
  1178. * @return (none)
  1179. */
  1180. /*----------------------------------------------------------------------------*/
  1181. VOID nicProcessAbnormalInterrupt(IN P_ADAPTER_T prAdapter)
  1182. {
  1183. UINT_32 u4Value = 0;
  1184. HAL_MCR_RD(prAdapter, MCR_WASR, &u4Value);
  1185. DBGLOG(REQ, WARN, "MCR_WASR: 0x%x\n", u4Value);
  1186. }
  1187. /*----------------------------------------------------------------------------*/
  1188. /*!
  1189. * @brief .
  1190. *
  1191. * @param prAdapter Pointer to the Adapter structure.
  1192. *
  1193. * @return (none)
  1194. */
  1195. /*----------------------------------------------------------------------------*/
  1196. VOID nicProcessFwOwnBackInterrupt(IN P_ADAPTER_T prAdapter)
  1197. {
  1198. } /* end of nicProcessFwOwnBackInterrupt() */
  1199. /*----------------------------------------------------------------------------*/
  1200. /*!
  1201. * @brief .
  1202. *
  1203. * @param prAdapter Pointer to the Adapter structure.
  1204. *
  1205. * @return (none)
  1206. */
  1207. /*----------------------------------------------------------------------------*/
  1208. VOID nicProcessSoftwareInterrupt(IN P_ADAPTER_T prAdapter)
  1209. {
  1210. UINT_32 u4IntrBits;
  1211. ASSERT(prAdapter);
  1212. u4IntrBits = prAdapter->u4IntStatus & BITS(8, 31);
  1213. if ((u4IntrBits & WHISR_D2H_SW_ASSERT_INFO_INT) != 0) {
  1214. nicPrintFirmwareAssertInfo(prAdapter);
  1215. #if CFG_CHIP_RESET_SUPPORT
  1216. glSendResetRequest();
  1217. #endif
  1218. }
  1219. #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
  1220. ASSERT((u4IntrBits & (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT))
  1221. != (ACK_GATING_ENABLE_D2H_INT | ACK_GATING_DISABLE_D2H_INT));
  1222. if (u4IntrBits & ACK_GATING_ENABLE_D2H_INT)
  1223. prAdapter->fgIsClockGatingEnabled = TRUE;
  1224. if (u4IntrBits & ACK_GATING_DISABLE_D2H_INT) {
  1225. prAdapter->fgIsClockGatingEnabled = FALSE;
  1226. /* Indicate Service Thread for TX */
  1227. if (kalGetTxPendingCmdCount(prAdapter->prGlueInfo) > 0 || wlanGetTxPendingFrameCount(prAdapter) > 0)
  1228. kalSetEvent(prAdapter->prGlueInfo);
  1229. }
  1230. #endif
  1231. DBGLOG(REQ, WARN, "u4IntrBits: 0x%x\n", u4IntrBits);
  1232. } /* end of nicProcessSoftwareInterrupt() */
  1233. VOID nicPutMailbox(IN P_ADAPTER_T prAdapter, IN UINT_32 u4MailboxNum, IN UINT_32 u4Data)
  1234. {
  1235. if (u4MailboxNum == 0) {
  1236. /* HAL_MCR_WR */
  1237. HAL_MCR_WR(prAdapter, MCR_H2DSM0R, u4Data);
  1238. } else if (u4MailboxNum == 1) {
  1239. /* HAL_MCR_WR */
  1240. HAL_MCR_WR(prAdapter, MCR_H2DSM1R, u4Data);
  1241. } else {
  1242. ASSERT(0);
  1243. }
  1244. }
  1245. VOID nicGetMailbox(IN P_ADAPTER_T prAdapter, IN UINT_32 u4MailboxNum, OUT PUINT_32 pu4Data)
  1246. {
  1247. if (u4MailboxNum == 0) {
  1248. /* HAL_MCR_RD */
  1249. HAL_MCR_RD(prAdapter, MCR_D2HRM0R, pu4Data);
  1250. } else if (u4MailboxNum == 1) {
  1251. /* HAL_MCR_RD */
  1252. HAL_MCR_RD(prAdapter, MCR_D2HRM1R, pu4Data);
  1253. } else {
  1254. ASSERT(0);
  1255. }
  1256. }
  1257. VOID nicSetSwIntr(IN P_ADAPTER_T prAdapter, IN UINT_32 u4SwIntrBitmap)
  1258. {
  1259. /* NOTE:
  1260. * SW interrupt in HW bit 16 is mapping to SW bit 0 (shift 16bit in HW transparancy)
  1261. * SW interrupt valid from b0~b15
  1262. */
  1263. ASSERT((u4SwIntrBitmap & BITS(0, 15)) == 0);
  1264. /* DBGLOG(NIC, TRACE, ("u4SwIntrBitmap: 0x%08x\n", u4SwIntrBitmap)); */
  1265. HAL_MCR_WR(prAdapter, MCR_WSICR, u4SwIntrBitmap);
  1266. }
  1267. /*----------------------------------------------------------------------------*/
  1268. /*!
  1269. * @brief This procedure is used to dequeue from prAdapter->rPendingCmdQueue
  1270. * with specified sequential number
  1271. *
  1272. * @param prAdapter Pointer of ADAPTER_T
  1273. * ucSeqNum Sequential Number
  1274. *
  1275. * @retval - P_CMD_INFO_T
  1276. */
  1277. /*----------------------------------------------------------------------------*/
  1278. P_CMD_INFO_T nicGetPendingCmdInfo(IN P_ADAPTER_T prAdapter, IN UINT_8 ucSeqNum)
  1279. {
  1280. P_QUE_T prCmdQue;
  1281. QUE_T rTempCmdQue;
  1282. P_QUE_T prTempCmdQue = &rTempCmdQue;
  1283. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  1284. P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) NULL;
  1285. GLUE_SPIN_LOCK_DECLARATION();
  1286. ASSERT(prAdapter);
  1287. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  1288. prCmdQue = &prAdapter->rPendingCmdQueue;
  1289. QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
  1290. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  1291. while (prQueueEntry) {
  1292. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  1293. if (prCmdInfo->ucCmdSeqNum == ucSeqNum)
  1294. break;
  1295. QUEUE_INSERT_TAIL(prCmdQue, prQueueEntry);
  1296. prCmdInfo = NULL;
  1297. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  1298. }
  1299. QUEUE_CONCATENATE_QUEUES(prCmdQue, prTempCmdQue);
  1300. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  1301. return prCmdInfo;
  1302. }
  1303. /*----------------------------------------------------------------------------*/
  1304. /*!
  1305. * @brief This procedure is used to dequeue from prAdapter->rTxCtrl.rTxMgmtTxingQueue
  1306. * with specified sequential number
  1307. *
  1308. * @param prAdapter Pointer of ADAPTER_T
  1309. * ucSeqNum Sequential Number
  1310. *
  1311. * @retval - P_MSDU_INFO_T
  1312. */
  1313. /*----------------------------------------------------------------------------*/
  1314. P_MSDU_INFO_T nicGetPendingTxMsduInfo(IN P_ADAPTER_T prAdapter, IN UINT_8 ucSeqNum)
  1315. {
  1316. P_QUE_T prTxingQue;
  1317. QUE_T rTempQue;
  1318. P_QUE_T prTempQue = &rTempQue;
  1319. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  1320. P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T) NULL;
  1321. GLUE_SPIN_LOCK_DECLARATION();
  1322. ASSERT(prAdapter);
  1323. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
  1324. prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
  1325. QUEUE_MOVE_ALL(prTempQue, prTxingQue);
  1326. QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
  1327. while (prQueueEntry) {
  1328. prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
  1329. if (prMsduInfo->ucTxSeqNum == ucSeqNum)
  1330. break;
  1331. QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
  1332. prMsduInfo = NULL;
  1333. QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
  1334. }
  1335. QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
  1336. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
  1337. return prMsduInfo;
  1338. }
  1339. P_MSDU_INFO_T nicGetPendingStaMMPDU(IN P_ADAPTER_T prAdapter, IN UINT_8 ucStaRecIdx)
  1340. {
  1341. P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T) NULL;
  1342. P_QUE_T prTxingQue = (P_QUE_T) NULL;
  1343. QUE_T rTempQue;
  1344. P_QUE_T prTempQue = &rTempQue;
  1345. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  1346. P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T) NULL;
  1347. GLUE_SPIN_LOCK_DECLARATION();
  1348. if (prAdapter == NULL) {
  1349. ASSERT(FALSE);
  1350. return NULL;
  1351. }
  1352. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
  1353. do {
  1354. prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
  1355. QUEUE_MOVE_ALL(prTempQue, prTxingQue);
  1356. QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
  1357. while (prQueueEntry) {
  1358. prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
  1359. if ((prMsduInfo->ucStaRecIndex == ucStaRecIdx) && (prMsduInfo->pfTxDoneHandler != NULL)) {
  1360. QM_TX_SET_NEXT_MSDU_INFO(prMsduInfo, prMsduInfoListHead);
  1361. prMsduInfoListHead = prMsduInfo;
  1362. } else {
  1363. QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
  1364. prMsduInfo = NULL;
  1365. }
  1366. QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
  1367. }
  1368. } while (FALSE);
  1369. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
  1370. return prMsduInfoListHead;
  1371. } /* nicGetPendingStaMMPDU */
  1372. VOID nicFreePendingTxMsduInfoByNetwork(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType)
  1373. {
  1374. P_QUE_T prTxingQue;
  1375. QUE_T rTempQue;
  1376. P_QUE_T prTempQue = &rTempQue;
  1377. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  1378. P_MSDU_INFO_T prMsduInfoListHead = (P_MSDU_INFO_T) NULL;
  1379. P_MSDU_INFO_T prMsduInfoListTail = (P_MSDU_INFO_T) NULL;
  1380. P_MSDU_INFO_T prMsduInfo = (P_MSDU_INFO_T) NULL;
  1381. GLUE_SPIN_LOCK_DECLARATION();
  1382. ASSERT(prAdapter);
  1383. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
  1384. prTxingQue = &(prAdapter->rTxCtrl.rTxMgmtTxingQueue);
  1385. QUEUE_MOVE_ALL(prTempQue, prTxingQue);
  1386. QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
  1387. while (prQueueEntry) {
  1388. prMsduInfo = (P_MSDU_INFO_T) prQueueEntry;
  1389. if ((ENUM_NETWORK_TYPE_INDEX_T) (prMsduInfo->ucNetworkType) == eNetworkType) {
  1390. if (prMsduInfoListHead == NULL) {
  1391. prMsduInfoListHead = prMsduInfoListTail = prMsduInfo;
  1392. } else {
  1393. QM_TX_SET_NEXT_MSDU_INFO(prMsduInfoListTail, prMsduInfo);
  1394. prMsduInfoListTail = prMsduInfo;
  1395. }
  1396. } else {
  1397. QUEUE_INSERT_TAIL(prTxingQue, prQueueEntry);
  1398. prMsduInfo = NULL;
  1399. }
  1400. QUEUE_REMOVE_HEAD(prTempQue, prQueueEntry, P_QUE_ENTRY_T);
  1401. }
  1402. QUEUE_CONCATENATE_QUEUES(prTxingQue, prTempQue);
  1403. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TXING_MGMT_LIST);
  1404. /* free */
  1405. if (prMsduInfoListHead)
  1406. nicTxFreeMsduInfoPacket(prAdapter, prMsduInfoListHead);
  1407. return;
  1408. } /* end of nicFreePendingTxMsduInfoByNetwork() */
  1409. /*----------------------------------------------------------------------------*/
  1410. /*!
  1411. * @brief This procedure is used to retrieve a CMD sequence number atomically
  1412. *
  1413. * @param prAdapter Pointer of ADAPTER_T
  1414. *
  1415. * @retval - UINT_8
  1416. */
  1417. /*----------------------------------------------------------------------------*/
  1418. UINT_8 nicIncreaseCmdSeqNum(IN P_ADAPTER_T prAdapter)
  1419. {
  1420. UINT_8 ucRetval;
  1421. KAL_SPIN_LOCK_DECLARATION();
  1422. ASSERT(prAdapter);
  1423. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
  1424. prAdapter->ucCmdSeqNum++;
  1425. ucRetval = prAdapter->ucCmdSeqNum;
  1426. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_SEQ_NUM);
  1427. return ucRetval;
  1428. }
  1429. /*----------------------------------------------------------------------------*/
  1430. /*!
  1431. * @brief This procedure is used to retrieve a TX sequence number atomically
  1432. *
  1433. * @param prAdapter Pointer of ADAPTER_T
  1434. *
  1435. * @retval - UINT_8
  1436. */
  1437. /*----------------------------------------------------------------------------*/
  1438. UINT_8 nicIncreaseTxSeqNum(IN P_ADAPTER_T prAdapter)
  1439. {
  1440. UINT_8 ucRetval;
  1441. KAL_SPIN_LOCK_DECLARATION();
  1442. ASSERT(prAdapter);
  1443. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
  1444. prAdapter->ucTxSeqNum++;
  1445. ucRetval = prAdapter->ucTxSeqNum;
  1446. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_SEQ_NUM);
  1447. return ucRetval;
  1448. }
  1449. /*----------------------------------------------------------------------------*/
  1450. /*!
  1451. * @brief This utility function is used to handle
  1452. * media state change event
  1453. *
  1454. * @param
  1455. *
  1456. * @retval
  1457. */
  1458. /*----------------------------------------------------------------------------*/
  1459. WLAN_STATUS
  1460. nicMediaStateChange(IN P_ADAPTER_T prAdapter,
  1461. IN ENUM_NETWORK_TYPE_INDEX_T eNetworkType, IN P_EVENT_CONNECTION_STATUS prConnectionStatus)
  1462. {
  1463. P_GLUE_INFO_T prGlueInfo;
  1464. ASSERT(prAdapter);
  1465. prGlueInfo = prAdapter->prGlueInfo;
  1466. switch (eNetworkType) {
  1467. case NETWORK_TYPE_AIS_INDEX:
  1468. if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_DISCONNECTED) { /* disconnected */
  1469. if (kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
  1470. DBGLOG(NIC, TRACE, "DisByMC\n");
  1471. kalIndicateStatusAndComplete(prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  1472. prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
  1473. }
  1474. /* reset buffered link quality information */
  1475. prAdapter->fgIsLinkQualityValid = FALSE;
  1476. prAdapter->fgIsLinkRateValid = FALSE;
  1477. } else if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_CONNECTED) { /* connected */
  1478. prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
  1479. /* fill information for association result */
  1480. prAdapter->rWlanInfo.rCurrBssId.rSsid.u4SsidLen = prConnectionStatus->ucSsidLen;
  1481. kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.rSsid.aucSsid,
  1482. prConnectionStatus->aucSsid, prConnectionStatus->ucSsidLen);
  1483. kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.arMacAddress,
  1484. prConnectionStatus->aucBssid, MAC_ADDR_LEN);
  1485. prAdapter->rWlanInfo.rCurrBssId.u4Privacy
  1486. = prConnectionStatus->ucEncryptStatus; /* @FIXME */
  1487. prAdapter->rWlanInfo.rCurrBssId.rRssi = 0; /* @FIXME */
  1488. prAdapter->rWlanInfo.rCurrBssId.eNetworkTypeInUse
  1489. = PARAM_NETWORK_TYPE_AUTOMODE; /* @FIXME */
  1490. prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4BeaconPeriod
  1491. = prConnectionStatus->u2BeaconPeriod;
  1492. prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4ATIMWindow = prConnectionStatus->u2ATIMWindow;
  1493. prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4DSConfig = prConnectionStatus->u4FreqInKHz;
  1494. prAdapter->rWlanInfo.ucNetworkType = prConnectionStatus->ucNetworkType;
  1495. prAdapter->rWlanInfo.rCurrBssId.eOpMode
  1496. = (ENUM_PARAM_OP_MODE_T) prConnectionStatus->ucInfraMode;
  1497. /* always indicate to OS according to MSDN (re-association/roaming) */
  1498. if (kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_CONNECTED) {
  1499. kalIndicateStatusAndComplete(prGlueInfo, WLAN_STATUS_MEDIA_CONNECT, NULL, 0);
  1500. } else {
  1501. /* connected -> connected : roaming ? */
  1502. kalIndicateStatusAndComplete(prGlueInfo, WLAN_STATUS_ROAM_OUT_FIND_BEST, NULL, 0);
  1503. }
  1504. }
  1505. break;
  1506. #if CFG_ENABLE_BT_OVER_WIFI
  1507. case NETWORK_TYPE_BOW_INDEX:
  1508. break;
  1509. #endif
  1510. #if CFG_ENABLE_WIFI_DIRECT
  1511. case NETWORK_TYPE_P2P_INDEX:
  1512. break;
  1513. #endif
  1514. default:
  1515. ASSERT(0);
  1516. }
  1517. return WLAN_STATUS_SUCCESS;
  1518. } /* nicMediaStateChange */
  1519. /*----------------------------------------------------------------------------*/
  1520. /*!
  1521. * @brief This utility function is used to convert between
  1522. * frequency and channel number
  1523. *
  1524. * @param u4ChannelNum
  1525. *
  1526. * @retval - Frequency in unit of KHz, 0 for invalid channel number
  1527. */
  1528. /*----------------------------------------------------------------------------*/
  1529. UINT_32 nicChannelNum2Freq(UINT_32 u4ChannelNum)
  1530. {
  1531. UINT_32 u4ChannelInMHz;
  1532. if (u4ChannelNum >= 1 && u4ChannelNum <= 13)
  1533. u4ChannelInMHz = 2412 + (u4ChannelNum - 1) * 5;
  1534. else if (u4ChannelNum == 14)
  1535. u4ChannelInMHz = 2484;
  1536. else if (u4ChannelNum == 133)
  1537. u4ChannelInMHz = 3665; /* 802.11y */
  1538. else if (u4ChannelNum == 137)
  1539. u4ChannelInMHz = 3685; /* 802.11y */
  1540. else if (u4ChannelNum >= 34 && u4ChannelNum <= 165)
  1541. u4ChannelInMHz = 5000 + u4ChannelNum * 5;
  1542. else if (u4ChannelNum >= 183 && u4ChannelNum <= 196)
  1543. u4ChannelInMHz = 4000 + u4ChannelNum * 5;
  1544. else
  1545. u4ChannelInMHz = 0;
  1546. return 1000 * u4ChannelInMHz;
  1547. }
  1548. /*----------------------------------------------------------------------------*/
  1549. /*!
  1550. * @brief This utility function is used to convert between
  1551. * frequency and channel number
  1552. *
  1553. * @param u4FreqInKHz
  1554. *
  1555. * @retval - Frequency Number, 0 for invalid freqency
  1556. */
  1557. /*----------------------------------------------------------------------------*/
  1558. UINT_32 nicFreq2ChannelNum(UINT_32 u4FreqInKHz)
  1559. {
  1560. switch (u4FreqInKHz) {
  1561. case 2412000:
  1562. return 1;
  1563. case 2417000:
  1564. return 2;
  1565. case 2422000:
  1566. return 3;
  1567. case 2427000:
  1568. return 4;
  1569. case 2432000:
  1570. return 5;
  1571. case 2437000:
  1572. return 6;
  1573. case 2442000:
  1574. return 7;
  1575. case 2447000:
  1576. return 8;
  1577. case 2452000:
  1578. return 9;
  1579. case 2457000:
  1580. return 10;
  1581. case 2462000:
  1582. return 11;
  1583. case 2467000:
  1584. return 12;
  1585. case 2472000:
  1586. return 13;
  1587. case 2484000:
  1588. return 14;
  1589. case 3665000:
  1590. return 133; /* 802.11y */
  1591. case 3685000:
  1592. return 137; /* 802.11y */
  1593. case 4915000:
  1594. return 183;
  1595. case 4920000:
  1596. return 184;
  1597. case 4925000:
  1598. return 185;
  1599. case 4930000:
  1600. return 186;
  1601. case 4935000:
  1602. return 187;
  1603. case 4940000:
  1604. return 188;
  1605. case 4945000:
  1606. return 189;
  1607. case 4960000:
  1608. return 192;
  1609. case 4980000:
  1610. return 196;
  1611. case 5170000:
  1612. return 34;
  1613. case 5180000:
  1614. return 36;
  1615. case 5190000:
  1616. return 38;
  1617. case 5200000:
  1618. return 40;
  1619. case 5210000:
  1620. return 42;
  1621. case 5220000:
  1622. return 44;
  1623. case 5230000:
  1624. return 46;
  1625. case 5240000:
  1626. return 48;
  1627. case 5250000:
  1628. return 50;
  1629. case 5260000:
  1630. return 52;
  1631. case 5270000:
  1632. return 54;
  1633. case 5280000:
  1634. return 56;
  1635. case 5290000:
  1636. return 58;
  1637. case 5300000:
  1638. return 60;
  1639. case 5320000:
  1640. return 64;
  1641. case 5500000:
  1642. return 100;
  1643. case 5520000:
  1644. return 104;
  1645. case 5540000:
  1646. return 108;
  1647. case 5560000:
  1648. return 112;
  1649. case 5580000:
  1650. return 116;
  1651. case 5600000:
  1652. return 120;
  1653. case 5620000:
  1654. return 124;
  1655. case 5640000:
  1656. return 128;
  1657. case 5660000:
  1658. return 132;
  1659. case 5680000:
  1660. return 136;
  1661. case 5700000:
  1662. return 140;
  1663. case 5745000:
  1664. return 149;
  1665. case 5765000:
  1666. return 153;
  1667. case 5785000:
  1668. return 157;
  1669. case 5805000:
  1670. return 161;
  1671. case 5825000:
  1672. return 165;
  1673. case 5845000:
  1674. return 169;
  1675. case 5865000:
  1676. return 173;
  1677. default:
  1678. return 0;
  1679. }
  1680. }
  1681. /* firmware command wrapper */
  1682. /* NETWORK (WIFISYS) */
  1683. /*----------------------------------------------------------------------------*/
  1684. /*!
  1685. * @brief This utility function is used to activate WIFISYS for specified network
  1686. *
  1687. * @param prAdapter Pointer of ADAPTER_T
  1688. * eNetworkTypeIdx Index of network type
  1689. *
  1690. * @retval -
  1691. */
  1692. /*----------------------------------------------------------------------------*/
  1693. WLAN_STATUS nicActivateNetwork(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
  1694. {
  1695. CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
  1696. P_BSS_INFO_T prBssInfo;
  1697. ASSERT(prAdapter);
  1698. ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
  1699. rCmdActivateCtrl.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
  1700. rCmdActivateCtrl.ucActive = 1;
  1701. if (((UINT_8) eNetworkTypeIdx) < NETWORK_TYPE_INDEX_NUM) {
  1702. prBssInfo = &prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx];
  1703. prBssInfo->fg40mBwAllowed = FALSE;
  1704. prBssInfo->fgAssoc40mBwAllowed = FALSE;
  1705. }
  1706. return wlanSendSetQueryCmd(prAdapter,
  1707. CMD_ID_BSS_ACTIVATE_CTRL,
  1708. TRUE,
  1709. FALSE,
  1710. FALSE,
  1711. NULL, NULL, sizeof(CMD_BSS_ACTIVATE_CTRL), (PUINT_8)&rCmdActivateCtrl, NULL, 0);
  1712. }
  1713. /*----------------------------------------------------------------------------*/
  1714. /*!
  1715. * @brief This utility function is used to deactivate WIFISYS for specified network
  1716. *
  1717. * @param prAdapter Pointer of ADAPTER_T
  1718. * eNetworkTypeIdx Index of network type
  1719. *
  1720. * @retval -
  1721. */
  1722. /*----------------------------------------------------------------------------*/
  1723. WLAN_STATUS nicDeactivateNetwork(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
  1724. {
  1725. WLAN_STATUS u4Status;
  1726. CMD_BSS_ACTIVATE_CTRL rCmdActivateCtrl;
  1727. ASSERT(prAdapter);
  1728. ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
  1729. rCmdActivateCtrl.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
  1730. rCmdActivateCtrl.ucActive = 0;
  1731. u4Status = wlanSendSetQueryCmd(prAdapter,
  1732. CMD_ID_BSS_ACTIVATE_CTRL,
  1733. TRUE,
  1734. FALSE,
  1735. FALSE,
  1736. NULL,
  1737. NULL, sizeof(CMD_BSS_ACTIVATE_CTRL), (PUINT_8)&rCmdActivateCtrl, NULL, 0);
  1738. /* free all correlated station records */
  1739. cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
  1740. qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
  1741. nicFreePendingTxMsduInfoByNetwork(prAdapter, eNetworkTypeIdx);
  1742. kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
  1743. return u4Status;
  1744. }
  1745. /* BSS-INFO */
  1746. /*----------------------------------------------------------------------------*/
  1747. /*!
  1748. * @brief This utility function is used to sync bss info with firmware
  1749. * when a new BSS has been connected or disconnected
  1750. *
  1751. * @param prAdapter Pointer of ADAPTER_T
  1752. * eNetworkTypeIdx Index of BSS-INFO type
  1753. *
  1754. * @retval -
  1755. */
  1756. /*----------------------------------------------------------------------------*/
  1757. WLAN_STATUS nicUpdateBss(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
  1758. {
  1759. WLAN_STATUS u4Status;
  1760. P_BSS_INFO_T prBssInfo;
  1761. CMD_SET_BSS_INFO rCmdSetBssInfo;
  1762. ASSERT(prAdapter);
  1763. ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
  1764. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
  1765. kalMemZero(&rCmdSetBssInfo, sizeof(CMD_SET_BSS_INFO));
  1766. rCmdSetBssInfo.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
  1767. rCmdSetBssInfo.ucConnectionState = (UINT_8) prBssInfo->eConnectionState;
  1768. rCmdSetBssInfo.ucCurrentOPMode = (UINT_8) prBssInfo->eCurrentOPMode;
  1769. rCmdSetBssInfo.ucSSIDLen = (UINT_8) prBssInfo->ucSSIDLen;
  1770. kalMemCopy(rCmdSetBssInfo.aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
  1771. COPY_MAC_ADDR(rCmdSetBssInfo.aucBSSID, prBssInfo->aucBSSID);
  1772. rCmdSetBssInfo.ucIsQBSS = (UINT_8) prBssInfo->fgIsQBSS;
  1773. rCmdSetBssInfo.ucNonHTBasicPhyType = prBssInfo->ucNonHTBasicPhyType;
  1774. rCmdSetBssInfo.u2OperationalRateSet = prBssInfo->u2OperationalRateSet;
  1775. rCmdSetBssInfo.u2BSSBasicRateSet = prBssInfo->u2BSSBasicRateSet;
  1776. rCmdSetBssInfo.ucPhyTypeSet = prBssInfo->ucPhyTypeSet;
  1777. rCmdSetBssInfo.fgHiddenSsidMode = prBssInfo->eHiddenSsidType;
  1778. #if CFG_ENABLE_WIFI_DIRECT
  1779. if (prAdapter->fgIsP2PRegistered)
  1780. COPY_MAC_ADDR(rCmdSetBssInfo.aucOwnMac, prBssInfo->aucOwnMacAddr);
  1781. #endif
  1782. rlmFillSyncCmdParam(&rCmdSetBssInfo.rBssRlmParam, prBssInfo);
  1783. rCmdSetBssInfo.fgWapiMode = (UINT_8) FALSE;
  1784. if (rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) {
  1785. P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  1786. rCmdSetBssInfo.ucAuthMode = (UINT_8) prConnSettings->eAuthMode;
  1787. rCmdSetBssInfo.ucEncStatus = (UINT_8) prConnSettings->eEncStatus;
  1788. rCmdSetBssInfo.fgWapiMode = (UINT_8) prConnSettings->fgWapiMode;
  1789. }
  1790. #if CFG_ENABLE_BT_OVER_WIFI
  1791. else if (rCmdSetBssInfo.ucNetTypeIndex == NETWORK_TYPE_BOW_INDEX) {
  1792. /* P_CONNECTION_SETTINGS_T prConnSettings = &(prAdapter->rWifiVar.rConnSettings); */
  1793. rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_WPA2_PSK;
  1794. rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION3_KEY_ABSENT;
  1795. }
  1796. #endif
  1797. else {
  1798. #if CFG_ENABLE_WIFI_DIRECT
  1799. if (prAdapter->fgIsP2PRegistered) {
  1800. if (kalP2PGetCipher(prAdapter->prGlueInfo)) {
  1801. rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_WPA2_PSK;
  1802. rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION3_KEY_ABSENT;
  1803. } else {
  1804. rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_OPEN;
  1805. rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION_DISABLED;
  1806. }
  1807. /* Need the probe response to detect the PBC overlap */
  1808. rCmdSetBssInfo.fgIsApMode = p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo);
  1809. }
  1810. #else
  1811. rCmdSetBssInfo.ucAuthMode = (UINT_8) AUTH_MODE_WPA2_PSK;
  1812. rCmdSetBssInfo.ucEncStatus = (UINT_8) ENUM_ENCRYPTION3_KEY_ABSENT;
  1813. #endif
  1814. }
  1815. if (eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX &&
  1816. prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE && prBssInfo->prStaRecOfAP != NULL) {
  1817. rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
  1818. cnmAisInfraConnectNotify(prAdapter);
  1819. }
  1820. #if CFG_ENABLE_WIFI_DIRECT
  1821. else if ((prAdapter->fgIsP2PRegistered) &&
  1822. (eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) &&
  1823. (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) && (prBssInfo->prStaRecOfAP != NULL)) {
  1824. rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
  1825. }
  1826. #endif
  1827. #if CFG_ENABLE_BT_OVER_WIFI
  1828. else if (eNetworkTypeIdx == NETWORK_TYPE_BOW_INDEX &&
  1829. prBssInfo->eCurrentOPMode == OP_MODE_BOW && prBssInfo->prStaRecOfAP != NULL) {
  1830. rCmdSetBssInfo.ucStaRecIdxOfAP = prBssInfo->prStaRecOfAP->ucIndex;
  1831. }
  1832. #endif
  1833. else
  1834. rCmdSetBssInfo.ucStaRecIdxOfAP = STA_REC_INDEX_NOT_FOUND;
  1835. u4Status = wlanSendSetQueryCmd(prAdapter,
  1836. CMD_ID_SET_BSS_INFO,
  1837. TRUE,
  1838. FALSE,
  1839. FALSE,
  1840. NULL, NULL, sizeof(CMD_SET_BSS_INFO), (PUINT_8)&rCmdSetBssInfo, NULL, 0);
  1841. /* if BSS-INFO is going to be disconnected state, free all correlated station records */
  1842. if (prBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
  1843. /* clear client list */
  1844. bssClearClientList(prAdapter, prBssInfo);
  1845. /* free all correlated station records */
  1846. cnmStaFreeAllStaByNetType(prAdapter, eNetworkTypeIdx, FALSE);
  1847. qmFreeAllByNetType(prAdapter, eNetworkTypeIdx);
  1848. kalClearSecurityFramesByNetType(prAdapter->prGlueInfo, eNetworkTypeIdx);
  1849. #if CFG_ENABLE_GTK_FRAME_FILTER
  1850. if (prBssInfo->prIpV4NetAddrList)
  1851. FREE_IPV4_NETWORK_ADDR_LIST(prBssInfo->prIpV4NetAddrList);
  1852. #endif
  1853. }
  1854. return u4Status;
  1855. }
  1856. /* BSS-INFO Indication (PM) */
  1857. /*----------------------------------------------------------------------------*/
  1858. /*!
  1859. * @brief This utility function is used to indicate PM that
  1860. * a BSS has been created. (for AdHoc / P2P-GO)
  1861. *
  1862. * @param prAdapter Pointer of ADAPTER_T
  1863. * eNetworkTypeIdx Index of BSS-INFO
  1864. *
  1865. * @retval -
  1866. */
  1867. /*----------------------------------------------------------------------------*/
  1868. WLAN_STATUS nicPmIndicateBssCreated(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
  1869. {
  1870. P_BSS_INFO_T prBssInfo;
  1871. CMD_INDICATE_PM_BSS_CREATED rCmdIndicatePmBssCreated;
  1872. ASSERT(prAdapter);
  1873. ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
  1874. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
  1875. rCmdIndicatePmBssCreated.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
  1876. rCmdIndicatePmBssCreated.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
  1877. rCmdIndicatePmBssCreated.u2BeaconInterval = prBssInfo->u2BeaconInterval;
  1878. rCmdIndicatePmBssCreated.u2AtimWindow = prBssInfo->u2ATIMWindow;
  1879. return wlanSendSetQueryCmd(prAdapter,
  1880. CMD_ID_INDICATE_PM_BSS_CREATED,
  1881. TRUE,
  1882. FALSE,
  1883. FALSE,
  1884. NULL,
  1885. NULL,
  1886. sizeof(CMD_INDICATE_PM_BSS_CREATED), (PUINT_8)&rCmdIndicatePmBssCreated, NULL, 0);
  1887. }
  1888. /*----------------------------------------------------------------------------*/
  1889. /*!
  1890. * @brief This utility function is used to indicate PM that
  1891. * a BSS has been connected
  1892. *
  1893. * @param prAdapter Pointer of ADAPTER_T
  1894. * eNetworkTypeIdx Index of BSS-INFO
  1895. *
  1896. * @retval -
  1897. */
  1898. /*----------------------------------------------------------------------------*/
  1899. WLAN_STATUS nicPmIndicateBssConnected(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
  1900. {
  1901. P_BSS_INFO_T prBssInfo;
  1902. CMD_INDICATE_PM_BSS_CONNECTED rCmdIndicatePmBssConnected;
  1903. ASSERT(prAdapter);
  1904. ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
  1905. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
  1906. rCmdIndicatePmBssConnected.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
  1907. rCmdIndicatePmBssConnected.ucDtimPeriod = prBssInfo->ucDTIMPeriod;
  1908. rCmdIndicatePmBssConnected.u2AssocId = prBssInfo->u2AssocId;
  1909. rCmdIndicatePmBssConnected.u2BeaconInterval = prBssInfo->u2BeaconInterval;
  1910. rCmdIndicatePmBssConnected.u2AtimWindow = prBssInfo->u2ATIMWindow;
  1911. rCmdIndicatePmBssConnected.ucBmpDeliveryAC = prBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC;
  1912. rCmdIndicatePmBssConnected.ucBmpTriggerAC = prBssInfo->rPmProfSetupInfo.ucBmpTriggerAC;
  1913. /* DBGPRINTF("nicPmIndicateBssConnected: ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x", */
  1914. /* rCmdIndicatePmBssConnected.ucBmpDeliveryAC, */
  1915. /* rCmdIndicatePmBssConnected.ucBmpTriggerAC); */
  1916. if ((eNetworkTypeIdx == NETWORK_TYPE_AIS_INDEX)
  1917. #if CFG_ENABLE_WIFI_DIRECT
  1918. || ((eNetworkTypeIdx == NETWORK_TYPE_P2P_INDEX) && (prAdapter->fgIsP2PRegistered))
  1919. #endif
  1920. ) {
  1921. if (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE && prBssInfo->prStaRecOfAP) {
  1922. rCmdIndicatePmBssConnected.fgIsUapsdConnection =
  1923. (UINT_8) prBssInfo->prStaRecOfAP->fgIsUapsdSupported;
  1924. } else {
  1925. rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0; /* @FIXME */
  1926. }
  1927. } else {
  1928. rCmdIndicatePmBssConnected.fgIsUapsdConnection = 0;
  1929. }
  1930. return wlanSendSetQueryCmd(prAdapter,
  1931. CMD_ID_INDICATE_PM_BSS_CONNECTED,
  1932. TRUE,
  1933. FALSE,
  1934. FALSE,
  1935. NULL,
  1936. NULL,
  1937. sizeof(CMD_INDICATE_PM_BSS_CONNECTED),
  1938. (PUINT_8)&rCmdIndicatePmBssConnected, NULL, 0);
  1939. }
  1940. /*----------------------------------------------------------------------------*/
  1941. /*!
  1942. * @brief This utility function is used to indicate PM that
  1943. * a BSS has been disconnected
  1944. *
  1945. * @param prAdapter Pointer of ADAPTER_T
  1946. * eNetworkTypeIdx Index of BSS-INFO
  1947. *
  1948. * @retval -
  1949. */
  1950. /*----------------------------------------------------------------------------*/
  1951. WLAN_STATUS nicPmIndicateBssAbort(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
  1952. {
  1953. CMD_INDICATE_PM_BSS_ABORT rCmdIndicatePmBssAbort;
  1954. ASSERT(prAdapter);
  1955. ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
  1956. rCmdIndicatePmBssAbort.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
  1957. return wlanSendSetQueryCmd(prAdapter,
  1958. CMD_ID_INDICATE_PM_BSS_ABORT,
  1959. TRUE,
  1960. FALSE,
  1961. FALSE,
  1962. NULL,
  1963. NULL,
  1964. sizeof(CMD_INDICATE_PM_BSS_ABORT), (PUINT_8)&rCmdIndicatePmBssAbort, NULL, 0);
  1965. }
  1966. WLAN_STATUS
  1967. nicConfigPowerSaveProfile(IN P_ADAPTER_T prAdapter,
  1968. ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex, PARAM_POWER_MODE ePwrMode, BOOLEAN fgEnCmdEvent)
  1969. {
  1970. DEBUGFUNC("nicConfigPowerSaveProfile");
  1971. DBGLOG(NIC, TRACE, "eNetTypeIndex:%d, ePwrMode:%d, fgEnCmdEvent:%d\n",
  1972. eNetTypeIndex, ePwrMode, fgEnCmdEvent);
  1973. ASSERT(prAdapter);
  1974. if (eNetTypeIndex >= NETWORK_TYPE_INDEX_NUM) {
  1975. ASSERT(0);
  1976. return WLAN_STATUS_NOT_SUPPORTED;
  1977. }
  1978. /* prAdapter->rWlanInfo.ePowerSaveMode.ucNetTypeIndex = eNetTypeIndex; */
  1979. /* prAdapter->rWlanInfo.ePowerSaveMode.ucPsProfile = (UINT_8)ePwrMode; */
  1980. prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucNetTypeIndex = eNetTypeIndex;
  1981. prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex].ucPsProfile = (UINT_8) ePwrMode;
  1982. return wlanSendSetQueryCmd(prAdapter,
  1983. CMD_ID_POWER_SAVE_MODE,
  1984. TRUE,
  1985. FALSE,
  1986. (fgEnCmdEvent ? TRUE : FALSE),
  1987. (fgEnCmdEvent ? nicCmdEventSetCommon : NULL),
  1988. (fgEnCmdEvent ? nicOidCmdTimeoutCommon : NULL),
  1989. sizeof(CMD_PS_PROFILE_T),
  1990. (PUINT_8)&(prAdapter->rWlanInfo.arPowerSaveMode[eNetTypeIndex]),
  1991. NULL, sizeof(PARAM_POWER_MODE)
  1992. );
  1993. } /* end of wlanoidSetAcpiDevicePowerStateMode() */
  1994. WLAN_STATUS nicEnterCtiaMode(IN P_ADAPTER_T prAdapter, BOOLEAN fgEnterCtia, BOOLEAN fgEnCmdEvent)
  1995. {
  1996. CMD_SW_DBG_CTRL_T rCmdSwCtrl;
  1997. CMD_ACCESS_REG rCmdAccessReg;
  1998. WLAN_STATUS rWlanStatus;
  1999. DEBUGFUNC("nicEnterCtiaMode");
  2000. DBGLOG(NIC, TRACE, "nicEnterCtiaMode: %d\n", fgEnterCtia);
  2001. ASSERT(prAdapter);
  2002. rWlanStatus = WLAN_STATUS_SUCCESS;
  2003. if (fgEnterCtia) {
  2004. /* 1. Disable On-Lin Scan */
  2005. prAdapter->fgEnOnlineScan = FALSE;
  2006. /* 3. Disable FIFO FULL no ack */
  2007. rCmdAccessReg.u4Address = 0x60140028;
  2008. rCmdAccessReg.u4Data = 0x904;
  2009. wlanSendSetQueryCmd(prAdapter, CMD_ID_ACCESS_REG, TRUE, /* FALSE, */
  2010. FALSE, /* TRUE, */
  2011. FALSE, NULL, NULL, sizeof(CMD_ACCESS_REG), (PUINT_8)&rCmdAccessReg, NULL, 0);
  2012. /* 4. Disable Roaming */
  2013. rCmdSwCtrl.u4Id = 0x90000204;
  2014. rCmdSwCtrl.u4Data = 0x0;
  2015. wlanSendSetQueryCmd(prAdapter,
  2016. CMD_ID_SW_DBG_CTRL,
  2017. TRUE,
  2018. FALSE,
  2019. FALSE, NULL, NULL, sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8)&rCmdSwCtrl, NULL, 0);
  2020. rCmdSwCtrl.u4Id = 0x90000200;
  2021. rCmdSwCtrl.u4Data = 0x820000;
  2022. wlanSendSetQueryCmd(prAdapter,
  2023. CMD_ID_SW_DBG_CTRL,
  2024. TRUE,
  2025. FALSE,
  2026. FALSE, NULL, NULL, sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8)&rCmdSwCtrl, NULL, 0);
  2027. /* Disalbe auto tx power */
  2028. rCmdSwCtrl.u4Id = 0xa0100003;
  2029. rCmdSwCtrl.u4Data = 0x0;
  2030. wlanSendSetQueryCmd(prAdapter,
  2031. CMD_ID_SW_DBG_CTRL,
  2032. TRUE,
  2033. FALSE,
  2034. FALSE, NULL, NULL, sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8)&rCmdSwCtrl, NULL, 0);
  2035. /* 2. Keep at CAM mode */
  2036. {
  2037. PARAM_POWER_MODE ePowerMode;
  2038. prAdapter->u4CtiaPowerMode = 0;
  2039. prAdapter->fgEnCtiaPowerMode = TRUE;
  2040. ePowerMode = Param_PowerModeCAM;
  2041. rWlanStatus = nicConfigPowerSaveProfile(prAdapter,
  2042. NETWORK_TYPE_AIS_INDEX, ePowerMode, fgEnCmdEvent);
  2043. }
  2044. /* 5. Disable Beacon Timeout Detection */
  2045. prAdapter->fgDisBcnLostDetection = TRUE;
  2046. } else {
  2047. /* 1. Enaable On-Lin Scan */
  2048. prAdapter->fgEnOnlineScan = TRUE;
  2049. /* 3. Enable FIFO FULL no ack */
  2050. rCmdAccessReg.u4Address = 0x60140028;
  2051. rCmdAccessReg.u4Data = 0x905;
  2052. wlanSendSetQueryCmd(prAdapter, CMD_ID_ACCESS_REG, TRUE, /* FALSE, */
  2053. FALSE, /* TRUE, */
  2054. FALSE, NULL, NULL, sizeof(CMD_ACCESS_REG), (PUINT_8)&rCmdAccessReg, NULL, 0);
  2055. /* 4. Enable Roaming */
  2056. rCmdSwCtrl.u4Id = 0x90000204;
  2057. rCmdSwCtrl.u4Data = 0x1;
  2058. wlanSendSetQueryCmd(prAdapter,
  2059. CMD_ID_SW_DBG_CTRL,
  2060. TRUE,
  2061. FALSE,
  2062. FALSE, NULL, NULL, sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8)&rCmdSwCtrl, NULL, 0);
  2063. rCmdSwCtrl.u4Id = 0x90000200;
  2064. rCmdSwCtrl.u4Data = 0x820000;
  2065. wlanSendSetQueryCmd(prAdapter,
  2066. CMD_ID_SW_DBG_CTRL,
  2067. TRUE,
  2068. FALSE,
  2069. FALSE, NULL, NULL, sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8)&rCmdSwCtrl, NULL, 0);
  2070. /* Enable auto tx power */
  2071. /* */
  2072. rCmdSwCtrl.u4Id = 0xa0100003;
  2073. rCmdSwCtrl.u4Data = 0x1;
  2074. wlanSendSetQueryCmd(prAdapter,
  2075. CMD_ID_SW_DBG_CTRL,
  2076. TRUE,
  2077. FALSE,
  2078. FALSE, NULL, NULL, sizeof(CMD_SW_DBG_CTRL_T), (PUINT_8)&rCmdSwCtrl, NULL, 0);
  2079. /* 2. Keep at Fast PS */
  2080. {
  2081. PARAM_POWER_MODE ePowerMode;
  2082. prAdapter->u4CtiaPowerMode = 2;
  2083. prAdapter->fgEnCtiaPowerMode = TRUE;
  2084. ePowerMode = Param_PowerModeFast_PSP;
  2085. rWlanStatus = nicConfigPowerSaveProfile(prAdapter,
  2086. NETWORK_TYPE_AIS_INDEX, ePowerMode, fgEnCmdEvent);
  2087. }
  2088. /* 5. Enable Beacon Timeout Detection */
  2089. prAdapter->fgDisBcnLostDetection = FALSE;
  2090. }
  2091. return rWlanStatus;
  2092. } /* end of nicEnterCtiaMode() */
  2093. /*----------------------------------------------------------------------------*/
  2094. /*!
  2095. * @brief This utility function is used to indicate firmware domain
  2096. * for beacon generation parameters
  2097. *
  2098. * @param prAdapter Pointer of ADAPTER_T
  2099. * eIeUpdMethod, Update Method
  2100. * eNetTypeIndex Index of Network
  2101. * u2Capability Capability
  2102. * aucIe Pointer to buffer of IEs
  2103. * u2IELen Length of IEs
  2104. *
  2105. * @retval - WLAN_STATUS_SUCCESS
  2106. * WLAN_STATUS_FAILURE
  2107. * WLAN_STATUS_PENDING
  2108. * WLAN_STATUS_INVALID_DATA
  2109. */
  2110. /*----------------------------------------------------------------------------*/
  2111. WLAN_STATUS
  2112. nicUpdateBeaconIETemplate(IN P_ADAPTER_T prAdapter,
  2113. IN ENUM_IE_UPD_METHOD_T eIeUpdMethod,
  2114. IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex,
  2115. IN UINT_16 u2Capability, IN PUINT_8 aucIe, IN UINT_16 u2IELen)
  2116. {
  2117. P_CMD_BEACON_TEMPLATE_UPDATE prCmdBcnUpdate;
  2118. UINT_16 u2CmdBufLen = 0;
  2119. P_GLUE_INFO_T prGlueInfo;
  2120. P_CMD_INFO_T prCmdInfo;
  2121. P_WIFI_CMD_T prWifiCmd;
  2122. UINT_8 ucCmdSeqNum;
  2123. DEBUGFUNC("wlanUpdateBeaconIETemplate");
  2124. DBGLOG(NIC, LOUD, "\nnicUpdateBeaconIETemplate\n");
  2125. ASSERT(prAdapter);
  2126. prGlueInfo = prAdapter->prGlueInfo;
  2127. if (u2IELen > MAX_IE_LENGTH)
  2128. return WLAN_STATUS_INVALID_DATA;
  2129. if (eIeUpdMethod == IE_UPD_METHOD_UPDATE_RANDOM || eIeUpdMethod == IE_UPD_METHOD_UPDATE_ALL) {
  2130. u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, aucIE) + u2IELen;
  2131. } else if (eIeUpdMethod == IE_UPD_METHOD_DELETE_ALL) {
  2132. u2CmdBufLen = OFFSET_OF(CMD_BEACON_TEMPLATE_UPDATE, u2IELen);
  2133. } else {
  2134. ASSERT(0);
  2135. return WLAN_STATUS_FAILURE;
  2136. }
  2137. /* prepare command info */
  2138. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, (CMD_HDR_SIZE + u2CmdBufLen));
  2139. if (!prCmdInfo) {
  2140. DBGLOG(NIC, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  2141. return WLAN_STATUS_FAILURE;
  2142. }
  2143. /* increase command sequence number */
  2144. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  2145. DBGLOG(REQ, TRACE, "ucCmdSeqNum =%d\n", ucCmdSeqNum);
  2146. /* Setup common CMD Info Packet */
  2147. prCmdInfo->eCmdType = COMMAND_TYPE_NETWORK_IOCTL;
  2148. prCmdInfo->eNetworkType = eNetTypeIndex;
  2149. prCmdInfo->u2InfoBufLen = (UINT_16) (CMD_HDR_SIZE + u2CmdBufLen);
  2150. prCmdInfo->pfCmdDoneHandler = NULL; /* @FIXME */
  2151. prCmdInfo->pfCmdTimeoutHandler = NULL; /* @FIXME */
  2152. prCmdInfo->fgIsOid = FALSE;
  2153. prCmdInfo->ucCID = CMD_ID_UPDATE_BEACON_CONTENT;
  2154. prCmdInfo->fgSetQuery = TRUE;
  2155. prCmdInfo->fgNeedResp = FALSE;
  2156. prCmdInfo->fgDriverDomainMCR = FALSE;
  2157. prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
  2158. prCmdInfo->u4SetInfoLen = u2CmdBufLen;
  2159. prCmdInfo->pvInformationBuffer = NULL;
  2160. prCmdInfo->u4InformationBufferLength = 0;
  2161. /* Setup WIFI_CMD_T (no payload) */
  2162. prWifiCmd = (P_WIFI_CMD_T) (prCmdInfo->pucInfoBuffer);
  2163. prWifiCmd->u2TxByteCount_UserPriority = prCmdInfo->u2InfoBufLen;
  2164. prWifiCmd->ucCID = prCmdInfo->ucCID;
  2165. prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
  2166. prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
  2167. prCmdBcnUpdate = (P_CMD_BEACON_TEMPLATE_UPDATE) (prWifiCmd->aucBuffer);
  2168. /* fill beacon updating command */
  2169. prCmdBcnUpdate->ucUpdateMethod = (UINT_8) eIeUpdMethod;
  2170. prCmdBcnUpdate->ucNetTypeIndex = (UINT_8) eNetTypeIndex;
  2171. prCmdBcnUpdate->u2Capability = u2Capability;
  2172. prCmdBcnUpdate->u2IELen = u2IELen;
  2173. if (u2IELen > 0)
  2174. kalMemCopy(prCmdBcnUpdate->aucIE, aucIe, u2IELen);
  2175. /* insert into prCmdQueue */
  2176. kalEnqueueCommand(prGlueInfo, (P_QUE_ENTRY_T) prCmdInfo);
  2177. /* wakeup txServiceThread later */
  2178. GLUE_SET_EVENT(prGlueInfo);
  2179. return WLAN_STATUS_PENDING;
  2180. }
  2181. /*----------------------------------------------------------------------------*/
  2182. /*!
  2183. * @brief This utility function is used to initialization PHY related
  2184. * varaibles
  2185. *
  2186. * @param prAdapter Pointer of ADAPTER_T
  2187. *
  2188. * @retval none
  2189. */
  2190. /*----------------------------------------------------------------------------*/
  2191. VOID nicSetAvailablePhyTypeSet(IN P_ADAPTER_T prAdapter)
  2192. {
  2193. P_CONNECTION_SETTINGS_T prConnSettings;
  2194. ASSERT(prAdapter);
  2195. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2196. if (prConnSettings->eDesiredPhyConfig >= PHY_CONFIG_NUM) {
  2197. ASSERT(0);
  2198. return;
  2199. }
  2200. prAdapter->rWifiVar.ucAvailablePhyTypeSet = aucPhyCfg2PhyTypeSet[prConnSettings->eDesiredPhyConfig];
  2201. if (prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_BIT_ERP)
  2202. prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_ERP_INDEX;
  2203. /* NOTE(Kevin): Because we don't have N only mode, TBD */
  2204. else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
  2205. prAdapter->rWifiVar.eNonHTBasicPhyType2G4 = PHY_TYPE_HR_DSSS_INDEX;
  2206. }
  2207. }
  2208. /*----------------------------------------------------------------------------*/
  2209. /*!
  2210. * @brief This utility function is used to update WMM Parms
  2211. *
  2212. * @param prAdapter Pointer of ADAPTER_T
  2213. * eNetworkTypeIdx Index of BSS-INFO
  2214. *
  2215. * @retval -
  2216. */
  2217. /*----------------------------------------------------------------------------*/
  2218. WLAN_STATUS nicQmUpdateWmmParms(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetworkTypeIdx)
  2219. {
  2220. P_BSS_INFO_T prBssInfo;
  2221. CMD_UPDATE_WMM_PARMS_T rCmdUpdateWmmParms;
  2222. ASSERT(prAdapter);
  2223. ASSERT(eNetworkTypeIdx < NETWORK_TYPE_INDEX_NUM);
  2224. DBGLOG(QM, EVENT, "sizeof(AC_QUE_PARMS_T): %zu\n", sizeof(AC_QUE_PARMS_T));
  2225. DBGLOG(QM, EVENT, "sizeof(CMD_UPDATE_WMM_PARMS): %zu\n", sizeof(CMD_UPDATE_WMM_PARMS_T));
  2226. DBGLOG(QM, EVENT, "sizeof(WIFI_CMD_T): %zu\n", sizeof(WIFI_CMD_T));
  2227. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetworkTypeIdx]);
  2228. rCmdUpdateWmmParms.ucNetTypeIndex = (UINT_8) eNetworkTypeIdx;
  2229. kalMemCopy(&rCmdUpdateWmmParms.arACQueParms[0], &prBssInfo->arACQueParms[0], (sizeof(AC_QUE_PARMS_T) * AC_NUM));
  2230. rCmdUpdateWmmParms.fgIsQBSS = prBssInfo->fgIsQBSS;
  2231. return wlanSendSetQueryCmd(prAdapter,
  2232. CMD_ID_UPDATE_WMM_PARMS,
  2233. TRUE,
  2234. FALSE,
  2235. FALSE,
  2236. NULL, NULL, sizeof(CMD_UPDATE_WMM_PARMS_T), (PUINT_8)&rCmdUpdateWmmParms, NULL, 0);
  2237. }
  2238. /*----------------------------------------------------------------------------*/
  2239. /*!
  2240. * @brief This utility function is used to update TX power gain corresponding to
  2241. * each band/modulation combination
  2242. *
  2243. * @param prAdapter Pointer of ADAPTER_T
  2244. * prTxPwrParam Pointer of TX power parameters
  2245. *
  2246. * @retval WLAN_STATUS_PENDING
  2247. * WLAN_STATUS_FAILURE
  2248. */
  2249. /*----------------------------------------------------------------------------*/
  2250. WLAN_STATUS nicUpdateTxPower(IN P_ADAPTER_T prAdapter, IN P_CMD_TX_PWR_T prTxPwrParam)
  2251. {
  2252. DEBUGFUNC("nicUpdateTxPower");
  2253. ASSERT(prAdapter);
  2254. return wlanSendSetQueryCmd(prAdapter,
  2255. CMD_ID_SET_TX_PWR,
  2256. TRUE,
  2257. FALSE, FALSE, NULL, NULL, sizeof(CMD_TX_PWR_T), (PUINT_8) prTxPwrParam, NULL, 0);
  2258. }
  2259. /*----------------------------------------------------------------------------*/
  2260. /*!
  2261. * @brief This utility function is used to set auto tx power parameter
  2262. *
  2263. * @param prAdapter Pointer of ADAPTER_T
  2264. * prTxPwrParam Pointer of Auto TX power parameters
  2265. *
  2266. * @retval WLAN_STATUS_PENDING
  2267. * WLAN_STATUS_FAILURE
  2268. */
  2269. /*----------------------------------------------------------------------------*/
  2270. WLAN_STATUS nicSetAutoTxPower(IN P_ADAPTER_T prAdapter, IN P_CMD_AUTO_POWER_PARAM_T prAutoPwrParam)
  2271. {
  2272. DEBUGFUNC("nicSetAutoTxPower");
  2273. ASSERT(prAdapter);
  2274. return wlanSendSetQueryCmd(prAdapter,
  2275. CMD_ID_SET_AUTOPWR_CTRL,
  2276. TRUE,
  2277. FALSE,
  2278. FALSE,
  2279. NULL, NULL, sizeof(CMD_AUTO_POWER_PARAM_T), (PUINT_8) prAutoPwrParam, NULL, 0);
  2280. }
  2281. /*----------------------------------------------------------------------------*/
  2282. /*!
  2283. * @brief This utility function is used to update TX power gain corresponding to
  2284. * each band/modulation combination
  2285. *
  2286. * @param prAdapter Pointer of ADAPTER_T
  2287. * prTxPwrParam Pointer of TX power parameters
  2288. *
  2289. * @retval WLAN_STATUS_PENDING
  2290. * WLAN_STATUS_FAILURE
  2291. */
  2292. /*----------------------------------------------------------------------------*/
  2293. WLAN_STATUS nicSetAutoTxPowerControl(IN P_ADAPTER_T prAdapter, IN P_CMD_TX_PWR_T prTxPwrParam)
  2294. {
  2295. DEBUGFUNC("nicUpdateTxPower");
  2296. ASSERT(prAdapter);
  2297. return wlanSendSetQueryCmd(prAdapter,
  2298. CMD_ID_SET_TX_PWR,
  2299. TRUE,
  2300. FALSE, FALSE, NULL, NULL, sizeof(CMD_TX_PWR_T), (PUINT_8) prTxPwrParam, NULL, 0);
  2301. }
  2302. /*----------------------------------------------------------------------------*/
  2303. /*!
  2304. * @brief This utility function is used to update power offset around 5GHz band
  2305. *
  2306. * @param prAdapter Pointer of ADAPTER_T
  2307. * pr5GPwrOffset Pointer of 5GHz power offset parameter
  2308. *
  2309. * @retval WLAN_STATUS_PENDING
  2310. * WLAN_STATUS_FAILURE
  2311. */
  2312. /*----------------------------------------------------------------------------*/
  2313. WLAN_STATUS nicUpdate5GOffset(IN P_ADAPTER_T prAdapter, IN P_CMD_5G_PWR_OFFSET_T pr5GPwrOffset)
  2314. {
  2315. DEBUGFUNC("nicUpdate5GOffset");
  2316. ASSERT(prAdapter);
  2317. return wlanSendSetQueryCmd(prAdapter,
  2318. CMD_ID_SET_5G_PWR_OFFSET,
  2319. TRUE,
  2320. FALSE,
  2321. FALSE, NULL, NULL, sizeof(CMD_5G_PWR_OFFSET_T), (PUINT_8) pr5GPwrOffset, NULL, 0);
  2322. }
  2323. /*----------------------------------------------------------------------------*/
  2324. /*!
  2325. * @brief This utility function is used to update DPD calibration result
  2326. *
  2327. * @param prAdapter Pointer of ADAPTER_T
  2328. * pr5GPwrOffset Pointer of parameter for DPD calibration result
  2329. *
  2330. * @retval WLAN_STATUS_PENDING
  2331. * WLAN_STATUS_FAILURE
  2332. */
  2333. /*----------------------------------------------------------------------------*/
  2334. WLAN_STATUS nicUpdateDPD(IN P_ADAPTER_T prAdapter, IN P_CMD_PWR_PARAM_T prDpdCalResult)
  2335. {
  2336. DEBUGFUNC("nicUpdateDPD");
  2337. ASSERT(prAdapter);
  2338. return wlanSendSetQueryCmd(prAdapter,
  2339. CMD_ID_SET_PWR_PARAM,
  2340. TRUE,
  2341. FALSE,
  2342. FALSE, NULL, NULL, sizeof(CMD_PWR_PARAM_T), (PUINT_8) prDpdCalResult, NULL, 0);
  2343. }
  2344. /*----------------------------------------------------------------------------*/
  2345. /*!
  2346. * @brief This utility function starts system service such as timer and
  2347. * memory pools
  2348. *
  2349. * @param prAdapter Pointer of ADAPTER_T
  2350. *
  2351. * @retval none
  2352. */
  2353. /*----------------------------------------------------------------------------*/
  2354. VOID nicInitSystemService(IN P_ADAPTER_T prAdapter)
  2355. {
  2356. ASSERT(prAdapter);
  2357. /* <1> Initialize MGMT Memory pool and STA_REC */
  2358. cnmMemInit(prAdapter);
  2359. cnmStaRecInit(prAdapter);
  2360. cmdBufInitialize(prAdapter);
  2361. /* <2> Mailbox Initialization */
  2362. mboxInitialize(prAdapter);
  2363. /* <3> Timer Initialization */
  2364. cnmTimerInitialize(prAdapter);
  2365. }
  2366. /*----------------------------------------------------------------------------*/
  2367. /*!
  2368. * @brief This utility function reset some specific system service,
  2369. * such as STA-REC
  2370. *
  2371. * @param prAdapter Pointer of ADAPTER_T
  2372. *
  2373. * @retval none
  2374. */
  2375. /*----------------------------------------------------------------------------*/
  2376. VOID nicResetSystemService(IN P_ADAPTER_T prAdapter)
  2377. {
  2378. ASSERT(prAdapter);
  2379. }
  2380. /*----------------------------------------------------------------------------*/
  2381. /*!
  2382. * @brief This utility function is used to update WMM Parms
  2383. *
  2384. * @param prAdapter Pointer of ADAPTER_T
  2385. *
  2386. * @retval none
  2387. */
  2388. /*----------------------------------------------------------------------------*/
  2389. VOID nicUninitSystemService(IN P_ADAPTER_T prAdapter)
  2390. {
  2391. ASSERT(prAdapter);
  2392. /* Timer Destruction */
  2393. cnmTimerDestroy(prAdapter);
  2394. /* Mailbox Destruction */
  2395. mboxDestroy(prAdapter);
  2396. }
  2397. /*----------------------------------------------------------------------------*/
  2398. /*!
  2399. * @brief This utility function is used to update WMM Parms
  2400. *
  2401. * @param prAdapter Pointer of ADAPTER_T
  2402. *
  2403. * @retval none
  2404. */
  2405. /*----------------------------------------------------------------------------*/
  2406. VOID nicInitMGMT(IN P_ADAPTER_T prAdapter, IN P_REG_INFO_T prRegInfo)
  2407. {
  2408. ASSERT(prAdapter);
  2409. /* CNM Module - initialization */
  2410. cnmInit(prAdapter);
  2411. /* RLM Module - initialization */
  2412. rlmFsmEventInit(prAdapter);
  2413. /* SCN Module - initialization */
  2414. scnInit(prAdapter);
  2415. /* AIS Module - intiailization */
  2416. aisInitializeConnectionSettings(prAdapter, prRegInfo);
  2417. aisFsmInit(prAdapter);
  2418. #if CFG_SUPPORT_ROAMING
  2419. /* Roaming Module - intiailization */
  2420. roamingFsmInit(prAdapter);
  2421. #endif /* CFG_SUPPORT_ROAMING */
  2422. #if CFG_SUPPORT_SWCR
  2423. swCrDebugInit(prAdapter);
  2424. #endif /* CFG_SUPPORT_SWCR */
  2425. #if (CFG_SUPPORT_TDLS == 1)
  2426. TdlsexInit(prAdapter);
  2427. #endif /* CFG_SUPPORT_TDLS */
  2428. }
  2429. /*----------------------------------------------------------------------------*/
  2430. /*!
  2431. * @brief This utility function is used to update WMM Parms
  2432. *
  2433. * @param prAdapter Pointer of ADAPTER_T
  2434. *
  2435. * @retval none
  2436. */
  2437. /*----------------------------------------------------------------------------*/
  2438. VOID nicUninitMGMT(IN P_ADAPTER_T prAdapter)
  2439. {
  2440. ASSERT(prAdapter);
  2441. #if CFG_SUPPORT_SWCR
  2442. swCrDebugUninit(prAdapter);
  2443. #endif /* CFG_SUPPORT_SWCR */
  2444. #if CFG_SUPPORT_ROAMING
  2445. /* Roaming Module - unintiailization */
  2446. roamingFsmUninit(prAdapter);
  2447. #endif /* CFG_SUPPORT_ROAMING */
  2448. /* AIS Module - unintiailization */
  2449. aisFsmUninit(prAdapter);
  2450. /* SCN Module - unintiailization */
  2451. scnUninit(prAdapter);
  2452. /* RLM Module - uninitialization */
  2453. rlmFsmEventUninit(prAdapter);
  2454. /* CNM Module - uninitialization */
  2455. cnmUninit(prAdapter);
  2456. #if (CFG_SUPPORT_TDLS == 1)
  2457. TdlsexUninit(prAdapter);
  2458. #endif /* CFG_SUPPORT_TDLS */
  2459. }
  2460. #if (MT6620_E1_ASIC_HIFSYS_WORKAROUND == 1)
  2461. /*----------------------------------------------------------------------------*/
  2462. /*!
  2463. * @brief This utility function is to inform firmware to enable MCU clock gating
  2464. *
  2465. * @param prAdapter Pointer of ADAPTER_T
  2466. *
  2467. * @retval none
  2468. */
  2469. /*----------------------------------------------------------------------------*/
  2470. WLAN_STATUS nicEnableClockGating(IN P_ADAPTER_T prAdapter)
  2471. {
  2472. UINT_32 i, u4WHISR = 0;
  2473. ASSERT(prAdapter);
  2474. if (prAdapter->fgIsClockGatingEnabled == TRUE)
  2475. return WLAN_STATUS_SUCCESS;
  2476. nicSetSwIntr(prAdapter, REQ_GATING_ENABLE_H2D_INT);
  2477. i = 0;
  2478. while (i < GATING_CONTROL_POLL_LIMIT) {
  2479. if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE)
  2480. return WLAN_STATUS_FAILURE;
  2481. HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8)&u4WHISR);
  2482. if (u4WHISR & ACK_GATING_ENABLE_D2H_INT) {
  2483. prAdapter->fgIsClockGatingEnabled = TRUE;
  2484. return WLAN_STATUS_SUCCESS;
  2485. }
  2486. }
  2487. ASSERT(0);
  2488. return WLAN_STATUS_PENDING;
  2489. }
  2490. /*----------------------------------------------------------------------------*/
  2491. /*!
  2492. * @brief This utility function is to inform firmware to disable MCU clock gating
  2493. *
  2494. * @param prAdapter Pointer of ADAPTER_T
  2495. *
  2496. * @retval none
  2497. */
  2498. /*----------------------------------------------------------------------------*/
  2499. WLAN_STATUS nicDisableClockGating(IN P_ADAPTER_T prAdapter)
  2500. {
  2501. UINT_32 i, u4WHISR = 0;
  2502. ASSERT(prAdapter);
  2503. if (prAdapter->fgIsClockGatingEnabled == FALSE)
  2504. return WLAN_STATUS_SUCCESS;
  2505. nicSetSwIntr(prAdapter, REQ_GATING_DISABLE_H2D_INT);
  2506. i = 0;
  2507. while (i < GATING_CONTROL_POLL_LIMIT) {
  2508. if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE)
  2509. return WLAN_STATUS_FAILURE;
  2510. HAL_READ_INTR_STATUS(prAdapter, sizeof(UINT_32), (PUINT_8)&u4WHISR);
  2511. if (u4WHISR & ACK_GATING_DISABLE_D2H_INT) {
  2512. prAdapter->fgIsClockGatingEnabled = FALSE;
  2513. return WLAN_STATUS_SUCCESS;
  2514. }
  2515. }
  2516. ASSERT(0);
  2517. return WLAN_STATUS_PENDING;
  2518. }
  2519. #endif
  2520. /*----------------------------------------------------------------------------*/
  2521. /*!
  2522. * @brief This function is invoked to buffer scan result
  2523. *
  2524. * @param prAdapter Pointer to the Adapter structure.
  2525. * @param rMacAddr BSSID
  2526. * @param prSsid Pointer to SSID
  2527. * @param u4Privacy Privacy settings (0: Open / 1: WEP/WPA/WPA2 enabled)
  2528. * @param rRssi Received Strength (-10 ~ -200 dBm)
  2529. * @param eNetworkType Network Type (a/b/g)
  2530. * @param prConfiguration Network Parameter
  2531. * @param eOpMode Infra/Ad-Hoc
  2532. * @param rSupportedRates Supported basic rates
  2533. * @param u2IELength IE Length
  2534. * @param pucIEBuf Pointer to Information Elements(IEs)
  2535. *
  2536. * @return (none)
  2537. */
  2538. /*----------------------------------------------------------------------------*/
  2539. VOID
  2540. nicAddScanResult(IN P_ADAPTER_T prAdapter,
  2541. IN PARAM_MAC_ADDRESS rMacAddr,
  2542. IN P_PARAM_SSID_T prSsid,
  2543. IN UINT_32 u4Privacy,
  2544. IN PARAM_RSSI rRssi,
  2545. IN ENUM_PARAM_NETWORK_TYPE_T eNetworkType,
  2546. IN P_PARAM_802_11_CONFIG_T prConfiguration,
  2547. IN ENUM_PARAM_OP_MODE_T eOpMode,
  2548. IN PARAM_RATES_EX rSupportedRates, IN UINT_16 u2IELength, IN PUINT_8 pucIEBuf)
  2549. {
  2550. BOOLEAN bReplace;
  2551. UINT_32 i;
  2552. UINT_32 u4IdxWeakest = 0;
  2553. PARAM_RSSI rWeakestRssi;
  2554. UINT_32 u4BufferSize;
  2555. ASSERT(prAdapter);
  2556. rWeakestRssi = (PARAM_RSSI) INT_MAX;
  2557. u4BufferSize = sizeof(prAdapter->rWlanInfo.aucScanIEBuf) / sizeof(prAdapter->rWlanInfo.aucScanIEBuf[0]);
  2558. bReplace = FALSE;
  2559. /* decide to replace or add */
  2560. for (i = 0; i < prAdapter->rWlanInfo.u4ScanResultNum; i++) {
  2561. /* find weakest entry && not connected one */
  2562. if (UNEQUAL_MAC_ADDR
  2563. (prAdapter->rWlanInfo.arScanResult[i].arMacAddress, prAdapter->rWlanInfo.rCurrBssId.arMacAddress)
  2564. && prAdapter->rWlanInfo.arScanResult[i].rRssi < rWeakestRssi) {
  2565. u4IdxWeakest = i;
  2566. rWeakestRssi = prAdapter->rWlanInfo.arScanResult[i].rRssi;
  2567. }
  2568. if (prAdapter->rWlanInfo.arScanResult[i].eOpMode == eOpMode &&
  2569. EQUAL_MAC_ADDR(&(prAdapter->rWlanInfo.arScanResult[i].arMacAddress), rMacAddr) &&
  2570. (EQUAL_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
  2571. prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
  2572. prSsid->aucSsid, prSsid->u4SsidLen)
  2573. || prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen == 0)) {
  2574. /* replace entry */
  2575. bReplace = TRUE;
  2576. /* free IE buffer then zero */
  2577. nicFreeScanResultIE(prAdapter, i);
  2578. kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]), OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
  2579. /* then fill buffer */
  2580. prAdapter->rWlanInfo.arScanResult[i].u4Length =
  2581. OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
  2582. COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
  2583. COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
  2584. prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
  2585. prSsid->aucSsid, prSsid->u4SsidLen);
  2586. prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
  2587. prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
  2588. prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
  2589. kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
  2590. prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
  2591. prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
  2592. kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
  2593. rSupportedRates, sizeof(PARAM_RATES_EX));
  2594. prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
  2595. /* IE - allocate buffer and update pointer */
  2596. if (u2IELength > 0) {
  2597. if (ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
  2598. kalMemCopy(&
  2599. (prAdapter->
  2600. rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
  2601. pucIEBuf, u2IELength);
  2602. prAdapter->rWlanInfo.apucScanResultIEs[i] =
  2603. &(prAdapter->
  2604. rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
  2605. prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
  2606. } else {
  2607. /* buffer is not enough */
  2608. prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
  2609. prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
  2610. prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
  2611. }
  2612. } else {
  2613. prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
  2614. }
  2615. break;
  2616. }
  2617. }
  2618. if (bReplace == FALSE) {
  2619. if (prAdapter->rWlanInfo.u4ScanResultNum < (CFG_MAX_NUM_BSS_LIST - 1)) {
  2620. i = prAdapter->rWlanInfo.u4ScanResultNum;
  2621. /* zero */
  2622. kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]), OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
  2623. /* then fill buffer */
  2624. prAdapter->rWlanInfo.arScanResult[i].u4Length =
  2625. OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
  2626. COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
  2627. COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
  2628. prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
  2629. prSsid->aucSsid, prSsid->u4SsidLen);
  2630. prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
  2631. prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
  2632. prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
  2633. kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
  2634. prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
  2635. prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
  2636. kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
  2637. rSupportedRates, sizeof(PARAM_RATES_EX));
  2638. prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
  2639. /* IE - allocate buffer and update pointer */
  2640. if (u2IELength > 0) {
  2641. if (ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
  2642. kalMemCopy(&
  2643. (prAdapter->
  2644. rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
  2645. pucIEBuf, u2IELength);
  2646. prAdapter->rWlanInfo.apucScanResultIEs[i] =
  2647. &(prAdapter->
  2648. rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
  2649. prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
  2650. } else {
  2651. /* buffer is not enough */
  2652. prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
  2653. prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
  2654. prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
  2655. }
  2656. } else {
  2657. prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
  2658. }
  2659. prAdapter->rWlanInfo.u4ScanResultNum++;
  2660. } else if (rWeakestRssi != (PARAM_RSSI) INT_MAX) {
  2661. /* replace weakest one */
  2662. i = u4IdxWeakest;
  2663. /* free IE buffer then zero */
  2664. nicFreeScanResultIE(prAdapter, i);
  2665. kalMemZero(&(prAdapter->rWlanInfo.arScanResult[i]), OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
  2666. /* then fill buffer */
  2667. prAdapter->rWlanInfo.arScanResult[i].u4Length =
  2668. OFFSET_OF(PARAM_BSSID_EX_T, aucIEs) + u2IELength;
  2669. COPY_MAC_ADDR(prAdapter->rWlanInfo.arScanResult[i].arMacAddress, rMacAddr);
  2670. COPY_SSID(prAdapter->rWlanInfo.arScanResult[i].rSsid.aucSsid,
  2671. prAdapter->rWlanInfo.arScanResult[i].rSsid.u4SsidLen,
  2672. prSsid->aucSsid, prSsid->u4SsidLen);
  2673. prAdapter->rWlanInfo.arScanResult[i].u4Privacy = u4Privacy;
  2674. prAdapter->rWlanInfo.arScanResult[i].rRssi = rRssi;
  2675. prAdapter->rWlanInfo.arScanResult[i].eNetworkTypeInUse = eNetworkType;
  2676. kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[i].rConfiguration),
  2677. prConfiguration, sizeof(PARAM_802_11_CONFIG_T));
  2678. prAdapter->rWlanInfo.arScanResult[i].eOpMode = eOpMode;
  2679. kalMemCopy((prAdapter->rWlanInfo.arScanResult[i].rSupportedRates),
  2680. rSupportedRates, sizeof(PARAM_RATES_EX));
  2681. prAdapter->rWlanInfo.arScanResult[i].u4IELength = (UINT_32) u2IELength;
  2682. if (u2IELength > 0) {
  2683. /* IE - allocate buffer and update pointer */
  2684. if (ALIGN_4(u2IELength) + prAdapter->rWlanInfo.u4ScanIEBufferUsage <= u4BufferSize) {
  2685. kalMemCopy(&
  2686. (prAdapter->
  2687. rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]),
  2688. pucIEBuf, u2IELength);
  2689. prAdapter->rWlanInfo.apucScanResultIEs[i] =
  2690. &(prAdapter->
  2691. rWlanInfo.aucScanIEBuf[prAdapter->rWlanInfo.u4ScanIEBufferUsage]);
  2692. prAdapter->rWlanInfo.u4ScanIEBufferUsage += ALIGN_4(u2IELength);
  2693. } else {
  2694. /* buffer is not enough */
  2695. prAdapter->rWlanInfo.arScanResult[i].u4Length -= u2IELength;
  2696. prAdapter->rWlanInfo.arScanResult[i].u4IELength = 0;
  2697. prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
  2698. }
  2699. } else {
  2700. prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
  2701. }
  2702. }
  2703. }
  2704. }
  2705. /*----------------------------------------------------------------------------*/
  2706. /*!
  2707. * @brief This function is invoked to free IE buffer for dedicated scan result
  2708. *
  2709. * @param prAdapter Pointer to the Adapter structure.
  2710. * @param u4Idx Index of Scan Result
  2711. *
  2712. * @return (none)
  2713. */
  2714. /*----------------------------------------------------------------------------*/
  2715. VOID nicFreeScanResultIE(IN P_ADAPTER_T prAdapter, IN UINT_32 u4Idx)
  2716. {
  2717. UINT_32 i;
  2718. PUINT_8 pucPivot, pucMovePivot;
  2719. UINT_32 u4MoveSize, u4FreeSize, u4ReserveSize;
  2720. ASSERT(prAdapter);
  2721. ASSERT(u4Idx < CFG_MAX_NUM_BSS_LIST);
  2722. if (prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength == 0
  2723. || prAdapter->rWlanInfo.apucScanResultIEs[u4Idx] == NULL) {
  2724. return;
  2725. }
  2726. u4FreeSize = ALIGN_4(prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength);
  2727. pucPivot = prAdapter->rWlanInfo.apucScanResultIEs[u4Idx];
  2728. pucMovePivot = (PUINT_8) ((ULONG) (prAdapter->rWlanInfo.apucScanResultIEs[u4Idx]) + u4FreeSize);
  2729. u4ReserveSize = ((ULONG) pucPivot) - (ULONG) (&(prAdapter->rWlanInfo.aucScanIEBuf[0]));
  2730. u4MoveSize = prAdapter->rWlanInfo.u4ScanIEBufferUsage - u4ReserveSize - u4FreeSize;
  2731. /* 1. rest of buffer to move forward */
  2732. kalMemCopy(pucPivot, pucMovePivot, u4MoveSize);
  2733. /* 1.1 modify pointers */
  2734. for (i = 0; i < prAdapter->rWlanInfo.u4ScanResultNum; i++) {
  2735. if (i != u4Idx) {
  2736. if (prAdapter->rWlanInfo.apucScanResultIEs[i] >= pucMovePivot) {
  2737. prAdapter->rWlanInfo.apucScanResultIEs[i] =
  2738. (PUINT_8) ((ULONG) (prAdapter->rWlanInfo.apucScanResultIEs[i]) - u4FreeSize);
  2739. }
  2740. }
  2741. }
  2742. /* 1.2 reset the freed one */
  2743. prAdapter->rWlanInfo.arScanResult[u4Idx].u4IELength = 0;
  2744. prAdapter->rWlanInfo.apucScanResultIEs[i] = NULL;
  2745. /* 2. reduce IE buffer usage */
  2746. prAdapter->rWlanInfo.u4ScanIEBufferUsage -= u4FreeSize;
  2747. }
  2748. /*----------------------------------------------------------------------------*/
  2749. /*!
  2750. * @brief This function is to hack parameters for WLAN TABLE for
  2751. * fixed rate settings
  2752. *
  2753. * @param prAdapter Pointer to the Adapter structure.
  2754. * @param eRateSetting
  2755. * @param pu2DesiredNonHTRateSet,
  2756. * @param pu2BSSBasicRateSet,
  2757. * @param pucMcsSet
  2758. * @param pucSupMcs32
  2759. * @param pu2HtCapInfo
  2760. *
  2761. * @return WLAN_STATUS_SUCCESS
  2762. */
  2763. /*----------------------------------------------------------------------------*/
  2764. WLAN_STATUS
  2765. nicUpdateRateParams(IN P_ADAPTER_T prAdapter,
  2766. IN ENUM_REGISTRY_FIXED_RATE_T eRateSetting,
  2767. IN PUINT_8 pucDesiredPhyTypeSet,
  2768. IN PUINT_16 pu2DesiredNonHTRateSet,
  2769. IN PUINT_16 pu2BSSBasicRateSet,
  2770. IN PUINT_8 pucMcsSet, IN PUINT_8 pucSupMcs32, IN PUINT_16 pu2HtCapInfo)
  2771. {
  2772. ASSERT(prAdapter);
  2773. ASSERT(eRateSetting > FIXED_RATE_NONE && eRateSetting < FIXED_RATE_NUM);
  2774. switch (prAdapter->rWifiVar.eRateSetting) {
  2775. case FIXED_RATE_1M:
  2776. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
  2777. *pu2DesiredNonHTRateSet = RATE_SET_BIT_1M;
  2778. *pu2BSSBasicRateSet = RATE_SET_BIT_1M;
  2779. *pucMcsSet = 0;
  2780. *pucSupMcs32 = 0;
  2781. *pu2HtCapInfo = 0;
  2782. break;
  2783. case FIXED_RATE_2M:
  2784. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
  2785. *pu2DesiredNonHTRateSet = RATE_SET_BIT_2M;
  2786. *pu2BSSBasicRateSet = RATE_SET_BIT_2M;
  2787. *pucMcsSet = 0;
  2788. *pucSupMcs32 = 0;
  2789. *pu2HtCapInfo = 0;
  2790. break;
  2791. case FIXED_RATE_5_5M:
  2792. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
  2793. *pu2DesiredNonHTRateSet = RATE_SET_BIT_5_5M;
  2794. *pu2BSSBasicRateSet = RATE_SET_BIT_5_5M;
  2795. *pucMcsSet = 0;
  2796. *pucSupMcs32 = 0;
  2797. *pu2HtCapInfo = 0;
  2798. break;
  2799. case FIXED_RATE_11M:
  2800. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HR_DSSS;
  2801. *pu2DesiredNonHTRateSet = RATE_SET_BIT_11M;
  2802. *pu2BSSBasicRateSet = RATE_SET_BIT_11M;
  2803. *pucMcsSet = 0;
  2804. *pucSupMcs32 = 0;
  2805. *pu2HtCapInfo = 0;
  2806. break;
  2807. case FIXED_RATE_6M:
  2808. if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_ERP)
  2809. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
  2810. else if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_OFDM)
  2811. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
  2812. *pu2DesiredNonHTRateSet = RATE_SET_BIT_6M;
  2813. *pu2BSSBasicRateSet = RATE_SET_BIT_6M;
  2814. *pucMcsSet = 0;
  2815. *pucSupMcs32 = 0;
  2816. *pu2HtCapInfo = 0;
  2817. break;
  2818. case FIXED_RATE_9M:
  2819. if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_ERP)
  2820. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
  2821. else if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_OFDM)
  2822. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
  2823. *pu2DesiredNonHTRateSet = RATE_SET_BIT_9M;
  2824. *pu2BSSBasicRateSet = RATE_SET_BIT_9M;
  2825. *pucMcsSet = 0;
  2826. *pucSupMcs32 = 0;
  2827. *pu2HtCapInfo = 0;
  2828. break;
  2829. case FIXED_RATE_12M:
  2830. if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_ERP)
  2831. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
  2832. else if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_OFDM)
  2833. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
  2834. *pu2DesiredNonHTRateSet = RATE_SET_BIT_12M;
  2835. *pu2BSSBasicRateSet = RATE_SET_BIT_12M;
  2836. *pucMcsSet = 0;
  2837. *pucSupMcs32 = 0;
  2838. *pu2HtCapInfo = 0;
  2839. break;
  2840. case FIXED_RATE_18M:
  2841. if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_ERP)
  2842. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
  2843. else if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_OFDM)
  2844. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
  2845. *pu2DesiredNonHTRateSet = RATE_SET_BIT_18M;
  2846. *pu2BSSBasicRateSet = RATE_SET_BIT_18M;
  2847. *pucMcsSet = 0;
  2848. *pucSupMcs32 = 0;
  2849. *pu2HtCapInfo = 0;
  2850. break;
  2851. case FIXED_RATE_24M:
  2852. if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_ERP)
  2853. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
  2854. else if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_OFDM)
  2855. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
  2856. *pu2DesiredNonHTRateSet = RATE_SET_BIT_24M;
  2857. *pu2BSSBasicRateSet = RATE_SET_BIT_24M;
  2858. *pucMcsSet = 0;
  2859. *pucSupMcs32 = 0;
  2860. *pu2HtCapInfo = 0;
  2861. break;
  2862. case FIXED_RATE_36M:
  2863. if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_ERP)
  2864. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
  2865. else if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_OFDM)
  2866. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
  2867. *pu2DesiredNonHTRateSet = RATE_SET_BIT_36M;
  2868. *pu2BSSBasicRateSet = RATE_SET_BIT_36M;
  2869. *pucMcsSet = 0;
  2870. *pucSupMcs32 = 0;
  2871. *pu2HtCapInfo = 0;
  2872. break;
  2873. case FIXED_RATE_48M:
  2874. if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_ERP)
  2875. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
  2876. else if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_OFDM)
  2877. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
  2878. *pu2DesiredNonHTRateSet = RATE_SET_BIT_48M;
  2879. *pu2BSSBasicRateSet = RATE_SET_BIT_48M;
  2880. *pucMcsSet = 0;
  2881. *pucSupMcs32 = 0;
  2882. *pu2HtCapInfo = 0;
  2883. break;
  2884. case FIXED_RATE_54M:
  2885. if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_ERP)
  2886. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_ERP;
  2887. else if ((*pucDesiredPhyTypeSet) & PHY_TYPE_BIT_OFDM)
  2888. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_OFDM;
  2889. *pu2DesiredNonHTRateSet = RATE_SET_BIT_54M;
  2890. *pu2BSSBasicRateSet = RATE_SET_BIT_54M;
  2891. *pucMcsSet = 0;
  2892. *pucSupMcs32 = 0;
  2893. *pu2HtCapInfo = 0;
  2894. break;
  2895. case FIXED_RATE_MCS0_20M_800NS:
  2896. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2897. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2898. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2899. *pucMcsSet = HT_RATE_MCS0_INDEX;
  2900. *pucSupMcs32 = 0;
  2901. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
  2902. | HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2903. break;
  2904. case FIXED_RATE_MCS1_20M_800NS:
  2905. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2906. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2907. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2908. *pucMcsSet = HT_RATE_MCS1_INDEX;
  2909. *pucSupMcs32 = 0;
  2910. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
  2911. | HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2912. break;
  2913. case FIXED_RATE_MCS2_20M_800NS:
  2914. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2915. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2916. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2917. *pucMcsSet = HT_RATE_MCS2_INDEX;
  2918. *pucSupMcs32 = 0;
  2919. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
  2920. | HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2921. break;
  2922. case FIXED_RATE_MCS3_20M_800NS:
  2923. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2924. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2925. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2926. *pucMcsSet = HT_RATE_MCS3_INDEX;
  2927. *pucSupMcs32 = 0;
  2928. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
  2929. | HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2930. break;
  2931. case FIXED_RATE_MCS4_20M_800NS:
  2932. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2933. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2934. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2935. *pucMcsSet = HT_RATE_MCS4_INDEX;
  2936. *pucSupMcs32 = 0;
  2937. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
  2938. | HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2939. break;
  2940. case FIXED_RATE_MCS5_20M_800NS:
  2941. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2942. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2943. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2944. *pucMcsSet = HT_RATE_MCS5_INDEX;
  2945. *pucSupMcs32 = 0;
  2946. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
  2947. | HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2948. break;
  2949. case FIXED_RATE_MCS6_20M_800NS:
  2950. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2951. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2952. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2953. *pucMcsSet = HT_RATE_MCS6_INDEX;
  2954. *pucSupMcs32 = 0;
  2955. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
  2956. | HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2957. break;
  2958. case FIXED_RATE_MCS7_20M_800NS:
  2959. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2960. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2961. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2962. *pucMcsSet = HT_RATE_MCS7_INDEX;
  2963. *pucSupMcs32 = 0;
  2964. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH
  2965. | HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2966. break;
  2967. case FIXED_RATE_MCS0_20M_400NS:
  2968. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2969. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2970. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2971. *pucMcsSet = HT_RATE_MCS0_INDEX;
  2972. *pucSupMcs32 = 0;
  2973. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2974. (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
  2975. break;
  2976. case FIXED_RATE_MCS1_20M_400NS:
  2977. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2978. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2979. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2980. *pucMcsSet = HT_RATE_MCS1_INDEX;
  2981. *pucSupMcs32 = 0;
  2982. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2983. (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
  2984. break;
  2985. case FIXED_RATE_MCS2_20M_400NS:
  2986. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2987. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2988. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2989. *pucMcsSet = HT_RATE_MCS2_INDEX;
  2990. *pucSupMcs32 = 0;
  2991. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  2992. (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
  2993. break;
  2994. case FIXED_RATE_MCS3_20M_400NS:
  2995. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  2996. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  2997. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  2998. *pucMcsSet = HT_RATE_MCS3_INDEX;
  2999. *pucSupMcs32 = 0;
  3000. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3001. (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
  3002. break;
  3003. case FIXED_RATE_MCS4_20M_400NS:
  3004. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3005. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3006. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3007. *pucMcsSet = HT_RATE_MCS4_INDEX;
  3008. *pucSupMcs32 = 0;
  3009. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3010. (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
  3011. break;
  3012. case FIXED_RATE_MCS5_20M_400NS:
  3013. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3014. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3015. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3016. *pucMcsSet = HT_RATE_MCS5_INDEX;
  3017. *pucSupMcs32 = 0;
  3018. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3019. (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
  3020. break;
  3021. case FIXED_RATE_MCS6_20M_400NS:
  3022. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3023. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3024. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3025. *pucMcsSet = HT_RATE_MCS6_INDEX;
  3026. *pucSupMcs32 = 0;
  3027. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3028. (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
  3029. break;
  3030. case FIXED_RATE_MCS7_20M_400NS:
  3031. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3032. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3033. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3034. *pucMcsSet = HT_RATE_MCS7_INDEX;
  3035. *pucSupMcs32 = 0;
  3036. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3037. (*pu2HtCapInfo) |= HT_CAP_INFO_SHORT_GI_20M;
  3038. break;
  3039. case FIXED_RATE_MCS0_40M_800NS:
  3040. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3041. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3042. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3043. *pucMcsSet = HT_RATE_MCS0_INDEX;
  3044. *pucSupMcs32 = 0;
  3045. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3046. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3047. break;
  3048. case FIXED_RATE_MCS1_40M_800NS:
  3049. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3050. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3051. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3052. *pucMcsSet = HT_RATE_MCS1_INDEX;
  3053. *pucSupMcs32 = 0;
  3054. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3055. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3056. break;
  3057. case FIXED_RATE_MCS2_40M_800NS:
  3058. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3059. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3060. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3061. *pucMcsSet = HT_RATE_MCS2_INDEX;
  3062. *pucSupMcs32 = 0;
  3063. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3064. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3065. break;
  3066. case FIXED_RATE_MCS3_40M_800NS:
  3067. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3068. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3069. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3070. *pucMcsSet = HT_RATE_MCS3_INDEX;
  3071. *pucSupMcs32 = 0;
  3072. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3073. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3074. break;
  3075. case FIXED_RATE_MCS4_40M_800NS:
  3076. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3077. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3078. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3079. *pucMcsSet = HT_RATE_MCS4_INDEX;
  3080. *pucSupMcs32 = 0;
  3081. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3082. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3083. break;
  3084. case FIXED_RATE_MCS5_40M_800NS:
  3085. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3086. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3087. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3088. *pucMcsSet = HT_RATE_MCS5_INDEX;
  3089. *pucSupMcs32 = 0;
  3090. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3091. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3092. break;
  3093. case FIXED_RATE_MCS6_40M_800NS:
  3094. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3095. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3096. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3097. *pucMcsSet = HT_RATE_MCS6_INDEX;
  3098. *pucSupMcs32 = 0;
  3099. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3100. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3101. break;
  3102. case FIXED_RATE_MCS7_40M_800NS:
  3103. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3104. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3105. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3106. *pucMcsSet = HT_RATE_MCS7_INDEX;
  3107. *pucSupMcs32 = 0;
  3108. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3109. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3110. break;
  3111. case FIXED_RATE_MCS32_800NS:
  3112. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3113. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3114. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3115. *pucMcsSet = HT_RATE_MCS32_INDEX;
  3116. *pucSupMcs32 = 1;
  3117. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_HT_GF);
  3118. (*pu2HtCapInfo) |= HT_CAP_INFO_SUP_CHNL_WIDTH;
  3119. break;
  3120. case FIXED_RATE_MCS0_40M_400NS:
  3121. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3122. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3123. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3124. *pucMcsSet = HT_RATE_MCS0_INDEX;
  3125. *pucSupMcs32 = 0;
  3126. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3127. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3128. break;
  3129. case FIXED_RATE_MCS1_40M_400NS:
  3130. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3131. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3132. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3133. *pucMcsSet = HT_RATE_MCS1_INDEX;
  3134. *pucSupMcs32 = 0;
  3135. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3136. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3137. break;
  3138. case FIXED_RATE_MCS2_40M_400NS:
  3139. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3140. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3141. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3142. *pucMcsSet = HT_RATE_MCS2_INDEX;
  3143. *pucSupMcs32 = 0;
  3144. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3145. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3146. break;
  3147. case FIXED_RATE_MCS3_40M_400NS:
  3148. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3149. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3150. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3151. *pucMcsSet = HT_RATE_MCS3_INDEX;
  3152. *pucSupMcs32 = 0;
  3153. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3154. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3155. break;
  3156. case FIXED_RATE_MCS4_40M_400NS:
  3157. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3158. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3159. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3160. *pucMcsSet = HT_RATE_MCS4_INDEX;
  3161. *pucSupMcs32 = 0;
  3162. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3163. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3164. break;
  3165. case FIXED_RATE_MCS5_40M_400NS:
  3166. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3167. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3168. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3169. *pucMcsSet = HT_RATE_MCS5_INDEX;
  3170. *pucSupMcs32 = 0;
  3171. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3172. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3173. break;
  3174. case FIXED_RATE_MCS6_40M_400NS:
  3175. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3176. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3177. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3178. *pucMcsSet = HT_RATE_MCS6_INDEX;
  3179. *pucSupMcs32 = 0;
  3180. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3181. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3182. break;
  3183. case FIXED_RATE_MCS7_40M_400NS:
  3184. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3185. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3186. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3187. *pucMcsSet = HT_RATE_MCS7_INDEX;
  3188. *pucSupMcs32 = 0;
  3189. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3190. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3191. break;
  3192. case FIXED_RATE_MCS32_400NS:
  3193. *pucDesiredPhyTypeSet = PHY_TYPE_BIT_HT;
  3194. *pu2DesiredNonHTRateSet = RATE_SET_BIT_HT_PHY;
  3195. *pu2BSSBasicRateSet = RATE_SET_BIT_HT_PHY;
  3196. *pucMcsSet = HT_RATE_MCS32_INDEX;
  3197. *pucSupMcs32 = 1;
  3198. (*pu2HtCapInfo) &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_HT_GF);
  3199. (*pu2HtCapInfo) |= (HT_CAP_INFO_SUP_CHNL_WIDTH | HT_CAP_INFO_SHORT_GI_40M);
  3200. break;
  3201. default:
  3202. ASSERT(0);
  3203. }
  3204. return WLAN_STATUS_SUCCESS;
  3205. }
  3206. /*----------------------------------------------------------------------------*/
  3207. /*!
  3208. * @brief This utility function is used to write the register
  3209. *
  3210. * @param u4Address Register address
  3211. * u4Value the value to be written
  3212. *
  3213. * @retval WLAN_STATUS_SUCCESS
  3214. * WLAN_STATUS_FAILURE
  3215. */
  3216. /*----------------------------------------------------------------------------*/
  3217. WLAN_STATUS nicWriteMcr(IN P_ADAPTER_T prAdapter, IN UINT_32 u4Address, IN UINT_32 u4Value)
  3218. {
  3219. CMD_ACCESS_REG rCmdAccessReg;
  3220. rCmdAccessReg.u4Address = u4Address;
  3221. rCmdAccessReg.u4Data = u4Value;
  3222. return wlanSendSetQueryCmd(prAdapter,
  3223. CMD_ID_ACCESS_REG,
  3224. TRUE,
  3225. FALSE,
  3226. FALSE, NULL, NULL, sizeof(CMD_ACCESS_REG), (PUINT_8) &rCmdAccessReg, NULL, 0);
  3227. }
  3228. /*----------------------------------------------------------------------------*/
  3229. /*!
  3230. * @brief This utility function is used to modify the auto rate parameters
  3231. *
  3232. * @param u4ArSysParam0 see description below
  3233. * u4ArSysParam1
  3234. * u4ArSysParam2
  3235. * u4ArSysParam3
  3236. *
  3237. *
  3238. * @retval WLAN_STATUS_SUCCESS
  3239. * WLAN_STATUS_FAILURE
  3240. *
  3241. * @note
  3242. * ArSysParam0[0:3] -> auto rate version (0:disable 1:version1 2:version2)
  3243. * ArSysParam0[4:5]-> auto bw version (0:disable 1:version1 2:version2)
  3244. * ArSysParam0[6:7]-> auto gi version (0:disable 1:version1 2:version2)
  3245. * ArSysParam0[8:15]-> HT rate clear mask
  3246. * ArSysParam0[16:31]-> Legacy rate clear mask
  3247. * ArSysParam1[0:7]-> Auto Rate check weighting window
  3248. * ArSysParam1[8:15]-> Auto Rate v1 Force Rate down
  3249. * ArSysParam1[16:23]-> Auto Rate v1 PerH
  3250. * ArSysParam1[24:31]-> Auto Rate v1 PerL
  3251. *
  3252. * Examples
  3253. * ArSysParam0 = 1,
  3254. * Enable auto rate version 1
  3255. *
  3256. * ArSysParam0 = 983041,
  3257. * Enable auto rate version 1
  3258. * Remove CCK 1M, 2M, 5.5M, 11M
  3259. *
  3260. * ArSysParam0 = 786433
  3261. * Enable auto rate version 1
  3262. * Remove CCK 5.5M 11M
  3263. */
  3264. /*----------------------------------------------------------------------------*/
  3265. WLAN_STATUS
  3266. nicRlmArUpdateParms(IN P_ADAPTER_T prAdapter,
  3267. IN UINT_32 u4ArSysParam0,
  3268. IN UINT_32 u4ArSysParam1, IN UINT_32 u4ArSysParam2, IN UINT_32 u4ArSysParam3)
  3269. {
  3270. UINT_8 ucArVer, ucAbwVer, ucAgiVer;
  3271. UINT_16 u2HtClrMask;
  3272. UINT_16 u2LegacyClrMask;
  3273. UINT_8 ucArCheckWindow;
  3274. UINT_8 ucArPerL;
  3275. UINT_8 ucArPerH;
  3276. UINT_8 ucArPerForceRateDownPer;
  3277. ucArVer = (UINT_8) (u4ArSysParam0 & BITS(0, 3));
  3278. ucAbwVer = (UINT_8) ((u4ArSysParam0 & BITS(4, 5)) >> 4);
  3279. ucAgiVer = (UINT_8) ((u4ArSysParam0 & BITS(6, 7)) >> 6);
  3280. u2HtClrMask = (UINT_16) ((u4ArSysParam0 & BITS(8, 15)) >> 8);
  3281. u2LegacyClrMask = (UINT_16) ((u4ArSysParam0 & BITS(16, 31)) >> 16);
  3282. #if 0
  3283. ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0, 7));
  3284. ucArPerForceRateDownPer = (UINT_8) ((u4ArSysParam1 & BITS(8, 15) >> 8));
  3285. ucArPerH = (UINT_8) ((u4ArSysParam1 & BITS(16, 23)) >> 16);
  3286. ucArPerL = (UINT_8) ((u4ArSysParam1 & BITS(24, 31)) >> 24);
  3287. #endif
  3288. ucArCheckWindow = (UINT_8) (u4ArSysParam1 & BITS(0, 7));
  3289. ucArPerForceRateDownPer = (UINT_8) (((u4ArSysParam1 >> 8) & BITS(0, 7)));
  3290. ucArPerH = (UINT_8) (((u4ArSysParam1 >> 16) & BITS(0, 7)));
  3291. ucArPerL = (UINT_8) (((u4ArSysParam1 >> 24) & BITS(0, 7)));
  3292. DBGLOG(NIC, INFO, "ArParam %u %u %u %u\n", u4ArSysParam0, u4ArSysParam1, u4ArSysParam2, u4ArSysParam3);
  3293. DBGLOG(NIC, INFO, "ArVer %u AbwVer %u AgiVer %u\n", ucArVer, ucAbwVer, ucAgiVer);
  3294. DBGLOG(NIC, INFO, "HtMask %x LegacyMask %x\n", u2HtClrMask, u2LegacyClrMask);
  3295. DBGLOG(NIC, INFO,
  3296. "CheckWin %u RateDownPer %u PerH %u PerL %u\n", ucArCheckWindow, ucArPerForceRateDownPer, ucArPerH,
  3297. ucArPerL);
  3298. #define SWCR_DATA_ADDR(MOD, ADDR) (0x90000000+(MOD<<8)+(ADDR))
  3299. #define SWCR_DATA_CMD(CATE, WRITE, INDEX, OPT0, OPT1) ((CATE<<24) | (WRITE<<23) | (INDEX<<16) | (OPT0 << 8) | OPT1)
  3300. #define SWCR_DATA0 0x0
  3301. #define SWCR_DATA1 0x4
  3302. #define SWCR_DATA2 0x8
  3303. #define SWCR_DATA3 0xC
  3304. #define SWCR_DATA4 0x10
  3305. #define SWCR_WRITE 1
  3306. #define SWCR_READ 0
  3307. if (ucArVer > 0) {
  3308. /* dummy = WiFi.WriteMCR(&h90000104, &h00000001) */
  3309. /* dummy = WiFi.WriteMCR(&h90000100, &h00850000) */
  3310. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), 1);
  3311. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 5, 0, 0));
  3312. } else {
  3313. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), 0);
  3314. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 5, 0, 0));
  3315. }
  3316. /* ucArVer 0: none 1:PER 2:Rcpi */
  3317. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArVer);
  3318. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 7, 0, 0));
  3319. /* Candidate rate Ht mask */
  3320. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), u2HtClrMask);
  3321. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 0x1c, 0, 0));
  3322. /* Candidate rate legacy mask */
  3323. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), u2LegacyClrMask);
  3324. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 0x1d, 0, 0));
  3325. #if 0
  3326. if (ucArCheckWindow != 0) {
  3327. /* TX DONE MCS INDEX CHECK STA RATE DOWN TH */
  3328. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArCheckWindow);
  3329. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 0x14, 0, 0));
  3330. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArCheckWindow);
  3331. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 0xc, 0, 0));
  3332. }
  3333. if (ucArPerForceRateDownPer != 0) {
  3334. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArPerForceRateDownPer);
  3335. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 0x18, 0, 0));
  3336. }
  3337. if (ucArPerH != 0) {
  3338. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArPerH);
  3339. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 0x1, 0, 0));
  3340. }
  3341. if (ucArPerL != 0) {
  3342. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA1), ucArPerL);
  3343. nicWriteMcr(prAdapter, SWCR_DATA_ADDR(1 /*MOD*/, SWCR_DATA0), SWCR_DATA_CMD(0, SWCR_WRITE, 0x2, 0, 0));
  3344. }
  3345. #endif
  3346. return WLAN_STATUS_SUCCESS;
  3347. }
  3348. /*----------------------------------------------------------------------------*/
  3349. /*!
  3350. * @brief This utility function is used to enable roaming
  3351. *
  3352. * @param u4EnableRoaming
  3353. *
  3354. *
  3355. * @retval WLAN_STATUS_SUCCESS
  3356. * WLAN_STATUS_FAILURE
  3357. *
  3358. * @note
  3359. * u4EnableRoaming -> Enable Romaing
  3360. *
  3361. */
  3362. /*----------------------------------------------------------------------------*/
  3363. WLAN_STATUS nicRoamingUpdateParams(IN P_ADAPTER_T prAdapter, IN UINT_32 u4EnableRoaming)
  3364. {
  3365. P_CONNECTION_SETTINGS_T prConnSettings;
  3366. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3367. prConnSettings->fgIsEnableRoaming = ((u4EnableRoaming > 0) ? (TRUE) : (FALSE));
  3368. return WLAN_STATUS_SUCCESS;
  3369. }
  3370. /*----------------------------------------------------------------------------*/
  3371. /*!
  3372. * \brief dump firmware Assert message
  3373. *
  3374. * \param[in]
  3375. * prAdapter
  3376. *
  3377. * \return
  3378. * TRUE
  3379. * FALSE
  3380. */
  3381. /*----------------------------------------------------------------------------*/
  3382. VOID nicPrintFirmwareAssertInfo(IN P_ADAPTER_T prAdapter)
  3383. {
  3384. UINT_32 u4MailBox0, u4MailBox1;
  3385. UINT_32 line = 0;
  3386. UINT_8 aucAssertFile[7];
  3387. UINT_32 u4ChipId;
  3388. #if CFG_SDIO_INTR_ENHANCE
  3389. u4MailBox0 = prAdapter->prSDIOCtrl->u4RcvMailbox0;
  3390. u4MailBox1 = prAdapter->prSDIOCtrl->u4RcvMailbox1;
  3391. #else
  3392. nicGetMailbox(prAdapter, 0, &u4MailBox0);
  3393. nicGetMailbox(prAdapter, 1, &u4MailBox1);
  3394. #endif
  3395. line = u4MailBox0 & 0x0000FFFF;
  3396. u4MailBox0 = ((u4MailBox0 >> 16) & 0x0000FFFF);
  3397. kalMemCopy(&aucAssertFile[0], &u4MailBox0, 2);
  3398. kalMemCopy(&aucAssertFile[2], &u4MailBox1, 4);
  3399. aucAssertFile[6] = '\0';
  3400. #if defined(MT6620)
  3401. u4ChipId = 6620;
  3402. #elif defined(MT6628)
  3403. u4ChipId = 6582;
  3404. #endif
  3405. kalPrint("\n[MT%u][wifi][Firmware] Assert at \"%s\" #%u\n\n", u4ChipId, aucAssertFile, line);
  3406. }
  3407. /*----------------------------------------------------------------------------*/
  3408. /*!
  3409. * @brief This function is called to update Link Quality information
  3410. *
  3411. * @param prAdapter Pointer of Adapter Data Structure
  3412. * eNetTypeIdx
  3413. * prEventLinkQuality
  3414. * cRssi
  3415. * cLinkQuality
  3416. *
  3417. * @return none
  3418. */
  3419. /*----------------------------------------------------------------------------*/
  3420. VOID
  3421. nicUpdateLinkQuality(IN P_ADAPTER_T prAdapter,
  3422. IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx, IN P_EVENT_LINK_QUALITY prEventLinkQuality)
  3423. {
  3424. ASSERT(prAdapter);
  3425. ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
  3426. ASSERT(prEventLinkQuality);
  3427. switch (eNetTypeIdx) {
  3428. case NETWORK_TYPE_AIS_INDEX:
  3429. if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  3430. /* check is to prevent RSSI to be updated by incorrect initial RSSI from hardware */
  3431. /* buffer statistics for further query */
  3432. if (prAdapter->fgIsLinkQualityValid == FALSE
  3433. || (kalGetTimeTick() - prAdapter->rLinkQualityUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
  3434. nicUpdateRSSI(prAdapter, eNetTypeIdx, prEventLinkQuality->cRssi,
  3435. prEventLinkQuality->cLinkQuality);
  3436. }
  3437. if (prAdapter->fgIsLinkRateValid == FALSE
  3438. || (kalGetTimeTick() - prAdapter->rLinkRateUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
  3439. nicUpdateLinkSpeed(prAdapter, eNetTypeIdx, prEventLinkQuality->u2LinkSpeed);
  3440. }
  3441. }
  3442. break;
  3443. #if CFG_ENABLE_WIFI_DIRECT && CFG_SUPPORT_P2P_RSSI_QUERY
  3444. case NETWORK_TYPE_P2P_INDEX:
  3445. if (prAdapter->fgIsP2pLinkQualityValid == FALSE
  3446. || (kalGetTimeTick() - prAdapter->rP2pLinkQualityUpdateTime) > CFG_LINK_QUALITY_VALID_PERIOD) {
  3447. P_EVENT_LINK_QUALITY_EX prEventLQEx = (P_EVENT_LINK_QUALITY_EX) prEventLinkQuality;
  3448. nicUpdateRSSI(prAdapter, NETWORK_TYPE_P2P_INDEX, prEventLQEx->cRssiP2P,
  3449. prEventLQEx->cLinkQualityP2P);
  3450. }
  3451. break;
  3452. #endif
  3453. default:
  3454. break;
  3455. }
  3456. }
  3457. /*----------------------------------------------------------------------------*/
  3458. /*!
  3459. * @brief This function is called to update RSSI and Link Quality information
  3460. *
  3461. * @param prAdapter Pointer of Adapter Data Structure
  3462. * eNetTypeIdx
  3463. * cRssi
  3464. * cLinkQuality
  3465. *
  3466. * @return none
  3467. */
  3468. /*----------------------------------------------------------------------------*/
  3469. VOID
  3470. nicUpdateRSSI(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx, IN INT_8 cRssi, IN INT_8 cLinkQuality)
  3471. {
  3472. ASSERT(prAdapter);
  3473. ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
  3474. switch (eNetTypeIdx) {
  3475. case NETWORK_TYPE_AIS_INDEX:
  3476. if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  3477. prAdapter->fgIsLinkQualityValid = TRUE;
  3478. prAdapter->rLinkQualityUpdateTime = kalGetTimeTick();
  3479. prAdapter->rLinkQuality.cRssi = cRssi;
  3480. prAdapter->rLinkQuality.cLinkQuality = cLinkQuality;
  3481. /* indicate to glue layer */
  3482. kalUpdateRSSI(prAdapter->prGlueInfo,
  3483. KAL_NETWORK_TYPE_AIS_INDEX,
  3484. prAdapter->rLinkQuality.cRssi, prAdapter->rLinkQuality.cLinkQuality);
  3485. }
  3486. break;
  3487. #if CFG_ENABLE_WIFI_DIRECT
  3488. #if CFG_SUPPORT_P2P_RSSI_QUERY
  3489. case NETWORK_TYPE_P2P_INDEX:
  3490. prAdapter->fgIsP2pLinkQualityValid = TRUE;
  3491. prAdapter->rP2pLinkQualityUpdateTime = kalGetTimeTick();
  3492. prAdapter->rP2pLinkQuality.cRssi = cRssi;
  3493. prAdapter->rP2pLinkQuality.cLinkQuality = cLinkQuality;
  3494. kalUpdateRSSI(prAdapter->prGlueInfo, KAL_NETWORK_TYPE_P2P_INDEX, cRssi, cLinkQuality);
  3495. break;
  3496. #endif
  3497. #endif
  3498. default:
  3499. break;
  3500. }
  3501. }
  3502. /*----------------------------------------------------------------------------*/
  3503. /*!
  3504. * @brief This function is called to update Link Quality information
  3505. *
  3506. * @param prAdapter Pointer of Adapter Data Structure
  3507. * eNetTypeIdx
  3508. * prEventLinkQuality
  3509. * cRssi
  3510. * cLinkQuality
  3511. *
  3512. * @return none
  3513. */
  3514. /*----------------------------------------------------------------------------*/
  3515. VOID nicUpdateLinkSpeed(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx, IN UINT_16 u2LinkSpeed)
  3516. {
  3517. ASSERT(prAdapter);
  3518. ASSERT(eNetTypeIdx < NETWORK_TYPE_INDEX_NUM);
  3519. switch (eNetTypeIdx) {
  3520. case NETWORK_TYPE_AIS_INDEX:
  3521. if (prAdapter->rWifiVar.arBssInfo[eNetTypeIdx].eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  3522. /* buffer statistics for further query */
  3523. prAdapter->fgIsLinkRateValid = TRUE;
  3524. prAdapter->rLinkRateUpdateTime = kalGetTimeTick();
  3525. prAdapter->rLinkQuality.u2LinkSpeed = u2LinkSpeed;
  3526. }
  3527. break;
  3528. default:
  3529. break;
  3530. }
  3531. }
  3532. #if CFG_SUPPORT_RDD_TEST_MODE
  3533. WLAN_STATUS nicUpdateRddTestMode(IN P_ADAPTER_T prAdapter, IN P_CMD_RDD_CH_T prRddChParam)
  3534. {
  3535. DEBUGFUNC("nicUpdateRddTestMode.\n");
  3536. ASSERT(prAdapter);
  3537. /* aisFsmScanRequest(prAdapter, NULL); */
  3538. return wlanSendSetQueryCmd(prAdapter,
  3539. CMD_ID_SET_RDD_CH,
  3540. TRUE,
  3541. FALSE, FALSE, NULL, NULL, sizeof(CMD_RDD_CH_T), (PUINT_8) prRddChParam, NULL, 0);
  3542. }
  3543. #endif