ais_fsm.c 163 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976
  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. /* 4 <A> Try to SCAN */
  1747. if (prAisFsmInfo->fgTryScan) {
  1748. eNextState = AIS_STATE_LOOKING_FOR;
  1749. fgIsTransition = TRUE;
  1750. break;
  1751. }
  1752. /* 4 <B> We've do SCAN already, now wait in some STATE. */
  1753. if (prConnSettings->eOPMode == NET_TYPE_INFRA) {
  1754. /* issue reconnect request,
  1755. * and retreat to idle state for scheduling */
  1756. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  1757. eNextState = AIS_STATE_IDLE;
  1758. fgIsTransition = TRUE;
  1759. }
  1760. #if CFG_SUPPORT_ADHOC
  1761. else if ((prConnSettings->eOPMode == NET_TYPE_IBSS)
  1762. || (prConnSettings->eOPMode == NET_TYPE_AUTO_SWITCH)
  1763. || (prConnSettings->eOPMode == NET_TYPE_DEDICATED_IBSS)) {
  1764. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  1765. prAisFsmInfo->prTargetBssDesc = NULL;
  1766. eNextState = AIS_STATE_IBSS_ALONE;
  1767. fgIsTransition = TRUE;
  1768. }
  1769. #endif /* CFG_SUPPORT_ADHOC */
  1770. else {
  1771. ASSERT(0);
  1772. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  1773. fgIsTransition = TRUE;
  1774. }
  1775. }
  1776. }
  1777. /* 4 <3> We are under Roaming Condition. */
  1778. else { /* prAdapter->eConnectionState == MEDIA_STATE_CONNECTED. */
  1779. /* 4 <3.a> This BSS_DESC_T is our AP. */
  1780. /* NOTE(Kevin 2008/05/16): Following cases will go back to NORMAL_TR.
  1781. * CASE I: During Roaming, APP(WZC/NDISTEST) change the connection
  1782. * settings. That make we can NOT match the original AP, so the
  1783. * prBssDesc is NULL.
  1784. * CASE II: The same reason as CASE I. Because APP change the
  1785. * eOPMode to other network type in connection setting
  1786. * (e.g. NET_TYPE_IBSS), so the BssDesc become the IBSS node.
  1787. * (For CASE I/II, before WZC/NDISTEST set the OID_SSID, it will change
  1788. * other parameters in connection setting first. So if we do roaming
  1789. * at the same time, it will hit these cases.)
  1790. *
  1791. * CASE III: Normal case, we can't find other candidate to roam
  1792. * out, so only the current AP will be matched.
  1793. *
  1794. * CASE IV: Timestamp of the current AP might be reset
  1795. */
  1796. if (prAisBssInfo->ucReasonOfDisconnect != DISCONNECT_REASON_CODE_REASSOCIATION &&
  1797. ((!prBssDesc) || /* CASE I */
  1798. (prBssDesc->eBSSType != BSS_TYPE_INFRASTRUCTURE) || /* CASE II */
  1799. (prBssDesc->fgIsConnected) || /* CASE III */
  1800. (EQUAL_MAC_ADDR(prBssDesc->aucBSSID, prAisBssInfo->aucBSSID))) /* CASE IV */) {
  1801. #if DBG
  1802. if ((prBssDesc) && (prBssDesc->fgIsConnected))
  1803. ASSERT(EQUAL_MAC_ADDR(prBssDesc->aucBSSID, prAisBssInfo->aucBSSID));
  1804. #endif /* DBG */
  1805. /* We already associated with it, go back to NORMAL_TR */
  1806. /* TODO(Kevin): Roaming Fail */
  1807. #if CFG_SUPPORT_ROAMING
  1808. roamingFsmRunEventFail(prAdapter, ROAMING_FAIL_REASON_NOCANDIDATE);
  1809. #endif /* CFG_SUPPORT_ROAMING */
  1810. /* Retreat to NORMAL_TR state */
  1811. eNextState = AIS_STATE_NORMAL_TR;
  1812. fgIsTransition = TRUE;
  1813. break;
  1814. }
  1815. /* 4 <3.b> Try to roam out for JOIN this BSS_DESC_T. */
  1816. if (prBssDesc == NULL) {
  1817. /* increase connection trial count for infrastructure connection */
  1818. if (prConnSettings->eOPMode == NET_TYPE_INFRA)
  1819. prAisFsmInfo->ucConnTrialCount++;
  1820. /* 4 <A> Try to SCAN */
  1821. if (prAisFsmInfo->fgTryScan) {
  1822. eNextState = AIS_STATE_LOOKING_FOR;
  1823. fgIsTransition = TRUE;
  1824. break;
  1825. }
  1826. /* 4 <B> We've do SCAN already, now wait in some STATE. */
  1827. if (prConnSettings->eOPMode == NET_TYPE_INFRA) {
  1828. /* issue reconnect request, and retreat to idle state
  1829. * for scheduling */
  1830. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  1831. eNextState = AIS_STATE_IDLE;
  1832. fgIsTransition = TRUE;
  1833. }
  1834. #if CFG_SUPPORT_ADHOC
  1835. else if ((prConnSettings->eOPMode == NET_TYPE_IBSS)
  1836. || (prConnSettings->eOPMode == NET_TYPE_AUTO_SWITCH)
  1837. || (prConnSettings->eOPMode ==
  1838. NET_TYPE_DEDICATED_IBSS)) {
  1839. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  1840. prAisFsmInfo->prTargetBssDesc = NULL;
  1841. eNextState = AIS_STATE_IBSS_ALONE;
  1842. fgIsTransition = TRUE;
  1843. }
  1844. #endif /* CFG_SUPPORT_ADHOC */
  1845. else {
  1846. ASSERT(0);
  1847. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  1848. fgIsTransition = TRUE;
  1849. }
  1850. } else {
  1851. #if DBG
  1852. if (prAisBssInfo->ucReasonOfDisconnect !=
  1853. DISCONNECT_REASON_CODE_REASSOCIATION) {
  1854. ASSERT(UNEQUAL_MAC_ADDR
  1855. (prBssDesc->aucBSSID, prAisBssInfo->aucBSSID));
  1856. }
  1857. #endif /* DBG */
  1858. /* 4 <A> Record the target BSS_DESC_T for next STATE. */
  1859. prAisFsmInfo->prTargetBssDesc = prBssDesc;
  1860. /* tyhsu: increase connection trial count */
  1861. prAisFsmInfo->ucConnTrialCount++;
  1862. /* Transit to channel acquire */
  1863. eNextState = AIS_STATE_REQ_CHANNEL_JOIN;
  1864. fgIsTransition = TRUE;
  1865. }
  1866. }
  1867. break;
  1868. case AIS_STATE_WAIT_FOR_NEXT_SCAN:
  1869. DBGLOG(AIS, LOUD, "SCAN: Idle Begin - Current Time = %u\n", kalGetTimeTick());
  1870. cnmTimerStartTimer(prAdapter,
  1871. &prAisFsmInfo->rBGScanTimer, SEC_TO_MSEC(prAisFsmInfo->u4SleepInterval));
  1872. SET_NET_PWR_STATE_IDLE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1873. if (prAisFsmInfo->u4SleepInterval < AIS_BG_SCAN_INTERVAL_MAX_SEC)
  1874. prAisFsmInfo->u4SleepInterval <<= 1;
  1875. break;
  1876. case AIS_STATE_SCAN:
  1877. case AIS_STATE_ONLINE_SCAN:
  1878. case AIS_STATE_LOOKING_FOR:
  1879. if (!IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX)) {
  1880. SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1881. /* sync with firmware */
  1882. nicActivateNetwork(prAdapter, NETWORK_TYPE_AIS_INDEX);
  1883. }
  1884. /* IE length decision */
  1885. if (prAisFsmInfo->u4ScanIELength > 0) {
  1886. u2ScanIELen = (UINT_16) prAisFsmInfo->u4ScanIELength;
  1887. } else {
  1888. #if CFG_SUPPORT_WPS2
  1889. u2ScanIELen = prAdapter->prGlueInfo->u2WSCIELen;
  1890. #else
  1891. u2ScanIELen = 0;
  1892. #endif
  1893. }
  1894. prScanReqMsg = (P_MSG_SCN_SCAN_REQ) cnmMemAlloc(prAdapter,
  1895. RAM_TYPE_MSG,
  1896. OFFSET_OF(MSG_SCN_SCAN_REQ,
  1897. aucIE) + u2ScanIELen);
  1898. if (!prScanReqMsg) {
  1899. ASSERT(0); /* Can't trigger SCAN FSM */
  1900. return;
  1901. }
  1902. prScanReqMsg->rMsgHdr.eMsgId = MID_AIS_SCN_SCAN_REQ;
  1903. prScanReqMsg->ucSeqNum = ++prAisFsmInfo->ucSeqNumOfScanReq;
  1904. prScanReqMsg->ucNetTypeIndex = (UINT_8) NETWORK_TYPE_AIS_INDEX;
  1905. #if CFG_SUPPORT_RDD_TEST_MODE
  1906. prScanReqMsg->eScanType = SCAN_TYPE_PASSIVE_SCAN;
  1907. #else
  1908. prScanReqMsg->eScanType = SCAN_TYPE_ACTIVE_SCAN;
  1909. #endif
  1910. #if CFG_SUPPORT_ROAMING_ENC
  1911. if (prAdapter->fgIsRoamingEncEnabled == TRUE) {
  1912. if (prAisFsmInfo->eCurrentState == AIS_STATE_LOOKING_FOR &&
  1913. prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  1914. prScanReqMsg->u2ChannelDwellTime = AIS_ROAMING_SCAN_CHANNEL_DWELL_TIME;
  1915. }
  1916. }
  1917. #endif /* CFG_SUPPORT_ROAMING_ENC */
  1918. if (prAisFsmInfo->eCurrentState == AIS_STATE_SCAN
  1919. || prAisFsmInfo->eCurrentState == AIS_STATE_ONLINE_SCAN) {
  1920. if (prAisFsmInfo->ucScanSSIDLen == 0) {
  1921. /* Scan for all available SSID */
  1922. prScanReqMsg->ucSSIDType = SCAN_REQ_SSID_WILDCARD;
  1923. } else {
  1924. prScanReqMsg->ucSSIDType = SCAN_REQ_SSID_SPECIFIED;
  1925. COPY_SSID(prScanReqMsg->aucSSID,
  1926. prScanReqMsg->ucSSIDLength,
  1927. prAisFsmInfo->aucScanSSID, prAisFsmInfo->ucScanSSIDLen);
  1928. }
  1929. } else {
  1930. /* Scan for determined SSID */
  1931. prScanReqMsg->ucSSIDType = SCAN_REQ_SSID_SPECIFIED;
  1932. COPY_SSID(prScanReqMsg->aucSSID,
  1933. prScanReqMsg->ucSSIDLength,
  1934. prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  1935. }
  1936. /* check if tethering is running and need to fix on specific channel */
  1937. if (cnmAisInfraChannelFixed(prAdapter, &eBand, &ucChannel) == TRUE) {
  1938. prScanReqMsg->eScanChannel = SCAN_CHANNEL_SPECIFIED;
  1939. prScanReqMsg->ucChannelListNum = 1;
  1940. prScanReqMsg->arChnlInfoList[0].eBand = eBand;
  1941. prScanReqMsg->arChnlInfoList[0].ucChannelNum = ucChannel;
  1942. } else if (prAdapter->aePreferBand[NETWORK_TYPE_AIS_INDEX] == BAND_NULL) {
  1943. if (prAdapter->fgEnable5GBand == TRUE)
  1944. prScanReqMsg->eScanChannel = SCAN_CHANNEL_FULL;
  1945. else
  1946. prScanReqMsg->eScanChannel = SCAN_CHANNEL_2G4;
  1947. } else if (prAdapter->aePreferBand[NETWORK_TYPE_AIS_INDEX] == BAND_2G4) {
  1948. prScanReqMsg->eScanChannel = SCAN_CHANNEL_2G4;
  1949. } else if (prAdapter->aePreferBand[NETWORK_TYPE_AIS_INDEX] == BAND_5G) {
  1950. prScanReqMsg->eScanChannel = SCAN_CHANNEL_5G;
  1951. } else {
  1952. prScanReqMsg->eScanChannel = SCAN_CHANNEL_FULL;
  1953. ASSERT(0);
  1954. }
  1955. if (prAisFsmInfo->u4ScanIELength > 0) {
  1956. kalMemCopy(prScanReqMsg->aucIE, prAisFsmInfo->aucScanIEBuf,
  1957. prAisFsmInfo->u4ScanIELength);
  1958. } else {
  1959. #if CFG_SUPPORT_WPS2
  1960. if (prAdapter->prGlueInfo->u2WSCIELen > 0) {
  1961. kalMemCopy(prScanReqMsg->aucIE, &prAdapter->prGlueInfo->aucWSCIE,
  1962. prAdapter->prGlueInfo->u2WSCIELen);
  1963. }
  1964. }
  1965. #endif
  1966. prScanReqMsg->u2IELen = u2ScanIELen;
  1967. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prScanReqMsg, MSG_SEND_METHOD_BUF);
  1968. DBGLOG(AIS, TRACE, "SendSR%d\n", prScanReqMsg->ucSeqNum);
  1969. prAisFsmInfo->fgTryScan = FALSE; /* Will enable background sleep for infrastructure */
  1970. prAdapter->ucScanTime++;
  1971. break;
  1972. case AIS_STATE_REQ_CHANNEL_JOIN:
  1973. /* send message to CNM for acquiring channel */
  1974. prMsgChReq = (P_MSG_CH_REQ_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_REQ_T));
  1975. if (!prMsgChReq) {
  1976. ASSERT(0); /* Can't indicate CNM for channel acquiring */
  1977. return;
  1978. }
  1979. prMsgChReq->rMsgHdr.eMsgId = MID_MNY_CNM_CH_REQ;
  1980. prMsgChReq->ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX;
  1981. prMsgChReq->ucTokenID = ++prAisFsmInfo->ucSeqNumOfChReq;
  1982. prMsgChReq->eReqType = CH_REQ_TYPE_JOIN;
  1983. prMsgChReq->u4MaxInterval = AIS_JOIN_CH_REQUEST_INTERVAL;
  1984. if (prAisFsmInfo->prTargetBssDesc != NULL) {
  1985. prMsgChReq->ucPrimaryChannel = prAisFsmInfo->prTargetBssDesc->ucChannelNum;
  1986. prMsgChReq->eRfSco = prAisFsmInfo->prTargetBssDesc->eSco;
  1987. prMsgChReq->eRfBand = prAisFsmInfo->prTargetBssDesc->eBand;
  1988. COPY_MAC_ADDR(prMsgChReq->aucBSSID, prAisFsmInfo->prTargetBssDesc->aucBSSID);
  1989. }
  1990. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgChReq, MSG_SEND_METHOD_BUF);
  1991. prAisFsmInfo->fgIsChannelRequested = TRUE;
  1992. break;
  1993. case AIS_STATE_JOIN:
  1994. aisFsmStateInit_JOIN(prAdapter, prAisFsmInfo->prTargetBssDesc);
  1995. break;
  1996. #if CFG_SUPPORT_ADHOC
  1997. case AIS_STATE_IBSS_ALONE:
  1998. aisFsmStateInit_IBSS_ALONE(prAdapter);
  1999. break;
  2000. case AIS_STATE_IBSS_MERGE:
  2001. aisFsmStateInit_IBSS_MERGE(prAdapter, prAisFsmInfo->prTargetBssDesc);
  2002. break;
  2003. #endif /* CFG_SUPPORT_ADHOC */
  2004. case AIS_STATE_NORMAL_TR:
  2005. if (prAisFsmInfo->fgIsInfraChannelFinished == FALSE) {
  2006. /* Don't do anything when rJoinTimeoutTimer is still ticking */
  2007. } else {
  2008. /* 1. Process for pending scan */
  2009. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, TRUE) == TRUE) {
  2010. wlanClearScanningResult(prAdapter);
  2011. eNextState = AIS_STATE_ONLINE_SCAN;
  2012. fgIsTransition = TRUE;
  2013. }
  2014. /* 2. Process for pending roaming scan */
  2015. else if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_SEARCH, TRUE) == TRUE) {
  2016. eNextState = AIS_STATE_LOOKING_FOR;
  2017. fgIsTransition = TRUE;
  2018. }
  2019. /* 3. Process for pending roaming scan */
  2020. else if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, TRUE) == TRUE) {
  2021. eNextState = AIS_STATE_SEARCH;
  2022. fgIsTransition = TRUE;
  2023. } else if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_REMAIN_ON_CHANNEL, TRUE) ==
  2024. TRUE) {
  2025. eNextState = AIS_STATE_REQ_REMAIN_ON_CHANNEL;
  2026. fgIsTransition = TRUE;
  2027. }
  2028. }
  2029. break;
  2030. case AIS_STATE_DISCONNECTING:
  2031. /* send for deauth frame for disconnection */
  2032. authSendDeauthFrame(prAdapter,
  2033. prAisBssInfo->prStaRecOfAP,
  2034. (P_SW_RFB_T) NULL, REASON_CODE_DEAUTH_LEAVING_BSS, aisDeauthXmitComplete);
  2035. cnmTimerStartTimer(prAdapter, &prAisFsmInfo->rDeauthDoneTimer, 100);
  2036. break;
  2037. case AIS_STATE_REQ_REMAIN_ON_CHANNEL:
  2038. /* send message to CNM for acquiring channel */
  2039. prMsgChReq = (P_MSG_CH_REQ_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_REQ_T));
  2040. if (!prMsgChReq) {
  2041. ASSERT(0); /* Can't indicate CNM for channel acquiring */
  2042. return;
  2043. }
  2044. /* release channel */
  2045. aisFsmReleaseCh(prAdapter);
  2046. /* zero-ize */
  2047. kalMemZero(prMsgChReq, sizeof(MSG_CH_REQ_T));
  2048. /* filling */
  2049. prMsgChReq->rMsgHdr.eMsgId = MID_MNY_CNM_CH_REQ;
  2050. prMsgChReq->ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX;
  2051. prMsgChReq->ucTokenID = ++prAisFsmInfo->ucSeqNumOfChReq;
  2052. prMsgChReq->eReqType = CH_REQ_TYPE_JOIN;
  2053. prMsgChReq->u4MaxInterval = prAisFsmInfo->rChReqInfo.u4DurationMs;
  2054. prMsgChReq->ucPrimaryChannel = prAisFsmInfo->rChReqInfo.ucChannelNum;
  2055. prMsgChReq->eRfSco = prAisFsmInfo->rChReqInfo.eSco;
  2056. prMsgChReq->eRfBand = prAisFsmInfo->rChReqInfo.eBand;
  2057. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgChReq, MSG_SEND_METHOD_BUF);
  2058. prAisFsmInfo->fgIsChannelRequested = TRUE;
  2059. break;
  2060. case AIS_STATE_REMAIN_ON_CHANNEL:
  2061. SET_NET_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2062. /* sync with firmware */
  2063. nicActivateNetwork(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2064. break;
  2065. default:
  2066. ASSERT(0); /* Make sure we have handle all STATEs */
  2067. break;
  2068. }
  2069. } while (fgIsTransition);
  2070. return;
  2071. } /* end of aisFsmSteps() */
  2072. /*----------------------------------------------------------------------------*/
  2073. /*!
  2074. * \brief
  2075. *
  2076. * \param[in]
  2077. *
  2078. * \return none
  2079. */
  2080. /*----------------------------------------------------------------------------*/
  2081. UINT_32 ucScanTimeoutTimes = 0;
  2082. VOID aisFsmRunEventScanDone(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  2083. {
  2084. P_MSG_SCN_SCAN_DONE prScanDoneMsg;
  2085. P_AIS_FSM_INFO_T prAisFsmInfo;
  2086. ENUM_AIS_STATE_T eNextState;
  2087. UINT_8 ucSeqNumOfCompMsg;
  2088. P_CONNECTION_SETTINGS_T prConnSettings;
  2089. DEBUGFUNC("aisFsmRunEventScanDone()");
  2090. ASSERT(prAdapter);
  2091. ASSERT(prMsgHdr);
  2092. ucScanTimeoutTimes = 0;
  2093. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2094. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2095. prScanDoneMsg = (P_MSG_SCN_SCAN_DONE) prMsgHdr;
  2096. ASSERT(prScanDoneMsg->ucNetTypeIndex == (UINT_8) NETWORK_TYPE_AIS_INDEX);
  2097. ucSeqNumOfCompMsg = prScanDoneMsg->ucSeqNum;
  2098. cnmMemFree(prAdapter, prMsgHdr);
  2099. eNextState = prAisFsmInfo->eCurrentState;
  2100. if (ucSeqNumOfCompMsg != prAisFsmInfo->ucSeqNumOfScanReq) {
  2101. DBGLOG(AIS, WARN, "SEQ NO of AIS SCN DONE MSG is not matched %d %d.\n",
  2102. ucSeqNumOfCompMsg, prAisFsmInfo->ucSeqNumOfScanReq);
  2103. } else {
  2104. switch (prAisFsmInfo->eCurrentState) {
  2105. case AIS_STATE_SCAN:
  2106. prConnSettings->fgIsScanReqIssued = FALSE;
  2107. /* reset scan IE buffer */
  2108. prAisFsmInfo->u4ScanIELength = 0;
  2109. kalScanDone(prAdapter->prGlueInfo, KAL_NETWORK_TYPE_AIS_INDEX, WLAN_STATUS_SUCCESS);
  2110. eNextState = AIS_STATE_IDLE;
  2111. #if CFG_SUPPORT_AGPS_ASSIST
  2112. scanReportScanResultToAgps(prAdapter);
  2113. #endif
  2114. break;
  2115. case AIS_STATE_ONLINE_SCAN:
  2116. prConnSettings->fgIsScanReqIssued = FALSE;
  2117. /* reset scan IE buffer */
  2118. prAisFsmInfo->u4ScanIELength = 0;
  2119. kalScanDone(prAdapter->prGlueInfo, KAL_NETWORK_TYPE_AIS_INDEX, WLAN_STATUS_SUCCESS);
  2120. #if CFG_SUPPORT_ROAMING
  2121. eNextState = aisFsmRoamingScanResultsUpdate(prAdapter);
  2122. #else
  2123. eNextState = AIS_STATE_NORMAL_TR;
  2124. #endif /* CFG_SUPPORT_ROAMING */
  2125. #if CFG_SUPPORT_AGPS_ASSIST
  2126. scanReportScanResultToAgps(prAdapter);
  2127. #endif
  2128. break;
  2129. case AIS_STATE_LOOKING_FOR:
  2130. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rScanDoneTimer);
  2131. scanReportBss2Cfg80211(prAdapter, BSS_TYPE_INFRASTRUCTURE, NULL);
  2132. #if CFG_SUPPORT_ROAMING
  2133. eNextState = aisFsmRoamingScanResultsUpdate(prAdapter);
  2134. #else
  2135. eNextState = AIS_STATE_SEARCH;
  2136. #endif /* CFG_SUPPORT_ROAMING */
  2137. break;
  2138. default:
  2139. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rScanDoneTimer);
  2140. break;
  2141. }
  2142. }
  2143. if (eNextState != prAisFsmInfo->eCurrentState)
  2144. aisFsmSteps(prAdapter, eNextState);
  2145. } /* end of aisFsmRunEventScanDone() */
  2146. /*----------------------------------------------------------------------------*/
  2147. /*!
  2148. * \brief
  2149. *
  2150. * \param[in]
  2151. *
  2152. * \return none
  2153. */
  2154. /*----------------------------------------------------------------------------*/
  2155. VOID aisFsmRunEventAbort(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  2156. {
  2157. P_MSG_AIS_ABORT_T prAisAbortMsg;
  2158. P_AIS_FSM_INFO_T prAisFsmInfo;
  2159. UINT_8 ucReasonOfDisconnect;
  2160. BOOLEAN fgDelayIndication;
  2161. P_CONNECTION_SETTINGS_T prConnSettings;
  2162. DEBUGFUNC("aisFsmRunEventAbort()");
  2163. ASSERT(prAdapter);
  2164. ASSERT(prMsgHdr);
  2165. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2166. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2167. /* 4 <1> Extract information of Abort Message and then free memory. */
  2168. prAisAbortMsg = (P_MSG_AIS_ABORT_T) prMsgHdr;
  2169. ucReasonOfDisconnect = prAisAbortMsg->ucReasonOfDisconnect;
  2170. fgDelayIndication = prAisAbortMsg->fgDelayIndication;
  2171. cnmMemFree(prAdapter, prMsgHdr);
  2172. #if DBG
  2173. DBGLOG(AIS, STATE, "EVENT-ABORT: Current State %s %d\n",
  2174. apucDebugAisState[prAisFsmInfo->eCurrentState], ucReasonOfDisconnect);
  2175. #else
  2176. DBGLOG(AIS, STATE, "[%d] EVENT-ABORT: Current State [%d %d]\n",
  2177. DBG_AIS_IDX, prAisFsmInfo->eCurrentState, ucReasonOfDisconnect);
  2178. #endif
  2179. GET_CURRENT_SYSTIME(&(prAisFsmInfo->rJoinReqTime));
  2180. /* 4 <2> clear previous pending connection request and insert new one */
  2181. if (ucReasonOfDisconnect == DISCONNECT_REASON_CODE_DEAUTHENTICATED
  2182. || ucReasonOfDisconnect == DISCONNECT_REASON_CODE_DISASSOCIATED) {
  2183. prConnSettings->fgIsDisconnectedByNonRequest = TRUE;
  2184. } else {
  2185. prConnSettings->fgIsDisconnectedByNonRequest = FALSE;
  2186. }
  2187. /* to support user space triggered roaming */
  2188. if (ucReasonOfDisconnect == DISCONNECT_REASON_CODE_ROAMING &&
  2189. prAisFsmInfo->eCurrentState != AIS_STATE_DISCONNECTING) {
  2190. if (prAisFsmInfo->eCurrentState == AIS_STATE_NORMAL_TR &&
  2191. prAisFsmInfo->fgIsInfraChannelFinished == TRUE) {
  2192. aisFsmSteps(prAdapter, AIS_STATE_SEARCH);
  2193. } else {
  2194. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_SEARCH, TRUE);
  2195. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, TRUE);
  2196. aisFsmInsertRequest(prAdapter, AIS_REQUEST_ROAMING_CONNECT);
  2197. }
  2198. return;
  2199. }
  2200. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_RECONNECT, TRUE);
  2201. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  2202. if (prAisFsmInfo->eCurrentState != AIS_STATE_DISCONNECTING) {
  2203. /* 4 <3> invoke abort handler */
  2204. aisFsmStateAbort(prAdapter, ucReasonOfDisconnect, fgDelayIndication);
  2205. }
  2206. } /* end of aisFsmRunEventAbort() */
  2207. /*----------------------------------------------------------------------------*/
  2208. /*!
  2209. * \brief This function handles AIS-FSM abort event/command
  2210. *
  2211. * \param[in] prAdapter Pointer of ADAPTER_T
  2212. * ucReasonOfDisconnect Reason for disonnection
  2213. * fgDelayIndication Option to delay disconnection indication
  2214. *
  2215. * \return none
  2216. */
  2217. /*----------------------------------------------------------------------------*/
  2218. VOID aisFsmStateAbort(IN P_ADAPTER_T prAdapter, UINT_8 ucReasonOfDisconnect, BOOLEAN fgDelayIndication)
  2219. {
  2220. P_AIS_FSM_INFO_T prAisFsmInfo;
  2221. P_BSS_INFO_T prAisBssInfo;
  2222. P_CONNECTION_SETTINGS_T prConnSettings;
  2223. BOOLEAN fgIsCheckConnected;
  2224. ASSERT(prAdapter);
  2225. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2226. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2227. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2228. fgIsCheckConnected = FALSE;
  2229. /* 4 <1> Save information of Abort Message and then free memory. */
  2230. prAisBssInfo->ucReasonOfDisconnect = ucReasonOfDisconnect;
  2231. /* 4 <2> Abort current job. */
  2232. switch (prAisFsmInfo->eCurrentState) {
  2233. case AIS_STATE_IDLE:
  2234. case AIS_STATE_SEARCH:
  2235. break;
  2236. case AIS_STATE_WAIT_FOR_NEXT_SCAN:
  2237. /* Do cancel timer */
  2238. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rBGScanTimer);
  2239. /* in case roaming is triggered */
  2240. fgIsCheckConnected = TRUE;
  2241. break;
  2242. case AIS_STATE_SCAN:
  2243. /* Do abort SCAN */
  2244. aisFsmStateAbort_SCAN(prAdapter);
  2245. /* queue for later handling */
  2246. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, FALSE) == FALSE)
  2247. aisFsmInsertRequest(prAdapter, AIS_REQUEST_SCAN);
  2248. break;
  2249. case AIS_STATE_LOOKING_FOR:
  2250. /* Do abort SCAN */
  2251. aisFsmStateAbort_SCAN(prAdapter);
  2252. /* in case roaming is triggered */
  2253. fgIsCheckConnected = TRUE;
  2254. break;
  2255. case AIS_STATE_REQ_CHANNEL_JOIN:
  2256. /* Release channel to CNM */
  2257. aisFsmReleaseCh(prAdapter);
  2258. /* in case roaming is triggered */
  2259. fgIsCheckConnected = TRUE;
  2260. break;
  2261. case AIS_STATE_JOIN:
  2262. /* Do abort JOIN */
  2263. aisFsmStateAbort_JOIN(prAdapter);
  2264. /* in case roaming is triggered */
  2265. fgIsCheckConnected = TRUE;
  2266. break;
  2267. #if CFG_SUPPORT_ADHOC
  2268. case AIS_STATE_IBSS_ALONE:
  2269. case AIS_STATE_IBSS_MERGE:
  2270. aisFsmStateAbort_IBSS(prAdapter);
  2271. break;
  2272. #endif /* CFG_SUPPORT_ADHOC */
  2273. case AIS_STATE_ONLINE_SCAN:
  2274. /* Do abort SCAN */
  2275. aisFsmStateAbort_SCAN(prAdapter);
  2276. /* queue for later handling */
  2277. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, FALSE) == FALSE)
  2278. aisFsmInsertRequest(prAdapter, AIS_REQUEST_SCAN);
  2279. fgIsCheckConnected = TRUE;
  2280. break;
  2281. case AIS_STATE_NORMAL_TR:
  2282. fgIsCheckConnected = TRUE;
  2283. break;
  2284. case AIS_STATE_DISCONNECTING:
  2285. /* Do abort NORMAL_TR */
  2286. aisFsmStateAbort_NORMAL_TR(prAdapter);
  2287. break;
  2288. case AIS_STATE_REQ_REMAIN_ON_CHANNEL:
  2289. /* release channel */
  2290. aisFsmReleaseCh(prAdapter);
  2291. break;
  2292. case AIS_STATE_REMAIN_ON_CHANNEL:
  2293. /* 1. release channel */
  2294. aisFsmReleaseCh(prAdapter);
  2295. /* 2. stop channel timeout timer */
  2296. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer);
  2297. break;
  2298. default:
  2299. break;
  2300. }
  2301. if (fgIsCheckConnected && (PARAM_MEDIA_STATE_CONNECTED == prAisBssInfo->eConnectionState)) {
  2302. /* switch into DISCONNECTING state for sending DEAUTH if necessary */
  2303. if (prAisBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE &&
  2304. prAisBssInfo->ucReasonOfDisconnect == DISCONNECT_REASON_CODE_NEW_CONNECTION &&
  2305. prAisBssInfo->prStaRecOfAP && prAisBssInfo->prStaRecOfAP->fgIsInUse) {
  2306. aisFsmSteps(prAdapter, AIS_STATE_DISCONNECTING);
  2307. return;
  2308. }
  2309. /* Do abort NORMAL_TR */
  2310. aisFsmStateAbort_NORMAL_TR(prAdapter);
  2311. }
  2312. aisFsmDisconnect(prAdapter, fgDelayIndication);
  2313. } /* end of aisFsmStateAbort() */
  2314. /*----------------------------------------------------------------------------*/
  2315. /*!
  2316. * @brief This function will handle the Join Complete Event from SAA FSM for AIS FSM
  2317. *
  2318. * @param[in] prMsgHdr Message of Join Complete of SAA FSM.
  2319. *
  2320. * @return (none)
  2321. */
  2322. /*----------------------------------------------------------------------------*/
  2323. VOID aisFsmRunEventJoinComplete(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  2324. {
  2325. P_MSG_JOIN_COMP_T prJoinCompMsg;
  2326. P_AIS_FSM_INFO_T prAisFsmInfo;
  2327. ENUM_AIS_STATE_T eNextState;
  2328. P_STA_RECORD_T prStaRec;
  2329. P_SW_RFB_T prAssocRspSwRfb;
  2330. P_BSS_INFO_T prAisBssInfo;
  2331. UINT_8 aucP2pSsid[] = CTIA_MAGIC_SSID;
  2332. OS_SYSTIME rCurrentTime;
  2333. DEBUGFUNC("aisFsmRunEventJoinComplete()");
  2334. ASSERT(prMsgHdr);
  2335. GET_CURRENT_SYSTIME(&rCurrentTime);
  2336. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2337. prJoinCompMsg = (P_MSG_JOIN_COMP_T) prMsgHdr;
  2338. prStaRec = prJoinCompMsg->prStaRec;
  2339. prAssocRspSwRfb = prJoinCompMsg->prSwRfb;
  2340. eNextState = prAisFsmInfo->eCurrentState;
  2341. DBGLOG(AIS, TRACE, "AISOK\n");
  2342. /* Check State and SEQ NUM */
  2343. do {
  2344. if (prAisFsmInfo->eCurrentState != AIS_STATE_JOIN)
  2345. break;
  2346. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2347. /* Check SEQ NUM */
  2348. if (prJoinCompMsg->ucSeqNum == prAisFsmInfo->ucSeqNumOfReqMsg) {
  2349. /* 4 <1> JOIN was successful */
  2350. if (prJoinCompMsg->rJoinStatus == WLAN_STATUS_SUCCESS) {
  2351. /* 1. Reset retry count */
  2352. prAisFsmInfo->ucConnTrialCount = 0;
  2353. prAdapter->rWifiVar.rConnSettings.eReConnectLevel = RECONNECT_LEVEL_MIN;
  2354. /* Completion of roaming */
  2355. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  2356. #if CFG_SUPPORT_ROAMING
  2357. /* 2. Deactivate previous BSS */
  2358. aisFsmRoamingDisconnectPrevAP(prAdapter, prStaRec);
  2359. /* 3. Update bss based on roaming staRec */
  2360. aisUpdateBssInfoForRoamingAP(prAdapter, prStaRec, prAssocRspSwRfb);
  2361. #endif /* CFG_SUPPORT_ROAMING */
  2362. } else {
  2363. /* 4 <1.1> Change FW's Media State immediately. */
  2364. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_CONNECTED);
  2365. /* 4 <1.2> Deactivate previous AP's STA_RECORD_T in Driver if have. */
  2366. if ((prAisBssInfo->prStaRecOfAP) &&
  2367. (prAisBssInfo->prStaRecOfAP != prStaRec) &&
  2368. (prAisBssInfo->prStaRecOfAP->fgIsInUse)) {
  2369. cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP,
  2370. STA_STATE_1);
  2371. }
  2372. /* 4 <1.3> Update BSS_INFO_T */
  2373. aisUpdateBssInfoForJOIN(prAdapter, prStaRec, prAssocRspSwRfb);
  2374. /* 4 <1.4> Activate current AP's STA_RECORD_T in Driver. */
  2375. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  2376. /* 4 <1.5> Update RSSI if necessary */
  2377. nicUpdateRSSI(prAdapter, NETWORK_TYPE_AIS_INDEX,
  2378. (INT_8) (RCPI_TO_dBm(prStaRec->ucRCPI)), 0);
  2379. /* 4 <1.6> Indicate Connected Event to Host immediately. */
  2380. /* Require BSSID, Association ID, Beacon Interval.. */
  2381. /* from AIS_BSS_INFO_T */
  2382. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_CONNECTED,
  2383. FALSE);
  2384. /* add for ctia mode */
  2385. if (EQUAL_SSID
  2386. (aucP2pSsid, CTIA_MAGIC_SSID_LEN, prAisBssInfo->aucSSID,
  2387. prAisBssInfo->ucSSIDLen)) {
  2388. nicEnterCtiaMode(prAdapter, TRUE, FALSE);
  2389. }
  2390. }
  2391. #if CFG_SUPPORT_ROAMING
  2392. /* if bssid is given, it means we no need fw roaming */
  2393. if (prAdapter->rWifiVar.rConnSettings.eConnectionPolicy != CONNECT_BY_BSSID)
  2394. roamingFsmRunEventStart(prAdapter);
  2395. #endif /* CFG_SUPPORT_ROAMING */
  2396. /* clear rJoinReqTime if there is no more framework roaming connect request */
  2397. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, FALSE) == FALSE)
  2398. prAisFsmInfo->rJoinReqTime = 0;
  2399. /* 4 <1.7> Set the Next State of AIS FSM */
  2400. eNextState = AIS_STATE_NORMAL_TR;
  2401. }
  2402. /* 4 <2> JOIN was not successful */
  2403. else {
  2404. /* 4 <2.1> Redo JOIN process with other Auth Type if possible */
  2405. if (aisFsmStateInit_RetryJOIN(prAdapter, prStaRec) == FALSE) {
  2406. P_BSS_DESC_T prBssDesc;
  2407. /* 1. Increase Failure Count */
  2408. prStaRec->ucJoinFailureCount++;
  2409. /* 2. release channel */
  2410. aisFsmReleaseCh(prAdapter);
  2411. /* 3.1 stop join timeout timer */
  2412. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rJoinTimeoutTimer);
  2413. /* 3.2 reset local variable */
  2414. prAisFsmInfo->fgIsInfraChannelFinished = TRUE;
  2415. prBssDesc = scanSearchBssDescByBssid(prAdapter, prStaRec->aucMacAddr);
  2416. if (prBssDesc == NULL) {
  2417. /* it maybe NULL when wlanRemove */
  2418. /*
  2419. (1) UI does wifi off during SAA does auth/assoc procedure.
  2420. (2) We will do LINK_INITIALIZE(&prScanInfo->rBSSDescList);
  2421. in nicUninitMGMT().
  2422. (3) We will handle prMsduInfo->pfTxDoneHandler
  2423. in nicTxRelease().
  2424. (4) prMsduInfo->pfTxDoneHandler will point to
  2425. saaFsmRunEventTxDone().
  2426. (5) Then jump to saaFsmSteps() -> saaFsmSendEventJoinComplete()
  2427. (6) Finally mboxSendMsg() -> aisFsmRunEventJoinComplete().
  2428. (7) In aisFsmRunEventJoinComplete(), we will check
  2429. "prBssDesc = scanSearchBssDescByBssid(prAdapter,
  2430. prStaRec->aucMacAddr);"
  2431. (8) And prBssDesc will be NULL and hangs in
  2432. "ASSERT(prBssDesc->fgIsConnecting);" when DBG=0.
  2433. ASSERT(prBssDesc);
  2434. ASSERT(prBssDesc->fgIsConnecting);
  2435. */
  2436. break;
  2437. }
  2438. /* ASSERT(prBssDesc); */
  2439. /* ASSERT(prBssDesc->fgIsConnecting); */
  2440. prBssDesc->ucJoinFailureCount++;
  2441. if (prBssDesc->ucJoinFailureCount >= SCN_BSS_JOIN_FAIL_THRESOLD) {
  2442. GET_CURRENT_SYSTIME(&prBssDesc->rJoinFailTime);
  2443. DBGLOG(AIS, INFO,
  2444. "Bss %pM join fail %d times,temp disable it at time:%u\n",
  2445. prBssDesc->aucBSSID,
  2446. SCN_BSS_JOIN_FAIL_THRESOLD, prBssDesc->rJoinFailTime);
  2447. }
  2448. if (prBssDesc)
  2449. prBssDesc->fgIsConnecting = FALSE;
  2450. /* 3.3 Free STA-REC */
  2451. if (prStaRec != prAisBssInfo->prStaRecOfAP)
  2452. cnmStaRecFree(prAdapter, prStaRec, FALSE);
  2453. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  2454. #if CFG_SUPPORT_ROAMING
  2455. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  2456. #endif /* CFG_SUPPORT_ROAMING */
  2457. } else if (prAisFsmInfo->rJoinReqTime != 0 &&
  2458. CHECK_FOR_TIMEOUT(rCurrentTime,
  2459. prAisFsmInfo->rJoinReqTime,
  2460. SEC_TO_SYSTIME(AIS_JOIN_TIMEOUT))) {
  2461. /* abort connection trial */
  2462. prAdapter->rWifiVar.rConnSettings.fgIsConnReqIssued = FALSE;
  2463. prAdapter->rWifiVar.rConnSettings.eReConnectLevel = RECONNECT_LEVEL_MIN;
  2464. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  2465. WLAN_STATUS_CONNECT_INDICATION, NULL, 0);
  2466. eNextState = AIS_STATE_IDLE;
  2467. } else {
  2468. /* 4.b send reconnect request */
  2469. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  2470. eNextState = AIS_STATE_IDLE;
  2471. }
  2472. }
  2473. }
  2474. }
  2475. #if DBG
  2476. else
  2477. DBGLOG(AIS, WARN, "SEQ NO of AIS JOIN COMP MSG is not matched.\n");
  2478. #endif /* DBG */
  2479. if (eNextState != prAisFsmInfo->eCurrentState)
  2480. aisFsmSteps(prAdapter, eNextState);
  2481. } while (FALSE);
  2482. if (prAssocRspSwRfb)
  2483. nicRxReturnRFB(prAdapter, prAssocRspSwRfb);
  2484. cnmMemFree(prAdapter, prMsgHdr);
  2485. } /* end of aisFsmRunEventJoinComplete() */
  2486. #if CFG_SUPPORT_ADHOC
  2487. /*----------------------------------------------------------------------------*/
  2488. /*!
  2489. * @brief This function will handle the Grant Msg of IBSS Create which was sent by
  2490. * CNM to indicate that channel was changed for creating IBSS.
  2491. *
  2492. * @param[in] prAdapter Pointer of ADAPTER_T
  2493. *
  2494. * @return (none)
  2495. */
  2496. /*----------------------------------------------------------------------------*/
  2497. VOID aisFsmCreateIBSS(IN P_ADAPTER_T prAdapter)
  2498. {
  2499. P_AIS_FSM_INFO_T prAisFsmInfo;
  2500. ASSERT(prAdapter);
  2501. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2502. do {
  2503. /* Check State */
  2504. if (prAisFsmInfo->eCurrentState == AIS_STATE_IBSS_ALONE)
  2505. aisUpdateBssInfoForCreateIBSS(prAdapter);
  2506. } while (FALSE);
  2507. } /* end of aisFsmCreateIBSS() */
  2508. /*----------------------------------------------------------------------------*/
  2509. /*!
  2510. * @brief This function will handle the Grant Msg of IBSS Merge which was sent by
  2511. * CNM to indicate that channel was changed for merging IBSS.
  2512. *
  2513. * @param[in] prAdapter Pointer of ADAPTER_T
  2514. * @param[in] prStaRec Pointer of STA_RECORD_T for merge
  2515. *
  2516. * @return (none)
  2517. */
  2518. /*----------------------------------------------------------------------------*/
  2519. VOID aisFsmMergeIBSS(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec)
  2520. {
  2521. P_AIS_FSM_INFO_T prAisFsmInfo;
  2522. ENUM_AIS_STATE_T eNextState;
  2523. P_BSS_INFO_T prAisBssInfo;
  2524. ASSERT(prAdapter);
  2525. ASSERT(prStaRec);
  2526. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2527. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2528. do {
  2529. eNextState = prAisFsmInfo->eCurrentState;
  2530. switch (prAisFsmInfo->eCurrentState) {
  2531. case AIS_STATE_IBSS_MERGE:
  2532. {
  2533. P_BSS_DESC_T prBssDesc;
  2534. /* 4 <1.1> Change FW's Media State immediately. */
  2535. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_CONNECTED);
  2536. /* 4 <1.2> Deactivate previous Peers' STA_RECORD_T in Driver if have. */
  2537. bssClearClientList(prAdapter, prAisBssInfo);
  2538. /* 4 <1.3> Unmark connection flag of previous BSS_DESC_T. */
  2539. prBssDesc = scanSearchBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  2540. if (prBssDesc != NULL) {
  2541. prBssDesc->fgIsConnecting = FALSE;
  2542. prBssDesc->fgIsConnected = FALSE;
  2543. }
  2544. /* 4 <1.4> Update BSS_INFO_T */
  2545. aisUpdateBssInfoForMergeIBSS(prAdapter, prStaRec);
  2546. /* 4 <1.5> Add Peers' STA_RECORD_T to Client List */
  2547. bssAddStaRecToClientList(prAdapter, prAisBssInfo, prStaRec);
  2548. /* 4 <1.6> Activate current Peer's STA_RECORD_T in Driver. */
  2549. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  2550. prStaRec->fgIsMerging = FALSE;
  2551. /* 4 <1.7> Enable other features */
  2552. /* 4 <1.8> Indicate Connected Event to Host immediately. */
  2553. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_CONNECTED, FALSE);
  2554. /* 4 <1.9> Set the Next State of AIS FSM */
  2555. eNextState = AIS_STATE_NORMAL_TR;
  2556. /* 4 <1.10> Release channel privilege */
  2557. aisFsmReleaseCh(prAdapter);
  2558. #if CFG_SLT_SUPPORT
  2559. prAdapter->rWifiVar.rSltInfo.prPseudoStaRec = prStaRec;
  2560. #endif
  2561. }
  2562. break;
  2563. default:
  2564. break;
  2565. }
  2566. if (eNextState != prAisFsmInfo->eCurrentState)
  2567. aisFsmSteps(prAdapter, eNextState);
  2568. } while (FALSE);
  2569. } /* end of aisFsmMergeIBSS() */
  2570. /*----------------------------------------------------------------------------*/
  2571. /*!
  2572. * @brief This function will handle the Notification of existing IBSS was found
  2573. * from SCN.
  2574. *
  2575. * @param[in] prMsgHdr Message of Notification of an IBSS was present.
  2576. *
  2577. * @return (none)
  2578. */
  2579. /*----------------------------------------------------------------------------*/
  2580. VOID aisFsmRunEventFoundIBSSPeer(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  2581. {
  2582. P_MSG_AIS_IBSS_PEER_FOUND_T prAisIbssPeerFoundMsg;
  2583. P_AIS_FSM_INFO_T prAisFsmInfo;
  2584. ENUM_AIS_STATE_T eNextState;
  2585. P_STA_RECORD_T prStaRec;
  2586. P_BSS_INFO_T prAisBssInfo;
  2587. P_BSS_DESC_T prBssDesc;
  2588. BOOLEAN fgIsMergeIn;
  2589. ASSERT(prMsgHdr);
  2590. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2591. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2592. prAisIbssPeerFoundMsg = (P_MSG_AIS_IBSS_PEER_FOUND_T) prMsgHdr;
  2593. ASSERT(prAisIbssPeerFoundMsg->ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX);
  2594. prStaRec = prAisIbssPeerFoundMsg->prStaRec;
  2595. ASSERT(prStaRec);
  2596. fgIsMergeIn = prAisIbssPeerFoundMsg->fgIsMergeIn;
  2597. cnmMemFree(prAdapter, prMsgHdr);
  2598. eNextState = prAisFsmInfo->eCurrentState;
  2599. switch (prAisFsmInfo->eCurrentState) {
  2600. case AIS_STATE_IBSS_ALONE:
  2601. {
  2602. /* 4 <1> An IBSS Peer 'merged in'. */
  2603. if (fgIsMergeIn) {
  2604. /* 4 <1.1> Change FW's Media State immediately. */
  2605. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_CONNECTED);
  2606. /* 4 <1.2> Add Peers' STA_RECORD_T to Client List */
  2607. bssAddStaRecToClientList(prAdapter, prAisBssInfo, prStaRec);
  2608. #if CFG_SLT_SUPPORT
  2609. /* 4 <1.3> Mark connection flag of BSS_DESC_T. */
  2610. prBssDesc = scanSearchBssDescByTA(prAdapter, prStaRec->aucMacAddr);
  2611. if (prBssDesc != NULL) {
  2612. prBssDesc->fgIsConnecting = FALSE;
  2613. prBssDesc->fgIsConnected = TRUE;
  2614. } else {
  2615. ASSERT(0); /* Should be able to find a BSS_DESC_T here. */
  2616. }
  2617. /* 4 <1.4> Activate current Peer's STA_RECORD_T in Driver. */
  2618. prStaRec->fgIsQoS = TRUE; /* TODO(Kevin): TBD */
  2619. #else
  2620. /* 4 <1.3> Mark connection flag of BSS_DESC_T. */
  2621. prBssDesc = scanSearchBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  2622. if (prBssDesc != NULL) {
  2623. prBssDesc->fgIsConnecting = FALSE;
  2624. prBssDesc->fgIsConnected = TRUE;
  2625. } else {
  2626. ASSERT(0); /* Should be able to find a BSS_DESC_T here. */
  2627. }
  2628. /* 4 <1.4> Activate current Peer's STA_RECORD_T in Driver. */
  2629. prStaRec->fgIsQoS = FALSE; /* TODO(Kevin): TBD */
  2630. #endif
  2631. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  2632. prStaRec->fgIsMerging = FALSE;
  2633. /* 4 <1.6> sync. to firmware */
  2634. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2635. /* 4 <1.7> Indicate Connected Event to Host immediately. */
  2636. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_CONNECTED, FALSE);
  2637. /* 4 <1.8> indicate PM for connected */
  2638. nicPmIndicateBssConnected(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2639. /* 4 <1.9> Set the Next State of AIS FSM */
  2640. eNextState = AIS_STATE_NORMAL_TR;
  2641. /* 4 <1.10> Release channel privilege */
  2642. aisFsmReleaseCh(prAdapter);
  2643. }
  2644. /* 4 <2> We need 'merge out' to this IBSS */
  2645. else {
  2646. /* 4 <2.1> Get corresponding BSS_DESC_T */
  2647. prBssDesc = scanSearchBssDescByTA(prAdapter, prStaRec->aucMacAddr);
  2648. prAisFsmInfo->prTargetBssDesc = prBssDesc;
  2649. /* 4 <2.2> Set the Next State of AIS FSM */
  2650. eNextState = AIS_STATE_IBSS_MERGE;
  2651. }
  2652. }
  2653. break;
  2654. case AIS_STATE_NORMAL_TR:
  2655. {
  2656. /* 4 <3> An IBSS Peer 'merged in'. */
  2657. if (fgIsMergeIn) {
  2658. /* 4 <3.1> Add Peers' STA_RECORD_T to Client List */
  2659. bssAddStaRecToClientList(prAdapter, prAisBssInfo, prStaRec);
  2660. #if CFG_SLT_SUPPORT
  2661. /* 4 <3.2> Activate current Peer's STA_RECORD_T in Driver. */
  2662. prStaRec->fgIsQoS = TRUE; /* TODO(Kevin): TBD */
  2663. #else
  2664. /* 4 <3.2> Activate current Peer's STA_RECORD_T in Driver. */
  2665. prStaRec->fgIsQoS = FALSE; /* TODO(Kevin): TBD */
  2666. #endif
  2667. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  2668. prStaRec->fgIsMerging = FALSE;
  2669. }
  2670. /* 4 <4> We need 'merge out' to this IBSS */
  2671. else {
  2672. /* 4 <4.1> Get corresponding BSS_DESC_T */
  2673. prBssDesc = scanSearchBssDescByTA(prAdapter, prStaRec->aucMacAddr);
  2674. prAisFsmInfo->prTargetBssDesc = prBssDesc;
  2675. /* 4 <4.2> Set the Next State of AIS FSM */
  2676. eNextState = AIS_STATE_IBSS_MERGE;
  2677. }
  2678. }
  2679. break;
  2680. default:
  2681. break;
  2682. }
  2683. if (eNextState != prAisFsmInfo->eCurrentState)
  2684. aisFsmSteps(prAdapter, eNextState);
  2685. } /* end of aisFsmRunEventFoundIBSSPeer() */
  2686. #endif /* CFG_SUPPORT_ADHOC */
  2687. /*----------------------------------------------------------------------------*/
  2688. /*!
  2689. * @brief This function will indicate the Media State to HOST
  2690. *
  2691. * @param[in] eConnectionState Current Media State
  2692. * @param[in] fgDelayIndication Set TRUE for postponing the Disconnect Indication.
  2693. *
  2694. * @return (none)
  2695. */
  2696. /*----------------------------------------------------------------------------*/
  2697. VOID
  2698. aisIndicationOfMediaStateToHost(IN P_ADAPTER_T prAdapter,
  2699. ENUM_PARAM_MEDIA_STATE_T eConnectionState, BOOLEAN fgDelayIndication)
  2700. {
  2701. EVENT_CONNECTION_STATUS rEventConnStatus;
  2702. P_CONNECTION_SETTINGS_T prConnSettings;
  2703. P_BSS_INFO_T prAisBssInfo;
  2704. P_AIS_FSM_INFO_T prAisFsmInfo;
  2705. DEBUGFUNC("aisIndicationOfMediaStateToHost()");
  2706. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2707. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2708. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2709. /* NOTE(Kevin): Move following line to aisChangeMediaState() macro per CM's request. */
  2710. /* prAisBssInfo->eConnectionState = eConnectionState; */
  2711. /* For indicating the Disconnect Event only if current media state is
  2712. * disconnected and we didn't do indication yet.
  2713. */
  2714. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
  2715. if (prAisBssInfo->eConnectionStateIndicated == eConnectionState)
  2716. return;
  2717. }
  2718. if (!fgDelayIndication) {
  2719. /* 4 <0> Cancel Delay Timer */
  2720. prAisFsmInfo->u4PostponeIndStartTime = 0;
  2721. /* 4 <1> Fill EVENT_CONNECTION_STATUS */
  2722. rEventConnStatus.ucMediaStatus = (UINT_8) eConnectionState;
  2723. if (eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  2724. rEventConnStatus.ucReasonOfDisconnect = DISCONNECT_REASON_CODE_RESERVED;
  2725. if (prAisBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
  2726. rEventConnStatus.ucInfraMode = (UINT_8) NET_TYPE_INFRA;
  2727. rEventConnStatus.u2AID = prAisBssInfo->u2AssocId;
  2728. rEventConnStatus.u2ATIMWindow = 0;
  2729. } else if (prAisBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
  2730. rEventConnStatus.ucInfraMode = (UINT_8) NET_TYPE_IBSS;
  2731. rEventConnStatus.u2AID = 0;
  2732. rEventConnStatus.u2ATIMWindow = prAisBssInfo->u2ATIMWindow;
  2733. } else {
  2734. ASSERT(0);
  2735. }
  2736. COPY_SSID(rEventConnStatus.aucSsid,
  2737. rEventConnStatus.ucSsidLen, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  2738. COPY_MAC_ADDR(rEventConnStatus.aucBssid, prAisBssInfo->aucBSSID);
  2739. rEventConnStatus.u2BeaconPeriod = prAisBssInfo->u2BeaconInterval;
  2740. rEventConnStatus.u4FreqInKHz = nicChannelNum2Freq(prAisBssInfo->ucPrimaryChannel);
  2741. switch (prAisBssInfo->ucNonHTBasicPhyType) {
  2742. case PHY_TYPE_HR_DSSS_INDEX:
  2743. rEventConnStatus.ucNetworkType = (UINT_8) PARAM_NETWORK_TYPE_DS;
  2744. break;
  2745. case PHY_TYPE_ERP_INDEX:
  2746. rEventConnStatus.ucNetworkType = (UINT_8) PARAM_NETWORK_TYPE_OFDM24;
  2747. break;
  2748. case PHY_TYPE_OFDM_INDEX:
  2749. rEventConnStatus.ucNetworkType = (UINT_8) PARAM_NETWORK_TYPE_OFDM5;
  2750. break;
  2751. default:
  2752. ASSERT(0);
  2753. rEventConnStatus.ucNetworkType = (UINT_8) PARAM_NETWORK_TYPE_DS;
  2754. break;
  2755. }
  2756. } else {
  2757. /* Deactivate previous Peers' STA_RECORD_T in Driver if have. */
  2758. bssClearClientList(prAdapter, prAisBssInfo);
  2759. #if CFG_PRIVACY_MIGRATION
  2760. /* Clear the pmkid cache while media disconnect */
  2761. secClearPmkid(prAdapter);
  2762. #endif
  2763. rEventConnStatus.ucReasonOfDisconnect = prAisBssInfo->ucReasonOfDisconnect;
  2764. }
  2765. /* 4 <2> Indication */
  2766. nicMediaStateChange(prAdapter, NETWORK_TYPE_AIS_INDEX, &rEventConnStatus);
  2767. prAisBssInfo->eConnectionStateIndicated = eConnectionState;
  2768. } else {
  2769. /* NOTE: Only delay the Indication of Disconnect Event */
  2770. ASSERT(eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED);
  2771. DBGLOG(AIS, INFO, "Postpone the indication of Disconnect for %d seconds\n",
  2772. prConnSettings->ucDelayTimeOfDisconnectEvent);
  2773. prAisFsmInfo->u4PostponeIndStartTime = kalGetTimeTick();
  2774. }
  2775. } /* end of aisIndicationOfMediaStateToHost() */
  2776. /*----------------------------------------------------------------------------*/
  2777. /*!
  2778. * @brief This function will indicate an Event of "Media Disconnect" to HOST
  2779. *
  2780. * @param[in] u4Param Unused timer parameter
  2781. *
  2782. * @return (none)
  2783. */
  2784. /*----------------------------------------------------------------------------*/
  2785. VOID aisPostponedEventOfDisconnTimeout(IN P_ADAPTER_T prAdapter, IN P_AIS_FSM_INFO_T prAisFsmInfo)
  2786. {
  2787. P_BSS_INFO_T prAisBssInfo;
  2788. P_CONNECTION_SETTINGS_T prConnSettings;
  2789. BOOLEAN fgFound = TRUE;
  2790. /* firstly, check if we have started postpone indication.
  2791. otherwise, give a chance to do join before indicate to host */
  2792. if (prAisFsmInfo->u4PostponeIndStartTime == 0)
  2793. return;
  2794. /* if we're in req channel/join/search state, don't report disconnect. */
  2795. if (prAisFsmInfo->eCurrentState == AIS_STATE_JOIN ||
  2796. prAisFsmInfo->eCurrentState == AIS_STATE_SEARCH ||
  2797. prAisFsmInfo->eCurrentState == AIS_STATE_REQ_CHANNEL_JOIN) {
  2798. DBGLOG(AIS, INFO, "CurrentState: %d, don't report disconnect\n",
  2799. prAisFsmInfo->eCurrentState);
  2800. return;
  2801. }
  2802. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2803. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2804. if (!CHECK_FOR_TIMEOUT(kalGetTimeTick(), prAisFsmInfo->u4PostponeIndStartTime,
  2805. SEC_TO_MSEC(prConnSettings->ucDelayTimeOfDisconnectEvent)))
  2806. return;
  2807. /* 4 <1> Deactivate previous AP's STA_RECORD_T in Driver if have. */
  2808. if (prAisBssInfo->prStaRecOfAP) {
  2809. /* cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP, STA_STATE_1); */
  2810. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  2811. }
  2812. /* 4 <2> Remove all pending connection request */
  2813. while (fgFound)
  2814. fgFound = aisFsmIsRequestPending(prAdapter, AIS_REQUEST_RECONNECT, TRUE);
  2815. if (prAisFsmInfo->eCurrentState == AIS_STATE_LOOKING_FOR)
  2816. prAisFsmInfo->eCurrentState = AIS_STATE_IDLE;
  2817. prConnSettings->fgIsDisconnectedByNonRequest = TRUE;
  2818. prAisBssInfo->u2DeauthReason = REASON_CODE_BEACON_TIMEOUT;
  2819. /* 4 <3> Indicate Disconnected Event to Host immediately. */
  2820. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED, FALSE);
  2821. } /* end of aisPostponedEventOfDisconnTimeout() */
  2822. /*----------------------------------------------------------------------------*/
  2823. /*!
  2824. * @brief This function will update the contain of BSS_INFO_T for AIS network once
  2825. * the association was completed.
  2826. *
  2827. * @param[in] prStaRec Pointer to the STA_RECORD_T
  2828. * @param[in] prAssocRspSwRfb Pointer to SW RFB of ASSOC RESP FRAME.
  2829. *
  2830. * @return (none)
  2831. */
  2832. /*----------------------------------------------------------------------------*/
  2833. VOID aisUpdateBssInfoForJOIN(IN P_ADAPTER_T prAdapter, P_STA_RECORD_T prStaRec, P_SW_RFB_T prAssocRspSwRfb)
  2834. {
  2835. P_AIS_FSM_INFO_T prAisFsmInfo;
  2836. P_BSS_INFO_T prAisBssInfo;
  2837. P_CONNECTION_SETTINGS_T prConnSettings;
  2838. P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame;
  2839. P_BSS_DESC_T prBssDesc;
  2840. UINT_16 u2IELength;
  2841. PUINT_8 pucIE;
  2842. DEBUGFUNC("aisUpdateBssInfoForJOIN()");
  2843. ASSERT(prStaRec);
  2844. ASSERT(prAssocRspSwRfb);
  2845. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2846. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2847. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2848. prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) prAssocRspSwRfb->pvHeader;
  2849. DBGLOG(AIS, TRACE, "Update AIS_BSS_INFO_T and apply settings to MAC\n");
  2850. /* 3 <1> Update BSS_INFO_T from AIS_FSM_INFO_T or User Settings */
  2851. /* 4 <1.1> Setup Operation Mode */
  2852. prAisBssInfo->eCurrentOPMode = OP_MODE_INFRASTRUCTURE;
  2853. /* 4 <1.2> Setup SSID */
  2854. COPY_SSID(prAisBssInfo->aucSSID, prAisBssInfo->ucSSIDLen, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  2855. /* 4 <1.3> Setup Channel, Band */
  2856. prAisBssInfo->ucPrimaryChannel = prAisFsmInfo->prTargetBssDesc->ucChannelNum;
  2857. prAisBssInfo->eBand = prAisFsmInfo->prTargetBssDesc->eBand;
  2858. /* 3 <2> Update BSS_INFO_T from STA_RECORD_T */
  2859. /* 4 <2.1> Save current AP's STA_RECORD_T and current AID */
  2860. prAisBssInfo->prStaRecOfAP = prStaRec;
  2861. prAisBssInfo->u2AssocId = prStaRec->u2AssocId;
  2862. /* 4 <2.2> Setup Capability */
  2863. prAisBssInfo->u2CapInfo = prStaRec->u2CapInfo; /* Use AP's Cap Info as BSS Cap Info */
  2864. if (prAisBssInfo->u2CapInfo & CAP_INFO_SHORT_PREAMBLE)
  2865. prAisBssInfo->fgIsShortPreambleAllowed = TRUE;
  2866. else
  2867. prAisBssInfo->fgIsShortPreambleAllowed = FALSE;
  2868. #if (CFG_SUPPORT_TDLS == 1)
  2869. /* init the TDLS flags */
  2870. prAisBssInfo->fgTdlsIsProhibited = prStaRec->fgTdlsIsProhibited;
  2871. prAisBssInfo->fgTdlsIsChSwProhibited = prStaRec->fgTdlsIsChSwProhibited;
  2872. #endif /* CFG_SUPPORT_TDLS */
  2873. /* 4 <2.3> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
  2874. prAisBssInfo->ucPhyTypeSet = prStaRec->ucDesiredPhyTypeSet;
  2875. prAisBssInfo->ucNonHTBasicPhyType = prStaRec->ucNonHTBasicPhyType;
  2876. prAisBssInfo->u2OperationalRateSet = prStaRec->u2OperationalRateSet;
  2877. prAisBssInfo->u2BSSBasicRateSet = prStaRec->u2BSSBasicRateSet;
  2878. /* 3 <3> Update BSS_INFO_T from SW_RFB_T (Association Resp Frame) */
  2879. /* 4 <3.1> Setup BSSID */
  2880. COPY_MAC_ADDR(prAisBssInfo->aucBSSID, prAssocRspFrame->aucBSSID);
  2881. u2IELength = (UINT_16) ((prAssocRspSwRfb->u2PacketLen - prAssocRspSwRfb->u2HeaderLen) -
  2882. (OFFSET_OF(WLAN_ASSOC_RSP_FRAME_T, aucInfoElem[0]) - WLAN_MAC_MGMT_HEADER_LEN));
  2883. pucIE = prAssocRspFrame->aucInfoElem;
  2884. /* 4 <3.2> Parse WMM and setup QBSS flag */
  2885. /* Parse WMM related IEs and configure HW CRs accordingly */
  2886. mqmProcessAssocRsp(prAdapter, prAssocRspSwRfb, pucIE, u2IELength);
  2887. prAisBssInfo->fgIsQBSS = prStaRec->fgIsQoS;
  2888. /* 3 <4> Update BSS_INFO_T from BSS_DESC_T */
  2889. prBssDesc = scanSearchBssDescByBssid(prAdapter, prAssocRspFrame->aucBSSID);
  2890. if (prBssDesc) {
  2891. prBssDesc->fgIsConnecting = FALSE;
  2892. prBssDesc->fgIsConnected = TRUE;
  2893. prBssDesc->ucJoinFailureCount = 0;
  2894. /* 4 <4.1> Setup MIB for current BSS */
  2895. prAisBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
  2896. } else {
  2897. /* should never happen */
  2898. ASSERT(0);
  2899. }
  2900. /* NOTE: Defer ucDTIMPeriod updating to when beacon is received after connection */
  2901. prAisBssInfo->ucDTIMPeriod = 0;
  2902. prAisBssInfo->u2ATIMWindow = 0;
  2903. prAisBssInfo->ucBeaconTimeoutCount = AIS_BEACON_TIMEOUT_COUNT_INFRA;
  2904. /* 4 <4.2> Update HT information and set channel */
  2905. /* Record HT related parameters in rStaRec and rBssInfo
  2906. * Note: it shall be called before nicUpdateBss()
  2907. */
  2908. rlmProcessAssocRsp(prAdapter, prAssocRspSwRfb, pucIE, u2IELength);
  2909. /* 4 <4.3> Sync with firmware for BSS-INFO */
  2910. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2911. /* 4 <4.4> *DEFER OPERATION* nicPmIndicateBssConnected() will be invoked */
  2912. /* inside scanProcessBeaconAndProbeResp() after 1st beacon is received */
  2913. } /* end of aisUpdateBssInfoForJOIN() */
  2914. #if CFG_SUPPORT_ADHOC
  2915. /*----------------------------------------------------------------------------*/
  2916. /*!
  2917. * @brief This function will create an Ad-Hoc network and start sending Beacon Frames.
  2918. *
  2919. * @param (none)
  2920. *
  2921. * @return (none)
  2922. */
  2923. /*----------------------------------------------------------------------------*/
  2924. VOID aisUpdateBssInfoForCreateIBSS(IN P_ADAPTER_T prAdapter)
  2925. {
  2926. P_AIS_FSM_INFO_T prAisFsmInfo;
  2927. P_BSS_INFO_T prAisBssInfo;
  2928. P_CONNECTION_SETTINGS_T prConnSettings;
  2929. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  2930. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  2931. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2932. if (prAisBssInfo->fgIsBeaconActivated)
  2933. return;
  2934. /* 3 <1> Update BSS_INFO_T per Network Basis */
  2935. /* 4 <1.1> Setup Operation Mode */
  2936. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  2937. /* 4 <1.2> Setup SSID */
  2938. COPY_SSID(prAisBssInfo->aucSSID, prAisBssInfo->ucSSIDLen, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  2939. /* 4 <1.3> Clear current AP's STA_RECORD_T and current AID */
  2940. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  2941. prAisBssInfo->u2AssocId = 0;
  2942. /* 4 <1.4> Setup Channel, Band and Phy Attributes */
  2943. prAisBssInfo->ucPrimaryChannel = prConnSettings->ucAdHocChannelNum;
  2944. prAisBssInfo->eBand = prConnSettings->eAdHocBand;
  2945. if (prAisBssInfo->eBand == BAND_2G4) {
  2946. /* Depend on eBand */
  2947. prAisBssInfo->ucPhyTypeSet = prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11BGN;
  2948. /* Depend on eCurrentOPMode and ucPhyTypeSet */
  2949. prAisBssInfo->ucConfigAdHocAPMode = AD_HOC_MODE_MIXED_11BG;
  2950. } else {
  2951. /* Depend on eBand */
  2952. prAisBssInfo->ucPhyTypeSet = prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11AN;
  2953. /* Depend on eCurrentOPMode and ucPhyTypeSet */
  2954. prAisBssInfo->ucConfigAdHocAPMode = AD_HOC_MODE_11A;
  2955. }
  2956. /* 4 <1.5> Setup MIB for current BSS */
  2957. prAisBssInfo->u2BeaconInterval = prConnSettings->u2BeaconPeriod;
  2958. prAisBssInfo->ucDTIMPeriod = 0;
  2959. prAisBssInfo->u2ATIMWindow = prConnSettings->u2AtimWindow;
  2960. prAisBssInfo->ucBeaconTimeoutCount = AIS_BEACON_TIMEOUT_COUNT_ADHOC;
  2961. #if CFG_PRIVACY_MIGRATION
  2962. if (prConnSettings->eEncStatus == ENUM_ENCRYPTION1_ENABLED ||
  2963. prConnSettings->eEncStatus == ENUM_ENCRYPTION2_ENABLED ||
  2964. prConnSettings->eEncStatus == ENUM_ENCRYPTION3_ENABLED) {
  2965. prAisBssInfo->fgIsProtection = TRUE;
  2966. } else {
  2967. prAisBssInfo->fgIsProtection = FALSE;
  2968. }
  2969. #else
  2970. prAisBssInfo->fgIsProtection = FALSE;
  2971. #endif
  2972. /* 3 <2> Update BSS_INFO_T common part */
  2973. ibssInitForAdHoc(prAdapter, prAisBssInfo);
  2974. /* 3 <3> Set MAC HW */
  2975. /* 4 <3.1> Setup channel and bandwidth */
  2976. rlmBssInitForAPandIbss(prAdapter, prAisBssInfo);
  2977. /* 4 <3.2> use command packets to inform firmware */
  2978. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2979. /* 4 <3.3> enable beaconing */
  2980. bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2981. /* 4 <3.4> Update AdHoc PM parameter */
  2982. nicPmIndicateBssCreated(prAdapter, NETWORK_TYPE_AIS_INDEX);
  2983. /* 3 <4> Set ACTIVE flag. */
  2984. prAisBssInfo->fgIsBeaconActivated = TRUE;
  2985. prAisBssInfo->fgHoldSameBssidForIBSS = TRUE;
  2986. /* 3 <5> Start IBSS Alone Timer */
  2987. cnmTimerStartTimer(prAdapter, &prAisFsmInfo->rIbssAloneTimer, SEC_TO_MSEC(AIS_IBSS_ALONE_TIMEOUT_SEC));
  2988. return;
  2989. } /* end of aisCreateIBSS() */
  2990. /*----------------------------------------------------------------------------*/
  2991. /*!
  2992. * @brief This function will update the contain of BSS_INFO_T for AIS network once
  2993. * the existing IBSS was found.
  2994. *
  2995. * @param[in] prStaRec Pointer to the STA_RECORD_T
  2996. *
  2997. * @return (none)
  2998. */
  2999. /*----------------------------------------------------------------------------*/
  3000. VOID aisUpdateBssInfoForMergeIBSS(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec)
  3001. {
  3002. P_AIS_FSM_INFO_T prAisFsmInfo;
  3003. P_BSS_INFO_T prAisBssInfo;
  3004. P_CONNECTION_SETTINGS_T prConnSettings;
  3005. P_BSS_DESC_T prBssDesc;
  3006. /* UINT_16 u2IELength; */
  3007. /* PUINT_8 pucIE; */
  3008. ASSERT(prStaRec);
  3009. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3010. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3011. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3012. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rIbssAloneTimer);
  3013. if (!prAisBssInfo->fgIsBeaconActivated) {
  3014. /* 3 <1> Update BSS_INFO_T per Network Basis */
  3015. /* 4 <1.1> Setup Operation Mode */
  3016. prAisBssInfo->eCurrentOPMode = OP_MODE_IBSS;
  3017. /* 4 <1.2> Setup SSID */
  3018. COPY_SSID(prAisBssInfo->aucSSID,
  3019. prAisBssInfo->ucSSIDLen, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  3020. /* 4 <1.3> Clear current AP's STA_RECORD_T and current AID */
  3021. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  3022. prAisBssInfo->u2AssocId = 0;
  3023. }
  3024. /* 3 <2> Update BSS_INFO_T from STA_RECORD_T */
  3025. /* 4 <2.1> Setup Capability */
  3026. prAisBssInfo->u2CapInfo = prStaRec->u2CapInfo; /* Use Peer's Cap Info as IBSS Cap Info */
  3027. if (prAisBssInfo->u2CapInfo & CAP_INFO_SHORT_PREAMBLE) {
  3028. prAisBssInfo->fgIsShortPreambleAllowed = TRUE;
  3029. prAisBssInfo->fgUseShortPreamble = TRUE;
  3030. } else {
  3031. prAisBssInfo->fgIsShortPreambleAllowed = FALSE;
  3032. prAisBssInfo->fgUseShortPreamble = FALSE;
  3033. }
  3034. /* 7.3.1.4 For IBSS, the Short Slot Time subfield shall be set to 0. */
  3035. prAisBssInfo->fgUseShortSlotTime = FALSE; /* Set to FALSE for AdHoc */
  3036. prAisBssInfo->u2CapInfo &= ~CAP_INFO_SHORT_SLOT_TIME;
  3037. if (prAisBssInfo->u2CapInfo & CAP_INFO_PRIVACY)
  3038. prAisBssInfo->fgIsProtection = TRUE;
  3039. else
  3040. prAisBssInfo->fgIsProtection = FALSE;
  3041. /* 4 <2.2> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
  3042. prAisBssInfo->ucPhyTypeSet = prStaRec->ucDesiredPhyTypeSet;
  3043. prAisBssInfo->ucNonHTBasicPhyType = prStaRec->ucNonHTBasicPhyType;
  3044. prAisBssInfo->u2OperationalRateSet = prStaRec->u2OperationalRateSet;
  3045. prAisBssInfo->u2BSSBasicRateSet = prStaRec->u2BSSBasicRateSet;
  3046. rateGetDataRatesFromRateSet(prAisBssInfo->u2OperationalRateSet,
  3047. prAisBssInfo->u2BSSBasicRateSet,
  3048. prAisBssInfo->aucAllSupportedRates, &prAisBssInfo->ucAllSupportedRatesLen);
  3049. /* 3 <3> X Update BSS_INFO_T from SW_RFB_T (Association Resp Frame) */
  3050. /* 3 <4> Update BSS_INFO_T from BSS_DESC_T */
  3051. prBssDesc = scanSearchBssDescByTA(prAdapter, prStaRec->aucMacAddr);
  3052. if (prBssDesc) {
  3053. prBssDesc->fgIsConnecting = FALSE;
  3054. prBssDesc->fgIsConnected = TRUE;
  3055. /* 4 <4.1> Setup BSSID */
  3056. COPY_MAC_ADDR(prAisBssInfo->aucBSSID, prBssDesc->aucBSSID);
  3057. /* 4 <4.2> Setup Channel, Band */
  3058. prAisBssInfo->ucPrimaryChannel = prBssDesc->ucChannelNum;
  3059. prAisBssInfo->eBand = prBssDesc->eBand;
  3060. /* 4 <4.3> Setup MIB for current BSS */
  3061. prAisBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
  3062. prAisBssInfo->ucDTIMPeriod = 0;
  3063. prAisBssInfo->u2ATIMWindow = 0; /* TBD(Kevin) */
  3064. prAisBssInfo->ucBeaconTimeoutCount = AIS_BEACON_TIMEOUT_COUNT_ADHOC;
  3065. } else {
  3066. /* should never happen */
  3067. ASSERT(0);
  3068. }
  3069. /* 3 <5> Set MAC HW */
  3070. /* 4 <5.1> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
  3071. {
  3072. UINT_8 ucLowestBasicRateIndex;
  3073. if (!rateGetLowestRateIndexFromRateSet(prAisBssInfo->u2BSSBasicRateSet, &ucLowestBasicRateIndex)) {
  3074. if (prAisBssInfo->ucPhyTypeSet & PHY_TYPE_BIT_OFDM)
  3075. ucLowestBasicRateIndex = RATE_6M_INDEX;
  3076. else
  3077. ucLowestBasicRateIndex = RATE_1M_INDEX;
  3078. }
  3079. prAisBssInfo->ucHwDefaultFixedRateCode =
  3080. aucRateIndex2RateCode[prAisBssInfo->fgUseShortPreamble][ucLowestBasicRateIndex];
  3081. }
  3082. /* 4 <5.2> Setup channel and bandwidth */
  3083. rlmBssInitForAPandIbss(prAdapter, prAisBssInfo);
  3084. /* 4 <5.3> use command packets to inform firmware */
  3085. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3086. /* 4 <5.4> enable beaconing */
  3087. bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3088. /* 4 <5.5> Update AdHoc PM parameter */
  3089. nicPmIndicateBssConnected(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3090. /* 3 <6> Set ACTIVE flag. */
  3091. prAisBssInfo->fgIsBeaconActivated = TRUE;
  3092. prAisBssInfo->fgHoldSameBssidForIBSS = TRUE;
  3093. } /* end of aisUpdateBssInfoForMergeIBSS() */
  3094. /*----------------------------------------------------------------------------*/
  3095. /*!
  3096. * @brief This function will validate the Rx Probe Request Frame and then return
  3097. * result to BSS to indicate if need to send the corresponding Probe Response
  3098. * Frame if the specified conditions were matched.
  3099. *
  3100. * @param[in] prAdapter Pointer to the Adapter structure.
  3101. * @param[in] prSwRfb Pointer to SW RFB data structure.
  3102. * @param[out] pu4ControlFlags Control flags for replying the Probe Response
  3103. *
  3104. * @retval TRUE Reply the Probe Response
  3105. * @retval FALSE Don't reply the Probe Response
  3106. */
  3107. /*----------------------------------------------------------------------------*/
  3108. BOOLEAN aisValidateProbeReq(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, OUT PUINT_32 pu4ControlFlags)
  3109. {
  3110. P_WLAN_MAC_MGMT_HEADER_T prMgtHdr;
  3111. P_BSS_INFO_T prBssInfo;
  3112. P_IE_SSID_T prIeSsid = (P_IE_SSID_T) NULL;
  3113. PUINT_8 pucIE;
  3114. UINT_16 u2IELength;
  3115. UINT_16 u2Offset = 0;
  3116. BOOLEAN fgReplyProbeResp = FALSE;
  3117. ASSERT(prSwRfb);
  3118. ASSERT(pu4ControlFlags);
  3119. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3120. /* 4 <1> Parse Probe Req IE and Get IE ptr (SSID, Supported Rate IE, ...) */
  3121. prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T) prSwRfb->pvHeader;
  3122. u2IELength = prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen;
  3123. pucIE = (PUINT_8) prSwRfb->pvHeader + prSwRfb->u2HeaderLen;
  3124. IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
  3125. if (ELEM_ID_SSID == IE_ID(pucIE)) {
  3126. if ((!prIeSsid) && (IE_LEN(pucIE) <= ELEM_MAX_LEN_SSID))
  3127. prIeSsid = (P_IE_SSID_T) pucIE;
  3128. break;
  3129. }
  3130. } /* end of IE_FOR_EACH */
  3131. /* 4 <2> Check network conditions */
  3132. if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
  3133. if ((prIeSsid) && ((prIeSsid->ucLength == BC_SSID_LEN) || /* WILDCARD SSID */
  3134. EQUAL_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen, /* CURRENT SSID */
  3135. prIeSsid->aucSSID, prIeSsid->ucLength))) {
  3136. fgReplyProbeResp = TRUE;
  3137. }
  3138. }
  3139. return fgReplyProbeResp;
  3140. } /* end of aisValidateProbeReq() */
  3141. #endif /* CFG_SUPPORT_ADHOC */
  3142. /*----------------------------------------------------------------------------*/
  3143. /*!
  3144. * @brief This function will modify and update necessary information to firmware
  3145. * for disconnection handling
  3146. *
  3147. * @param[in] prAdapter Pointer to the Adapter structure.
  3148. *
  3149. * @retval None
  3150. */
  3151. /*----------------------------------------------------------------------------*/
  3152. VOID aisFsmDisconnect(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgDelayIndication)
  3153. {
  3154. P_BSS_INFO_T prAisBssInfo;
  3155. ASSERT(prAdapter);
  3156. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3157. nicPmIndicateBssAbort(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3158. #if CFG_SUPPORT_ADHOC
  3159. if (prAisBssInfo->fgIsBeaconActivated) {
  3160. nicUpdateBeaconIETemplate(prAdapter, IE_UPD_METHOD_DELETE_ALL, NETWORK_TYPE_AIS_INDEX, 0, NULL, 0);
  3161. prAisBssInfo->fgIsBeaconActivated = FALSE;
  3162. }
  3163. #endif
  3164. rlmBssAborted(prAdapter, prAisBssInfo);
  3165. /* 4 <3> Unset the fgIsConnected flag of BSS_DESC_T and send Deauth if needed. */
  3166. if (PARAM_MEDIA_STATE_CONNECTED == prAisBssInfo->eConnectionState) {
  3167. /* add for ctia mode */
  3168. {
  3169. UINT_8 aucP2pSsid[] = CTIA_MAGIC_SSID;
  3170. if (EQUAL_SSID(aucP2pSsid, CTIA_MAGIC_SSID_LEN, prAisBssInfo->aucSSID, prAisBssInfo->ucSSIDLen))
  3171. nicEnterCtiaMode(prAdapter, FALSE, FALSE);
  3172. }
  3173. if (prAisBssInfo->ucReasonOfDisconnect == DISCONNECT_REASON_CODE_RADIO_LOST) {
  3174. scanRemoveBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  3175. /* remove from scanning results as well */
  3176. wlanClearBssInScanningResult(prAdapter, prAisBssInfo->aucBSSID);
  3177. /* trials for re-association */
  3178. if (fgDelayIndication) {
  3179. DBGLOG(AIS, INFO, "try to do re-association due to radio lost!\n");
  3180. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_RECONNECT, TRUE);
  3181. aisFsmInsertRequest(prAdapter, AIS_REQUEST_RECONNECT);
  3182. }
  3183. } else {
  3184. scanRemoveConnFlagOfBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  3185. }
  3186. if (fgDelayIndication) {
  3187. if (OP_MODE_IBSS != prAisBssInfo->eCurrentOPMode)
  3188. prAisBssInfo->fgHoldSameBssidForIBSS = FALSE;
  3189. } else {
  3190. prAisBssInfo->fgHoldSameBssidForIBSS = FALSE;
  3191. }
  3192. } else {
  3193. prAisBssInfo->fgHoldSameBssidForIBSS = FALSE;
  3194. }
  3195. /* 4 <4> Change Media State immediately. */
  3196. if (prAisBssInfo->ucReasonOfDisconnect != DISCONNECT_REASON_CODE_REASSOCIATION) {
  3197. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
  3198. /* 4 <4.1> sync. with firmware */
  3199. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3200. }
  3201. if (!fgDelayIndication) {
  3202. /* 4 <5> Deactivate previous AP's STA_RECORD_T or all Clients in Driver if have. */
  3203. if (prAisBssInfo->prStaRecOfAP) {
  3204. /* cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP, STA_STATE_1); */
  3205. prAisBssInfo->prStaRecOfAP = (P_STA_RECORD_T) NULL;
  3206. }
  3207. }
  3208. #if CFG_SUPPORT_ROAMING
  3209. roamingFsmRunEventAbort(prAdapter);
  3210. /* clear pending roaming connection request */
  3211. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_SEARCH, TRUE);
  3212. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, TRUE);
  3213. #endif /* CFG_SUPPORT_ROAMING */
  3214. /* 4 <6> Indicate Disconnected Event to Host */
  3215. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED, fgDelayIndication);
  3216. /* 4 <7> Trigger AIS FSM */
  3217. aisFsmSteps(prAdapter, AIS_STATE_IDLE);
  3218. } /* end of aisFsmDisconnect() */
  3219. /*----------------------------------------------------------------------------*/
  3220. /*!
  3221. * @brief This function will indicate an Event of Scan done Time-Out to AIS FSM.
  3222. *
  3223. * @param[in] u4Param Unused timer parameter
  3224. *
  3225. * @return (none)
  3226. */
  3227. /*----------------------------------------------------------------------------*/
  3228. UINT_32 IsrCnt = 0, IsrPassCnt = 0, TaskIsrCnt = 0;
  3229. VOID aisFsmRunEventScanDoneTimeOut(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3230. {
  3231. #define SCAN_DONE_TIMEOUT_TIMES_LIMIT 20
  3232. P_AIS_FSM_INFO_T prAisFsmInfo;
  3233. ENUM_AIS_STATE_T eNextState;
  3234. P_CONNECTION_SETTINGS_T prConnSettings;
  3235. GL_HIF_INFO_T *HifInfo;
  3236. UINT_32 u4FwCnt;
  3237. DEBUGFUNC("aisFsmRunEventScanDoneTimeOut()");
  3238. ASSERT(prAdapter);
  3239. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3240. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3241. HifInfo = &prAdapter->prGlueInfo->rHifInfo;
  3242. DBGLOG(AIS, WARN, "aisFsmRunEventScanDoneTimeOut Current[%d]\n", prAisFsmInfo->eCurrentState);
  3243. DBGLOG(AIS, WARN, "Isr/task %u %u %u (0x%x)\n", IsrCnt, IsrPassCnt, TaskIsrCnt, prAdapter->fgIsIntEnable);
  3244. /* dump firmware program counter */
  3245. DBGLOG(AIS, WARN, "CONNSYS FW CPUINFO:\n");
  3246. for (u4FwCnt = 0; u4FwCnt < 16; u4FwCnt++)
  3247. DBGLOG(AIS, WARN, "0x%08x ", MCU_REG_READL(HifInfo, CONN_MCU_CPUPCR));
  3248. ucScanTimeoutTimes++;
  3249. if (ucScanTimeoutTimes > SCAN_DONE_TIMEOUT_TIMES_LIMIT) {
  3250. kalSendAeeWarning("[Scan done timeout more than 20 times!]", __func__);
  3251. glDoChipReset();
  3252. }
  3253. #if 0 /* ALPS02018734: remove trigger assert */
  3254. if (prAdapter->fgTestMode == FALSE) {
  3255. /* Titus - xxx */
  3256. /* assert if and only if in normal mode */
  3257. mtk_wcn_wmt_assert(WMTDRV_TYPE_WIFI, 40);
  3258. }
  3259. #endif
  3260. /* report all scanned frames to upper layer to avoid scanned frame is timeout */
  3261. /* must be put before kalScanDone */
  3262. /* scanReportBss2Cfg80211(prAdapter,BSS_TYPE_INFRASTRUCTURE,NULL); */
  3263. prConnSettings->fgIsScanReqIssued = FALSE;
  3264. kalScanDone(prAdapter->prGlueInfo, KAL_NETWORK_TYPE_AIS_INDEX, WLAN_STATUS_SUCCESS);
  3265. eNextState = prAisFsmInfo->eCurrentState;
  3266. switch (prAisFsmInfo->eCurrentState) {
  3267. case AIS_STATE_SCAN:
  3268. prAisFsmInfo->u4ScanIELength = 0;
  3269. eNextState = AIS_STATE_IDLE;
  3270. break;
  3271. case AIS_STATE_ONLINE_SCAN:
  3272. /* reset scan IE buffer */
  3273. prAisFsmInfo->u4ScanIELength = 0;
  3274. #if CFG_SUPPORT_ROAMING
  3275. eNextState = aisFsmRoamingScanResultsUpdate(prAdapter);
  3276. #else
  3277. eNextState = AIS_STATE_NORMAL_TR;
  3278. #endif /* CFG_SUPPORT_ROAMING */
  3279. break;
  3280. default:
  3281. break;
  3282. }
  3283. /* try to stop scan in CONNSYS */
  3284. aisFsmStateAbort_SCAN(prAdapter);
  3285. /* wlanQueryDebugCode(prAdapter); */ /* display current SCAN FSM in FW, debug use */
  3286. if (eNextState != prAisFsmInfo->eCurrentState)
  3287. aisFsmSteps(prAdapter, eNextState);
  3288. } /* end of aisFsmBGSleepTimeout() */
  3289. /*----------------------------------------------------------------------------*/
  3290. /*!
  3291. * @brief This function will indicate an Event of "Background Scan Time-Out" to AIS FSM.
  3292. *
  3293. * @param[in] u4Param Unused timer parameter
  3294. *
  3295. * @return (none)
  3296. */
  3297. /*----------------------------------------------------------------------------*/
  3298. VOID aisFsmRunEventBGSleepTimeOut(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3299. {
  3300. P_AIS_FSM_INFO_T prAisFsmInfo;
  3301. ENUM_AIS_STATE_T eNextState;
  3302. DEBUGFUNC("aisFsmRunEventBGSleepTimeOut()");
  3303. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3304. eNextState = prAisFsmInfo->eCurrentState;
  3305. switch (prAisFsmInfo->eCurrentState) {
  3306. case AIS_STATE_WAIT_FOR_NEXT_SCAN:
  3307. DBGLOG(AIS, LOUD, "EVENT - SCAN TIMER: Idle End - Current Time = %u\n", kalGetTimeTick());
  3308. eNextState = AIS_STATE_LOOKING_FOR;
  3309. SET_NET_PWR_STATE_ACTIVE(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3310. break;
  3311. default:
  3312. break;
  3313. }
  3314. /* Call aisFsmSteps() when we are going to change AIS STATE */
  3315. if (eNextState != prAisFsmInfo->eCurrentState)
  3316. aisFsmSteps(prAdapter, eNextState);
  3317. } /* end of aisFsmBGSleepTimeout() */
  3318. /*----------------------------------------------------------------------------*/
  3319. /*!
  3320. * @brief This function will indicate an Event of "IBSS ALONE Time-Out" to AIS FSM.
  3321. *
  3322. * @param[in] u4Param Unused timer parameter
  3323. *
  3324. * @return (none)
  3325. */
  3326. /*----------------------------------------------------------------------------*/
  3327. VOID aisFsmRunEventIbssAloneTimeOut(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3328. {
  3329. P_AIS_FSM_INFO_T prAisFsmInfo;
  3330. ENUM_AIS_STATE_T eNextState;
  3331. DEBUGFUNC("aisFsmRunEventIbssAloneTimeOut()");
  3332. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3333. eNextState = prAisFsmInfo->eCurrentState;
  3334. switch (prAisFsmInfo->eCurrentState) {
  3335. case AIS_STATE_IBSS_ALONE:
  3336. /* There is no one participate in our AdHoc during this TIMEOUT Interval
  3337. * so go back to search for a valid IBSS again.
  3338. */
  3339. DBGLOG(AIS, LOUD, "EVENT-IBSS ALONE TIMER: Start pairing\n");
  3340. prAisFsmInfo->fgTryScan = TRUE;
  3341. /* abort timer */
  3342. aisFsmReleaseCh(prAdapter);
  3343. /* Pull back to SEARCH to find candidate again */
  3344. eNextState = AIS_STATE_SEARCH;
  3345. break;
  3346. default:
  3347. break;
  3348. }
  3349. /* Call aisFsmSteps() when we are going to change AIS STATE */
  3350. if (eNextState != prAisFsmInfo->eCurrentState)
  3351. aisFsmSteps(prAdapter, eNextState);
  3352. } /* end of aisIbssAloneTimeOut() */
  3353. /*----------------------------------------------------------------------------*/
  3354. /*!
  3355. * @brief This function will indicate an Event of "Join Time-Out" to AIS FSM.
  3356. *
  3357. * @param[in] u4Param Unused timer parameter
  3358. *
  3359. * @return (none)
  3360. */
  3361. /*----------------------------------------------------------------------------*/
  3362. VOID aisFsmRunEventJoinTimeout(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3363. {
  3364. P_BSS_INFO_T prAisBssInfo;
  3365. P_AIS_FSM_INFO_T prAisFsmInfo;
  3366. ENUM_AIS_STATE_T eNextState;
  3367. OS_SYSTIME rCurrentTime;
  3368. DEBUGFUNC("aisFsmRunEventJoinTimeout()");
  3369. prAisBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
  3370. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3371. eNextState = prAisFsmInfo->eCurrentState;
  3372. GET_CURRENT_SYSTIME(&rCurrentTime);
  3373. switch (prAisFsmInfo->eCurrentState) {
  3374. case AIS_STATE_JOIN:
  3375. DBGLOG(AIS, LOUD, "EVENT- JOIN TIMEOUT\n");
  3376. /* 1. Do abort JOIN */
  3377. aisFsmStateAbort_JOIN(prAdapter);
  3378. /* 2. Increase Join Failure Count */
  3379. prAisFsmInfo->prTargetBssDesc->ucJoinFailureCount++;
  3380. /* For JB nl802.11 */
  3381. if (prAisFsmInfo->prTargetBssDesc->ucJoinFailureCount < JOIN_MAX_RETRY_FAILURE_COUNT) {
  3382. /* 3.1 Retreat to AIS_STATE_SEARCH state for next try */
  3383. eNextState = AIS_STATE_SEARCH;
  3384. } else if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  3385. /* 3.2 Retreat to AIS_STATE_WAIT_FOR_NEXT_SCAN state for next try */
  3386. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  3387. } else if (prAisFsmInfo->rJoinReqTime != 0 &&
  3388. !CHECK_FOR_TIMEOUT(rCurrentTime,
  3389. prAisFsmInfo->rJoinReqTime,
  3390. SEC_TO_SYSTIME(AIS_JOIN_TIMEOUT))) {
  3391. /* 3.3 Retreat to AIS_STATE_WAIT_FOR_NEXT_SCAN state for next try */
  3392. eNextState = AIS_STATE_WAIT_FOR_NEXT_SCAN;
  3393. } else {
  3394. /* 3.4 Retreat to AIS_STATE_JOIN_FAILURE to terminate join operation */
  3395. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_CONNECT_INDICATION, NULL, 0);
  3396. eNextState = AIS_STATE_IDLE;
  3397. }
  3398. break;
  3399. case AIS_STATE_NORMAL_TR:
  3400. /* 1. release channel */
  3401. aisFsmReleaseCh(prAdapter);
  3402. prAisFsmInfo->fgIsInfraChannelFinished = TRUE;
  3403. /* 2. process if there is pending scan */
  3404. if (aisFsmIsRequestPending(prAdapter, AIS_REQUEST_SCAN, TRUE) == TRUE) {
  3405. wlanClearScanningResult(prAdapter);
  3406. eNextState = AIS_STATE_ONLINE_SCAN;
  3407. }
  3408. break;
  3409. default:
  3410. /* release channel */
  3411. aisFsmReleaseCh(prAdapter);
  3412. break;
  3413. }
  3414. /* Call aisFsmSteps() when we are going to change AIS STATE */
  3415. if (eNextState != prAisFsmInfo->eCurrentState)
  3416. aisFsmSteps(prAdapter, eNextState);
  3417. } /* end of aisFsmRunEventJoinTimeout() */
  3418. VOID aisFsmRunEventDeauthTimeout(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  3419. {
  3420. aisDeauthXmitComplete(prAdapter, NULL, TX_RESULT_LIFE_TIMEOUT);
  3421. }
  3422. #if defined(CFG_TEST_MGMT_FSM) && (CFG_TEST_MGMT_FSM != 0)
  3423. /*----------------------------------------------------------------------------*/
  3424. /*!
  3425. * \brief
  3426. *
  3427. * \param[in]
  3428. *
  3429. * \return none
  3430. */
  3431. /*----------------------------------------------------------------------------*/
  3432. VOID aisTest(VOID)
  3433. {
  3434. P_MSG_AIS_ABORT_T prAisAbortMsg;
  3435. P_CONNECTION_SETTINGS_T prConnSettings;
  3436. UINT_8 aucSSID[] = "pci-11n";
  3437. UINT_8 ucSSIDLen = 7;
  3438. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3439. /* Set Connection Request Issued Flag */
  3440. prConnSettings->fgIsConnReqIssued = TRUE;
  3441. prConnSettings->ucSSIDLen = ucSSIDLen;
  3442. kalMemCopy(prConnSettings->aucSSID, aucSSID, ucSSIDLen);
  3443. prAisAbortMsg = (P_MSG_AIS_ABORT_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_AIS_ABORT_T));
  3444. if (!prAisAbortMsg) {
  3445. ASSERT(0); /* Can't trigger SCAN FSM */
  3446. return;
  3447. }
  3448. prAisAbortMsg->rMsgHdr.eMsgId = MID_HEM_AIS_FSM_ABORT;
  3449. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prAisAbortMsg, MSG_SEND_METHOD_BUF);
  3450. wifi_send_msg(INDX_WIFI, MSG_ID_WIFI_IST, 0);
  3451. }
  3452. #endif /* CFG_TEST_MGMT_FSM */
  3453. /*----------------------------------------------------------------------------*/
  3454. /*!
  3455. * \brief This function is used to handle OID_802_11_BSSID_LIST_SCAN
  3456. *
  3457. * \param[in] prAdapter Pointer of ADAPTER_T
  3458. * \param[in] prSsid Pointer of SSID_T if specified
  3459. * \param[in] pucIe Pointer to buffer of extra information elements to be attached
  3460. * \param[in] u4IeLength Length of information elements
  3461. *
  3462. * \return none
  3463. */
  3464. /*----------------------------------------------------------------------------*/
  3465. VOID aisFsmScanRequest(IN P_ADAPTER_T prAdapter, IN P_PARAM_SSID_T prSsid, IN PUINT_8 pucIe, IN UINT_32 u4IeLength)
  3466. {
  3467. P_CONNECTION_SETTINGS_T prConnSettings;
  3468. P_BSS_INFO_T prAisBssInfo;
  3469. P_AIS_FSM_INFO_T prAisFsmInfo;
  3470. DEBUGFUNC("aisFsmScanRequest()");
  3471. ASSERT(prAdapter);
  3472. ASSERT(u4IeLength <= MAX_IE_LENGTH);
  3473. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3474. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3475. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3476. if (!prConnSettings->fgIsScanReqIssued) {
  3477. prConnSettings->fgIsScanReqIssued = TRUE;
  3478. if (prSsid == NULL) {
  3479. prAisFsmInfo->ucScanSSIDLen = 0;
  3480. } else {
  3481. COPY_SSID(prAisFsmInfo->aucScanSSID,
  3482. prAisFsmInfo->ucScanSSIDLen, prSsid->aucSsid, (UINT_8) prSsid->u4SsidLen);
  3483. }
  3484. if (u4IeLength > 0 && u4IeLength <= MAX_IE_LENGTH) {
  3485. prAisFsmInfo->u4ScanIELength = u4IeLength;
  3486. kalMemCopy(prAisFsmInfo->aucScanIEBuf, pucIe, u4IeLength);
  3487. } else {
  3488. prAisFsmInfo->u4ScanIELength = 0;
  3489. }
  3490. if (prAisFsmInfo->eCurrentState == AIS_STATE_NORMAL_TR) {
  3491. if (prAisBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE
  3492. && prAisFsmInfo->fgIsInfraChannelFinished == FALSE) {
  3493. /* 802.1x might not finished yet, pend it for later handling .. */
  3494. aisFsmInsertRequest(prAdapter, AIS_REQUEST_SCAN);
  3495. } else {
  3496. if (prAisFsmInfo->fgIsChannelGranted == TRUE) {
  3497. DBGLOG(AIS, WARN,
  3498. "Scan Request with channel granted for join operation: %d, %d",
  3499. prAisFsmInfo->fgIsChannelGranted, prAisFsmInfo->fgIsChannelRequested);
  3500. }
  3501. /* start online scan */
  3502. wlanClearScanningResult(prAdapter);
  3503. aisFsmSteps(prAdapter, AIS_STATE_ONLINE_SCAN);
  3504. }
  3505. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_IDLE) {
  3506. wlanClearScanningResult(prAdapter);
  3507. aisFsmSteps(prAdapter, AIS_STATE_SCAN);
  3508. } else {
  3509. aisFsmInsertRequest(prAdapter, AIS_REQUEST_SCAN);
  3510. }
  3511. } else {
  3512. DBGLOG(AIS, WARN, "Scan Request dropped. (state: %d)\n", prAisFsmInfo->eCurrentState);
  3513. }
  3514. } /* end of aisFsmScanRequest() */
  3515. /*----------------------------------------------------------------------------*/
  3516. /*!
  3517. * \brief This function is invoked when CNM granted channel privilege
  3518. *
  3519. * \param[in] prAdapter Pointer of ADAPTER_T
  3520. *
  3521. * \return none
  3522. */
  3523. /*----------------------------------------------------------------------------*/
  3524. VOID aisFsmRunEventChGrant(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  3525. {
  3526. P_BSS_INFO_T prAisBssInfo;
  3527. P_AIS_FSM_INFO_T prAisFsmInfo;
  3528. P_MSG_CH_GRANT_T prMsgChGrant;
  3529. UINT_8 ucTokenID;
  3530. UINT_32 u4GrantInterval;
  3531. ASSERT(prAdapter);
  3532. ASSERT(prMsgHdr);
  3533. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3534. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3535. prMsgChGrant = (P_MSG_CH_GRANT_T) prMsgHdr;
  3536. ucTokenID = prMsgChGrant->ucTokenID;
  3537. u4GrantInterval = prMsgChGrant->u4GrantInterval;
  3538. /* 1. free message */
  3539. cnmMemFree(prAdapter, prMsgHdr);
  3540. if (prAisFsmInfo->eCurrentState == AIS_STATE_REQ_CHANNEL_JOIN && prAisFsmInfo->ucSeqNumOfChReq == ucTokenID) {
  3541. /* 2. channel privilege has been approved */
  3542. prAisFsmInfo->u4ChGrantedInterval = u4GrantInterval;
  3543. /* 3. state transition to join/ibss-alone/ibss-merge */
  3544. /* 3.1 set timeout timer in cases join could not be completed */
  3545. cnmTimerStartTimer(prAdapter,
  3546. &prAisFsmInfo->rJoinTimeoutTimer,
  3547. prAisFsmInfo->u4ChGrantedInterval - AIS_JOIN_CH_GRANT_THRESHOLD);
  3548. /* 3.2 set local variable to indicate join timer is ticking */
  3549. prAisFsmInfo->fgIsInfraChannelFinished = FALSE;
  3550. /* 3.3 switch to join state */
  3551. aisFsmSteps(prAdapter, AIS_STATE_JOIN);
  3552. prAisFsmInfo->fgIsChannelGranted = TRUE;
  3553. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_REQ_REMAIN_ON_CHANNEL &&
  3554. prAisFsmInfo->ucSeqNumOfChReq == ucTokenID) {
  3555. /* 2. channel privilege has been approved */
  3556. prAisFsmInfo->u4ChGrantedInterval = u4GrantInterval;
  3557. /* 3.1 set timeout timer in cases upper layer cancel_remain_on_channel never comes */
  3558. cnmTimerStartTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer, prAisFsmInfo->u4ChGrantedInterval);
  3559. /* 3.2 switch to remain_on_channel state */
  3560. aisFsmSteps(prAdapter, AIS_STATE_REMAIN_ON_CHANNEL);
  3561. /* 3.3. indicate upper layer for channel ready */
  3562. kalReadyOnChannel(prAdapter->prGlueInfo,
  3563. prAisFsmInfo->rChReqInfo.u8Cookie,
  3564. prAisFsmInfo->rChReqInfo.eBand,
  3565. prAisFsmInfo->rChReqInfo.eSco,
  3566. prAisFsmInfo->rChReqInfo.ucChannelNum, prAisFsmInfo->rChReqInfo.u4DurationMs);
  3567. prAisFsmInfo->fgIsChannelGranted = TRUE;
  3568. } else { /* mismatched grant */
  3569. /* 2. return channel privilege to CNM immediately */
  3570. aisFsmReleaseCh(prAdapter);
  3571. }
  3572. } /* end of aisFsmRunEventChGrant() */
  3573. /*----------------------------------------------------------------------------*/
  3574. /*!
  3575. * \brief This function is to inform CNM that channel privilege
  3576. * has been released
  3577. *
  3578. * \param[in] prAdapter Pointer of ADAPTER_T
  3579. *
  3580. * \return none
  3581. */
  3582. /*----------------------------------------------------------------------------*/
  3583. VOID aisFsmReleaseCh(IN P_ADAPTER_T prAdapter)
  3584. {
  3585. P_AIS_FSM_INFO_T prAisFsmInfo;
  3586. P_MSG_CH_ABORT_T prMsgChAbort;
  3587. ASSERT(prAdapter);
  3588. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3589. if (prAisFsmInfo->fgIsChannelGranted == TRUE || prAisFsmInfo->fgIsChannelRequested == TRUE) {
  3590. prAisFsmInfo->fgIsChannelRequested = FALSE;
  3591. prAisFsmInfo->fgIsChannelGranted = FALSE;
  3592. /* 1. return channel privilege to CNM immediately */
  3593. prMsgChAbort = (P_MSG_CH_ABORT_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_ABORT_T));
  3594. if (!prMsgChAbort) {
  3595. ASSERT(0); /* Can't release Channel to CNM */
  3596. return;
  3597. }
  3598. prMsgChAbort->rMsgHdr.eMsgId = MID_MNY_CNM_CH_ABORT;
  3599. prMsgChAbort->ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX;
  3600. prMsgChAbort->ucTokenID = prAisFsmInfo->ucSeqNumOfChReq;
  3601. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgChAbort, MSG_SEND_METHOD_BUF);
  3602. }
  3603. } /* end of aisFsmReleaseCh() */
  3604. /*----------------------------------------------------------------------------*/
  3605. /*!
  3606. * \brief This function is to inform AIS that corresponding beacon has not
  3607. * been received for a while and probing is not successful
  3608. *
  3609. * \param[in] prAdapter Pointer of ADAPTER_T
  3610. *
  3611. * \return none
  3612. */
  3613. /*----------------------------------------------------------------------------*/
  3614. VOID aisBssBeaconTimeout(IN P_ADAPTER_T prAdapter)
  3615. {
  3616. P_BSS_INFO_T prAisBssInfo;
  3617. BOOLEAN fgDoAbortIndication = FALSE;
  3618. P_CONNECTION_SETTINGS_T prConnSettings;
  3619. ASSERT(prAdapter);
  3620. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3621. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3622. /* 4 <1> Diagnose Connection for Beacon Timeout Event */
  3623. if (PARAM_MEDIA_STATE_CONNECTED == prAisBssInfo->eConnectionState) {
  3624. if (OP_MODE_INFRASTRUCTURE == prAisBssInfo->eCurrentOPMode) {
  3625. P_STA_RECORD_T prStaRec = prAisBssInfo->prStaRecOfAP;
  3626. if (prStaRec)
  3627. fgDoAbortIndication = TRUE;
  3628. } else if (OP_MODE_IBSS == prAisBssInfo->eCurrentOPMode) {
  3629. fgDoAbortIndication = TRUE;
  3630. }
  3631. }
  3632. /* 4 <2> invoke abort handler */
  3633. if (fgDoAbortIndication) {
  3634. #if 0
  3635. P_CONNECTION_SETTINGS_T prConnSettings;
  3636. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3637. prConnSettings->fgIsDisconnectedByNonRequest = TRUE;
  3638. #endif
  3639. DBGLOG(AIS, INFO, "Beacon Timeout, Remove BSS [%pM]\n", prAisBssInfo->aucBSSID);
  3640. scanRemoveBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  3641. /*
  3642. Note: Cannot change TRUE to FALSE; or you will suffer the problem in
  3643. ALPS01270257/ ALPS01804173
  3644. */
  3645. if (prConnSettings->eReConnectLevel < RECONNECT_LEVEL_USER_SET) {
  3646. prConnSettings->eReConnectLevel = RECONNECT_LEVEL_BEACON_TIMEOUT;
  3647. prConnSettings->fgIsConnReqIssued = TRUE;
  3648. }
  3649. aisFsmStateAbort(prAdapter, DISCONNECT_REASON_CODE_RADIO_LOST, TRUE);
  3650. }
  3651. } /* end of aisBssBeaconTimeout() */
  3652. VOID aisBssSecurityChanged(P_ADAPTER_T prAdapter)
  3653. {
  3654. P_BSS_INFO_T prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3655. prAdapter->rWifiVar.rConnSettings.fgIsDisconnectedByNonRequest = TRUE;
  3656. prAisBssInfo->u2DeauthReason = REASON_CODE_BSS_SECURITY_CHANGE;
  3657. aisFsmStateAbort(prAdapter, DISCONNECT_REASON_CODE_DEAUTHENTICATED, FALSE);
  3658. }
  3659. /*----------------------------------------------------------------------------*/
  3660. /*!
  3661. * \brief This function is to inform AIS that DEAUTH frame has been
  3662. * sent and thus state machine could go ahead
  3663. *
  3664. * \param[in] prAdapter Pointer of ADAPTER_T
  3665. * \param[in] prMsduInfo Pointer of MSDU_INFO_T for DEAUTH frame
  3666. * \param[in] prAdapter Pointer of ADAPTER_T
  3667. *
  3668. * \return WLAN_STATUS_SUCCESS
  3669. */
  3670. /*----------------------------------------------------------------------------*/
  3671. WLAN_STATUS
  3672. aisDeauthXmitComplete(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  3673. {
  3674. P_AIS_FSM_INFO_T prAisFsmInfo;
  3675. ASSERT(prAdapter);
  3676. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3677. if (rTxDoneStatus == TX_RESULT_SUCCESS)
  3678. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rDeauthDoneTimer);
  3679. if (prAisFsmInfo->eCurrentState == AIS_STATE_DISCONNECTING) {
  3680. if (rTxDoneStatus != TX_RESULT_DROPPED_IN_DRIVER)
  3681. aisFsmStateAbort(prAdapter, DISCONNECT_REASON_CODE_NEW_CONNECTION, FALSE);
  3682. } else {
  3683. DBGLOG(AIS, WARN, "DEAUTH frame transmitted without further handling");
  3684. }
  3685. return WLAN_STATUS_SUCCESS;
  3686. } /* end of aisDeauthXmitComplete() */
  3687. #if CFG_SUPPORT_ROAMING
  3688. /*----------------------------------------------------------------------------*/
  3689. /*!
  3690. * @brief This function will indicate an Event of "Looking for a candidate due to weak signal" to AIS FSM.
  3691. *
  3692. * @param[in] u4ReqScan Requesting Scan or not
  3693. *
  3694. * @return (none)
  3695. */
  3696. /*----------------------------------------------------------------------------*/
  3697. VOID aisFsmRunEventRoamingDiscovery(IN P_ADAPTER_T prAdapter, UINT_32 u4ReqScan)
  3698. {
  3699. P_AIS_FSM_INFO_T prAisFsmInfo;
  3700. P_CONNECTION_SETTINGS_T prConnSettings;
  3701. ENUM_AIS_REQUEST_TYPE_T eAisRequest;
  3702. DBGLOG(AIS, LOUD, "aisFsmRunEventRoamingDiscovery()\n");
  3703. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3704. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3705. /* search candidates by best rssi */
  3706. prConnSettings->eConnectionPolicy = CONNECT_BY_SSID_BEST_RSSI;
  3707. #if CFG_SUPPORT_WFD
  3708. #if CFG_ENABLE_WIFI_DIRECT
  3709. {
  3710. /* Check WFD is running */
  3711. P_BSS_INFO_T prP2pBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  3712. P_WFD_CFG_SETTINGS_T prWfdCfgSettings = (P_WFD_CFG_SETTINGS_T) NULL;
  3713. if (prAdapter->fgIsP2PRegistered &&
  3714. IS_BSS_ACTIVE(prP2pBssInfo) &&
  3715. (prP2pBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT ||
  3716. prP2pBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE)) {
  3717. DBGLOG(ROAMING, INFO, "Handle roaming when P2P is GC or GO.\n");
  3718. if (prAdapter->rWifiVar.prP2pFsmInfo) {
  3719. prWfdCfgSettings = &(prAdapter->rWifiVar.prP2pFsmInfo->rWfdConfigureSettings);
  3720. if ((prWfdCfgSettings->ucWfdEnable == 1) &&
  3721. ((prWfdCfgSettings->u4WfdFlag & WFD_FLAGS_DEV_INFO_VALID))) {
  3722. DBGLOG(ROAMING, INFO, "WFD is running. Stop roaming.\n");
  3723. roamingFsmRunEventRoam(prAdapter);
  3724. roamingFsmRunEventFail(prAdapter, ROAMING_FAIL_REASON_NOCANDIDATE);
  3725. return;
  3726. }
  3727. } else {
  3728. ASSERT(0);
  3729. }
  3730. } /* fgIsP2PRegistered */
  3731. }
  3732. #endif
  3733. #endif
  3734. /* results are still new */
  3735. if (!u4ReqScan) {
  3736. roamingFsmRunEventRoam(prAdapter);
  3737. eAisRequest = AIS_REQUEST_ROAMING_CONNECT;
  3738. } else {
  3739. if (prAisFsmInfo->eCurrentState == AIS_STATE_ONLINE_SCAN
  3740. || prAisFsmInfo->eCurrentState == AIS_STATE_LOOKING_FOR) {
  3741. eAisRequest = AIS_REQUEST_ROAMING_CONNECT;
  3742. } else {
  3743. eAisRequest = AIS_REQUEST_ROAMING_SEARCH;
  3744. }
  3745. }
  3746. if (prAisFsmInfo->eCurrentState == AIS_STATE_NORMAL_TR && prAisFsmInfo->fgIsInfraChannelFinished == TRUE) {
  3747. if (eAisRequest == AIS_REQUEST_ROAMING_SEARCH)
  3748. aisFsmSteps(prAdapter, AIS_STATE_LOOKING_FOR);
  3749. else
  3750. aisFsmSteps(prAdapter, AIS_STATE_SEARCH);
  3751. } else {
  3752. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_SEARCH, TRUE);
  3753. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_ROAMING_CONNECT, TRUE);
  3754. aisFsmInsertRequest(prAdapter, eAisRequest);
  3755. }
  3756. } /* end of aisFsmRunEventRoamingDiscovery() */
  3757. /*----------------------------------------------------------------------------*/
  3758. /*!
  3759. * @brief Update the time of ScanDone for roaming and transit to Roam state.
  3760. *
  3761. * @param (none)
  3762. *
  3763. * @return (none)
  3764. */
  3765. /*----------------------------------------------------------------------------*/
  3766. ENUM_AIS_STATE_T aisFsmRoamingScanResultsUpdate(IN P_ADAPTER_T prAdapter)
  3767. {
  3768. P_AIS_FSM_INFO_T prAisFsmInfo;
  3769. P_ROAMING_INFO_T prRoamingFsmInfo;
  3770. ENUM_AIS_STATE_T eNextState;
  3771. DBGLOG(AIS, LOUD, "->aisFsmRoamingScanResultsUpdate()\n");
  3772. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3773. prRoamingFsmInfo = (P_ROAMING_INFO_T) &(prAdapter->rWifiVar.rRoamingInfo);
  3774. roamingFsmScanResultsUpdate(prAdapter);
  3775. eNextState = prAisFsmInfo->eCurrentState;
  3776. if (prRoamingFsmInfo->eCurrentState == ROAMING_STATE_DISCOVERY) {
  3777. roamingFsmRunEventRoam(prAdapter);
  3778. eNextState = AIS_STATE_SEARCH;
  3779. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_LOOKING_FOR) {
  3780. eNextState = AIS_STATE_SEARCH;
  3781. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_ONLINE_SCAN) {
  3782. eNextState = AIS_STATE_NORMAL_TR;
  3783. }
  3784. return eNextState;
  3785. } /* end of aisFsmRoamingScanResultsUpdate() */
  3786. /*----------------------------------------------------------------------------*/
  3787. /*!
  3788. * @brief This function will modify and update necessary information to firmware
  3789. * for disconnection of last AP before switching to roaming bss.
  3790. *
  3791. * @param IN prAdapter Pointer to the Adapter structure.
  3792. * prTargetStaRec Target of StaRec of roaming
  3793. *
  3794. * @retval None
  3795. */
  3796. /*----------------------------------------------------------------------------*/
  3797. VOID aisFsmRoamingDisconnectPrevAP(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prTargetStaRec)
  3798. {
  3799. P_BSS_INFO_T prAisBssInfo;
  3800. DBGLOG(AIS, LOUD, "aisFsmRoamingDisconnectPrevAP()");
  3801. ASSERT(prAdapter);
  3802. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3803. nicPmIndicateBssAbort(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3804. /* Not invoke rlmBssAborted() here to avoid prAisBssInfo->fg40mBwAllowed
  3805. * to be reset. RLM related parameters will be reset again when handling
  3806. * association response in rlmProcessAssocRsp(). 20110413
  3807. */
  3808. /* rlmBssAborted(prAdapter, prAisBssInfo); */
  3809. /* 4 <3> Unset the fgIsConnected flag of BSS_DESC_T and send Deauth if needed. */
  3810. if (PARAM_MEDIA_STATE_CONNECTED == prAisBssInfo->eConnectionState)
  3811. scanRemoveConnFlagOfBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
  3812. /* 4 <4> Change Media State immediately. */
  3813. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_DISCONNECTED);
  3814. /* 4 <4.1> sync. with firmware */
  3815. prTargetStaRec->ucNetTypeIndex = 0xff; /* Virtial NetType */
  3816. nicUpdateBss(prAdapter, NETWORK_TYPE_AIS_INDEX);
  3817. prTargetStaRec->ucNetTypeIndex = NETWORK_TYPE_AIS_INDEX; /* Virtial NetType */
  3818. #if (CFG_SUPPORT_TDLS == 1)
  3819. TdlsexLinkHistoryRecord(prAdapter->prGlueInfo, TRUE, prAisBssInfo->aucBSSID,
  3820. TRUE, TDLS_REASON_CODE_MTK_DIS_BY_US_DUE_TO_ROAMING);
  3821. #endif /* CFG_SUPPORT_TDLS */
  3822. } /* end of aisFsmRoamingDisconnectPrevAP() */
  3823. /*----------------------------------------------------------------------------*/
  3824. /*!
  3825. * @brief This function will update the contain of BSS_INFO_T for AIS network once
  3826. * the roaming was completed.
  3827. *
  3828. * @param IN prAdapter Pointer to the Adapter structure.
  3829. * prStaRec StaRec of roaming AP
  3830. * prAssocRspSwRfb
  3831. *
  3832. * @retval None
  3833. */
  3834. /*----------------------------------------------------------------------------*/
  3835. VOID aisUpdateBssInfoForRoamingAP(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec, IN P_SW_RFB_T prAssocRspSwRfb)
  3836. {
  3837. P_BSS_INFO_T prAisBssInfo;
  3838. DBGLOG(AIS, LOUD, "aisUpdateBssInfoForRoamingAP()");
  3839. ASSERT(prAdapter);
  3840. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3841. /* 4 <1.1> Change FW's Media State immediately. */
  3842. aisChangeMediaState(prAdapter, PARAM_MEDIA_STATE_CONNECTED);
  3843. /* 4 <1.2> Deactivate previous AP's STA_RECORD_T in Driver if have. */
  3844. if ((prAisBssInfo->prStaRecOfAP) &&
  3845. (prAisBssInfo->prStaRecOfAP != prStaRec) && (prAisBssInfo->prStaRecOfAP->fgIsInUse)) {
  3846. cnmStaRecChangeState(prAdapter, prAisBssInfo->prStaRecOfAP, STA_STATE_1);
  3847. }
  3848. /* 4 <1.3> Update BSS_INFO_T */
  3849. aisUpdateBssInfoForJOIN(prAdapter, prStaRec, prAssocRspSwRfb);
  3850. /* 4 <1.4> Activate current AP's STA_RECORD_T in Driver. */
  3851. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
  3852. /* 4 <1.6> Indicate Connected Event to Host immediately. */
  3853. /* Require BSSID, Association ID, Beacon Interval.. from AIS_BSS_INFO_T */
  3854. aisIndicationOfMediaStateToHost(prAdapter, PARAM_MEDIA_STATE_CONNECTED, FALSE);
  3855. } /* end of aisFsmRoamingUpdateBss() */
  3856. #endif /* CFG_SUPPORT_ROAMING */
  3857. /*----------------------------------------------------------------------------*/
  3858. /*!
  3859. * @brief Check if there is any pending request and remove it (optional)
  3860. *
  3861. * @param prAdapter
  3862. * eReqType
  3863. * bRemove
  3864. *
  3865. * @return TRUE
  3866. * FALSE
  3867. */
  3868. /*----------------------------------------------------------------------------*/
  3869. BOOLEAN aisFsmIsRequestPending(IN P_ADAPTER_T prAdapter, IN ENUM_AIS_REQUEST_TYPE_T eReqType, IN BOOLEAN bRemove)
  3870. {
  3871. P_AIS_FSM_INFO_T prAisFsmInfo;
  3872. P_AIS_REQ_HDR_T prPendingReqHdr, prPendingReqHdrNext;
  3873. ASSERT(prAdapter);
  3874. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3875. /* traverse through pending request list */
  3876. LINK_FOR_EACH_ENTRY_SAFE(prPendingReqHdr,
  3877. prPendingReqHdrNext, &(prAisFsmInfo->rPendingReqList), rLinkEntry, AIS_REQ_HDR_T) {
  3878. /* check for specified type */
  3879. if (prPendingReqHdr->eReqType == eReqType) {
  3880. /* check if need to remove */
  3881. if (bRemove == TRUE) {
  3882. LINK_REMOVE_KNOWN_ENTRY(&(prAisFsmInfo->rPendingReqList),
  3883. &(prPendingReqHdr->rLinkEntry));
  3884. cnmMemFree(prAdapter, prPendingReqHdr);
  3885. }
  3886. return TRUE;
  3887. }
  3888. }
  3889. return FALSE;
  3890. }
  3891. /*----------------------------------------------------------------------------*/
  3892. /*!
  3893. * @brief Get next pending request
  3894. *
  3895. * @param prAdapter
  3896. *
  3897. * @return P_AIS_REQ_HDR_T
  3898. */
  3899. /*----------------------------------------------------------------------------*/
  3900. P_AIS_REQ_HDR_T aisFsmGetNextRequest(IN P_ADAPTER_T prAdapter)
  3901. {
  3902. P_AIS_FSM_INFO_T prAisFsmInfo;
  3903. P_AIS_REQ_HDR_T prPendingReqHdr;
  3904. ASSERT(prAdapter);
  3905. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3906. LINK_REMOVE_HEAD(&(prAisFsmInfo->rPendingReqList), prPendingReqHdr, P_AIS_REQ_HDR_T);
  3907. return prPendingReqHdr;
  3908. }
  3909. /*----------------------------------------------------------------------------*/
  3910. /*!
  3911. * @brief Insert a new request
  3912. *
  3913. * @param prAdapter
  3914. * eReqType
  3915. *
  3916. * @return TRUE
  3917. * FALSE
  3918. */
  3919. /*----------------------------------------------------------------------------*/
  3920. BOOLEAN aisFsmInsertRequest(IN P_ADAPTER_T prAdapter, IN ENUM_AIS_REQUEST_TYPE_T eReqType)
  3921. {
  3922. P_AIS_REQ_HDR_T prAisReq;
  3923. P_AIS_FSM_INFO_T prAisFsmInfo;
  3924. ASSERT(prAdapter);
  3925. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3926. prAisReq = (P_AIS_REQ_HDR_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(AIS_REQ_HDR_T));
  3927. if (!prAisReq) {
  3928. ASSERT(0); /* Can't generate new message */
  3929. return FALSE;
  3930. }
  3931. prAisReq->eReqType = eReqType;
  3932. /* attach request into pending request list */
  3933. LINK_INSERT_TAIL(&prAisFsmInfo->rPendingReqList, &prAisReq->rLinkEntry);
  3934. return TRUE;
  3935. }
  3936. /*----------------------------------------------------------------------------*/
  3937. /*!
  3938. * @brief Flush all pending requests
  3939. *
  3940. * @param prAdapter
  3941. *
  3942. * @return (none)
  3943. */
  3944. /*----------------------------------------------------------------------------*/
  3945. VOID aisFsmFlushRequest(IN P_ADAPTER_T prAdapter)
  3946. {
  3947. P_AIS_REQ_HDR_T prAisReq;
  3948. ASSERT(prAdapter);
  3949. while ((prAisReq = aisFsmGetNextRequest(prAdapter)) != NULL)
  3950. cnmMemFree(prAdapter, prAisReq);
  3951. }
  3952. VOID aisFsmRunEventRemainOnChannel(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  3953. {
  3954. P_MSG_REMAIN_ON_CHANNEL_T prRemainOnChannel;
  3955. P_AIS_FSM_INFO_T prAisFsmInfo;
  3956. P_CONNECTION_SETTINGS_T prConnSettings;
  3957. DEBUGFUNC("aisFsmRunEventRemainOnChannel()");
  3958. ASSERT(prAdapter);
  3959. ASSERT(prMsgHdr);
  3960. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3961. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  3962. prRemainOnChannel = (P_MSG_REMAIN_ON_CHANNEL_T) prMsgHdr;
  3963. /* record parameters */
  3964. prAisFsmInfo->rChReqInfo.eBand = prRemainOnChannel->eBand;
  3965. prAisFsmInfo->rChReqInfo.eSco = prRemainOnChannel->eSco;
  3966. prAisFsmInfo->rChReqInfo.ucChannelNum = prRemainOnChannel->ucChannelNum;
  3967. prAisFsmInfo->rChReqInfo.u4DurationMs = prRemainOnChannel->u4DurationMs;
  3968. prAisFsmInfo->rChReqInfo.u8Cookie = prRemainOnChannel->u8Cookie;
  3969. if (prAisFsmInfo->eCurrentState == AIS_STATE_IDLE || prAisFsmInfo->eCurrentState == AIS_STATE_NORMAL_TR) {
  3970. /* transit to next state */
  3971. aisFsmSteps(prAdapter, AIS_STATE_REQ_REMAIN_ON_CHANNEL);
  3972. } else {
  3973. aisFsmInsertRequest(prAdapter, AIS_REQUEST_REMAIN_ON_CHANNEL);
  3974. }
  3975. /* free messages */
  3976. cnmMemFree(prAdapter, prMsgHdr);
  3977. }
  3978. VOID aisFsmRunEventCancelRemainOnChannel(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  3979. {
  3980. P_AIS_FSM_INFO_T prAisFsmInfo;
  3981. P_BSS_INFO_T prAisBssInfo;
  3982. P_MSG_CANCEL_REMAIN_ON_CHANNEL_T prCancelRemainOnChannel;
  3983. ASSERT(prAdapter);
  3984. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  3985. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  3986. prCancelRemainOnChannel = (P_MSG_CANCEL_REMAIN_ON_CHANNEL_T) prMsgHdr;
  3987. /* 1. Check the cookie first */
  3988. if (prCancelRemainOnChannel->u8Cookie == prAisFsmInfo->rChReqInfo.u8Cookie) {
  3989. /* 2. release channel privilege/request */
  3990. if (prAisFsmInfo->eCurrentState == AIS_STATE_REQ_REMAIN_ON_CHANNEL) {
  3991. /* 2.1 elease channel */
  3992. aisFsmReleaseCh(prAdapter);
  3993. } else if (prAisFsmInfo->eCurrentState == AIS_STATE_REMAIN_ON_CHANNEL) {
  3994. /* 2.1 release channel */
  3995. aisFsmReleaseCh(prAdapter);
  3996. /* 2.2 stop channel timeout timer */
  3997. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer);
  3998. }
  3999. /* 3. clear pending request of remain_on_channel */
  4000. aisFsmIsRequestPending(prAdapter, AIS_REQUEST_REMAIN_ON_CHANNEL, TRUE);
  4001. /* 4. decide which state to retreat */
  4002. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED)
  4003. aisFsmSteps(prAdapter, AIS_STATE_NORMAL_TR);
  4004. else
  4005. aisFsmSteps(prAdapter, AIS_STATE_IDLE);
  4006. }
  4007. /* 5. free message */
  4008. cnmMemFree(prAdapter, prMsgHdr);
  4009. }
  4010. VOID aisFsmRunEventMgmtFrameTx(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
  4011. {
  4012. P_AIS_FSM_INFO_T prAisFsmInfo;
  4013. P_MSG_MGMT_TX_REQUEST_T prMgmtTxMsg = (P_MSG_MGMT_TX_REQUEST_T) NULL;
  4014. do {
  4015. ASSERT_BREAK((prAdapter != NULL) && (prMsgHdr != NULL));
  4016. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4017. /* prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]); */
  4018. if (prAisFsmInfo == NULL)
  4019. break;
  4020. prMgmtTxMsg = (P_MSG_MGMT_TX_REQUEST_T) prMsgHdr;
  4021. aisFuncTxMgmtFrame(prAdapter,
  4022. &prAisFsmInfo->rMgmtTxInfo, prMgmtTxMsg->prMgmtMsduInfo, prMgmtTxMsg->u8Cookie);
  4023. } while (FALSE);
  4024. if (prMsgHdr)
  4025. cnmMemFree(prAdapter, prMsgHdr);
  4026. } /* aisFsmRunEventMgmtFrameTx */
  4027. VOID aisFsmRunEventChannelTimeout(IN P_ADAPTER_T prAdapter, ULONG ulParam)
  4028. {
  4029. P_AIS_FSM_INFO_T prAisFsmInfo;
  4030. P_BSS_INFO_T prAisBssInfo;
  4031. DEBUGFUNC("aisFsmRunEventRemainOnChannel()");
  4032. ASSERT(prAdapter);
  4033. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4034. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  4035. if (prAisFsmInfo->eCurrentState == AIS_STATE_REMAIN_ON_CHANNEL) {
  4036. /* 1. release channel */
  4037. aisFsmReleaseCh(prAdapter);
  4038. /* 2. stop channel timeout timer */
  4039. cnmTimerStopTimer(prAdapter, &prAisFsmInfo->rChannelTimeoutTimer);
  4040. /* 3. expiration indication to upper layer */
  4041. kalRemainOnChannelExpired(prAdapter->prGlueInfo,
  4042. prAisFsmInfo->rChReqInfo.u8Cookie,
  4043. prAisFsmInfo->rChReqInfo.eBand,
  4044. prAisFsmInfo->rChReqInfo.eSco, prAisFsmInfo->rChReqInfo.ucChannelNum);
  4045. /* 4. decide which state to retreat */
  4046. if (prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED)
  4047. aisFsmSteps(prAdapter, AIS_STATE_NORMAL_TR);
  4048. else
  4049. aisFsmSteps(prAdapter, AIS_STATE_IDLE);
  4050. } else {
  4051. DBGLOG(AIS, WARN, "Unexpected remain_on_channel timeout event\n");
  4052. #if DBG
  4053. DBGLOG(AIS, STATE, "CURRENT State: [%s]\n", apucDebugAisState[prAisFsmInfo->eCurrentState]);
  4054. #else
  4055. DBGLOG(AIS, STATE, "[%d] CURRENT State: [%d]\n", DBG_AIS_IDX, prAisFsmInfo->eCurrentState);
  4056. #endif
  4057. }
  4058. }
  4059. WLAN_STATUS
  4060. aisFsmRunEventMgmtFrameTxDone(IN P_ADAPTER_T prAdapter,
  4061. IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  4062. {
  4063. P_AIS_FSM_INFO_T prAisFsmInfo;
  4064. P_AIS_MGMT_TX_REQ_INFO_T prMgmtTxReqInfo = (P_AIS_MGMT_TX_REQ_INFO_T) NULL;
  4065. BOOLEAN fgIsSuccess = FALSE;
  4066. do {
  4067. ASSERT_BREAK((prAdapter != NULL) && (prMsduInfo != NULL));
  4068. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4069. prMgmtTxReqInfo = &(prAisFsmInfo->rMgmtTxInfo);
  4070. if (rTxDoneStatus != TX_RESULT_SUCCESS) {
  4071. DBGLOG(AIS, ERROR, "Mgmt Frame TX Fail, Status:%d.\n", rTxDoneStatus);
  4072. } else {
  4073. fgIsSuccess = TRUE;
  4074. /* printk("Mgmt Frame TX Done.\n"); */
  4075. }
  4076. if (prMgmtTxReqInfo->prMgmtTxMsdu == prMsduInfo) {
  4077. kalIndicateMgmtTxStatus(prAdapter->prGlueInfo,
  4078. prMgmtTxReqInfo->u8Cookie,
  4079. fgIsSuccess, prMsduInfo->prPacket, (UINT_32) prMsduInfo->u2FrameLength);
  4080. prMgmtTxReqInfo->prMgmtTxMsdu = NULL;
  4081. }
  4082. } while (FALSE);
  4083. return WLAN_STATUS_SUCCESS;
  4084. } /* aisFsmRunEventMgmtFrameTxDone */
  4085. WLAN_STATUS
  4086. aisFuncTxMgmtFrame(IN P_ADAPTER_T prAdapter,
  4087. IN P_AIS_MGMT_TX_REQ_INFO_T prMgmtTxReqInfo, IN P_MSDU_INFO_T prMgmtTxMsdu, IN UINT_64 u8Cookie)
  4088. {
  4089. WLAN_STATUS rWlanStatus = WLAN_STATUS_SUCCESS;
  4090. P_MSDU_INFO_T prTxMsduInfo = (P_MSDU_INFO_T) NULL;
  4091. P_WLAN_MAC_HEADER_T prWlanHdr = (P_WLAN_MAC_HEADER_T) NULL;
  4092. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  4093. do {
  4094. ASSERT_BREAK((prAdapter != NULL) && (prMgmtTxReqInfo != NULL));
  4095. if (prMgmtTxReqInfo->fgIsMgmtTxRequested) {
  4096. /* 1. prMgmtTxReqInfo->prMgmtTxMsdu != NULL */
  4097. /* Packet on driver, not done yet, drop it. */
  4098. prTxMsduInfo = prMgmtTxReqInfo->prMgmtTxMsdu;
  4099. if (prTxMsduInfo != NULL) {
  4100. kalIndicateMgmtTxStatus(prAdapter->prGlueInfo,
  4101. prMgmtTxReqInfo->u8Cookie,
  4102. FALSE,
  4103. prTxMsduInfo->prPacket, (UINT_32) prTxMsduInfo->u2FrameLength);
  4104. /* Leave it to TX Done handler. */
  4105. /* cnmMgtPktFree(prAdapter, prTxMsduInfo); */
  4106. prMgmtTxReqInfo->prMgmtTxMsdu = NULL;
  4107. }
  4108. /* 2. prMgmtTxReqInfo->prMgmtTxMsdu == NULL */
  4109. /* Packet transmitted, wait tx done. (cookie issue) */
  4110. }
  4111. ASSERT(prMgmtTxReqInfo->prMgmtTxMsdu == NULL);
  4112. prWlanHdr = (P_WLAN_MAC_HEADER_T) ((ULONG) prMgmtTxMsdu->prPacket + MAC_TX_RESERVED_FIELD);
  4113. prStaRec = cnmGetStaRecByAddress(prAdapter, NETWORK_TYPE_AIS_INDEX, prWlanHdr->aucAddr1);
  4114. prMgmtTxMsdu->ucNetworkType = (UINT_8) NETWORK_TYPE_AIS_INDEX;
  4115. prMgmtTxReqInfo->u8Cookie = u8Cookie;
  4116. prMgmtTxReqInfo->prMgmtTxMsdu = prMgmtTxMsdu;
  4117. prMgmtTxReqInfo->fgIsMgmtTxRequested = TRUE;
  4118. prMgmtTxMsdu->eSrc = TX_PACKET_MGMT;
  4119. prMgmtTxMsdu->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
  4120. prMgmtTxMsdu->ucStaRecIndex = (prStaRec != NULL) ? (prStaRec->ucIndex) : (0xFF);
  4121. if (prStaRec != NULL) {
  4122. /* Do nothing */
  4123. /* printk("Mgmt with station record: %pM .\n", prStaRec->aucMacAddr); */
  4124. }
  4125. prMgmtTxMsdu->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN; /* TODO: undcertain. */
  4126. prMgmtTxMsdu->fgIs802_1x = FALSE;
  4127. prMgmtTxMsdu->fgIs802_11 = TRUE;
  4128. prMgmtTxMsdu->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
  4129. prMgmtTxMsdu->pfTxDoneHandler = aisFsmRunEventMgmtFrameTxDone;
  4130. prMgmtTxMsdu->fgIsBasicRate = TRUE;
  4131. DBGLOG(AIS, TRACE, "Mgmt seq NO. %d .\n", prMgmtTxMsdu->ucTxSeqNum);
  4132. nicTxEnqueueMsdu(prAdapter, prMgmtTxMsdu);
  4133. } while (FALSE);
  4134. return rWlanStatus;
  4135. } /* aisFuncTxMgmtFrame */
  4136. /*----------------------------------------------------------------------------*/
  4137. /*!
  4138. * @brief This function will validate the Rx Action Frame and indicate to uppoer layer
  4139. * if the specified conditions were matched.
  4140. *
  4141. * @param[in] prAdapter Pointer to the Adapter structure.
  4142. * @param[in] prSwRfb Pointer to SW RFB data structure.
  4143. * @param[out] pu4ControlFlags Control flags for replying the Probe Response
  4144. *
  4145. * @retval none
  4146. */
  4147. /*----------------------------------------------------------------------------*/
  4148. VOID aisFuncValidateRxActionFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  4149. {
  4150. P_AIS_FSM_INFO_T prAisFsmInfo = (P_AIS_FSM_INFO_T) NULL;
  4151. DEBUGFUNC("aisFuncValidateRxActionFrame");
  4152. do {
  4153. ASSERT_BREAK((prAdapter != NULL) && (prSwRfb != NULL));
  4154. prAisFsmInfo = &(prAdapter->rWifiVar.rAisFsmInfo);
  4155. if (1 /* prAisFsmInfo->u4AisPacketFilter & PARAM_PACKET_FILTER_ACTION_FRAME */) {
  4156. /* Leave the action frame to wpa_supplicant. */
  4157. kalIndicateRxMgmtFrame(prAdapter->prGlueInfo, prSwRfb);
  4158. }
  4159. } while (FALSE);
  4160. return;
  4161. } /* aisFuncValidateRxActionFrame */