ais_fsm.c 165 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/ais_fsm.c#1
  3. */
  4. /*! \file "aa_fsm.c"
  5. \brief This file defines the FSM for SAA and AAA MODULE.
  6. This file defines the FSM for SAA and AAA MODULE.
  7. */
  8. /*
  9. ** Log: ais_fsm.c
  10. **
  11. ** 09 06 2013 cp.wu
  12. ** always paste SSID information to SAA-FSM
  13. **
  14. ** 09 06 2013 cp.wu
  15. ** add error handling when reassociation request failed to locate bss descriptor
  16. **
  17. ** 09 05 2013 cp.wu
  18. ** isolate logic regarding roaming & reassociation
  19. **
  20. ** 09 04 2013 cp.wu
  21. ** fix typo
  22. **
  23. ** 09 03 2013 cp.wu
  24. ** add path for reassociation
  25. *
  26. * 04 20 2012 cp.wu
  27. * [WCXRP00000913] [MT6620 Wi-Fi] create repository of source code dedicated for MT6620 E6 ASIC
  28. * correct macro
  29. *
  30. * 01 16 2012 cp.wu
  31. * [MT6620 Wi-Fi][Driver] API and behavior modification for preferred band configuration with
  32. * corresponding network configuration
  33. * add wlanSetPreferBandByNetwork() for glue layer to invoke for setting preferred band configuration
  34. * corresponding to network type.
  35. *
  36. * 11 24 2011 wh.su
  37. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  38. * Adjust code for DBG and CONFIG_XLOG.
  39. *
  40. * 11 22 2011 cp.wu
  41. * [WCXRP00001120] [MT6620 Wi-Fi][Driver] Modify roaming to AIS state transition from synchronous
  42. * to asynchronous approach to avoid incomplete state termination
  43. * 1. change RDD related compile option brace position.
  44. * 2. when roaming is triggered, ask AIS to transit immediately only when AIS is in Normal TR state
  45. * without join timeout timer ticking
  46. * 3. otherwise, insert AIS_REQUEST into pending request queue
  47. *
  48. * 11 11 2011 wh.su
  49. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  50. * modify the xlog related code.
  51. *
  52. * 11 04 2011 cp.wu
  53. * [WCXRP00001086] [MT6620 Wi-Fi][Driver] On Android, indicate an extra DISCONNECT for REASSOCIATED
  54. * cases as an explicit trigger for Android framework
  55. * correct reference to BSSID field in Association-Response frame.
  56. *
  57. * 11 04 2011 cp.wu
  58. * [WCXRP00001086] [MT6620 Wi-Fi][Driver] On Android, indicate an extra DISCONNECT for REASSOCIATED
  59. * cases as an explicit trigger for Android framework
  60. * 1. for DEAUTH/DISASSOC cases, indicate for DISCONNECTION immediately.
  61. * 2. (Android only) when reassociation-and-non-roaming cases happened, indicate an extra DISCONNECT
  62. * indication to Android Wi-Fi framework
  63. *
  64. * 11 02 2011 wh.su
  65. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  66. * adding the code for XLOG.
  67. *
  68. * 10 26 2011 tsaiyuan.hsu
  69. * [WCXRP00001064] [MT6620 Wi-Fi][DRV]] add code with roaming awareness when disconnecting AIS network
  70. * be aware roaming when disconnecting AIS network.
  71. *
  72. * 10 25 2011 cm.chang
  73. * [WCXRP00001058] [All Wi-Fi][Driver] Fix sta_rec's phyTypeSet and OBSS scan in AP mode
  74. * STA_REC shall be NULL for Beacon's MSDU
  75. *
  76. * 10 13 2011 cp.wu
  77. * [MT6620 Wi-Fi][Driver] Reduce join failure count limit to 2 for faster re-join for other BSS
  78. * 1. short join failure count limit to 2
  79. * 2. treat join timeout as kind of join failure as well
  80. *
  81. * 10 12 2011 wh.su
  82. * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
  83. * adding the 802.11w related function and define .
  84. *
  85. * 09 30 2011 cm.chang
  86. * [WCXRP00001020] [MT6620 Wi-Fi][Driver] Handle secondary channel offset of AP in 5GHz band
  87. * .
  88. *
  89. * 09 20 2011 tsaiyuan.hsu
  90. * [WCXRP00000931] [MT5931 Wi-Fi][DRV/FW] add swcr to disable roaming from driver
  91. * change window registry of driver for roaming.
  92. *
  93. * 09 20 2011 cm.chang
  94. * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
  95. * Handle client mode about preamble type and slot time
  96. *
  97. * 09 08 2011 tsaiyuan.hsu
  98. * [WCXRP00000972] [MT6620 Wi-Fi][DRV]] check if roaming occurs after join failure to avoid state incosistence.
  99. * check if roaming occurs after join failure to avoid deactivation of network.
  100. *
  101. * 08 24 2011 chinghwa.yu
  102. * [WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
  103. * Update RDD test mode cases.
  104. *
  105. * 08 16 2011 tsaiyuan.hsu
  106. * [WCXRP00000931] [MT5931 Wi-Fi][DRV/FW] add swcr to disable roaming from driver
  107. * EnableRoaming in registry is deprecated.
  108. *
  109. * 08 16 2011 tsaiyuan.hsu
  110. * [WCXRP00000931] [MT5931 Wi-Fi][DRV/FW] add swcr to disable roaming from driver
  111. * use registry to enable or disable roaming.
  112. *
  113. * 07 07 2011 cp.wu
  114. * [WCXRP00000840] [MT6620 Wi-Fi][Driver][AIS] Stop timer for joining when channel is released
  115. * due to join failure count exceeding limit
  116. * stop timer when joining operation is failed due to try count exceeds limitation
  117. *
  118. * 06 28 2011 cp.wu
  119. * [WCXRP00000815] [MT6620 Wi-Fi][Driver] allow single BSSID with multiple SSID settings to work
  120. * around some tricky AP which use space character as hidden SSID
  121. * do not handle SCAN request immediately after connected to increase the probability of receiving 1st beacon frame.
  122. *
  123. * 06 23 2011 cp.wu
  124. * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
  125. * change parameter name from PeerAddr to BSSID
  126. *
  127. * 06 20 2011 cp.wu
  128. * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
  129. * 1. specify target's BSSID when requesting channel privilege.
  130. * 2. pass BSSID information to firmware domain
  131. *
  132. * 06 16 2011 cp.wu
  133. * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
  134. * ensure DEAUTH is always sent before establish a new connection
  135. *
  136. * 06 16 2011 cp.wu
  137. * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
  138. * typo fix: a right brace is missed.
  139. *
  140. * 06 16 2011 cp.wu
  141. * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
  142. * When RECONNECT request is identified as disconnected, it is necessary to check for pending scan request.
  143. *
  144. * 06 16 2011 cp.wu
  145. * [WCXRP00000757] [MT6620 Wi-Fi][Driver][SCN] take use of RLM API to filter out BSS in disallowed channels
  146. * mark fgIsTransition as TRUE for state rolling.
  147. *
  148. * 06 16 2011 cp.wu
  149. * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
  150. * always check for pending scan after switched into NORMAL_TR state.
  151. *
  152. * 06 14 2011 cp.wu
  153. * [WCXRP00000782] [MT6620 Wi-Fi][AIS] Treat connection at higher priority over scanning to avoid WZC connection timeout
  154. * always treat connection request at higher priority over scanning request
  155. *
  156. * 06 09 2011 tsaiyuan.hsu
  157. * [WCXRP00000760] [MT5931 Wi-Fi][FW] Refine rxmHandleMacRxDone to reduce code size
  158. * move send_auth at rxmHandleMacRxDone in firmware to driver to reduce code size.
  159. *
  160. * 06 02 2011 cp.wu
  161. * [WCXRP00000681] [MT5931][Firmware] HIF code size reduction
  162. * eliminate unused parameters for SAA-FSM
  163. *
  164. * 05 18 2011 cp.wu
  165. * [WCXRP00000732] [MT6620 Wi-Fi][AIS] No need to switch back to IDLE state
  166. * when DEAUTH frame is dropped due to bss disconnection
  167. * change SCAN handling behavior when followed by a CONNECT/DISCONNECT requests by pending instead of dropping.
  168. *
  169. * 05 17 2011 cp.wu
  170. * [WCXRP00000732] [MT6620 Wi-Fi][AIS] No need to switch back to IDLE state
  171. * when DEAUTH frame is dropped due to bss disconnection
  172. * when TX DONE status is TX_RESULT_DROPPED_IN_DRIVER, no need to switch back to IDLE state.
  173. *
  174. * 04 14 2011 cm.chang
  175. * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
  176. * .
  177. *
  178. * 04 13 2011 george.huang
  179. * [WCXRP00000628] [MT6620 Wi-Fi][FW][Driver] Modify U-APSD setting to default OFF
  180. * remove assert
  181. *
  182. * 03 18 2011 cp.wu
  183. * [WCXRP00000575] [MT6620 Wi-Fi][Driver][AIS] reduce memory usage when generating mailbox message for scan request
  184. * when there is no IE needed for probe request, then request a smaller memory for mailbox message
  185. *
  186. * 03 17 2011 chinglan.wang
  187. * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
  188. * .
  189. *
  190. * 03 17 2011 chinglan.wang
  191. * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
  192. * .
  193. *
  194. * 03 16 2011 tsaiyuan.hsu
  195. * [WCXRP00000517] [MT6620 Wi-Fi][Driver][FW] Fine Tune Performance of Roaming
  196. * remove obsolete definition and unused variables.
  197. *
  198. * 03 11 2011 cp.wu
  199. * [WCXRP00000535] [MT6620 Wi-Fi][Driver] Fixed channel operation when AIS and Tethering are operating concurrently
  200. * When fixed channel operation is necessary, AIS-FSM would scan and only connect for BSS on the specific channel
  201. *
  202. * 03 09 2011 tsaiyuan.hsu
  203. * [WCXRP00000517] [MT6620 Wi-Fi][Driver][FW] Fine Tune Performance of Roaming
  204. * avoid clearing fgIsScanReqIssued so as to add scan results.
  205. *
  206. * 03 07 2011 terry.wu
  207. * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
  208. * Toggle non-standard debug messages to comments.
  209. *
  210. * 03 04 2011 tsaiyuan.hsu
  211. * [WCXRP00000517] [MT6620 Wi-Fi][Driver][FW] Fine Tune Performance of Roaming
  212. * reset retry conter of attemp to connect to ap after completion of join.
  213. *
  214. * 03 04 2011 cp.wu
  215. * [WCXRP00000515] [MT6620 Wi-Fi][Driver] Surpress compiler warning which is identified by GNU compiler collection
  216. * surpress compile warning occurred when compiled by GNU compiler collection.
  217. *
  218. * 03 02 2011 cp.wu
  219. * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right
  220. * after connection is built.
  221. * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
  222. *
  223. * 02 26 2011 tsaiyuan.hsu
  224. * [WCXRP00000391] [MT6620 Wi-Fi][FW] Add Roaming Support
  225. * not send disassoc or deauth to leaving AP so as to improve performace of roaming.
  226. *
  227. * 02 23 2011 cp.wu
  228. * [WCXRP00000487] [MT6620 Wi-Fi][Driver][AIS] Serve scan and connect request with a queue-based approach to
  229. * improve response time for scanning request
  230. * when handling reconnect request, set fgTryScan as TRUE
  231. *
  232. * 02 22 2011 cp.wu
  233. * [WCXRP00000487] [MT6620 Wi-Fi][Driver][AIS] Serve scan and connect request with a queue-based approach
  234. * to improve response time for scanning request
  235. * handle SCAN and RECONNECT with a FIFO approach.
  236. *
  237. * 02 09 2011 tsaiyuan.hsu
  238. * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
  239. * Check if prRegInfo is null or not before initializing roaming parameters.
  240. *
  241. * 02 01 2011 cp.wu
  242. * [WCXRP00000416] [MT6620 Wi-Fi][Driver] treat "unable to find BSS" as connection trial
  243. * to prevent infinite reconnection trials
  244. * treat "unable to find BSS" as connection trial to prevent infinite reconnection trials.
  245. *
  246. * 01 27 2011 tsaiyuan.hsu
  247. * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
  248. * add roaming fsm
  249. * 1. not support 11r, only use strength of signal to determine roaming.
  250. * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
  251. * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
  252. * 4. assume that change of link quality in smooth way.
  253. *
  254. * 01 26 2011 yuche.tsai
  255. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  256. * .
  257. *
  258. * 01 25 2011 yuche.tsai
  259. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  260. * Fix Compile Error when DBG is disabled.
  261. *
  262. * 01 25 2011 yuche.tsai
  263. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  264. * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
  265. *
  266. * 01 14 2011 cp.wu
  267. * [WCXRP00000359] [MT6620 Wi-Fi][Driver] add an extra state to ensure DEAUTH frame is always sent
  268. * Add an extra state to guarantee DEAUTH frame is sent then connect to new BSS.
  269. * This change is due to WAPI AP needs DEAUTH frame as a necessary step in handshaking protocol.
  270. *
  271. * 01 11 2011 cp.wu
  272. * [WCXRP00000307] [MT6620 Wi-Fi][SQA]WHQL test .2c_wlan_adhoc case fail.
  273. * [IBSS] when merged in, the bss state should be updated to firmware to pass WHQL adhoc failed item
  274. *
  275. * 01 10 2011 cp.wu
  276. * [WCXRP00000351] [MT6620 Wi-Fi][Driver] remove from scanning result in OID handling layer
  277. * when the corresponding BSS is disconnected due to beacon timeout
  278. * remove from scanning result when the BSS is disconnected due to beacon timeout.
  279. *
  280. * 01 03 2011 cp.wu
  281. * [WCXRP00000337] [MT6620 Wi-FI][Driver] AIS-FSM not to invoke cnmStaRecResetStatus
  282. * directly 'cause it frees all belonging STA-RECs
  283. * do not invoke cnmStaRecResetStatus() directly, nicUpdateBss will do the things after bss is disconnected
  284. *
  285. * 12 30 2010 cp.wu
  286. * [WCXRP00000270] [MT6620 Wi-Fi][Driver] Clear issues after concurrent networking support has been merged
  287. * do not need to manipulate prStaRec after indicating BSS disconnection to firmware,
  288. * 'cause all STA-RECs belongs to BSS has been freed already
  289. *
  290. * 12 27 2010 cp.wu
  291. * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
  292. * add DEBUGFUNC() macro invoking for more detailed debugging information
  293. *
  294. * 12 23 2010 george.huang
  295. * [WCXRP00000152] [MT6620 Wi-Fi] AP mode power saving function
  296. * 1. update WMM IE parsing, with ASSOC REQ handling
  297. * 2. extend U-APSD parameter passing from driver to FW
  298. *
  299. * 12 17 2010 cp.wu
  300. * [WCXRP00000270] [MT6620 Wi-Fi][Driver] Clear issues after concurrent networking support has been merged
  301. * before BSS disconnection is indicated to firmware, all correlated peer should be cleared and freed
  302. *
  303. * 12 07 2010 cm.chang
  304. * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
  305. * 1. BSSINFO include RLM parameter
  306. * 2. free all sta records when network is disconnected
  307. *
  308. * 11 25 2010 yuche.tsai
  309. * NULL
  310. * Update SLT Function for QoS Support and not be affected by fixed rate function.
  311. *
  312. * 11 25 2010 cp.wu
  313. * [WCXRP00000208] [MT6620 Wi-Fi][Driver] Add scanning with specified SSID to AIS FSM
  314. * add scanning with specified SSID facility to AIS-FSM
  315. *
  316. * 11 01 2010 cp.wu
  317. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with
  318. * Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver] Add implementation for querying current TX rate
  319. * from firmware auto rate module
  320. * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
  321. * 2) Remove CNM CH-RECOVER event handling
  322. * 3) cfg read/write API renamed with kal prefix for unified naming rules.
  323. *
  324. * 10 26 2010 cp.wu
  325. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000137] [MT6620 Wi-Fi] [FW]
  326. * Support NIC capability query command
  327. * 1) update NVRAM content template to ver 1.02
  328. * 2) add compile option for querying NIC capability (default: off)
  329. * 3) modify AIS 5GHz support to run-time option, which could be turned on by registry or NVRAM setting
  330. * 4) correct auto-rate compiler error under linux (treat warning as error)
  331. * 5) simplify usage of NVRAM and REG_INFO_T
  332. * 6) add version checking between driver and firmware
  333. *
  334. * 10 14 2010 wh.su
  335. * [WCXRP00000097] [MT6620 Wi-Fi] [Driver] Fixed the P2P not setting the fgIsChannelExt value make scan not abort
  336. * initial the fgIsChannelExt value.
  337. *
  338. * 10 08 2010 cp.wu
  339. * [WCXRP00000087] [MT6620 Wi-Fi][Driver] Cannot connect to 5GHz AP, driver will cause FW assert.
  340. * correct erroneous logic: specifying eBand with incompatible eSco
  341. *
  342. * 10 04 2010 cp.wu
  343. * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T
  344. * and replaced by ENUM_NETWORK_TYPE_INDEX_T only
  345. * remove ENUM_NETWORK_TYPE_T definitions
  346. *
  347. * 09 27 2010 chinghwa.yu
  348. * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
  349. * Update BCM/BoW design and settings.
  350. *
  351. * 09 23 2010 cp.wu
  352. * [WCXRP00000049] [MT6620 Wi-Fi][Driver] Adhoc cannot be created successfully.
  353. * keep IBSS-ALONE state retrying until further instruction is received
  354. *
  355. * 09 21 2010 cp.wu
  356. * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD
  357. * when entering RF test with AIS associated
  358. * Do a complete reset with STA-REC null checking for RF test re-entry
  359. *
  360. * 09 09 2010 yuche.tsai
  361. * NULL
  362. * Fix NULL IE Beacon issue. Sync Beacon Content to FW before enable beacon.
  363. * Both in IBSS Create & IBSS Merge
  364. *
  365. * 09 09 2010 cp.wu
  366. * NULL
  367. * frequency is in unit of KHz thus no need to divide 1000 once more.
  368. *
  369. * 09 06 2010 cp.wu
  370. * NULL
  371. * 1) initialize for correct parameter even for disassociation.
  372. * 2) AIS-FSM should have a limit on trials to build connection
  373. *
  374. * 09 03 2010 kevin.huang
  375. * NULL
  376. * Refine #include sequence and solve recursive/nested #include issue
  377. *
  378. * 08 30 2010 cp.wu
  379. * NULL
  380. * eliminate klockwork errors
  381. *
  382. * 08 29 2010 yuche.tsai
  383. * NULL
  384. * Finish SLT TX/RX & Rate Changing Support.
  385. *
  386. * 08 25 2010 cp.wu
  387. * NULL
  388. * add option for enabling AIS 5GHz scan
  389. *
  390. * 08 25 2010 cp.wu
  391. * NULL
  392. * [AIS-FSM] IBSS no longer needs to acquire channel for beaconing,
  393. * RLM/CNM will handle the channel switching when BSS information is updated
  394. *
  395. * 08 25 2010 george.huang
  396. * NULL
  397. * update OID/ registry control path for PM related settings
  398. *
  399. * 08 24 2010 cm.chang
  400. * NULL
  401. * Support RLM initail channel of Ad-hoc, P2P and BOW
  402. *
  403. * 08 20 2010 cm.chang
  404. * NULL
  405. * Migrate RLM code to host from FW
  406. *
  407. * 08 12 2010 cp.wu
  408. * NULL
  409. * check-in missed files.
  410. *
  411. * 08 12 2010 kevin.huang
  412. * NULL
  413. * Refine bssProcessProbeRequest() and bssSendBeaconProbeResponse()
  414. *
  415. * 08 09 2010 cp.wu
  416. * NULL
  417. * reset fgIsScanReqIssued when abort request is received right after join completion.
  418. *
  419. * 08 03 2010 cp.wu
  420. * NULL
  421. * surpress compilation warning.
  422. *
  423. * 08 02 2010 cp.wu
  424. * NULL
  425. * comment out deprecated members in BSS_INFO, which are only used by firmware rather than driver.
  426. *
  427. * 07 30 2010 cp.wu
  428. * NULL
  429. * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
  430. * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
  431. * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
  432. *
  433. * 07 29 2010 cp.wu
  434. * NULL
  435. * eliminate u4FreqInKHz usage, combined into rConnections.ucAdHoc*
  436. *
  437. * 07 29 2010 cp.wu
  438. * NULL
  439. * allocate on MGMT packet for IBSS beaconing.
  440. *
  441. * 07 29 2010 cp.wu
  442. * NULL
  443. * [AIS-FSM] fix: when join failed, release channel privilege as well
  444. *
  445. * 07 28 2010 cp.wu
  446. * NULL
  447. * reuse join-abort sub-procedure to reduce code size.
  448. *
  449. * 07 28 2010 cp.wu
  450. * NULL
  451. * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
  452. * 2) change nicMediaStateChange() API prototype
  453. *
  454. * 07 26 2010 cp.wu
  455. *
  456. * AIS-FSM: when scan request is coming in the 1st 5 seconds of channel privilege period,
  457. * just pend it til 5-sec. period finishes
  458. *
  459. * 07 26 2010 cp.wu
  460. *
  461. * AIS-FSM FIX: return channel privilege even when the privilege is not granted yet
  462. * QM: qmGetFrameAction() won't assert when corresponding STA-REC index is not found
  463. *
  464. * 07 26 2010 cp.wu
  465. *
  466. * re-commit code logic being overwriten.
  467. *
  468. * 07 24 2010 wh.su
  469. *
  470. * .support the Wi-Fi RSN
  471. *
  472. * 07 23 2010 cp.wu
  473. *
  474. * 1) re-enable AIS-FSM beacon timeout handling.
  475. * 2) scan done API revised
  476. *
  477. * 07 23 2010 cp.wu
  478. *
  479. * 1) enable Ad-Hoc
  480. * 2) disable beacon timeout handling temporally due to unexpected beacon timeout event.
  481. *
  482. * 07 23 2010 cp.wu
  483. *
  484. * indicate scan done for linux wireless extension
  485. *
  486. * 07 23 2010 cp.wu
  487. *
  488. * add AIS-FSM handling for beacon timeout event.
  489. *
  490. * 07 22 2010 cp.wu
  491. *
  492. * 1) refine AIS-FSM indent.
  493. * 2) when entering RF Test mode, flush 802.1X frames as well
  494. * 3) when entering D3 state, flush 802.1X frames as well
  495. *
  496. * 07 21 2010 cp.wu
  497. *
  498. * separate AIS-FSM states into different cases of channel request.
  499. *
  500. * 07 21 2010 cp.wu
  501. *
  502. * 1) change BG_SCAN to ONLINE_SCAN for consistent term
  503. * 2) only clear scanning result when scan is permitted to do
  504. *
  505. * 07 20 2010 cp.wu
  506. *
  507. * 1) [AIS] when new scan is issued, clear currently available scanning result except the connected one
  508. * 2) refine disconnection behaviour when issued during BG-SCAN process
  509. *
  510. * 07 20 2010 cp.wu
  511. *
  512. * 1) bugfix: do not stop timer for join after switched into normal_tr state,
  513. * for providing chance for DHCP handshasking
  514. * 2) modify rsnPerformPolicySelection() invoking
  515. *
  516. * 07 19 2010 cp.wu
  517. *
  518. * 1) init AIS_BSS_INFO as channel number = 1 with band = 2.4GHz
  519. * 2) correct typo
  520. *
  521. * 07 19 2010 wh.su
  522. *
  523. * update for security supporting.
  524. *
  525. * 07 19 2010 cp.wu
  526. *
  527. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  528. * when IBSS is being merged-in, send command packet to PM for connected indication
  529. *
  530. * 07 19 2010 cp.wu
  531. *
  532. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  533. * Add Ad-Hoc support to AIS-FSM
  534. *
  535. * 07 19 2010 jeffrey.chang
  536. *
  537. * Linux port modification
  538. *
  539. * 07 16 2010 cp.wu
  540. *
  541. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  542. * bugfix for SCN migration
  543. * 1) modify QUEUE_CONCATENATE_QUEUES() so it could be used to concatence with an empty queue
  544. * 2) before AIS issues scan request, network(BSS) needs to be activated first
  545. * 3) only invoke COPY_SSID when using specified SSID for scan
  546. *
  547. * 07 15 2010 cp.wu
  548. *
  549. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  550. * for AIS scanning, driver specifies no extra IE for probe request
  551. *
  552. * 07 15 2010 cp.wu
  553. *
  554. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  555. * driver no longer generates probe request frames
  556. *
  557. * 07 14 2010 yarco.yang
  558. *
  559. * Remove CFG_MQM_MIGRATION
  560. *
  561. * 07 14 2010 cp.wu
  562. *
  563. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  564. * Refine AIS-FSM by divided into more states
  565. *
  566. * 07 13 2010 cm.chang
  567. *
  568. * Rename MSG_CH_RELEASE_T to MSG_CH_ABORT_T
  569. *
  570. * 07 09 2010 cp.wu
  571. *
  572. * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
  573. * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
  574. * 3) implment DRV-SCN module, currently only accepts single scan request,
  575. * other request will be directly dropped by returning BUSY
  576. *
  577. * 07 09 2010 george.huang
  578. *
  579. * [WPD00001556] Migrate PM variables from FW to driver: for composing QoS Info
  580. *
  581. * 07 08 2010 cp.wu
  582. *
  583. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  584. *
  585. * 07 08 2010 cp.wu
  586. * [WPD00003833][MT6620 and MT5931] Driver migration
  587. * take use of RLM module for parsing/generating HT IEs for 11n capability
  588. *
  589. * 07 08 2010 cm.chang
  590. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  591. * Rename MID_MNY_CNM_CH_RELEASE to MID_MNY_CNM_CH_ABORT
  592. *
  593. * 07 07 2010 cp.wu
  594. * [WPD00003833][MT6620 and MT5931] Driver migration
  595. * for first connection, if connecting failed do not enter into scan state.
  596. *
  597. * 07 06 2010 cp.wu
  598. * [WPD00003833][MT6620 and MT5931] Driver migration
  599. * once STA-REC is allocated and updated, invoke cnmStaRecChangeState() to sync. with firmware.
  600. *
  601. * 07 06 2010 george.huang
  602. * [WPD00001556]Basic power managemenet function
  603. * Update arguments for nicUpdateBeaconIETemplate()
  604. *
  605. * 07 06 2010 cp.wu
  606. * [WPD00003833][MT6620 and MT5931] Driver migration
  607. * STA-REC is maintained by CNM only.
  608. *
  609. * 07 05 2010 cp.wu
  610. * [WPD00003833][MT6620 and MT5931] Driver migration
  611. * remove unused definitions.
  612. *
  613. * 07 01 2010 cp.wu
  614. * [WPD00003833][MT6620 and MT5931] Driver migration
  615. * AIS-FSM integration with CNM channel request messages
  616. *
  617. * 07 01 2010 cp.wu
  618. * [WPD00003833][MT6620 and MT5931] Driver migration
  619. * implementation of DRV-SCN and related mailbox message handling.
  620. *
  621. * 06 30 2010 cp.wu
  622. * [WPD00003833][MT6620 and MT5931] Driver migration
  623. * sync. with CMD/EVENT document ver0.07.
  624. *
  625. * 06 29 2010 cp.wu
  626. * [WPD00003833][MT6620 and MT5931] Driver migration
  627. * 1) sync to. CMD/EVENT document v0.03
  628. * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
  629. * 3) send command packet to indicate FW-PM after
  630. * a) 1st beacon is received after AIS has connected to an AP
  631. * b) IBSS-ALONE has been created
  632. * c) IBSS-MERGE has occurred
  633. *
  634. * 06 25 2010 cp.wu
  635. * [WPD00003833][MT6620 and MT5931] Driver migration
  636. * modify Beacon/ProbeResp to complete parsing,
  637. * because host software has looser memory usage restriction
  638. *
  639. * 06 23 2010 cp.wu
  640. * [WPD00003833][MT6620 and MT5931] Driver migration
  641. * integrate .
  642. *
  643. * 06 22 2010 cp.wu
  644. * [WPD00003833][MT6620 and MT5931] Driver migration
  645. * comment out RLM APIs by CFG_RLM_MIGRATION.
  646. *
  647. * 06 22 2010 cp.wu
  648. * [WPD00003833][MT6620 and MT5931] Driver migration
  649. * 1) add command warpper for STA-REC/BSS-INFO sync.
  650. * 2) enhance command packet sending procedure for non-oid part
  651. * 3) add command packet definitions for STA-REC/BSS-INFO sync.
  652. *
  653. * 06 21 2010 yarco.yang
  654. * [WPD00003837][MT6620]Data Path Refine
  655. * Support CFG_MQM_MIGRATION flag
  656. *
  657. * 06 21 2010 cp.wu
  658. * [WPD00003833][MT6620 and MT5931] Driver migration
  659. * add scan_fsm into building.
  660. *
  661. * 06 21 2010 cp.wu
  662. * [WPD00003833][MT6620 and MT5931] Driver migration
  663. * RSN/PRIVACY compilation flag awareness correction
  664. *
  665. * 06 18 2010 cm.chang
  666. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  667. * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
  668. *
  669. * 06 18 2010 wh.su
  670. * [WPD00003840][MT6620 5931] Security migration
  671. * migration from MT6620 firmware.
  672. *
  673. * 06 15 2010 cp.wu
  674. * [WPD00003833][MT6620 and MT5931] Driver migration
  675. * add scan.c.
  676. *
  677. * 06 14 2010 cp.wu
  678. * [WPD00003833][MT6620 and MT5931] Driver migration
  679. * restore utility function invoking via hem_mbox to direct calls
  680. *
  681. * 06 11 2010 cp.wu
  682. * [WPD00003833][MT6620 and MT5931] Driver migration
  683. * auth.c is migrated.
  684. *
  685. * 06 11 2010 cp.wu
  686. * [WPD00003833][MT6620 and MT5931] Driver migration
  687. * add bss.c.
  688. *
  689. * 06 11 2010 cp.wu
  690. * [WPD00003833][MT6620 and MT5931] Driver migration
  691. * 1) migrate assoc.c.
  692. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  693. * 3) add configuration options for CNM_MEM and RSN modules
  694. * 4) add data path for management frames
  695. * 5) eliminate rPacketInfo of MSDU_INFO_T
  696. *
  697. * 06 10 2010 cp.wu
  698. * [WPD00003833][MT6620 and MT5931] Driver migration
  699. * change to enqueue TX frame infinitely.
  700. *
  701. * 06 10 2010 cp.wu
  702. * [WPD00003833][MT6620 and MT5931] Driver migration
  703. * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
  704. * 2) when disconnected, indicate nic directly (no event is needed)
  705. *
  706. * 06 10 2010 cp.wu
  707. * [WPD00003833][MT6620 and MT5931] Driver migration
  708. * add buildable & linkable ais_fsm.c
  709. *
  710. * related reference are still waiting to be resolved
  711. *
  712. * 06 01 2010 cm.chang
  713. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  714. * Add conditionial compiling flag to choose default available bandwidth
  715. *
  716. * 05 28 2010 kevin.huang
  717. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  718. * Add ClientList handling API - bssClearClientList, bssAddStaRecToClientList
  719. *
  720. * 05 24 2010 kevin.huang
  721. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  722. * Refine authSendAuthFrame() for NULL STA_RECORD_T case and minimum deauth interval.
  723. *
  724. * 05 21 2010 kevin.huang
  725. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  726. * Fix compile error if CFG_CMD_EVENT_VER_009 == 0 for prEventConnStatus->ucNetworkType.
  727. *
  728. * 05 21 2010 kevin.huang
  729. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  730. * Refine txmInitWtblTxRateTable() - set TX initial rate according to AP's operation rate set
  731. *
  732. * 05 17 2010 kevin.huang
  733. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  734. * Call pmAbort() and add ucNetworkType field in EVENT_CONNECTION_STATUS
  735. *
  736. * 05 14 2010 kevin.huang
  737. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  738. * Fix compile warning - define of MQM_WMM_PARSING was removed
  739. *
  740. * 05 12 2010 kevin.huang
  741. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  742. * Add Power Management - Legacy PS-POLL support.
  743. *
  744. * 04 28 2010 tehuang.liu
  745. * [BORA00000605][WIFISYS] Phase3 Integration
  746. * Removed the use of compiling flag MQM_WMM_PARSING
  747. *
  748. * 04 27 2010 kevin.huang
  749. * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
  750. *
  751. * Fix typo
  752. *
  753. * 04 27 2010 kevin.huang
  754. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  755. * Add Set Slot Time and Beacon Timeout Support for AdHoc Mode
  756. *
  757. * 04 19 2010 kevin.huang
  758. * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
  759. * Add Send Deauth for Class 3 Error and Leave Network Support
  760. *
  761. * 04 15 2010 wh.su
  762. * [BORA00000680][MT6620] Support the statistic for Micxxsoft os query
  763. * fixed the protected bit at cap info for ad-hoc.
  764. *
  765. * 04 13 2010 kevin.huang
  766. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  767. * Add new HW CH macro support
  768. *
  769. * 04 07 2010 chinghwa.yu
  770. * [BORA00000563]Add WiFi CoEx BCM module
  771. * Add TX Power Control RCPI function.
  772. *
  773. * 03 29 2010 wh.su
  774. * [BORA00000605][WIFISYS] Phase3 Integration
  775. * move the wlan table alloc / free to change state function.
  776. *
  777. * 03 25 2010 wh.su
  778. * [BORA00000676][MT6620] Support the frequency setting and query at build connection / connection event
  779. * modify the build connection and status event structure bu CMD_EVENT doc 0.09 draft, default is disable.
  780. *
  781. * 03 24 2010 wh.su
  782. * [BORA00000605][WIFISYS] Phase3 Integration
  783. * fixed some WHQL testing error.
  784. *
  785. * 03 24 2010 kevin.huang
  786. * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
  787. * Add Set / Unset POWER STATE in AIS Network
  788. *
  789. * 03 16 2010 kevin.huang
  790. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  791. * Add AdHoc Mode
  792. *
  793. * 03 10 2010 kevin.huang
  794. * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
  795. * Add Channel Manager for arbitration of JOIN and SCAN Req
  796. *
  797. * 03 03 2010 kevin.huang
  798. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  799. * Add PHY_CONFIG to change Phy Type
  800. *
  801. * 03 03 2010 chinghwa.yu
  802. * [BORA00000563]Add WiFi CoEx BCM module
  803. * Use bcmWiFiNotify to replace wifi_send_msg to pass information to BCM module.
  804. *
  805. * 03 03 2010 chinghwa.yu
  806. * [BORA00000563]Add WiFi CoEx BCM module
  807. * Remove wmt_task definition and add PTA function.
  808. *
  809. * 03 02 2010 tehuang.liu
  810. * [BORA00000569][WIFISYS] Phase 2 Integration Test
  811. * Init TXM and MQM testing procedures in aisFsmRunEventJoinComplete()
  812. *
  813. * 03 01 2010 tehuang.liu
  814. * [BORA00000569][WIFISYS] Phase 2 Integration Test
  815. * Modified aisUpdateBssInfo() to call TXM's functions for setting WTBL TX parameters
  816. *
  817. * 03 01 2010 wh.su
  818. * [BORA00000605][WIFISYS] Phase3 Integration
  819. * clear the pmkid cache while indicate media disconnect.
  820. *
  821. * 02 26 2010 tehuang.liu
  822. * [BORA00000569][WIFISYS] Phase 2 Integration Test
  823. * .
  824. *
  825. * 02 26 2010 tehuang.liu
  826. * [BORA00000569][WIFISYS] Phase 2 Integration Test
  827. * Enabled MQM parsing WMM IEs for non-AP mode
  828. *
  829. * 02 26 2010 kevin.huang
  830. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  831. * Remove CFG_TEST_VIRTUAL_CMD and add support of Driver STA_RECORD_T activation
  832. *
  833. * 02 25 2010 wh.su
  834. * [BORA00000605][WIFISYS] Phase3 Integration
  835. * use the Rx0 dor event indicate.
  836. *
  837. * 02 23 2010 kevin.huang
  838. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  839. * Support dynamic channel selection
  840. *
  841. * 02 23 2010 wh.su
  842. * [BORA00000621][MT6620 Wi-Fi] Add the RSSI indicate to avoid XP stalled for query rssi value
  843. * Adding the RSSI event support,
  844. * using the HAL function to get the rcpi value and tranlsate to RSSI and indicate to driver
  845. *
  846. * 02 12 2010 cm.chang
  847. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  848. * Use bss info array for concurrent handle
  849. *
  850. * 02 05 2010 kevin.huang
  851. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  852. * Revise data structure to share the same BSS_INFO_T for avoiding coding error
  853. *
  854. * 02 04 2010 kevin.huang
  855. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  856. * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
  857. *
  858. * 01 27 2010 tehuang.liu
  859. * [BORA00000569][WIFISYS] Phase 2 Integration Test
  860. * Set max AMDPU size supported by the peer to 64 KB,
  861. * removed mqmInit() and mqmTxSendAddBaReq() function calls in aisUpdateBssInfo()
  862. *
  863. * 01 27 2010 wh.su
  864. * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
  865. * add and fixed some security function.
  866. *
  867. * 01 22 2010 cm.chang
  868. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  869. * Support protection and bandwidth switch
  870. *
  871. * 01 20 2010 kevin.huang
  872. * [BORA00000569][WIFISYS] Phase 2 Integration Test
  873. * Add PHASE_2_INTEGRATION_WORK_AROUND and CFG_SUPPORT_BCM flags
  874. *
  875. * 01 15 2010 tehuang.liu
  876. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  877. * Configured the AMPDU factor to 3 for the APu1rwduu`wvpghlqg|q`mpdkb+ilp
  878. *
  879. * 01 14 2010 chinghwa.yu
  880. * [BORA00000563]Add WiFi CoEx BCM module
  881. * Add WiFi BCM module for the 1st time.
  882. *
  883. * 01 11 2010 kevin.huang
  884. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  885. * Add Deauth and Disassoc Handler
  886. *
  887. * 01 07 2010 kevin.huang
  888. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  889. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  890. *
  891. * Refine JOIN Complete and separate the function of Media State indication
  892. *
  893. * 01 04 2010 tehuang.liu
  894. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  895. * For working out the first connection Chariot-verified version
  896. *
  897. * 12 18 2009 cm.chang
  898. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  899. * .
  900. *
  901. * Dec 10 2009 mtk01088
  902. * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
  903. * adding the sample code to update the wlan table rate,
  904. *
  905. * Dec 10 2009 mtk01104
  906. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  907. * Different function prototype of wifi_send_msg()
  908. *
  909. * Dec 9 2009 mtk01104
  910. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  911. * Call rlm related function to process HT info when join complete
  912. *
  913. * Dec 9 2009 mtk01088
  914. * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
  915. * default the acquired wlan table entry code off
  916. *
  917. * Dec 9 2009 mtk01088
  918. * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
  919. * adding the code to acquired the wlan table entry, and a sample code to update the BA bit at table
  920. *
  921. * Dec 7 2009 mtk01461
  922. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  923. * Fix the problem of prSwRfb overwrited by event packet in aisFsmRunEventJoinComplete()
  924. *
  925. * Dec 4 2009 mtk01088
  926. * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
  927. * adding the code to integrate the security related code
  928. *
  929. * Dec 3 2009 mtk01461
  930. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  931. * Remove redundant declaration
  932. *
  933. * Dec 3 2009 mtk01461
  934. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  935. * Add code for JOIN init and JOIN complete
  936. *
  937. * Nov 30 2009 mtk01461
  938. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  939. * Rename u4RSSI to i4RSSI
  940. *
  941. * Nov 30 2009 mtk01461
  942. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  943. * Revise ENUM_MEDIA_STATE to ENUM_PARAM_MEDIA_STATE
  944. *
  945. * Nov 30 2009 mtk01461
  946. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  947. * Add fgIsScanReqIssued to CONNECTION_SETTINGS_T
  948. *
  949. * Nov 26 2009 mtk01461
  950. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  951. * Revise Virtual CMD handler due to structure changed
  952. *
  953. * Nov 25 2009 mtk01461
  954. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  955. * Add Virtual CMD & RESP for testing CMD PATH
  956. *
  957. * Nov 23 2009 mtk01461
  958. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  959. * Add aisFsmInitializeConnectionSettings()
  960. *
  961. * Nov 20 2009 mtk01461
  962. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  963. * Add CFG_TEST_MGMT_FSM flag for aisFsmTest()
  964. *
  965. * Nov 16 2009 mtk01461
  966. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  967. *
  968. */
  969. /*******************************************************************************
  970. * C O M P I L E R F L A G S
  971. ********************************************************************************
  972. */
  973. /*******************************************************************************
  974. * E X T E R N A L R E F E R E N C E S
  975. ********************************************************************************
  976. */
  977. #include "precomp.h"
  978. /*******************************************************************************
  979. * C O N S T A N T S
  980. ********************************************************************************
  981. */
  982. #define AIS_ROAMING_CONNECTION_TRIAL_LIMIT 2
  983. #define AIS_ROAMING_SCAN_CHANNEL_DWELL_TIME 80
  984. #define CTIA_MAGIC_SSID "ctia_test_only_*#*#3646633#*#*"
  985. #define CTIA_MAGIC_SSID_LEN 30
  986. #define AIS_JOIN_TIMEOUT 7
  987. /*******************************************************************************
  988. * D A T A T Y P E S
  989. ********************************************************************************
  990. */
  991. /*******************************************************************************
  992. * P U B L I C D A T A
  993. ********************************************************************************
  994. */
  995. /*******************************************************************************
  996. * P R I V A T E D A T A
  997. ********************************************************************************
  998. */
  999. #if DBG
  1000. /*lint -save -e64 Type mismatch */
  1001. static PUINT_8 apucDebugAisState[AIS_STATE_NUM] = {
  1002. (PUINT_8) DISP_STRING("AIS_STATE_IDLE"),
  1003. (PUINT_8) DISP_STRING("AIS_STATE_SEARCH"),
  1004. (PUINT_8) DISP_STRING("AIS_STATE_SCAN"),
  1005. (PUINT_8) DISP_STRING("AIS_STATE_ONLINE_SCAN"),
  1006. (PUINT_8) DISP_STRING("AIS_STATE_LOOKING_FOR"),
  1007. (PUINT_8) DISP_STRING("AIS_STATE_WAIT_FOR_NEXT_SCAN"),
  1008. (PUINT_8) DISP_STRING("AIS_STATE_REQ_CHANNEL_JOIN"),
  1009. (PUINT_8) DISP_STRING("AIS_STATE_JOIN"),
  1010. (PUINT_8) DISP_STRING("AIS_STATE_IBSS_ALONE"),
  1011. (PUINT_8) DISP_STRING("AIS_STATE_IBSS_MERGE"),
  1012. (PUINT_8) DISP_STRING("AIS_STATE_NORMAL_TR"),
  1013. (PUINT_8) DISP_STRING("AIS_STATE_DISCONNECTING"),
  1014. (PUINT_8) DISP_STRING("AIS_STATE_REQ_REMAIN_ON_CHANNEL"),
  1015. (PUINT_8) DISP_STRING("AIS_STATE_REMAIN_ON_CHANNEL")
  1016. };
  1017. /*lint -restore */
  1018. #endif /* DBG */
  1019. /*******************************************************************************
  1020. * M A C R O S
  1021. ********************************************************************************
  1022. */
  1023. /*******************************************************************************
  1024. * F U N C T I O N D E C L A R A T I O N S
  1025. ********************************************************************************
  1026. */
  1027. /*******************************************************************************
  1028. * F U N C T I O N S
  1029. ********************************************************************************
  1030. */
  1031. /*----------------------------------------------------------------------------*/
  1032. /*!
  1033. * @brief the function is used to initialize the value of the connection settings for
  1034. * AIS network
  1035. *
  1036. * @param (none)
  1037. *
  1038. * @return (none)
  1039. */
  1040. /*----------------------------------------------------------------------------*/
  1041. VOID aisInitializeConnectionSettings(IN P_ADAPTER_T prAdapter, IN P_REG_INFO_T prRegInfo)
  1042. {
  1043. P_CONNECTION_SETTINGS_T prConnSettings;
  1044. UINT_8 aucAnyBSSID[] = BC_BSSID;
  1045. UINT_8 aucZeroMacAddr[] = NULL_MAC_ADDR;
  1046. int i = 0;
  1047. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  1048. /* Setup default values for operation */
  1049. COPY_MAC_ADDR(prConnSettings->aucMacAddress, aucZeroMacAddr);
  1050. if (prRegInfo)
  1051. prConnSettings->ucDelayTimeOfDisconnectEvent =
  1052. (!prAdapter->fgIsHw5GBandDisabled && prRegInfo->ucSupport5GBand) ?
  1053. AIS_DELAY_TIME_OF_DISC_SEC_DUALBAND : AIS_DELAY_TIME_OF_DISC_SEC_ONLY_2G4;
  1054. else
  1055. prConnSettings->ucDelayTimeOfDisconnectEvent = AIS_DELAY_TIME_OF_DISC_SEC_ONLY_2G4;
  1056. COPY_MAC_ADDR(prConnSettings->aucBSSID, aucAnyBSSID);
  1057. prConnSettings->fgIsConnByBssidIssued = FALSE;
  1058. prConnSettings->eReConnectLevel = RECONNECT_LEVEL_MIN;
  1059. prConnSettings->fgIsConnReqIssued = FALSE;
  1060. prConnSettings->fgIsDisconnectedByNonRequest = FALSE;
  1061. prConnSettings->ucSSIDLen = 0;
  1062. prConnSettings->eOPMode = NET_TYPE_INFRA;
  1063. prConnSettings->eConnectionPolicy = CONNECT_BY_SSID_BEST_RSSI;
  1064. if (prRegInfo) {
  1065. prConnSettings->ucAdHocChannelNum = (UINT_8) nicFreq2ChannelNum(prRegInfo->u4StartFreq);
  1066. prConnSettings->eAdHocBand = prRegInfo->u4StartFreq < 5000000 ? BAND_2G4 : BAND_5G;
  1067. prConnSettings->eAdHocMode = (ENUM_PARAM_AD_HOC_MODE_T) (prRegInfo->u4AdhocMode);
  1068. }
  1069. prConnSettings->eAuthMode = AUTH_MODE_OPEN;
  1070. prConnSettings->eEncStatus = ENUM_ENCRYPTION_DISABLED;
  1071. prConnSettings->fgIsScanReqIssued = FALSE;
  1072. /* MIB attributes */
  1073. prConnSettings->u2BeaconPeriod = DOT11_BEACON_PERIOD_DEFAULT;
  1074. prConnSettings->u2RTSThreshold = DOT11_RTS_THRESHOLD_DEFAULT;
  1075. prConnSettings->u2DesiredNonHTRateSet = RATE_SET_ALL_ABG;
  1076. /* prConnSettings->u4FreqInKHz; */ /* Center frequency */
  1077. /* Set U-APSD AC */
  1078. prConnSettings->bmfgApsdEnAc = PM_UAPSD_NONE;
  1079. secInit(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1080. /* Features */
  1081. prConnSettings->fgIsEnableRoaming = FALSE;
  1082. #if CFG_SUPPORT_ROAMING
  1083. if (prRegInfo)
  1084. prConnSettings->fgIsEnableRoaming = ((prRegInfo->fgDisRoaming > 0) ? (FALSE) : (TRUE));
  1085. #endif /* CFG_SUPPORT_ROAMING */
  1086. prConnSettings->fgIsAdHocQoSEnable = FALSE;
  1087. prConnSettings->eDesiredPhyConfig = PHY_CONFIG_802_11ABGN;
  1088. /* Set default bandwidth modes */
  1089. prConnSettings->uc2G4BandwidthMode = CONFIG_BW_20M;
  1090. prConnSettings->uc5GBandwidthMode = CONFIG_BW_20_40M;
  1091. prConnSettings->rRsnInfo.ucElemId = 0x30;
  1092. prConnSettings->rRsnInfo.u2Version = 0x0001;
  1093. prConnSettings->rRsnInfo.u4GroupKeyCipherSuite = 0;
  1094. prConnSettings->rRsnInfo.u4PairwiseKeyCipherSuiteCount = 0;
  1095. for (i = 0; i < MAX_NUM_SUPPORTED_CIPHER_SUITES; i++)
  1096. prConnSettings->rRsnInfo.au4PairwiseKeyCipherSuite[i] = 0;
  1097. prConnSettings->rRsnInfo.u4AuthKeyMgtSuiteCount = 0;
  1098. for (i = 0; i < MAX_NUM_SUPPORTED_AKM_SUITES; i++)
  1099. prConnSettings->rRsnInfo.au4AuthKeyMgtSuite[i] = 0;
  1100. prConnSettings->rRsnInfo.u2RsnCap = 0;
  1101. prConnSettings->rRsnInfo.fgRsnCapPresent = FALSE;
  1102. } /* end of aisFsmInitializeConnectionSettings() */
  1103. /*----------------------------------------------------------------------------*/
  1104. /*!
  1105. * @brief the function is used to initialize the value in AIS_FSM_INFO_T for
  1106. * AIS FSM operation
  1107. *
  1108. * @param (none)
  1109. *
  1110. * @return (none)
  1111. */
  1112. /*----------------------------------------------------------------------------*/
  1113. VOID aisFsmInit(IN P_ADAPTER_T prAdapter)
  1114. {
  1115. P_AIS_FSM_INFO_T prAisFsmInfo;
  1116. P_BSS_INFO_T prAisBssInfo;
  1117. P_AIS_SPECIFIC_BSS_INFO_T prAisSpecificBssInfo;
  1118. DEBUGFUNC("aisFsmInit()");
  1119. DBGLOG(SW1, INFO, "->aisFsmInit()\n");
  1120. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1121. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1122. prAisSpecificBssInfo = &(prAdapter->rWifiVar.rAisSpecificBssInfo);
  1123. /* 4 <1> Initiate FSM */
  1124. prAisFsmInfo->ePreviousState = AIS_STATE_IDLE;
  1125. prAisFsmInfo->eCurrentState = AIS_STATE_IDLE;
  1126. prAisFsmInfo->ucAvailableAuthTypes = 0;
  1127. prAisFsmInfo->prTargetBssDesc = (P_BSS_DESC_T) NULL;
  1128. prAisFsmInfo->ucSeqNumOfReqMsg = 0;
  1129. prAisFsmInfo->ucSeqNumOfChReq = 0;
  1130. prAisFsmInfo->ucSeqNumOfScanReq = 0;
  1131. prAisFsmInfo->fgIsInfraChannelFinished = TRUE;
  1132. #if CFG_SUPPORT_ROAMING
  1133. prAisFsmInfo->fgIsRoamingScanPending = FALSE;
  1134. #endif /* CFG_SUPPORT_ROAMING */
  1135. prAisFsmInfo->fgIsChannelRequested = FALSE;
  1136. prAisFsmInfo->fgIsChannelGranted = FALSE;
  1137. /* 4 <1.1> Initiate FSM - Timer INIT */
  1138. cnmTimerInitTimer(prAdapter,
  1139. &prAisFsmInfo->rBGScanTimer,
  1140. (PFN_MGMT_TIMEOUT_FUNC) aisFsmRunEventBGSleepTimeOut, (ULONG) NULL);
  1141. cnmTimerInitTimer(prAdapter,
  1142. &prAisFsmInfo->rIbssAloneTimer,
  1143. (PFN_MGMT_TIMEOUT_FUNC) aisFsmRunEventIbssAloneTimeOut, (ULONG) NULL);
  1144. prAisFsmInfo->u4PostponeIndStartTime = 0;
  1145. cnmTimerInitTimer(prAdapter,
  1146. &prAisFsmInfo->rJoinTimeoutTimer,
  1147. (PFN_MGMT_TIMEOUT_FUNC) aisFsmRunEventJoinTimeout, (ULONG) NULL);
  1148. cnmTimerInitTimer(prAdapter,
  1149. &prAisFsmInfo->rScanDoneTimer,
  1150. (PFN_MGMT_TIMEOUT_FUNC) aisFsmRunEventScanDoneTimeOut, (ULONG) NULL);
  1151. cnmTimerInitTimer(prAdapter,
  1152. &prAisFsmInfo->rChannelTimeoutTimer,
  1153. (PFN_MGMT_TIMEOUT_FUNC) aisFsmRunEventChannelTimeout, (ULONG) NULL);
  1154. cnmTimerInitTimer(prAdapter,
  1155. &prAisFsmInfo->rDeauthDoneTimer,
  1156. (PFN_MGMT_TIMEOUT_FUNC) aisFsmRunEventDeauthTimeout, (ULONG) NULL);
  1157. /* 4 <1.2> Initiate PWR STATE */
  1158. SET_NET_PWR_STATE_IDLE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1159. /* 4 <2> Initiate BSS_INFO_T - common part */
  1160. BSS_INFO_INIT(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1161. COPY_MAC_ADDR(prAisBssInfo->aucOwnMacAddr, prAdapter->rWifiVar.aucMacAddress);
  1162. /* 4 <3> Initiate BSS_INFO_T - private part */
  1163. /* TODO */
  1164. prAisBssInfo->eBand = BAND_2G4;
  1165. prAisBssInfo->ucPrimaryChannel = 1;
  1166. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  1167. /* 4 <4> Allocate MSDU_INFO_T for Beacon */
  1168. prAisBssInfo->prBeacon = cnmMgtPktAlloc(prAdapter,
  1169. OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem[0]) + MAX_IE_LENGTH);
  1170. if (prAisBssInfo->prBeacon) {
  1171. prAisBssInfo->prBeacon->eSrc = TX_PACKET_MGMT;
  1172. prAisBssInfo->prBeacon->ucStaRecIndex = 0xFF; /* NULL STA_REC */
  1173. } else {
  1174. ASSERT(0);
  1175. }
  1176. #if 0
  1177. prAisBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC = PM_UAPSD_ALL;
  1178. prAisBssInfo->rPmProfSetupInfo.ucBmpTriggerAC = PM_UAPSD_ALL;
  1179. prAisBssInfo->rPmProfSetupInfo.ucUapsdSp = WMM_MAX_SP_LENGTH_2;
  1180. #else
  1181. if (prAdapter->u4UapsdAcBmp == 0) {
  1182. prAdapter->u4UapsdAcBmp = CFG_INIT_UAPSD_AC_BMP;
  1183. /* ASSERT(prAdapter->u4UapsdAcBmp); */
  1184. }
  1185. prAisBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC = (UINT_8) prAdapter->u4UapsdAcBmp;
  1186. prAisBssInfo->rPmProfSetupInfo.ucBmpTriggerAC = (UINT_8) prAdapter->u4UapsdAcBmp;
  1187. prAisBssInfo->rPmProfSetupInfo.ucUapsdSp = (UINT_8) prAdapter->u4MaxSpLen;
  1188. #endif
  1189. /* request list initialization */
  1190. LINK_INITIALIZE(&prAisFsmInfo->rPendingReqList);
  1191. /* DBGPRINTF("[2] ucBmpDeliveryAC:0x%x, ucBmpTriggerAC:0x%x, ucUapsdSp:0x%x", */
  1192. /* prAisBssInfo->rPmProfSetupInfo.ucBmpDeliveryAC, */
  1193. /* prAisBssInfo->rPmProfSetupInfo.ucBmpTriggerAC, */
  1194. /* prAisBssInfo->rPmProfSetupInfo.ucUapsdSp); */
  1195. } /* end of aisFsmInit() */
  1196. /*----------------------------------------------------------------------------*/
  1197. /*!
  1198. * @brief the function is used to uninitialize the value in AIS_FSM_INFO_T for
  1199. * AIS FSM operation
  1200. *
  1201. * @param (none)
  1202. *
  1203. * @return (none)
  1204. */
  1205. /*----------------------------------------------------------------------------*/
  1206. VOID aisFsmUninit(IN P_ADAPTER_T prAdapter)
  1207. {
  1208. P_AIS_FSM_INFO_T prAisFsmInfo;
  1209. P_BSS_INFO_T prAisBssInfo;
  1210. P_AIS_SPECIFIC_BSS_INFO_T prAisSpecificBssInfo;
  1211. DEBUGFUNC("aisFsmUninit()");
  1212. DBGLOG(SW1, INFO, "->aisFsmUninit()\n");
  1213. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1214. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1215. prAisSpecificBssInfo = &(prAdapter->rWifiVar.rAisSpecificBssInfo);
  1216. /* 4 <1> Stop all timers */
  1217. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rBGScanTimer);
  1218. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rIbssAloneTimer);
  1219. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rJoinTimeoutTimer);
  1220. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rScanDoneTimer); /* Add by Enlai */
  1221. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer);
  1222. /* 4 <2> flush pending request */
  1223. aisFsmFlushRequest(prAdapter);
  1224. /* 4 <3> Reset driver-domain BSS-INFO */
  1225. if (prAisBssInfo->prBeacon) {
  1226. cnmMgtPktFree(prAdapter, prAisBssInfo->prBeacon);
  1227. prAisBssInfo->prBeacon = NULL;
  1228. }
  1229. #if CFG_SUPPORT_802_11W
  1230. rsnStopSaQuery(prAdapter);
  1231. #endif
  1232. } /* end of aisFsmUninit() */
  1233. /*----------------------------------------------------------------------------*/
  1234. /*!
  1235. * @brief Initialization of JOIN STATE
  1236. *
  1237. * @param[in] prBssDesc The pointer of BSS_DESC_T which is the BSS we will try to join with.
  1238. *
  1239. * @return (none)
  1240. */
  1241. /*----------------------------------------------------------------------------*/
  1242. VOID aisFsmStateInit_JOIN(IN P_ADAPTER_T prAdapter, P_BSS_DESC_T prBssDesc)
  1243. {
  1244. P_AIS_FSM_INFO_T prAisFsmInfo;
  1245. P_BSS_INFO_T prAisBssInfo;
  1246. P_AIS_SPECIFIC_BSS_INFO_T prAisSpecificBssInfo;
  1247. P_CONNECTION_SETTINGS_T prConnSettings;
  1248. P_STA_RECORD_T prStaRec;
  1249. P_MSG_JOIN_REQ_T prJoinReqMsg;
  1250. DEBUGFUNC("aisFsmStateInit_JOIN()");
  1251. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1252. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1253. prAisSpecificBssInfo = &(prAdapter->rWifiVar.rAisSpecificBssInfo);
  1254. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  1255. ASSERT(prBssDesc);
  1256. /* 4 <1> We are going to connect to this BSS. */
  1257. prBssDesc->fgIsConnecting = TRUE;
  1258. /* 4 <2> Setup corresponding STA_RECORD_T */
  1259. prStaRec = bssCreateStaRecFromBssDesc(prAdapter, STA_TYPE_LEGACY_AP, NETWORK_TYPE_AIS_INDEX, prBssDesc);
  1260. if (prStaRec == NULL) {
  1261. DBGLOG(AIS, WARN, "Create station record fail\n");
  1262. return;
  1263. }
  1264. prAisFsmInfo->prTargetStaRec = prStaRec;
  1265. /* 4 <2.1> sync. to firmware domain */
  1266. if (prStaRec->ucStaState == STA_STATE_1)
  1267. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
  1268. /* 4 <3> Update ucAvailableAuthTypes which we can choice during SAA */
  1269. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
  1270. prStaRec->fgIsReAssoc = FALSE;
  1271. switch (prConnSettings->eAuthMode) {
  1272. case AUTH_MODE_OPEN: /* Note: Omit break here. */
  1273. case AUTH_MODE_WPA:
  1274. case AUTH_MODE_WPA_PSK:
  1275. case AUTH_MODE_WPA2:
  1276. case AUTH_MODE_WPA2_PSK:
  1277. prAisFsmInfo->ucAvailableAuthTypes = (UINT_8) AUTH_TYPE_OPEN_SYSTEM;
  1278. break;
  1279. case AUTH_MODE_SHARED:
  1280. prAisFsmInfo->ucAvailableAuthTypes = (UINT_8) AUTH_TYPE_SHARED_KEY;
  1281. break;
  1282. case AUTH_MODE_AUTO_SWITCH:
  1283. DBGLOG(AIS, LOUD, "JOIN INIT: eAuthMode == AUTH_MODE_AUTO_SWITCH\n");
  1284. prAisFsmInfo->ucAvailableAuthTypes = (UINT_8) (AUTH_TYPE_OPEN_SYSTEM | AUTH_TYPE_SHARED_KEY);
  1285. break;
  1286. default:
  1287. ASSERT(!(prConnSettings->eAuthMode == AUTH_MODE_WPA_NONE));
  1288. DBGLOG(AIS, ERROR, "JOIN INIT: Auth Algorithm : %d was not supported by JOIN\n",
  1289. prConnSettings->eAuthMode);
  1290. /* TODO(Kevin): error handling ? */
  1291. return;
  1292. }
  1293. /* TODO(tyhsu): Assume that Roaming Auth Type is equal to ConnSettings eAuthMode */
  1294. prAisSpecificBssInfo->ucRoamingAuthTypes = prAisFsmInfo->ucAvailableAuthTypes;
  1295. prStaRec->ucTxAuthAssocRetryLimit = TX_AUTH_ASSOCI_RETRY_LIMIT;
  1296. } else {
  1297. ASSERT(prBssDesc->eBSSType == BSS_TYPE_INFRASTRUCTURE);
  1298. ASSERT(!prBssDesc->fgIsConnected);
  1299. DBGLOG(AIS, LOUD, "JOIN INIT: AUTH TYPE = %d for Roaming\n",
  1300. prAisSpecificBssInfo->ucRoamingAuthTypes);
  1301. prStaRec->fgIsReAssoc = TRUE; /* We do roaming while the medium is connected */
  1302. /* TODO(Kevin): We may call a sub function to acquire the Roaming Auth Type */
  1303. prAisFsmInfo->ucAvailableAuthTypes = prAisSpecificBssInfo->ucRoamingAuthTypes;
  1304. prStaRec->ucTxAuthAssocRetryLimit = TX_AUTH_ASSOCI_RETRY_LIMIT_FOR_ROAMING;
  1305. }
  1306. /* 4 <4> Use an appropriate Authentication Algorithm Number among the ucAvailableAuthTypes */
  1307. if (prAisFsmInfo->ucAvailableAuthTypes & (UINT_8) AUTH_TYPE_OPEN_SYSTEM) {
  1308. DBGLOG(AIS, LOUD, "JOIN INIT: Try to do Authentication with AuthType == OPEN_SYSTEM.\n");
  1309. prAisFsmInfo->ucAvailableAuthTypes &= ~(UINT_8) AUTH_TYPE_OPEN_SYSTEM;
  1310. prStaRec->ucAuthAlgNum = (UINT_8) AUTH_ALGORITHM_NUM_OPEN_SYSTEM;
  1311. } else if (prAisFsmInfo->ucAvailableAuthTypes & (UINT_8) AUTH_TYPE_SHARED_KEY) {
  1312. DBGLOG(AIS, LOUD, "JOIN INIT: Try to do Authentication with AuthType == SHARED_KEY.\n");
  1313. prAisFsmInfo->ucAvailableAuthTypes &= ~(UINT_8) AUTH_TYPE_SHARED_KEY;
  1314. prStaRec->ucAuthAlgNum = (UINT_8) AUTH_ALGORITHM_NUM_SHARED_KEY;
  1315. } else if (prAisFsmInfo->ucAvailableAuthTypes & (UINT_8) AUTH_TYPE_FAST_BSS_TRANSITION) {
  1316. DBGLOG(AIS, LOUD, "JOIN INIT: Try to do Authentication with AuthType == FAST_BSS_TRANSITION.\n");
  1317. prAisFsmInfo->ucAvailableAuthTypes &= ~(UINT_8) AUTH_TYPE_FAST_BSS_TRANSITION;
  1318. prStaRec->ucAuthAlgNum = (UINT_8) AUTH_ALGORITHM_NUM_FAST_BSS_TRANSITION;
  1319. } else {
  1320. ASSERT(0);
  1321. }
  1322. /* 4 <5> Overwrite Connection Setting for eConnectionPolicy == ANY (Used by Assoc Req) */
  1323. if (prBssDesc->ucSSIDLen)
  1324. COPY_SSID(prConnSettings->aucSSID, prConnSettings->ucSSIDLen, prBssDesc->aucSSID, prBssDesc->ucSSIDLen);
  1325. /* 4 <6> Send a Msg to trigger SAA to start JOIN process. */
  1326. prJoinReqMsg = (P_MSG_JOIN_REQ_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_JOIN_REQ_T));
  1327. if (!prJoinReqMsg) {
  1328. ASSERT(0); /* Can't trigger SAA FSM */
  1329. return;
  1330. }
  1331. prJoinReqMsg->rMsgHdr.eMsgId = MID_AIS_SAA_FSM_START;
  1332. prJoinReqMsg->ucSeqNum = ++prAisFsmInfo->ucSeqNumOfReqMsg;
  1333. prJoinReqMsg->prStaRec = prStaRec;
  1334. if (1) {
  1335. int j;
  1336. P_FRAG_INFO_T prFragInfo;
  1337. for (j = 0; j < MAX_NUM_CONCURRENT_FRAGMENTED_MSDUS; j++) {
  1338. prFragInfo = &prStaRec->rFragInfo[j];
  1339. if (prFragInfo->pr1stFrag) {
  1340. /* nicRxReturnRFB(prAdapter, prFragInfo->pr1stFrag); */
  1341. prFragInfo->pr1stFrag = (P_SW_RFB_T) NULL;
  1342. }
  1343. }
  1344. }
  1345. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prJoinReqMsg, MSG_SEND_METHOD_BUF);
  1346. } /* end of aisFsmInit_JOIN() */
  1347. /*----------------------------------------------------------------------------*/
  1348. /*!
  1349. * @brief Retry JOIN for AUTH_MODE_AUTO_SWITCH
  1350. *
  1351. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1352. *
  1353. * @retval TRUE We will retry JOIN
  1354. * @retval FALSE We will not retry JOIN
  1355. */
  1356. /*----------------------------------------------------------------------------*/
  1357. BOOLEAN aisFsmStateInit_RetryJOIN(IN P_ADAPTER_T prAdapter, P_STA_RECORD_T prStaRec)
  1358. {
  1359. P_AIS_FSM_INFO_T prAisFsmInfo;
  1360. P_MSG_JOIN_REQ_T prJoinReqMsg;
  1361. DEBUGFUNC("aisFsmStateInit_RetryJOIN()");
  1362. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1363. /* Retry other AuthType if possible */
  1364. if (!prAisFsmInfo->ucAvailableAuthTypes)
  1365. return FALSE;
  1366. if (prAisFsmInfo->ucAvailableAuthTypes & (UINT_8) AUTH_TYPE_SHARED_KEY) {
  1367. DBGLOG(AIS, INFO, "RETRY JOIN INIT: Retry Authentication with AuthType == SHARED_KEY.\n");
  1368. prAisFsmInfo->ucAvailableAuthTypes &= ~(UINT_8) AUTH_TYPE_SHARED_KEY;
  1369. prStaRec->ucAuthAlgNum = (UINT_8) AUTH_ALGORITHM_NUM_SHARED_KEY;
  1370. } else {
  1371. DBGLOG(AIS, ERROR, "RETRY JOIN INIT: Retry Authentication with Unexpected AuthType.\n");
  1372. ASSERT(0);
  1373. }
  1374. prAisFsmInfo->ucAvailableAuthTypes = 0; /* No more available Auth Types */
  1375. /* Trigger SAA to start JOIN process. */
  1376. prJoinReqMsg = (P_MSG_JOIN_REQ_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_JOIN_REQ_T));
  1377. if (!prJoinReqMsg) {
  1378. ASSERT(0); /* Can't trigger SAA FSM */
  1379. return FALSE;
  1380. }
  1381. prJoinReqMsg->rMsgHdr.eMsgId = MID_AIS_SAA_FSM_START;
  1382. prJoinReqMsg->ucSeqNum = ++prAisFsmInfo->ucSeqNumOfReqMsg;
  1383. prJoinReqMsg->prStaRec = prStaRec;
  1384. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prJoinReqMsg, MSG_SEND_METHOD_BUF);
  1385. return TRUE;
  1386. } /* end of aisFsmRetryJOIN() */
  1387. #if CFG_SUPPORT_ADHOC
  1388. /*----------------------------------------------------------------------------*/
  1389. /*!
  1390. * @brief State Initialization of AIS_STATE_IBSS_ALONE
  1391. *
  1392. * @param (none)
  1393. *
  1394. * @return (none)
  1395. */
  1396. /*----------------------------------------------------------------------------*/
  1397. VOID aisFsmStateInit_IBSS_ALONE(IN P_ADAPTER_T prAdapter)
  1398. {
  1399. P_AIS_FSM_INFO_T prAisFsmInfo;
  1400. P_CONNECTION_SETTINGS_T prConnSettings;
  1401. P_BSS_INFO_T prAisBssInfo;
  1402. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1403. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  1404. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1405. /* 4 <1> Check if IBSS was created before ? */
  1406. if (prAisBssInfo->fgIsBeaconActivated) {
  1407. /* 4 <2> Start IBSS Alone Timer for periodic SCAN and then SEARCH */
  1408. #if !CFG_SLT_SUPPORT
  1409. cnmTimerStartTimer(prAdapter, &prAisFsmInfo->rIbssAloneTimer, SEC_TO_MSEC(AIS_IBSS_ALONE_TIMEOUT_SEC));
  1410. #endif
  1411. }
  1412. aisFsmCreateIBSS(prAdapter);
  1413. } /* end of aisFsmStateInit_IBSS_ALONE() */
  1414. /*----------------------------------------------------------------------------*/
  1415. /*!
  1416. * @brief State Initialization of AIS_STATE_IBSS_MERGE
  1417. *
  1418. * @param[in] prBssDesc The pointer of BSS_DESC_T which is the IBSS we will try to merge with.
  1419. *
  1420. * @return (none)
  1421. */
  1422. /*----------------------------------------------------------------------------*/
  1423. VOID aisFsmStateInit_IBSS_MERGE(IN P_ADAPTER_T prAdapter, P_BSS_DESC_T prBssDesc)
  1424. {
  1425. P_AIS_FSM_INFO_T prAisFsmInfo;
  1426. P_CONNECTION_SETTINGS_T prConnSettings;
  1427. P_BSS_INFO_T prAisBssInfo;
  1428. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  1429. ASSERT(prBssDesc);
  1430. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1431. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  1432. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1433. /* 4 <1> We will merge with to this BSS immediately. */
  1434. prBssDesc->fgIsConnecting = FALSE;
  1435. prBssDesc->fgIsConnected = TRUE;
  1436. /* 4 <2> Setup corresponding STA_RECORD_T */
  1437. prStaRec = bssCreateStaRecFromBssDesc(prAdapter, STA_TYPE_ADHOC_PEER, NETWORK_TYPE_AIS_INDEX, prBssDesc);
  1438. if (prStaRec == NULL) {
  1439. DBGLOG(AIS, WARN, "Create station record fail\n");
  1440. return;
  1441. }
  1442. prStaRec->fgIsMerging = TRUE;
  1443. prAisFsmInfo->prTargetStaRec = prStaRec;
  1444. /* 4 <2.1> sync. to firmware domain */
  1445. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
  1446. /* 4 <3> IBSS-Merge */
  1447. aisFsmMergeIBSS(prAdapter, prStaRec);
  1448. } /* end of aisFsmStateInit_IBSS_MERGE() */
  1449. #endif /* CFG_SUPPORT_ADHOC */
  1450. /*----------------------------------------------------------------------------*/
  1451. /*!
  1452. * @brief Process of JOIN Abort
  1453. *
  1454. * @param (none)
  1455. *
  1456. * @return (none)
  1457. */
  1458. /*----------------------------------------------------------------------------*/
  1459. VOID aisFsmStateAbort_JOIN(IN P_ADAPTER_T prAdapter)
  1460. {
  1461. P_AIS_FSM_INFO_T prAisFsmInfo;
  1462. P_MSG_JOIN_ABORT_T prJoinAbortMsg;
  1463. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1464. /* 1. Abort JOIN process */
  1465. prJoinAbortMsg = (P_MSG_JOIN_ABORT_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_JOIN_ABORT_T));
  1466. if (!prJoinAbortMsg) {
  1467. ASSERT(0); /* Can't abort SAA FSM */
  1468. return;
  1469. }
  1470. prJoinAbortMsg->rMsgHdr.eMsgId = MID_AIS_SAA_FSM_ABORT;
  1471. prJoinAbortMsg->ucSeqNum = prAisFsmInfo->ucSeqNumOfReqMsg;
  1472. prJoinAbortMsg->prStaRec = prAisFsmInfo->prTargetStaRec;
  1473. scanRemoveConnFlagOfBssDescByBssid(prAdapter, prAisFsmInfo->prTargetStaRec->aucMacAddr);
  1474. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prJoinAbortMsg, MSG_SEND_METHOD_BUF);
  1475. /* 2. Return channel privilege */
  1476. aisFsmReleaseCh(prAdapter);
  1477. /* 3.1 stop join timeout timer */
  1478. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rJoinTimeoutTimer);
  1479. /* 3.2 reset local variable */
  1480. prAisFsmInfo->fgIsInfraChannelFinished = TRUE;
  1481. prAdapter->rWifiVar.rConnSettings.fgIsConnReqIssued = FALSE;
  1482. } /* end of aisFsmAbortJOIN() */
  1483. /*----------------------------------------------------------------------------*/
  1484. /*!
  1485. * @brief Process of SCAN Abort
  1486. *
  1487. * @param (none)
  1488. *
  1489. * @return (none)
  1490. */
  1491. /*----------------------------------------------------------------------------*/
  1492. VOID aisFsmStateAbort_SCAN(IN P_ADAPTER_T prAdapter)
  1493. {
  1494. P_AIS_FSM_INFO_T prAisFsmInfo;
  1495. P_MSG_SCN_SCAN_CANCEL prScanCancelMsg;
  1496. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1497. /* Abort JOIN process. */
  1498. prScanCancelMsg = (P_MSG_SCN_SCAN_CANCEL) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_SCN_SCAN_CANCEL));
  1499. if (!prScanCancelMsg) {
  1500. ASSERT(0); /* Can't abort SCN FSM */
  1501. return;
  1502. }
  1503. prScanCancelMsg->rMsgHdr.eMsgId = MID_AIS_SCN_SCAN_CANCEL;
  1504. prScanCancelMsg->ucSeqNum = prAisFsmInfo->ucSeqNumOfScanReq;
  1505. prScanCancelMsg->ucNetTypeIndex = (UINT_8) NETWORK_TYPE_AIS_INDEX;
  1506. #if CFG_ENABLE_WIFI_DIRECT
  1507. if (prAdapter->fgIsP2PRegistered)
  1508. prScanCancelMsg->fgIsChannelExt = FALSE;
  1509. #endif
  1510. /* unbuffered message to guarantee scan is cancelled in sequence */
  1511. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prScanCancelMsg, MSG_SEND_METHOD_UNBUF);
  1512. } /* end of aisFsmAbortSCAN() */
  1513. /*----------------------------------------------------------------------------*/
  1514. /*!
  1515. * @brief Process of NORMAL_TR Abort
  1516. *
  1517. * @param (none)
  1518. *
  1519. * @return (none)
  1520. */
  1521. /*----------------------------------------------------------------------------*/
  1522. VOID aisFsmStateAbort_NORMAL_TR(IN P_ADAPTER_T prAdapter)
  1523. {
  1524. P_AIS_FSM_INFO_T prAisFsmInfo;
  1525. ASSERT(prAdapter);
  1526. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1527. DBGLOG(AIS, TRACE, "aisFsmStateAbort_NORMAL_TR\n");
  1528. /* TODO(Kevin): Do abort other MGMT func */
  1529. /* 1. Release channel to CNM */
  1530. aisFsmReleaseCh(prAdapter);
  1531. /* 2.1 stop join timeout timer */
  1532. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rJoinTimeoutTimer);
  1533. /* 2.2 reset local variable */
  1534. prAisFsmInfo->fgIsInfraChannelFinished = TRUE;
  1535. } /* end of aisFsmAbortNORMAL_TR() */
  1536. #if CFG_SUPPORT_ADHOC
  1537. /*----------------------------------------------------------------------------*/
  1538. /*!
  1539. * @brief Process of NORMAL_TR Abort
  1540. *
  1541. * @param (none)
  1542. *
  1543. * @return (none)
  1544. */
  1545. /*----------------------------------------------------------------------------*/
  1546. VOID aisFsmStateAbort_IBSS(IN P_ADAPTER_T prAdapter)
  1547. {
  1548. P_AIS_FSM_INFO_T prAisFsmInfo;
  1549. P_BSS_DESC_T prBssDesc;
  1550. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1551. /* reset BSS-DESC */
  1552. if (prAisFsmInfo->prTargetStaRec) {
  1553. prBssDesc = scanSearchBssDescByTA(prAdapter, prAisFsmInfo->prTargetStaRec->aucMacAddr);
  1554. if (prBssDesc) {
  1555. prBssDesc->fgIsConnected = FALSE;
  1556. prBssDesc->fgIsConnecting = FALSE;
  1557. }
  1558. }
  1559. /* release channel privilege */
  1560. aisFsmReleaseCh(prAdapter);
  1561. }
  1562. #endif /* CFG_SUPPORT_ADHOC */
  1563. /*----------------------------------------------------------------------------*/
  1564. /*!
  1565. * @brief The Core FSM engine of AIS(Ad-hoc, Infra STA)
  1566. *
  1567. * @param[in] eNextState Enum value of next AIS STATE
  1568. *
  1569. * @return (none)
  1570. */
  1571. /*----------------------------------------------------------------------------*/
  1572. VOID aisFsmSteps(IN P_ADAPTER_T prAdapter, ENUM_AIS_STATE_T eNextState)
  1573. {
  1574. P_AIS_FSM_INFO_T prAisFsmInfo;
  1575. P_BSS_INFO_T prAisBssInfo;
  1576. P_CONNECTION_SETTINGS_T prConnSettings;
  1577. P_BSS_DESC_T prBssDesc;
  1578. P_MSG_CH_REQ_T prMsgChReq;
  1579. P_MSG_SCN_SCAN_REQ prScanReqMsg;
  1580. P_AIS_REQ_HDR_T prAisReq;
  1581. ENUM_BAND_T eBand;
  1582. UINT_8 ucChannel;
  1583. UINT_16 u2ScanIELen;
  1584. ENUM_AIS_STATE_T eOriPreState;
  1585. BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
  1586. DEBUGFUNC("aisFsmSteps()");
  1587. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  1588. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1589. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  1590. eOriPreState = prAisFsmInfo->ePreviousState;
  1591. do {
  1592. /* Do entering Next State */
  1593. prAisFsmInfo->ePreviousState = prAisFsmInfo->eCurrentState;
  1594. #if DBG
  1595. DBGLOG(AIS, STATE, "TRANSITION: [%s] -> [%s]\n",
  1596. apucDebugAisState[prAisFsmInfo->eCurrentState], apucDebugAisState[eNextState]);
  1597. #else
  1598. DBGLOG(AIS, STATE, "[%d] TRANSITION: [%d] -> [%d]\n",
  1599. DBG_AIS_IDX, prAisFsmInfo->eCurrentState, eNextState);
  1600. #endif
  1601. /* NOTE(Kevin): This is the only place to change the eCurrentState(except initial) */
  1602. prAisFsmInfo->eCurrentState = eNextState;
  1603. fgIsTransition = (BOOLEAN) FALSE;
  1604. aisPostponedEventOfDisconnTimeout(prAdapter, prAisFsmInfo);
  1605. /* Do tasks of the State that we just entered */
  1606. switch (prAisFsmInfo->eCurrentState) {
  1607. /* NOTE(Kevin): we don't have to rearrange the sequence of following
  1608. * switch case. Instead I would like to use a common lookup table of array
  1609. * of function pointer to speed up state search.
  1610. */
  1611. case AIS_STATE_IDLE:
  1612. prAisReq = aisFsmGetNextRequest(prAdapter);
  1613. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rScanDoneTimer);
  1614. if (prAisReq == NULL || prAisReq->eReqType == AIS_REQUEST_RECONNECT) {
  1615. if (prConnSettings->fgIsConnReqIssued == TRUE &&
  1616. prConnSettings->fgIsDisconnectedByNonRequest == FALSE) {
  1617. prAisFsmInfo->fgTryScan = TRUE;
  1618. SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1619. SET_NET_PWR_STATE_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1620. /* sync with firmware */
  1621. nicActivateNetwork(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1622. /* reset trial count */
  1623. prAisFsmInfo->ucConnTrialCount = 0;
  1624. eNextState = AIS_STATE_SEARCH;
  1625. fgIsTransition = TRUE;
  1626. } else {
  1627. UNSET_NET_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1628. SET_NET_PWR_STATE_IDLE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1629. /* sync with firmware */
  1630. nicDeactivateNetwork(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1631. /* check for other pending request */
  1632. if (prAisReq &&
  1633. (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, TRUE) == TRUE)) {
  1634. wlanClearScanningResult(prAdapter);
  1635. eNextState = AIS_STATE_SCAN;
  1636. fgIsTransition = TRUE;
  1637. }
  1638. }
  1639. if (prAisReq) {
  1640. /* free the message */
  1641. cnmMemFree(prAdapter, prAisReq);
  1642. }
  1643. } else if (prAisReq->eReqType == AIS_REQUEST_SCAN) {
  1644. #if CFG_SUPPORT_ROAMING
  1645. prAisFsmInfo->fgIsRoamingScanPending = FALSE;
  1646. #endif /* CFG_SUPPORT_ROAMING */
  1647. wlanClearScanningResult(prAdapter);
  1648. eNextState = AIS_STATE_SCAN;
  1649. fgIsTransition = TRUE;
  1650. /* free the message */
  1651. cnmMemFree(prAdapter, prAisReq);
  1652. } else if (prAisReq->eReqType == AIS_REQUEST_ROAMING_CONNECT
  1653. || prAisReq->eReqType == AIS_REQUEST_ROAMING_SEARCH) {
  1654. /* ignore */
  1655. /* free the message */
  1656. cnmMemFree(prAdapter, prAisReq);
  1657. } else if (prAisReq->eReqType == AIS_REQUEST_REMAIN_ON_CHANNEL) {
  1658. eNextState = AIS_STATE_REQ_REMAIN_ON_CHANNEL;
  1659. fgIsTransition = TRUE;
  1660. /* free the message */
  1661. cnmMemFree(prAdapter, prAisReq);
  1662. }
  1663. prAisFsmInfo->u4SleepInterval = AIS_BG_SCAN_INTERVAL_MIN_SEC;
  1664. break;
  1665. case AIS_STATE_SEARCH:
  1666. /* 4 <1> Search for a matched candidate and save it to prTargetBssDesc. */
  1667. #if CFG_SLT_SUPPORT
  1668. prBssDesc = prAdapter->rWifiVar.rSltInfo.prPseudoBssDesc;
  1669. #else
  1670. prBssDesc = scanSearchBssDescByPolicy(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1671. #endif
  1672. /* every time BSS join failure count is integral multiples of SCN_BSS_JOIN_FAIL_THRESOLD,
  1673. we need to scan again to find if a new BSS is here in the ESS,
  1674. this can also avoid too frequency to retry the rejected AP */
  1675. if (prAisFsmInfo->ePreviousState == AIS_STATE_LOOKING_FOR ||
  1676. ((eOriPreState == AIS_STATE_ONLINE_SCAN ||
  1677. eOriPreState == AIS_STATE_SCAN) && prAisFsmInfo->ePreviousState != eOriPreState)) {
  1678. /* if previous state is scan/online scan/looking for, don't try to scan again */
  1679. } else if (prBssDesc && prBssDesc->ucJoinFailureCount >= SCN_BSS_JOIN_FAIL_THRESOLD &&
  1680. ((prBssDesc->ucJoinFailureCount - SCN_BSS_JOIN_FAIL_THRESOLD) %
  1681. SCN_BSS_JOIN_FAIL_THRESOLD) == 0)
  1682. prBssDesc = NULL;
  1683. /* we are under Roaming Condition. */
  1684. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  1685. if (prAisFsmInfo->ucConnTrialCount > AIS_ROAMING_CONNECTION_TRIAL_LIMIT) {
  1686. #if CFG_SUPPORT_ROAMING
  1687. roamingFsmRunEventFail(prAdapter, ROAMING_FAIL_REASON_CONNLIMIT);
  1688. #endif /* CFG_SUPPORT_ROAMING */
  1689. /* reset retry count */
  1690. prAisFsmInfo->ucConnTrialCount = 0;
  1691. /* abort connection trial */
  1692. if (prConnSettings->eReConnectLevel < RECONNECT_LEVEL_BEACON_TIMEOUT) {
  1693. prConnSettings->eReConnectLevel = RECONNECT_LEVEL_ROAMING_FAIL;
  1694. prConnSettings->fgIsConnReqIssued = FALSE;
  1695. } else {
  1696. DBGLOG(AIS, INFO,
  1697. "Do not set fgIsConnReqIssued, Level is %d\n",
  1698. prConnSettings->eReConnectLevel);
  1699. }
  1700. eNextState = AIS_STATE_NORMAL_TR;
  1701. fgIsTransition = TRUE;
  1702. break;
  1703. }
  1704. }
  1705. /* 4 <2> We are not under Roaming Condition. */
  1706. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
  1707. /* 4 <2.a> If we have the matched one */
  1708. if (prBssDesc) {
  1709. /* 4 <A> Stored the Selected BSS security cipher.
  1710. For later asoc req compose IE */
  1711. prAisBssInfo->u4RsnSelectedGroupCipher = prBssDesc->u4RsnSelectedGroupCipher;
  1712. prAisBssInfo->u4RsnSelectedPairwiseCipher =
  1713. prBssDesc->u4RsnSelectedPairwiseCipher;
  1714. prAisBssInfo->u4RsnSelectedAKMSuite = prBssDesc->u4RsnSelectedAKMSuite;
  1715. /* 4 <B> Do STATE transition and update current Operation Mode. */
  1716. if (prBssDesc->eBSSType == BSS_TYPE_INFRASTRUCTURE) {
  1717. prAisBssInfo->eCurrentOPMode = OP_MODE_INFRASTRUCTURE;
  1718. /* Record the target BSS_DESC_T for next STATE. */
  1719. prAisFsmInfo->prTargetBssDesc = prBssDesc;
  1720. /* Transit to channel acquire */
  1721. eNextState = AIS_STATE_REQ_CHANNEL_JOIN;
  1722. fgIsTransition = TRUE;
  1723. /* increase connection trial count */
  1724. prAisFsmInfo->ucConnTrialCount++;
  1725. }
  1726. #if CFG_SUPPORT_ADHOC
  1727. else if (prBssDesc->eBSSType == BSS_TYPE_IBSS) {
  1728. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  1729. /* Record the target BSS_DESC_T for next STATE. */
  1730. prAisFsmInfo->prTargetBssDesc = prBssDesc;
  1731. eNextState = AIS_STATE_IBSS_MERGE;
  1732. fgIsTransition = TRUE;
  1733. }
  1734. #endif /* CFG_SUPPORT_ADHOC */
  1735. else {
  1736. ASSERT(0);
  1737. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  1738. fgIsTransition = TRUE;
  1739. }
  1740. }
  1741. /* 4 <2.b> If we don't have the matched one */
  1742. else {
  1743. /* increase connection trial count for infrastructure connection */
  1744. if (prConnSettings->eOPMode == NET_TYPE_INFRA)
  1745. prAisFsmInfo->ucConnTrialCount++;
  1746. /* Join req timeout means Bss had lost and no need to looking for */
  1747. if (prAisFsmInfo->rJoinReqTime != 0 &&
  1748. CHECK_FOR_TIMEOUT(kalGetTimeTick(),
  1749. prAisFsmInfo->rJoinReqTime,
  1750. SEC_TO_SYSTIME(AIS_JOIN_TIMEOUT))) {
  1751. UINT_16 u2StaTusCode = STATUS_CODE_JOIN_TIMEOUT;
  1752. prConnSettings->fgIsDisconnectedByNonRequest = TRUE;
  1753. eNextState = AIS_STATE_IDLE;
  1754. fgIsTransition = TRUE;
  1755. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  1756. WLAN_STATUS_JOIN_FAILURE,
  1757. (PVOID)&u2StaTusCode, sizeof(u2StaTusCode));
  1758. break;
  1759. }
  1760. /* 4 <A> Try to SCAN */
  1761. if (prAisFsmInfo->fgTryScan) {
  1762. eNextState = AIS_STATE_LOOKING_FOR;
  1763. fgIsTransition = TRUE;
  1764. break;
  1765. }
  1766. /* 4 <B> We've do SCAN already, now wait in some STATE. */
  1767. if (prConnSettings->eOPMode == NET_TYPE_INFRA) {
  1768. /* issue reconnect request,
  1769. * and retreat to idle state for scheduling */
  1770. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  1771. eNextState = AIS_STATE_IDLE;
  1772. fgIsTransition = TRUE;
  1773. }
  1774. #if CFG_SUPPORT_ADHOC
  1775. else if ((prConnSettings->eOPMode == NET_TYPE_IBSS)
  1776. || (prConnSettings->eOPMode == NET_TYPE_AUTO_SWITCH)
  1777. || (prConnSettings->eOPMode == NET_TYPE_DEDICATED_IBSS)) {
  1778. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  1779. prAisFsmInfo->prTargetBssDesc = NULL;
  1780. eNextState = AIS_STATE_IBSS_ALONE;
  1781. fgIsTransition = TRUE;
  1782. }
  1783. #endif /* CFG_SUPPORT_ADHOC */
  1784. else {
  1785. ASSERT(0);
  1786. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  1787. fgIsTransition = TRUE;
  1788. }
  1789. }
  1790. }
  1791. /* 4 <3> We are under Roaming Condition. */
  1792. else { /* prAdapter->eConnectionState == MEDIA_STATE_CONNECTED. */
  1793. /* 4 <3.a> This BSS_DESC_T is our AP. */
  1794. /* NOTE(Kevin 2008/05/16): Following cases will go back to NORMAL_TR.
  1795. * CASE I: During Roaming, APP(WZC/NDISTEST) change the connection
  1796. * settings. That make we can NOT match the original AP, so the
  1797. * prBssDesc is NULL.
  1798. * CASE II: The same reason as CASE I. Because APP change the
  1799. * eOPMode to other network type in connection setting
  1800. * (e.g. NET_TYPE_IBSS), so the BssDesc become the IBSS node.
  1801. * (For CASE I/II, before WZC/NDISTEST set the OID_SSID, it will change
  1802. * other parameters in connection setting first. So if we do roaming
  1803. * at the same time, it will hit these cases.)
  1804. *
  1805. * CASE III: Normal case, we can't find other candidate to roam
  1806. * out, so only the current AP will be matched.
  1807. *
  1808. * CASE IV: Timestamp of the current AP might be reset
  1809. */
  1810. if (prAisBssInfo->ucReasonOfDisconnect != DISCONNECT_REASON_CODE_REASSOCIATION &&
  1811. ((!prBssDesc) || /* CASE I */
  1812. (prBssDesc->eBSSType != BSS_TYPE_INFRASTRUCTURE) || /* CASE II */
  1813. (prBssDesc->fgIsConnected) || /* CASE III */
  1814. (EQUAL_MAC_ADDR(prBssDesc->aucBSSID, prAisBssInfo->aucBSSID))) /* CASE IV */) {
  1815. #if DBG
  1816. if ((prBssDesc) && (prBssDesc->fgIsConnected))
  1817. ASSERT(EQUAL_MAC_ADDR(prBssDesc->aucBSSID, prAisBssInfo->aucBSSID));
  1818. #endif /* DBG */
  1819. /* We already associated with it, go back to NORMAL_TR */
  1820. /* TODO(Kevin): Roaming Fail */
  1821. #if CFG_SUPPORT_ROAMING
  1822. roamingFsmRunEventFail(prAdapter, ROAMING_FAIL_REASON_NOCANDIDATE);
  1823. #endif /* CFG_SUPPORT_ROAMING */
  1824. /* Retreat to NORMAL_TR state */
  1825. eNextState = AIS_STATE_NORMAL_TR;
  1826. fgIsTransition = TRUE;
  1827. break;
  1828. }
  1829. /* 4 <3.b> Try to roam out for JOIN this BSS_DESC_T. */
  1830. if (prBssDesc == NULL) {
  1831. /* increase connection trial count for infrastructure connection */
  1832. if (prConnSettings->eOPMode == NET_TYPE_INFRA)
  1833. prAisFsmInfo->ucConnTrialCount++;
  1834. /* 4 <A> Try to SCAN */
  1835. if (prAisFsmInfo->fgTryScan) {
  1836. eNextState = AIS_STATE_LOOKING_FOR;
  1837. fgIsTransition = TRUE;
  1838. break;
  1839. }
  1840. /* 4 <B> We've do SCAN already, now wait in some STATE. */
  1841. if (prConnSettings->eOPMode == NET_TYPE_INFRA) {
  1842. /* issue reconnect request, and retreat to idle state
  1843. * for scheduling */
  1844. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  1845. eNextState = AIS_STATE_IDLE;
  1846. fgIsTransition = TRUE;
  1847. }
  1848. #if CFG_SUPPORT_ADHOC
  1849. else if ((prConnSettings->eOPMode == NET_TYPE_IBSS)
  1850. || (prConnSettings->eOPMode == NET_TYPE_AUTO_SWITCH)
  1851. || (prConnSettings->eOPMode ==
  1852. NET_TYPE_DEDICATED_IBSS)) {
  1853. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  1854. prAisFsmInfo->prTargetBssDesc = NULL;
  1855. eNextState = AIS_STATE_IBSS_ALONE;
  1856. fgIsTransition = TRUE;
  1857. }
  1858. #endif /* CFG_SUPPORT_ADHOC */
  1859. else {
  1860. ASSERT(0);
  1861. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  1862. fgIsTransition = TRUE;
  1863. }
  1864. } else {
  1865. #if DBG
  1866. if (prAisBssInfo->ucReasonOfDisconnect !=
  1867. DISCONNECT_REASON_CODE_REASSOCIATION) {
  1868. ASSERT(UNEQUAL_MAC_ADDR
  1869. (prBssDesc->aucBSSID, prAisBssInfo->aucBSSID));
  1870. }
  1871. #endif /* DBG */
  1872. /* 4 <A> Record the target BSS_DESC_T for next STATE. */
  1873. prAisFsmInfo->prTargetBssDesc = prBssDesc;
  1874. /* tyhsu: increase connection trial count */
  1875. prAisFsmInfo->ucConnTrialCount++;
  1876. /* Transit to channel acquire */
  1877. eNextState = AIS_STATE_REQ_CHANNEL_JOIN;
  1878. fgIsTransition = TRUE;
  1879. }
  1880. }
  1881. break;
  1882. case AIS_STATE_WAIT_FOR_NEXT_SCAN:
  1883. DBGLOG(AIS, LOUD, "SCAN: Idle Begin - Current Time = %u\n", kalGetTimeTick());
  1884. cnmTimerStartTimer(prAdapter,
  1885. &prAisFsmInfo->rBGScanTimer, SEC_TO_MSEC(prAisFsmInfo->u4SleepInterval));
  1886. SET_NET_PWR_STATE_IDLE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1887. if (prAisFsmInfo->u4SleepInterval < AIS_BG_SCAN_INTERVAL_MAX_SEC)
  1888. prAisFsmInfo->u4SleepInterval <<= 1;
  1889. break;
  1890. case AIS_STATE_SCAN:
  1891. case AIS_STATE_ONLINE_SCAN:
  1892. case AIS_STATE_LOOKING_FOR:
  1893. if (!IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX)) {
  1894. SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1895. /* sync with firmware */
  1896. nicActivateNetwork(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1897. }
  1898. /* IE length decision */
  1899. if (prAisFsmInfo->u4ScanIELength > 0) {
  1900. u2ScanIELen = (UINT_16) prAisFsmInfo->u4ScanIELength;
  1901. } else {
  1902. #if CFG_SUPPORT_WPS2
  1903. u2ScanIELen = prAdapter->prGlueInfo->u2WSCIELen;
  1904. #else
  1905. u2ScanIELen = 0;
  1906. #endif
  1907. }
  1908. prScanReqMsg = (P_MSG_SCN_SCAN_REQ) cnmMemAlloc(prAdapter,
  1909. RAM_TYPE_MSG,
  1910. OFFSET_OF(MSG_SCN_SCAN_REQ,
  1911. aucIE) + u2ScanIELen);
  1912. if (!prScanReqMsg) {
  1913. ASSERT(0); /* Can't trigger SCAN FSM */
  1914. return;
  1915. }
  1916. prScanReqMsg->rMsgHdr.eMsgId = MID_AIS_SCN_SCAN_REQ;
  1917. prScanReqMsg->ucSeqNum = ++prAisFsmInfo->ucSeqNumOfScanReq;
  1918. prScanReqMsg->ucNetTypeIndex = (UINT_8) NETWORK_TYPE_AIS_INDEX;
  1919. #if CFG_SUPPORT_RDD_TEST_MODE
  1920. prScanReqMsg->eScanType = SCAN_TYPE_PASSIVE_SCAN;
  1921. #else
  1922. prScanReqMsg->eScanType = SCAN_TYPE_ACTIVE_SCAN;
  1923. #endif
  1924. #if CFG_SUPPORT_ROAMING_ENC
  1925. if (prAdapter->fgIsRoamingEncEnabled == TRUE) {
  1926. if (prAisFsmInfo->eCurrentState == AIS_STATE_LOOKING_FOR &&
  1927. prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  1928. prScanReqMsg->u2ChannelDwellTime = AIS_ROAMING_SCAN_CHANNEL_DWELL_TIME;
  1929. }
  1930. }
  1931. #endif /* CFG_SUPPORT_ROAMING_ENC */
  1932. if (prAisFsmInfo->eCurrentState == AIS_STATE_SCAN
  1933. || prAisFsmInfo->eCurrentState == AIS_STATE_ONLINE_SCAN) {
  1934. if (prAisFsmInfo->ucScanSSIDLen == 0) {
  1935. /* Scan for all available SSID */
  1936. prScanReqMsg->ucSSIDType = SCAN_REQ_SSID_WILDCARD;
  1937. } else {
  1938. prScanReqMsg->ucSSIDType = SCAN_REQ_SSID_SPECIFIED;
  1939. COPY_SSID(prScanReqMsg->aucSSID,
  1940. prScanReqMsg->ucSSIDLength,
  1941. prAisFsmInfo->aucScanSSID, prAisFsmInfo->ucScanSSIDLen);
  1942. }
  1943. } else {
  1944. /* Scan for determined SSID */
  1945. prScanReqMsg->ucSSIDType = SCAN_REQ_SSID_SPECIFIED;
  1946. COPY_SSID(prScanReqMsg->aucSSID,
  1947. prScanReqMsg->ucSSIDLength,
  1948. prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  1949. }
  1950. /* check if tethering is running and need to fix on specific channel */
  1951. if (cnmAisInfraChannelFixed(prAdapter, &eBand, &ucChannel) == TRUE) {
  1952. prScanReqMsg->eScanChannel = SCAN_CHANNEL_SPECIFIED;
  1953. prScanReqMsg->ucChannelListNum = 1;
  1954. prScanReqMsg->arChnlInfoList[0].eBand = eBand;
  1955. prScanReqMsg->arChnlInfoList[0].ucChannelNum = ucChannel;
  1956. } else if (prAdapter->aePreferBand[NETWORK_TYPE_AIS_INDEX] == BAND_NULL) {
  1957. if (prAdapter->fgEnable5GBand == TRUE)
  1958. prScanReqMsg->eScanChannel = SCAN_CHANNEL_FULL;
  1959. else
  1960. prScanReqMsg->eScanChannel = SCAN_CHANNEL_2G4;
  1961. } else if (prAdapter->aePreferBand[NETWORK_TYPE_AIS_INDEX] == BAND_2G4) {
  1962. prScanReqMsg->eScanChannel = SCAN_CHANNEL_2G4;
  1963. } else if (prAdapter->aePreferBand[NETWORK_TYPE_AIS_INDEX] == BAND_5G) {
  1964. prScanReqMsg->eScanChannel = SCAN_CHANNEL_5G;
  1965. } else {
  1966. prScanReqMsg->eScanChannel = SCAN_CHANNEL_FULL;
  1967. ASSERT(0);
  1968. }
  1969. if (prAisFsmInfo->u4ScanIELength > 0) {
  1970. kalMemCopy(prScanReqMsg->aucIE, prAisFsmInfo->aucScanIEBuf,
  1971. prAisFsmInfo->u4ScanIELength);
  1972. } else {
  1973. #if CFG_SUPPORT_WPS2
  1974. if (prAdapter->prGlueInfo->u2WSCIELen > 0) {
  1975. kalMemCopy(prScanReqMsg->aucIE, &prAdapter->prGlueInfo->aucWSCIE,
  1976. prAdapter->prGlueInfo->u2WSCIELen);
  1977. }
  1978. }
  1979. #endif
  1980. prScanReqMsg->u2IELen = u2ScanIELen;
  1981. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prScanReqMsg, MSG_SEND_METHOD_BUF);
  1982. DBGLOG(AIS, TRACE, "SendSR%d\n", prScanReqMsg->ucSeqNum);
  1983. prAisFsmInfo->fgTryScan = FALSE; /* Will enable background sleep for infrastructure */
  1984. prAdapter->ucScanTime++;
  1985. break;
  1986. case AIS_STATE_REQ_CHANNEL_JOIN:
  1987. /* send message to CNM for acquiring channel */
  1988. prMsgChReq = (P_MSG_CH_REQ_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_REQ_T));
  1989. if (!prMsgChReq) {
  1990. ASSERT(0); /* Can't indicate CNM for channel acquiring */
  1991. return;
  1992. }
  1993. prMsgChReq->rMsgHdr.eMsgId = MID_MNY_CNM_CH_REQ;
  1994. prMsgChReq->ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX;
  1995. prMsgChReq->ucTokenID = ++prAisFsmInfo->ucSeqNumOfChReq;
  1996. prMsgChReq->eReqType = CH_REQ_TYPE_JOIN;
  1997. prMsgChReq->u4MaxInterval = AIS_JOIN_CH_REQUEST_INTERVAL;
  1998. if (prAisFsmInfo->prTargetBssDesc != NULL) {
  1999. prMsgChReq->ucPrimaryChannel = prAisFsmInfo->prTargetBssDesc->ucChannelNum;
  2000. prMsgChReq->eRfSco = prAisFsmInfo->prTargetBssDesc->eSco;
  2001. prMsgChReq->eRfBand = prAisFsmInfo->prTargetBssDesc->eBand;
  2002. COPY_MAC_ADDR(prMsgChReq->aucBSSID, prAisFsmInfo->prTargetBssDesc->aucBSSID);
  2003. }
  2004. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgChReq, MSG_SEND_METHOD_BUF);
  2005. prAisFsmInfo->fgIsChannelRequested = TRUE;
  2006. break;
  2007. case AIS_STATE_JOIN:
  2008. aisFsmStateInit_JOIN(prAdapter, prAisFsmInfo->prTargetBssDesc);
  2009. break;
  2010. #if CFG_SUPPORT_ADHOC
  2011. case AIS_STATE_IBSS_ALONE:
  2012. aisFsmStateInit_IBSS_ALONE(prAdapter);
  2013. break;
  2014. case AIS_STATE_IBSS_MERGE:
  2015. aisFsmStateInit_IBSS_MERGE(prAdapter, prAisFsmInfo->prTargetBssDesc);
  2016. break;
  2017. #endif /* CFG_SUPPORT_ADHOC */
  2018. case AIS_STATE_NORMAL_TR:
  2019. if (prAisFsmInfo->fgIsInfraChannelFinished == FALSE) {
  2020. /* Don't do anything when rJoinTimeoutTimer is still ticking */
  2021. } else {
  2022. /* 1. Process for pending scan */
  2023. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, TRUE) == TRUE) {
  2024. wlanClearScanningResult(prAdapter);
  2025. eNextState = AIS_STATE_ONLINE_SCAN;
  2026. fgIsTransition = TRUE;
  2027. }
  2028. /* 2. Process for pending roaming scan */
  2029. else if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_SEARCH, TRUE) == TRUE) {
  2030. eNextState = AIS_STATE_LOOKING_FOR;
  2031. fgIsTransition = TRUE;
  2032. }
  2033. /* 3. Process for pending roaming scan */
  2034. else if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, TRUE) == TRUE) {
  2035. eNextState = AIS_STATE_SEARCH;
  2036. fgIsTransition = TRUE;
  2037. } else if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_REMAIN_ON_CHANNEL, TRUE) ==
  2038. TRUE) {
  2039. eNextState = AIS_STATE_REQ_REMAIN_ON_CHANNEL;
  2040. fgIsTransition = TRUE;
  2041. }
  2042. }
  2043. break;
  2044. case AIS_STATE_DISCONNECTING:
  2045. /* send for deauth frame for disconnection */
  2046. authSendDeauthFrame(prAdapter,
  2047. prAisBssInfo->prStaRecOfAP,
  2048. (P_SW_RFB_T) NULL, REASON_CODE_DEAUTH_LEAVING_BSS, aisDeauthXmitComplete);
  2049. cnmTimerStartTimer(prAdapter, &prAisFsmInfo->rDeauthDoneTimer, 100);
  2050. break;
  2051. case AIS_STATE_REQ_REMAIN_ON_CHANNEL:
  2052. /* send message to CNM for acquiring channel */
  2053. prMsgChReq = (P_MSG_CH_REQ_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_REQ_T));
  2054. if (!prMsgChReq) {
  2055. ASSERT(0); /* Can't indicate CNM for channel acquiring */
  2056. return;
  2057. }
  2058. /* release channel */
  2059. aisFsmReleaseCh(prAdapter);
  2060. /* zero-ize */
  2061. kalMemZero(prMsgChReq, sizeof(MSG_CH_REQ_T));
  2062. /* filling */
  2063. prMsgChReq->rMsgHdr.eMsgId = MID_MNY_CNM_CH_REQ;
  2064. prMsgChReq->ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX;
  2065. prMsgChReq->ucTokenID = ++prAisFsmInfo->ucSeqNumOfChReq;
  2066. prMsgChReq->eReqType = CH_REQ_TYPE_JOIN;
  2067. prMsgChReq->u4MaxInterval = prAisFsmInfo->rChReqInfo.u4DurationMs;
  2068. prMsgChReq->ucPrimaryChannel = prAisFsmInfo->rChReqInfo.ucChannelNum;
  2069. prMsgChReq->eRfSco = prAisFsmInfo->rChReqInfo.eSco;
  2070. prMsgChReq->eRfBand = prAisFsmInfo->rChReqInfo.eBand;
  2071. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgChReq, MSG_SEND_METHOD_BUF);
  2072. prAisFsmInfo->fgIsChannelRequested = TRUE;
  2073. break;
  2074. case AIS_STATE_REMAIN_ON_CHANNEL:
  2075. SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2076. /* sync with firmware */
  2077. nicActivateNetwork(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2078. break;
  2079. default:
  2080. ASSERT(0); /* Make sure we have handle all STATEs */
  2081. break;
  2082. }
  2083. } while (fgIsTransition);
  2084. return;
  2085. } /* end of aisFsmSteps() */
  2086. /*----------------------------------------------------------------------------*/
  2087. /*!
  2088. * \brief
  2089. *
  2090. * \param[in]
  2091. *
  2092. * \return none
  2093. */
  2094. /*----------------------------------------------------------------------------*/
  2095. UINT_32 ucScanTimeoutTimes = 0;
  2096. VOID aisFsmRunEventScanDone(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  2097. {
  2098. P_MSG_SCN_SCAN_DONE prScanDoneMsg;
  2099. P_AIS_FSM_INFO_T prAisFsmInfo;
  2100. ENUM_AIS_STATE_T eNextState;
  2101. UINT_8 ucSeqNumOfCompMsg;
  2102. P_CONNECTION_SETTINGS_T prConnSettings;
  2103. DEBUGFUNC("aisFsmRunEventScanDone()");
  2104. ASSERT(prAdapter);
  2105. ASSERT(prMsgHdr);
  2106. ucScanTimeoutTimes = 0;
  2107. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2108. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2109. prScanDoneMsg = (P_MSG_SCN_SCAN_DONE) prMsgHdr;
  2110. ASSERT(prScanDoneMsg->ucNetTypeIndex == (UINT_8) NETWORK_TYPE_AIS_INDEX);
  2111. ucSeqNumOfCompMsg = prScanDoneMsg->ucSeqNum;
  2112. cnmMemFree(prAdapter, prMsgHdr);
  2113. eNextState = prAisFsmInfo->eCurrentState;
  2114. if (ucSeqNumOfCompMsg != prAisFsmInfo->ucSeqNumOfScanReq) {
  2115. DBGLOG(AIS, WARN, "SEQ NO of AIS SCN DONE MSG is not matched %d %d.\n",
  2116. ucSeqNumOfCompMsg, prAisFsmInfo->ucSeqNumOfScanReq);
  2117. } else {
  2118. switch (prAisFsmInfo->eCurrentState) {
  2119. case AIS_STATE_SCAN:
  2120. prConnSettings->fgIsScanReqIssued = FALSE;
  2121. /* reset scan IE buffer */
  2122. prAisFsmInfo->u4ScanIELength = 0;
  2123. kalScanDone(prAdapter->prGlueInfo, KAL_NETWORK_TYPE_AIS_INDEX, WLAN_STATUS_SUCCESS);
  2124. eNextState = AIS_STATE_IDLE;
  2125. #if CFG_SUPPORT_AGPS_ASSIST
  2126. scanReportScanResultToAgps(prAdapter);
  2127. #endif
  2128. break;
  2129. case AIS_STATE_ONLINE_SCAN:
  2130. prConnSettings->fgIsScanReqIssued = FALSE;
  2131. /* reset scan IE buffer */
  2132. prAisFsmInfo->u4ScanIELength = 0;
  2133. kalScanDone(prAdapter->prGlueInfo, KAL_NETWORK_TYPE_AIS_INDEX, WLAN_STATUS_SUCCESS);
  2134. #if CFG_SUPPORT_ROAMING
  2135. eNextState = aisFsmRoamingScanResultsUpdate(prAdapter);
  2136. #else
  2137. eNextState = AIS_STATE_NORMAL_TR;
  2138. #endif /* CFG_SUPPORT_ROAMING */
  2139. #if CFG_SUPPORT_AGPS_ASSIST
  2140. scanReportScanResultToAgps(prAdapter);
  2141. #endif
  2142. break;
  2143. case AIS_STATE_LOOKING_FOR:
  2144. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rScanDoneTimer);
  2145. scanReportBss2Cfg80211(prAdapter, BSS_TYPE_INFRASTRUCTURE, NULL);
  2146. #if CFG_SUPPORT_ROAMING
  2147. eNextState = aisFsmRoamingScanResultsUpdate(prAdapter);
  2148. #else
  2149. eNextState = AIS_STATE_SEARCH;
  2150. #endif /* CFG_SUPPORT_ROAMING */
  2151. break;
  2152. default:
  2153. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rScanDoneTimer);
  2154. break;
  2155. }
  2156. }
  2157. if (eNextState != prAisFsmInfo->eCurrentState)
  2158. aisFsmSteps(prAdapter, eNextState);
  2159. } /* end of aisFsmRunEventScanDone() */
  2160. /*----------------------------------------------------------------------------*/
  2161. /*!
  2162. * \brief
  2163. *
  2164. * \param[in]
  2165. *
  2166. * \return none
  2167. */
  2168. /*----------------------------------------------------------------------------*/
  2169. VOID aisFsmRunEventAbort(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  2170. {
  2171. P_MSG_AIS_ABORT_T prAisAbortMsg;
  2172. P_AIS_FSM_INFO_T prAisFsmInfo;
  2173. UINT_8 ucReasonOfDisconnect;
  2174. BOOLEAN fgDelayIndication;
  2175. P_CONNECTION_SETTINGS_T prConnSettings;
  2176. DEBUGFUNC("aisFsmRunEventAbort()");
  2177. ASSERT(prAdapter);
  2178. ASSERT(prMsgHdr);
  2179. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2180. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2181. /* 4 <1> Extract information of Abort Message and then free memory. */
  2182. prAisAbortMsg = (P_MSG_AIS_ABORT_T) prMsgHdr;
  2183. ucReasonOfDisconnect = prAisAbortMsg->ucReasonOfDisconnect;
  2184. fgDelayIndication = prAisAbortMsg->fgDelayIndication;
  2185. cnmMemFree(prAdapter, prMsgHdr);
  2186. #if DBG
  2187. DBGLOG(AIS, STATE, "EVENT-ABORT: Current State %s %d\n",
  2188. apucDebugAisState[prAisFsmInfo->eCurrentState], ucReasonOfDisconnect);
  2189. #else
  2190. DBGLOG(AIS, STATE, "[%d] EVENT-ABORT: Current State [%d %d]\n",
  2191. DBG_AIS_IDX, prAisFsmInfo->eCurrentState, ucReasonOfDisconnect);
  2192. #endif
  2193. GET_CURRENT_SYSTIME(&(prAisFsmInfo->rJoinReqTime));
  2194. /* 4 <2> clear previous pending connection request and insert new one */
  2195. if (ucReasonOfDisconnect == DISCONNECT_REASON_CODE_DEAUTHENTICATED
  2196. || ucReasonOfDisconnect == DISCONNECT_REASON_CODE_DISASSOCIATED) {
  2197. prConnSettings->fgIsDisconnectedByNonRequest = TRUE;
  2198. } else {
  2199. prConnSettings->fgIsDisconnectedByNonRequest = FALSE;
  2200. }
  2201. /* to support user space triggered roaming */
  2202. if (ucReasonOfDisconnect == DISCONNECT_REASON_CODE_ROAMING &&
  2203. prAisFsmInfo->eCurrentState != AIS_STATE_DISCONNECTING) {
  2204. if (prAisFsmInfo->eCurrentState == AIS_STATE_NORMAL_TR &&
  2205. prAisFsmInfo->fgIsInfraChannelFinished == TRUE) {
  2206. aisFsmSteps(prAdapter, AIS_STATE_SEARCH);
  2207. } else {
  2208. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_SEARCH, TRUE);
  2209. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, TRUE);
  2210. aisFsmInsertRequest(prAdapter, AIS_REQUEST_ROAMING_CONNECT);
  2211. }
  2212. return;
  2213. }
  2214. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_RECONNECT, TRUE);
  2215. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  2216. if (prAisFsmInfo->eCurrentState != AIS_STATE_DISCONNECTING) {
  2217. /* 4 <3> invoke abort handler */
  2218. aisFsmStateAbort(prAdapter, ucReasonOfDisconnect, fgDelayIndication);
  2219. }
  2220. } /* end of aisFsmRunEventAbort() */
  2221. /*----------------------------------------------------------------------------*/
  2222. /*!
  2223. * \brief This function handles AIS-FSM abort event/command
  2224. *
  2225. * \param[in] prAdapter Pointer of ADAPTER_T
  2226. * ucReasonOfDisconnect Reason for disonnection
  2227. * fgDelayIndication Option to delay disconnection indication
  2228. *
  2229. * \return none
  2230. */
  2231. /*----------------------------------------------------------------------------*/
  2232. VOID aisFsmStateAbort(IN P_ADAPTER_T prAdapter, UINT_8 ucReasonOfDisconnect, BOOLEAN fgDelayIndication)
  2233. {
  2234. P_AIS_FSM_INFO_T prAisFsmInfo;
  2235. P_BSS_INFO_T prAisBssInfo;
  2236. P_CONNECTION_SETTINGS_T prConnSettings;
  2237. BOOLEAN fgIsCheckConnected;
  2238. ASSERT(prAdapter);
  2239. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2240. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2241. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2242. fgIsCheckConnected = FALSE;
  2243. /* 4 <1> Save information of Abort Message and then free memory. */
  2244. prAisBssInfo->ucReasonOfDisconnect = ucReasonOfDisconnect;
  2245. /* 4 <2> Abort current job. */
  2246. switch (prAisFsmInfo->eCurrentState) {
  2247. case AIS_STATE_IDLE:
  2248. case AIS_STATE_SEARCH:
  2249. break;
  2250. case AIS_STATE_WAIT_FOR_NEXT_SCAN:
  2251. /* Do cancel timer */
  2252. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rBGScanTimer);
  2253. /* in case roaming is triggered */
  2254. fgIsCheckConnected = TRUE;
  2255. break;
  2256. case AIS_STATE_SCAN:
  2257. /* Do abort SCAN */
  2258. aisFsmStateAbort_SCAN(prAdapter);
  2259. /* queue for later handling */
  2260. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, FALSE) == FALSE)
  2261. aisFsmInsertRequest(prAdapter, AIS_REQUEST_SCAN);
  2262. break;
  2263. case AIS_STATE_LOOKING_FOR:
  2264. /* Do abort SCAN */
  2265. aisFsmStateAbort_SCAN(prAdapter);
  2266. /* in case roaming is triggered */
  2267. fgIsCheckConnected = TRUE;
  2268. break;
  2269. case AIS_STATE_REQ_CHANNEL_JOIN:
  2270. /* Release channel to CNM */
  2271. aisFsmReleaseCh(prAdapter);
  2272. /* in case roaming is triggered */
  2273. fgIsCheckConnected = TRUE;
  2274. break;
  2275. case AIS_STATE_JOIN:
  2276. /* Do abort JOIN */
  2277. aisFsmStateAbort_JOIN(prAdapter);
  2278. /* in case roaming is triggered */
  2279. fgIsCheckConnected = TRUE;
  2280. break;
  2281. #if CFG_SUPPORT_ADHOC
  2282. case AIS_STATE_IBSS_ALONE:
  2283. case AIS_STATE_IBSS_MERGE:
  2284. aisFsmStateAbort_IBSS(prAdapter);
  2285. break;
  2286. #endif /* CFG_SUPPORT_ADHOC */
  2287. case AIS_STATE_ONLINE_SCAN:
  2288. /* Do abort SCAN */
  2289. aisFsmStateAbort_SCAN(prAdapter);
  2290. /* queue for later handling */
  2291. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, FALSE) == FALSE)
  2292. aisFsmInsertRequest(prAdapter, AIS_REQUEST_SCAN);
  2293. fgIsCheckConnected = TRUE;
  2294. break;
  2295. case AIS_STATE_NORMAL_TR:
  2296. fgIsCheckConnected = TRUE;
  2297. break;
  2298. case AIS_STATE_DISCONNECTING:
  2299. /* Do abort NORMAL_TR */
  2300. aisFsmStateAbort_NORMAL_TR(prAdapter);
  2301. break;
  2302. case AIS_STATE_REQ_REMAIN_ON_CHANNEL:
  2303. /* release channel */
  2304. aisFsmReleaseCh(prAdapter);
  2305. break;
  2306. case AIS_STATE_REMAIN_ON_CHANNEL:
  2307. /* 1. release channel */
  2308. aisFsmReleaseCh(prAdapter);
  2309. /* 2. stop channel timeout timer */
  2310. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer);
  2311. break;
  2312. default:
  2313. break;
  2314. }
  2315. if (fgIsCheckConnected && (PARAM_MEDIA_STATE_CONNECTED == prAisBssInfo->eConnectionState)) {
  2316. /* switch into DISCONNECTING state for sending DEAUTH if necessary */
  2317. if (prAisBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE &&
  2318. prAisBssInfo->ucReasonOfDisconnect == DISCONNECT_REASON_CODE_NEW_CONNECTION &&
  2319. prAisBssInfo->prStaRecOfAP && prAisBssInfo->prStaRecOfAP->fgIsInUse) {
  2320. aisFsmSteps(prAdapter, AIS_STATE_DISCONNECTING);
  2321. return;
  2322. }
  2323. /* Do abort NORMAL_TR */
  2324. aisFsmStateAbort_NORMAL_TR(prAdapter);
  2325. }
  2326. aisFsmDisconnect(prAdapter, fgDelayIndication);
  2327. } /* end of aisFsmStateAbort() */
  2328. /*----------------------------------------------------------------------------*/
  2329. /*!
  2330. * @brief This function will handle the Join Complete Event from SAA FSM for AIS FSM
  2331. *
  2332. * @param[in] prMsgHdr Message of Join Complete of SAA FSM.
  2333. *
  2334. * @return (none)
  2335. */
  2336. /*----------------------------------------------------------------------------*/
  2337. VOID aisFsmRunEventJoinComplete(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  2338. {
  2339. P_MSG_JOIN_COMP_T prJoinCompMsg;
  2340. P_AIS_FSM_INFO_T prAisFsmInfo;
  2341. ENUM_AIS_STATE_T eNextState;
  2342. P_STA_RECORD_T prStaRec;
  2343. P_SW_RFB_T prAssocRspSwRfb;
  2344. P_BSS_INFO_T prAisBssInfo;
  2345. UINT_8 aucP2pSsid[] = CTIA_MAGIC_SSID;
  2346. OS_SYSTIME rCurrentTime;
  2347. P_CONNECTION_SETTINGS_T prConnSettings;
  2348. UINT_16 u2StatusCode = 0;
  2349. DEBUGFUNC("aisFsmRunEventJoinComplete()");
  2350. ASSERT(prMsgHdr);
  2351. GET_CURRENT_SYSTIME(&rCurrentTime);
  2352. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2353. prJoinCompMsg = (P_MSG_JOIN_COMP_T) prMsgHdr;
  2354. prStaRec = prJoinCompMsg->prStaRec;
  2355. prAssocRspSwRfb = prJoinCompMsg->prSwRfb;
  2356. eNextState = prAisFsmInfo->eCurrentState;
  2357. prConnSettings = &prAdapter->rWifiVar.rConnSettings;
  2358. DBGLOG(AIS, TRACE, "AISOK\n");
  2359. /* Check State and SEQ NUM */
  2360. do {
  2361. if (prAisFsmInfo->eCurrentState != AIS_STATE_JOIN)
  2362. break;
  2363. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2364. /* Check SEQ NUM */
  2365. if (prJoinCompMsg->ucSeqNum == prAisFsmInfo->ucSeqNumOfReqMsg) {
  2366. /* 4 <1> JOIN was successful */
  2367. if (prJoinCompMsg->rJoinStatus == WLAN_STATUS_SUCCESS) {
  2368. /* 1. Reset retry count */
  2369. prAisFsmInfo->ucConnTrialCount = 0;
  2370. prAdapter->rWifiVar.rConnSettings.eReConnectLevel = RECONNECT_LEVEL_MIN;
  2371. /* Completion of roaming */
  2372. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  2373. #if CFG_SUPPORT_ROAMING
  2374. /* 2. Deactivate previous BSS */
  2375. aisFsmRoamingDisconnectPrevAP(prAdapter, prStaRec);
  2376. /* 3. Update bss based on roaming staRec */
  2377. aisUpdateBssInfoForRoamingAP(prAdapter, prStaRec, prAssocRspSwRfb);
  2378. #endif /* CFG_SUPPORT_ROAMING */
  2379. } else {
  2380. /* 4 <1.1> Change FW's Media State immediately. */
  2381. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_CONNECTED);
  2382. /* 4 <1.2> Deactivate previous AP's STA_RECORD_T in Driver if have. */
  2383. if ((prAisBssInfo->prStaRecOfAP) &&
  2384. (prAisBssInfo->prStaRecOfAP != prStaRec) &&
  2385. (prAisBssInfo->prStaRecOfAP->fgIsInUse)) {
  2386. cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP,
  2387. STA_STATE_1);
  2388. }
  2389. /* 4 <1.3> Update BSS_INFO_T */
  2390. aisUpdateBssInfoForJOIN(prAdapter, prStaRec, prAssocRspSwRfb);
  2391. /* 4 <1.4> Activate current AP's STA_RECORD_T in Driver. */
  2392. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  2393. /* 4 <1.5> Update RSSI if necessary */
  2394. nicUpdateRSSI(prAdapter, NETWORK_TYPE_AIS_INDEX,
  2395. (INT_8) (RCPI_TO_dBm(prStaRec->ucRCPI)), 0);
  2396. /* 4 <1.6> Indicate Connected Event to Host immediately. */
  2397. /* Require BSSID, Association ID, Beacon Interval.. */
  2398. /* from AIS_BSS_INFO_T */
  2399. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_CONNECTED,
  2400. FALSE);
  2401. /* add for ctia mode */
  2402. if (EQUAL_SSID
  2403. (aucP2pSsid, CTIA_MAGIC_SSID_LEN, prAisBssInfo->aucSSID,
  2404. prAisBssInfo->ucSSIDLen)) {
  2405. nicEnterCtiaMode(prAdapter, TRUE, FALSE);
  2406. }
  2407. }
  2408. #if CFG_SUPPORT_ROAMING
  2409. /* if bssid is given, it means we no need fw roaming */
  2410. if (prAdapter->rWifiVar.rConnSettings.eConnectionPolicy != CONNECT_BY_BSSID)
  2411. roamingFsmRunEventStart(prAdapter);
  2412. #endif /* CFG_SUPPORT_ROAMING */
  2413. /* clear rJoinReqTime if there is no more framework roaming connect request */
  2414. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, FALSE) == FALSE)
  2415. prAisFsmInfo->rJoinReqTime = 0;
  2416. /* 4 <1.7> Set the Next State of AIS FSM */
  2417. eNextState = AIS_STATE_NORMAL_TR;
  2418. }
  2419. /* 4 <2> JOIN was not successful */
  2420. else {
  2421. /* 4 <2.1> Redo JOIN process with other Auth Type if possible */
  2422. if (aisFsmStateInit_RetryJOIN(prAdapter, prStaRec) == FALSE) {
  2423. P_BSS_DESC_T prBssDesc;
  2424. /* 1. Increase Failure Count */
  2425. prStaRec->ucJoinFailureCount++;
  2426. /* 2. release channel */
  2427. aisFsmReleaseCh(prAdapter);
  2428. /* 3.1 stop join timeout timer */
  2429. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rJoinTimeoutTimer);
  2430. /* 3.2 reset local variable */
  2431. prAisFsmInfo->fgIsInfraChannelFinished = TRUE;
  2432. prBssDesc = scanSearchBssDescByBssid(prAdapter, prStaRec->aucMacAddr);
  2433. if (prBssDesc == NULL) {
  2434. /* it maybe NULL when wlanRemove */
  2435. /*
  2436. (1) UI does wifi off during SAA does auth/assoc procedure.
  2437. (2) We will do LINK_INITIALIZE(&prScanInfo->rBSSDescList);
  2438. in nicUninitMGMT().
  2439. (3) We will handle prMsduInfo->pfTxDoneHandler
  2440. in nicTxRelease().
  2441. (4) prMsduInfo->pfTxDoneHandler will point to
  2442. saaFsmRunEventTxDone().
  2443. (5) Then jump to saaFsmSteps() -> saaFsmSendEventJoinComplete()
  2444. (6) Finally mboxSendMsg() -> aisFsmRunEventJoinComplete().
  2445. (7) In aisFsmRunEventJoinComplete(), we will check
  2446. "prBssDesc = scanSearchBssDescByBssid(prAdapter,
  2447. prStaRec->aucMacAddr);"
  2448. (8) And prBssDesc will be NULL and hangs in
  2449. "ASSERT(prBssDesc->fgIsConnecting);" when DBG=0.
  2450. ASSERT(prBssDesc);
  2451. ASSERT(prBssDesc->fgIsConnecting);
  2452. */
  2453. break;
  2454. }
  2455. DBGLOG(AIS, TRACE,
  2456. "ucJoinFailureCount=%d %d, Status=%d Reason=%d, eConnectionState=%d\n",
  2457. prStaRec->ucJoinFailureCount, prBssDesc->ucJoinFailureCount,
  2458. prStaRec->u2StatusCode, prStaRec->u2ReasonCode,
  2459. prAisBssInfo->eConnectionState);
  2460. /* ASSERT(prBssDesc); */
  2461. /* ASSERT(prBssDesc->fgIsConnecting); */
  2462. u2StatusCode = prStaRec->u2StatusCode;
  2463. prBssDesc->ucJoinFailureCount++;
  2464. if (prBssDesc->ucJoinFailureCount >= SCN_BSS_JOIN_FAIL_THRESOLD) {
  2465. GET_CURRENT_SYSTIME(&prBssDesc->rJoinFailTime);
  2466. DBGLOG(AIS, INFO,
  2467. "Bss %pM join fail %d times,temp disable it at time:%u\n",
  2468. prBssDesc->aucBSSID,
  2469. SCN_BSS_JOIN_FAIL_THRESOLD, prBssDesc->rJoinFailTime);
  2470. }
  2471. if (prBssDesc)
  2472. prBssDesc->fgIsConnecting = FALSE;
  2473. /* 3.3 Free STA-REC */
  2474. if (prStaRec != prAisBssInfo->prStaRecOfAP)
  2475. cnmStaRecFree(prAdapter, prStaRec, FALSE);
  2476. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  2477. #if CFG_SUPPORT_ROAMING
  2478. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  2479. #endif /* CFG_SUPPORT_ROAMING */
  2480. } else if (prAisFsmInfo->rJoinReqTime != 0 &&
  2481. CHECK_FOR_TIMEOUT(rCurrentTime,
  2482. prAisFsmInfo->rJoinReqTime,
  2483. SEC_TO_SYSTIME(AIS_JOIN_TIMEOUT))) {
  2484. /* abort connection trial */
  2485. prAdapter->rWifiVar.rConnSettings.fgIsConnReqIssued = FALSE;
  2486. prAdapter->rWifiVar.rConnSettings.eReConnectLevel = RECONNECT_LEVEL_MIN;
  2487. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  2488. WLAN_STATUS_JOIN_FAILURE,
  2489. (PVOID)&u2StatusCode,
  2490. sizeof(u2StatusCode));
  2491. eNextState = AIS_STATE_IDLE;
  2492. } else {
  2493. /* 4.b send reconnect request */
  2494. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  2495. eNextState = AIS_STATE_IDLE;
  2496. }
  2497. }
  2498. }
  2499. }
  2500. #if DBG
  2501. else
  2502. DBGLOG(AIS, WARN, "SEQ NO of AIS JOIN COMP MSG is not matched.\n");
  2503. #endif /* DBG */
  2504. if (eNextState != prAisFsmInfo->eCurrentState)
  2505. aisFsmSteps(prAdapter, eNextState);
  2506. } while (FALSE);
  2507. if (prAssocRspSwRfb)
  2508. nicRxReturnRFB(prAdapter, prAssocRspSwRfb);
  2509. cnmMemFree(prAdapter, prMsgHdr);
  2510. } /* end of aisFsmRunEventJoinComplete() */
  2511. #if CFG_SUPPORT_ADHOC
  2512. /*----------------------------------------------------------------------------*/
  2513. /*!
  2514. * @brief This function will handle the Grant Msg of IBSS Create which was sent by
  2515. * CNM to indicate that channel was changed for creating IBSS.
  2516. *
  2517. * @param[in] prAdapter Pointer of ADAPTER_T
  2518. *
  2519. * @return (none)
  2520. */
  2521. /*----------------------------------------------------------------------------*/
  2522. VOID aisFsmCreateIBSS(IN P_ADAPTER_T prAdapter)
  2523. {
  2524. P_AIS_FSM_INFO_T prAisFsmInfo;
  2525. ASSERT(prAdapter);
  2526. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2527. do {
  2528. /* Check State */
  2529. if (prAisFsmInfo->eCurrentState == AIS_STATE_IBSS_ALONE)
  2530. aisUpdateBssInfoForCreateIBSS(prAdapter);
  2531. } while (FALSE);
  2532. } /* end of aisFsmCreateIBSS() */
  2533. /*----------------------------------------------------------------------------*/
  2534. /*!
  2535. * @brief This function will handle the Grant Msg of IBSS Merge which was sent by
  2536. * CNM to indicate that channel was changed for merging IBSS.
  2537. *
  2538. * @param[in] prAdapter Pointer of ADAPTER_T
  2539. * @param[in] prStaRec Pointer of STA_RECORD_T for merge
  2540. *
  2541. * @return (none)
  2542. */
  2543. /*----------------------------------------------------------------------------*/
  2544. VOID aisFsmMergeIBSS(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec)
  2545. {
  2546. P_AIS_FSM_INFO_T prAisFsmInfo;
  2547. ENUM_AIS_STATE_T eNextState;
  2548. P_BSS_INFO_T prAisBssInfo;
  2549. ASSERT(prAdapter);
  2550. ASSERT(prStaRec);
  2551. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2552. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2553. do {
  2554. eNextState = prAisFsmInfo->eCurrentState;
  2555. switch (prAisFsmInfo->eCurrentState) {
  2556. case AIS_STATE_IBSS_MERGE:
  2557. {
  2558. P_BSS_DESC_T prBssDesc;
  2559. /* 4 <1.1> Change FW's Media State immediately. */
  2560. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_CONNECTED);
  2561. /* 4 <1.2> Deactivate previous Peers' STA_RECORD_T in Driver if have. */
  2562. bssClearClientList(prAdapter, prAisBssInfo);
  2563. /* 4 <1.3> Unmark connection flag of previous BSS_DESC_T. */
  2564. prBssDesc = scanSearchBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  2565. if (prBssDesc != NULL) {
  2566. prBssDesc->fgIsConnecting = FALSE;
  2567. prBssDesc->fgIsConnected = FALSE;
  2568. }
  2569. /* 4 <1.4> Update BSS_INFO_T */
  2570. aisUpdateBssInfoForMergeIBSS(prAdapter, prStaRec);
  2571. /* 4 <1.5> Add Peers' STA_RECORD_T to Client List */
  2572. bssAddStaRecToClientList(prAdapter, prAisBssInfo, prStaRec);
  2573. /* 4 <1.6> Activate current Peer's STA_RECORD_T in Driver. */
  2574. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  2575. prStaRec->fgIsMerging = FALSE;
  2576. /* 4 <1.7> Enable other features */
  2577. /* 4 <1.8> Indicate Connected Event to Host immediately. */
  2578. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_CONNECTED, FALSE);
  2579. /* 4 <1.9> Set the Next State of AIS FSM */
  2580. eNextState = AIS_STATE_NORMAL_TR;
  2581. /* 4 <1.10> Release channel privilege */
  2582. aisFsmReleaseCh(prAdapter);
  2583. #if CFG_SLT_SUPPORT
  2584. prAdapter->rWifiVar.rSltInfo.prPseudoStaRec = prStaRec;
  2585. #endif
  2586. }
  2587. break;
  2588. default:
  2589. break;
  2590. }
  2591. if (eNextState != prAisFsmInfo->eCurrentState)
  2592. aisFsmSteps(prAdapter, eNextState);
  2593. } while (FALSE);
  2594. } /* end of aisFsmMergeIBSS() */
  2595. /*----------------------------------------------------------------------------*/
  2596. /*!
  2597. * @brief This function will handle the Notification of existing IBSS was found
  2598. * from SCN.
  2599. *
  2600. * @param[in] prMsgHdr Message of Notification of an IBSS was present.
  2601. *
  2602. * @return (none)
  2603. */
  2604. /*----------------------------------------------------------------------------*/
  2605. VOID aisFsmRunEventFoundIBSSPeer(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  2606. {
  2607. P_MSG_AIS_IBSS_PEER_FOUND_T prAisIbssPeerFoundMsg;
  2608. P_AIS_FSM_INFO_T prAisFsmInfo;
  2609. ENUM_AIS_STATE_T eNextState;
  2610. P_STA_RECORD_T prStaRec;
  2611. P_BSS_INFO_T prAisBssInfo;
  2612. P_BSS_DESC_T prBssDesc;
  2613. BOOLEAN fgIsMergeIn;
  2614. ASSERT(prMsgHdr);
  2615. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2616. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2617. prAisIbssPeerFoundMsg = (P_MSG_AIS_IBSS_PEER_FOUND_T) prMsgHdr;
  2618. ASSERT(prAisIbssPeerFoundMsg->ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX);
  2619. prStaRec = prAisIbssPeerFoundMsg->prStaRec;
  2620. ASSERT(prStaRec);
  2621. fgIsMergeIn = prAisIbssPeerFoundMsg->fgIsMergeIn;
  2622. cnmMemFree(prAdapter, prMsgHdr);
  2623. eNextState = prAisFsmInfo->eCurrentState;
  2624. switch (prAisFsmInfo->eCurrentState) {
  2625. case AIS_STATE_IBSS_ALONE:
  2626. {
  2627. /* 4 <1> An IBSS Peer 'merged in'. */
  2628. if (fgIsMergeIn) {
  2629. /* 4 <1.1> Change FW's Media State immediately. */
  2630. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_CONNECTED);
  2631. /* 4 <1.2> Add Peers' STA_RECORD_T to Client List */
  2632. bssAddStaRecToClientList(prAdapter, prAisBssInfo, prStaRec);
  2633. #if CFG_SLT_SUPPORT
  2634. /* 4 <1.3> Mark connection flag of BSS_DESC_T. */
  2635. prBssDesc = scanSearchBssDescByTA(prAdapter, prStaRec->aucMacAddr);
  2636. if (prBssDesc != NULL) {
  2637. prBssDesc->fgIsConnecting = FALSE;
  2638. prBssDesc->fgIsConnected = TRUE;
  2639. } else {
  2640. ASSERT(0); /* Should be able to find a BSS_DESC_T here. */
  2641. }
  2642. /* 4 <1.4> Activate current Peer's STA_RECORD_T in Driver. */
  2643. prStaRec->fgIsQoS = TRUE; /* TODO(Kevin): TBD */
  2644. #else
  2645. /* 4 <1.3> Mark connection flag of BSS_DESC_T. */
  2646. prBssDesc = scanSearchBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  2647. if (prBssDesc != NULL) {
  2648. prBssDesc->fgIsConnecting = FALSE;
  2649. prBssDesc->fgIsConnected = TRUE;
  2650. } else {
  2651. ASSERT(0); /* Should be able to find a BSS_DESC_T here. */
  2652. }
  2653. /* 4 <1.4> Activate current Peer's STA_RECORD_T in Driver. */
  2654. prStaRec->fgIsQoS = FALSE; /* TODO(Kevin): TBD */
  2655. #endif
  2656. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  2657. prStaRec->fgIsMerging = FALSE;
  2658. /* 4 <1.6> sync. to firmware */
  2659. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2660. /* 4 <1.7> Indicate Connected Event to Host immediately. */
  2661. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_CONNECTED, FALSE);
  2662. /* 4 <1.8> indicate PM for connected */
  2663. nicPmIndicateBssConnected(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2664. /* 4 <1.9> Set the Next State of AIS FSM */
  2665. eNextState = AIS_STATE_NORMAL_TR;
  2666. /* 4 <1.10> Release channel privilege */
  2667. aisFsmReleaseCh(prAdapter);
  2668. }
  2669. /* 4 <2> We need 'merge out' to this IBSS */
  2670. else {
  2671. /* 4 <2.1> Get corresponding BSS_DESC_T */
  2672. prBssDesc = scanSearchBssDescByTA(prAdapter, prStaRec->aucMacAddr);
  2673. prAisFsmInfo->prTargetBssDesc = prBssDesc;
  2674. /* 4 <2.2> Set the Next State of AIS FSM */
  2675. eNextState = AIS_STATE_IBSS_MERGE;
  2676. }
  2677. }
  2678. break;
  2679. case AIS_STATE_NORMAL_TR:
  2680. {
  2681. /* 4 <3> An IBSS Peer 'merged in'. */
  2682. if (fgIsMergeIn) {
  2683. /* 4 <3.1> Add Peers' STA_RECORD_T to Client List */
  2684. bssAddStaRecToClientList(prAdapter, prAisBssInfo, prStaRec);
  2685. #if CFG_SLT_SUPPORT
  2686. /* 4 <3.2> Activate current Peer's STA_RECORD_T in Driver. */
  2687. prStaRec->fgIsQoS = TRUE; /* TODO(Kevin): TBD */
  2688. #else
  2689. /* 4 <3.2> Activate current Peer's STA_RECORD_T in Driver. */
  2690. prStaRec->fgIsQoS = FALSE; /* TODO(Kevin): TBD */
  2691. #endif
  2692. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  2693. prStaRec->fgIsMerging = FALSE;
  2694. }
  2695. /* 4 <4> We need 'merge out' to this IBSS */
  2696. else {
  2697. /* 4 <4.1> Get corresponding BSS_DESC_T */
  2698. prBssDesc = scanSearchBssDescByTA(prAdapter, prStaRec->aucMacAddr);
  2699. prAisFsmInfo->prTargetBssDesc = prBssDesc;
  2700. /* 4 <4.2> Set the Next State of AIS FSM */
  2701. eNextState = AIS_STATE_IBSS_MERGE;
  2702. }
  2703. }
  2704. break;
  2705. default:
  2706. break;
  2707. }
  2708. if (eNextState != prAisFsmInfo->eCurrentState)
  2709. aisFsmSteps(prAdapter, eNextState);
  2710. } /* end of aisFsmRunEventFoundIBSSPeer() */
  2711. #endif /* CFG_SUPPORT_ADHOC */
  2712. /*----------------------------------------------------------------------------*/
  2713. /*!
  2714. * @brief This function will indicate the Media State to HOST
  2715. *
  2716. * @param[in] eConnectionState Current Media State
  2717. * @param[in] fgDelayIndication Set TRUE for postponing the Disconnect Indication.
  2718. *
  2719. * @return (none)
  2720. */
  2721. /*----------------------------------------------------------------------------*/
  2722. VOID
  2723. aisIndicationOfMediaStateToHost(IN P_ADAPTER_T prAdapter,
  2724. ENUM_PARAM_MEDIA_STATE_T eConnectionState, BOOLEAN fgDelayIndication)
  2725. {
  2726. EVENT_CONNECTION_STATUS rEventConnStatus;
  2727. P_CONNECTION_SETTINGS_T prConnSettings;
  2728. P_BSS_INFO_T prAisBssInfo;
  2729. P_AIS_FSM_INFO_T prAisFsmInfo;
  2730. DEBUGFUNC("aisIndicationOfMediaStateToHost()");
  2731. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2732. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2733. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2734. /* NOTE(Kevin): Move following line to aisChangeMediaState() macro per CM's request. */
  2735. /* prAisBssInfo->eConnectionState = eConnectionState; */
  2736. /* For indicating the Disconnect Event only if current media state is
  2737. * disconnected and we didn't do indication yet.
  2738. */
  2739. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
  2740. if (prAisBssInfo->eConnectionStateIndicated == eConnectionState)
  2741. return;
  2742. }
  2743. if (!fgDelayIndication) {
  2744. /* 4 <0> Cancel Delay Timer */
  2745. prAisFsmInfo->u4PostponeIndStartTime = 0;
  2746. /* 4 <1> Fill EVENT_CONNECTION_STATUS */
  2747. rEventConnStatus.ucMediaStatus = (UINT_8) eConnectionState;
  2748. if (eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  2749. rEventConnStatus.ucReasonOfDisconnect = DISCONNECT_REASON_CODE_RESERVED;
  2750. if (prAisBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
  2751. rEventConnStatus.ucInfraMode = (UINT_8) NET_TYPE_INFRA;
  2752. rEventConnStatus.u2AID = prAisBssInfo->u2AssocId;
  2753. rEventConnStatus.u2ATIMWindow = 0;
  2754. } else if (prAisBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
  2755. rEventConnStatus.ucInfraMode = (UINT_8) NET_TYPE_IBSS;
  2756. rEventConnStatus.u2AID = 0;
  2757. rEventConnStatus.u2ATIMWindow = prAisBssInfo->u2ATIMWindow;
  2758. } else {
  2759. ASSERT(0);
  2760. }
  2761. COPY_SSID(rEventConnStatus.aucSsid,
  2762. rEventConnStatus.ucSsidLen, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  2763. COPY_MAC_ADDR(rEventConnStatus.aucBssid, prAisBssInfo->aucBSSID);
  2764. rEventConnStatus.u2BeaconPeriod = prAisBssInfo->u2BeaconInterval;
  2765. rEventConnStatus.u4FreqInKHz = nicChannelNum2Freq(prAisBssInfo->ucPrimaryChannel);
  2766. switch (prAisBssInfo->ucNonHTBasicPhyType) {
  2767. case PHY_TYPE_HR_DSSS_INDEX:
  2768. rEventConnStatus.ucNetworkType = (UINT_8) PARAM_NETWORK_TYPE_DS;
  2769. break;
  2770. case PHY_TYPE_ERP_INDEX:
  2771. rEventConnStatus.ucNetworkType = (UINT_8) PARAM_NETWORK_TYPE_OFDM24;
  2772. break;
  2773. case PHY_TYPE_OFDM_INDEX:
  2774. rEventConnStatus.ucNetworkType = (UINT_8) PARAM_NETWORK_TYPE_OFDM5;
  2775. break;
  2776. default:
  2777. ASSERT(0);
  2778. rEventConnStatus.ucNetworkType = (UINT_8) PARAM_NETWORK_TYPE_DS;
  2779. break;
  2780. }
  2781. } else {
  2782. /* Deactivate previous Peers' STA_RECORD_T in Driver if have. */
  2783. bssClearClientList(prAdapter, prAisBssInfo);
  2784. #if CFG_PRIVACY_MIGRATION
  2785. /* Clear the pmkid cache while media disconnect */
  2786. secClearPmkid(prAdapter);
  2787. #endif
  2788. rEventConnStatus.ucReasonOfDisconnect = prAisBssInfo->ucReasonOfDisconnect;
  2789. }
  2790. /* 4 <2> Indication */
  2791. nicMediaStateChange(prAdapter, NETWORK_TYPE_AIS_INDEX, &rEventConnStatus);
  2792. prAisBssInfo->eConnectionStateIndicated = eConnectionState;
  2793. } else {
  2794. /* NOTE: Only delay the Indication of Disconnect Event */
  2795. ASSERT(eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED);
  2796. DBGLOG(AIS, INFO, "Postpone the indication of Disconnect for %d seconds\n",
  2797. prConnSettings->ucDelayTimeOfDisconnectEvent);
  2798. prAisFsmInfo->u4PostponeIndStartTime = kalGetTimeTick();
  2799. }
  2800. } /* end of aisIndicationOfMediaStateToHost() */
  2801. /*----------------------------------------------------------------------------*/
  2802. /*!
  2803. * @brief This function will indicate an Event of "Media Disconnect" to HOST
  2804. *
  2805. * @param[in] u4Param Unused timer parameter
  2806. *
  2807. * @return (none)
  2808. */
  2809. /*----------------------------------------------------------------------------*/
  2810. VOID aisPostponedEventOfDisconnTimeout(IN P_ADAPTER_T prAdapter, IN P_AIS_FSM_INFO_T prAisFsmInfo)
  2811. {
  2812. P_BSS_INFO_T prAisBssInfo;
  2813. P_CONNECTION_SETTINGS_T prConnSettings;
  2814. P_SCAN_INFO_T prScanInfo;
  2815. BOOLEAN fgFound = TRUE;
  2816. /* firstly, check if we have started postpone indication.
  2817. otherwise, give a chance to do join before indicate to host */
  2818. if (prAisFsmInfo->u4PostponeIndStartTime == 0)
  2819. return;
  2820. /* if we're in req channel/join/search state, don't report disconnect. */
  2821. if (prAisFsmInfo->eCurrentState == AIS_STATE_JOIN ||
  2822. prAisFsmInfo->eCurrentState == AIS_STATE_SEARCH ||
  2823. prAisFsmInfo->eCurrentState == AIS_STATE_REQ_CHANNEL_JOIN) {
  2824. DBGLOG(AIS, INFO, "CurrentState: %d, don't report disconnect\n",
  2825. prAisFsmInfo->eCurrentState);
  2826. return;
  2827. }
  2828. prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
  2829. if (prScanInfo->eCurrentState == SCAN_STATE_SCANNING) {
  2830. DBGLOG(AIS, INFO, "SCANNING, don't report disconnect\n");
  2831. return;
  2832. }
  2833. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2834. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2835. if (!CHECK_FOR_TIMEOUT(kalGetTimeTick(), prAisFsmInfo->u4PostponeIndStartTime,
  2836. SEC_TO_MSEC(prConnSettings->ucDelayTimeOfDisconnectEvent)))
  2837. return;
  2838. /* 4 <1> Deactivate previous AP's STA_RECORD_T in Driver if have. */
  2839. if (prAisBssInfo->prStaRecOfAP) {
  2840. /* cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP, STA_STATE_1); */
  2841. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  2842. }
  2843. /* 4 <2> Remove all pending connection request */
  2844. while (fgFound)
  2845. fgFound = aisFsmIsRequestPending(prAdapter, AIS_REQUEST_RECONNECT, TRUE);
  2846. if (prAisFsmInfo->eCurrentState == AIS_STATE_LOOKING_FOR)
  2847. prAisFsmInfo->eCurrentState = AIS_STATE_IDLE;
  2848. prConnSettings->fgIsDisconnectedByNonRequest = TRUE;
  2849. prAisBssInfo->u2DeauthReason = REASON_CODE_BEACON_TIMEOUT;
  2850. /* 4 <3> Indicate Disconnected Event to Host immediately. */
  2851. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED, FALSE);
  2852. } /* end of aisPostponedEventOfDisconnTimeout() */
  2853. /*----------------------------------------------------------------------------*/
  2854. /*!
  2855. * @brief This function will update the contain of BSS_INFO_T for AIS network once
  2856. * the association was completed.
  2857. *
  2858. * @param[in] prStaRec Pointer to the STA_RECORD_T
  2859. * @param[in] prAssocRspSwRfb Pointer to SW RFB of ASSOC RESP FRAME.
  2860. *
  2861. * @return (none)
  2862. */
  2863. /*----------------------------------------------------------------------------*/
  2864. VOID aisUpdateBssInfoForJOIN(IN P_ADAPTER_T prAdapter, P_STA_RECORD_T prStaRec, P_SW_RFB_T prAssocRspSwRfb)
  2865. {
  2866. P_AIS_FSM_INFO_T prAisFsmInfo;
  2867. P_BSS_INFO_T prAisBssInfo;
  2868. P_CONNECTION_SETTINGS_T prConnSettings;
  2869. P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame;
  2870. P_BSS_DESC_T prBssDesc;
  2871. UINT_16 u2IELength;
  2872. PUINT_8 pucIE;
  2873. DEBUGFUNC("aisUpdateBssInfoForJOIN()");
  2874. ASSERT(prStaRec);
  2875. ASSERT(prAssocRspSwRfb);
  2876. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2877. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2878. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2879. prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) prAssocRspSwRfb->pvHeader;
  2880. DBGLOG(AIS, TRACE, "Update AIS_BSS_INFO_T and apply settings to MAC\n");
  2881. /* 3 <1> Update BSS_INFO_T from AIS_FSM_INFO_T or User Settings */
  2882. /* 4 <1.1> Setup Operation Mode */
  2883. prAisBssInfo->eCurrentOPMode = OP_MODE_INFRASTRUCTURE;
  2884. /* 4 <1.2> Setup SSID */
  2885. COPY_SSID(prAisBssInfo->aucSSID, prAisBssInfo->ucSSIDLen, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  2886. /* 4 <1.3> Setup Channel, Band */
  2887. prAisBssInfo->ucPrimaryChannel = prAisFsmInfo->prTargetBssDesc->ucChannelNum;
  2888. prAisBssInfo->eBand = prAisFsmInfo->prTargetBssDesc->eBand;
  2889. /* 3 <2> Update BSS_INFO_T from STA_RECORD_T */
  2890. /* 4 <2.1> Save current AP's STA_RECORD_T and current AID */
  2891. prAisBssInfo->prStaRecOfAP = prStaRec;
  2892. prAisBssInfo->u2AssocId = prStaRec->u2AssocId;
  2893. /* 4 <2.2> Setup Capability */
  2894. prAisBssInfo->u2CapInfo = prStaRec->u2CapInfo; /* Use AP's Cap Info as BSS Cap Info */
  2895. if (prAisBssInfo->u2CapInfo & CAP_INFO_SHORT_PREAMBLE)
  2896. prAisBssInfo->fgIsShortPreambleAllowed = TRUE;
  2897. else
  2898. prAisBssInfo->fgIsShortPreambleAllowed = FALSE;
  2899. #if (CFG_SUPPORT_TDLS == 1)
  2900. /* init the TDLS flags */
  2901. prAisBssInfo->fgTdlsIsProhibited = prStaRec->fgTdlsIsProhibited;
  2902. prAisBssInfo->fgTdlsIsChSwProhibited = prStaRec->fgTdlsIsChSwProhibited;
  2903. #endif /* CFG_SUPPORT_TDLS */
  2904. /* 4 <2.3> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
  2905. prAisBssInfo->ucPhyTypeSet = prStaRec->ucDesiredPhyTypeSet;
  2906. prAisBssInfo->ucNonHTBasicPhyType = prStaRec->ucNonHTBasicPhyType;
  2907. prAisBssInfo->u2OperationalRateSet = prStaRec->u2OperationalRateSet;
  2908. prAisBssInfo->u2BSSBasicRateSet = prStaRec->u2BSSBasicRateSet;
  2909. /* 3 <3> Update BSS_INFO_T from SW_RFB_T (Association Resp Frame) */
  2910. /* 4 <3.1> Setup BSSID */
  2911. COPY_MAC_ADDR(prAisBssInfo->aucBSSID, prAssocRspFrame->aucBSSID);
  2912. u2IELength = (UINT_16) ((prAssocRspSwRfb->u2PacketLen - prAssocRspSwRfb->u2HeaderLen) -
  2913. (OFFSET_OF(WLAN_ASSOC_RSP_FRAME_T, aucInfoElem[0]) - WLAN_MAC_MGMT_HEADER_LEN));
  2914. pucIE = prAssocRspFrame->aucInfoElem;
  2915. /* 4 <3.2> Parse WMM and setup QBSS flag */
  2916. /* Parse WMM related IEs and configure HW CRs accordingly */
  2917. mqmProcessAssocRsp(prAdapter, prAssocRspSwRfb, pucIE, u2IELength);
  2918. prAisBssInfo->fgIsQBSS = prStaRec->fgIsQoS;
  2919. /* 3 <4> Update BSS_INFO_T from BSS_DESC_T */
  2920. prBssDesc = scanSearchBssDescByBssid(prAdapter, prAssocRspFrame->aucBSSID);
  2921. if (prBssDesc) {
  2922. prBssDesc->fgIsConnecting = FALSE;
  2923. prBssDesc->fgIsConnected = TRUE;
  2924. prBssDesc->ucJoinFailureCount = 0;
  2925. /* 4 <4.1> Setup MIB for current BSS */
  2926. prAisBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
  2927. } else {
  2928. /* should never happen */
  2929. ASSERT(0);
  2930. }
  2931. /* NOTE: Defer ucDTIMPeriod updating to when beacon is received after connection */
  2932. prAisBssInfo->ucDTIMPeriod = 0;
  2933. prAisBssInfo->u2ATIMWindow = 0;
  2934. prAisBssInfo->ucBeaconTimeoutCount = AIS_BEACON_TIMEOUT_COUNT_INFRA;
  2935. /* 4 <4.2> Update HT information and set channel */
  2936. /* Record HT related parameters in rStaRec and rBssInfo
  2937. * Note: it shall be called before nicUpdateBss()
  2938. */
  2939. rlmProcessAssocRsp(prAdapter, prAssocRspSwRfb, pucIE, u2IELength);
  2940. /* 4 <4.3> Sync with firmware for BSS-INFO */
  2941. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2942. /* 4 <4.4> *DEFER OPERATION* nicPmIndicateBssConnected() will be invoked */
  2943. /* inside scanProcessBeaconAndProbeResp() after 1st beacon is received */
  2944. } /* end of aisUpdateBssInfoForJOIN() */
  2945. #if CFG_SUPPORT_ADHOC
  2946. /*----------------------------------------------------------------------------*/
  2947. /*!
  2948. * @brief This function will create an Ad-Hoc network and start sending Beacon Frames.
  2949. *
  2950. * @param (none)
  2951. *
  2952. * @return (none)
  2953. */
  2954. /*----------------------------------------------------------------------------*/
  2955. VOID aisUpdateBssInfoForCreateIBSS(IN P_ADAPTER_T prAdapter)
  2956. {
  2957. P_AIS_FSM_INFO_T prAisFsmInfo;
  2958. P_BSS_INFO_T prAisBssInfo;
  2959. P_CONNECTION_SETTINGS_T prConnSettings;
  2960. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2961. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2962. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2963. if (prAisBssInfo->fgIsBeaconActivated)
  2964. return;
  2965. /* 3 <1> Update BSS_INFO_T per Network Basis */
  2966. /* 4 <1.1> Setup Operation Mode */
  2967. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  2968. /* 4 <1.2> Setup SSID */
  2969. COPY_SSID(prAisBssInfo->aucSSID, prAisBssInfo->ucSSIDLen, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  2970. /* 4 <1.3> Clear current AP's STA_RECORD_T and current AID */
  2971. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  2972. prAisBssInfo->u2AssocId = 0;
  2973. /* 4 <1.4> Setup Channel, Band and Phy Attributes */
  2974. prAisBssInfo->ucPrimaryChannel = prConnSettings->ucAdHocChannelNum;
  2975. prAisBssInfo->eBand = prConnSettings->eAdHocBand;
  2976. if (prAisBssInfo->eBand == BAND_2G4) {
  2977. /* Depend on eBand */
  2978. prAisBssInfo->ucPhyTypeSet = prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11BGN;
  2979. /* Depend on eCurrentOPMode and ucPhyTypeSet */
  2980. prAisBssInfo->ucConfigAdHocAPMode = AD_HOC_MODE_MIXED_11BG;
  2981. } else {
  2982. /* Depend on eBand */
  2983. prAisBssInfo->ucPhyTypeSet = prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11AN;
  2984. /* Depend on eCurrentOPMode and ucPhyTypeSet */
  2985. prAisBssInfo->ucConfigAdHocAPMode = AD_HOC_MODE_11A;
  2986. }
  2987. /* 4 <1.5> Setup MIB for current BSS */
  2988. prAisBssInfo->u2BeaconInterval = prConnSettings->u2BeaconPeriod;
  2989. prAisBssInfo->ucDTIMPeriod = 0;
  2990. prAisBssInfo->u2ATIMWindow = prConnSettings->u2AtimWindow;
  2991. prAisBssInfo->ucBeaconTimeoutCount = AIS_BEACON_TIMEOUT_COUNT_ADHOC;
  2992. #if CFG_PRIVACY_MIGRATION
  2993. if (prConnSettings->eEncStatus == ENUM_ENCRYPTION1_ENABLED ||
  2994. prConnSettings->eEncStatus == ENUM_ENCRYPTION2_ENABLED ||
  2995. prConnSettings->eEncStatus == ENUM_ENCRYPTION3_ENABLED) {
  2996. prAisBssInfo->fgIsProtection = TRUE;
  2997. } else {
  2998. prAisBssInfo->fgIsProtection = FALSE;
  2999. }
  3000. #else
  3001. prAisBssInfo->fgIsProtection = FALSE;
  3002. #endif
  3003. /* 3 <2> Update BSS_INFO_T common part */
  3004. ibssInitForAdHoc(prAdapter, prAisBssInfo);
  3005. /* 3 <3> Set MAC HW */
  3006. /* 4 <3.1> Setup channel and bandwidth */
  3007. rlmBssInitForAPandIbss(prAdapter, prAisBssInfo);
  3008. /* 4 <3.2> use command packets to inform firmware */
  3009. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3010. /* 4 <3.3> enable beaconing */
  3011. bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3012. /* 4 <3.4> Update AdHoc PM parameter */
  3013. nicPmIndicateBssCreated(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3014. /* 3 <4> Set ACTIVE flag. */
  3015. prAisBssInfo->fgIsBeaconActivated = TRUE;
  3016. prAisBssInfo->fgHoldSameBssidForIBSS = TRUE;
  3017. /* 3 <5> Start IBSS Alone Timer */
  3018. cnmTimerStartTimer(prAdapter, &prAisFsmInfo->rIbssAloneTimer, SEC_TO_MSEC(AIS_IBSS_ALONE_TIMEOUT_SEC));
  3019. return;
  3020. } /* end of aisCreateIBSS() */
  3021. /*----------------------------------------------------------------------------*/
  3022. /*!
  3023. * @brief This function will update the contain of BSS_INFO_T for AIS network once
  3024. * the existing IBSS was found.
  3025. *
  3026. * @param[in] prStaRec Pointer to the STA_RECORD_T
  3027. *
  3028. * @return (none)
  3029. */
  3030. /*----------------------------------------------------------------------------*/
  3031. VOID aisUpdateBssInfoForMergeIBSS(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec)
  3032. {
  3033. P_AIS_FSM_INFO_T prAisFsmInfo;
  3034. P_BSS_INFO_T prAisBssInfo;
  3035. P_CONNECTION_SETTINGS_T prConnSettings;
  3036. P_BSS_DESC_T prBssDesc;
  3037. /* UINT_16 u2IELength; */
  3038. /* PUINT_8 pucIE; */
  3039. ASSERT(prStaRec);
  3040. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3041. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3042. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3043. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rIbssAloneTimer);
  3044. if (!prAisBssInfo->fgIsBeaconActivated) {
  3045. /* 3 <1> Update BSS_INFO_T per Network Basis */
  3046. /* 4 <1.1> Setup Operation Mode */
  3047. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  3048. /* 4 <1.2> Setup SSID */
  3049. COPY_SSID(prAisBssInfo->aucSSID,
  3050. prAisBssInfo->ucSSIDLen, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  3051. /* 4 <1.3> Clear current AP's STA_RECORD_T and current AID */
  3052. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  3053. prAisBssInfo->u2AssocId = 0;
  3054. }
  3055. /* 3 <2> Update BSS_INFO_T from STA_RECORD_T */
  3056. /* 4 <2.1> Setup Capability */
  3057. prAisBssInfo->u2CapInfo = prStaRec->u2CapInfo; /* Use Peer's Cap Info as IBSS Cap Info */
  3058. if (prAisBssInfo->u2CapInfo & CAP_INFO_SHORT_PREAMBLE) {
  3059. prAisBssInfo->fgIsShortPreambleAllowed = TRUE;
  3060. prAisBssInfo->fgUseShortPreamble = TRUE;
  3061. } else {
  3062. prAisBssInfo->fgIsShortPreambleAllowed = FALSE;
  3063. prAisBssInfo->fgUseShortPreamble = FALSE;
  3064. }
  3065. /* 7.3.1.4 For IBSS, the Short Slot Time subfield shall be set to 0. */
  3066. prAisBssInfo->fgUseShortSlotTime = FALSE; /* Set to FALSE for AdHoc */
  3067. prAisBssInfo->u2CapInfo &= ~CAP_INFO_SHORT_SLOT_TIME;
  3068. if (prAisBssInfo->u2CapInfo & CAP_INFO_PRIVACY)
  3069. prAisBssInfo->fgIsProtection = TRUE;
  3070. else
  3071. prAisBssInfo->fgIsProtection = FALSE;
  3072. /* 4 <2.2> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
  3073. prAisBssInfo->ucPhyTypeSet = prStaRec->ucDesiredPhyTypeSet;
  3074. prAisBssInfo->ucNonHTBasicPhyType = prStaRec->ucNonHTBasicPhyType;
  3075. prAisBssInfo->u2OperationalRateSet = prStaRec->u2OperationalRateSet;
  3076. prAisBssInfo->u2BSSBasicRateSet = prStaRec->u2BSSBasicRateSet;
  3077. rateGetDataRatesFromRateSet(prAisBssInfo->u2OperationalRateSet,
  3078. prAisBssInfo->u2BSSBasicRateSet,
  3079. prAisBssInfo->aucAllSupportedRates, &prAisBssInfo->ucAllSupportedRatesLen);
  3080. /* 3 <3> X Update BSS_INFO_T from SW_RFB_T (Association Resp Frame) */
  3081. /* 3 <4> Update BSS_INFO_T from BSS_DESC_T */
  3082. prBssDesc = scanSearchBssDescByTA(prAdapter, prStaRec->aucMacAddr);
  3083. if (prBssDesc) {
  3084. prBssDesc->fgIsConnecting = FALSE;
  3085. prBssDesc->fgIsConnected = TRUE;
  3086. /* 4 <4.1> Setup BSSID */
  3087. COPY_MAC_ADDR(prAisBssInfo->aucBSSID, prBssDesc->aucBSSID);
  3088. /* 4 <4.2> Setup Channel, Band */
  3089. prAisBssInfo->ucPrimaryChannel = prBssDesc->ucChannelNum;
  3090. prAisBssInfo->eBand = prBssDesc->eBand;
  3091. /* 4 <4.3> Setup MIB for current BSS */
  3092. prAisBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
  3093. prAisBssInfo->ucDTIMPeriod = 0;
  3094. prAisBssInfo->u2ATIMWindow = 0; /* TBD(Kevin) */
  3095. prAisBssInfo->ucBeaconTimeoutCount = AIS_BEACON_TIMEOUT_COUNT_ADHOC;
  3096. } else {
  3097. /* should never happen */
  3098. ASSERT(0);
  3099. }
  3100. /* 3 <5> Set MAC HW */
  3101. /* 4 <5.1> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
  3102. {
  3103. UINT_8 ucLowestBasicRateIndex;
  3104. if (!rateGetLowestRateIndexFromRateSet(prAisBssInfo->u2BSSBasicRateSet, &ucLowestBasicRateIndex)) {
  3105. if (prAisBssInfo->ucPhyTypeSet & PHY_TYPE_BIT_OFDM)
  3106. ucLowestBasicRateIndex = RATE_6M_INDEX;
  3107. else
  3108. ucLowestBasicRateIndex = RATE_1M_INDEX;
  3109. }
  3110. prAisBssInfo->ucHwDefaultFixedRateCode =
  3111. aucRateIndex2RateCode[prAisBssInfo->fgUseShortPreamble][ucLowestBasicRateIndex];
  3112. }
  3113. /* 4 <5.2> Setup channel and bandwidth */
  3114. rlmBssInitForAPandIbss(prAdapter, prAisBssInfo);
  3115. /* 4 <5.3> use command packets to inform firmware */
  3116. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3117. /* 4 <5.4> enable beaconing */
  3118. bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3119. /* 4 <5.5> Update AdHoc PM parameter */
  3120. nicPmIndicateBssConnected(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3121. /* 3 <6> Set ACTIVE flag. */
  3122. prAisBssInfo->fgIsBeaconActivated = TRUE;
  3123. prAisBssInfo->fgHoldSameBssidForIBSS = TRUE;
  3124. } /* end of aisUpdateBssInfoForMergeIBSS() */
  3125. /*----------------------------------------------------------------------------*/
  3126. /*!
  3127. * @brief This function will validate the Rx Probe Request Frame and then return
  3128. * result to BSS to indicate if need to send the corresponding Probe Response
  3129. * Frame if the specified conditions were matched.
  3130. *
  3131. * @param[in] prAdapter Pointer to the Adapter structure.
  3132. * @param[in] prSwRfb Pointer to SW RFB data structure.
  3133. * @param[out] pu4ControlFlags Control flags for replying the Probe Response
  3134. *
  3135. * @retval TRUE Reply the Probe Response
  3136. * @retval FALSE Don't reply the Probe Response
  3137. */
  3138. /*----------------------------------------------------------------------------*/
  3139. BOOLEAN aisValidateProbeReq(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, OUT PUINT_32 pu4ControlFlags)
  3140. {
  3141. P_WLAN_MAC_MGMT_HEADER_T prMgtHdr;
  3142. P_BSS_INFO_T prBssInfo;
  3143. P_IE_SSID_T prIeSsid = (P_IE_SSID_T) NULL;
  3144. PUINT_8 pucIE;
  3145. UINT_16 u2IELength;
  3146. UINT_16 u2Offset = 0;
  3147. BOOLEAN fgReplyProbeResp = FALSE;
  3148. ASSERT(prSwRfb);
  3149. ASSERT(pu4ControlFlags);
  3150. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3151. /* 4 <1> Parse Probe Req IE and Get IE ptr (SSID, Supported Rate IE, ...) */
  3152. prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T) prSwRfb->pvHeader;
  3153. u2IELength = prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen;
  3154. pucIE = (PUINT_8) prSwRfb->pvHeader + prSwRfb->u2HeaderLen;
  3155. IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
  3156. if (ELEM_ID_SSID == IE_ID(pucIE)) {
  3157. if ((!prIeSsid) && (IE_LEN(pucIE) <= ELEM_MAX_LEN_SSID))
  3158. prIeSsid = (P_IE_SSID_T) pucIE;
  3159. break;
  3160. }
  3161. } /* end of IE_FOR_EACH */
  3162. /* 4 <2> Check network conditions */
  3163. if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
  3164. if ((prIeSsid) && ((prIeSsid->ucLength == BC_SSID_LEN) || /* WILDCARD SSID */
  3165. EQUAL_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen, /* CURRENT SSID */
  3166. prIeSsid->aucSSID, prIeSsid->ucLength))) {
  3167. fgReplyProbeResp = TRUE;
  3168. }
  3169. }
  3170. return fgReplyProbeResp;
  3171. } /* end of aisValidateProbeReq() */
  3172. #endif /* CFG_SUPPORT_ADHOC */
  3173. /*----------------------------------------------------------------------------*/
  3174. /*!
  3175. * @brief This function will modify and update necessary information to firmware
  3176. * for disconnection handling
  3177. *
  3178. * @param[in] prAdapter Pointer to the Adapter structure.
  3179. *
  3180. * @retval None
  3181. */
  3182. /*----------------------------------------------------------------------------*/
  3183. VOID aisFsmDisconnect(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgDelayIndication)
  3184. {
  3185. P_BSS_INFO_T prAisBssInfo;
  3186. ASSERT(prAdapter);
  3187. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3188. nicPmIndicateBssAbort(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3189. #if CFG_SUPPORT_ADHOC
  3190. if (prAisBssInfo->fgIsBeaconActivated) {
  3191. nicUpdateBeaconIETemplate(prAdapter, IE_UPD_METHOD_DELETE_ALL, NETWORK_TYPE_AIS_INDEX, 0, NULL, 0);
  3192. prAisBssInfo->fgIsBeaconActivated = FALSE;
  3193. }
  3194. #endif
  3195. rlmBssAborted(prAdapter, prAisBssInfo);
  3196. /* 4 <3> Unset the fgIsConnected flag of BSS_DESC_T and send Deauth if needed. */
  3197. if (PARAM_MEDIA_STATE_CONNECTED == prAisBssInfo->eConnectionState) {
  3198. /* add for ctia mode */
  3199. {
  3200. UINT_8 aucP2pSsid[] = CTIA_MAGIC_SSID;
  3201. if (EQUAL_SSID(aucP2pSsid, CTIA_MAGIC_SSID_LEN, prAisBssInfo->aucSSID, prAisBssInfo->ucSSIDLen))
  3202. nicEnterCtiaMode(prAdapter, FALSE, FALSE);
  3203. }
  3204. if (prAisBssInfo->ucReasonOfDisconnect == DISCONNECT_REASON_CODE_RADIO_LOST) {
  3205. scanRemoveBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  3206. /* remove from scanning results as well */
  3207. wlanClearBssInScanningResult(prAdapter, prAisBssInfo->aucBSSID);
  3208. /* trials for re-association */
  3209. if (fgDelayIndication) {
  3210. DBGLOG(AIS, INFO, "try to do re-association due to radio lost!\n");
  3211. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_RECONNECT, TRUE);
  3212. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  3213. }
  3214. } else {
  3215. scanRemoveConnFlagOfBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  3216. }
  3217. if (fgDelayIndication) {
  3218. if (OP_MODE_IBSS != prAisBssInfo->eCurrentOPMode)
  3219. prAisBssInfo->fgHoldSameBssidForIBSS = FALSE;
  3220. } else {
  3221. prAisBssInfo->fgHoldSameBssidForIBSS = FALSE;
  3222. }
  3223. } else {
  3224. prAisBssInfo->fgHoldSameBssidForIBSS = FALSE;
  3225. }
  3226. /* 4 <4> Change Media State immediately. */
  3227. if (prAisBssInfo->ucReasonOfDisconnect != DISCONNECT_REASON_CODE_REASSOCIATION) {
  3228. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
  3229. /* 4 <4.1> sync. with firmware */
  3230. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3231. }
  3232. if (!fgDelayIndication) {
  3233. /* 4 <5> Deactivate previous AP's STA_RECORD_T or all Clients in Driver if have. */
  3234. if (prAisBssInfo->prStaRecOfAP) {
  3235. /* cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP, STA_STATE_1); */
  3236. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  3237. }
  3238. }
  3239. #if CFG_SUPPORT_ROAMING
  3240. roamingFsmRunEventAbort(prAdapter);
  3241. /* clear pending roaming connection request */
  3242. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_SEARCH, TRUE);
  3243. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, TRUE);
  3244. #endif /* CFG_SUPPORT_ROAMING */
  3245. /* 4 <6> Indicate Disconnected Event to Host */
  3246. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED, fgDelayIndication);
  3247. /* 4 <7> Trigger AIS FSM */
  3248. aisFsmSteps(prAdapter, AIS_STATE_IDLE);
  3249. } /* end of aisFsmDisconnect() */
  3250. /*----------------------------------------------------------------------------*/
  3251. /*!
  3252. * @brief This function will indicate an Event of Scan done Time-Out to AIS FSM.
  3253. *
  3254. * @param[in] u4Param Unused timer parameter
  3255. *
  3256. * @return (none)
  3257. */
  3258. /*----------------------------------------------------------------------------*/
  3259. UINT_32 IsrCnt = 0, IsrPassCnt = 0, TaskIsrCnt = 0;
  3260. VOID aisFsmRunEventScanDoneTimeOut(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3261. {
  3262. #define SCAN_DONE_TIMEOUT_TIMES_LIMIT 20
  3263. P_AIS_FSM_INFO_T prAisFsmInfo;
  3264. ENUM_AIS_STATE_T eNextState;
  3265. P_CONNECTION_SETTINGS_T prConnSettings;
  3266. GL_HIF_INFO_T *HifInfo;
  3267. UINT_32 u4FwCnt;
  3268. DEBUGFUNC("aisFsmRunEventScanDoneTimeOut()");
  3269. ASSERT(prAdapter);
  3270. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3271. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3272. HifInfo = &prAdapter->prGlueInfo->rHifInfo;
  3273. DBGLOG(AIS, WARN, "aisFsmRunEventScanDoneTimeOut Current[%d]\n", prAisFsmInfo->eCurrentState);
  3274. DBGLOG(AIS, WARN, "Isr/task %u %u %u (0x%x)\n", IsrCnt, IsrPassCnt, TaskIsrCnt, prAdapter->fgIsIntEnable);
  3275. /* dump firmware program counter */
  3276. DBGLOG(AIS, WARN, "CONNSYS FW CPUINFO:\n");
  3277. for (u4FwCnt = 0; u4FwCnt < 16; u4FwCnt++)
  3278. DBGLOG(AIS, WARN, "0x%08x ", MCU_REG_READL(HifInfo, CONN_MCU_CPUPCR));
  3279. ucScanTimeoutTimes++;
  3280. if (ucScanTimeoutTimes > SCAN_DONE_TIMEOUT_TIMES_LIMIT) {
  3281. kalSendAeeWarning("[Scan done timeout more than 20 times!]", __func__);
  3282. glDoChipReset();
  3283. }
  3284. #if 0 /* ALPS02018734: remove trigger assert */
  3285. if (prAdapter->fgTestMode == FALSE) {
  3286. /* Titus - xxx */
  3287. /* assert if and only if in normal mode */
  3288. mtk_wcn_wmt_assert(WMTDRV_TYPE_WIFI, 40);
  3289. }
  3290. #endif
  3291. /* report all scanned frames to upper layer to avoid scanned frame is timeout */
  3292. /* must be put before kalScanDone */
  3293. /* scanReportBss2Cfg80211(prAdapter,BSS_TYPE_INFRASTRUCTURE,NULL); */
  3294. prConnSettings->fgIsScanReqIssued = FALSE;
  3295. kalScanDone(prAdapter->prGlueInfo, KAL_NETWORK_TYPE_AIS_INDEX, WLAN_STATUS_SUCCESS);
  3296. eNextState = prAisFsmInfo->eCurrentState;
  3297. switch (prAisFsmInfo->eCurrentState) {
  3298. case AIS_STATE_SCAN:
  3299. prAisFsmInfo->u4ScanIELength = 0;
  3300. eNextState = AIS_STATE_IDLE;
  3301. break;
  3302. case AIS_STATE_ONLINE_SCAN:
  3303. /* reset scan IE buffer */
  3304. prAisFsmInfo->u4ScanIELength = 0;
  3305. #if CFG_SUPPORT_ROAMING
  3306. eNextState = aisFsmRoamingScanResultsUpdate(prAdapter);
  3307. #else
  3308. eNextState = AIS_STATE_NORMAL_TR;
  3309. #endif /* CFG_SUPPORT_ROAMING */
  3310. break;
  3311. default:
  3312. break;
  3313. }
  3314. /* try to stop scan in CONNSYS */
  3315. aisFsmStateAbort_SCAN(prAdapter);
  3316. /* wlanQueryDebugCode(prAdapter); */ /* display current SCAN FSM in FW, debug use */
  3317. if (eNextState != prAisFsmInfo->eCurrentState)
  3318. aisFsmSteps(prAdapter, eNextState);
  3319. } /* end of aisFsmBGSleepTimeout() */
  3320. /*----------------------------------------------------------------------------*/
  3321. /*!
  3322. * @brief This function will indicate an Event of "Background Scan Time-Out" to AIS FSM.
  3323. *
  3324. * @param[in] u4Param Unused timer parameter
  3325. *
  3326. * @return (none)
  3327. */
  3328. /*----------------------------------------------------------------------------*/
  3329. VOID aisFsmRunEventBGSleepTimeOut(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3330. {
  3331. P_AIS_FSM_INFO_T prAisFsmInfo;
  3332. ENUM_AIS_STATE_T eNextState;
  3333. DEBUGFUNC("aisFsmRunEventBGSleepTimeOut()");
  3334. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3335. eNextState = prAisFsmInfo->eCurrentState;
  3336. switch (prAisFsmInfo->eCurrentState) {
  3337. case AIS_STATE_WAIT_FOR_NEXT_SCAN:
  3338. DBGLOG(AIS, LOUD, "EVENT - SCAN TIMER: Idle End - Current Time = %u\n", kalGetTimeTick());
  3339. eNextState = AIS_STATE_LOOKING_FOR;
  3340. SET_NET_PWR_STATE_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3341. break;
  3342. default:
  3343. break;
  3344. }
  3345. /* Call aisFsmSteps() when we are going to change AIS STATE */
  3346. if (eNextState != prAisFsmInfo->eCurrentState)
  3347. aisFsmSteps(prAdapter, eNextState);
  3348. } /* end of aisFsmBGSleepTimeout() */
  3349. /*----------------------------------------------------------------------------*/
  3350. /*!
  3351. * @brief This function will indicate an Event of "IBSS ALONE Time-Out" to AIS FSM.
  3352. *
  3353. * @param[in] u4Param Unused timer parameter
  3354. *
  3355. * @return (none)
  3356. */
  3357. /*----------------------------------------------------------------------------*/
  3358. VOID aisFsmRunEventIbssAloneTimeOut(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3359. {
  3360. P_AIS_FSM_INFO_T prAisFsmInfo;
  3361. ENUM_AIS_STATE_T eNextState;
  3362. DEBUGFUNC("aisFsmRunEventIbssAloneTimeOut()");
  3363. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3364. eNextState = prAisFsmInfo->eCurrentState;
  3365. switch (prAisFsmInfo->eCurrentState) {
  3366. case AIS_STATE_IBSS_ALONE:
  3367. /* There is no one participate in our AdHoc during this TIMEOUT Interval
  3368. * so go back to search for a valid IBSS again.
  3369. */
  3370. DBGLOG(AIS, LOUD, "EVENT-IBSS ALONE TIMER: Start pairing\n");
  3371. prAisFsmInfo->fgTryScan = TRUE;
  3372. /* abort timer */
  3373. aisFsmReleaseCh(prAdapter);
  3374. /* Pull back to SEARCH to find candidate again */
  3375. eNextState = AIS_STATE_SEARCH;
  3376. break;
  3377. default:
  3378. break;
  3379. }
  3380. /* Call aisFsmSteps() when we are going to change AIS STATE */
  3381. if (eNextState != prAisFsmInfo->eCurrentState)
  3382. aisFsmSteps(prAdapter, eNextState);
  3383. } /* end of aisIbssAloneTimeOut() */
  3384. /*----------------------------------------------------------------------------*/
  3385. /*!
  3386. * @brief This function will indicate an Event of "Join Time-Out" to AIS FSM.
  3387. *
  3388. * @param[in] u4Param Unused timer parameter
  3389. *
  3390. * @return (none)
  3391. */
  3392. /*----------------------------------------------------------------------------*/
  3393. VOID aisFsmRunEventJoinTimeout(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3394. {
  3395. P_BSS_INFO_T prAisBssInfo;
  3396. P_AIS_FSM_INFO_T prAisFsmInfo;
  3397. ENUM_AIS_STATE_T eNextState;
  3398. OS_SYSTIME rCurrentTime;
  3399. DEBUGFUNC("aisFsmRunEventJoinTimeout()");
  3400. prAisBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
  3401. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3402. eNextState = prAisFsmInfo->eCurrentState;
  3403. GET_CURRENT_SYSTIME(&rCurrentTime);
  3404. switch (prAisFsmInfo->eCurrentState) {
  3405. case AIS_STATE_JOIN:
  3406. DBGLOG(AIS, LOUD, "EVENT- JOIN TIMEOUT\n");
  3407. /* 1. Do abort JOIN */
  3408. aisFsmStateAbort_JOIN(prAdapter);
  3409. /* 2. Increase Join Failure Count */
  3410. prAisFsmInfo->prTargetBssDesc->ucJoinFailureCount++;
  3411. /* For JB nl802.11 */
  3412. if (prAisFsmInfo->prTargetBssDesc->ucJoinFailureCount < JOIN_MAX_RETRY_FAILURE_COUNT) {
  3413. /* 3.1 Retreat to AIS_STATE_SEARCH state for next try */
  3414. eNextState = AIS_STATE_SEARCH;
  3415. } else if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  3416. /* 3.2 Retreat to AIS_STATE_WAIT_FOR_NEXT_SCAN state for next try */
  3417. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  3418. } else if (prAisFsmInfo->rJoinReqTime != 0 &&
  3419. !CHECK_FOR_TIMEOUT(rCurrentTime,
  3420. prAisFsmInfo->rJoinReqTime,
  3421. SEC_TO_SYSTIME(AIS_JOIN_TIMEOUT))) {
  3422. /* 3.3 Retreat to AIS_STATE_WAIT_FOR_NEXT_SCAN state for next try */
  3423. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  3424. } else {
  3425. /* 3.4 Retreat to AIS_STATE_JOIN_FAILURE to terminate join operation */
  3426. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_JOIN_FAILURE, NULL, 0);
  3427. eNextState = AIS_STATE_IDLE;
  3428. }
  3429. break;
  3430. case AIS_STATE_NORMAL_TR:
  3431. /* 1. release channel */
  3432. aisFsmReleaseCh(prAdapter);
  3433. prAisFsmInfo->fgIsInfraChannelFinished = TRUE;
  3434. /* 2. process if there is pending scan */
  3435. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, TRUE) == TRUE) {
  3436. wlanClearScanningResult(prAdapter);
  3437. eNextState = AIS_STATE_ONLINE_SCAN;
  3438. }
  3439. break;
  3440. default:
  3441. /* release channel */
  3442. aisFsmReleaseCh(prAdapter);
  3443. break;
  3444. }
  3445. /* Call aisFsmSteps() when we are going to change AIS STATE */
  3446. if (eNextState != prAisFsmInfo->eCurrentState)
  3447. aisFsmSteps(prAdapter, eNextState);
  3448. } /* end of aisFsmRunEventJoinTimeout() */
  3449. VOID aisFsmRunEventDeauthTimeout(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3450. {
  3451. aisDeauthXmitComplete(prAdapter, NULL, TX_RESULT_LIFE_TIMEOUT);
  3452. }
  3453. #if defined(CFG_TEST_MGMT_FSM) && (CFG_TEST_MGMT_FSM != 0)
  3454. /*----------------------------------------------------------------------------*/
  3455. /*!
  3456. * \brief
  3457. *
  3458. * \param[in]
  3459. *
  3460. * \return none
  3461. */
  3462. /*----------------------------------------------------------------------------*/
  3463. VOID aisTest(VOID)
  3464. {
  3465. P_MSG_AIS_ABORT_T prAisAbortMsg;
  3466. P_CONNECTION_SETTINGS_T prConnSettings;
  3467. UINT_8 aucSSID[] = "pci-11n";
  3468. UINT_8 ucSSIDLen = 7;
  3469. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3470. /* Set Connection Request Issued Flag */
  3471. prConnSettings->fgIsConnReqIssued = TRUE;
  3472. prConnSettings->ucSSIDLen = ucSSIDLen;
  3473. kalMemCopy(prConnSettings->aucSSID, aucSSID, ucSSIDLen);
  3474. prAisAbortMsg = (P_MSG_AIS_ABORT_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_AIS_ABORT_T));
  3475. if (!prAisAbortMsg) {
  3476. ASSERT(0); /* Can't trigger SCAN FSM */
  3477. return;
  3478. }
  3479. prAisAbortMsg->rMsgHdr.eMsgId = MID_HEM_AIS_FSM_ABORT;
  3480. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prAisAbortMsg, MSG_SEND_METHOD_BUF);
  3481. wifi_send_msg(INDX_WIFI, MSG_ID_WIFI_IST, 0);
  3482. }
  3483. #endif /* CFG_TEST_MGMT_FSM */
  3484. /*----------------------------------------------------------------------------*/
  3485. /*!
  3486. * \brief This function is used to handle OID_802_11_BSSID_LIST_SCAN
  3487. *
  3488. * \param[in] prAdapter Pointer of ADAPTER_T
  3489. * \param[in] prSsid Pointer of SSID_T if specified
  3490. * \param[in] pucIe Pointer to buffer of extra information elements to be attached
  3491. * \param[in] u4IeLength Length of information elements
  3492. *
  3493. * \return none
  3494. */
  3495. /*----------------------------------------------------------------------------*/
  3496. VOID aisFsmScanRequest(IN P_ADAPTER_T prAdapter, IN P_PARAM_SSID_T prSsid, IN PUINT_8 pucIe, IN UINT_32 u4IeLength)
  3497. {
  3498. P_CONNECTION_SETTINGS_T prConnSettings;
  3499. P_BSS_INFO_T prAisBssInfo;
  3500. P_AIS_FSM_INFO_T prAisFsmInfo;
  3501. DEBUGFUNC("aisFsmScanRequest()");
  3502. ASSERT(prAdapter);
  3503. ASSERT(u4IeLength <= MAX_IE_LENGTH);
  3504. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3505. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3506. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3507. if (!prConnSettings->fgIsScanReqIssued) {
  3508. prConnSettings->fgIsScanReqIssued = TRUE;
  3509. if (prSsid == NULL) {
  3510. prAisFsmInfo->ucScanSSIDLen = 0;
  3511. } else {
  3512. COPY_SSID(prAisFsmInfo->aucScanSSID,
  3513. prAisFsmInfo->ucScanSSIDLen, prSsid->aucSsid, (UINT_8) prSsid->u4SsidLen);
  3514. }
  3515. if (u4IeLength > 0 && u4IeLength <= MAX_IE_LENGTH) {
  3516. prAisFsmInfo->u4ScanIELength = u4IeLength;
  3517. kalMemCopy(prAisFsmInfo->aucScanIEBuf, pucIe, u4IeLength);
  3518. } else {
  3519. prAisFsmInfo->u4ScanIELength = 0;
  3520. }
  3521. if (prAisFsmInfo->eCurrentState == AIS_STATE_NORMAL_TR) {
  3522. if (prAisBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE
  3523. && prAisFsmInfo->fgIsInfraChannelFinished == FALSE) {
  3524. /* 802.1x might not finished yet, pend it for later handling .. */
  3525. aisFsmInsertRequest(prAdapter, AIS_REQUEST_SCAN);
  3526. } else {
  3527. if (prAisFsmInfo->fgIsChannelGranted == TRUE) {
  3528. DBGLOG(AIS, WARN,
  3529. "Scan Request with channel granted for join operation: %d, %d",
  3530. prAisFsmInfo->fgIsChannelGranted, prAisFsmInfo->fgIsChannelRequested);
  3531. }
  3532. /* start online scan */
  3533. wlanClearScanningResult(prAdapter);
  3534. aisFsmSteps(prAdapter, AIS_STATE_ONLINE_SCAN);
  3535. }
  3536. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_IDLE) {
  3537. wlanClearScanningResult(prAdapter);
  3538. aisFsmSteps(prAdapter, AIS_STATE_SCAN);
  3539. } else {
  3540. aisFsmInsertRequest(prAdapter, AIS_REQUEST_SCAN);
  3541. }
  3542. } else {
  3543. DBGLOG(AIS, WARN, "Scan Request dropped. (state: %d)\n", prAisFsmInfo->eCurrentState);
  3544. }
  3545. } /* end of aisFsmScanRequest() */
  3546. /*----------------------------------------------------------------------------*/
  3547. /*!
  3548. * \brief This function is invoked when CNM granted channel privilege
  3549. *
  3550. * \param[in] prAdapter Pointer of ADAPTER_T
  3551. *
  3552. * \return none
  3553. */
  3554. /*----------------------------------------------------------------------------*/
  3555. VOID aisFsmRunEventChGrant(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  3556. {
  3557. P_BSS_INFO_T prAisBssInfo;
  3558. P_AIS_FSM_INFO_T prAisFsmInfo;
  3559. P_MSG_CH_GRANT_T prMsgChGrant;
  3560. UINT_8 ucTokenID;
  3561. UINT_32 u4GrantInterval;
  3562. ASSERT(prAdapter);
  3563. ASSERT(prMsgHdr);
  3564. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3565. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3566. prMsgChGrant = (P_MSG_CH_GRANT_T) prMsgHdr;
  3567. ucTokenID = prMsgChGrant->ucTokenID;
  3568. u4GrantInterval = prMsgChGrant->u4GrantInterval;
  3569. /* 1. free message */
  3570. cnmMemFree(prAdapter, prMsgHdr);
  3571. if (prAisFsmInfo->eCurrentState == AIS_STATE_REQ_CHANNEL_JOIN && prAisFsmInfo->ucSeqNumOfChReq == ucTokenID) {
  3572. /* 2. channel privilege has been approved */
  3573. prAisFsmInfo->u4ChGrantedInterval = u4GrantInterval;
  3574. /* 3. state transition to join/ibss-alone/ibss-merge */
  3575. /* 3.1 set timeout timer in cases join could not be completed */
  3576. cnmTimerStartTimer(prAdapter,
  3577. &prAisFsmInfo->rJoinTimeoutTimer,
  3578. prAisFsmInfo->u4ChGrantedInterval - AIS_JOIN_CH_GRANT_THRESHOLD);
  3579. /* 3.2 set local variable to indicate join timer is ticking */
  3580. prAisFsmInfo->fgIsInfraChannelFinished = FALSE;
  3581. /* 3.3 switch to join state */
  3582. aisFsmSteps(prAdapter, AIS_STATE_JOIN);
  3583. prAisFsmInfo->fgIsChannelGranted = TRUE;
  3584. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_REQ_REMAIN_ON_CHANNEL &&
  3585. prAisFsmInfo->ucSeqNumOfChReq == ucTokenID) {
  3586. /* 2. channel privilege has been approved */
  3587. prAisFsmInfo->u4ChGrantedInterval = u4GrantInterval;
  3588. /* 3.1 set timeout timer in cases upper layer cancel_remain_on_channel never comes */
  3589. cnmTimerStartTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer, prAisFsmInfo->u4ChGrantedInterval);
  3590. /* 3.2 switch to remain_on_channel state */
  3591. aisFsmSteps(prAdapter, AIS_STATE_REMAIN_ON_CHANNEL);
  3592. /* 3.3. indicate upper layer for channel ready */
  3593. kalReadyOnChannel(prAdapter->prGlueInfo,
  3594. prAisFsmInfo->rChReqInfo.u8Cookie,
  3595. prAisFsmInfo->rChReqInfo.eBand,
  3596. prAisFsmInfo->rChReqInfo.eSco,
  3597. prAisFsmInfo->rChReqInfo.ucChannelNum, prAisFsmInfo->rChReqInfo.u4DurationMs);
  3598. prAisFsmInfo->fgIsChannelGranted = TRUE;
  3599. } else { /* mismatched grant */
  3600. /* 2. return channel privilege to CNM immediately */
  3601. aisFsmReleaseCh(prAdapter);
  3602. }
  3603. } /* end of aisFsmRunEventChGrant() */
  3604. /*----------------------------------------------------------------------------*/
  3605. /*!
  3606. * \brief This function is to inform CNM that channel privilege
  3607. * has been released
  3608. *
  3609. * \param[in] prAdapter Pointer of ADAPTER_T
  3610. *
  3611. * \return none
  3612. */
  3613. /*----------------------------------------------------------------------------*/
  3614. VOID aisFsmReleaseCh(IN P_ADAPTER_T prAdapter)
  3615. {
  3616. P_AIS_FSM_INFO_T prAisFsmInfo;
  3617. P_MSG_CH_ABORT_T prMsgChAbort;
  3618. ASSERT(prAdapter);
  3619. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3620. if (prAisFsmInfo->fgIsChannelGranted == TRUE || prAisFsmInfo->fgIsChannelRequested == TRUE) {
  3621. prAisFsmInfo->fgIsChannelRequested = FALSE;
  3622. prAisFsmInfo->fgIsChannelGranted = FALSE;
  3623. /* 1. return channel privilege to CNM immediately */
  3624. prMsgChAbort = (P_MSG_CH_ABORT_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_ABORT_T));
  3625. if (!prMsgChAbort) {
  3626. ASSERT(0); /* Can't release Channel to CNM */
  3627. return;
  3628. }
  3629. prMsgChAbort->rMsgHdr.eMsgId = MID_MNY_CNM_CH_ABORT;
  3630. prMsgChAbort->ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX;
  3631. prMsgChAbort->ucTokenID = prAisFsmInfo->ucSeqNumOfChReq;
  3632. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgChAbort, MSG_SEND_METHOD_BUF);
  3633. }
  3634. } /* end of aisFsmReleaseCh() */
  3635. /*----------------------------------------------------------------------------*/
  3636. /*!
  3637. * \brief This function is to inform AIS that corresponding beacon has not
  3638. * been received for a while and probing is not successful
  3639. *
  3640. * \param[in] prAdapter Pointer of ADAPTER_T
  3641. *
  3642. * \return none
  3643. */
  3644. /*----------------------------------------------------------------------------*/
  3645. VOID aisBssBeaconTimeout(IN P_ADAPTER_T prAdapter)
  3646. {
  3647. P_BSS_INFO_T prAisBssInfo;
  3648. BOOLEAN fgDoAbortIndication = FALSE;
  3649. P_CONNECTION_SETTINGS_T prConnSettings;
  3650. ASSERT(prAdapter);
  3651. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3652. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3653. /* 4 <1> Diagnose Connection for Beacon Timeout Event */
  3654. if (PARAM_MEDIA_STATE_CONNECTED == prAisBssInfo->eConnectionState) {
  3655. if (OP_MODE_INFRASTRUCTURE == prAisBssInfo->eCurrentOPMode) {
  3656. P_STA_RECORD_T prStaRec = prAisBssInfo->prStaRecOfAP;
  3657. if (prStaRec)
  3658. fgDoAbortIndication = TRUE;
  3659. } else if (OP_MODE_IBSS == prAisBssInfo->eCurrentOPMode) {
  3660. fgDoAbortIndication = TRUE;
  3661. }
  3662. }
  3663. /* 4 <2> invoke abort handler */
  3664. if (fgDoAbortIndication) {
  3665. #if 0
  3666. P_CONNECTION_SETTINGS_T prConnSettings;
  3667. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3668. prConnSettings->fgIsDisconnectedByNonRequest = TRUE;
  3669. #endif
  3670. DBGLOG(AIS, INFO, "Beacon Timeout, Remove BSS [%pM]\n", prAisBssInfo->aucBSSID);
  3671. scanRemoveBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  3672. /*
  3673. Note: Cannot change TRUE to FALSE; or you will suffer the problem in
  3674. ALPS01270257/ ALPS01804173
  3675. */
  3676. if (prConnSettings->eReConnectLevel < RECONNECT_LEVEL_USER_SET) {
  3677. prConnSettings->eReConnectLevel = RECONNECT_LEVEL_BEACON_TIMEOUT;
  3678. prConnSettings->fgIsConnReqIssued = TRUE;
  3679. }
  3680. aisFsmStateAbort(prAdapter, DISCONNECT_REASON_CODE_RADIO_LOST, TRUE);
  3681. }
  3682. } /* end of aisBssBeaconTimeout() */
  3683. VOID aisBssSecurityChanged(P_ADAPTER_T prAdapter)
  3684. {
  3685. P_BSS_INFO_T prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3686. prAdapter->rWifiVar.rConnSettings.fgIsDisconnectedByNonRequest = TRUE;
  3687. prAisBssInfo->u2DeauthReason = REASON_CODE_BSS_SECURITY_CHANGE;
  3688. aisFsmStateAbort(prAdapter, DISCONNECT_REASON_CODE_DEAUTHENTICATED, FALSE);
  3689. }
  3690. /*----------------------------------------------------------------------------*/
  3691. /*!
  3692. * \brief This function is to inform AIS that DEAUTH frame has been
  3693. * sent and thus state machine could go ahead
  3694. *
  3695. * \param[in] prAdapter Pointer of ADAPTER_T
  3696. * \param[in] prMsduInfo Pointer of MSDU_INFO_T for DEAUTH frame
  3697. * \param[in] prAdapter Pointer of ADAPTER_T
  3698. *
  3699. * \return WLAN_STATUS_SUCCESS
  3700. */
  3701. /*----------------------------------------------------------------------------*/
  3702. WLAN_STATUS
  3703. aisDeauthXmitComplete(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  3704. {
  3705. P_AIS_FSM_INFO_T prAisFsmInfo;
  3706. ASSERT(prAdapter);
  3707. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3708. if (rTxDoneStatus == TX_RESULT_SUCCESS)
  3709. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rDeauthDoneTimer);
  3710. if (prAisFsmInfo->eCurrentState == AIS_STATE_DISCONNECTING) {
  3711. if (rTxDoneStatus != TX_RESULT_DROPPED_IN_DRIVER)
  3712. aisFsmStateAbort(prAdapter, DISCONNECT_REASON_CODE_NEW_CONNECTION, FALSE);
  3713. } else {
  3714. DBGLOG(AIS, WARN, "DEAUTH frame transmitted without further handling");
  3715. }
  3716. return WLAN_STATUS_SUCCESS;
  3717. } /* end of aisDeauthXmitComplete() */
  3718. #if CFG_SUPPORT_ROAMING
  3719. /*----------------------------------------------------------------------------*/
  3720. /*!
  3721. * @brief This function will indicate an Event of "Looking for a candidate due to weak signal" to AIS FSM.
  3722. *
  3723. * @param[in] u4ReqScan Requesting Scan or not
  3724. *
  3725. * @return (none)
  3726. */
  3727. /*----------------------------------------------------------------------------*/
  3728. VOID aisFsmRunEventRoamingDiscovery(IN P_ADAPTER_T prAdapter, UINT_32 u4ReqScan)
  3729. {
  3730. P_AIS_FSM_INFO_T prAisFsmInfo;
  3731. P_CONNECTION_SETTINGS_T prConnSettings;
  3732. ENUM_AIS_REQUEST_TYPE_T eAisRequest;
  3733. DBGLOG(AIS, LOUD, "aisFsmRunEventRoamingDiscovery()\n");
  3734. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3735. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3736. /* search candidates by best rssi */
  3737. prConnSettings->eConnectionPolicy = CONNECT_BY_SSID_BEST_RSSI;
  3738. #if CFG_SUPPORT_WFD
  3739. #if CFG_ENABLE_WIFI_DIRECT
  3740. {
  3741. /* Check WFD is running */
  3742. P_BSS_INFO_T prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  3743. P_WFD_CFG_SETTINGS_T prWfdCfgSettings = (P_WFD_CFG_SETTINGS_T) NULL;
  3744. if (prAdapter->fgIsP2PRegistered &&
  3745. IS_BSS_ACTIVE(prP2pBssInfo) &&
  3746. (prP2pBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT ||
  3747. prP2pBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE)) {
  3748. DBGLOG(ROAMING, INFO, "Handle roaming when P2P is GC or GO.\n");
  3749. if (prAdapter->rWifiVar.prP2pFsmInfo) {
  3750. prWfdCfgSettings = &(prAdapter->rWifiVar.prP2pFsmInfo->rWfdConfigureSettings);
  3751. if ((prWfdCfgSettings->ucWfdEnable == 1) &&
  3752. ((prWfdCfgSettings->u4WfdFlag & WFD_FLAGS_DEV_INFO_VALID))) {
  3753. DBGLOG(ROAMING, INFO, "WFD is running. Stop roaming.\n");
  3754. roamingFsmRunEventRoam(prAdapter);
  3755. roamingFsmRunEventFail(prAdapter, ROAMING_FAIL_REASON_NOCANDIDATE);
  3756. return;
  3757. }
  3758. } else {
  3759. ASSERT(0);
  3760. }
  3761. } /* fgIsP2PRegistered */
  3762. }
  3763. #endif
  3764. #endif
  3765. /* results are still new */
  3766. if (!u4ReqScan) {
  3767. roamingFsmRunEventRoam(prAdapter);
  3768. eAisRequest = AIS_REQUEST_ROAMING_CONNECT;
  3769. } else {
  3770. if (prAisFsmInfo->eCurrentState == AIS_STATE_ONLINE_SCAN
  3771. || prAisFsmInfo->eCurrentState == AIS_STATE_LOOKING_FOR) {
  3772. eAisRequest = AIS_REQUEST_ROAMING_CONNECT;
  3773. } else {
  3774. eAisRequest = AIS_REQUEST_ROAMING_SEARCH;
  3775. }
  3776. }
  3777. if (prAisFsmInfo->eCurrentState == AIS_STATE_NORMAL_TR && prAisFsmInfo->fgIsInfraChannelFinished == TRUE) {
  3778. if (eAisRequest == AIS_REQUEST_ROAMING_SEARCH)
  3779. aisFsmSteps(prAdapter, AIS_STATE_LOOKING_FOR);
  3780. else
  3781. aisFsmSteps(prAdapter, AIS_STATE_SEARCH);
  3782. } else {
  3783. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_SEARCH, TRUE);
  3784. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, TRUE);
  3785. aisFsmInsertRequest(prAdapter, eAisRequest);
  3786. }
  3787. } /* end of aisFsmRunEventRoamingDiscovery() */
  3788. /*----------------------------------------------------------------------------*/
  3789. /*!
  3790. * @brief Update the time of ScanDone for roaming and transit to Roam state.
  3791. *
  3792. * @param (none)
  3793. *
  3794. * @return (none)
  3795. */
  3796. /*----------------------------------------------------------------------------*/
  3797. ENUM_AIS_STATE_T aisFsmRoamingScanResultsUpdate(IN P_ADAPTER_T prAdapter)
  3798. {
  3799. P_AIS_FSM_INFO_T prAisFsmInfo;
  3800. P_ROAMING_INFO_T prRoamingFsmInfo;
  3801. ENUM_AIS_STATE_T eNextState;
  3802. DBGLOG(AIS, LOUD, "->aisFsmRoamingScanResultsUpdate()\n");
  3803. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3804. prRoamingFsmInfo = (P_ROAMING_INFO_T) &(prAdapter->rWifiVar.rRoamingInfo);
  3805. roamingFsmScanResultsUpdate(prAdapter);
  3806. eNextState = prAisFsmInfo->eCurrentState;
  3807. if (prRoamingFsmInfo->eCurrentState == ROAMING_STATE_DISCOVERY) {
  3808. roamingFsmRunEventRoam(prAdapter);
  3809. eNextState = AIS_STATE_SEARCH;
  3810. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_LOOKING_FOR) {
  3811. eNextState = AIS_STATE_SEARCH;
  3812. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_ONLINE_SCAN) {
  3813. eNextState = AIS_STATE_NORMAL_TR;
  3814. }
  3815. return eNextState;
  3816. } /* end of aisFsmRoamingScanResultsUpdate() */
  3817. /*----------------------------------------------------------------------------*/
  3818. /*!
  3819. * @brief This function will modify and update necessary information to firmware
  3820. * for disconnection of last AP before switching to roaming bss.
  3821. *
  3822. * @param IN prAdapter Pointer to the Adapter structure.
  3823. * prTargetStaRec Target of StaRec of roaming
  3824. *
  3825. * @retval None
  3826. */
  3827. /*----------------------------------------------------------------------------*/
  3828. VOID aisFsmRoamingDisconnectPrevAP(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prTargetStaRec)
  3829. {
  3830. P_BSS_INFO_T prAisBssInfo;
  3831. DBGLOG(AIS, LOUD, "aisFsmRoamingDisconnectPrevAP()");
  3832. ASSERT(prAdapter);
  3833. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3834. nicPmIndicateBssAbort(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3835. /* Not invoke rlmBssAborted() here to avoid prAisBssInfo->fg40mBwAllowed
  3836. * to be reset. RLM related parameters will be reset again when handling
  3837. * association response in rlmProcessAssocRsp(). 20110413
  3838. */
  3839. /* rlmBssAborted(prAdapter, prAisBssInfo); */
  3840. /* 4 <3> Unset the fgIsConnected flag of BSS_DESC_T and send Deauth if needed. */
  3841. if (PARAM_MEDIA_STATE_CONNECTED == prAisBssInfo->eConnectionState)
  3842. scanRemoveConnFlagOfBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  3843. /* 4 <4> Change Media State immediately. */
  3844. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
  3845. /* 4 <4.1> sync. with firmware */
  3846. prTargetStaRec->ucNetTypeIndex = 0xff; /* Virtial NetType */
  3847. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3848. prTargetStaRec->ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX; /* Virtial NetType */
  3849. #if (CFG_SUPPORT_TDLS == 1)
  3850. TdlsexLinkHistoryRecord(prAdapter->prGlueInfo, TRUE, prAisBssInfo->aucBSSID,
  3851. TRUE, TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_ROAMING);
  3852. #endif /* CFG_SUPPORT_TDLS */
  3853. } /* end of aisFsmRoamingDisconnectPrevAP() */
  3854. /*----------------------------------------------------------------------------*/
  3855. /*!
  3856. * @brief This function will update the contain of BSS_INFO_T for AIS network once
  3857. * the roaming was completed.
  3858. *
  3859. * @param IN prAdapter Pointer to the Adapter structure.
  3860. * prStaRec StaRec of roaming AP
  3861. * prAssocRspSwRfb
  3862. *
  3863. * @retval None
  3864. */
  3865. /*----------------------------------------------------------------------------*/
  3866. VOID aisUpdateBssInfoForRoamingAP(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec, IN P_SW_RFB_T prAssocRspSwRfb)
  3867. {
  3868. P_BSS_INFO_T prAisBssInfo;
  3869. DBGLOG(AIS, LOUD, "aisUpdateBssInfoForRoamingAP()");
  3870. ASSERT(prAdapter);
  3871. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3872. /* 4 <1.1> Change FW's Media State immediately. */
  3873. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_CONNECTED);
  3874. /* 4 <1.2> Deactivate previous AP's STA_RECORD_T in Driver if have. */
  3875. if ((prAisBssInfo->prStaRecOfAP) &&
  3876. (prAisBssInfo->prStaRecOfAP != prStaRec) && (prAisBssInfo->prStaRecOfAP->fgIsInUse)) {
  3877. cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP, STA_STATE_1);
  3878. }
  3879. /* 4 <1.3> Update BSS_INFO_T */
  3880. aisUpdateBssInfoForJOIN(prAdapter, prStaRec, prAssocRspSwRfb);
  3881. /* 4 <1.4> Activate current AP's STA_RECORD_T in Driver. */
  3882. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  3883. /* 4 <1.6> Indicate Connected Event to Host immediately. */
  3884. /* Require BSSID, Association ID, Beacon Interval.. from AIS_BSS_INFO_T */
  3885. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_CONNECTED, FALSE);
  3886. } /* end of aisFsmRoamingUpdateBss() */
  3887. #endif /* CFG_SUPPORT_ROAMING */
  3888. /*----------------------------------------------------------------------------*/
  3889. /*!
  3890. * @brief Check if there is any pending request and remove it (optional)
  3891. *
  3892. * @param prAdapter
  3893. * eReqType
  3894. * bRemove
  3895. *
  3896. * @return TRUE
  3897. * FALSE
  3898. */
  3899. /*----------------------------------------------------------------------------*/
  3900. BOOLEAN aisFsmIsRequestPending(IN P_ADAPTER_T prAdapter, IN ENUM_AIS_REQUEST_TYPE_T eReqType, IN BOOLEAN bRemove)
  3901. {
  3902. P_AIS_FSM_INFO_T prAisFsmInfo;
  3903. P_AIS_REQ_HDR_T prPendingReqHdr, prPendingReqHdrNext;
  3904. ASSERT(prAdapter);
  3905. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3906. /* traverse through pending request list */
  3907. LINK_FOR_EACH_ENTRY_SAFE(prPendingReqHdr,
  3908. prPendingReqHdrNext, &(prAisFsmInfo->rPendingReqList), rLinkEntry, AIS_REQ_HDR_T) {
  3909. /* check for specified type */
  3910. if (prPendingReqHdr->eReqType == eReqType) {
  3911. /* check if need to remove */
  3912. if (bRemove == TRUE) {
  3913. LINK_REMOVE_KNOWN_ENTRY(&(prAisFsmInfo->rPendingReqList),
  3914. &(prPendingReqHdr->rLinkEntry));
  3915. cnmMemFree(prAdapter, prPendingReqHdr);
  3916. }
  3917. return TRUE;
  3918. }
  3919. }
  3920. return FALSE;
  3921. }
  3922. /*----------------------------------------------------------------------------*/
  3923. /*!
  3924. * @brief Get next pending request
  3925. *
  3926. * @param prAdapter
  3927. *
  3928. * @return P_AIS_REQ_HDR_T
  3929. */
  3930. /*----------------------------------------------------------------------------*/
  3931. P_AIS_REQ_HDR_T aisFsmGetNextRequest(IN P_ADAPTER_T prAdapter)
  3932. {
  3933. P_AIS_FSM_INFO_T prAisFsmInfo;
  3934. P_AIS_REQ_HDR_T prPendingReqHdr;
  3935. ASSERT(prAdapter);
  3936. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3937. LINK_REMOVE_HEAD(&(prAisFsmInfo->rPendingReqList), prPendingReqHdr, P_AIS_REQ_HDR_T);
  3938. return prPendingReqHdr;
  3939. }
  3940. /*----------------------------------------------------------------------------*/
  3941. /*!
  3942. * @brief Insert a new request
  3943. *
  3944. * @param prAdapter
  3945. * eReqType
  3946. *
  3947. * @return TRUE
  3948. * FALSE
  3949. */
  3950. /*----------------------------------------------------------------------------*/
  3951. BOOLEAN aisFsmInsertRequest(IN P_ADAPTER_T prAdapter, IN ENUM_AIS_REQUEST_TYPE_T eReqType)
  3952. {
  3953. P_AIS_REQ_HDR_T prAisReq;
  3954. P_AIS_FSM_INFO_T prAisFsmInfo;
  3955. ASSERT(prAdapter);
  3956. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3957. prAisReq = (P_AIS_REQ_HDR_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(AIS_REQ_HDR_T));
  3958. if (!prAisReq) {
  3959. ASSERT(0); /* Can't generate new message */
  3960. return FALSE;
  3961. }
  3962. prAisReq->eReqType = eReqType;
  3963. /* attach request into pending request list */
  3964. LINK_INSERT_TAIL(&prAisFsmInfo->rPendingReqList, &prAisReq->rLinkEntry);
  3965. return TRUE;
  3966. }
  3967. /*----------------------------------------------------------------------------*/
  3968. /*!
  3969. * @brief Flush all pending requests
  3970. *
  3971. * @param prAdapter
  3972. *
  3973. * @return (none)
  3974. */
  3975. /*----------------------------------------------------------------------------*/
  3976. VOID aisFsmFlushRequest(IN P_ADAPTER_T prAdapter)
  3977. {
  3978. P_AIS_REQ_HDR_T prAisReq;
  3979. ASSERT(prAdapter);
  3980. while ((prAisReq = aisFsmGetNextRequest(prAdapter)) != NULL)
  3981. cnmMemFree(prAdapter, prAisReq);
  3982. }
  3983. VOID aisFsmRunEventRemainOnChannel(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  3984. {
  3985. P_MSG_REMAIN_ON_CHANNEL_T prRemainOnChannel;
  3986. P_AIS_FSM_INFO_T prAisFsmInfo;
  3987. P_CONNECTION_SETTINGS_T prConnSettings;
  3988. DEBUGFUNC("aisFsmRunEventRemainOnChannel()");
  3989. ASSERT(prAdapter);
  3990. ASSERT(prMsgHdr);
  3991. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3992. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3993. prRemainOnChannel = (P_MSG_REMAIN_ON_CHANNEL_T) prMsgHdr;
  3994. /* record parameters */
  3995. prAisFsmInfo->rChReqInfo.eBand = prRemainOnChannel->eBand;
  3996. prAisFsmInfo->rChReqInfo.eSco = prRemainOnChannel->eSco;
  3997. prAisFsmInfo->rChReqInfo.ucChannelNum = prRemainOnChannel->ucChannelNum;
  3998. prAisFsmInfo->rChReqInfo.u4DurationMs = prRemainOnChannel->u4DurationMs;
  3999. prAisFsmInfo->rChReqInfo.u8Cookie = prRemainOnChannel->u8Cookie;
  4000. if (prAisFsmInfo->eCurrentState == AIS_STATE_IDLE || prAisFsmInfo->eCurrentState == AIS_STATE_NORMAL_TR) {
  4001. /* transit to next state */
  4002. aisFsmSteps(prAdapter, AIS_STATE_REQ_REMAIN_ON_CHANNEL);
  4003. } else {
  4004. aisFsmInsertRequest(prAdapter, AIS_REQUEST_REMAIN_ON_CHANNEL);
  4005. }
  4006. /* free messages */
  4007. cnmMemFree(prAdapter, prMsgHdr);
  4008. }
  4009. VOID aisFsmRunEventCancelRemainOnChannel(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  4010. {
  4011. P_AIS_FSM_INFO_T prAisFsmInfo;
  4012. P_BSS_INFO_T prAisBssInfo;
  4013. P_MSG_CANCEL_REMAIN_ON_CHANNEL_T prCancelRemainOnChannel;
  4014. ASSERT(prAdapter);
  4015. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4016. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  4017. prCancelRemainOnChannel = (P_MSG_CANCEL_REMAIN_ON_CHANNEL_T) prMsgHdr;
  4018. /* 1. Check the cookie first */
  4019. if (prCancelRemainOnChannel->u8Cookie == prAisFsmInfo->rChReqInfo.u8Cookie) {
  4020. /* 2. release channel privilege/request */
  4021. if (prAisFsmInfo->eCurrentState == AIS_STATE_REQ_REMAIN_ON_CHANNEL) {
  4022. /* 2.1 elease channel */
  4023. aisFsmReleaseCh(prAdapter);
  4024. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_REMAIN_ON_CHANNEL) {
  4025. /* 2.1 release channel */
  4026. aisFsmReleaseCh(prAdapter);
  4027. /* 2.2 stop channel timeout timer */
  4028. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer);
  4029. }
  4030. /* 3. clear pending request of remain_on_channel */
  4031. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_REMAIN_ON_CHANNEL, TRUE);
  4032. /* 4. decide which state to retreat */
  4033. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED)
  4034. aisFsmSteps(prAdapter, AIS_STATE_NORMAL_TR);
  4035. else
  4036. aisFsmSteps(prAdapter, AIS_STATE_IDLE);
  4037. }
  4038. /* 5. free message */
  4039. cnmMemFree(prAdapter, prMsgHdr);
  4040. }
  4041. VOID aisFsmRunEventMgmtFrameTx(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  4042. {
  4043. P_AIS_FSM_INFO_T prAisFsmInfo;
  4044. P_MSG_MGMT_TX_REQUEST_T prMgmtTxMsg = (P_MSG_MGMT_TX_REQUEST_T) NULL;
  4045. do {
  4046. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  4047. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4048. /* prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]); */
  4049. if (prAisFsmInfo == NULL)
  4050. break;
  4051. prMgmtTxMsg = (P_MSG_MGMT_TX_REQUEST_T) prMsgHdr;
  4052. aisFuncTxMgmtFrame(prAdapter,
  4053. &prAisFsmInfo->rMgmtTxInfo, prMgmtTxMsg->prMgmtMsduInfo, prMgmtTxMsg->u8Cookie);
  4054. } while (FALSE);
  4055. if (prMsgHdr)
  4056. cnmMemFree(prAdapter, prMsgHdr);
  4057. } /* aisFsmRunEventMgmtFrameTx */
  4058. VOID aisFsmRunEventChannelTimeout(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  4059. {
  4060. P_AIS_FSM_INFO_T prAisFsmInfo;
  4061. P_BSS_INFO_T prAisBssInfo;
  4062. DEBUGFUNC("aisFsmRunEventRemainOnChannel()");
  4063. ASSERT(prAdapter);
  4064. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4065. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  4066. if (prAisFsmInfo->eCurrentState == AIS_STATE_REMAIN_ON_CHANNEL) {
  4067. /* 1. release channel */
  4068. aisFsmReleaseCh(prAdapter);
  4069. /* 2. stop channel timeout timer */
  4070. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer);
  4071. /* 3. expiration indication to upper layer */
  4072. kalRemainOnChannelExpired(prAdapter->prGlueInfo,
  4073. prAisFsmInfo->rChReqInfo.u8Cookie,
  4074. prAisFsmInfo->rChReqInfo.eBand,
  4075. prAisFsmInfo->rChReqInfo.eSco, prAisFsmInfo->rChReqInfo.ucChannelNum);
  4076. /* 4. decide which state to retreat */
  4077. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED)
  4078. aisFsmSteps(prAdapter, AIS_STATE_NORMAL_TR);
  4079. else
  4080. aisFsmSteps(prAdapter, AIS_STATE_IDLE);
  4081. } else {
  4082. DBGLOG(AIS, WARN, "Unexpected remain_on_channel timeout event\n");
  4083. #if DBG
  4084. DBGLOG(AIS, STATE, "CURRENT State: [%s]\n", apucDebugAisState[prAisFsmInfo->eCurrentState]);
  4085. #else
  4086. DBGLOG(AIS, STATE, "[%d] CURRENT State: [%d]\n", DBG_AIS_IDX, prAisFsmInfo->eCurrentState);
  4087. #endif
  4088. }
  4089. }
  4090. WLAN_STATUS
  4091. aisFsmRunEventMgmtFrameTxDone(IN P_ADAPTER_T prAdapter,
  4092. IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  4093. {
  4094. P_AIS_FSM_INFO_T prAisFsmInfo;
  4095. P_AIS_MGMT_TX_REQ_INFO_T prMgmtTxReqInfo = (P_AIS_MGMT_TX_REQ_INFO_T) NULL;
  4096. BOOLEAN fgIsSuccess = FALSE;
  4097. do {
  4098. ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
  4099. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4100. prMgmtTxReqInfo = &(prAisFsmInfo->rMgmtTxInfo);
  4101. if (rTxDoneStatus != TX_RESULT_SUCCESS) {
  4102. DBGLOG(AIS, ERROR, "Mgmt Frame TX Fail, Status:%d.\n", rTxDoneStatus);
  4103. } else {
  4104. fgIsSuccess = TRUE;
  4105. /* printk("Mgmt Frame TX Done.\n"); */
  4106. }
  4107. if (prMgmtTxReqInfo->prMgmtTxMsdu == prMsduInfo) {
  4108. kalIndicateMgmtTxStatus(prAdapter->prGlueInfo,
  4109. prMgmtTxReqInfo->u8Cookie,
  4110. fgIsSuccess, prMsduInfo->prPacket, (UINT_32) prMsduInfo->u2FrameLength);
  4111. prMgmtTxReqInfo->prMgmtTxMsdu = NULL;
  4112. }
  4113. } while (FALSE);
  4114. return WLAN_STATUS_SUCCESS;
  4115. } /* aisFsmRunEventMgmtFrameTxDone */
  4116. WLAN_STATUS
  4117. aisFuncTxMgmtFrame(IN P_ADAPTER_T prAdapter,
  4118. IN P_AIS_MGMT_TX_REQ_INFO_T prMgmtTxReqInfo, IN P_MSDU_INFO_T prMgmtTxMsdu, IN UINT_64 u8Cookie)
  4119. {
  4120. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  4121. P_MSDU_INFO_T prTxMsduInfo = (P_MSDU_INFO_T) NULL;
  4122. P_WLAN_MAC_HEADER_T prWlanHdr = (P_WLAN_MAC_HEADER_T) NULL;
  4123. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  4124. do {
  4125. ASSERT_BREAK((prAdapter != NULL) && (prMgmtTxReqInfo != NULL));
  4126. if (prMgmtTxReqInfo->fgIsMgmtTxRequested) {
  4127. /* 1. prMgmtTxReqInfo->prMgmtTxMsdu != NULL */
  4128. /* Packet on driver, not done yet, drop it. */
  4129. prTxMsduInfo = prMgmtTxReqInfo->prMgmtTxMsdu;
  4130. if (prTxMsduInfo != NULL) {
  4131. kalIndicateMgmtTxStatus(prAdapter->prGlueInfo,
  4132. prMgmtTxReqInfo->u8Cookie,
  4133. FALSE,
  4134. prTxMsduInfo->prPacket, (UINT_32) prTxMsduInfo->u2FrameLength);
  4135. /* Leave it to TX Done handler. */
  4136. /* cnmMgtPktFree(prAdapter, prTxMsduInfo); */
  4137. prMgmtTxReqInfo->prMgmtTxMsdu = NULL;
  4138. }
  4139. /* 2. prMgmtTxReqInfo->prMgmtTxMsdu == NULL */
  4140. /* Packet transmitted, wait tx done. (cookie issue) */
  4141. }
  4142. ASSERT(prMgmtTxReqInfo->prMgmtTxMsdu == NULL);
  4143. prWlanHdr = (P_WLAN_MAC_HEADER_T) ((ULONG) prMgmtTxMsdu->prPacket + MAC_TX_RESERVED_FIELD);
  4144. prStaRec = cnmGetStaRecByAddress(prAdapter, NETWORK_TYPE_AIS_INDEX, prWlanHdr->aucAddr1);
  4145. prMgmtTxMsdu->ucNetworkType = (UINT_8) NETWORK_TYPE_AIS_INDEX;
  4146. prMgmtTxReqInfo->u8Cookie = u8Cookie;
  4147. prMgmtTxReqInfo->prMgmtTxMsdu = prMgmtTxMsdu;
  4148. prMgmtTxReqInfo->fgIsMgmtTxRequested = TRUE;
  4149. prMgmtTxMsdu->eSrc = TX_PACKET_MGMT;
  4150. prMgmtTxMsdu->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
  4151. prMgmtTxMsdu->ucStaRecIndex = (prStaRec != NULL) ? (prStaRec->ucIndex) : (0xFF);
  4152. if (prStaRec != NULL) {
  4153. /* Do nothing */
  4154. /* printk("Mgmt with station record: %pM .\n", prStaRec->aucMacAddr); */
  4155. }
  4156. prMgmtTxMsdu->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN; /* TODO: undcertain. */
  4157. prMgmtTxMsdu->fgIs802_1x = FALSE;
  4158. prMgmtTxMsdu->fgIs802_11 = TRUE;
  4159. prMgmtTxMsdu->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
  4160. prMgmtTxMsdu->pfTxDoneHandler = aisFsmRunEventMgmtFrameTxDone;
  4161. prMgmtTxMsdu->fgIsBasicRate = TRUE;
  4162. DBGLOG(AIS, TRACE, "Mgmt seq NO. %d .\n", prMgmtTxMsdu->ucTxSeqNum);
  4163. nicTxEnqueueMsdu(prAdapter, prMgmtTxMsdu);
  4164. } while (FALSE);
  4165. return rWlanStatus;
  4166. } /* aisFuncTxMgmtFrame */
  4167. /*----------------------------------------------------------------------------*/
  4168. /*!
  4169. * @brief This function will validate the Rx Action Frame and indicate to uppoer layer
  4170. * if the specified conditions were matched.
  4171. *
  4172. * @param[in] prAdapter Pointer to the Adapter structure.
  4173. * @param[in] prSwRfb Pointer to SW RFB data structure.
  4174. * @param[out] pu4ControlFlags Control flags for replying the Probe Response
  4175. *
  4176. * @retval none
  4177. */
  4178. /*----------------------------------------------------------------------------*/
  4179. VOID aisFuncValidateRxActionFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  4180. {
  4181. P_AIS_FSM_INFO_T prAisFsmInfo = (P_AIS_FSM_INFO_T) NULL;
  4182. DEBUGFUNC("aisFuncValidateRxActionFrame");
  4183. do {
  4184. ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
  4185. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4186. if (1 /* prAisFsmInfo->u4AisPacketFilter & PARAM_PACKET_FILTER_ACTION_FRAME */) {
  4187. /* Leave the action frame to wpa_supplicant. */
  4188. kalIndicateRxMgmtFrame(prAdapter->prGlueInfo, prSwRfb);
  4189. }
  4190. } while (FALSE);
  4191. return;
  4192. } /* aisFuncValidateRxActionFrame */