nic.c 141 KB

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